← All changes
|
src/actions/importing/aioseo/aioseo-cleanup-action.php
+8
-14
18.8
→
trunk
View file →
| @@ -8,10 +8,8 @@ | ||
| 8 | 8 | use Yoast\WP\SEO\Helpers\Options_Helper; |
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Importing action for cleaning up AIOSEO data. |
| 12 | - * | |
| 13 | - * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded | |
| 14 | 12 | */ |
| 15 | 13 | class Aioseo_Cleanup_Action extends Abstract_Aioseo_Importing_Action { |
| 16 | 14 | |
| 17 | 15 | /** |
| @@ -16,19 +14,19 @@ | ||
| 16 | 14 | |
| 17 | 15 | /** |
| 18 | 16 | * The plugin of the action. |
| 19 | 17 | */ |
| 20 | - const PLUGIN = 'aioseo'; | |
| 18 | + public const PLUGIN = 'aioseo'; | |
| 21 | 19 | |
| 22 | 20 | /** |
| 23 | 21 | * The type of the action. |
| 24 | 22 | */ |
| 25 | - const TYPE = 'cleanup'; | |
| 23 | + public const TYPE = 'cleanup'; | |
| 26 | 24 | |
| 27 | 25 | /** |
| 28 | 26 | * The AIOSEO meta_keys to be cleaned up. |
| 29 | 27 | * |
| 30 | - * @var array | |
| 28 | + * @var array<string> | |
| 31 | 29 | */ |
| 32 | 30 | protected $aioseo_postmeta_keys = [ |
| 33 | 31 | '_aioseo_title', |
| 34 | 32 | '_aioseo_description', |
| @@ -47,15 +45,12 @@ | ||
| 47 | 45 | |
| 48 | 46 | /** |
| 49 | 47 | * Class constructor. |
| 50 | 48 | * |
| 51 | - * @param wpdb $wpdb The WordPress database instance. | |
| 52 | - * @param Options_Helper $options The options helper. | |
| 49 | + * @param wpdb $wpdb The WordPress database instance. | |
| 50 | + * @param Options_Helper $options The options helper. | |
| 53 | 51 | */ |
| 54 | - public function __construct( | |
| 55 | - wpdb $wpdb, | |
| 56 | - Options_Helper $options | |
| 57 | - ) { | |
| 52 | + public function __construct( wpdb $wpdb, Options_Helper $options ) { | |
| 58 | 53 | $this->wpdb = $wpdb; |
| 59 | 54 | $this->options = $options; |
| 60 | 55 | } |
| 61 | 56 | |
| @@ -110,9 +105,8 @@ | ||
| 110 | 105 | $meta_data = $this->wpdb->query( $this->cleanup_postmeta_query() ); |
| 111 | 106 | $aioseo_table_truncate_done = $this->wpdb->query( $this->truncate_query() ); |
| 112 | 107 | // phpcs:enable WordPress.DB.PreparedSQL.NotPrepared |
| 113 | 108 | |
| 114 | - | |
| 115 | 109 | if ( $meta_data === false && $aioseo_table_truncate_done === false ) { |
| 116 | 110 | return false; |
| 117 | 111 | } |
| 118 | 112 | |
| @@ -135,9 +129,9 @@ | ||
| 135 | 129 | |
| 136 | 130 | // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Reason: There is no unescaped user input. |
| 137 | 131 | return $this->wpdb->prepare( |
| 138 | 132 | "DELETE FROM {$table} WHERE meta_key IN (" . \implode( ', ', \array_fill( 0, \count( $meta_keys_to_delete ), '%s' ) ) . ')', |
| 139 | - $meta_keys_to_delete | |
| 133 | + $meta_keys_to_delete, | |
| 140 | 134 | ); |
| 141 | 135 | // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
| 142 | 136 | } |
| 143 | 137 | |
| @@ -165,9 +159,9 @@ | ||
| 165 | 159 | public function get_limit() { |
| 166 | 160 | /** |
| 167 | 161 | * Filter 'wpseo_aioseo_cleanup_limit' - Allow filtering the number of posts indexed during each indexing pass. |
| 168 | 162 | * |
| 169 | - * @api int The maximum number of posts cleaned up. | |
| 163 | + * @param int $max_posts The maximum number of posts cleaned up. | |
| 170 | 164 | */ |
| 171 | 165 | $limit = \apply_filters( 'wpseo_aioseo_cleanup_limit', 25 ); |
| 172 | 166 | |
| 173 | 167 | if ( ! \is_int( $limit ) || $limit < 1 ) { |