Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update plugin wordpress-seo from 15.6.2 to 16.0.2 #46

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 0 additions & 22 deletions plugins/wordpress-seo/admin/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,28 +316,6 @@ function wpseo_register_ajax_integrations() {

/* ********************* DEPRECATED FUNCTIONS ********************* */

/**
* Used in the editor to replace vars for the snippet preview.
*
* @deprecated 11.9
* @codeCoverageIgnore
*/
function wpseo_ajax_replace_vars() {
_deprecated_function( __METHOD__, 'WPSEO 11.9' );

global $post;
check_ajax_referer( 'wpseo-replace-vars' );

$post = get_post( intval( filter_input( INPUT_POST, 'post_id' ) ) );
global $wp_query;
$wp_query->queried_object = $post;
$wp_query->queried_object_id = $post->ID;

$omit = [ 'excerpt', 'excerpt_only', 'title' ];
echo wpseo_replace_vars( stripslashes( filter_input( INPUT_POST, 'string' ) ), $post, $omit );
die;
}

/**
* Hides the default tagline notice for a specific user.
*
Expand Down
34 changes: 21 additions & 13 deletions plugins/wordpress-seo/admin/class-admin-asset-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ protected function scripts_to_be_registered() {
'jquery-ui-core',
'jquery-ui-progressbar',
'wp-api',
'wp-data',
'yoast-seo-api',
self::PREFIX . 'yoast-components',
self::PREFIX . 'helpers',
self::PREFIX . 'replacement-variable-editor',
Expand Down Expand Up @@ -310,6 +312,7 @@ protected function scripts_to_be_registered() {
'wp-i18n',
'wp-plugins',
'wp-rich-text',
'yoast-seo-api',
self::PREFIX . 'yoast-components',
self::PREFIX . 'legacy-components',
self::PREFIX . 'search-metadata-previews',
Expand All @@ -327,6 +330,7 @@ protected function scripts_to_be_registered() {
'wp-components',
'wp-compose',
'wp-element',
'yoast-seo-api',
self::PREFIX . 'redux',
self::PREFIX . 'yoast-components',
self::PREFIX . 'legacy-components',
Expand Down Expand Up @@ -612,6 +616,18 @@ protected function scripts_to_be_registered() {
self::PREFIX . 'yoast-components',
],
],
[
/**
* Yoast dynamic blocks
*/
'name' => 'dynamic-blocks',
'src' => 'dynamic-blocks-' . $flat_version,
'deps' => [
'wp-blocks',
'wp-i18n',
'wp-server-side-render',
],
],
[
// The `@yoast/components` package.
'name' => 'yoast-components',
Expand Down Expand Up @@ -787,6 +803,7 @@ protected function scripts_to_be_registered() {
'wp-sanitize',
'wp-api-fetch',
'wp-hooks',
'yoast-seo-api',
self::PREFIX . 'components',
self::PREFIX . 'analysis',
self::PREFIX . 'commons',
Expand Down Expand Up @@ -831,6 +848,10 @@ protected function styles_to_be_registered() {
'name' => 'alert',
'src' => 'alerts-' . $flat_version,
],
[
'name' => 'badge',
'src' => 'badge-' . $flat_version,
],
[
'name' => 'edit-page',
'src' => 'edit-page-' . $flat_version,
Expand Down Expand Up @@ -933,17 +954,4 @@ protected function get_url( WPSEO_Admin_Asset $asset, $type ) {

return $this->asset_location->get_url( $asset, $type );
}

/* ********************* DEPRECATED METHODS ********************* */

/**
* This function is needed for backwards compatibility with Local SEO 12.5.
*
* @deprecated 12.8
* @codeCoverageIgnore
*
* @return void
*/
public function register_wp_assets() {
}
}
161 changes: 1 addition & 160 deletions plugins/wordpress-seo/admin/class-admin-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function __construct() {

add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_dismissible' ] );
add_action( 'admin_init', [ $this, 'yoast_plugin_suggestions_notification' ], 15 );
add_action( 'admin_init', [ $this, 'yoast_plugin_update_notification' ] );
add_action( 'admin_init', [ $this, 'unsupported_php_notice' ], 15 );
add_action( 'admin_init', [ $this->asset_manager, 'register_assets' ] );
add_action( 'admin_init', [ $this, 'show_hook_deprecation_warnings' ] );
Expand Down Expand Up @@ -132,106 +131,6 @@ private function get_yoast_seo_suggested_plugins_notification( $name, $plugin, $
);
}

/**
* Determines whether a update notification needs to be displayed.
*
* @return void
*/
public function yoast_plugin_update_notification() {
$notification_center = Yoast_Notification_Center::get();
$current_minor_version = $this->get_major_minor_version( WPSEO_Options::get( 'version', WPSEO_VERSION ) );
$file = plugin_dir_path( WPSEO_FILE ) . 'release-info.json';

// Remove if file is not present.
if ( ! file_exists( $file ) ) {
$notification_center->remove_notification_by_id( 'wpseo-plugin-updated' );
return;
}

// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Retrieving a local file.
$release_json = file_get_contents( $file );

/**
* Filter: 'wpseo_update_notice_content' - Allow filtering of the content
* of the update notice read from the release-info.json file.
*
* @api object The object from the release-info.json file.
*/
$release_info = apply_filters( 'wpseo_update_notice_content', json_decode( $release_json ) );

// Remove if file is malformed or for a different version.
if ( is_null( $release_info )
|| empty( $release_info->version )
|| version_compare( $this->get_major_minor_version( $release_info->version ), $current_minor_version, '!=' )
|| empty( $release_info->release_description )
) {
$notification_center->remove_notification_by_id( 'wpseo-plugin-updated' );
return;
}

$notification = $this->get_yoast_seo_update_notification( $release_info );

// Restore notification if it was dismissed in a previous minor version.
$last_dismissed_version = get_user_option( $notification->get_dismissal_key() );
if ( ! $last_dismissed_version
|| version_compare( $this->get_major_minor_version( $last_dismissed_version ), $current_minor_version, '<' )
) {
Yoast_Notification_Center::restore_notification( $notification );
}
$notification_center->add_notification( $notification );
}

/**
* Helper to truncate the version string up to the minor number
*
* @param string $version The version string to extract the major.minor number from.
* @return string The version string up to the minor number.
*/
private function get_major_minor_version( $version ) {
$version_parts = preg_split( '/[^0-9]+/', $version, 3 );
return join( '.', array_slice( $version_parts, 0, 2 ) );
}

/**
* Builds Yoast SEO update notification.
*
* @param object $release_info The release information.
*
* @return Yoast_Notification The notification for the present version
*/
private function get_yoast_seo_update_notification( $release_info ) {
$info_message = '<strong>';
$info_message .= sprintf(
/* translators: %1$s expands to Yoast SEO, %2$s expands to the plugin version. */
__( 'New in %1$s %2$s: ', 'wordpress-seo' ),
'Yoast SEO',
$release_info->version
);
$info_message .= '</strong>';
$info_message .= $release_info->release_description;

if ( ! empty( $release_info->shortlink ) ) {
$link = esc_url( WPSEO_Shortlinker::get( $release_info->shortlink ) );
$info_message .= ' <a href="' . esc_url( $link ) . '" target="_blank">';
$info_message .= sprintf(
/* translators: %s expands to the plugin version. */
__( 'Read all about version %s here', 'wordpress-seo' ),
$release_info->version
);
$info_message .= '</a>';
}

return new Yoast_Notification(
$info_message,
[
'id' => 'wpseo-plugin-updated',
'type' => Yoast_Notification::UPDATED,
'data_json' => [ 'dismiss_value' => WPSEO_Options::get( 'version', WPSEO_VERSION ) ],
'dismissal_key' => 'wpseo-plugin-updated',
]
);
}

/**
* Creates an unsupported PHP version notification in the notification center.
*
Expand Down Expand Up @@ -354,7 +253,7 @@ private function load_plugin_suggestions() {
* @return void
*/
private function register_premium_upsell_admin_block() {
if ( ! WPSEO_Utils::is_yoast_seo_premium() ) {
if ( ! YoastSEO()->helpers->product->is_premium() ) {
$upsell_block = new WPSEO_Premium_Upsell_Admin_Block( 'wpseo_admin_promo_footer' );
$upsell_block->register_hooks();
}
Expand Down Expand Up @@ -586,64 +485,6 @@ public function add_publish_box_section( $post ) {

/* ********************* DEPRECATED METHODS ********************* */

/**
* Add an alert if outdated versions of Yoast SEO plugins are running.
*
* @deprecated 12.3
* @codeCoverageIgnore
*/
public function yoast_plugin_compatibility_notification() {
_deprecated_function( __METHOD__, 'WPSEO 12.3' );
}

/**
* Creates a WordPress upgrade notification in the notification center.
*
* @deprecated 12.5
* @codeCoverageIgnore
*
* @return void
*/
public function wordpress_upgrade_notice() {
_deprecated_function( __METHOD__, 'WPSEO 12.5' );
}

/**
* Shows a notice to the user if they have Google Analytics for WordPress 5.4.3 installed because it causes an error
* on the google search console page.
*
* @deprecated 12.5
*
* @codeCoverageIgnore
*/
public function ga_compatibility_notice() {
_deprecated_function( __METHOD__, 'WPSEO 12.5' );
}

/**
* Display notice to disable comment pagination.
*
* @deprecated 12.8
* @codeCoverageIgnore
*/
public function page_comments_notice() {
_deprecated_function( __METHOD__, 'WPSEO 12.8' );
}

/**
* Are page comments enabled.
*
* @deprecated 12.8
* @codeCoverageIgnore
*
* @return bool
*/
public function has_page_comments() {
_deprecated_function( __METHOD__, 'WPSEO 12.8' );

return get_option( 'page_comments' ) === '1';
}

/**
* Notify about the default tagline if the user hasn't changed it.
*
Expand Down
58 changes: 20 additions & 38 deletions plugins/wordpress-seo/admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function __construct() {
}

add_filter( 'plugin_action_links_' . WPSEO_BASENAME, [ $this, 'add_action_link' ], 10, 2 );
add_filter( 'network_admin_plugin_action_links_' . WPSEO_BASENAME, [ $this, 'add_action_link' ], 10, 2 );

add_action( 'admin_enqueue_scripts', [ $this, 'config_page_scripts' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_global_style' ] );
Expand Down Expand Up @@ -106,7 +107,6 @@ public function __construct() {
$integrations[] = new WPSEO_Schema_Person_Upgrade_Notification();
$integrations[] = new WPSEO_Tracking( 'https://tracking.yoast.com/stats', ( WEEK_IN_SECONDS * 2 ) );
$integrations[] = new WPSEO_Admin_Settings_Changed_Listener();
$integrations[] = $this->get_helpscout_beacon();

$integrations = array_merge(
$integrations,
Expand Down Expand Up @@ -219,7 +219,13 @@ public function save_bulk_edit_options( $status, $option, $value ) {
*/
public function add_action_link( $links, $file ) {
if ( WPSEO_BASENAME === $file && WPSEO_Capability_Utils::current_user_can( 'wpseo_manage_options' ) ) {
$settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=' . self::PAGE_IDENTIFIER ) ) . '">' . __( 'Settings', 'wordpress-seo' ) . '</a>';
if ( is_network_admin() ) {
$settings_url = network_admin_url( 'admin.php?page=' . self::PAGE_IDENTIFIER );
}
else {
$settings_url = admin_url( 'admin.php?page=' . self::PAGE_IDENTIFIER );
}
$settings_link = '<a href="' . esc_url( $settings_url ) . '">' . __( 'Settings', 'wordpress-seo' ) . '</a>';
array_unshift( $links, $settings_link );
}

Expand All @@ -228,7 +234,18 @@ public function add_action_link( $links, $file ) {
array_unshift( $links, $faq_link );

$addon_manager = new WPSEO_Addon_Manager();
if ( WPSEO_Utils::is_yoast_seo_premium() ) {
if ( YoastSEO()->helpers->product->is_premium() ) {

// Remove Free 'deactivate' link if Premium is active as well. We don't want users to deactivate Free when Premium is active.
unset( $links['deactivate'] );
$no_deactivation_explanation = '<span style="color: #32373c">' . sprintf(
/* translators: %s expands to Yoast SEO Premium. */
__( 'Required by %s', 'wordpress-seo' ),
'Yoast SEO Premium'
) . '</span>';

array_unshift( $links, $no_deactivation_explanation );

if ( $addon_manager->has_valid_subscription( WPSEO_Addon_Manager::PREMIUM_SLUG ) ) {
return $links;
}
Expand Down Expand Up @@ -352,39 +369,4 @@ protected function initialize_cornerstone_content() {
'cornerstone_filter' => new WPSEO_Cornerstone_Filter(),
];
}

/**
* Retrieves an instance of the HelpScout beacon class for Yoast SEO.
*
* @return WPSEO_HelpScout The instance of the HelpScout beacon.
*/
private function get_helpscout_beacon() {
$helpscout_settings = [
'beacon_id' => '2496aba6-0292-489c-8f5d-1c0fba417c2f',
'pages' => [
'wpseo_dashboard',
'wpseo_titles',
'wpseo_search_console',
'wpseo_social',
'wpseo_tools',
'wpseo_licenses',
],
'products' => [],
'ask_consent' => true,
];

/**
* Filter: 'wpseo_helpscout_beacon_settings' - Allows overriding the HelpScout beacon settings.
*
* @api string - The helpscout beacons settings.
*/
$helpscout_settings = apply_filters( 'wpseo_helpscout_beacon_settings', $helpscout_settings );

return new WPSEO_HelpScout(
$helpscout_settings['beacon_id'],
$helpscout_settings['pages'],
$helpscout_settings['products'],
$helpscout_settings['ask_consent']
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ protected function get_meta_data_result( $post_ids ) {
"
SELECT *
FROM {$wpdb->postmeta}
WHERE post_id IN({$post_ids}) && meta_key = '" . WPSEO_Meta::$meta_prefix . $this->target_db_field . "'
WHERE post_id IN({$post_ids}) AND meta_key = '" . WPSEO_Meta::$meta_prefix . $this->target_db_field . "'
"
);

Expand Down
Loading