PluginProbe ʕ •ᴥ•ʔ
Advanced Database Cleaner – Optimize & Clean Database to Speed Up Site Performance / trunk
Advanced Database Cleaner – Optimize & Clean Database to Speed Up Site Performance vtrunk
4.2.0 trunk 1.0.0 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.5 1.3.6 1.3.7 2.0.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.1.0 4.1.1
advanced-database-cleaner / includes / utils / validator / class-adbc-tables-validator.php
advanced-database-cleaner / includes / utils / validator Last commit date
class-adbc-automation-validator.php 7 months ago class-adbc-common-validator.php 2 days ago class-adbc-selected-items-validator.php 3 months ago class-adbc-settings-validator.php 2 days ago class-adbc-tables-validator.php 7 months ago
class-adbc-tables-validator.php
51 lines
1 <?php
2
3 // Exit if accessed directly
4 if ( ! defined( 'ABSPATH' ) )
5 exit;
6
7 /**
8 * ADBC Tables validator class.
9 *
10 * This class provides functions to validate and sanitize the tables data used in the plugin.
11 */
12 class ADBC_Tables_Validator {
13
14 /**
15 * Validate the selected tables names list sent by the user against the existing tables and return the valid ones.
16 *
17 * @param array $tables_names The tables names to validate.
18 *
19 * @return array The validated tables names, empty array if invalid.
20 */
21 public static function validate_tables_names_list( $tables_names ) {
22
23 $validated_tables = [];
24
25 if ( ! is_array( $tables_names ) )
26 return $validated_tables;
27
28 $batch_size = ADBC_Settings::instance()->get_setting( 'database_rows_batch' );
29 $offset = 0;
30 $valid_tables = [];
31
32 // loop through the tables in batches and check the selected tables against the existing tables
33 while ( $tables_names_batch = ADBC_Tables::get_tables_names( $batch_size, $offset ) ) {
34
35 foreach ( $tables_names as $table_name ) {
36
37 // if the table exists, add it to the valid tables
38 if ( key_exists( $table_name, $tables_names_batch ) )
39 $valid_tables[] = $table_name;
40
41 }
42
43 $offset += $batch_size;
44
45 }
46
47 return $valid_tables;
48
49 }
50
51 }