| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Controls Draft |
| 5 |
*/ |
| 6 |
|
| 7 |
namespace Extendify; |
| 8 |
|
| 9 |
defined('ABSPATH') || die('No direct access.'); |
| 10 |
|
| 11 |
|
| 12 |
/** |
| 13 |
* The controller for interacting with site settings |
| 14 |
*/ |
| 15 |
|
| 16 |
class SiteSettings |
| 17 |
{ |
| 18 |
/** |
| 19 |
* Get when the site was created |
| 20 |
* |
| 21 |
* @return string|NULL |
| 22 |
*/ |
| 23 |
public static function getSiteCreatedAt() |
| 24 |
{ |
| 25 |
$cacheKey = 'extendify_site_created_at'; |
| 26 |
$cached = \wp_cache_get($cacheKey); |
| 27 |
if ($cached) { |
| 28 |
return $cached; |
| 29 |
} |
| 30 |
|
| 31 |
$userOne = \get_userdata(1); |
| 32 |
if ($userOne) { |
| 33 |
$createdAt = $userOne->user_registered; |
| 34 |
\wp_cache_set($cacheKey, $createdAt); |
| 35 |
return $createdAt; |
| 36 |
} |
| 37 |
|
| 38 |
$wpdb = $GLOBALS['wpdb']; |
| 39 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery |
| 40 |
$result = $wpdb->get_row($wpdb->prepare( |
| 41 |
'SELECT CREATE_TIME |
| 42 |
FROM INFORMATION_SCHEMA.TABLES |
| 43 |
WHERE TABLE_SCHEMA = %s |
| 44 |
AND TABLE_NAME = %s |
| 45 |
LIMIT 1', |
| 46 |
$wpdb->dbname, |
| 47 |
$wpdb->posts |
| 48 |
)); |
| 49 |
if (!property_exists($result, 'CREATE_TIME')) { |
| 50 |
return null; |
| 51 |
} |
| 52 |
|
| 53 |
$createdAt = gmdate( |
| 54 |
'Y-m-d H:i:s', |
| 55 |
strtotime($result->CREATE_TIME) |
| 56 |
); |
| 57 |
\wp_cache_set($cacheKey, $createdAt); |
| 58 |
return $createdAt; |
| 59 |
} |
| 60 |
} |
| 61 |
|