Merged in feature/314-dev-dev01 (pull request #24)

auto-patch  314-dev-dev01-2024-01-25T04_09_02

* auto-patch  314-dev-dev01-2024-01-25T04_09_02
This commit is contained in:
Tony Volpe
2024-01-25 04:11:47 +00:00
parent 6b67473553
commit 68dbe860e9
540 changed files with 3445 additions and 2131 deletions

View File

@@ -17,14 +17,14 @@ class Addon_Update_Watcher implements Integration_Interface {
*
* @var string
*/
const WPSEO_FREE_PLUGIN_ID = 'wordpress-seo/wp-seo.php';
public const WPSEO_FREE_PLUGIN_ID = 'wordpress-seo/wp-seo.php';
/**
* A list of Yoast add-on identifiers.
*
* @var string[]
*/
const ADD_ON_PLUGIN_FILES = [
public const ADD_ON_PLUGIN_FILES = [
'wordpress-seo-premium/wp-seo-premium.php',
'wpseo-video/video-seo.php',
'wpseo-local/local-seo.php', // When installing Local through a released zip, the path is different from the path on a dev environment.
@@ -35,6 +35,8 @@ class Addon_Update_Watcher implements Integration_Interface {
/**
* Registers the hooks.
*
* @return void
*/
public function register_hooks() {
\add_action( 'add_site_option_auto_update_plugins', [ $this, 'call_toggle_auto_updates_with_empty_array' ], 10, 2 );
@@ -101,6 +103,8 @@ class Addon_Update_Watcher implements Integration_Interface {
*
* @param string $option The name of the option that is being created.
* @param array|mixed $value The new (and first) value of the option that is being created.
*
* @return void
*/
public function call_toggle_auto_updates_with_empty_array( $option, $value ) {
if ( $option !== 'auto_update_plugins' ) {
@@ -187,6 +191,8 @@ class Addon_Update_Watcher implements Integration_Interface {
* Enables auto-updates for all addons.
*
* @param string[] $auto_updated_plugins The current list of auto-updated plugins.
*
* @return void
*/
protected function enable_auto_updates_for_addons( $auto_updated_plugins ) {
$plugins = \array_unique( \array_merge( $auto_updated_plugins, self::ADD_ON_PLUGIN_FILES ) );
@@ -197,6 +203,8 @@ class Addon_Update_Watcher implements Integration_Interface {
* Disables auto-updates for all addons.
*
* @param string[] $auto_updated_plugins The current list of auto-updated plugins.
*
* @return void
*/
protected function disable_auto_updates_for_addons( $auto_updated_plugins ) {
$plugins = \array_values( \array_diff( $auto_updated_plugins, self::ADD_ON_PLUGIN_FILES ) );

View File

@@ -16,7 +16,7 @@ class Auto_Update_Watcher implements Integration_Interface {
/**
* The notification ID.
*/
const NOTIFICATION_ID = 'wpseo-auto-update';
public const NOTIFICATION_ID = 'wpseo-auto-update';
/**
* The Yoast notification center.

View File

@@ -89,6 +89,8 @@ class Indexable_Ancestor_Watcher implements Integration_Interface {
/**
* Registers the appropriate hooks.
*
* @return void
*/
public function register_hooks() {
\add_action( 'wpseo_save_indexable', [ $this, 'reset_children' ], \PHP_INT_MAX, 2 );
@@ -149,7 +151,7 @@ class Indexable_Ancestor_Watcher implements Integration_Interface {
// Removes the objects that are already present in the children.
$existing_post_indexables = \array_filter(
$child_indexables,
static function( $indexable ) {
static function ( $indexable ) {
return $indexable->object_type === 'post';
}
);
@@ -178,6 +180,8 @@ class Indexable_Ancestor_Watcher implements Integration_Interface {
* Updates the indexable hierarchy and indexable permalink.
*
* @param Indexable $indexable The indexable to update the hierarchy and permalink for.
*
* @return void
*/
protected function update_hierarchy_and_permalink( $indexable ) {
if ( \is_a( $indexable, Indexable::class ) ) {
@@ -197,7 +201,7 @@ class Indexable_Ancestor_Watcher implements Integration_Interface {
* @return array List with object ids for the term.
*/
protected function get_object_ids_for_term( $term_id, $child_indexables ) {
$filter_terms = static function( $child ) {
$filter_terms = static function ( $child ) {
return $child->object_type === 'term';
};

View File

@@ -50,6 +50,8 @@ class Indexable_Author_Watcher implements Integration_Interface {
* Initializes the integration.
*
* This is the place to register hooks and filters.
*
* @return void
*/
public function register_hooks() {
\add_action( 'user_register', [ $this, 'build_indexable' ], \PHP_INT_MAX );

View File

@@ -2,6 +2,7 @@
namespace Yoast\WP\SEO\Integrations\Watchers;
use WPSEO_Utils;
use Yoast\WP\SEO\Config\Indexing_Reasons;
/**
@@ -48,6 +49,8 @@ class Indexable_Category_Permalink_Watcher extends Indexable_Permalink_Watcher {
// If a new value has been set for 'stripcategorybase', clear the category permalinks.
if ( $old_value['stripcategorybase'] !== $new_value['stripcategorybase'] ) {
$this->indexable_helper->reset_permalink_indexables( 'term', 'category', Indexing_Reasons::REASON_CATEGORY_BASE_PREFIX );
// Clear the rewrites, so the new permalink structure is used.
WPSEO_Utils::clear_rewrites();
}
}
}

View File

@@ -52,6 +52,8 @@ class Indexable_Date_Archive_Watcher implements Integration_Interface {
* Initializes the integration.
*
* This is the place to register hooks and filters.
*
* @return void
*/
public function register_hooks() {
\add_action( 'update_option_wpseo_titles', [ $this, 'check_option' ], 10, 2 );

View File

@@ -52,6 +52,8 @@ class Indexable_Home_Page_Watcher implements Integration_Interface {
* Initializes the integration.
*
* This is the place to register hooks and filters.
*
* @return void
*/
public function register_hooks() {
\add_action( 'update_option_wpseo_titles', [ $this, 'check_option' ], 15, 3 );

View File

@@ -86,6 +86,8 @@ class Indexable_Permalink_Watcher implements Integration_Interface {
/**
* Resets the permalinks for everything that is related to the permalink structure.
*
* @return void
*/
public function reset_permalinks() {
@@ -111,6 +113,8 @@ class Indexable_Permalink_Watcher implements Integration_Interface {
* Resets the permalink for the given post type.
*
* @param string $post_type The post type to reset.
*
* @return void
*/
public function reset_permalinks_post_type( $post_type ) {
$this->indexable_helper->reset_permalink_indexables( 'post', $post_type );
@@ -123,6 +127,8 @@ class Indexable_Permalink_Watcher implements Integration_Interface {
* @param string $old_value Unused. The old option value.
* @param string $new_value Unused. The new option value.
* @param string $type The option name.
*
* @return void
*/
public function reset_permalinks_term( $old_value, $new_value, $type ) {
$subtype = $type;

View File

@@ -47,6 +47,8 @@ class Indexable_Post_Meta_Watcher implements Integration_Interface {
* Initializes the integration.
*
* This is the place to register hooks and filters.
*
* @return void
*/
public function register_hooks() {
// Register all posts whose meta have changed.

View File

@@ -52,6 +52,8 @@ class Indexable_Post_Type_Archive_Watcher implements Integration_Interface {
* Initializes the integration.
*
* This is the place to register hooks and filters.
*
* @return void
*/
public function register_hooks() {
\add_action( 'update_option_wpseo_titles', [ $this, 'check_option' ], 10, 2 );

View File

@@ -109,7 +109,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.
@@ -132,7 +131,7 @@ class Indexable_Post_Type_Change_Watcher implements Integration_Interface {
$this->indexing_helper->set_reason( Indexing_Reasons::REASON_POST_TYPE_MADE_PUBLIC );
do_action( 'new_public_post_type_notifications', $newly_made_public_post_types );
\do_action( 'new_public_post_type_notifications', $newly_made_public_post_types );
}
// There are post types that have been made private.
@@ -143,7 +142,7 @@ class Indexable_Post_Type_Change_Watcher implements Integration_Interface {
\wp_schedule_single_event( ( \time() + ( \MINUTE_IN_SECONDS * 5 ) ), Cleanup_Integration::START_HOOK );
}
do_action( 'clean_new_public_post_type_notifications', $newly_made_non_public_post_types );
\do_action( 'clean_new_public_post_type_notifications', $newly_made_non_public_post_types );
}
}
}

View File

@@ -157,6 +157,8 @@ class Indexable_Post_Watcher implements Integration_Interface {
*
* @param Indexable $indexable The indexable.
* @param WP_Post $post The post.
*
* @return void
*/
public function updated_indexable( $indexable, $post ) {
// Only interested in post indexables.
@@ -218,6 +220,8 @@ class Indexable_Post_Watcher implements Integration_Interface {
* Updates the has_public_posts when the post indexable is built.
*
* @param Indexable $indexable The indexable to check.
*
* @return void
*/
protected function update_has_public_posts( $indexable ) {
// Update the author indexable's has public posts value.
@@ -259,6 +263,8 @@ class Indexable_Post_Watcher implements Integration_Interface {
* Updates the relations on post save or post status change.
*
* @param WP_Post $post The post that has been updated.
*
* @return void
*/
protected function update_relations( $post ) {
$related_indexables = $this->get_related_indexables( $post );

View File

@@ -44,6 +44,8 @@ class Indexable_Static_Home_Page_Watcher implements Integration_Interface {
* Initializes the integration.
*
* This is the place to register hooks and filters.
*
* @return void
*/
public function register_hooks() {
\add_action( 'update_option_page_on_front', [ $this, 'update_static_homepage_permalink' ], 10, 2 );
@@ -54,6 +56,8 @@ class Indexable_Static_Home_Page_Watcher implements Integration_Interface {
*
* @param string $old_value The previous homepage's ID.
* @param int $value The new homepage's ID.
*
* @return void
*/
public function update_static_homepage_permalink( $old_value, $value ) {
if ( \is_string( $old_value ) ) {
@@ -72,6 +76,8 @@ class Indexable_Static_Home_Page_Watcher implements Integration_Interface {
* Updates the permalink based on the selected homepage settings.
*
* @param int $page_id The page's id.
*
* @return void
*/
private function update_permalink_for_page( $page_id ) {
if ( $page_id === 0 ) {

View File

@@ -53,6 +53,8 @@ class Indexable_System_Page_Watcher implements Integration_Interface {
* Initializes the integration.
*
* This is the place to register hooks and filters.
*
* @return void
*/
public function register_hooks() {
\add_action( 'update_option_wpseo_titles', [ $this, 'check_option' ], 10, 2 );

View File

@@ -133,7 +133,7 @@ class Indexable_Taxonomy_Change_Watcher implements Integration_Interface {
\delete_transient( Indexable_Term_Indexation_Action::UNINDEXED_LIMITED_COUNT_TRANSIENT );
$this->indexing_helper->set_reason( Indexing_Reasons::REASON_TAXONOMY_MADE_PUBLIC );
do_action( 'new_public_taxonomy_notifications', $newly_made_public_taxonomies );
\do_action( 'new_public_taxonomy_notifications', $newly_made_public_taxonomies );
}
// There are taxonomies that have been made private.
@@ -144,7 +144,7 @@ class Indexable_Taxonomy_Change_Watcher implements Integration_Interface {
\wp_schedule_single_event( ( \time() + ( \MINUTE_IN_SECONDS * 5 ) ), Cleanup_Integration::START_HOOK );
}
do_action( 'clean_new_public_taxonomy_notifications', $newly_made_non_public_taxonomies );
\do_action( 'clean_new_public_taxonomy_notifications', $newly_made_non_public_taxonomies );
}
}
}

View File

@@ -104,6 +104,8 @@ class Primary_Category_Quick_Edit_Watcher implements Integration_Interface {
* @param array $terms Unused. An array of object terms.
* @param array $tt_ids An array of term taxonomy IDs.
* @param string $taxonomy Taxonomy slug.
*
* @return void
*/
public function validate_primary_category( $object_id, $terms, $tt_ids, $taxonomy ) {
$post = \get_post( $object_id );
@@ -159,6 +161,8 @@ class Primary_Category_Quick_Edit_Watcher implements Integration_Interface {
*
* @param int $post_id The post id to set primary taxonomy for.
* @param string $main_taxonomy Name of the taxonomy that is set to be the primary one.
*
* @return void
*/
private function remove_primary_term( $post_id, $main_taxonomy ) {
$primary_term = $this->primary_term_repository->find_by_post_id_and_taxonomy( $post_id, $main_taxonomy, false );
@@ -174,6 +178,8 @@ class Primary_Category_Quick_Edit_Watcher implements Integration_Interface {
* Builds the hierarchy for a post.
*
* @param WP_Post $post The post.
*
* @return void
*/
public function build_post_hierarchy( $post ) {
if ( $this->post_type_helper->is_excluded( $post->post_type ) ) {

View File

@@ -82,6 +82,8 @@ class Primary_Term_Watcher implements Integration_Interface {
* Initializes the integration.
*
* This is the place to register hooks and filters.
*
* @return void
*/
public function register_hooks() {
\add_action( 'save_post', [ $this, 'save_primary_terms' ], \PHP_INT_MAX );
@@ -92,6 +94,8 @@ class Primary_Term_Watcher implements Integration_Interface {
* Saves all selected primary terms.
*
* @param int $post_id Post ID to save primary terms for.
*
* @return void
*/
public function save_primary_terms( $post_id ) {
// Bail if this is a multisite installation and the site has been switched.
@@ -113,6 +117,8 @@ class Primary_Term_Watcher implements Integration_Interface {
*
* @param int $post_id Post ID to save primary term for.
* @param WP_Term $taxonomy Taxonomy to save primary term for.
*
* @return void
*/
protected function save_primary_term( $post_id, $taxonomy ) {
if ( isset( $_POST[ WPSEO_Meta::$form_prefix . 'primary_' . $taxonomy->name . '_term' ] ) && \is_string( $_POST[ WPSEO_Meta::$form_prefix . 'primary_' . $taxonomy->name . '_term' ] ) ) {

View File

@@ -14,8 +14,6 @@ use Yoast_Notification_Center;
/**
* Shows a notification for users who have access for robots disabled.
*
* @class Search_Engines_Discouraged_Watcher
*/
class Search_Engines_Discouraged_Watcher implements Integration_Interface {
@@ -24,7 +22,7 @@ class Search_Engines_Discouraged_Watcher implements Integration_Interface {
/**
* The notification ID.
*/
const NOTIFICATION_ID = 'wpseo-search-engines-discouraged';
public const NOTIFICATION_ID = 'wpseo-search-engines-discouraged';
/**
* The Yoast notification center.

View File

@@ -13,15 +13,13 @@ use Yoast_Notification_Center;
/**
* Shows a notification for users who have Woocommerce product beta editor enabled.
*
* @class Woocommerce_Beta_Editor_Watcher
*/
class Woocommerce_Beta_Editor_Watcher implements Integration_Interface {
/**
* The notification ID.
*/
const NOTIFICATION_ID = 'wpseo-woocommerce-beta-editor-warning';
public const NOTIFICATION_ID = 'wpseo-woocommerce-beta-editor-warning';
/**
* The short link helper.
@@ -56,7 +54,7 @@ class Woocommerce_Beta_Editor_Watcher implements Integration_Interface {
*
* @param Yoast_Notification_Center $notification_center The notification center.
* @param Notification_Helper $notification_helper The notification helper.
* @param Short_Link_Helper $short_link_helper The short link helper.
* @param Short_Link_Helper $short_link_helper The short link helper.
*/
public function __construct(
Yoast_Notification_Center $notification_center,