plugin updates

This commit is contained in:
Tony Volpe
2024-06-17 15:33:26 -04:00
parent 3751a5a1a6
commit e4e274a9a7
2674 changed files with 0 additions and 507851 deletions

View File

@@ -1,72 +0,0 @@
<?php
namespace Yoast\WP\SEO\Analytics\Application;
use WPSEO_Collection;
use Yoast\WP\SEO\Actions\Indexing\Indexation_Action_Interface;
use Yoast\WP\SEO\Analytics\Domain\Missing_Indexable_Bucket;
use Yoast\WP\SEO\Analytics\Domain\Missing_Indexable_Count;
/**
* Manages the collection of the missing indexable data.
*
* @makePublic
*/
class Missing_Indexables_Collector implements WPSEO_Collection {
/**
* All the indexation actions.
*
* @var array<Indexation_Action_Interface>
*/
private $indexation_actions;
/**
* The collector constructor.
*
* @param Indexation_Action_Interface ...$indexation_actions All the Indexation actions.
*/
public function __construct( Indexation_Action_Interface ...$indexation_actions ) {
$this->indexation_actions = $indexation_actions;
$this->add_additional_indexing_actions();
}
/**
* Gets the data for the tracking collector.
*
* @return array The list of missing indexables.
*/
public function get() {
$missing_indexable_bucket = new Missing_Indexable_Bucket();
foreach ( $this->indexation_actions as $indexation_action ) {
$missing_indexable_count = new Missing_Indexable_Count( \get_class( $indexation_action ), $indexation_action->get_total_unindexed() );
$missing_indexable_bucket->add_missing_indexable_count( $missing_indexable_count );
}
return [ 'missing_indexables' => $missing_indexable_bucket->to_array() ];
}
/**
* Adds additional indexing actions to count from the 'wpseo_indexable_collector_add_indexation_actions' filter.
*
* @return void
*/
private function add_additional_indexing_actions() {
/**
* Filter: Adds the possibility to add additional indexation actions to be included in the count routine.
*
* @internal
* @param Indexation_Action_Interface $actions This filter expects a list of Indexation_Action_Interface instances
* and expects only Indexation_Action_Interface implementations to be
* added to the list.
*/
$indexing_actions = (array) \apply_filters( 'wpseo_indexable_collector_add_indexation_actions', $this->indexation_actions );
$this->indexation_actions = \array_filter(
$indexing_actions,
static function ( $indexing_action ) {
return \is_a( $indexing_action, Indexation_Action_Interface::class );
}
);
}
}

View File

@@ -1,84 +0,0 @@
<?php
namespace Yoast\WP\SEO\Analytics\Application;
use WPSEO_Collection;
use Yoast\WP\SEO\Analytics\Domain\To_Be_Cleaned_Indexable_Bucket;
use Yoast\WP\SEO\Analytics\Domain\To_Be_Cleaned_Indexable_Count;
use Yoast\WP\SEO\Repositories\Indexable_Cleanup_Repository;
/**
* Collects data about to-be-cleaned indexables.
*
* @makePublic
*/
class To_Be_Cleaned_Indexables_Collector implements WPSEO_Collection {
/**
* The cleanup query repository.
*
* @var Indexable_Cleanup_Repository
*/
private $indexable_cleanup_repository;
/**
* The constructor.
*
* @param Indexable_Cleanup_Repository $indexable_cleanup_repository The Indexable cleanup repository.
*/
public function __construct( Indexable_Cleanup_Repository $indexable_cleanup_repository ) {
$this->indexable_cleanup_repository = $indexable_cleanup_repository;
}
/**
* Gets the data for the collector.
*
* @return array
*/
public function get() {
$to_be_cleaned_indexable_bucket = new To_Be_Cleaned_Indexable_Bucket();
$cleanup_tasks = [
'indexables_with_post_object_type_and_shop_order_object_sub_type' => $this->indexable_cleanup_repository->count_indexables_with_object_type_and_object_sub_type( 'post', 'shop_order' ),
'indexables_with_auto-draft_post_status' => $this->indexable_cleanup_repository->count_indexables_with_post_status( 'auto-draft' ),
'indexables_for_non_publicly_viewable_post' => $this->indexable_cleanup_repository->count_indexables_for_non_publicly_viewable_post(),
'indexables_for_non_publicly_viewable_taxonomies' => $this->indexable_cleanup_repository->count_indexables_for_non_publicly_viewable_taxonomies(),
'indexables_for_non_publicly_viewable_post_type_archive_pages' => $this->indexable_cleanup_repository->count_indexables_for_non_publicly_post_type_archive_pages(),
'indexables_for_authors_archive_disabled' => $this->indexable_cleanup_repository->count_indexables_for_authors_archive_disabled(),
'indexables_for_authors_without_archive' => $this->indexable_cleanup_repository->count_indexables_for_authors_without_archive(),
'indexables_for_object_type_and_source_table_users' => $this->indexable_cleanup_repository->count_indexables_for_orphaned_users(),
'indexables_for_object_type_and_source_table_posts' => $this->indexable_cleanup_repository->count_indexables_for_object_type_and_source_table( 'posts', 'ID', 'post' ),
'indexables_for_object_type_and_source_table_terms' => $this->indexable_cleanup_repository->count_indexables_for_object_type_and_source_table( 'terms', 'term_id', 'term' ),
'orphaned_from_table_indexable_hierarchy' => $this->indexable_cleanup_repository->count_orphaned_from_table( 'Indexable_Hierarchy', 'indexable_id' ),
'orphaned_from_table_indexable_id' => $this->indexable_cleanup_repository->count_orphaned_from_table( 'SEO_Links', 'indexable_id' ),
'orphaned_from_table_target_indexable_id' => $this->indexable_cleanup_repository->count_orphaned_from_table( 'SEO_Links', 'target_indexable_id' ),
];
foreach ( $cleanup_tasks as $name => $count ) {
if ( $count !== null ) {
$count_object = new To_Be_Cleaned_Indexable_Count( $name, $count );
$to_be_cleaned_indexable_bucket->add_to_be_cleaned_indexable_count( $count_object );
}
}
$this->add_additional_counts( $to_be_cleaned_indexable_bucket );
return [ 'to_be_cleaned_indexables' => $to_be_cleaned_indexable_bucket->to_array() ];
}
/**
* Allows additional tasks to be added via the 'wpseo_add_cleanup_counts_to_indexable_bucket' action.
*
* @param To_Be_Cleaned_Indexable_Bucket $to_be_cleaned_indexable_bucket The current bucket with data.
*
* @return void
*/
private function add_additional_counts( $to_be_cleaned_indexable_bucket ) {
/**
* Action: Adds the possibility to add additional to be cleaned objects.
*
* @internal
* @param To_Be_Cleaned_Indexable_Bucket $bucket An indexable cleanup bucket. New values are instances of To_Be_Cleaned_Indexable_Count.
*/
\do_action( 'wpseo_add_cleanup_counts_to_indexable_bucket', $to_be_cleaned_indexable_bucket );
}
}

View File

@@ -1,48 +0,0 @@
<?php
namespace Yoast\WP\SEO\Analytics\Domain;
/**
* A collection domain object.
*/
class Missing_Indexable_Bucket {
/**
* All the missing indexable count objects.
*
* @var array<Missing_Indexable_Count>
*/
private $missing_indexable_counts;
/**
* The constructor.
*/
public function __construct() {
$this->missing_indexable_counts = [];
}
/**
* Adds a missing indexable count object to this bucket.
*
* @param Missing_Indexable_Count $missing_indexable_count The missing indexable count object.
*
* @return void
*/
public function add_missing_indexable_count( Missing_Indexable_Count $missing_indexable_count ): void {
$this->missing_indexable_counts[] = $missing_indexable_count;
}
/**
* Returns the array representation of all indexable counts.
*
* @return array
*/
public function to_array() {
return \array_map(
static function ( $item ) {
return $item->to_array();
},
$this->missing_indexable_counts
);
}
}

View File

@@ -1,64 +0,0 @@
<?php
namespace Yoast\WP\SEO\Analytics\Domain;
/**
* Domain object that holds indexable count information.
*/
class Missing_Indexable_Count {
/**
* The indexable type that is represented by this.
*
* @var string
*/
private $indexable_type;
/**
* The amount of missing indexables.
*
* @var int
*/
private $count;
/**
* The constructor.
*
* @param string $indexable_type The indexable type that is represented by this.
* @param int $count The amount of missing indexables.
*/
public function __construct( $indexable_type, $count ) {
$this->indexable_type = $indexable_type;
$this->count = $count;
}
/**
* Returns an array representation of the data.
*
* @return array Returns both values in an array format.
*/
public function to_array() {
return [
'indexable_type' => $this->get_indexable_type(),
'count' => $this->get_count(),
];
}
/**
* Gets the indexable type.
*
* @return string Returns the indexable type.
*/
public function get_indexable_type() {
return $this->indexable_type;
}
/**
* Gets the count.
*
* @return int Returns the amount of missing indexables.
*/
public function get_count() {
return $this->count;
}
}

View File

@@ -1,48 +0,0 @@
<?php
namespace Yoast\WP\SEO\Analytics\Domain;
/**
* A collection domain object.
*/
class To_Be_Cleaned_Indexable_Bucket {
/**
* All the to be cleaned indexable count objects.
*
* @var array<To_Be_Cleaned_Indexable_Count>
*/
private $to_be_cleaned_indexable_counts;
/**
* The constructor.
*/
public function __construct() {
$this->to_be_cleaned_indexable_counts = [];
}
/**
* Adds a 'to be cleaned' indexable count object to this bucket.
*
* @param To_Be_Cleaned_Indexable_Count $to_be_cleaned_indexable_counts The to be cleaned indexable count object.
*
* @return void
*/
public function add_to_be_cleaned_indexable_count( To_Be_Cleaned_Indexable_Count $to_be_cleaned_indexable_counts ) {
$this->to_be_cleaned_indexable_counts[] = $to_be_cleaned_indexable_counts;
}
/**
* Returns the array representation of all indexable counts.
*
* @return array
*/
public function to_array() {
return \array_map(
static function ( $item ) {
return $item->to_array();
},
$this->to_be_cleaned_indexable_counts
);
}
}

View File

@@ -1,64 +0,0 @@
<?php
namespace Yoast\WP\SEO\Analytics\Domain;
/**
* The to be cleaned indexable domain object.
*/
class To_Be_Cleaned_Indexable_Count {
/**
* The cleanup task that is represented by this.
*
* @var string
*/
private $cleanup_name;
/**
* The amount of missing indexables.
*
* @var int
*/
private $count;
/**
* The constructor.
*
* @param string $cleanup_name The indexable type that is represented by this.
* @param int $count The amount of missing indexables.
*/
public function __construct( $cleanup_name, $count ) {
$this->cleanup_name = $cleanup_name;
$this->count = $count;
}
/**
* Returns an array representation of the data.
*
* @return array Returns both values in an array format.
*/
public function to_array() {
return [
'cleanup_name' => $this->get_cleanup_name(),
'count' => $this->get_count(),
];
}
/**
* Gets the name.
*
* @return string
*/
public function get_cleanup_name() {
return $this->cleanup_name;
}
/**
* Gets the count.
*
* @return int Returns the amount of missing indexables.
*/
public function get_count() {
return $this->count;
}
}

View File

@@ -1,64 +0,0 @@
<?php
namespace Yoast\WP\SEO\Analytics\User_Interface;
use Yoast\WP\SEO\Conditionals\No_Conditionals;
use Yoast\WP\SEO\Helpers\Options_Helper;
use Yoast\WP\SEO\Integrations\Integration_Interface;
/**
* Handles setting a timestamp when the indexation of a specific indexation action is completed.
*/
class Last_Completed_Indexation_Integration implements Integration_Interface {
use No_Conditionals;
/**
* The options helper.
*
* @var Options_Helper The options helper.
*/
private $options_helper;
/**
* The constructor.
*
* @param Options_Helper $options_helper The options helper.
*/
public function __construct( Options_Helper $options_helper ) {
$this->options_helper = $options_helper;
}
/**
* Registers action hook to maybe save an option.
*
* @return void
*/
public function register_hooks(): void {
\add_action(
'wpseo_indexables_unindexed_calculated',
[
$this,
'maybe_set_indexables_unindexed_calculated',
],
10,
2
);
}
/**
* Saves a timestamp option when there are no unindexed indexables.
*
* @param string $indexable_name The name of the indexable that is being checked.
* @param int $count The amount of missing indexables.
*
* @return void
*/
public function maybe_set_indexables_unindexed_calculated( string $indexable_name, int $count ): void {
if ( $count === 0 ) {
$no_index = $this->options_helper->get( 'last_known_no_unindexed', [] );
$no_index[ $indexable_name ] = \time();
$this->options_helper->set( 'last_known_no_unindexed', $no_index );
}
}
}