| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) die('No direct access allowed'); |
| 3 |
|
| 4 |
if (!class_exists('WP_Optimize_Table_404_Detector')) : |
| 5 |
|
| 6 |
class WP_Optimize_Table_404_Detector implements WP_Optimize_Table_Interface { |
| 7 |
|
| 8 |
/** |
| 9 |
* Name of the table |
| 10 |
* |
| 11 |
* @var string |
| 12 |
*/ |
| 13 |
private $table_name = '404_detector'; |
| 14 |
|
| 15 |
/** |
| 16 |
* Complete table name with a prefix |
| 17 |
* |
| 18 |
* @return string |
| 19 |
*/ |
| 20 |
public function get_table_name(): string { |
| 21 |
global $wpdb; |
| 22 |
|
| 23 |
return $wpdb->base_prefix . 'wpo_' . $this->table_name; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Table fields and keys (if any) |
| 28 |
* |
| 29 |
* @return array |
| 30 |
*/ |
| 31 |
public function describe(): array { |
| 32 |
return array( |
| 33 |
'fields' => array( |
| 34 |
'url' => 'TEXT NOT NULL', |
| 35 |
'request_timestamp' => 'BIGINT UNSIGNED NOT NULL', |
| 36 |
'request_count' => 'BIGINT UNSIGNED NOT NULL', |
| 37 |
'referrer' => 'TEXT NOT NULL' |
| 38 |
), |
| 39 |
'keys' => array( |
| 40 |
'url_timestamp_referrer' => '(url(75),request_timestamp,referrer(75))', |
| 41 |
'timestamp_count' => '(request_timestamp,request_count)' |
| 42 |
), |
| 43 |
'unique' => 'url(75),request_timestamp,referrer(75)' |
| 44 |
); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Returns singleton instance |
| 49 |
* |
| 50 |
* @return WP_Optimize_Table_404_Detector |
| 51 |
*/ |
| 52 |
public static function get_instance() { |
| 53 |
static $instance = null; |
| 54 |
if (null === $instance) { |
| 55 |
$instance = new static(); |
| 56 |
} |
| 57 |
return $instance; |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
endif; |
| 62 |
|