/var/www/html_uk/wp-content/plugins/automatewoo/includes/SystemChecks/DatabaseTablesExist.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

namespace AutomateWoo\SystemChecks;

use 
AutomateWoo\Database_Tables;

defined'ABSPATH' ) || exit;

/**
 * Class DatabaseTablesExist
 *
 * @package AutomateWoo\SystemChecks
 */
class DatabaseTablesExist extends AbstractSystemCheck {
    
/**
     * Class constructor
     */
    
public function __construct() {
        
$this->title         __'Database Tables Installed''automatewoo' );
        
$this->description   __'Checks the AutomateWoo custom database tables have been installed.''automatewoo' );
        
$this->high_priority true;
    }

    
/**
     * Perform the check
     */
    
public function run() {
        global 
$wpdb;

        
$expected_tables Database_Tables::get_all();
        
$missing_tables  = array();

        foreach ( 
$expected_tables as $table ) {
            
$table_exists $wpdb->get_results$wpdb->prepare'SHOW TABLES LIKE %s'$table->get_name() ) );

            if ( empty( 
$table_exists ) ) {
                
$missing_tables[] = $table->get_name();
            }
        }

        if ( ! empty( 
$missing_tables ) ) {
            
/* translators: %1$s list of missing database tables */
            
return $this->errorsprintf__'Tables not found: %1$s''automatewoo' ), implode', '$missing_tables ) ) );
        }

        return 
$this->success();
    }
}