rebase code on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:51:46 -04:00
parent b16ad94b69
commit 8f1a2c3a66
2197 changed files with 184921 additions and 35568 deletions

View File

@@ -109,9 +109,7 @@ class Admin_Columns_Cache_Integration implements Integration_Interface {
$indexables = $this->indexable_repository->find_by_multiple_ids_and_type( $post_ids, 'post', false );
foreach ( $indexables as $indexable ) {
if ( $indexable instanceof Indexable ) {
$this->indexable_cache[ $indexable->object_id ] = $indexable;
}
$this->indexable_cache[ $indexable->object_id ] = $indexable;
}
}

View File

@@ -7,6 +7,7 @@ use WPSEO_Addon_Manager;
use WPSEO_Admin_Asset_Manager;
use WPSEO_Option_Tab;
use WPSEO_Shortlinker;
use WPSEO_Utils;
use Yoast\WP\SEO\Conditionals\Admin_Conditional;
use Yoast\WP\SEO\Context\Meta_Tags_Context;
use Yoast\WP\SEO\Helpers\Options_Helper;
@@ -139,8 +140,8 @@ class First_Time_Configuration_Integration implements Integration_Interface {
$this->admin_asset_manager->enqueue_script( 'indexation' );
$this->admin_asset_manager->enqueue_script( 'first-time-configuration' );
$this->admin_asset_manager->enqueue_style( 'first-time-configuration' );
$this->admin_asset_manager->enqueue_style( 'admin-css' );
$this->admin_asset_manager->enqueue_style( 'tailwind' );
$this->admin_asset_manager->enqueue_style( 'monorepo' );
$data = [
@@ -184,44 +185,78 @@ class First_Time_Configuration_Integration implements Integration_Interface {
$selected_option_label = $selected_option['label'];
}
$data_ftc = [
'canEditUser' => $this->can_edit_profile( $person_id ),
'companyOrPerson' => $this->is_company_or_person(),
'companyOrPersonLabel' => $selected_option_label,
'companyName' => $this->get_company_name(),
'fallbackCompanyName' => $this->get_fallback_company_name( $this->get_company_name() ),
'websiteName' => $this->get_website_name(),
'fallbackWebsiteName' => $this->get_fallback_website_name( $this->get_website_name() ),
'companyLogo' => $this->get_company_logo(),
'companyLogoFallback' => $this->get_company_fallback_logo( $this->get_company_logo() ),
'companyLogoId' => $this->get_person_logo_id(),
'finishedSteps' => $finished_steps,
'personId' => (int) $person_id,
'personName' => $this->get_person_name(),
'personLogo' => $this->get_person_logo(),
'personLogoFallback' => $this->get_person_fallback_logo( $this->get_person_logo() ),
'personLogoId' => $this->get_person_logo_id(),
'siteTagline' => $this->get_site_tagline(),
'socialProfiles' => [
'facebookUrl' => $social_profiles['facebook_site'],
'twitterUsername' => $social_profiles['twitter_site'],
'otherSocialUrls' => $social_profiles['other_social_urls'],
],
'isPremium' => $this->product_helper->is_premium(),
'tracking' => $this->has_tracking_enabled(),
'isTrackingAllowedMultisite' => $this->is_tracking_enabled_multisite(),
'isMainSite' => $this->is_main_site(),
'companyOrPersonOptions' => $options,
'shouldForceCompany' => $this->should_force_company(),
'knowledgeGraphMessage' => $knowledge_graph_message,
'shortlinks' => [
'gdpr' => $this->shortlinker->build_shortlink( 'https://yoa.st/gdpr-config-workout' ),
'configIndexables' => $this->shortlinker->build_shortlink( 'https://yoa.st/config-indexables' ),
'configIndexablesBenefits' => $this->shortlinker->build_shortlink( 'https://yoa.st/config-indexables-benefits' ),
],
];
$this->admin_asset_manager->localize_script( 'first-time-configuration', 'wpseoFirstTimeConfigurationData', $data_ftc );
$this->admin_asset_manager->add_inline_script(
'first-time-configuration',
\sprintf(
'window.wpseoFirstTimeConfigurationData = {
"canEditUser": %d,
"companyOrPerson": "%s",
"companyOrPersonLabel": "%s",
"companyName": "%s",
"fallbackCompanyName": "%s",
"websiteName": "%s",
"fallbackWebsiteName": "%s",
"companyLogo": "%s",
"companyLogoFallback": "%s",
"companyLogoId": %d,
"finishedSteps": %s,
"personId": %d,
"personName": "%s",
"personLogo": "%s",
"personLogoFallback": "%s",
"personLogoId": %d,
"siteTagline": "%s",
"socialProfiles": {
"facebookUrl": "%s",
"twitterUsername": "%s",
"otherSocialUrls": %s,
},
"isPremium": %d,
"tracking": %d,
"isTrackingAllowedMultisite": %d,
"isMainSite": %d,
"companyOrPersonOptions": %s,
"shouldForceCompany": %d,
"knowledgeGraphMessage": "%s",
"shortlinks": {
"gdpr": "%s",
"configIndexables": "%s",
"configIndexablesBenefits": "%s",
},
};',
$this->can_edit_profile( $person_id ),
$this->is_company_or_person(),
$selected_option_label,
$this->get_company_name(),
$this->get_fallback_company_name( $this->get_company_name() ),
$this->get_website_name(),
$this->get_fallback_website_name( $this->get_website_name() ),
$this->get_company_logo(),
$this->get_company_fallback_logo( $this->get_company_logo() ),
$this->get_company_logo_id(),
WPSEO_Utils::format_json_encode( $finished_steps ),
$person_id,
$this->get_person_name(),
$this->get_person_logo(),
$this->get_person_fallback_logo( $this->get_person_logo() ),
$this->get_person_logo_id(),
$this->get_site_tagline(),
$social_profiles['facebook_site'],
$social_profiles['twitter_site'],
WPSEO_Utils::format_json_encode( $social_profiles['other_social_urls'] ),
$this->product_helper->is_premium(),
$this->has_tracking_enabled(),
$this->is_tracking_enabled_multisite(),
$this->is_main_site(),
WPSEO_Utils::format_json_encode( $options ),
$this->should_force_company(),
$knowledge_graph_message,
$this->shortlinker->build_shortlink( 'https://yoa.st/gdpr-config-workout' ),
$this->shortlinker->build_shortlink( 'https://yoa.st/config-indexables' ),
$this->shortlinker->build_shortlink( 'https://yoa.st/config-indexables-benefits' )
),
'before'
);
}
/**

View File

@@ -243,7 +243,7 @@ class Workouts_Integration implements Integration_Interface {
$notice = new Notice_Presenter(
$title,
$copy,
null,
'Assistent_Time_bubble_500x570.png',
$button
);

View File

@@ -1,17 +0,0 @@
<?php
namespace Yoast\WP\SEO\Integrations\Alerts;
/**
* Black_Friday_Product_Editor_Checklist_Notification class.
* @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
*/
class Black_Friday_Product_Editor_Checklist_Notification extends Abstract_Dismissable_Alert {
/**
* Holds the alert identifier.
*
* @var string
*/
protected $alert_identifier = 'black-friday-2023-product-editor-checklist';
}

