This commit is contained in:
Hanson.xyz Dev
2026-01-04 17:50:08 -06:00
parent 7e45ce0756
commit acc8ac87a0
4131 changed files with 232562 additions and 250244 deletions
@@ -317,7 +317,7 @@ class WPSEO_Addon_Manager {
/**
* Checks if there are addon updates.
*
* @param stdClass|mixed $data The current data for update_plugins.
* @param stdClass $data The current data for update_plugins.
*
* @return stdClass Extended data for update_plugins.
*/
@@ -8,6 +8,7 @@
use Yoast\WP\SEO\Conditionals\WooCommerce_Conditional;
use Yoast\WP\SEO\Helpers\Product_Helper;
use Yoast\WP\SEO\Helpers\Score_Icon_Helper;
use Yoast\WP\SEO\Integrations\Admin\Brand_Insights_Page;
use Yoast\WP\SEO\Integrations\Support_Integration;
use Yoast\WP\SEO\Models\Indexable;
use Yoast\WP\SEO\Presenters\Admin\Premium_Badge_Presenter;
@@ -290,6 +291,7 @@ class WPSEO_Admin_Bar_Menu implements WPSEO_WordPress_Integration {
}
$this->add_premium_link( $wp_admin_bar );
$this->add_brand_insights_link( $wp_admin_bar );
}
/**
@@ -589,21 +591,26 @@ class WPSEO_Admin_Bar_Menu implements WPSEO_WordPress_Integration {
* @return void
*/
protected function add_premium_link( WP_Admin_Bar $wp_admin_bar ) {
$link = $this->shortlinker->build_shortlink( 'https://yoa.st/admin-bar-get-premium' );
// Don't show the Upgrade button if Yoast SEO WooCommerce addon is active.
$addon_manager = new WPSEO_Addon_Manager();
if ( $addon_manager->is_installed( WPSEO_Addon_Manager::WOOCOMMERCE_SLUG ) ) {
return;
}
$has_woocommerce = ( new Woocommerce_Conditional() )->is_met();
if ( $this->product_helper->is_premium() ) {
$link = $this->shortlinker->build_shortlink( 'https://yoa.st/admin-bar-get-ai-insights' );
// Don't show the Upgrade button if Premium is active without the WooCommerce plugin.
if ( $this->product_helper->is_premium() && ! $has_woocommerce ) {
return;
}
elseif ( $has_woocommerce ) {
$link = $this->shortlinker->build_shortlink( 'https://yoa.st/admin-bar-get-premium' );
if ( $has_woocommerce ) {
$link = $this->shortlinker->build_shortlink( 'https://yoa.st/admin-bar-get-premium-woocommerce' );
}
$button_label = esc_html__( 'Upgrade', 'wordpress-seo' );
$badge = '';
if ( $this->product_helper->is_premium() ) {
$badge = '<div id="wpseo-new-badge-upgrade">' . __( 'New', 'wordpress-seo' ) . '</div>';
}
if ( YoastSEO()->classes->get( Promotion_Manager::class )->is( 'black-friday-promotion' ) ) {
$button_label = esc_html__( '30% off - BF Sale', 'wordpress-seo' );
@@ -614,10 +621,9 @@ class WPSEO_Admin_Bar_Menu implements WPSEO_WordPress_Integration {
'id' => 'wpseo-get-premium',
// Circumvent an issue in the WP admin bar API in order to pass `data` attributes. See https://core.trac.wordpress.org/ticket/38636.
'title' => sprintf(
'<a href="%1$s" target="_blank" data-action="load-nfd-ctb" data-ctb-id="f6a84663-465f-4cb5-8ba5-f7a6d72224b2">%2$s</a>%3$s',
'<a href="%1$s" target="_blank" data-action="load-nfd-ctb" data-ctb-id="f6a84663-465f-4cb5-8ba5-f7a6d72224b2">%2$s</a>',
esc_url( $link ),
$button_label,
$badge,
$button_label
),
'meta' => [
'tabindex' => '0',
@@ -626,6 +632,38 @@ class WPSEO_Admin_Bar_Menu implements WPSEO_WordPress_Integration {
);
}
/**
* Adds the Brand Insights link to the admin bar.
*
* @param WP_Admin_Bar $wp_admin_bar Admin bar instance to add the menu to.
*
* @return void
*/
protected function add_brand_insights_link( WP_Admin_Bar $wp_admin_bar ) {
$page = $this->product_helper->is_premium() ? 'wpseo_brand_insights_premium' : 'wpseo_brand_insights';
$button_content = 'AI Brand Insights';
$menu_title = '<span class="yoast-brand-insights-gradient-border">'
. '<span class="yoast-brand-insights-content">'
. $button_content
. Brand_Insights_Page::EXTERNAL_LINK_ICON
. '</span></span>';
$wp_admin_bar->add_menu(
[
'parent' => self::MENU_IDENTIFIER,
'id' => $page,
'title' => $menu_title,
'href' => admin_url( 'admin.php?page=' . $page ),
'meta' => [
'tabindex' => '0',
'target' => '_blank',
],
]
);
}
/**
* Adds the admin bar settings submenu.
*
@@ -659,6 +697,11 @@ class WPSEO_Admin_Bar_Menu implements WPSEO_WordPress_Integration {
continue;
}
// Don't add the Brand Insights menu items (they're now in the main menu).
if ( $submenu_page[4] === 'wpseo_brand_insights' || $submenu_page[4] === 'wpseo_brand_insights_premium' ) {
continue;
}
$id = 'wpseo-' . str_replace( '_', '-', str_replace( 'wpseo_', '', $submenu_page[4] ) );
if ( $id === 'wpseo-dashboard' ) {
$id = 'wpseo-general';
@@ -920,9 +963,9 @@ class WPSEO_Admin_Bar_Menu implements WPSEO_WordPress_Integration {
/**
* Add submenu items to a menu item.
*
* @param array $submenu_items Submenu items array.
* @param WP_Admin_Bar $wp_admin_bar Admin bar object.
* @param string $parent_id Parent menu item ID.
* @param array<array{id: string, title: string, href: string}> $submenu_items Submenu items array.
* @param WP_Admin_Bar $wp_admin_bar Admin bar object.
* @param string $parent_id Parent menu item ID.
*
* @return void
*/
@@ -154,6 +154,7 @@ class WPSEO_Option_Wpseo extends WPSEO_Option {
'default_seo_title' => [],
'default_seo_meta_desc' => [],
'first_activated_by' => 0,
'enable_task_list' => true,
];
/**
@@ -547,6 +548,7 @@ class WPSEO_Option_Wpseo extends WPSEO_Option {
* 'site_kit_connected',
* 'google_site_kit_feature_enabled',
* 'enable_llms_txt',
* 'enable_task_list',
* and most of the feature variables.
*/
default:
@@ -617,6 +619,7 @@ class WPSEO_Option_Wpseo extends WPSEO_Option {
'algolia_integration_active' => false,
'google_site_kit_feature_enabled' => false,
'enable_llms_txt' => false,
'enable_task_list' => false,
];
// We can reuse this logic from the base class with the above defaults to parse with the correct feature values.