From 04bb54dc5248cd1bad8517e7b8ee8a104570a416 Mon Sep 17 00:00:00 2001 From: RaduCristianPopescu <119046336+RaduCristianPopescu@users.noreply.github.com> Date: Tue, 5 Aug 2025 14:03:14 +0300 Subject: [PATCH 01/11] refactor: redesign support page --- includes/admin/feedzy-rss-feeds-admin.php | 94 +++++++++++++---------- includes/feedzy-rss-feeds.php | 3 +- includes/layouts/feedzy-support.php | 14 ++++ includes/layouts/header.php | 2 +- includes/layouts/setup-wizard.php | 12 +-- 5 files changed, 77 insertions(+), 48 deletions(-) diff --git a/includes/admin/feedzy-rss-feeds-admin.php b/includes/admin/feedzy-rss-feeds-admin.php index 337d7dd6b..a1c2508e0 100644 --- a/includes/admin/feedzy-rss-feeds-admin.php +++ b/includes/admin/feedzy-rss-feeds-admin.php @@ -932,6 +932,17 @@ public function feedzy_menu_pages() { $svg_base64_icon = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iNzdweCIgaGVpZ2h0PSI3N3B4IiB2aWV3Qm94PSIwIDAgNzcgNzciIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDUyLjYgKDY3NDkxKSAtIGh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaCAtLT4KICAgIDx0aXRsZT5Db21iaW5lZC1TaGFwZTwvdGl0bGU+CiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KICAgIDxnIGlkPSJQcm9kdWN0LVBhZ2UiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxn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I2IDIyMS44Mjk5NjcsMTAwMS43NTIyNiAyMjIuMzUwNDA4LDEwMDEuMjk1MzcgQzIyOS4yODI0MDEsOTk1LjIxMTE3IDIzOS43MDI4MSw5OTUuMTk4MjA5IDI0Ni42NDk1NDYsMTAwMS4yOTU0MSBDMjQ3LjE3MDA0NywxMDAxLjc1MjI1IDI0Ny45NTg0MiwxMDAxLjcxOTI1IDI0OC40NDgwNzUsMTAwMS4yMjk1OSBMMjUxLjI0NTQ2NSw5OTguNDMyMjA1IEMyNTEuNzc3OTUyLDk5Ny44OTk4MzQgMjUxLjc1OTU2MSw5OTcuMDI3MTM2IDI1MS4xOTkxOTYsOTk2LjUyNDI2OSBaIE0yNTkuNTE3NDgxLDk4OC4wNjI4MTggQzI0NS43NTQ2NjIsOTc1LjI1MzkxIDIyNC4zMTI1MzEsOTc1LjE5MTM3NCAyMTAuNDgyNDY0LDk4OC4wNjI4NzMgQzIwOS45NTA5Niw5ODguNTU3NTU3IDIwOS45NDA4NDUsOTg5LjM5NjY4OSAyMTAuNDU0MjIyLDk4OS45MTAwNjYgTDIxMy4xODU0ODksOTkyLjY0MTMzMyBDMjEzLjY3NTU2OSw5OTMuMTMxNDEzIDIxNC40NjI4MjQsOTkzLjE0MTkyNCAyMTQuOTcyNjIyLDk5Mi42NzIzNTUgQzIyNi4yODEwMjksOTgyLjI1NDc4NiAyNDMuNzIwODA0LDk4Mi4yNTY0MTUgMjU5LjUxNzQ4MSw5ODguMDYyODE4IFoiIGlkPSJDb21iaW5lZC1TaGFwZSI+PC9wYXRoPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+'; add_menu_page( __( 'Feedzy', 'feedzy-rss-feeds' ), __( 'Feedzy', 'feedzy-rss-feeds' ), apply_filters( 'feedzy_admin_menu_capability', 'publish_posts' ), 'feedzy-admin-menu', '', $svg_base64_icon, 98.7666 ); + add_submenu_page( + 'feedzy-admin-menu', + __( 'Dashboard', 'feedzy-rss-feeds' ), + __( 'Dashboard', 'feedzy-rss-feeds' ), + 'manage_options', + 'feedzy-support', + array( + $this, + 'render_support', + ) + ); add_submenu_page( 'feedzy-admin-menu', __( 'Settings', 'feedzy-rss-feeds' ), @@ -954,19 +965,8 @@ public function feedzy_menu_pages() { 'feedzy_integration_page', ) ); - add_submenu_page( - 'feedzy-admin-menu', - __( 'Support', 'feedzy-rss-feeds' ), - __( 'Support', 'feedzy-rss-feeds' ) . '', - 'manage_options', - 'feedzy-support', - array( - $this, - 'render_support', - ) - ); - if ( ! feedzy_is_pro() && get_option( 'feedzy_fresh_install', false ) ) { + if ( ! feedzy_is_pro() && get_option( 'feedzy_fresh_install', false ) ) { $hook = add_submenu_page( 'feedzy-admin-menu', __( 'Setup Wizard', 'feedzy-rss-feeds' ), @@ -981,37 +981,51 @@ public function feedzy_menu_pages() { add_action( "load-$hook", array( $this, 'feedzy_load_setup_wizard_page' ) ); add_action( 'adminmenu', array( $this, 'feedzy_hide_wizard_menu' ) ); } - if ( ! defined( 'REVIVE_NETWORK_VERSION' ) ) { - $rss_to_social = __( 'RSS to Social', 'feedzy-rss-feeds' ) . ''; - add_action( - 'admin_footer', - function () { - ?> - - '; + add_action( + 'admin_footer', + function () { + ?> + + loader->add_action( 'feedzy_post_http_teardown', self::$instance->admin, 'post_http_teardown', 10, 1 ); self::$instance->loader->add_action( 'admin_init', self::$instance->admin, 'admin_init', 10, 1 ); self::$instance->loader->add_action( 'manage_feedzy_categories_posts_custom_column', self::$instance->admin, 'manage_feedzy_category_columns', 10, 2 ); - self::$instance->loader->add_action( 'admin_menu', self::$instance->admin, 'feedzy_menu_pages' ); + self::$instance->loader->add_action( 'admin_menu', self::$instance->admin, 'feedzy_menu_pages', 8); + self::$instance->loader->add_action( 'admin_menu', self::$instance->admin, 'rss_to_social_menu', 20 ); self::$instance->loader->add_action( 'wp_ajax_get_tinymce_form', self::$instance->admin, 'get_tinymce_form' ); self::$instance->loader->add_action( 'wp_enqueue_scripts', self::$instance->admin, 'enqueue_styles' ); self::$instance->loader->add_action( 'admin_enqueue_scripts', self::$instance->admin, 'enqueue_styles_admin', 99 ); diff --git a/includes/layouts/feedzy-support.php b/includes/layouts/feedzy-support.php index e7e975744..eebf29f34 100644 --- a/includes/layouts/feedzy-support.php +++ b/includes/layouts/feedzy-support.php @@ -31,6 +31,20 @@ class="">" class=""> +
' + response.message + '
' + ); + $errorMessage.insertAfter( + $('.fz-license-section').find('.help-text') + ); + $button.removeAttr('disabled').removeClass('fz-checking'); + return; + } + window.location.reload(); + }; + + /** + * Validates license via AJAX, disables button and clears previous errors + * @param {Event} e - Click event from check license button + */ + const checkLicense = (e) => { + e.preventDefault(); + const $button = $(e.currentTarget); + + $button.attr('disabled', true).addClass('fz-checking'); + $button + .parents('.fz-license-section') + .find('.feedzy-api-error') + .remove(); + + const licenseData = $button + .parent('.fz-input-group-btn') + .find('input') + .serialize(); + + $.post( + window.ajaxurl, + licenseData, + (response) => handleLicenseResponse(response, $button), + 'json' + ); + }; + + $(document).ready(() => { + $('.fz-license-section #license_key').on('input', function () { + handleLicenseKeyInput($(this)); + }); + + $('.fz-license-section #check_ti_license').on('click', checkLicense); + }); +})(window.jQuery); diff --git a/js/feedzy-setting.js b/js/feedzy-setting.js index 375c581c0..51fe07414 100644 --- a/js/feedzy-setting.js +++ b/js/feedzy-setting.js @@ -98,50 +98,6 @@ jQuery(function ($) { } }); - - // License key. - jQuery('.fz-license-section #license_key').on('input', function () { - const licenseKey = jQuery(this).val(); - if (licenseKey !== '') { - jQuery('#check_ti_license').removeAttr('disabled'); - } else { - jQuery('#check_ti_license').attr('disabled', true); - } - jQuery('.fz-license-section input[name="license_key"]').val(licenseKey); - }); - - jQuery('.fz-license-section #check_ti_license').on('click', function (e) { - e.preventDefault(); - const _this = jQuery(this); - _this.attr('disabled', true).addClass('fz-checking'); - - _this.parents('.fz-license-section').find('.feedzy-api-error').remove(); - - const LicenseData = _this - .parent('.fz-input-group-btn') - .find('input') - .serialize(); - - jQuery.post( - ajaxurl, - LicenseData, - function (response) { - if (!response.success) { - jQuery( - '' + - response.message + - '
' - ).insertAfter( - jQuery('.fz-license-section').find('.help-text') - ); - _this.removeAttr('disabled').removeClass('fz-checking'); - } else { - window.location.reload(); - } - }, - 'json' - ); - }); snackbarNotice(); const initializeAutoCatActions = () => { From 11a91b2ebcc183889fe27e096bfcf7f7aaa33362 Mon Sep 17 00:00:00 2001 From: RaduCristianPopescu <119046336+RaduCristianPopescu@users.noreply.github.com> Date: Tue, 5 Aug 2025 17:00:48 +0300 Subject: [PATCH 03/11] fix: sanitize tab input and improve support page rendering --- includes/admin/feedzy-rss-feeds-admin.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/includes/admin/feedzy-rss-feeds-admin.php b/includes/admin/feedzy-rss-feeds-admin.php index 5195e42eb..3fedbb4a4 100644 --- a/includes/admin/feedzy-rss-feeds-admin.php +++ b/includes/admin/feedzy-rss-feeds-admin.php @@ -278,14 +278,15 @@ public function enqueue_styles_admin() { } // phpcs:ignore WordPress.Security.NonceVerification.Recommended - if ( 'feedzy_page_feedzy-support' === $screen->base && - ( - ( isset( $_GET['tab'] ) && 'improve' === $_GET['tab'] ) - || ( 'edit' !== $screen->base && 'feedzy_imports' === $screen->post_type ) - || ( isset( $_GET['tab'] ) && 'license' === $_GET['tab'] ) + $tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : ''; + + if ( 'feedzy_page_feedzy-support' === $screen->base && + ( + ( 'improve' === $tab ) + || ( 'edit' !== $screen->base && 'feedzy_imports' === $screen->post_type ) + || ( 'license' === $tab ) ) ) { - $asset_file = include FEEDZY_ABSPATH . '/build/feedback/index.asset.php'; wp_enqueue_script( $this->plugin_name . '_feedback', FEEDZY_ABSURL . 'build/feedback/index.js', array_merge( $asset_file['dependencies'], array( 'wp-editor', 'wp-api', 'lodash' ) ), $asset_file['version'], true ); wp_enqueue_style( 'wp-block-editor' ); @@ -1003,7 +1004,12 @@ public function feedzy_menu_pages() { } } - public function rss_to_social_menu() { + /** + * Method to render the support page. + * + * @access public + */ + public function rss_to_social_menu(): void { $capability = feedzy_current_user_can(); if ( ! $capability ) { return; @@ -1044,8 +1050,6 @@ function () { ), ) ); - - $submenu['feedzy-admin-menu'] = array_values( $submenu['feedzy-admin-menu'] ); } } From eaa837fa5658baf52453d1daf6c9ee83c4c28a6f Mon Sep 17 00:00:00 2001 From: RaduCristianPopescu <119046336+RaduCristianPopescu@users.noreply.github.com> Date: Tue, 5 Aug 2025 17:13:30 +0300 Subject: [PATCH 04/11] fix: button issue --- js/feedzy-setting.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/js/feedzy-setting.js b/js/feedzy-setting.js index 51fe07414..a00f99f9b 100644 --- a/js/feedzy-setting.js +++ b/js/feedzy-setting.js @@ -98,6 +98,49 @@ jQuery(function ($) { } }); + // License key. + jQuery('.fz-license-section #license_key').on('input', function () { + const licenseKey = jQuery(this).val(); + if (licenseKey !== '') { + jQuery('#check_ti_license').removeAttr('disabled'); + } else { + jQuery('#check_ti_license').attr('disabled', true); + } + jQuery('.fz-license-section input[name="license_key"]').val(licenseKey); + }); + + jQuery('.fz-license-section #check_ti_license').on('click', function (e) { + e.preventDefault(); + const _this = jQuery(this); + _this.attr('disabled', true).addClass('fz-checking'); + + _this.parents('.fz-license-section').find('.feedzy-api-error').remove(); + + const LicenseData = _this + .parent('.fz-input-group-btn') + .find('input') + .serialize(); + + jQuery.post( + ajaxurl, + LicenseData, + function (response) { + if (!response.success) { + jQuery( + '' + + response.message + + '
' + ).insertAfter( + jQuery('.fz-license-section').find('.help-text') + ); + _this.removeAttr('disabled').removeClass('fz-checking'); + } else { + window.location.reload(); + } + }, + 'json' + ); + }); snackbarNotice(); const initializeAutoCatActions = () => { From 0b165612e4d0e188bdcb3debf6bbd45430fe2449 Mon Sep 17 00:00:00 2001 From: RaduCristianPopescu <119046336+RaduCristianPopescu@users.noreply.github.com> Date: Tue, 5 Aug 2025 17:30:50 +0300 Subject: [PATCH 05/11] fix: redundant code --- includes/admin/feedzy-rss-feeds-admin.php | 14 ++++++++ js/feedzy-setting.js | 43 ----------------------- 2 files changed, 14 insertions(+), 43 deletions(-) diff --git a/includes/admin/feedzy-rss-feeds-admin.php b/includes/admin/feedzy-rss-feeds-admin.php index 3fedbb4a4..3c1a1c8fd 100644 --- a/includes/admin/feedzy-rss-feeds-admin.php +++ b/includes/admin/feedzy-rss-feeds-admin.php @@ -206,6 +206,20 @@ public function enqueue_styles_admin() { ), ) ); + + wp_enqueue_script( $this->plugin_name . '_license', FEEDZY_ABSURL . 'js/feedzy-license.js', array( 'jquery' ), $this->version, true ); + + wp_localize_script( + $this->plugin_name . '_license', + 'feedzyLicense', + array( + 'l10n' => array( + 'licenseKey' => __( 'License Key', 'feedzy-rss-feeds' ), + 'checkBtn' => __( 'Check License', 'feedzy-rss-feeds' ), + 'errorMsg' => __( 'An error occurred while checking the license. Please try again.', 'feedzy-rss-feeds' ), + ), + ) + ); } $upsell_screens = array( 'feedzy-rss_page_feedzy-settings', 'feedzy-rss_page_feedzy-admin-menu-pro-upsell' ); diff --git a/js/feedzy-setting.js b/js/feedzy-setting.js index a00f99f9b..51fe07414 100644 --- a/js/feedzy-setting.js +++ b/js/feedzy-setting.js @@ -98,49 +98,6 @@ jQuery(function ($) { } }); - // License key. - jQuery('.fz-license-section #license_key').on('input', function () { - const licenseKey = jQuery(this).val(); - if (licenseKey !== '') { - jQuery('#check_ti_license').removeAttr('disabled'); - } else { - jQuery('#check_ti_license').attr('disabled', true); - } - jQuery('.fz-license-section input[name="license_key"]').val(licenseKey); - }); - - jQuery('.fz-license-section #check_ti_license').on('click', function (e) { - e.preventDefault(); - const _this = jQuery(this); - _this.attr('disabled', true).addClass('fz-checking'); - - _this.parents('.fz-license-section').find('.feedzy-api-error').remove(); - - const LicenseData = _this - .parent('.fz-input-group-btn') - .find('input') - .serialize(); - - jQuery.post( - ajaxurl, - LicenseData, - function (response) { - if (!response.success) { - jQuery( - '' + - response.message + - '
' - ).insertAfter( - jQuery('.fz-license-section').find('.help-text') - ); - _this.removeAttr('disabled').removeClass('fz-checking'); - } else { - window.location.reload(); - } - }, - 'json' - ); - }); snackbarNotice(); const initializeAutoCatActions = () => { From 59c576809a6ff7c436e7c2c08cff870050363930 Mon Sep 17 00:00:00 2001 From: RaduCristianPopescu <119046336+RaduCristianPopescu@users.noreply.github.com> Date: Wed, 6 Aug 2025 12:11:51 +0300 Subject: [PATCH 06/11] feat: add license script enqueueing --- includes/admin/feedzy-rss-feeds-admin.php | 55 ++++++++++++----------- includes/layouts/feedzy-support.php | 4 +- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/includes/admin/feedzy-rss-feeds-admin.php b/includes/admin/feedzy-rss-feeds-admin.php index 3c1a1c8fd..8b087656d 100644 --- a/includes/admin/feedzy-rss-feeds-admin.php +++ b/includes/admin/feedzy-rss-feeds-admin.php @@ -128,6 +128,31 @@ public function enqueue_styles() { } wp_register_style( $this->plugin_name, FEEDZY_ABSURL . 'css/feedzy-rss-feeds.css', array(), $this->version, 'all' ); } + + /** + * Helper function to enqueue the license script with localization + */ + private function enqueue_license_script() { + wp_enqueue_script( + $this->plugin_name . '_license', + FEEDZY_ABSURL . 'js/feedzy-license.js', + array( 'jquery' ), + $this->version, + true + ); + + wp_localize_script( + $this->plugin_name . '_license', + 'feedzyLicense', + array( + 'l10n' => array( + 'licenseKey' => __( 'License Key', 'feedzy-rss-feeds' ), + 'checkBtn' => __( 'Check License', 'feedzy-rss-feeds' ), + 'errorMsg' => __( 'An error occurred while checking the license. Please try again.', 'feedzy-rss-feeds' ), + ), + ) + ); + } /** * Register the stylesheets for the admin area. @@ -207,19 +232,7 @@ public function enqueue_styles_admin() { ) ); - wp_enqueue_script( $this->plugin_name . '_license', FEEDZY_ABSURL . 'js/feedzy-license.js', array( 'jquery' ), $this->version, true ); - - wp_localize_script( - $this->plugin_name . '_license', - 'feedzyLicense', - array( - 'l10n' => array( - 'licenseKey' => __( 'License Key', 'feedzy-rss-feeds' ), - 'checkBtn' => __( 'Check License', 'feedzy-rss-feeds' ), - 'errorMsg' => __( 'An error occurred while checking the license. Please try again.', 'feedzy-rss-feeds' ), - ), - ) - ); + $this->enqueue_license_script(); } $upsell_screens = array( 'feedzy-rss_page_feedzy-settings', 'feedzy-rss_page_feedzy-admin-menu-pro-upsell' ); @@ -314,19 +327,7 @@ public function enqueue_styles_admin() { ) ); - wp_enqueue_script( $this->plugin_name . '_license', FEEDZY_ABSURL . 'js/feedzy-license.js', array( 'jquery' ), $this->version, true ); - - wp_localize_script( - $this->plugin_name . '_license', - 'feedzyLicense', - array( - 'l10n' => array( - 'licenseKey' => __( 'License Key', 'feedzy-rss-feeds' ), - 'checkBtn' => __( 'Check License', 'feedzy-rss-feeds' ), - 'errorMsg' => __( 'An error occurred while checking the license. Please try again.', 'feedzy-rss-feeds' ), - ), - ) - ); + $this->enqueue_license_script(); wp_set_script_translations( $this->plugin_name . '_feedback', 'feedzy-rss-feeds' ); } @@ -1019,7 +1020,7 @@ public function feedzy_menu_pages() { } /** - * Method to render the support page. + * Handle the RSS to Social menu item. * * @access public */ diff --git a/includes/layouts/feedzy-support.php b/includes/layouts/feedzy-support.php index 7280fa451..f338ae9ea 100644 --- a/includes/layouts/feedzy-support.php +++ b/includes/layouts/feedzy-support.php @@ -39,14 +39,14 @@ class="">