| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Helpers; |
| 4 |
|
| 5 |
use wpdb; |
| 6 |
|
| 7 |
/** |
| 8 |
* The AIOSEO Helper. |
| 9 |
*/ |
| 10 |
class Aioseo_Helper { |
| 11 |
|
| 12 |
/** |
| 13 |
* The WordPress database instance. |
| 14 |
* |
| 15 |
* @var wpdb |
| 16 |
*/ |
| 17 |
protected $wpdb; |
| 18 |
|
| 19 |
/** |
| 20 |
* The wpdb helper. |
| 21 |
* |
| 22 |
* @var Wpdb_Helper |
| 23 |
*/ |
| 24 |
protected $wpdb_helper; |
| 25 |
|
| 26 |
/** |
| 27 |
* Class constructor. |
| 28 |
* |
| 29 |
* @param wpdb $wpdb The WordPress database instance. |
| 30 |
* @param Wpdb_Helper $wpdb_helper The wpdb helper. |
| 31 |
*/ |
| 32 |
public function __construct( wpdb $wpdb, Wpdb_Helper $wpdb_helper ) { |
| 33 |
$this->wpdb = $wpdb; |
| 34 |
$this->wpdb_helper = $wpdb_helper; |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Retrieves the AIOSEO table name along with the db prefix. |
| 39 |
* |
| 40 |
* @return string The AIOSEO table name along with the db prefix. |
| 41 |
*/ |
| 42 |
public function get_table() { |
| 43 |
return $this->wpdb->prefix . 'aioseo_posts'; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Determines if the AIOSEO database table exists. |
| 48 |
* |
| 49 |
* @return bool True if the table is found. |
| 50 |
*/ |
| 51 |
public function aioseo_exists() { |
| 52 |
return $this->wpdb_helper->table_exists( $this->get_table() ) === true; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Retrieves the option where the global settings exist. |
| 57 |
* |
| 58 |
* @return array The option where the global settings exist. |
| 59 |
*/ |
| 60 |
public function get_global_option() { |
| 61 |
return \json_decode( \get_option( 'aioseo_options', '' ), true ); |
| 62 |
} |
| 63 |
} |
| 64 |
|