| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\User_Meta\User_Interface; |
| 4 |
|
| 5 |
use Yoast\WP\SEO\Conditionals\No_Conditionals; |
| 6 |
use Yoast\WP\SEO\Integrations\Integration_Interface; |
| 7 |
use Yoast\WP\SEO\User_Meta\Application\Cleanup_Service; |
| 8 |
|
| 9 |
/** |
| 10 |
* Handles the cleanup for user meta. |
| 11 |
*/ |
| 12 |
class Cleanup_Integration implements Integration_Interface { |
| 13 |
|
| 14 |
use No_Conditionals; |
| 15 |
|
| 16 |
/** |
| 17 |
* The cleanup service. |
| 18 |
* |
| 19 |
* @var Cleanup_Service |
| 20 |
*/ |
| 21 |
private $cleanup_service; |
| 22 |
|
| 23 |
/** |
| 24 |
* The constructor. |
| 25 |
* |
| 26 |
* @param Cleanup_Service $cleanup_service The cleanup service. |
| 27 |
*/ |
| 28 |
public function __construct( Cleanup_Service $cleanup_service ) { |
| 29 |
$this->cleanup_service = $cleanup_service; |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Registers action hook. |
| 34 |
* |
| 35 |
* @return void |
| 36 |
*/ |
| 37 |
public function register_hooks(): void { |
| 38 |
\add_filter( 'wpseo_misc_cleanup_tasks', [ $this, 'add_user_meta_cleanup_tasks' ] ); |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Adds cleanup tasks for the cleanup integration. |
| 43 |
* |
| 44 |
* @param Closure[] $tasks Array of tasks to be added. |
| 45 |
* |
| 46 |
* @return Closure[] An associative array of tasks to be added to the cleanup integration. |
| 47 |
*/ |
| 48 |
public function add_user_meta_cleanup_tasks( $tasks ) { |
| 49 |
return \array_merge( |
| 50 |
$tasks, |
| 51 |
[ |
| 52 |
'clean_selected_empty_usermeta' => function ( $limit ) { |
| 53 |
return $this->cleanup_service->cleanup_selected_empty_usermeta( $limit ); |
| 54 |
}, |
| 55 |
], |
| 56 |
); |
| 57 |
} |
| 58 |
} |
| 59 |
|