View File

@@ -1,16 +0,0 @@
<?php
namespace Yoast\WP\SEO\Integrations\Alerts;
/**
* Black_Friday_Promo_Notification class.
*/
class Black_Friday_Promo_Notification extends Abstract_Dismissable_Alert {
/**
* Holds the alert identifier.
*
* @var string
*/
protected $alert_identifier = 'black-friday-promo-notification';
}

View File

@@ -125,7 +125,7 @@ class Cleanup_Integration implements Integration_Interface {
return $this->cleanup_repository->update_indexables_author_to_reassigned( $limit );
},
'clean_orphaned_user_indexables_without_wp_user' => function ( $limit ) {
return $this->cleanup_repository->clean_indexables_for_orphaned_users( $limit );
return $this->cleanup_repository->clean_indexables_for_object_type_and_source_table( 'users', 'ID', 'user', $limit );
},
'clean_orphaned_user_indexables_without_wp_post' => function ( $limit ) {
return $this->cleanup_repository->clean_indexables_for_object_type_and_source_table( 'posts', 'ID', 'post', $limit );

View File

@@ -2,7 +2,6 @@
namespace Yoast\WP\SEO\Integrations;
use WP_HTML_Tag_Processor;
use WPSEO_Replace_Vars;
use Yoast\WP\SEO\Conditionals\Front_End_Conditional;
use Yoast\WP\SEO\Context\Meta_Tags_Context;
@@ -176,20 +175,6 @@ class Front_End_Integration implements Integration_Interface {
'Schema',
];
/**
* The next output.
*
* @var string
*/
protected $next;
/**
* The prev output.
*
* @var string
*/
protected $prev;
/**
* Returns the conditionals based on which this loadable should be active.
*
@@ -234,8 +219,6 @@ class Front_End_Integration implements Integration_Interface {
* to avoid duplicate and/or mismatched metadata.
*/
public function register_hooks() {
\add_filter( 'render_block', [ $this, 'query_loop_next_prev' ], 1, 2 );
\add_action( 'wp_head', [ $this, 'call_wpseo_head' ], 1 );
// Filter the title for compatibility with other plugins and themes.
\add_filter( 'wp_title', [ $this, 'filter_title' ], 15 );
@@ -279,72 +262,6 @@ class Front_End_Integration implements Integration_Interface {
return $title;
}
/**
* Filters the next and prev links in the query loop block.
*
* @param string $html The HTML output.
* @param array $block The block.
* @return string The filtered HTML output.
*/
public function query_loop_next_prev( $html, $block ) {
if ( $block['blockName'] === 'core/query' ) {
// Check that the query does not inherit the main query.
if ( isset( $block['attrs']['query']['inherit'] ) && ! $block['attrs']['query']['inherit'] ) {
\add_filter( 'wpseo_adjacent_rel_url', [ $this, 'adjacent_rel_url' ], 1, 3 );
}
}
if ( $block['blockName'] === 'core/query-pagination-next' ) {
$this->next = $html;
}
if ( $block['blockName'] === 'core/query-pagination-previous' ) {
$this->prev = $html;
}
return $html;
}
/**
* Returns correct adjacent pages when QUery loop block does not inherit query from template.
*
* @param string $link The current link.
* @param string $rel Link relationship, prev or next.
* @param Indexable_Presentation|null $presentation The indexable presentation.
*
* @return string The correct link.
*/
public function adjacent_rel_url( $link, $rel, $presentation = null ) {
if ( $link === \home_url( '/' ) ) {
return $link;
}
if ( $rel === 'next' || $rel === 'prev' ) {
// WP_HTML_Tag_Processor was introduced in WordPress 6.2.
if ( \class_exists( WP_HTML_Tag_Processor::class ) ) {
$processor = new WP_HTML_Tag_Processor( $this->$rel );
while ( $processor->next_tag( [ 'tag_name' => 'a' ] ) ) {
$href = $processor->get_attribute( 'href' );
if ( $href ) {
return $presentation->permalink . substr( $href, 1 );
}
}
}
// Remove else when dropping support for WordPress 6.1 and lower.
else {
$pattern = '/"(.*?)"/';
// Find all matches of the pattern in the HTML string.
\preg_match_all( $pattern, $this->$rel, $matches );
if ( isset( $matches[1] ) && isset( $matches[1][0] ) && $matches[1][0] ) {
return $presentation->permalink . \substr( $matches[1][0], 1 );
}
}
}
return $link;
}
/**
* Filters our robots presenter, but only when wp_robots is attached to the wp_head action.
*

View File

@@ -20,13 +20,10 @@ use WPSEO_Shortlinker;
use WPSEO_Utils;
use Yoast\WP\SEO\Actions\Alert_Dismissal_Action;
use Yoast\WP\SEO\Conditionals\Third_Party\Elementor_Edit_Conditional;
use Yoast\WP\SEO\Conditionals\WooCommerce_Conditional;
use Yoast\WP\SEO\Helpers\Capability_Helper;
use Yoast\WP\SEO\Helpers\Options_Helper;
use Yoast\WP\SEO\Integrations\Integration_Interface;
use Yoast\WP\SEO\Introductions\Infrastructure\Wistia_Embed_Permission_Repository;
use Yoast\WP\SEO\Presenters\Admin\Meta_Fields_Presenter;
use Yoast\WP\SEO\Promotions\Application\Promotion_Manager_Interface;
/**
* Integrates the Yoast SEO metabox in the Elementor editor.
@@ -101,13 +98,6 @@ class Elementor implements Integration_Interface {
*/
protected $inclusive_language_analysis;
/**
* The promotions manager.
*
* @var Promotion_Manager_Interface
*/
private $promotion_manager;
/**
* Returns the conditionals based in which this loadable should be active.
*
@@ -120,21 +110,18 @@ class Elementor implements Integration_Interface {
/**
* Constructor.
*
* @param WPSEO_Admin_Asset_Manager $asset_manager The asset manager.
* @param Options_Helper $options The options helper.
* @param Capability_Helper $capability The capability helper.
* @param Promotion_Manager_Interface $promotion_manager The promotions manager.
* @param WPSEO_Admin_Asset_Manager $asset_manager The asset manager.
* @param Options_Helper $options The options helper.
* @param Capability_Helper $capability The capability helper.
*/
public function __construct(
WPSEO_Admin_Asset_Manager $asset_manager,
Options_Helper $options,
Capability_Helper $capability,
Promotion_Manager_Interface $promotion_manager
Capability_Helper $capability
) {
$this->asset_manager = $asset_manager;
$this->options = $options;
$this->capability = $capability;
$this->promotion_manager = $promotion_manager;
$this->asset_manager = $asset_manager;
$this->options = $options;
$this->capability = $capability;
$this->seo_analysis = new WPSEO_Metabox_Analysis_SEO();
$this->readability_analysis = new WPSEO_Metabox_Analysis_Readability();
@@ -414,7 +401,6 @@ class Elementor implements Integration_Interface {
$this->asset_manager->enqueue_style( 'scoring' );
$this->asset_manager->enqueue_style( 'monorepo' );
$this->asset_manager->enqueue_style( 'admin-css' );
$this->asset_manager->enqueue_style( 'ai-generator' );
$this->asset_manager->enqueue_style( 'elementor' );
$this->asset_manager->enqueue_script( 'admin-global' );
@@ -448,31 +434,24 @@ class Elementor implements Integration_Interface {
'enabled_features' => WPSEO_Utils::retrieve_enabled_features(),
];
$alert_dismissal_action = \YoastSEO()->classes->get( Alert_Dismissal_Action::class );
$dismissed_alerts = $alert_dismissal_action->all_dismissed();
$woocommerce_conditional = new WooCommerce_Conditional();
$alert_dismissal_action = \YoastSEO()->classes->get( Alert_Dismissal_Action::class );
$dismissed_alerts = $alert_dismissal_action->all_dismissed();
$script_data = [
'media' => [ 'choose_image' => \__( 'Use Image', 'wordpress-seo' ) ],
'metabox' => $this->get_metabox_script_data(),
'userLanguageCode' => WPSEO_Language_Utils::get_language( \get_user_locale() ),
'isPost' => true,
'isBlockEditor' => WP_Screen::get()->is_block_editor(),
'isElementorEditor' => true,
'isWooCommerceActive' => $woocommerce_conditional->is_met(),
'postStatus' => \get_post_status( $post_id ),
'postType' => \get_post_type( $post_id ),
'analysis' => [
'media' => [ 'choose_image' => \__( 'Use Image', 'wordpress-seo' ) ],
'metabox' => $this->get_metabox_script_data(),
'userLanguageCode' => WPSEO_Language_Utils::get_language( \get_user_locale() ),
'isPost' => true,
'isBlockEditor' => WP_Screen::get()->is_block_editor(),
'isElementorEditor' => true,
'postStatus' => \get_post_status( $post_id ),
'analysis' => [
'plugins' => $plugins_script_data,
'worker' => $worker_script_data,
],
'dismissedAlerts' => $dismissed_alerts,
'webinarIntroElementorUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/webinar-intro-elementor' ),
'blackFridayBlockEditorUrl' => ( $this->promotion_manager->is( 'black_friday_2023_checklist' ) ) ? WPSEO_Shortlinker::get( 'https://yoa.st/black-friday-checklist' ) : '',
'usedKeywordsNonce' => \wp_create_nonce( 'wpseo-keyword-usage-and-post-types' ),
'linkParams' => WPSEO_Shortlinker::get_query_params(),
'pluginUrl' => \plugins_url( '', \WPSEO_FILE ),
'wistiaEmbedPermission' => \YoastSEO()->classes->get( Wistia_Embed_Permission_Repository::class )->get_value_for_user( \get_current_user_id() ),
'dismissedAlerts' => $dismissed_alerts,
'webinarIntroElementorUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/webinar-intro-elementor' ),
'usedKeywordsNonce' => \wp_create_nonce( 'wpseo-keyword-usage-and-post-types' ),
];
if ( \post_type_supports( $this->get_metabox_post()->post_type, 'thumbnail' ) ) {

View File

@@ -99,8 +99,7 @@ class Indexable_Post_Type_Change_Watcher implements Integration_Interface {
return;
}
$public_post_types = $this->post_type_helper->get_indexable_post_types();
$public_post_types = \array_keys( $this->post_type_helper->get_public_post_types() );
$last_known_public_post_types = $this->options->get( 'last_known_public_post_types', [] );
// Initializing the option on the first run.
@@ -109,7 +108,6 @@ class Indexable_Post_Type_Change_Watcher implements Integration_Interface {
return;
}
// We look for new public post types.
$newly_made_public_post_types = \array_diff( $public_post_types, $last_known_public_post_types );
// We look for post types that from public have been made private.
@@ -124,7 +122,7 @@ class Indexable_Post_Type_Change_Watcher implements Integration_Interface {
$this->options->set( 'last_known_public_post_types', $public_post_types );
// There are new post types that have been made public.
if ( $newly_made_public_post_types ) {
if ( ! empty( $newly_made_public_post_types ) ) {
// Force a notification requesting to start the SEO data optimization.
\delete_transient( Indexable_Post_Indexation_Action::UNINDEXED_COUNT_TRANSIENT );
@@ -136,7 +134,7 @@ class Indexable_Post_Type_Change_Watcher implements Integration_Interface {
}
// There are post types that have been made private.
if ( $newly_made_non_public_post_types ) {
if ( ! empty( $newly_made_non_public_post_types ) ) {
// Schedule a cron job to remove all the posts whose post type has been made private.
$cleanup_not_yet_scheduled = ! \wp_next_scheduled( Cleanup_Integration::START_HOOK );
if ( $cleanup_not_yet_scheduled ) {

View File

@@ -101,8 +101,7 @@ class Indexable_Taxonomy_Change_Watcher implements Integration_Interface {
return;
}
$public_taxonomies = $this->taxonomy_helper->get_indexable_taxonomies();
$public_taxonomies = \array_keys( $this->taxonomy_helper->get_public_taxonomies() );
$last_known_public_taxonomies = $this->options->get( 'last_known_public_taxonomies', [] );
// Initializing the option on the first run.
@@ -113,7 +112,6 @@ class Indexable_Taxonomy_Change_Watcher implements Integration_Interface {
// We look for new public taxonomies.
$newly_made_public_taxonomies = \array_diff( $public_taxonomies, $last_known_public_taxonomies );
// We look fortaxonomies that from public have been made private.
$newly_made_non_public_taxonomies = \array_diff( $last_known_public_taxonomies, $public_taxonomies );