Yoast\WP\SEO\Repositories

Indexable_Cleanup_Repository::clean_indexables_with_object_type_and_object_sub_type()publicYoast 1.0

Deletes rows from the indexable table depending on the object_type and object_sub_type.

Метод класса: Indexable_Cleanup_Repository{}

Хуков нет.

Возвращает

int|true|false. 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() Yoast 23.6

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 );
}