| Server IP : 151.101.66.159 / Your IP : 216.73.216.66 Web Server : Flywheel/5.1.0 System : Linux wordpress 6.12.113+ #1 SMP Thu Oct 22 02:38:20 UTC 2026 x86_64 User : root ( ) PHP Version : 7.4.33.18 Disable Function : disk_free_space,diskfreespace,dl,exec,fpassthru,getmypid,getmyuid,highlight_file,link,opcache_compile_file,opcache_get_configuration,opcache_is_script_cached,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifcontinued,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,phpinfo,popen,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,socket_listen,source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wp-content/plugins/wordpress-seo/src/plans/user-interface/ |
Upload File : |
<?php
namespace Yoast\WP\SEO\Plans\User_Interface;
use WPSEO_Addon_Manager;
use WPSEO_Shortlinker;
use Yoast\WP\SEO\Conditionals\Traits\Admin_Conditional_Trait;
use Yoast\WP\SEO\Conditionals\WooCommerce_Conditional;
use Yoast\WP\SEO\General\User_Interface\General_Page_Integration;
use Yoast\WP\SEO\Helpers\Current_Page_Helper;
use Yoast\WP\SEO\Helpers\Product_Helper;
use Yoast\WP\SEO\Integrations\Integration_Interface;
use Yoast\WP\SEO\Promotions\Application\Promotion_Manager;
/**
* Adds the plans page to the Yoast admin menu.
*/
class Upgrade_Sidebar_Menu_Integration implements Integration_Interface {
use Admin_Conditional_Trait;
/**
* The page name.
*/
public const PAGE = 'wpseo_upgrade_sidebar';
/**
* The WooCommerce conditional.
*
* @var WooCommerce_Conditional
*/
private $woocommerce_conditional;
/**
* The shortlinker.
*
* @var WPSEO_Shortlinker
*/
private $shortlinker;
/**
* The product helper.
*
* @var Product_Helper
*/
private $product_helper;
/**
* The current page helper.
*
* @var Current_Page_Helper
*/
private $current_page_helper;
/**
* The promotion manager.
*
* @var Promotion_Manager
*/
private $promotion_manager;
/**
* The addon manager.
*
* @var WPSEO_Addon_Manager
*/
private $addon_manager;
/**
* Constructor.
*
* @param WooCommerce_Conditional $woocommerce_conditional The WooCommerce conditional.
* @param WPSEO_Shortlinker $shortlinker The shortlinker.
* @param Product_Helper $product_helper The product helper.
* @param Current_Page_Helper $current_page_helper The current page helper.
* @param Promotion_Manager $promotion_manager The promotion manager.
* @param WPSEO_Addon_Manager $addon_manager The addon manager.
*/
public function __construct(
WooCommerce_Conditional $woocommerce_conditional,
WPSEO_Shortlinker $shortlinker,
Product_Helper $product_helper,
Current_Page_Helper $current_page_helper,
Promotion_Manager $promotion_manager,
WPSEO_Addon_Manager $addon_manager
) {
$this->woocommerce_conditional = $woocommerce_conditional;
$this->shortlinker = $shortlinker;
$this->product_helper = $product_helper;
$this->current_page_helper = $current_page_helper;
$this->promotion_manager = $promotion_manager;
$this->addon_manager = $addon_manager;
}
/**
* Initializes the integration.
*
* This is the place to register hooks and filters.
*
* @return void
*/
public function register_hooks() {
// Add page with PHP_INT_MAX - 1 to allow other items (like Brand Insights) to be positioned after.
\add_filter( 'wpseo_submenu_pages', [ $this, 'add_page' ], ( \PHP_INT_MAX - 1 ) );
\add_filter( 'wpseo_network_submenu_pages', [ $this, 'add_page' ], ( \PHP_INT_MAX - 1 ) );
\add_action( 'admin_init', [ $this, 'do_redirect' ], 1 );
}
/**
* Adds the page to the (currently) last position in the array.
*
* @param array<string, array<string, array<static|string>>> $pages The pages.
*
* @return array<string, array<string, array<static|string>>> The pages.
*/
public function add_page( $pages ) {
// Don't show the Upgrade button if Yoast SEO WooCommerce addon is active.
if ( $this->addon_manager->is_installed( WPSEO_Addon_Manager::WOOCOMMERCE_SLUG ) ) {
return $pages;
}
// Don't show the Upgrade button if Premium is active without the WooCommerce plugin.
if ( $this->product_helper->is_premium() && ! $this->woocommerce_conditional->is_met() ) {
return $pages;
}
$button_content = \__( 'Upgrade', 'wordpress-seo' );
if ( $this->promotion_manager->is( 'black-friday-promotion' ) ) {
$button_content = ( $this->product_helper->is_premium() ) ? \__( 'Get 30% off', 'wordpress-seo' ) : \__( '30% off - BF Sale', 'wordpress-seo' );
}
$pages[] = [
General_Page_Integration::PAGE,
'',
'<span class="yst-root"><span class="yst-button yst-w-full yst-whitespace-nowrap yst-button--upsell yst-button--small">' . $button_content . ' </span></span>',
'wpseo_manage_options',
self::PAGE,
static function () {
echo 'redirecting...';
},
];
return $pages;
}
/**
* Redirects to the yoast.com.
*
* @return void
*/
public function do_redirect(): void {
if ( $this->current_page_helper->get_current_yoast_seo_page() !== self::PAGE ) {
return;
}
$link = $this->shortlinker->build_shortlink( 'https://yoa.st/wordpress-menu-upgrade-premium' );
if ( $this->woocommerce_conditional->is_met() ) {
$link = $this->shortlinker->build_shortlink( 'https://yoa.st/wordpress-menu-upgrade-woocommerce' );
}
\wp_redirect( $link );//phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect -- Safe redirect is used here.
exit();
}
}