@@ -5,36 +5,36 @@ |
||
| 5 | 5 | global $wp_version; |
| 6 | 6 | |
| 7 | 7 | if (!is_admin() && version_compare('7.1', phpversion(), '>')) { |
| 8 | - wp_die( |
|
| 9 | - __('You must be using PHP 7.1.0 or greater.', 'castor'), |
|
| 10 | - __('Unsupported PHP version', 'castor') |
|
| 11 | - ); |
|
| 8 | + wp_die( |
|
| 9 | + __('You must be using PHP 7.1.0 or greater.', 'castor'), |
|
| 10 | + __('Unsupported PHP version', 'castor') |
|
| 11 | + ); |
|
| 12 | 12 | } |
| 13 | 13 | if (!is_admin() && version_compare('5.2', $wp_version, '>')) { |
| 14 | - wp_die( |
|
| 15 | - __('You must be using WordPress 5.2.0 or greater.', 'castor'), |
|
| 16 | - __('Unsupported WordPress version', 'castor') |
|
| 17 | - ); |
|
| 14 | + wp_die( |
|
| 15 | + __('You must be using WordPress 5.2.0 or greater.', 'castor'), |
|
| 16 | + __('Unsupported WordPress version', 'castor') |
|
| 17 | + ); |
|
| 18 | 18 | } |
| 19 | 19 | if (is_customize_preview() && filter_input(INPUT_GET, 'theme')) { |
| 20 | - wp_die( |
|
| 21 | - __('Theme must be activated prior to using the customizer.', 'castor') |
|
| 22 | - ); |
|
| 20 | + wp_die( |
|
| 21 | + __('Theme must be activated prior to using the customizer.', 'castor') |
|
| 22 | + ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | define('CASTOR_FRAMEWORK_VERSION', '1.4.3'); |
| 26 | 26 | |
| 27 | 27 | if (version_compare($wp_version, '5.3', '<')) { |
| 28 | - require_once ABSPATH.'/'.WPINC.'/class-oembed.php'; |
|
| 28 | + require_once ABSPATH.'/'.WPINC.'/class-oembed.php'; |
|
| 29 | 29 | } else { |
| 30 | - require_once ABSPATH.'/'.WPINC.'/class-wp-oembed.php'; |
|
| 30 | + require_once ABSPATH.'/'.WPINC.'/class-wp-oembed.php'; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | if (!function_exists('castor_app')) { |
| 34 | - function castor_app() |
|
| 35 | - { |
|
| 36 | - return \GeminiLabs\Castor\Application::getInstance(); |
|
| 37 | - } |
|
| 34 | + function castor_app() |
|
| 35 | + { |
|
| 36 | + return \GeminiLabs\Castor\Application::getInstance(); |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | \GeminiLabs\Castor\Application::getInstance()->init(); |
@@ -1,36 +1,36 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -defined('WPINC') || die; |
|
| 3 | +defined( 'WPINC' ) || die; |
|
| 4 | 4 | |
| 5 | 5 | global $wp_version; |
| 6 | 6 | |
| 7 | -if (!is_admin() && version_compare('7.1', phpversion(), '>')) { |
|
| 7 | +if( !is_admin() && version_compare( '7.1', phpversion(), '>' ) ) { |
|
| 8 | 8 | wp_die( |
| 9 | - __('You must be using PHP 7.1.0 or greater.', 'castor'), |
|
| 10 | - __('Unsupported PHP version', 'castor') |
|
| 9 | + __( 'You must be using PHP 7.1.0 or greater.', 'castor' ), |
|
| 10 | + __( 'Unsupported PHP version', 'castor' ) |
|
| 11 | 11 | ); |
| 12 | 12 | } |
| 13 | -if (!is_admin() && version_compare('5.2', $wp_version, '>')) { |
|
| 13 | +if( !is_admin() && version_compare( '5.2', $wp_version, '>' ) ) { |
|
| 14 | 14 | wp_die( |
| 15 | - __('You must be using WordPress 5.2.0 or greater.', 'castor'), |
|
| 16 | - __('Unsupported WordPress version', 'castor') |
|
| 15 | + __( 'You must be using WordPress 5.2.0 or greater.', 'castor' ), |
|
| 16 | + __( 'Unsupported WordPress version', 'castor' ) |
|
| 17 | 17 | ); |
| 18 | 18 | } |
| 19 | -if (is_customize_preview() && filter_input(INPUT_GET, 'theme')) { |
|
| 19 | +if( is_customize_preview() && filter_input( INPUT_GET, 'theme' ) ) { |
|
| 20 | 20 | wp_die( |
| 21 | - __('Theme must be activated prior to using the customizer.', 'castor') |
|
| 21 | + __( 'Theme must be activated prior to using the customizer.', 'castor' ) |
|
| 22 | 22 | ); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -define('CASTOR_FRAMEWORK_VERSION', '1.4.3'); |
|
| 25 | +define( 'CASTOR_FRAMEWORK_VERSION', '1.4.3' ); |
|
| 26 | 26 | |
| 27 | -if (version_compare($wp_version, '5.3', '<')) { |
|
| 27 | +if( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 28 | 28 | require_once ABSPATH.'/'.WPINC.'/class-oembed.php'; |
| 29 | 29 | } else { |
| 30 | 30 | require_once ABSPATH.'/'.WPINC.'/class-wp-oembed.php'; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | -if (!function_exists('castor_app')) { |
|
| 33 | +if( !function_exists( 'castor_app' ) ) { |
|
| 34 | 34 | function castor_app() |
| 35 | 35 | { |
| 36 | 36 | return \GeminiLabs\Castor\Application::getInstance(); |
@@ -10,211 +10,211 @@ |
||
| 10 | 10 | |
| 11 | 11 | class Controller |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * @return void |
|
| 15 | - * @action after_setup_theme |
|
| 16 | - */ |
|
| 17 | - public function afterSetupTheme() |
|
| 18 | - { |
|
| 19 | - castor_app()->cssDir = trailingslashit((string) apply_filters('castor/assets/styles/dir', 'css')); |
|
| 20 | - castor_app()->imgDir = trailingslashit((string) apply_filters('castor/assets/images/dir', 'img')); |
|
| 21 | - castor_app()->jsDir = trailingslashit((string) apply_filters('castor/assets/scripts/dir', 'js')); |
|
| 22 | - |
|
| 23 | - add_editor_style(Theme::assetUri(castor_app()->cssDir.'editor.css')); |
|
| 24 | - add_theme_support('customize-selective-refresh-widgets'); |
|
| 25 | - add_theme_support('html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form']); |
|
| 26 | - add_theme_support('post-thumbnails'); |
|
| 27 | - add_theme_support('soil-clean-up'); |
|
| 28 | - add_theme_support('soil-jquery-cdn'); |
|
| 29 | - add_theme_support('soil-nav-walker'); |
|
| 30 | - add_theme_support('soil-nice-search'); |
|
| 31 | - add_theme_support('soil-relative-urls'); |
|
| 32 | - add_theme_support('title-tag'); |
|
| 33 | - load_theme_textdomain('castor', Theme::paths('dir.template').'/languages'); |
|
| 34 | - |
|
| 35 | - $menus = apply_filters('castor/register/nav_menus', [ |
|
| 36 | - 'main_menu' => __('Main Menu', 'castor'), |
|
| 37 | - ]); |
|
| 38 | - |
|
| 39 | - foreach ($menus as $location => $description) { |
|
| 40 | - register_nav_menu($location, $description); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @return array |
|
| 46 | - * @filter body_class |
|
| 47 | - */ |
|
| 48 | - public function filterBodyClasses(array $classes) |
|
| 49 | - { |
|
| 50 | - if (Theme::displaySidebar()) { |
|
| 51 | - $classes[] = 'has-sidebar'; |
|
| 52 | - } |
|
| 53 | - return array_keys(array_flip($classes)); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @return string |
|
| 58 | - * @filter login_headertext |
|
| 59 | - */ |
|
| 60 | - public function filterLoginTitle() |
|
| 61 | - { |
|
| 62 | - return get_bloginfo('name'); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * @return string |
|
| 67 | - * @filter login_headerurl |
|
| 68 | - */ |
|
| 69 | - public function filterLoginUrl() |
|
| 70 | - { |
|
| 71 | - return get_bloginfo('url'); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @return string |
|
| 76 | - * @filter template_include |
|
| 77 | - */ |
|
| 78 | - public function filterTemplate($template) |
|
| 79 | - { |
|
| 80 | - if (is_string($template)) { |
|
| 81 | - $template = Template::setLayout($template); |
|
| 82 | - Development::storeTemplatePath($template); |
|
| 83 | - } |
|
| 84 | - return $template; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @return array |
|
| 89 | - * @filter {$type}_template_hierarchy |
|
| 90 | - */ |
|
| 91 | - public function filterTemplateHierarchy(array $templates) |
|
| 92 | - { |
|
| 93 | - return array_map(function ($template) { |
|
| 94 | - return Utility::startWith('templates/', $template); |
|
| 95 | - }, $templates); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @return void |
|
| 100 | - * @action admin_head |
|
| 101 | - * @action login_head |
|
| 102 | - */ |
|
| 103 | - public function loadAdminFavicon() |
|
| 104 | - { |
|
| 105 | - if (file_exists(Theme::assetPath('favicon/favicon-admin.ico'))) { |
|
| 106 | - printf('<link rel="shortcut icon" href="%s">', Theme::assetUri('favicon/favicon-admin.ico')); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * @return void |
|
| 112 | - * @action login_head |
|
| 113 | - */ |
|
| 114 | - public function login() |
|
| 115 | - { |
|
| 116 | - if (file_exists(Theme::assetPath(castor_app()->cssDir.'login.css'))) { |
|
| 117 | - printf('<link rel="stylesheet" href="%s">', Theme::assetUri(castor_app()->cssDir.'login.css')); |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * @return void |
|
| 123 | - * @action admin_enqueue_scripts |
|
| 124 | - */ |
|
| 125 | - public function registerAdminAssets() |
|
| 126 | - { |
|
| 127 | - if (file_exists(Theme::assetPath(castor_app()->cssDir.'admin.css'))) { |
|
| 128 | - wp_enqueue_style('castor/admin.css', |
|
| 129 | - Theme::assetUri(castor_app()->cssDir.'admin.css'), |
|
| 130 | - apply_filters('castor/enqueue/admin/css/deps', []), |
|
| 131 | - CASTOR_FRAMEWORK_VERSION |
|
| 132 | - ); |
|
| 133 | - } |
|
| 134 | - if (file_exists(Theme::assetPath(castor_app()->jsDir.'admin.js'))) { |
|
| 135 | - wp_enqueue_script('castor/admin.js', |
|
| 136 | - Theme::assetUri(castor_app()->jsDir.'admin.js'), |
|
| 137 | - apply_filters('castor/enqueue/admin/js/deps', []), |
|
| 138 | - CASTOR_FRAMEWORK_VERSION, |
|
| 139 | - true |
|
| 140 | - ); |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * @return void |
|
| 146 | - * @action wp_enqueue_scripts |
|
| 147 | - */ |
|
| 148 | - public function registerAssets() |
|
| 149 | - { |
|
| 150 | - wp_register_style('castor/main.css', |
|
| 151 | - Theme::assetUri(castor_app()->cssDir.'main.css'), |
|
| 152 | - apply_filters('castor/enqueue/css/deps', []), |
|
| 153 | - CASTOR_FRAMEWORK_VERSION |
|
| 154 | - ); |
|
| 155 | - wp_register_script('castor/main.js', |
|
| 156 | - Theme::assetUri(castor_app()->jsDir.'main.js'), |
|
| 157 | - apply_filters('castor/enqueue/js/deps', []), |
|
| 158 | - CASTOR_FRAMEWORK_VERSION, |
|
| 159 | - true |
|
| 160 | - ); |
|
| 161 | - wp_localize_script('castor/main.js', apply_filters('castor/enqueue/js/localize/variable', 'globals'), |
|
| 162 | - apply_filters('castor/enqueue/js/localize/variables', [ |
|
| 163 | - 'ajax' => admin_url('admin-ajax.php'), |
|
| 164 | - ]) |
|
| 165 | - ); |
|
| 166 | - do_action('castor/register/assets'); |
|
| 167 | - wp_enqueue_style('castor/main.css'); |
|
| 168 | - wp_enqueue_script('castor/main.js'); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * @return void |
|
| 173 | - * @action customize_register |
|
| 174 | - */ |
|
| 175 | - public function registerCustomizer(WP_Customize_Manager $manager) |
|
| 176 | - { |
|
| 177 | - $manager->get_setting('blogname')->transport = 'postMessage'; |
|
| 178 | - $manager->selective_refresh->add_partial('blogname', [ |
|
| 179 | - 'selector' => '.brand', |
|
| 180 | - 'render_callback' => function () { |
|
| 181 | - bloginfo('name'); |
|
| 182 | - }, |
|
| 183 | - ]); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * @return void |
|
| 188 | - * @action customize_preview_init |
|
| 189 | - */ |
|
| 190 | - public function registerCustomizerAssets() |
|
| 191 | - { |
|
| 192 | - wp_enqueue_script('castor/customizer.js', Theme::assetUri(castor_app()->jsDir.'customizer.js'), ['customize-preview'], CASTOR_FRAMEWORK_VERSION, true); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * @return void |
|
| 197 | - * @action widgets_init |
|
| 198 | - */ |
|
| 199 | - public function registerSidebars() |
|
| 200 | - { |
|
| 201 | - $defaults = apply_filters('castor/register/sidebars/defaults', [ |
|
| 202 | - 'before_widget' => '<div class="widget %1$s %2$s">', |
|
| 203 | - 'after_widget' => '</div>', |
|
| 204 | - 'before_title' => '<h4>', |
|
| 205 | - 'after_title' => '</h4>', |
|
| 206 | - ]); |
|
| 207 | - |
|
| 208 | - $sidebars = apply_filters('castor/register/sidebars', [ |
|
| 209 | - 'sidebar-primary' => __('Primary Sidebar', 'castor'), |
|
| 210 | - 'sidebar-footer' => __('Footer Widgets', 'castor'), |
|
| 211 | - ]); |
|
| 212 | - |
|
| 213 | - foreach ($sidebars as $id => $name) { |
|
| 214 | - register_sidebar([ |
|
| 215 | - 'id' => $id, |
|
| 216 | - 'name' => $name, |
|
| 217 | - ] + $defaults); |
|
| 218 | - } |
|
| 219 | - } |
|
| 13 | + /** |
|
| 14 | + * @return void |
|
| 15 | + * @action after_setup_theme |
|
| 16 | + */ |
|
| 17 | + public function afterSetupTheme() |
|
| 18 | + { |
|
| 19 | + castor_app()->cssDir = trailingslashit((string) apply_filters('castor/assets/styles/dir', 'css')); |
|
| 20 | + castor_app()->imgDir = trailingslashit((string) apply_filters('castor/assets/images/dir', 'img')); |
|
| 21 | + castor_app()->jsDir = trailingslashit((string) apply_filters('castor/assets/scripts/dir', 'js')); |
|
| 22 | + |
|
| 23 | + add_editor_style(Theme::assetUri(castor_app()->cssDir.'editor.css')); |
|
| 24 | + add_theme_support('customize-selective-refresh-widgets'); |
|
| 25 | + add_theme_support('html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form']); |
|
| 26 | + add_theme_support('post-thumbnails'); |
|
| 27 | + add_theme_support('soil-clean-up'); |
|
| 28 | + add_theme_support('soil-jquery-cdn'); |
|
| 29 | + add_theme_support('soil-nav-walker'); |
|
| 30 | + add_theme_support('soil-nice-search'); |
|
| 31 | + add_theme_support('soil-relative-urls'); |
|
| 32 | + add_theme_support('title-tag'); |
|
| 33 | + load_theme_textdomain('castor', Theme::paths('dir.template').'/languages'); |
|
| 34 | + |
|
| 35 | + $menus = apply_filters('castor/register/nav_menus', [ |
|
| 36 | + 'main_menu' => __('Main Menu', 'castor'), |
|
| 37 | + ]); |
|
| 38 | + |
|
| 39 | + foreach ($menus as $location => $description) { |
|
| 40 | + register_nav_menu($location, $description); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @return array |
|
| 46 | + * @filter body_class |
|
| 47 | + */ |
|
| 48 | + public function filterBodyClasses(array $classes) |
|
| 49 | + { |
|
| 50 | + if (Theme::displaySidebar()) { |
|
| 51 | + $classes[] = 'has-sidebar'; |
|
| 52 | + } |
|
| 53 | + return array_keys(array_flip($classes)); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @return string |
|
| 58 | + * @filter login_headertext |
|
| 59 | + */ |
|
| 60 | + public function filterLoginTitle() |
|
| 61 | + { |
|
| 62 | + return get_bloginfo('name'); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * @return string |
|
| 67 | + * @filter login_headerurl |
|
| 68 | + */ |
|
| 69 | + public function filterLoginUrl() |
|
| 70 | + { |
|
| 71 | + return get_bloginfo('url'); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @return string |
|
| 76 | + * @filter template_include |
|
| 77 | + */ |
|
| 78 | + public function filterTemplate($template) |
|
| 79 | + { |
|
| 80 | + if (is_string($template)) { |
|
| 81 | + $template = Template::setLayout($template); |
|
| 82 | + Development::storeTemplatePath($template); |
|
| 83 | + } |
|
| 84 | + return $template; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @return array |
|
| 89 | + * @filter {$type}_template_hierarchy |
|
| 90 | + */ |
|
| 91 | + public function filterTemplateHierarchy(array $templates) |
|
| 92 | + { |
|
| 93 | + return array_map(function ($template) { |
|
| 94 | + return Utility::startWith('templates/', $template); |
|
| 95 | + }, $templates); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @return void |
|
| 100 | + * @action admin_head |
|
| 101 | + * @action login_head |
|
| 102 | + */ |
|
| 103 | + public function loadAdminFavicon() |
|
| 104 | + { |
|
| 105 | + if (file_exists(Theme::assetPath('favicon/favicon-admin.ico'))) { |
|
| 106 | + printf('<link rel="shortcut icon" href="%s">', Theme::assetUri('favicon/favicon-admin.ico')); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * @return void |
|
| 112 | + * @action login_head |
|
| 113 | + */ |
|
| 114 | + public function login() |
|
| 115 | + { |
|
| 116 | + if (file_exists(Theme::assetPath(castor_app()->cssDir.'login.css'))) { |
|
| 117 | + printf('<link rel="stylesheet" href="%s">', Theme::assetUri(castor_app()->cssDir.'login.css')); |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * @return void |
|
| 123 | + * @action admin_enqueue_scripts |
|
| 124 | + */ |
|
| 125 | + public function registerAdminAssets() |
|
| 126 | + { |
|
| 127 | + if (file_exists(Theme::assetPath(castor_app()->cssDir.'admin.css'))) { |
|
| 128 | + wp_enqueue_style('castor/admin.css', |
|
| 129 | + Theme::assetUri(castor_app()->cssDir.'admin.css'), |
|
| 130 | + apply_filters('castor/enqueue/admin/css/deps', []), |
|
| 131 | + CASTOR_FRAMEWORK_VERSION |
|
| 132 | + ); |
|
| 133 | + } |
|
| 134 | + if (file_exists(Theme::assetPath(castor_app()->jsDir.'admin.js'))) { |
|
| 135 | + wp_enqueue_script('castor/admin.js', |
|
| 136 | + Theme::assetUri(castor_app()->jsDir.'admin.js'), |
|
| 137 | + apply_filters('castor/enqueue/admin/js/deps', []), |
|
| 138 | + CASTOR_FRAMEWORK_VERSION, |
|
| 139 | + true |
|
| 140 | + ); |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * @return void |
|
| 146 | + * @action wp_enqueue_scripts |
|
| 147 | + */ |
|
| 148 | + public function registerAssets() |
|
| 149 | + { |
|
| 150 | + wp_register_style('castor/main.css', |
|
| 151 | + Theme::assetUri(castor_app()->cssDir.'main.css'), |
|
| 152 | + apply_filters('castor/enqueue/css/deps', []), |
|
| 153 | + CASTOR_FRAMEWORK_VERSION |
|
| 154 | + ); |
|
| 155 | + wp_register_script('castor/main.js', |
|
| 156 | + Theme::assetUri(castor_app()->jsDir.'main.js'), |
|
| 157 | + apply_filters('castor/enqueue/js/deps', []), |
|
| 158 | + CASTOR_FRAMEWORK_VERSION, |
|
| 159 | + true |
|
| 160 | + ); |
|
| 161 | + wp_localize_script('castor/main.js', apply_filters('castor/enqueue/js/localize/variable', 'globals'), |
|
| 162 | + apply_filters('castor/enqueue/js/localize/variables', [ |
|
| 163 | + 'ajax' => admin_url('admin-ajax.php'), |
|
| 164 | + ]) |
|
| 165 | + ); |
|
| 166 | + do_action('castor/register/assets'); |
|
| 167 | + wp_enqueue_style('castor/main.css'); |
|
| 168 | + wp_enqueue_script('castor/main.js'); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * @return void |
|
| 173 | + * @action customize_register |
|
| 174 | + */ |
|
| 175 | + public function registerCustomizer(WP_Customize_Manager $manager) |
|
| 176 | + { |
|
| 177 | + $manager->get_setting('blogname')->transport = 'postMessage'; |
|
| 178 | + $manager->selective_refresh->add_partial('blogname', [ |
|
| 179 | + 'selector' => '.brand', |
|
| 180 | + 'render_callback' => function () { |
|
| 181 | + bloginfo('name'); |
|
| 182 | + }, |
|
| 183 | + ]); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * @return void |
|
| 188 | + * @action customize_preview_init |
|
| 189 | + */ |
|
| 190 | + public function registerCustomizerAssets() |
|
| 191 | + { |
|
| 192 | + wp_enqueue_script('castor/customizer.js', Theme::assetUri(castor_app()->jsDir.'customizer.js'), ['customize-preview'], CASTOR_FRAMEWORK_VERSION, true); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * @return void |
|
| 197 | + * @action widgets_init |
|
| 198 | + */ |
|
| 199 | + public function registerSidebars() |
|
| 200 | + { |
|
| 201 | + $defaults = apply_filters('castor/register/sidebars/defaults', [ |
|
| 202 | + 'before_widget' => '<div class="widget %1$s %2$s">', |
|
| 203 | + 'after_widget' => '</div>', |
|
| 204 | + 'before_title' => '<h4>', |
|
| 205 | + 'after_title' => '</h4>', |
|
| 206 | + ]); |
|
| 207 | + |
|
| 208 | + $sidebars = apply_filters('castor/register/sidebars', [ |
|
| 209 | + 'sidebar-primary' => __('Primary Sidebar', 'castor'), |
|
| 210 | + 'sidebar-footer' => __('Footer Widgets', 'castor'), |
|
| 211 | + ]); |
|
| 212 | + |
|
| 213 | + foreach ($sidebars as $id => $name) { |
|
| 214 | + register_sidebar([ |
|
| 215 | + 'id' => $id, |
|
| 216 | + 'name' => $name, |
|
| 217 | + ] + $defaults); |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | 220 | } |
@@ -16,28 +16,28 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | public function afterSetupTheme() |
| 18 | 18 | { |
| 19 | - castor_app()->cssDir = trailingslashit((string) apply_filters('castor/assets/styles/dir', 'css')); |
|
| 20 | - castor_app()->imgDir = trailingslashit((string) apply_filters('castor/assets/images/dir', 'img')); |
|
| 21 | - castor_app()->jsDir = trailingslashit((string) apply_filters('castor/assets/scripts/dir', 'js')); |
|
| 22 | - |
|
| 23 | - add_editor_style(Theme::assetUri(castor_app()->cssDir.'editor.css')); |
|
| 24 | - add_theme_support('customize-selective-refresh-widgets'); |
|
| 25 | - add_theme_support('html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form']); |
|
| 26 | - add_theme_support('post-thumbnails'); |
|
| 27 | - add_theme_support('soil-clean-up'); |
|
| 28 | - add_theme_support('soil-jquery-cdn'); |
|
| 29 | - add_theme_support('soil-nav-walker'); |
|
| 30 | - add_theme_support('soil-nice-search'); |
|
| 31 | - add_theme_support('soil-relative-urls'); |
|
| 32 | - add_theme_support('title-tag'); |
|
| 33 | - load_theme_textdomain('castor', Theme::paths('dir.template').'/languages'); |
|
| 34 | - |
|
| 35 | - $menus = apply_filters('castor/register/nav_menus', [ |
|
| 36 | - 'main_menu' => __('Main Menu', 'castor'), |
|
| 37 | - ]); |
|
| 38 | - |
|
| 39 | - foreach ($menus as $location => $description) { |
|
| 40 | - register_nav_menu($location, $description); |
|
| 19 | + castor_app()->cssDir = trailingslashit( (string) apply_filters( 'castor/assets/styles/dir', 'css' ) ); |
|
| 20 | + castor_app()->imgDir = trailingslashit( (string) apply_filters( 'castor/assets/images/dir', 'img' ) ); |
|
| 21 | + castor_app()->jsDir = trailingslashit( (string) apply_filters( 'castor/assets/scripts/dir', 'js' ) ); |
|
| 22 | + |
|
| 23 | + add_editor_style( Theme::assetUri( castor_app()->cssDir.'editor.css' ) ); |
|
| 24 | + add_theme_support( 'customize-selective-refresh-widgets' ); |
|
| 25 | + add_theme_support( 'html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form'] ); |
|
| 26 | + add_theme_support( 'post-thumbnails' ); |
|
| 27 | + add_theme_support( 'soil-clean-up' ); |
|
| 28 | + add_theme_support( 'soil-jquery-cdn' ); |
|
| 29 | + add_theme_support( 'soil-nav-walker' ); |
|
| 30 | + add_theme_support( 'soil-nice-search' ); |
|
| 31 | + add_theme_support( 'soil-relative-urls' ); |
|
| 32 | + add_theme_support( 'title-tag' ); |
|
| 33 | + load_theme_textdomain( 'castor', Theme::paths( 'dir.template' ).'/languages' ); |
|
| 34 | + |
|
| 35 | + $menus = apply_filters( 'castor/register/nav_menus', [ |
|
| 36 | + 'main_menu' => __( 'Main Menu', 'castor' ), |
|
| 37 | + ] ); |
|
| 38 | + |
|
| 39 | + foreach( $menus as $location => $description ) { |
|
| 40 | + register_nav_menu( $location, $description ); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | * @return array |
| 46 | 46 | * @filter body_class |
| 47 | 47 | */ |
| 48 | - public function filterBodyClasses(array $classes) |
|
| 48 | + public function filterBodyClasses( array $classes ) |
|
| 49 | 49 | { |
| 50 | - if (Theme::displaySidebar()) { |
|
| 50 | + if( Theme::displaySidebar() ) { |
|
| 51 | 51 | $classes[] = 'has-sidebar'; |
| 52 | 52 | } |
| 53 | - return array_keys(array_flip($classes)); |
|
| 53 | + return array_keys( array_flip( $classes ) ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function filterLoginTitle() |
| 61 | 61 | { |
| 62 | - return get_bloginfo('name'); |
|
| 62 | + return get_bloginfo( 'name' ); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -68,18 +68,18 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function filterLoginUrl() |
| 70 | 70 | { |
| 71 | - return get_bloginfo('url'); |
|
| 71 | + return get_bloginfo( 'url' ); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * @return string |
| 76 | 76 | * @filter template_include |
| 77 | 77 | */ |
| 78 | - public function filterTemplate($template) |
|
| 78 | + public function filterTemplate( $template ) |
|
| 79 | 79 | { |
| 80 | - if (is_string($template)) { |
|
| 81 | - $template = Template::setLayout($template); |
|
| 82 | - Development::storeTemplatePath($template); |
|
| 80 | + if( is_string( $template ) ) { |
|
| 81 | + $template = Template::setLayout( $template ); |
|
| 82 | + Development::storeTemplatePath( $template ); |
|
| 83 | 83 | } |
| 84 | 84 | return $template; |
| 85 | 85 | } |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | * @return array |
| 89 | 89 | * @filter {$type}_template_hierarchy |
| 90 | 90 | */ |
| 91 | - public function filterTemplateHierarchy(array $templates) |
|
| 91 | + public function filterTemplateHierarchy( array $templates ) |
|
| 92 | 92 | { |
| 93 | - return array_map(function ($template) { |
|
| 94 | - return Utility::startWith('templates/', $template); |
|
| 95 | - }, $templates); |
|
| 93 | + return array_map( function( $template ) { |
|
| 94 | + return Utility::startWith( 'templates/', $template ); |
|
| 95 | + }, $templates ); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function loadAdminFavicon() |
| 104 | 104 | { |
| 105 | - if (file_exists(Theme::assetPath('favicon/favicon-admin.ico'))) { |
|
| 106 | - printf('<link rel="shortcut icon" href="%s">', Theme::assetUri('favicon/favicon-admin.ico')); |
|
| 105 | + if( file_exists( Theme::assetPath( 'favicon/favicon-admin.ico' ) ) ) { |
|
| 106 | + printf( '<link rel="shortcut icon" href="%s">', Theme::assetUri( 'favicon/favicon-admin.ico' ) ); |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function login() |
| 115 | 115 | { |
| 116 | - if (file_exists(Theme::assetPath(castor_app()->cssDir.'login.css'))) { |
|
| 117 | - printf('<link rel="stylesheet" href="%s">', Theme::assetUri(castor_app()->cssDir.'login.css')); |
|
| 116 | + if( file_exists( Theme::assetPath( castor_app()->cssDir.'login.css' ) ) ) { |
|
| 117 | + printf( '<link rel="stylesheet" href="%s">', Theme::assetUri( castor_app()->cssDir.'login.css' ) ); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
@@ -124,17 +124,17 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function registerAdminAssets() |
| 126 | 126 | { |
| 127 | - if (file_exists(Theme::assetPath(castor_app()->cssDir.'admin.css'))) { |
|
| 128 | - wp_enqueue_style('castor/admin.css', |
|
| 129 | - Theme::assetUri(castor_app()->cssDir.'admin.css'), |
|
| 130 | - apply_filters('castor/enqueue/admin/css/deps', []), |
|
| 127 | + if( file_exists( Theme::assetPath( castor_app()->cssDir.'admin.css' ) ) ) { |
|
| 128 | + wp_enqueue_style( 'castor/admin.css', |
|
| 129 | + Theme::assetUri( castor_app()->cssDir.'admin.css' ), |
|
| 130 | + apply_filters( 'castor/enqueue/admin/css/deps', [] ), |
|
| 131 | 131 | CASTOR_FRAMEWORK_VERSION |
| 132 | 132 | ); |
| 133 | 133 | } |
| 134 | - if (file_exists(Theme::assetPath(castor_app()->jsDir.'admin.js'))) { |
|
| 135 | - wp_enqueue_script('castor/admin.js', |
|
| 136 | - Theme::assetUri(castor_app()->jsDir.'admin.js'), |
|
| 137 | - apply_filters('castor/enqueue/admin/js/deps', []), |
|
| 134 | + if( file_exists( Theme::assetPath( castor_app()->jsDir.'admin.js' ) ) ) { |
|
| 135 | + wp_enqueue_script( 'castor/admin.js', |
|
| 136 | + Theme::assetUri( castor_app()->jsDir.'admin.js' ), |
|
| 137 | + apply_filters( 'castor/enqueue/admin/js/deps', [] ), |
|
| 138 | 138 | CASTOR_FRAMEWORK_VERSION, |
| 139 | 139 | true |
| 140 | 140 | ); |
@@ -147,40 +147,40 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function registerAssets() |
| 149 | 149 | { |
| 150 | - wp_register_style('castor/main.css', |
|
| 151 | - Theme::assetUri(castor_app()->cssDir.'main.css'), |
|
| 152 | - apply_filters('castor/enqueue/css/deps', []), |
|
| 150 | + wp_register_style( 'castor/main.css', |
|
| 151 | + Theme::assetUri( castor_app()->cssDir.'main.css' ), |
|
| 152 | + apply_filters( 'castor/enqueue/css/deps', [] ), |
|
| 153 | 153 | CASTOR_FRAMEWORK_VERSION |
| 154 | 154 | ); |
| 155 | - wp_register_script('castor/main.js', |
|
| 156 | - Theme::assetUri(castor_app()->jsDir.'main.js'), |
|
| 157 | - apply_filters('castor/enqueue/js/deps', []), |
|
| 155 | + wp_register_script( 'castor/main.js', |
|
| 156 | + Theme::assetUri( castor_app()->jsDir.'main.js' ), |
|
| 157 | + apply_filters( 'castor/enqueue/js/deps', [] ), |
|
| 158 | 158 | CASTOR_FRAMEWORK_VERSION, |
| 159 | 159 | true |
| 160 | 160 | ); |
| 161 | - wp_localize_script('castor/main.js', apply_filters('castor/enqueue/js/localize/variable', 'globals'), |
|
| 162 | - apply_filters('castor/enqueue/js/localize/variables', [ |
|
| 163 | - 'ajax' => admin_url('admin-ajax.php'), |
|
| 164 | - ]) |
|
| 161 | + wp_localize_script( 'castor/main.js', apply_filters( 'castor/enqueue/js/localize/variable', 'globals' ), |
|
| 162 | + apply_filters( 'castor/enqueue/js/localize/variables', [ |
|
| 163 | + 'ajax' => admin_url( 'admin-ajax.php' ), |
|
| 164 | + ] ) |
|
| 165 | 165 | ); |
| 166 | - do_action('castor/register/assets'); |
|
| 167 | - wp_enqueue_style('castor/main.css'); |
|
| 168 | - wp_enqueue_script('castor/main.js'); |
|
| 166 | + do_action( 'castor/register/assets' ); |
|
| 167 | + wp_enqueue_style( 'castor/main.css' ); |
|
| 168 | + wp_enqueue_script( 'castor/main.js' ); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | 172 | * @return void |
| 173 | 173 | * @action customize_register |
| 174 | 174 | */ |
| 175 | - public function registerCustomizer(WP_Customize_Manager $manager) |
|
| 175 | + public function registerCustomizer( WP_Customize_Manager $manager ) |
|
| 176 | 176 | { |
| 177 | - $manager->get_setting('blogname')->transport = 'postMessage'; |
|
| 178 | - $manager->selective_refresh->add_partial('blogname', [ |
|
| 177 | + $manager->get_setting( 'blogname' )->transport = 'postMessage'; |
|
| 178 | + $manager->selective_refresh->add_partial( 'blogname', [ |
|
| 179 | 179 | 'selector' => '.brand', |
| 180 | - 'render_callback' => function () { |
|
| 181 | - bloginfo('name'); |
|
| 180 | + 'render_callback' => function() { |
|
| 181 | + bloginfo( 'name' ); |
|
| 182 | 182 | }, |
| 183 | - ]); |
|
| 183 | + ] ); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function registerCustomizerAssets() |
| 191 | 191 | { |
| 192 | - wp_enqueue_script('castor/customizer.js', Theme::assetUri(castor_app()->jsDir.'customizer.js'), ['customize-preview'], CASTOR_FRAMEWORK_VERSION, true); |
|
| 192 | + wp_enqueue_script( 'castor/customizer.js', Theme::assetUri( castor_app()->jsDir.'customizer.js' ), ['customize-preview'], CASTOR_FRAMEWORK_VERSION, true ); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -198,23 +198,23 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function registerSidebars() |
| 200 | 200 | { |
| 201 | - $defaults = apply_filters('castor/register/sidebars/defaults', [ |
|
| 201 | + $defaults = apply_filters( 'castor/register/sidebars/defaults', [ |
|
| 202 | 202 | 'before_widget' => '<div class="widget %1$s %2$s">', |
| 203 | 203 | 'after_widget' => '</div>', |
| 204 | 204 | 'before_title' => '<h4>', |
| 205 | 205 | 'after_title' => '</h4>', |
| 206 | - ]); |
|
| 206 | + ] ); |
|
| 207 | 207 | |
| 208 | - $sidebars = apply_filters('castor/register/sidebars', [ |
|
| 209 | - 'sidebar-primary' => __('Primary Sidebar', 'castor'), |
|
| 210 | - 'sidebar-footer' => __('Footer Widgets', 'castor'), |
|
| 211 | - ]); |
|
| 208 | + $sidebars = apply_filters( 'castor/register/sidebars', [ |
|
| 209 | + 'sidebar-primary' => __( 'Primary Sidebar', 'castor' ), |
|
| 210 | + 'sidebar-footer' => __( 'Footer Widgets', 'castor' ), |
|
| 211 | + ] ); |
|
| 212 | 212 | |
| 213 | - foreach ($sidebars as $id => $name) { |
|
| 214 | - register_sidebar([ |
|
| 213 | + foreach( $sidebars as $id => $name ) { |
|
| 214 | + register_sidebar( [ |
|
| 215 | 215 | 'id' => $id, |
| 216 | 216 | 'name' => $name, |
| 217 | - ] + $defaults); |
|
| 217 | + ] + $defaults ); |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | } |