rebase on oct-10-2023
This commit is contained in:
@@ -48,6 +48,13 @@ class Indexing_Helper {
|
||||
*/
|
||||
protected $indexing_actions;
|
||||
|
||||
/**
|
||||
* The indexation actions that can be done in the background.
|
||||
*
|
||||
* @var Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[]
|
||||
*/
|
||||
protected $background_indexing_actions;
|
||||
|
||||
/**
|
||||
* The indexable repository.
|
||||
*
|
||||
@@ -100,6 +107,9 @@ class Indexing_Helper {
|
||||
$post_link_indexing_action,
|
||||
$term_link_indexing_action,
|
||||
];
|
||||
|
||||
// Coincidentally, the background indexing actions are the same with the Free indexing actions for now.
|
||||
$this->background_indexing_actions = $this->indexing_actions;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,15 +317,20 @@ class Indexing_Helper {
|
||||
/**
|
||||
* Returns a limited number of unindexed objects.
|
||||
*
|
||||
* @param int $limit Limit the number of unindexed objects that are counted.
|
||||
* @param int $limit Limit the number of unindexed objects that are counted.
|
||||
* @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated.
|
||||
*
|
||||
* @return int The total number of unindexed objects.
|
||||
*/
|
||||
public function get_limited_unindexed_count( $limit ) {
|
||||
public function get_limited_unindexed_count( $limit, $actions = [] ) {
|
||||
$unindexed_count = 0;
|
||||
|
||||
foreach ( $this->indexing_actions as $indexing_action ) {
|
||||
$unindexed_count += $indexing_action->get_limited_unindexed_count( $limit - $unindexed_count + 1 );
|
||||
if ( empty( $actions ) ) {
|
||||
$actions = $this->indexing_actions;
|
||||
}
|
||||
|
||||
foreach ( $actions as $action ) {
|
||||
$unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 );
|
||||
if ( $unindexed_count > $limit ) {
|
||||
return $unindexed_count;
|
||||
}
|
||||
@@ -332,7 +347,7 @@ class Indexing_Helper {
|
||||
* @return int The total number of unindexed objects.
|
||||
*/
|
||||
public function get_limited_filtered_unindexed_count( $limit ) {
|
||||
$unindexed_count = $this->get_limited_unindexed_count( $limit );
|
||||
$unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions );
|
||||
|
||||
if ( $unindexed_count > $limit ) {
|
||||
return $unindexed_count;
|
||||
@@ -348,4 +363,29 @@ class Indexing_Helper {
|
||||
*/
|
||||
return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations.
|
||||
*
|
||||
* @param int $limit Limit the number of unindexed objects that are counted.
|
||||
*
|
||||
* @return int The total number of unindexed objects that can be indexed in the background.
|
||||
*/
|
||||
public function get_limited_filtered_unindexed_count_background( $limit ) {
|
||||
$unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions );
|
||||
|
||||
if ( $unindexed_count > $limit ) {
|
||||
return $unindexed_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background,
|
||||
* and allow for a maximum number of items counted to improve performance.
|
||||
*
|
||||
* @param int $unindexed_count The amount of unindexed objects.
|
||||
* @param int|false $limit Limit the number of unindexed objects that need to be counted.
|
||||
* False if it doesn't need to be limited.
|
||||
*/
|
||||
return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user