Yoast\WP\SEO\Repositories
Indexable_Cleanup_Repository::clean_indexables_with_object_type_and_object_sub_type
Deletes rows from the indexable table depending on the object_type and object_sub_type.
Метод класса: Indexable_Cleanup_Repository{}
Хуков нет.
Возвращает
int|bool. The number of rows that was deleted or false if the query failed.
Использование
$Indexable_Cleanup_Repository = new Indexable_Cleanup_Repository(); $Indexable_Cleanup_Repository->clean_indexables_with_object_type_and_object_sub_type( $object_type, $object_sub_type, $limit );
- $object_type(строка) (обязательный)
- The object type to query.
- $object_sub_type(строка) (обязательный)
- The object subtype to query.
- $limit(int) (обязательный)
- The limit we'll apply to the delete query.
Код Indexable_Cleanup_Repository::clean_indexables_with_object_type_and_object_sub_type() Indexable Cleanup Repository::clean indexables with object type and object sub type Yoast 28.8
public function clean_indexables_with_object_type_and_object_sub_type( string $object_type, string $object_sub_type, int $limit ) {
global $wpdb;
$indexable_table = Model::get_table_name( 'Indexable' );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Reason: There is no unescaped user input.
$sql = $wpdb->prepare( "DELETE FROM $indexable_table WHERE object_type = %s AND object_sub_type = %s ORDER BY id LIMIT %d", $object_type, $object_sub_type, $limit );
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: Already prepared.
return $wpdb->query( $sql );
}