From 51f893fcbfc24d9f4412a7c32b7bfa63987816b6 Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Fri, 15 Aug 2025 17:02:56 +0530 Subject: [PATCH 1/6] feat: improve onboarding import process --- includes/admin/feedzy-rss-feeds-admin.php | 17 +++ includes/admin/feedzy-rss-feeds-import.php | 22 +++- includes/layouts/setup-wizard.php | 63 +++++++++--- includes/views/css/style-wizard.css | 29 ++++++ js/feedzy-setup-wizard.js | 114 +++++++++++++++++++++ 5 files changed, 231 insertions(+), 14 deletions(-) diff --git a/includes/admin/feedzy-rss-feeds-admin.php b/includes/admin/feedzy-rss-feeds-admin.php index a0b4ae184..8c7922f9d 100644 --- a/includes/admin/feedzy-rss-feeds-admin.php +++ b/includes/admin/feedzy-rss-feeds-admin.php @@ -1978,6 +1978,10 @@ public function feedzy_load_setup_wizard_page() { * Enqueue setup wizard required scripts. */ public function feedzy_enqueue_setup_wizard_scripts() { + if ( ! did_action( 'wp_enqueue_media' ) ) { + wp_enqueue_media(); + } + wp_enqueue_style( $this->plugin_name . '_chosen' ); wp_enqueue_style( $this->plugin_name . '_smart_wizard', FEEDZY_ABSURL . 'css/smart_wizard_all.min.css', array(), $this->version ); wp_enqueue_style( $this->plugin_name . '_setup_wizard', FEEDZY_ABSURL . 'includes/views/css/style-wizard.css', array( $this->plugin_name . '-settings' ), $this->version, 'all' ); @@ -2003,6 +2007,19 @@ public function feedzy_enqueue_setup_wizard_scripts() { 'firstButtonText' => __( 'Create Page', 'feedzy-rss-feeds' ), 'secondButtonText' => __( 'Do not create', 'feedzy-rss-feeds' ), ), + 'mediaUploadText' => array( + 'iframeTitle' => __( 'Select image', 'feedzy-rss-feeds' ), + 'iframeButton' => __( 'Set default image', 'feedzy-rss-feeds' ), + 'actionButtonTextOne' => __( 'Choose image', 'feedzy-rss-feeds' ), + 'actionButtonTextTwo' => __( 'Replace image', 'feedzy-rss-feeds' ), + 'actionButtonTextThree' => __( 'Remove image', 'feedzy-rss-feeds' ), + ), + 'dryRun' => array( + 'loading' => '

' . __( 'Processing the source and loading the items that will be imported when it runs', 'feedzy-rss-feeds' ) . '...

' + . '

' . __( 'Please note that if some of these items have already have been imported in previous runs with the same filters, they may be shown here but will not be imported again.', 'feedzy-rss-feeds' ) . '

' + . '

', + 'title' => __( 'Importable Items', 'feedzy-rss-feeds' ), + ), ) ); } diff --git a/includes/admin/feedzy-rss-feeds-import.php b/includes/admin/feedzy-rss-feeds-import.php index a343ce729..c546ccf50 100644 --- a/includes/admin/feedzy-rss-feeds-import.php +++ b/includes/admin/feedzy-rss-feeds-import.php @@ -3951,6 +3951,8 @@ private function wizard_import_feed() { $post_type = ! empty( $_POST['post_type'] ) ? sanitize_text_field( wp_unslash( $_POST['post_type'] ) ) : ''; $post_status = ! empty( $_POST['post_status'] ) ? sanitize_text_field( wp_unslash( $_POST['post_status'] ) ) : ''; + $fallback_image = ! empty( $_POST['fallback_image'] ) ? sanitize_text_field( wp_unslash( $_POST['fallback_image'] ) ) : ''; + $excluded_post_title = ! empty( $_POST['excluded_post_title'] ) ? sanitize_text_field( wp_unslash( $_POST['excluded_post_title'] ) ) : ''; $wizard_data = get_option( 'feedzy_wizard_data', array() ); $wizard_data = ! empty( $wizard_data ) ? $wizard_data : array(); $wizard_data['post_type'] = $post_type; @@ -3994,7 +3996,25 @@ private function wizard_import_feed() { // Update wizard data. $wizard_data['job_id'] = $job_id; update_option( 'feedzy_wizard_data', $wizard_data ); - + + $filter_conditions = array( + 'match' => 'all', + 'conditions' => array(), + ); + + if ( ! empty( $excluded_post_title ) ) { + $filter_conditions['conditions'] = array( + array( + 'field' => 'title', + 'operator' => 'not_contains', + 'value' => $excluded_post_title, + ), + ); + } + + update_post_meta( $job_id, 'filter_conditions', wp_json_encode( $filter_conditions ) ); + update_post_meta( $job_id, 'default_thumbnail_id', $fallback_image ); + $response = array( 'status' => true, ); diff --git a/includes/layouts/setup-wizard.php b/includes/layouts/setup-wizard.php index d729e9eab..f493602de 100644 --- a/includes/layouts/setup-wizard.php +++ b/includes/layouts/setup-wizard.php @@ -24,6 +24,7 @@ } $published_status = array( 'publish', 'draft' ); +add_thickbox(); ?>
@@ -177,25 +178,61 @@
+
+
+
+ +
+ +
+
+
+ +
+ + + + + +
+ +
+
+
+
+
-
- +
+ +
+ +
+ diff --git a/includes/views/css/style-wizard.css b/includes/views/css/style-wizard.css index 8f963126f..19f840d05 100644 --- a/includes/views/css/style-wizard.css +++ b/includes/views/css/style-wizard.css @@ -471,3 +471,32 @@ .feedzy-accordion-item__title h2 { margin-bottom: 0; } + +#TB_ajaxContent ul { + list-style: decimal; + margin-left: 20px; +} + +#TB_ajaxContent ul li { + padding: 5px !important; +} + +#TB_ajaxContent p.loading-img { + text-align: center; +} + +#TB_ajaxContent.loaded p.hide-when-loaded { + display: none; +} + +#TB_ajaxContent div.dry_run span { + display: block; +} + +#TB_ajaxContent div.dry_run span i.pass { + color: #149714; +} + +#TB_ajaxContent div.dry_run span i.fail { + color: #ca4a1f; +} \ No newline at end of file diff --git a/js/feedzy-setup-wizard.js b/js/feedzy-setup-wizard.js index a1a744cb1..603308c2f 100644 --- a/js/feedzy-setup-wizard.js +++ b/js/feedzy-setup-wizard.js @@ -211,6 +211,8 @@ jQuery(function ($) { post_status: $( 'select[name="feedzy_meta_data[import_post_status]"]' ).val(), + fallback_image: $('input[name="feedzy_meta_data[default_thumbnail_id]"]').val(), + excluded_post_title: $('input[name="feedzy_meta_data[exclude_post_title]"]').val(), action: 'feedzy', _action: 'wizard_import_feed', }, @@ -359,4 +361,116 @@ jQuery(function ($) { // Init chosen selectbox. $('.feedzy-chosen').chosen({ width: '100%' }); + + // on upload button click + $( 'body' ).on( 'click', '.feedzy-open-media', function( e ) { + e.preventDefault(); + const button = $( this ), + wp_media_uploader = wp.media( { + title: feedzySetupWizardData.mediaUploadText.iframeTitle, + library : { + type : 'image' + }, + button: { + text: feedzySetupWizardData.mediaUploadText.iframeButton + }, + multiple: true + } ).on( 'select', function() { // it also has "open" and "close" events + const selectedAttachments = wp_media_uploader.state().get( 'selection' ); + const countSelected = selectedAttachments?.toJSON()?.length; + button.parents( '.fz-form-group' ).find( '.feedzy-media-preview' ).remove(); + // Display image preview when a single image is selected. + if ( 1 === countSelected ) { + const attachment = selectedAttachments.first().toJSON(); + let attachmentUrl = attachment.url; + if ( attachment.sizes.thumbnail ) { + attachmentUrl = attachment.sizes.thumbnail.url; + } + if ( $( '.feedzy-media-preview' ).length ) { + $( '.feedzy-media-preview' ).find( 'img' ).attr( 'src', attachmentUrl ); + } else { + $( '
' ).insertBefore( button.parent() ); + } + } else { + $( + '
' + + selectedAttachments + ?.toJSON() + ?.map(({ url, sizes }) => { + if (sizes?.thumbnail) { + url = sizes.thumbnail.url; + } + return ``; + }) + .join('') + + '
' + ).insertBefore(button.parent()); + } + // Get all selected attachment ids. + const ids = selectedAttachments.map( function( image ) { + return image.id; + } ).join( ',' ); + + button.parent().find( '.feedzy-remove-media' ).addClass( 'is-show' ); + button.parent().find( 'input:hidden' ).val( ids ).trigger( 'change' ); + $( '.feedzy-open-media' ).html( feedzySetupWizardData.mediaUploadText.actionButtonTextTwo ); + } ); + + wp_media_uploader.on(' open', function() { + const selectedVal = button.parent().find( 'input:hidden' ).val(); + if ( '' === selectedVal ) { + return; + } + const selection = wp_media_uploader.state().get('selection'); + + selectedVal.split(',').forEach(function( id ) { + const attachment = wp.media.attachment( id ); + attachment.fetch(); + selection.add(attachment ? [attachment] : []); + }); + } ); + + wp_media_uploader.open(); + }); + + $(document).on( 'click', '.feedzy-remove-media', function( e ) { + $(this) + e.preventDefault(); + $('.feedzy-media-preview').remove(); + $(this).removeClass('is-show'); + + // Reset the input. + $('input[name="feedzy_meta_data[default_thumbnail_id]"]').val(0); + $('.feedzy-open-media').html(feedzySetupWizardData.mediaUploadText.actionButtonTextOne); + } ); + + $('#preflight').on('click', function (e) { + e.preventDefault(); + const $fields = {}; + // collect all elements. + $('#smartwizard') + .find(':input') + .each(function (index, element) { + if ('undefined' === typeof $(element).attr('name')) { + return; + } + $fields[$(element).attr('name')] = $(element).val(); + }); + $fields['feedzy_meta_data[source]'] = $('#wizard_feed_source').val(); + tb_show(feedzySetupWizardData.dryRun.title, 'TB_inline?'); + $('#TB_ajaxContent').html(feedzySetupWizardData.dryRun.loading); + $.post( + ajaxurl, + { + security: window.feedzySetupWizardData.ajax.security, + fields: $.param($fields), + action: 'feedzy', + _action: 'dry_run', + }, + function(data) { + $('#TB_ajaxContent').addClass('loaded'); + $('#TB_ajaxContent div').html(data.data.output); + }, + ); + }); }); From 85bd4606ee84fa66c5e1e42ae04b7fa0d9a434cd Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Mon, 18 Aug 2025 16:04:37 +0530 Subject: [PATCH 2/6] refactor: preview import feed --- includes/admin/feedzy-rss-feeds-admin.php | 2 +- includes/admin/feedzy-rss-feeds-import.php | 7 ++++--- includes/layouts/setup-wizard.php | 10 ++++++---- includes/views/css/style-wizard.css | 6 +++++- js/feedzy-setup-wizard.js | 9 +++++---- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/includes/admin/feedzy-rss-feeds-admin.php b/includes/admin/feedzy-rss-feeds-admin.php index 8c7922f9d..e7c5141f8 100644 --- a/includes/admin/feedzy-rss-feeds-admin.php +++ b/includes/admin/feedzy-rss-feeds-admin.php @@ -2016,7 +2016,7 @@ public function feedzy_enqueue_setup_wizard_scripts() { ), 'dryRun' => array( 'loading' => '

' . __( 'Processing the source and loading the items that will be imported when it runs', 'feedzy-rss-feeds' ) . '...

' - . '

' . __( 'Please note that if some of these items have already have been imported in previous runs with the same filters, they may be shown here but will not be imported again.', 'feedzy-rss-feeds' ) . '

' + . '

' . __( 'Note: Preview does not display filtered results. Filters will be applied when posts are imported.', 'feedzy-rss-feeds' ) . '

' . '

', 'title' => __( 'Importable Items', 'feedzy-rss-feeds' ), ), diff --git a/includes/admin/feedzy-rss-feeds-import.php b/includes/admin/feedzy-rss-feeds-import.php index c546ccf50..74865d7e8 100644 --- a/includes/admin/feedzy-rss-feeds-import.php +++ b/includes/admin/feedzy-rss-feeds-import.php @@ -1392,7 +1392,8 @@ private function run_now() { private function dry_run() { check_ajax_referer( FEEDZY_BASEFILE, 'security' ); - $fields = urldecode( isset( $_POST['fields'] ) ? sanitize_url( $_POST['fields'] ) : '' ); + $fields = urldecode( isset( $_POST['fields'] ) ? sanitize_url( $_POST['fields'] ) : '' ); + $environment = isset( $_POST['environment'] ) ? sanitize_text_field( $_POST['environment'] ) : 'default'; parse_str( $fields, $data ); $feedzy_meta_data = $data['feedzy_meta_data']; @@ -1472,8 +1473,8 @@ function ( $errors, $feed, $url ) { $feedzy_meta_data['import_feed_limit'], '', // should be empty. $feedzy_meta_data['inc_key'], - feedzy_is_pro() ? 'keywords_exc' : '', - feedzy_is_pro() ? $feedzy_meta_data['exc_key'] : '', + feedzy_is_pro() || 'wizard' === $environment ? 'keywords_exc' : '', + feedzy_is_pro() || 'wizard' === $environment ? $feedzy_meta_data['exc_key'] : '', feedzy_is_pro() ? 'keywords_ban' : '', feedzy_is_pro() ? $feedzy_meta_data['exc_key'] : '', implode( ',', $tags ) diff --git a/includes/layouts/setup-wizard.php b/includes/layouts/setup-wizard.php index f493602de..8d61f8c53 100644 --- a/includes/layouts/setup-wizard.php +++ b/includes/layouts/setup-wizard.php @@ -139,6 +139,11 @@
+ + +
- diff --git a/includes/views/css/style-wizard.css b/includes/views/css/style-wizard.css index 19f840d05..1ebd809dc 100644 --- a/includes/views/css/style-wizard.css +++ b/includes/views/css/style-wizard.css @@ -471,7 +471,11 @@ .feedzy-accordion-item__title h2 { margin-bottom: 0; } - +.btn-ghost.disabled { + cursor: none; + pointer-events: none; + color: #757575; +} #TB_ajaxContent ul { list-style: decimal; margin-left: 20px; diff --git a/js/feedzy-setup-wizard.js b/js/feedzy-setup-wizard.js index 603308c2f..080600f9a 100644 --- a/js/feedzy-setup-wizard.js +++ b/js/feedzy-setup-wizard.js @@ -35,7 +35,7 @@ jQuery(function ($) { const feedUrl = $(this).attr('href'); $(this).parents('.fz-row').find('input:text').val(feedUrl); - $('[data-step_number="2"]').removeClass('disabled'); + $('[data-step_number="2"], #preflight').removeClass('disabled'); return false; }); @@ -212,7 +212,7 @@ jQuery(function ($) { 'select[name="feedzy_meta_data[import_post_status]"]' ).val(), fallback_image: $('input[name="feedzy_meta_data[default_thumbnail_id]"]').val(), - excluded_post_title: $('input[name="feedzy_meta_data[exclude_post_title]"]').val(), + excluded_post_title: $('input[name="feedzy_meta_data[exc_key]"]').val(), action: 'feedzy', _action: 'wizard_import_feed', }, @@ -331,9 +331,9 @@ jQuery(function ($) { // Remove disabled class from save button. $(document).on('input', '#wizard_feed_source', function () { if ('' === $(this).val()) { - $('[data-step_number="2"]').addClass('disabled'); + $('[data-step_number="2"], #preflight').addClass('disabled'); } else { - $('[data-step_number="2"]').removeClass('disabled'); + $('[data-step_number="2"], #preflight').removeClass('disabled'); } }); @@ -466,6 +466,7 @@ jQuery(function ($) { fields: $.param($fields), action: 'feedzy', _action: 'dry_run', + environment: 'wizard', }, function(data) { $('#TB_ajaxContent').addClass('loaded'); From d36c8bb8e78fa2ab02f33ed795d04b1c97ed8e59 Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Mon, 18 Aug 2025 18:50:56 +0530 Subject: [PATCH 3/6] remove notice --- includes/admin/feedzy-rss-feeds-admin.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/admin/feedzy-rss-feeds-admin.php b/includes/admin/feedzy-rss-feeds-admin.php index e7c5141f8..50cf3a513 100644 --- a/includes/admin/feedzy-rss-feeds-admin.php +++ b/includes/admin/feedzy-rss-feeds-admin.php @@ -2016,7 +2016,6 @@ public function feedzy_enqueue_setup_wizard_scripts() { ), 'dryRun' => array( 'loading' => '

' . __( 'Processing the source and loading the items that will be imported when it runs', 'feedzy-rss-feeds' ) . '...

' - . '

' . __( 'Note: Preview does not display filtered results. Filters will be applied when posts are imported.', 'feedzy-rss-feeds' ) . '

' . '

', 'title' => __( 'Importable Items', 'feedzy-rss-feeds' ), ), From e07ba948f673e4053e2b0cc9edc2c58eb4e500b0 Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Tue, 19 Aug 2025 12:48:55 +0530 Subject: [PATCH 4/6] refactor: upload single image as fallback image --- js/feedzy-setup-wizard.js | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/js/feedzy-setup-wizard.js b/js/feedzy-setup-wizard.js index 080600f9a..4b304fe31 100644 --- a/js/feedzy-setup-wizard.js +++ b/js/feedzy-setup-wizard.js @@ -374,37 +374,20 @@ jQuery(function ($) { button: { text: feedzySetupWizardData.mediaUploadText.iframeButton }, - multiple: true + multiple: false } ).on( 'select', function() { // it also has "open" and "close" events const selectedAttachments = wp_media_uploader.state().get( 'selection' ); - const countSelected = selectedAttachments?.toJSON()?.length; button.parents( '.fz-form-group' ).find( '.feedzy-media-preview' ).remove(); // Display image preview when a single image is selected. - if ( 1 === countSelected ) { - const attachment = selectedAttachments.first().toJSON(); - let attachmentUrl = attachment.url; - if ( attachment.sizes.thumbnail ) { - attachmentUrl = attachment.sizes.thumbnail.url; - } - if ( $( '.feedzy-media-preview' ).length ) { - $( '.feedzy-media-preview' ).find( 'img' ).attr( 'src', attachmentUrl ); - } else { - $( '
' ).insertBefore( button.parent() ); - } + const attachment = selectedAttachments.first().toJSON(); + let attachmentUrl = attachment.url; + if ( attachment.sizes.thumbnail ) { + attachmentUrl = attachment.sizes.thumbnail.url; + } + if ( $( '.feedzy-media-preview' ).length ) { + $( '.feedzy-media-preview' ).find( 'img' ).attr( 'src', attachmentUrl ); } else { - $( - '
' + - selectedAttachments - ?.toJSON() - ?.map(({ url, sizes }) => { - if (sizes?.thumbnail) { - url = sizes.thumbnail.url; - } - return ``; - }) - .join('') + - '
' - ).insertBefore(button.parent()); + $( '
' ).insertBefore( button.parent() ); } // Get all selected attachment ids. const ids = selectedAttachments.map( function( image ) { From aa1fffe8ca78726347810166fbd21ec4d98cf67f Mon Sep 17 00:00:00 2001 From: Soare Robert-Daniel Date: Tue, 19 Aug 2025 11:40:39 +0300 Subject: [PATCH 5/6] fix: get custom fallback image ID on import settings --- includes/admin/feedzy-rss-feeds-import.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/includes/admin/feedzy-rss-feeds-import.php b/includes/admin/feedzy-rss-feeds-import.php index 74865d7e8..4944c077d 100644 --- a/includes/admin/feedzy-rss-feeds-import.php +++ b/includes/admin/feedzy-rss-feeds-import.php @@ -561,9 +561,14 @@ public function feedzy_import_feed_options() { $default_thumbnail_id = 0; $inherited_thumbnail_id = ! empty( $this->free_settings['general']['default-thumbnail-id'] ) ? (int) $this->free_settings['general']['default-thumbnail-id'] : 0; + $custom_thumbnail_id = get_post_meta( $post->ID, 'default_thumbnail_id', true ); + + if ( is_numeric( $custom_thumbnail_id ) ) { + $default_thumbnail_id = $custom_thumbnail_id; + } + if ( feedzy_is_pro() ) { - $default_thumbnail_id = get_post_meta( $post->ID, 'default_thumbnail_id', true ); - $import_schedule = array( + $import_schedule = array( 'fz_cron_schedule' => ! empty( $this->free_settings['general']['fz_cron_schedule'] ) ? $this->free_settings['general']['fz_cron_schedule'] : '', ); } From 6e9d1078274518208c30516abb41cee83b8f66d3 Mon Sep 17 00:00:00 2001 From: Soare Robert-Daniel Date: Tue, 19 Aug 2025 11:48:17 +0300 Subject: [PATCH 6/6] chore: clean up Remove the old suggestion for filter since preview is now before the filter --- includes/admin/feedzy-rss-feeds-import.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/includes/admin/feedzy-rss-feeds-import.php b/includes/admin/feedzy-rss-feeds-import.php index 4944c077d..9f954c141 100644 --- a/includes/admin/feedzy-rss-feeds-import.php +++ b/includes/admin/feedzy-rss-feeds-import.php @@ -1397,8 +1397,7 @@ private function run_now() { private function dry_run() { check_ajax_referer( FEEDZY_BASEFILE, 'security' ); - $fields = urldecode( isset( $_POST['fields'] ) ? sanitize_url( $_POST['fields'] ) : '' ); - $environment = isset( $_POST['environment'] ) ? sanitize_text_field( $_POST['environment'] ) : 'default'; + $fields = urldecode( isset( $_POST['fields'] ) ? sanitize_url( $_POST['fields'] ) : '' ); parse_str( $fields, $data ); $feedzy_meta_data = $data['feedzy_meta_data']; @@ -1478,8 +1477,8 @@ function ( $errors, $feed, $url ) { $feedzy_meta_data['import_feed_limit'], '', // should be empty. $feedzy_meta_data['inc_key'], - feedzy_is_pro() || 'wizard' === $environment ? 'keywords_exc' : '', - feedzy_is_pro() || 'wizard' === $environment ? $feedzy_meta_data['exc_key'] : '', + feedzy_is_pro() ? 'keywords_exc' : '', + feedzy_is_pro() ? $feedzy_meta_data['exc_key'] : '', feedzy_is_pro() ? 'keywords_ban' : '', feedzy_is_pro() ? $feedzy_meta_data['exc_key'] : '', implode( ',', $tags )