| 1 |
<?php |
| 2 |
/** |
| 3 |
* OpenStation App Framework — WordPress Env adapter. |
| 4 |
* |
| 5 |
* @package OpenStation |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace OpenStation\App\WordPress; |
| 9 |
|
| 10 |
use OpenStation\App\Contracts\Env as EnvContract; |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit; |
| 13 |
|
| 14 |
/** |
| 15 |
* WordPress environment facts. |
| 16 |
*/ |
| 17 |
final class Env implements EnvContract { |
| 18 |
|
| 19 |
/** {@inheritDoc} */ |
| 20 |
public function constant( $name, $fallback = null ) { |
| 21 |
return defined( $name ) ? constant( $name ) : $fallback; |
| 22 |
} |
| 23 |
|
| 24 |
/** {@inheritDoc} */ |
| 25 |
public function content_dir() { |
| 26 |
return rtrim( WP_CONTENT_DIR, '/\\' ); |
| 27 |
} |
| 28 |
|
| 29 |
/** {@inheritDoc} */ |
| 30 |
public function platform() { |
| 31 |
return array( |
| 32 |
'name' => 'WordPress', |
| 33 |
'version' => (string) get_bloginfo( 'version' ), |
| 34 |
); |
| 35 |
} |
| 36 |
|
| 37 |
/** {@inheritDoc} */ |
| 38 |
public function environment_type() { |
| 39 |
return (string) wp_get_environment_type(); |
| 40 |
} |
| 41 |
|
| 42 |
/** {@inheritDoc} */ |
| 43 |
public function is_network() { |
| 44 |
return is_multisite(); |
| 45 |
} |
| 46 |
|
| 47 |
/** {@inheritDoc} */ |
| 48 |
public function format_datetime( $timestamp, $format = 'Y-m-d H:i:s' ) { |
| 49 |
return (string) wp_date( (string) $format, (int) $timestamp ); |
| 50 |
} |
| 51 |
} |
| 52 |
|