@@ -1,25 +1,25 @@ |
||
| 1 | -<?php defined( 'WPINC' ) || die; |
|
| 1 | +<?php defined('WPINC') || die; |
|
| 2 | 2 | |
| 3 | 3 | global $wp_version; |
| 4 | 4 | |
| 5 | -if( !is_admin() && version_compare( '7.0', phpversion(), '>' )) { |
|
| 5 | +if (!is_admin() && version_compare('7.0', phpversion(), '>')) { |
|
| 6 | 6 | wp_die( |
| 7 | - __( 'You must be using PHP 7.0.0 or greater.', 'castor' ), |
|
| 8 | - __( 'Unsupported PHP version', 'castor' ) |
|
| 7 | + __('You must be using PHP 7.0.0 or greater.', 'castor'), |
|
| 8 | + __('Unsupported PHP version', 'castor') |
|
| 9 | 9 | ); |
| 10 | 10 | } |
| 11 | -if( !is_admin() && version_compare( '4.7', $wp_version, '>' )) { |
|
| 11 | +if (!is_admin() && version_compare('4.7', $wp_version, '>')) { |
|
| 12 | 12 | wp_die( |
| 13 | - __( 'You must be using WordPress 4.7.0 or greater.', 'castor' ), |
|
| 14 | - __( 'Unsupported WordPress version', 'castor' ) |
|
| 13 | + __('You must be using WordPress 4.7.0 or greater.', 'castor'), |
|
| 14 | + __('Unsupported WordPress version', 'castor') |
|
| 15 | 15 | ); |
| 16 | 16 | } |
| 17 | -if( is_customize_preview() && filter_input( INPUT_GET, 'theme' )) { |
|
| 17 | +if (is_customize_preview() && filter_input(INPUT_GET, 'theme')) { |
|
| 18 | 18 | wp_die( |
| 19 | - __( 'Theme must be activated prior to using the customizer.', 'castor' ) |
|
| 19 | + __('Theme must be activated prior to using the customizer.', 'castor') |
|
| 20 | 20 | ); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -require_once( ABSPATH.'/'.WPINC.'/class-oembed.php' ); |
|
| 23 | +require_once(ABSPATH . '/' . WPINC . '/class-oembed.php'); |
|
| 24 | 24 | |
| 25 | 25 | \GeminiLabs\Castor\Application::getInstance()->init(); |
@@ -18,11 +18,11 @@ discard block |
||
| 18 | 18 | protected $file; |
| 19 | 19 | protected $log; |
| 20 | 20 | |
| 21 | - public function __construct( $filename ) |
|
| 21 | + public function __construct($filename) |
|
| 22 | 22 | { |
| 23 | 23 | $this->file = $filename; |
| 24 | - $this->log = file_exists( $filename ) |
|
| 25 | - ? file_get_contents( $filename ) |
|
| 24 | + $this->log = file_exists($filename) |
|
| 25 | + ? file_get_contents($filename) |
|
| 26 | 26 | : ''; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | * @param array $context |
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | - public function alert( $message, array $context = [] ) |
|
| 43 | + public function alert($message, array $context = []) |
|
| 44 | 44 | { |
| 45 | - $this->log( static::ALERT, $message, $context ); |
|
| 45 | + $this->log(static::ALERT, $message, $context); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | public function clear() |
| 52 | 52 | { |
| 53 | 53 | $this->log = ''; |
| 54 | - file_put_contents( $this->file, $this->log ); |
|
| 54 | + file_put_contents($this->file, $this->log); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | * @param array $context |
| 63 | 63 | * @return void |
| 64 | 64 | */ |
| 65 | - public function critical( $message, array $context = [] ) |
|
| 65 | + public function critical($message, array $context = []) |
|
| 66 | 66 | { |
| 67 | - $this->log( static::CRITICAL, $message, $context ); |
|
| 67 | + $this->log(static::CRITICAL, $message, $context); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | * @param array $context |
| 75 | 75 | * @return void |
| 76 | 76 | */ |
| 77 | - public function debug( $message, array $context = [] ) |
|
| 77 | + public function debug($message, array $context = []) |
|
| 78 | 78 | { |
| 79 | - $this->log( static::DEBUG, $message, $context ); |
|
| 79 | + $this->log(static::DEBUG, $message, $context); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -86,9 +86,9 @@ discard block |
||
| 86 | 86 | * @param array $context |
| 87 | 87 | * @return void |
| 88 | 88 | */ |
| 89 | - public function emergency( $message, array $context = [] ) |
|
| 89 | + public function emergency($message, array $context = []) |
|
| 90 | 90 | { |
| 91 | - $this->log( static::EMERGENCY, $message, $context ); |
|
| 91 | + $this->log(static::EMERGENCY, $message, $context); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | * @param array $context |
| 100 | 100 | * @return void |
| 101 | 101 | */ |
| 102 | - public function error( $message, array $context = [] ) |
|
| 102 | + public function error($message, array $context = []) |
|
| 103 | 103 | { |
| 104 | - $this->log( static::ERROR, $message, $context ); |
|
| 104 | + $this->log(static::ERROR, $message, $context); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | * @param array $context |
| 113 | 113 | * @return void |
| 114 | 114 | */ |
| 115 | - public function info( $message, array $context = [] ) |
|
| 115 | + public function info($message, array $context = []) |
|
| 116 | 116 | { |
| 117 | - $this->log( static::INFO, $message, $context ); |
|
| 117 | + $this->log(static::INFO, $message, $context); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -124,9 +124,9 @@ discard block |
||
| 124 | 124 | * @param array $context |
| 125 | 125 | * @return void |
| 126 | 126 | */ |
| 127 | - public function notice( $message, array $context = [] ) |
|
| 127 | + public function notice($message, array $context = []) |
|
| 128 | 128 | { |
| 129 | - $this->log( static::NOTICE, $message, $context ); |
|
| 129 | + $this->log(static::NOTICE, $message, $context); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | * @param array $context |
| 139 | 139 | * @return void |
| 140 | 140 | */ |
| 141 | - public function warning( $message, array $context = [] ) |
|
| 141 | + public function warning($message, array $context = []) |
|
| 142 | 142 | { |
| 143 | - $this->log( static::WARNING, $message, $context ); |
|
| 143 | + $this->log(static::WARNING, $message, $context); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -148,25 +148,25 @@ discard block |
||
| 148 | 148 | * @param array $context |
| 149 | 149 | * @return array|string |
| 150 | 150 | */ |
| 151 | - protected function interpolate( $message, array $context = [] ) |
|
| 151 | + protected function interpolate($message, array $context = []) |
|
| 152 | 152 | { |
| 153 | - if( is_array( $message )) { |
|
| 154 | - return htmlspecialchars( print_r( $message, true ), ENT_QUOTES, 'UTF-8' ); |
|
| 153 | + if (is_array($message)) { |
|
| 154 | + return htmlspecialchars(print_r($message, true), ENT_QUOTES, 'UTF-8'); |
|
| 155 | 155 | } |
| 156 | 156 | $replace = []; |
| 157 | - foreach( $context as $key => $val ) { |
|
| 158 | - if( is_object( $val ) && get_class( $val ) === 'DateTime' ) { |
|
| 159 | - $val = $val->format( 'Y-m-d H:i:s' ); |
|
| 157 | + foreach ($context as $key => $val) { |
|
| 158 | + if (is_object($val) && get_class($val) === 'DateTime') { |
|
| 159 | + $val = $val->format('Y-m-d H:i:s'); |
|
| 160 | 160 | } |
| 161 | - else if( is_object( $val ) || is_array( $val )) { |
|
| 162 | - $val = json_encode( $val ); |
|
| 161 | + else if (is_object($val) || is_array($val)) { |
|
| 162 | + $val = json_encode($val); |
|
| 163 | 163 | } |
| 164 | - else if( is_resource( $val )) { |
|
| 164 | + else if (is_resource($val)) { |
|
| 165 | 165 | $val = (string) $val; |
| 166 | 166 | } |
| 167 | - $replace['{'.$key.'}'] = $val; |
|
| 167 | + $replace['{' . $key . '}'] = $val; |
|
| 168 | 168 | } |
| 169 | - return strtr( $message, $replace ); |
|
| 169 | + return strtr($message, $replace); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -175,16 +175,16 @@ discard block |
||
| 175 | 175 | * @param array $context |
| 176 | 176 | * @return void |
| 177 | 177 | */ |
| 178 | - protected function log( $level, $message, array $context = [] ) |
|
| 178 | + protected function log($level, $message, array $context = []) |
|
| 179 | 179 | { |
| 180 | - if( !defined( 'CASTOR_DEBUG' ) |
|
| 180 | + if (!defined('CASTOR_DEBUG') |
|
| 181 | 181 | || CASTOR_DEBUG !== true |
| 182 | - || !in_array( $level, (new ReflectionClass( __NAMESPACE__.'\Log' ))->getConstants(), true ) |
|
| 182 | + || !in_array($level, (new ReflectionClass(__NAMESPACE__ . '\Log'))->getConstants(), true) |
|
| 183 | 183 | )return; |
| 184 | - $date = get_date_from_gmt( gmdate('Y-m-d H:i:s') ); |
|
| 185 | - $level = strtoupper( $level ); |
|
| 186 | - $message = $this->interpolate( $message, $context ); |
|
| 184 | + $date = get_date_from_gmt(gmdate('Y-m-d H:i:s')); |
|
| 185 | + $level = strtoupper($level); |
|
| 186 | + $message = $this->interpolate($message, $context); |
|
| 187 | 187 | $entry = "[$date] $level: $message" . PHP_EOL; |
| 188 | - file_put_contents( $this->file, $entry, FILE_APPEND|LOCK_EX ); |
|
| 188 | + file_put_contents($this->file, $entry, FILE_APPEND | LOCK_EX); |
|
| 189 | 189 | } |
| 190 | 190 | } |
@@ -12,36 +12,36 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | public function __construct() |
| 14 | 14 | { |
| 15 | - $this->assets = sprintf( '%s/assets/', dirname( __DIR__ )); |
|
| 15 | + $this->assets = sprintf('%s/assets/', dirname(__DIR__)); |
|
| 16 | 16 | Facade::clearResolvedInstances(); |
| 17 | - Facade::setFacadeApplication( $this ); |
|
| 17 | + Facade::setFacadeApplication($this); |
|
| 18 | 18 | $this->registerAliases(); |
| 19 | 19 | $this->registerBindings(); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function init() |
| 23 | 23 | { |
| 24 | - $controller = $this->make( 'Controller' ); |
|
| 24 | + $controller = $this->make('Controller'); |
|
| 25 | 25 | |
| 26 | 26 | // Action hooks |
| 27 | - add_action( 'after_setup_theme', [$controller, 'afterSetupTheme'], 20 ); |
|
| 28 | - add_action( 'login_head', [$controller, 'loadAdminFavicon'] ); |
|
| 29 | - add_action( 'admin_head', [$controller, 'loadAdminFavicon'] ); |
|
| 30 | - add_action( 'login_head', [$controller, 'login'] ); |
|
| 31 | - add_action( 'admin_enqueue_scripts', [$controller, 'registerAdminAssets'] ); |
|
| 32 | - add_action( 'wp_enqueue_scripts', [$controller, 'registerAssets'] ); |
|
| 33 | - add_action( 'customize_register', [$controller, 'registerCustomizer'] ); |
|
| 34 | - add_action( 'customize_preview_init', [$controller, 'registerCustomizerAssets'] ); |
|
| 35 | - add_action( 'widgets_init', [$controller, 'registerSidebars'] ); |
|
| 27 | + add_action('after_setup_theme', [$controller, 'afterSetupTheme'], 20); |
|
| 28 | + add_action('login_head', [$controller, 'loadAdminFavicon']); |
|
| 29 | + add_action('admin_head', [$controller, 'loadAdminFavicon']); |
|
| 30 | + add_action('login_head', [$controller, 'login']); |
|
| 31 | + add_action('admin_enqueue_scripts', [$controller, 'registerAdminAssets']); |
|
| 32 | + add_action('wp_enqueue_scripts', [$controller, 'registerAssets']); |
|
| 33 | + add_action('customize_register', [$controller, 'registerCustomizer']); |
|
| 34 | + add_action('customize_preview_init', [$controller, 'registerCustomizerAssets']); |
|
| 35 | + add_action('widgets_init', [$controller, 'registerSidebars']); |
|
| 36 | 36 | |
| 37 | 37 | // Filter hooks |
| 38 | - add_filter( 'body_class', [$controller, 'filterBodyClasses'] ); |
|
| 39 | - add_filter( 'template_include', [$controller, 'filterTemplate'] ); |
|
| 40 | - add_filter( 'login_headertitle', [$controller, 'filterLoginTitle'] ); |
|
| 41 | - add_filter( 'login_headerurl', [$controller, 'filterLoginUrl'] ); |
|
| 38 | + add_filter('body_class', [$controller, 'filterBodyClasses']); |
|
| 39 | + add_filter('template_include', [$controller, 'filterTemplate']); |
|
| 40 | + add_filter('login_headertitle', [$controller, 'filterLoginTitle']); |
|
| 41 | + add_filter('login_headerurl', [$controller, 'filterLoginUrl']); |
|
| 42 | 42 | |
| 43 | - foreach( $this->getTemplateTypes() as $type ) { |
|
| 44 | - add_filter( "{$type}_template_hierarchy", [$controller, 'filterTemplateHierarchy'] ); |
|
| 43 | + foreach ($this->getTemplateTypes() as $type) { |
|
| 44 | + add_filter("{$type}_template_hierarchy", [$controller, 'filterTemplateHierarchy']); |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | 'Theme' => Facades\Theme::class, |
| 62 | 62 | 'Utility' => Facades\Utility::class, |
| 63 | 63 | ]; |
| 64 | - $aliases = apply_filters( 'castor/register/aliases', $aliases ); |
|
| 65 | - AliasLoader::getInstance( $aliases )->register(); |
|
| 64 | + $aliases = apply_filters('castor/register/aliases', $aliases); |
|
| 65 | + AliasLoader::getInstance($aliases)->register(); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function registerBindings() |
| 72 | 72 | { |
| 73 | - $this->bind( Helpers\Log::class, function() { |
|
| 74 | - return new Helpers\Log( trailingslashit( get_stylesheet_directory() ).'castor-debug.log' ); |
|
| 73 | + $this->bind(Helpers\Log::class, function() { |
|
| 74 | + return new Helpers\Log(trailingslashit(get_stylesheet_directory()) . 'castor-debug.log'); |
|
| 75 | 75 | }); |
| 76 | 76 | } |
| 77 | 77 | |