Skip to content
Merged
212 changes: 153 additions & 59 deletions includes/admin/feedzy-rss-feeds-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,34 @@ 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
*
* @access public
* @return void
*/
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.
Expand Down Expand Up @@ -206,6 +234,8 @@ public function enqueue_styles_admin() {
),
)
);

$this->enqueue_license_script();
}

$upsell_screens = array( 'feedzy-rss_page_feedzy-settings', 'feedzy-rss_page_feedzy-admin-menu-pro-upsell' );
Expand Down Expand Up @@ -278,8 +308,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 ) ) ) {

$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' );
Expand All @@ -293,6 +330,8 @@ public function enqueue_styles_admin() {
)
);

$this->enqueue_license_script();

wp_set_script_translations( $this->plugin_name . '_feedback', 'feedzy-rss-feeds' );
}

Expand Down Expand Up @@ -923,6 +962,7 @@ public function feedzy_filter_plugin_row_meta( $links, $file ) {
*
* @since 3.0.12
* @access public
* @return void
*/
public function feedzy_menu_pages() {
$capability = feedzy_current_user_can();
Expand All @@ -932,6 +972,17 @@ public function feedzy_menu_pages() {
$svg_base64_icon = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iNzdweCIgaGVpZ2h0PSI3N3B4IiB2aWV3Qm94PSIwIDAgNzcgNzciIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDUyLjYgKDY3NDkxKSAtIGh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaCAtLT4KICAgIDx0aXRsZT5Db21iaW5lZC1TaGFwZTwvdGl0bGU+CiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KICAgIDxnIGlkPSJQcm9kdWN0LVBhZ2UiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIGlkPSJXb3JkUHJlc3MtcGx1Z2lucyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTE5Ni4wMDAwMDAsIC05NTcuMDAwMDAwKSIgZmlsbD0iIzQyNjhDRiI+CiAgICAgICAgICAgIDxwYXR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4yOTU0MSBDMjQ3LjE3MDA0NywxMDAxLjc1MjI1IDI0Ny45NTg0MiwxMDAxLjcxOTI1IDI0OC40NDgwNzUsMTAwMS4yMjk1OSBMMjUxLjI0NTQ2NSw5OTguNDMyMjA1IEMyNTEuNzc3OTUyLDk5Ny44OTk4MzQgMjUxLjc1OTU2MSw5OTcuMDI3MTM2IDI1MS4xOTkxOTYsOTk2LjUyNDI2OSBaIE0yNTkuNTE3NDgxLDk4OC4wNjI4MTggQzI0NS43NTQ2NjIsOTc1LjI1MzkxIDIyNC4zMTI1MzEsOTc1LjE5MTM3NCAyMTAuNDgyNDY0LDk4OC4wNjI4NzMgQzIwOS45NTA5Niw5ODguNTU3NTU3IDIwOS45NDA4NDUsOTg5LjM5NjY4OSAyMTAuNDU0MjIyLDk4OS45MTAwNjYgTDIxMy4xODU0ODksOTkyLjY0MTMzMyBDMjEzLjY3NTU2OSw5OTMuMTMxNDEzIDIxNC40NjI4MjQsOTkzLjE0MTkyNCAyMTQuOTcyNjIyLDk5Mi42NzIzNTUgQzIyNi4yODEwMjksOTgyLjI1NDc4NiAyNDMuNzIwODA0LDk4Mi4yNTY0MTUgMjU5LjUxNzQ4MSw5ODguMDYyODE4IFoiIGlkPSJDb21iaW5lZC1TaGFwZSI+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' ),
Expand All @@ -954,17 +1005,6 @@ public function feedzy_menu_pages() {
'feedzy_integration_page',
)
);
add_submenu_page(
'feedzy-admin-menu',
__( 'Support', 'feedzy-rss-feeds' ),
__( 'Support', 'feedzy-rss-feeds' ) . '<span class="dashicons dashicons-editor-help more-features-icon" style="width: 17px; height: 17px; margin-left: 4px; color: #ffca54; font-size: 17px; vertical-align: -3px;"></span>',
'manage_options',
'feedzy-support',
array(
$this,
'render_support',
)
);

if ( ! feedzy_is_pro() && get_option( 'feedzy_fresh_install', false ) ) {
$hook = add_submenu_page(
Expand All @@ -981,37 +1021,55 @@ 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' ) . '<span id="feedzy-rn-menu" class="dashicons dashicons-external" style="font-size:initial;"></span>';
add_action(
'admin_footer',
function () {
?>
<script type="text/javascript">
jQuery(document).ready(function ($) {
$('#feedzy-rn-menu').parent().attr('target', '_blank');
});
</script>
<?php
}
);
}

global $submenu;
if ( isset( $submenu['feedzy-admin-menu'] ) ) {
/**
* Handle the RSS to Social menu item.
*
* @access public
* @return void
*/
public function rss_to_social_menu() {
$capability = feedzy_current_user_can();
if ( ! $capability ) {
return;
}

array_splice(
$submenu['feedzy-admin-menu'],
4,
0,
array(
array(
$rss_to_social,
'manage_options',
tsdk_utmify( 'https://revive.social/plugins/revive-network', 'feedzy-menu' ),
),
)
);
if ( defined( 'REVIVE_NETWORK_VERSION' ) && ! feedzy_is_pro() ) {
return;
}

$rss_to_social = __( 'RSS to Social', 'feedzy-rss-feeds' ) . '<span id="feedzy-rn-menu" class="dashicons dashicons-external" style="font-size:initial;"></span>';
add_action(
'admin_footer',
function () {
?>
<script type="text/javascript">
jQuery(document).ready(function ($) {
$('#feedzy-rn-menu').parent().attr('target', '_blank');
});
</script>
<?php
}
);

global $submenu;
if ( isset( $submenu['feedzy-admin-menu'] ) ) {
if ( isset( $submenu['feedzy-admin-menu'][0] ) ) {
unset( $submenu['feedzy-admin-menu'][0] );
}
array_splice(
$submenu['feedzy-admin-menu'],
5,
0,
array(
array(
$rss_to_social,
'manage_options',
tsdk_utmify( 'https://revive.social/plugins/revive-network', 'feedzy-menu' ),
),
)
);
}
}

Expand Down Expand Up @@ -1605,7 +1663,20 @@ public function feedzy_dismiss_wizard( $redirect_to_dashboard = true ) {
update_option( 'feedzy_fresh_install', $status );
delete_option( 'feedzy_wizard_data' );
if ( false !== $redirect_to_dashboard ) {
wp_safe_redirect( remove_query_arg( array( 'action', 'status' ) ) );

$cleaned_url = remove_query_arg( array( 'page', 'action', 'status' ) );
$parsed_url = wp_parse_url( $cleaned_url );

// Default to dashboard if no page is set.
if (
isset( $parsed_url['path'] ) &&
strpos( $parsed_url['path'], '/wp-admin/admin.php' ) !== false &&
empty( $parsed_url['query'] )
) {
$cleaned_url = add_query_arg( 'page', 'feedzy-support', $cleaned_url );
}

wp_safe_redirect( $cleaned_url );
exit;
}
return true;
Expand Down Expand Up @@ -1809,7 +1880,12 @@ private function setup_wizard_subscribe_process() {
$segment = 1;
$response = array(
'status' => 1,
'redirect_to' => add_query_arg( 'post_type', 'feedzy_imports', admin_url( 'edit.php' ) ),
'redirect_to' => add_query_arg(
array(
'page' => 'feedzy-support',
),
admin_url( 'admin.php' )
),
'message' => __( 'Redirecting to Feedzy dashboard', 'feedzy-rss-feeds' ),
);

Expand All @@ -1834,30 +1910,48 @@ private function setup_wizard_subscribe_process() {
} else {
$response = array(
'status' => 1,
'redirect_to' => add_query_arg( 'post_type', 'feedzy_imports', admin_url( 'edit.php' ) ),
'redirect_to' => add_query_arg(
array(
'page' => 'feedzy-support',
),
admin_url( 'admin.php' )
),
'message' => __( 'Redirecting to Feedzy dashboard', 'feedzy-rss-feeds' ),
);
}
} elseif ( 'page_builder' === $integrate_with ) {
$post_edit_link = get_edit_post_link( $page_id, 'db' );
// Get elementor edit page link.
if ( defined( 'ELEMENTOR_PATH' ) && class_exists( 'Elementor\Widget_Base' ) ) {
$segment = 3;
$post_edit_link = add_query_arg(
array(
'post' => $page_id,
'action' => 'elementor',
if ( empty( $page_id ) ) {
$response = array(
'status' => 1,
'redirect_to' => add_query_arg(
array(
'page' => 'feedzy-support',
),
admin_url( 'admin.php' )
),
admin_url( 'post.php' )
'message' => __( 'Redirecting to Feedzy dashboard', 'feedzy-rss-feeds' ),
);
} else {
$segment = 4;
$post_edit_link = get_edit_post_link( $page_id, 'db' );
// Get elementor edit page link.
if ( defined( 'ELEMENTOR_PATH' ) && class_exists( 'Elementor\Widget_Base' ) ) {
$segment = 3;
$post_edit_link = add_query_arg(
array(
'post' => $page_id,
'action' => 'elementor',
),
admin_url( 'post.php' )
);
} else {
$segment = 4;
}
$response = array(
'status' => 1,
'redirect_to' => $post_edit_link,
'message' => __( 'Redirecting to draft page', 'feedzy-rss-feeds' ),
);
}
$response = array(
'status' => 1,
'redirect_to' => $post_edit_link,
'message' => __( 'Redirecting to draft page', 'feedzy-rss-feeds' ),
);
}
if ( $with_subscribe && is_email( $email ) ) {
update_option( 'feedzy_rss_feeds_logger_flag', 'yes' );
Expand Down
3 changes: 2 additions & 1 deletion includes/feedzy-rss-feeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ private function define_admin_hooks() {
self::$instance->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 );
Expand Down
3 changes: 3 additions & 0 deletions includes/layouts/feedzy-license.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="fz-form-wrap">
<?php do_action( 'feedzy_dashboard_license_content' ); ?>
</div>
25 changes: 24 additions & 1 deletion includes/layouts/feedzy-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,30 @@ class="<?php echo 'docs' === $active_tab ? 'active' : ''; ?>"><?php esc_html_e(
class="<?php echo 'feedzy-pro' === $active_tab ? 'active' : ''; ?>"><?php esc_html_e( 'Free vs Pro', 'feedzy-rss-feeds' ); ?></a>
</li>
<?php endif; ?>
<?php if ( defined( 'FEEDZY_PRO_VERSION' ) && has_action( 'feedzy_dashboard_license_content' ) ) : ?>
<li>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=feedzy-support&tab=license' ) ); ?>"
class="<?php echo 'license' === $active_tab ? 'active' : ''; ?>"><?php esc_html_e( 'License', 'feedzy-rss-feeds' ); ?></a>
</li>
<?php endif; ?>
<li>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=feedzy-support&tab=improve' ) ); ?>"
class="<?php echo 'improve' === $active_tab ? 'active' : ''; ?>"><?php esc_html_e( 'Help us improve!', 'feedzy-rss-feeds' ); ?></a>
</li>
<li>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=feedzy-settings' ) ); ?>"
class="<?php echo 'settings' === $active_tab ? 'active' : ''; ?>">
<?php esc_html_e( 'Settings', 'feedzy-rss-feeds' ); ?>
<span class="dashicons dashicons-external"></span>
</a>
</li>
<li>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=feedzy-integration' ) ); ?>"
class="<?php echo 'integration' === $active_tab ? 'active' : ''; ?>">
<?php esc_html_e( 'Integration', 'feedzy-rss-feeds' ); ?>
<span class="dashicons dashicons-external"></span>
</a>
</li>
<?php $support_tab_heading = apply_filters( 'feedzy_support_tab_heading', '', $active_tab ); ?>
<?php if ( ! empty( $support_tab_heading ) ) : ?>
<li>
Expand All @@ -54,6 +74,9 @@ class="<?php echo 'improve' === $active_tab ? 'active' : ''; ?>"><?php esc_html_
case 'improve':
load_template( FEEDZY_ABSPATH . '/includes/layouts/feedzy-improve.php' );
break;
case 'license':
load_template( FEEDZY_ABSPATH . '/includes/layouts/feedzy-license.php' );
break;
default:
$template = apply_filters( 'feedzy_support_tab_content', '', $active_tab );
if ( ! empty( $template ) ) {
Expand Down Expand Up @@ -98,4 +121,4 @@ class="<?php echo 'improve' === $active_tab ? 'active' : ''; ?>"><?php esc_html_
</div>
<?php endif; ?>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion includes/layouts/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// phpcs:disable WordPress.Security.NonceVerification
$page_title = __( 'Settings', 'feedzy-rss-feeds' );
if ( isset( $_GET['page'] ) && 'feedzy-support' === $_GET['page'] ) {
$page_title = __( 'Support', 'feedzy-rss-feeds' );
$page_title = __( 'Dashboard', 'feedzy-rss-feeds' );
} elseif ( isset( $_GET['page'] ) && 'feedzy-integration' === $_GET['page'] ) {
$page_title = __( 'Integration', 'feedzy-rss-feeds' );
}
Expand Down
12 changes: 6 additions & 6 deletions includes/layouts/setup-wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* @package Feedzy_Rss_Feeds
*/

$dashboard_url = add_query_arg(
// Note: It will be redirect to dashboard by `feedzy_dismiss_wizard` action.
$skip_onboarding_url_callback = add_query_arg(
array(
'post_type' => 'feedzy_imports',
'action' => 'feedzy_dismiss_wizard',
'status' => 0,
'action' => 'feedzy_dismiss_wizard',
'status' => 0,
),
admin_url( 'edit.php' )
admin_url( 'admin.php' )
);
// phpcs:ignore WordPress.Security.NonceVerification
$integrate_with = ! empty( $_GET['integrate-with'] ) ? sanitize_text_field( wp_unslash( $_GET['integrate-with'] ) ) : '';
Expand All @@ -34,7 +34,7 @@
</div>
</div>
<div class="back-btn">
<a href="<?php echo esc_url( $dashboard_url ); ?>" class="btn-link"><span class="dashicons dashicons-arrow-left-alt"></span> <?php esc_html_e( 'Go to dashboard', 'feedzy-rss-feeds' ); ?></a>
<a href="<?php echo esc_url( $skip_onboarding_url_callback ); ?>" class="btn-link"><span class="dashicons dashicons-arrow-left-alt"></span> <?php esc_html_e( 'Go to dashboard', 'feedzy-rss-feeds' ); ?></a>
</div>
</div>
</div>
Expand Down
Loading
Loading