Skip to content

Commit 797c900

Browse files
feat: new onboarding workflow (#1106)
- Add a skip button for Step 2. - Add option to set the status of the imported feed. - Created import feed settings will now be set to draft to allow the user to run it manually. - On Feed choice, redirect to the created import feed settings page instead of the import feeds settings list.
1 parent 45cec8b commit 797c900

File tree

4 files changed

+316
-214
lines changed

4 files changed

+316
-214
lines changed

includes/admin/feedzy-rss-feeds-admin.php

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,34 +1786,42 @@ private function setup_wizard_install_plugin() {
17861786
* Step: 4 skip and subscribe process.
17871787
*/
17881788
private function setup_wizard_subscribe_process() {
1789+
check_ajax_referer( FEEDZY_BASEFILE, 'security' );
1790+
17891791
$segment = 0;
17901792
$wizard_data = get_option( 'feedzy_wizard_data', array() );
17911793
$integrate_with = ! empty( $wizard_data['integrate_with'] ) ? $wizard_data['integrate_with'] : '';
1792-
$post_type = ! empty( $wizard_data['post_type'] ) ? $wizard_data['post_type'] : '';
17931794
$page_id = ! empty( $wizard_data['page_id'] ) ? $wizard_data['page_id'] : '';
1795+
$job_id = ! empty( $wizard_data['job_id'] ) ? $wizard_data['job_id'] : '';
17941796
$response = array(
17951797
'status' => 0,
17961798
'redirect_to' => '',
17971799
'message' => '',
17981800
);
17991801

1800-
$with_subscribe = ! empty( $_POST['with_subscribe'] ) ? (bool) $_POST['with_subscribe'] : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
1801-
$email = ! empty( $_POST['email'] ) ? filter_input( INPUT_POST, 'email', FILTER_SANITIZE_EMAIL ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
1802+
$with_subscribe = ! empty( $_POST['with_subscribe'] ) ? (bool) $_POST['with_subscribe'] : '';
1803+
$email = ! empty( $_POST['email'] ) ? filter_input( INPUT_POST, 'email', FILTER_SANITIZE_EMAIL ) : '';
1804+
if ( empty( $integrate_with ) ) {
1805+
$integrate_with = ! empty( $_POST['integrate_with'] ) ? sanitize_text_field( $_POST['integrate_with'] ) : '';
1806+
}
18021807

18031808
if ( 'feed' === $integrate_with ) {
1804-
$segment = 1;
1805-
$redirect_to = get_post_type_archive_link( $post_type );
1806-
$response = array(
1809+
$segment = 1;
1810+
$response = array(
18071811
'status' => 1,
1808-
'redirect_to' => $redirect_to,
1809-
'message' => __( 'Redirecting to archive page', 'feedzy-rss-feeds' ),
1812+
'redirect_to' => add_query_arg( 'post_type', 'feedzy_imports', admin_url( 'edit.php' ) ),
1813+
'message' => __( 'Redirecting to Feedzy dashboard', 'feedzy-rss-feeds' ),
18101814
);
1811-
if ( false === $redirect_to ) {
1812-
$response = array(
1813-
'status' => 1,
1814-
'redirect_to' => add_query_arg( 'post_type', 'feedzy_imports', admin_url( 'edit.php' ) ),
1815-
'message' => __( 'Redirecting to Feedzy dashboard', 'feedzy-rss-feeds' ),
1815+
1816+
if ( $job_id ) {
1817+
$response['redirect_to'] = add_query_arg(
1818+
array(
1819+
'post' => $job_id,
1820+
'action' => 'edit',
1821+
),
1822+
admin_url( 'post.php' )
18161823
);
1824+
$response['message'] = __( 'Redirecting to import feed', 'feedzy-rss-feeds' );
18171825
}
18181826
} elseif ( 'shortcode' === $integrate_with ) {
18191827
$segment = 2;

includes/admin/feedzy-rss-feeds-import.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3489,6 +3489,7 @@ private function wizard_import_feed() {
34893489
check_ajax_referer( FEEDZY_BASEFILE, 'security' );
34903490

34913491
$post_type = ! empty( $_POST['post_type'] ) ? sanitize_text_field( wp_unslash( $_POST['post_type'] ) ) : '';
3492+
$post_status = ! empty( $_POST['post_status'] ) ? sanitize_text_field( wp_unslash( $_POST['post_status'] ) ) : '';
34923493
$wizard_data = get_option( 'feedzy_wizard_data', array() );
34933494
$wizard_data = ! empty( $wizard_data ) ? $wizard_data : array();
34943495
$wizard_data['post_type'] = $post_type;
@@ -3514,7 +3515,7 @@ private function wizard_import_feed() {
35143515
array(
35153516
'post_title' => $post_title,
35163517
'post_type' => 'feedzy_imports',
3517-
'post_status' => 'publish',
3518+
'post_status' => 'draft',
35183519
)
35193520
);
35203521
Feedzy_Rss_Feeds_Usage::get_instance()->track_import_creation();
@@ -3526,15 +3527,15 @@ private function wizard_import_feed() {
35263527
update_post_meta( $job_id, 'import_post_date', '[#item_date]' );
35273528
update_post_meta( $job_id, 'import_post_content', '[[{"value":"%5B%7B%22id%22%3A%22%22%2C%22tag%22%3A%22item_content%22%2C%22data%22%3A%7B%7D%7D%5D"}]]' );
35283529
update_post_meta( $job_id, 'import_post_type', $post_type );
3529-
update_post_meta( $job_id, 'import_post_status', 'publish' );
3530+
update_post_meta( $job_id, 'import_post_status', $post_status );
35303531
update_post_meta( $job_id, 'import_post_featured_img', '[#item_image]' );
35313532

35323533
// Update wizard data.
3534+
$wizard_data['job_id'] = $job_id;
35333535
update_option( 'feedzy_wizard_data', $wizard_data );
35343536

3535-
$job = get_post( $job_id );
3536-
$count = $this->run_job( $job, 10 );
3537-
do_action( 'feedzy_run_cron_extra', $job );
3537+
$job = get_post( $job_id );
3538+
$count = $this->run_job( $job, 10 );
35383539
$response = array(
35393540
'status' => $count > 0,
35403541
);

includes/layouts/setup-wizard.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
$wizard_data = get_option( 'feedzy_wizard_data', array() );
2323
$feed_source = ! empty( $wizard_data['feed'] ) ? $wizard_data['feed'] : '';
2424
}
25+
$published_status = array( 'publish', 'draft' );
2526

2627
?>
2728
<div class="feedzy-wizard-wrap feedzy-wrap">
@@ -147,6 +148,11 @@
147148
?>
148149
<span class="dashicons dashicons-arrow-right-alt"></span>
149150
</button>
151+
<button class="btn btn-ghost btn-skip" style="color: #757575;">
152+
<?php
153+
esc_html_e( 'Skip', 'feedzy-rss-feeds' );
154+
?>
155+
</button>
150156
<span class="spinner"></span>
151157
</div>
152158
</div>
@@ -161,16 +167,42 @@
161167
<div class="feedzy-accordion-item__content border-top">
162168
<div class="fz-form-wrap">
163169
<div class="form-block">
170+
<label class="form-label">
171+
<?php esc_html_e( 'Import as', 'feedzy-rss-feeds' ); ?>
172+
</label>
164173
<div class="mx-320">
165174
<select name="feedzy[wizard_data][import_post_type]" class="form-control feedzy-chosen">
166175
<option value="post"><?php esc_html_e( 'Post', 'feedzy-rss-feeds' ); ?></option>
167176
<option value="page"><?php esc_html_e( 'Page', 'feedzy-rss-feeds' ); ?></option>
168177
</select>
169178
</div>
170179
</div>
180+
<div class="form-block">
181+
<label class="form-label">
182+
<?php esc_html_e( 'Post status', 'feedzy-rss-feeds' ); ?>
183+
</label>
184+
<div class="mx-320">
185+
<select id="feedzy_post_status" class="form-control feedzy-chosen" name="feedzy_meta_data[import_post_status]">
186+
<?php
187+
foreach ( $published_status as $_status ) {
188+
?>
189+
<option value="<?php echo esc_attr( $_status ); ?>">
190+
<?php echo esc_html( ucfirst( $_status ) ); ?>
191+
</option>
192+
<?php
193+
}
194+
?>
195+
</select>
196+
</div>
197+
</div>
171198
<div class="form-block">
172199
<button class="btn btn-primary fz-wizard-feed-import">
173-
<?php esc_html_e( 'Save and Import', 'feedzy-rss-feeds' ); ?> <span class="dashicons dashicons-arrow-right-alt"></span>
200+
<?php esc_html_e( 'Create a draft import', 'feedzy-rss-feeds' ); ?> <span class="dashicons dashicons-arrow-right-alt"></span>
201+
</button>
202+
<button class="btn btn-ghost btn-skip" style="color: #757575;">
203+
<?php
204+
esc_html_e( 'Skip', 'feedzy-rss-feeds' );
205+
?>
174206
</button>
175207
<span class="spinner"></span>
176208
</div>

0 commit comments

Comments
 (0)