Yoast\WP\SEO\Repositories
Indexable_Cleanup_Repository::count_orphaned_from_table
Counts orphaned rows from a yoast table.
Метод класса: Indexable_Cleanup_Repository{}
Хуков нет.
Возвращает
int|bool. The number of deleted rows, false if the query fails.
Использование
$Indexable_Cleanup_Repository = new Indexable_Cleanup_Repository(); $Indexable_Cleanup_Repository->count_orphaned_from_table( $table, $column );
- $table(строка) (обязательный)
- The table to clean up.
- $column(строка) (обязательный)
- The table column the cleanup will rely on.
Код Indexable_Cleanup_Repository::count_orphaned_from_table() Indexable Cleanup Repository::count orphaned from table Yoast 28.6
public function count_orphaned_from_table( string $table, string $column ) {
global $wpdb;
$table = Model::get_table_name( $table );
$indexable_table = Model::get_table_name( 'Indexable' );
// Warning: If this query is changed, make sure to update the query in cleanup_orphaned_from_table in Premium as well.
// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: Already prepared.
return $wpdb->get_col(
"
SELECT count(*)
FROM {$table} table_to_clean
LEFT JOIN {$indexable_table} AS indexable_table
ON table_to_clean.{$column} = indexable_table.id
WHERE indexable_table.id IS NULL
AND table_to_clean.{$column} IS NOT NULL",
)[0];
// phpcs:enable
}