@@ -16,24 +16,24 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function afterSetupTheme() |
18 | 18 | { |
19 | - add_editor_style( Theme::assetUri( 'css/editor.css' )); |
|
20 | - add_theme_support( 'customize-selective-refresh-widgets' ); |
|
21 | - add_theme_support( 'html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form'] ); |
|
22 | - add_theme_support( 'post-thumbnails' ); |
|
23 | - add_theme_support( 'soil-clean-up' ); |
|
24 | - add_theme_support( 'soil-jquery-cdn' ); |
|
25 | - add_theme_support( 'soil-nav-walker' ); |
|
26 | - add_theme_support( 'soil-nice-search' ); |
|
27 | - add_theme_support( 'soil-relative-urls' ); |
|
28 | - add_theme_support( 'title-tag' ); |
|
29 | - load_theme_textdomain( 'castor', Theme::paths( 'dir.template' ) . '/languages' ); |
|
30 | - |
|
31 | - $menus = apply_filters( 'castor/register/nav_menus', [ |
|
32 | - 'main_menu' => __( 'Main Menu', 'castor' ), |
|
19 | + add_editor_style(Theme::assetUri('css/editor.css')); |
|
20 | + add_theme_support('customize-selective-refresh-widgets'); |
|
21 | + add_theme_support('html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form']); |
|
22 | + add_theme_support('post-thumbnails'); |
|
23 | + add_theme_support('soil-clean-up'); |
|
24 | + add_theme_support('soil-jquery-cdn'); |
|
25 | + add_theme_support('soil-nav-walker'); |
|
26 | + add_theme_support('soil-nice-search'); |
|
27 | + add_theme_support('soil-relative-urls'); |
|
28 | + add_theme_support('title-tag'); |
|
29 | + load_theme_textdomain('castor', Theme::paths('dir.template') . '/languages'); |
|
30 | + |
|
31 | + $menus = apply_filters('castor/register/nav_menus', [ |
|
32 | + 'main_menu' => __('Main Menu', 'castor'), |
|
33 | 33 | ]); |
34 | 34 | |
35 | - foreach( $menus as $location => $description ) { |
|
36 | - register_nav_menu( $location, $description ); |
|
35 | + foreach ($menus as $location => $description) { |
|
36 | + register_nav_menu($location, $description); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function filterLoginTitle() |
45 | 45 | { |
46 | - return get_bloginfo( 'name' ); |
|
46 | + return get_bloginfo('name'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -52,18 +52,18 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function filterLoginUrl() |
54 | 54 | { |
55 | - return get_bloginfo( 'url' ); |
|
55 | + return get_bloginfo('url'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @return string |
60 | 60 | * @filter template_include |
61 | 61 | */ |
62 | - public function filterTemplate( $template ) |
|
62 | + public function filterTemplate($template) |
|
63 | 63 | { |
64 | - if( is_string( $template )) { |
|
65 | - $template = Template::setLayout( $template ); |
|
66 | - Development::storeTemplatePath( $template ); |
|
64 | + if (is_string($template)) { |
|
65 | + $template = Template::setLayout($template); |
|
66 | + Development::storeTemplatePath($template); |
|
67 | 67 | } |
68 | 68 | return $template; |
69 | 69 | } |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | * @return array |
73 | 73 | * @filter {$type}_template_hierarchy |
74 | 74 | */ |
75 | - public function filterTemplateHierarchy( array $templates ) |
|
75 | + public function filterTemplateHierarchy(array $templates) |
|
76 | 76 | { |
77 | - return array_map( function( $template ) { |
|
78 | - return Utility::startWith( 'templates/', $template ); |
|
79 | - }, $templates ); |
|
77 | + return array_map(function($template) { |
|
78 | + return Utility::startWith('templates/', $template); |
|
79 | + }, $templates); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function login() |
87 | 87 | { |
88 | - if( file_exists( Theme::assetPath( 'css/login.css' ))) { |
|
89 | - printf( '<link rel="stylesheet" href="%s">', Theme::assetUri( 'css/login.css' )); |
|
88 | + if (file_exists(Theme::assetPath('css/login.css'))) { |
|
89 | + printf('<link rel="stylesheet" href="%s">', Theme::assetUri('css/login.css')); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -96,20 +96,20 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function registerAssets() |
98 | 98 | { |
99 | - wp_enqueue_style( 'castor/main.css', |
|
100 | - Theme::assetUri( 'css/main.css' ), |
|
101 | - apply_filters( 'castor/enqueue/css/deps', [] ), |
|
99 | + wp_enqueue_style('castor/main.css', |
|
100 | + Theme::assetUri('css/main.css'), |
|
101 | + apply_filters('castor/enqueue/css/deps', []), |
|
102 | 102 | null |
103 | 103 | ); |
104 | - wp_enqueue_script( 'castor/main.js', |
|
105 | - Theme::assetUri( 'js/main.js' ), |
|
106 | - apply_filters( 'castor/enqueue/js/deps', [] ), |
|
104 | + wp_enqueue_script('castor/main.js', |
|
105 | + Theme::assetUri('js/main.js'), |
|
106 | + apply_filters('castor/enqueue/js/deps', []), |
|
107 | 107 | null, |
108 | 108 | true |
109 | 109 | ); |
110 | - wp_localize_script( 'castor/main.js', apply_filters( 'castor/enqueue/js/localize/variable', 'globals' ), |
|
111 | - apply_filters( 'castor/enqueue/js/localize/variables', [ |
|
112 | - 'ajax' => admin_url( 'admin-ajax.php' ), |
|
110 | + wp_localize_script('castor/main.js', apply_filters('castor/enqueue/js/localize/variable', 'globals'), |
|
111 | + apply_filters('castor/enqueue/js/localize/variables', [ |
|
112 | + 'ajax' => admin_url('admin-ajax.php'), |
|
113 | 113 | ]) |
114 | 114 | ); |
115 | 115 | } |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * @return void |
119 | 119 | * @action customize_register |
120 | 120 | */ |
121 | - public function registerCustomizer( WP_Customize_Manager $manager ) |
|
121 | + public function registerCustomizer(WP_Customize_Manager $manager) |
|
122 | 122 | { |
123 | - $manager->get_setting( 'blogname' )->transport = 'postMessage'; |
|
124 | - $manager->selective_refresh->add_partial( 'blogname', [ |
|
123 | + $manager->get_setting('blogname')->transport = 'postMessage'; |
|
124 | + $manager->selective_refresh->add_partial('blogname', [ |
|
125 | 125 | 'selector' => '.brand', |
126 | 126 | 'render_callback' => function() { |
127 | - bloginfo( 'name' ); |
|
127 | + bloginfo('name'); |
|
128 | 128 | }, |
129 | 129 | ]); |
130 | 130 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function registerCustomizerAssets() |
137 | 137 | { |
138 | - wp_enqueue_script( 'castor/customizer.js', Theme::assetUri( 'js/customizer.js' ), ['customize-preview'], null, true ); |
|
138 | + wp_enqueue_script('castor/customizer.js', Theme::assetUri('js/customizer.js'), ['customize-preview'], null, true); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,23 +144,23 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function registerSidebars() |
146 | 146 | { |
147 | - $defaults = apply_filters( 'castor/register/sidebars/defaults', [ |
|
147 | + $defaults = apply_filters('castor/register/sidebars/defaults', [ |
|
148 | 148 | 'before_widget' => '<div class="widget %1$s %2$s">', |
149 | 149 | 'after_widget' => '</div>', |
150 | 150 | 'before_title' => '<h4>', |
151 | 151 | 'after_title' => '</h4>', |
152 | 152 | ]); |
153 | 153 | |
154 | - $sidebars = apply_filters( 'castor/register/sidebars', [ |
|
155 | - 'sidebar-primary' => __( 'Primary Sidebar', 'castor' ), |
|
156 | - 'sidebar-footer' => __( 'Footer Sidebar', 'castor' ), |
|
154 | + $sidebars = apply_filters('castor/register/sidebars', [ |
|
155 | + 'sidebar-primary' => __('Primary Sidebar', 'castor'), |
|
156 | + 'sidebar-footer' => __('Footer Sidebar', 'castor'), |
|
157 | 157 | ]); |
158 | 158 | |
159 | - foreach( $sidebars as $id => $name ) { |
|
159 | + foreach ($sidebars as $id => $name) { |
|
160 | 160 | register_sidebar([ |
161 | 161 | 'id' => $id, |
162 | 162 | 'name' => $name, |
163 | - ] + $defaults ); |
|
163 | + ] + $defaults); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | } |
@@ -6,13 +6,13 @@ |
||
6 | 6 | |
7 | 7 | class SiteMeta extends Facade |
8 | 8 | { |
9 | - /** |
|
10 | - * Get the fully qualified class name of the component. |
|
11 | - * |
|
12 | - * @return string |
|
13 | - */ |
|
14 | - protected static function getFacadeAccessor() |
|
15 | - { |
|
16 | - return \GeminiLabs\Castor\Helpers\SiteMeta::class; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Get the fully qualified class name of the component. |
|
11 | + * |
|
12 | + * @return string |
|
13 | + */ |
|
14 | + protected static function getFacadeAccessor() |
|
15 | + { |
|
16 | + return \GeminiLabs\Castor\Helpers\SiteMeta::class; |
|
17 | + } |
|
18 | 18 | } |
@@ -38,7 +38,9 @@ discard block |
||
38 | 38 | public function printFiltersFor( $hook = '' ) |
39 | 39 | { |
40 | 40 | global $wp_filter; |
41 | - if( empty( $hook ) || !isset( $wp_filter[$hook] ))return; |
|
41 | + if( empty( $hook ) || !isset( $wp_filter[$hook] )) { |
|
42 | + return; |
|
43 | + } |
|
42 | 44 | $this->printF( $wp_filter[ $hook ] ); |
43 | 45 | } |
44 | 46 | |
@@ -70,8 +72,7 @@ discard block |
||
70 | 72 | printf( '<div class="print__r"><pre>%s</pre></div>', |
71 | 73 | htmlspecialchars( print_r( func_get_arg(0), true ), ENT_QUOTES, 'UTF-8' ) |
72 | 74 | ); |
73 | - } |
|
74 | - else if( $args > 1 ) { |
|
75 | + } else if( $args > 1 ) { |
|
75 | 76 | echo '<div class="print__r_group">'; |
76 | 77 | foreach( func_get_args() as $value ) { |
77 | 78 | $this->printF( $value ); |
@@ -10,33 +10,33 @@ discard block |
||
10 | 10 | |
11 | 11 | protected $utility; |
12 | 12 | |
13 | - public function __construct( Utility $utility ) |
|
13 | + public function __construct(Utility $utility) |
|
14 | 14 | { |
15 | - $this->utility = $utility; |
|
15 | + $this->utility = $utility; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public function capture() |
19 | 19 | { |
20 | 20 | ob_start(); |
21 | - call_user_func_array( [$this, 'printF'], func_get_args() ); |
|
21 | + call_user_func_array([$this, 'printF'], func_get_args()); |
|
22 | 22 | return ob_get_clean(); |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function className() |
26 | 26 | { |
27 | - return $this->isDev() && in_array( DEV, ['css', true] ) |
|
27 | + return $this->isDev() && in_array(DEV, ['css', true]) |
|
28 | 28 | ? 'dev' |
29 | 29 | : ''; |
30 | 30 | } |
31 | 31 | |
32 | 32 | public function debug() |
33 | 33 | { |
34 | - call_user_func_array( [$this, 'printF'], func_get_args() ); |
|
34 | + call_user_func_array([$this, 'printF'], func_get_args()); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function isDev() |
38 | 38 | { |
39 | - return defined( 'DEV' ) && !!DEV && WP_ENV == 'development'; |
|
39 | + return defined('DEV') && !!DEV && WP_ENV == 'development'; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function isProduction() |
@@ -44,27 +44,27 @@ discard block |
||
44 | 44 | return WP_ENV == 'production'; |
45 | 45 | } |
46 | 46 | |
47 | - public function printFiltersFor( $hook = '' ) |
|
47 | + public function printFiltersFor($hook = '') |
|
48 | 48 | { |
49 | 49 | global $wp_filter; |
50 | - if( empty( $hook ) || !isset( $wp_filter[$hook] ))return; |
|
51 | - $this->printF( $wp_filter[ $hook ] ); |
|
50 | + if (empty($hook) || !isset($wp_filter[$hook]))return; |
|
51 | + $this->printF($wp_filter[$hook]); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function printTemplatePaths() |
55 | 55 | { |
56 | - if( $this->isDev() && ( DEV == 'templates' || DEV === true )) { |
|
57 | - $templates = array_map( function( $key, $value ) { |
|
58 | - return sprintf( '[%s] => %s', $key, $value ); |
|
59 | - }, array_keys( $this->templatePaths ), $this->templatePaths ); |
|
60 | - $this->printF( implode( "\n", $templates )); |
|
56 | + if ($this->isDev() && (DEV == 'templates' || DEV === true)) { |
|
57 | + $templates = array_map(function($key, $value) { |
|
58 | + return sprintf('[%s] => %s', $key, $value); |
|
59 | + }, array_keys($this->templatePaths), $this->templatePaths); |
|
60 | + $this->printF(implode("\n", $templates)); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | - public function storeTemplatePath( $template ) |
|
64 | + public function storeTemplatePath($template) |
|
65 | 65 | { |
66 | - if( is_string( $template )) { |
|
67 | - $this->templatePaths[] = $this->utility->trimLeft( $template, trailingslashit( WP_CONTENT_DIR )); |
|
66 | + if (is_string($template)) { |
|
67 | + $this->templatePaths[] = $this->utility->trimLeft($template, trailingslashit(WP_CONTENT_DIR)); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | { |
73 | 73 | $args = func_num_args(); |
74 | 74 | |
75 | - if( $args == 1 ) { |
|
76 | - printf( '<div class="print__r"><pre>%s</pre></div>', |
|
77 | - htmlspecialchars( print_r( func_get_arg(0), true ), ENT_QUOTES, 'UTF-8' ) |
|
75 | + if ($args == 1) { |
|
76 | + printf('<div class="print__r"><pre>%s</pre></div>', |
|
77 | + htmlspecialchars(print_r(func_get_arg(0), true), ENT_QUOTES, 'UTF-8') |
|
78 | 78 | ); |
79 | 79 | } |
80 | - else if( $args > 1 ) { |
|
80 | + else if ($args > 1) { |
|
81 | 81 | echo '<div class="print__r_group">'; |
82 | - foreach( func_get_args() as $value ) { |
|
83 | - $this->printF( $value ); |
|
82 | + foreach (func_get_args() as $value) { |
|
83 | + $this->printF($value); |
|
84 | 84 | } |
85 | 85 | echo '</div>'; |
86 | 86 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | protected $theme; |
20 | 20 | protected $utility; |
21 | 21 | |
22 | - public function __construct( Image $image, PostMeta $postmeta, Theme $theme, Utility $utility ) |
|
22 | + public function __construct(Image $image, PostMeta $postmeta, Theme $theme, Utility $utility) |
|
23 | 23 | { |
24 | 24 | $this->image = $image; |
25 | 25 | $this->postmeta = $postmeta; |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @return WP_Query |
32 | 32 | */ |
33 | - public function get( array $args = [] ) |
|
33 | + public function get(array $args = []) |
|
34 | 34 | { |
35 | - $this->normalizeArgs( $args ); |
|
35 | + $this->normalizeArgs($args); |
|
36 | 36 | |
37 | 37 | $this->gallery = new WP_Query([ |
38 | 38 | 'orderby' => 'post__in', |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function render() |
54 | 54 | { |
55 | - if( empty( $this->args['media'] ))return; |
|
56 | - $images = array_reduce( $this->gallery->posts, function( $images, $attachment ) { |
|
57 | - return $images . $this->renderImage( $attachment ); |
|
55 | + if (empty($this->args['media']))return; |
|
56 | + $images = array_reduce($this->gallery->posts, function($images, $attachment) { |
|
57 | + return $images . $this->renderImage($attachment); |
|
58 | 58 | }); |
59 | - return sprintf( '<div class="gallery-images" itemscope itemtype="http://schema.org/ImageGallery">%s</div>%s', |
|
59 | + return sprintf('<div class="gallery-images" itemscope itemtype="http://schema.org/ImageGallery">%s</div>%s', |
|
60 | 60 | $images, |
61 | 61 | $this->renderPagination() |
62 | 62 | ); |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | /** |
66 | 66 | * @return null|string |
67 | 67 | */ |
68 | - public function renderImage( WP_Post $attachment ) |
|
68 | + public function renderImage(WP_Post $attachment) |
|
69 | 69 | { |
70 | - $image = $this->image->get( $attachment->ID )->image; |
|
70 | + $image = $this->image->get($attachment->ID)->image; |
|
71 | 71 | |
72 | - if( !$image )return; |
|
72 | + if (!$image)return; |
|
73 | 73 | return sprintf( |
74 | 74 | '<figure class="gallery-image" data-w="%s" data-h="%s" data-ps=\'%s\' itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">' . |
75 | 75 | '%s<figcaption itemprop="caption description">' . |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | '</figure>', |
79 | 79 | $image->thumbnail['width'], |
80 | 80 | $image->thumbnail['height'], |
81 | - $this->getPhotoswipeData( $image ), |
|
82 | - $this->renderImageTag( $image ), |
|
81 | + $this->getPhotoswipeData($image), |
|
82 | + $this->renderImageTag($image), |
|
83 | 83 | $image->caption, |
84 | 84 | $image->copyright |
85 | 85 | ); |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function renderPagination() |
92 | 92 | { |
93 | - if( !$this->args['pagination'] )return; |
|
93 | + if (!$this->args['pagination'])return; |
|
94 | 94 | return paginate_links([ |
95 | - 'before_page_number' => '<span class="screen-reader-text">' . __( 'Page', 'castor' ) . ' </span>', |
|
95 | + 'before_page_number' => '<span class="screen-reader-text">' . __('Page', 'castor') . ' </span>', |
|
96 | 96 | 'current' => $this->gallery->query['paged'], |
97 | 97 | 'mid_size' => 1, |
98 | - 'next_text' => __( 'Next', 'castor' ), |
|
99 | - 'prev_text' => __( 'Previous', 'castor' ), |
|
98 | + 'next_text' => __('Next', 'castor'), |
|
99 | + 'prev_text' => __('Previous', 'castor'), |
|
100 | 100 | 'total' => $this->gallery->max_num_pages, |
101 | 101 | ]); |
102 | 102 | } |
@@ -107,14 +107,14 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return bool |
109 | 109 | */ |
110 | - protected function getBoolValue( $key, $value = null ) |
|
110 | + protected function getBoolValue($key, $value = null) |
|
111 | 111 | { |
112 | - $bool = $this->getValue( $key, $value ); |
|
112 | + $bool = $this->getValue($key, $value); |
|
113 | 113 | |
114 | - if( is_null( filter_var( $bool, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ))) { |
|
115 | - $bool = $this->postmeta->get( $bool ); |
|
114 | + if (is_null(filter_var($bool, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE))) { |
|
115 | + $bool = $this->postmeta->get($bool); |
|
116 | 116 | } |
117 | - return wp_validate_boolean( $bool ); |
|
117 | + return wp_validate_boolean($bool); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return int |
124 | 124 | */ |
125 | - protected function getGalleryArg( $value = null ) |
|
125 | + protected function getGalleryArg($value = null) |
|
126 | 126 | { |
127 | - $gallery = $this->getValue( 'gallery', $value ); |
|
127 | + $gallery = $this->getValue('gallery', $value); |
|
128 | 128 | |
129 | - if( !is_numeric( $gallery ) && is_string( $gallery )) { |
|
130 | - $gallery = intval( $this->postmeta->get( $gallery )); |
|
129 | + if (!is_numeric($gallery) && is_string($gallery)) { |
|
130 | + $gallery = intval($this->postmeta->get($gallery)); |
|
131 | 131 | } |
132 | - return !is_null( get_post( $gallery )) |
|
133 | - ? intval( $gallery ) |
|
132 | + return !is_null(get_post($gallery)) |
|
133 | + ? intval($gallery) |
|
134 | 134 | : 0; |
135 | 135 | } |
136 | 136 | |
@@ -139,14 +139,14 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return int |
141 | 141 | */ |
142 | - protected function getImagesPerPageArg( $value = null ) |
|
142 | + protected function getImagesPerPageArg($value = null) |
|
143 | 143 | { |
144 | - $perPage = $this->getValue( 'images_per_page', $value ); |
|
144 | + $perPage = $this->getValue('images_per_page', $value); |
|
145 | 145 | |
146 | - if( !is_numeric( $perPage ) && is_string( $perPage )) { |
|
147 | - $perPage = $this->postmeta->get( $perPage ); |
|
146 | + if (!is_numeric($perPage) && is_string($perPage)) { |
|
147 | + $perPage = $this->postmeta->get($perPage); |
|
148 | 148 | } |
149 | - return !!intval( $perPage ) |
|
149 | + return !!intval($perPage) |
|
150 | 150 | ? $perPage |
151 | 151 | : -1; |
152 | 152 | } |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @return bool |
158 | 158 | */ |
159 | - protected function getLazyloadArg( $value = null ) |
|
159 | + protected function getLazyloadArg($value = null) |
|
160 | 160 | { |
161 | - return $this->getBoolValue( 'lazyload', $value ); |
|
161 | + return $this->getBoolValue('lazyload', $value); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return array |
168 | 168 | */ |
169 | - protected function getMediaArg( $value = null ) |
|
169 | + protected function getMediaArg($value = null) |
|
170 | 170 | { |
171 | - $media = $this->getValue( 'media', $value ); |
|
171 | + $media = $this->getValue('media', $value); |
|
172 | 172 | |
173 | - if( is_string( $media )) { |
|
174 | - $media = $this->postmeta->get( $media, [ |
|
173 | + if (is_string($media)) { |
|
174 | + $media = $this->postmeta->get($media, [ |
|
175 | 175 | 'ID' => $this->getGalleryArg(), |
176 | 176 | 'single' => false, |
177 | 177 | ]); |
178 | 178 | } |
179 | - return is_array( $media ) |
|
180 | - ? wp_parse_id_list( $media ) |
|
179 | + return is_array($media) |
|
180 | + ? wp_parse_id_list($media) |
|
181 | 181 | : []; |
182 | 182 | } |
183 | 183 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function getPaged() |
188 | 188 | { |
189 | - return intval( get_query_var(( is_front_page() ? 'page' : 'paged' ))) ?: 1; |
|
189 | + return intval(get_query_var((is_front_page() ? 'page' : 'paged'))) ?: 1; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @return bool |
196 | 196 | */ |
197 | - protected function getPaginationArg( $value = null ) |
|
197 | + protected function getPaginationArg($value = null) |
|
198 | 198 | { |
199 | - return $this->getBoolValue( 'pagination', $value ); |
|
199 | + return $this->getBoolValue('pagination', $value); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -204,17 +204,17 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return bool |
206 | 206 | */ |
207 | - protected function getPermalinksArg( $value = null ) |
|
207 | + protected function getPermalinksArg($value = null) |
|
208 | 208 | { |
209 | - return $this->getBoolValue( 'permalinks', $value ); |
|
209 | + return $this->getBoolValue('permalinks', $value); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
213 | 213 | * @return string |
214 | 214 | */ |
215 | - protected function getPhotoswipeData( $image ) |
|
215 | + protected function getPhotoswipeData($image) |
|
216 | 216 | { |
217 | - return sprintf( '{"l":{"src":"%s","w":%d,"h":%d},"m":{"src":"%s","w":%d,"h":%d}}', |
|
217 | + return sprintf('{"l":{"src":"%s","w":%d,"h":%d},"m":{"src":"%s","w":%d,"h":%d}}', |
|
218 | 218 | $image->large['url'], |
219 | 219 | $image->large['width'], |
220 | 220 | $image->large['height'], |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @return mixed |
232 | 232 | */ |
233 | - protected function getValue( $key, $value = null ) |
|
233 | + protected function getValue($key, $value = null) |
|
234 | 234 | { |
235 | - if( is_null( $value ) && isset( $this->args[$key] )) { |
|
235 | + if (is_null($value) && isset($this->args[$key])) { |
|
236 | 236 | $value = $this->args[$key]; |
237 | 237 | } |
238 | 238 | return $value; |
@@ -241,23 +241,23 @@ discard block |
||
241 | 241 | /** |
242 | 242 | * @return array |
243 | 243 | */ |
244 | - protected function normalizeArgs( array $args = [] ) |
|
244 | + protected function normalizeArgs(array $args = []) |
|
245 | 245 | { |
246 | 246 | $defaults = [ |
247 | - 'gallery', // (string) meta_key | (int) post_id |
|
248 | - 'lazyload', // (string) meta_key | (bool) |
|
249 | - 'media', // (string) meta_key | (array) post_ids |
|
250 | - 'pagination', // (string) meta_key | (bool) |
|
247 | + 'gallery', // (string) meta_key | (int) post_id |
|
248 | + 'lazyload', // (string) meta_key | (bool) |
|
249 | + 'media', // (string) meta_key | (array) post_ids |
|
250 | + 'pagination', // (string) meta_key | (bool) |
|
251 | 251 | 'images_per_page', // (string) meta_key | (int) number |
252 | - 'permalinks', // (string) meta_key | (bool) |
|
252 | + 'permalinks', // (string) meta_key | (bool) |
|
253 | 253 | ]; |
254 | 254 | |
255 | - $this->args = shortcode_atts( array_combine( $defaults, $defaults ), $args ); |
|
255 | + $this->args = shortcode_atts(array_combine($defaults, $defaults), $args); |
|
256 | 256 | |
257 | - array_walk( $this->args, function( &$value, $key ) { |
|
258 | - $method = $this->utility->buildMethodName( $key . '_arg' ); |
|
259 | - if( method_exists( $this, $method )) { |
|
260 | - $value = call_user_func([ $this, $method ], $value ); |
|
257 | + array_walk($this->args, function(&$value, $key) { |
|
258 | + $method = $this->utility->buildMethodName($key . '_arg'); |
|
259 | + if (method_exists($this, $method)) { |
|
260 | + $value = call_user_func([$this, $method], $value); |
|
261 | 261 | } |
262 | 262 | }); |
263 | 263 | |
@@ -269,20 +269,20 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return null|string |
271 | 271 | */ |
272 | - protected function renderImageTag( $image ) |
|
272 | + protected function renderImageTag($image) |
|
273 | 273 | { |
274 | 274 | $imgSrc = $this->getLazyloadArg() |
275 | - ? $this->theme->imageUri( 'blank.gif' ) |
|
275 | + ? $this->theme->imageUri('blank.gif') |
|
276 | 276 | : $image->thumbnail['url']; |
277 | 277 | |
278 | - $imgTag = sprintf( '<img src="%s" data-src="%s" itemprop="thumbnail" alt="%s"/>', |
|
278 | + $imgTag = sprintf('<img src="%s" data-src="%s" itemprop="thumbnail" alt="%s"/>', |
|
279 | 279 | $imgSrc, |
280 | 280 | $image->thumbnail['url'], |
281 | 281 | $image->alt |
282 | 282 | ); |
283 | 283 | |
284 | 284 | return $this->getPermalinksArg() |
285 | - ? sprintf( '<a href="%s" itemprop="contentUrl">%s</a>', $image->permalink, $imgTag ) |
|
285 | + ? sprintf('<a href="%s" itemprop="contentUrl">%s</a>', $image->permalink, $imgTag) |
|
286 | 286 | : $imgTag; |
287 | 287 | } |
288 | 288 | } |
@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function render() |
54 | 54 | { |
55 | - if( empty( $this->args['media'] ))return; |
|
55 | + if( empty( $this->args['media'] )) { |
|
56 | + return; |
|
57 | + } |
|
56 | 58 | $images = array_reduce( $this->gallery->posts, function( $images, $attachment ) { |
57 | 59 | return $images . $this->renderImage( $attachment ); |
58 | 60 | }); |
@@ -69,7 +71,9 @@ discard block |
||
69 | 71 | { |
70 | 72 | $image = $this->image->get( $attachment->ID )->image; |
71 | 73 | |
72 | - if( !$image )return; |
|
74 | + if( !$image ) { |
|
75 | + return; |
|
76 | + } |
|
73 | 77 | return sprintf( |
74 | 78 | '<figure class="gallery-image" data-w="%s" data-h="%s" data-ps=\'%s\' itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">' . |
75 | 79 | '%s<figcaption itemprop="caption description">' . |
@@ -90,7 +94,9 @@ discard block |
||
90 | 94 | */ |
91 | 95 | public function renderPagination() |
92 | 96 | { |
93 | - if( !$this->args['pagination'] )return; |
|
97 | + if( !$this->args['pagination'] ) { |
|
98 | + return; |
|
99 | + } |
|
94 | 100 | return paginate_links([ |
95 | 101 | 'before_page_number' => '<span class="screen-reader-text">' . __( 'Page', 'castor' ) . ' </span>', |
96 | 102 | 'current' => $this->gallery->query['paged'], |
@@ -6,13 +6,13 @@ |
||
6 | 6 | |
7 | 7 | class ArchiveMeta extends Facade |
8 | 8 | { |
9 | - /** |
|
10 | - * Get the fully qualified class name of the component. |
|
11 | - * |
|
12 | - * @return string |
|
13 | - */ |
|
14 | - protected static function getFacadeAccessor() |
|
15 | - { |
|
16 | - return \GeminiLabs\Castor\Helpers\ArchiveMeta::class; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Get the fully qualified class name of the component. |
|
11 | + * |
|
12 | + * @return string |
|
13 | + */ |
|
14 | + protected static function getFacadeAccessor() |
|
15 | + { |
|
16 | + return \GeminiLabs\Castor\Helpers\ArchiveMeta::class; |
|
17 | + } |
|
18 | 18 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | public function __construct() |
21 | 21 | { |
22 | - $this->options = get_option( apply_filters( 'pollux/archives/id', 'pollux_archives' ), [] ); |
|
22 | + $this->options = get_option(apply_filters('pollux/archives/id', 'pollux_archives'), []); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * @param string $group |
29 | 29 | * @return mixed |
30 | 30 | */ |
31 | - public function get( $key = '', $fallback = null, $group = '' ) |
|
31 | + public function get($key = '', $fallback = null, $group = '') |
|
32 | 32 | { |
33 | - return parent::get( $group, $key, $fallback ); |
|
33 | + return parent::get($group, $key, $fallback); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -17,36 +17,36 @@ discard block |
||
17 | 17 | |
18 | 18 | public function __construct() |
19 | 19 | { |
20 | - $this->options = get_option( apply_filters( 'pollux/settings/id', 'pollux_settings' ), [] ); |
|
20 | + $this->options = get_option(apply_filters('pollux/settings/id', 'pollux_settings'), []); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @param string $group |
25 | 25 | * @return object|array|null |
26 | 26 | */ |
27 | - public function __call( $group, $args ) |
|
27 | + public function __call($group, $args) |
|
28 | 28 | { |
29 | - $args = array_pad( $args, 2, null ); |
|
29 | + $args = array_pad($args, 2, null); |
|
30 | 30 | $group = $this->$group; |
31 | - if( is_object( $group )) { |
|
31 | + if (is_object($group)) { |
|
32 | 32 | return $group; |
33 | 33 | } |
34 | - return $this->get( $group, $args[0], $args[1] ); |
|
34 | + return $this->get($group, $args[0], $args[1]); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @param string $group |
39 | 39 | * @return object|array|null |
40 | 40 | */ |
41 | - public function __get( $group ) |
|
41 | + public function __get($group) |
|
42 | 42 | { |
43 | - if( $group == 'all' ) { |
|
43 | + if ($group == 'all') { |
|
44 | 44 | return (object) $this->options; |
45 | 45 | } |
46 | - if( empty( $group )) { |
|
46 | + if (empty($group)) { |
|
47 | 47 | $group = $this->getDefaultGroup(); |
48 | 48 | } |
49 | - return isset( $this->options[$group] ) |
|
49 | + return isset($this->options[$group]) |
|
50 | 50 | ? $this->options[$group] |
51 | 51 | : null; |
52 | 52 | } |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | * @param mixed $fallback |
58 | 58 | * @return mixed |
59 | 59 | */ |
60 | - public function get( $group = '', $key = '', $fallback = null ) |
|
60 | + public function get($group = '', $key = '', $fallback = null) |
|
61 | 61 | { |
62 | - if( func_num_args() < 1 ) { |
|
62 | + if (func_num_args() < 1) { |
|
63 | 63 | return $this->all; |
64 | 64 | } |
65 | - if( is_string( $group )) { |
|
65 | + if (is_string($group)) { |
|
66 | 66 | $group = $this->$group; |
67 | 67 | } |
68 | - if( !is_array( $group )) { |
|
68 | + if (!is_array($group)) { |
|
69 | 69 | return $fallback; |
70 | 70 | } |
71 | - if( is_null( $key )) { |
|
71 | + if (is_null($key)) { |
|
72 | 72 | return $group; |
73 | 73 | } |
74 | - return $this->getValue( $group, $key, $fallback ); |
|
74 | + return $this->getValue($group, $key, $fallback); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | * @param mixed $fallback |
88 | 88 | * @return mixed |
89 | 89 | */ |
90 | - protected function getValue( array $group, $key, $fallback ) |
|
90 | + protected function getValue(array $group, $key, $fallback) |
|
91 | 91 | { |
92 | - if( !array_key_exists( $key, $group )) { |
|
92 | + if (!array_key_exists($key, $group)) { |
|
93 | 93 | return $fallback; |
94 | 94 | } |
95 | - return empty( $group[$key] ) && !is_null( $fallback ) |
|
95 | + return empty($group[$key]) && !is_null($fallback) |
|
96 | 96 | ? $fallback |
97 | 97 | : $group[$key]; |
98 | 98 | } |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | * @param string $metaKey |
15 | 15 | * @return mixed |
16 | 16 | */ |
17 | - public function get( $metaKey, array $args = [] ) |
|
17 | + public function get($metaKey, array $args = []) |
|
18 | 18 | { |
19 | - if( empty( $metaKey ))return; |
|
19 | + if (empty($metaKey))return; |
|
20 | 20 | |
21 | - $args = $this->normalize( $args ); |
|
22 | - $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
|
23 | - $metaValue = get_post_meta( $args['id'], $metaKey, $args['single'] ); |
|
21 | + $args = $this->normalize($args); |
|
22 | + $metaKey = $this->buildMetaKey($metaKey, $args['prefix']); |
|
23 | + $metaValue = get_post_meta($args['id'], $metaKey, $args['single']); |
|
24 | 24 | |
25 | - if( is_string( $metaValue )) { |
|
26 | - $metaValue = trim( $metaValue ); |
|
25 | + if (is_string($metaValue)) { |
|
26 | + $metaValue = trim($metaValue); |
|
27 | 27 | } |
28 | - return empty( $metaValue ) |
|
28 | + return empty($metaValue) |
|
29 | 29 | ? $args['fallback'] |
30 | 30 | : $metaValue; |
31 | 31 | } |
@@ -35,24 +35,24 @@ discard block |
||
35 | 35 | * @param string $prefix |
36 | 36 | * @return string |
37 | 37 | */ |
38 | - protected function buildMetaKey( $metaKey, $prefix ) |
|
38 | + protected function buildMetaKey($metaKey, $prefix) |
|
39 | 39 | { |
40 | - return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix )) |
|
41 | - ? sprintf( '_%s%s', rtrim( $prefix, '_' ), $metaKey ) |
|
40 | + return (substr($metaKey, 0, 1) == '_' && !empty($prefix)) |
|
41 | + ? sprintf('_%s%s', rtrim($prefix, '_'), $metaKey) |
|
42 | 42 | : $prefix . $metaKey; |
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @return array |
47 | 47 | */ |
48 | - protected function normalize( array $args ) |
|
48 | + protected function normalize(array $args) |
|
49 | 49 | { |
50 | 50 | $defaults = [ |
51 | 51 | 'id' => get_the_ID(), |
52 | 52 | 'fallback' => '', |
53 | 53 | 'single' => true, |
54 | - 'prefix' => apply_filters( 'pollux/prefix', 'pollux_' ), |
|
54 | + 'prefix' => apply_filters('pollux/prefix', 'pollux_'), |
|
55 | 55 | ]; |
56 | - return shortcode_atts( $defaults, array_change_key_case( $args )); |
|
56 | + return shortcode_atts($defaults, array_change_key_case($args)); |
|
57 | 57 | } |
58 | 58 | } |
@@ -16,7 +16,9 @@ |
||
16 | 16 | */ |
17 | 17 | public function get( $metaKey, array $args = [] ) |
18 | 18 | { |
19 | - if( empty( $metaKey ))return; |
|
19 | + if( empty( $metaKey )) { |
|
20 | + return; |
|
21 | + } |
|
20 | 22 | |
21 | 23 | $args = $this->normalize( $args ); |
22 | 24 | $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
@@ -12,31 +12,31 @@ 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 | } |
20 | 20 | |
21 | 21 | public function init() |
22 | 22 | { |
23 | - $controller = $this->make( 'Controller' ); |
|
23 | + $controller = $this->make('Controller'); |
|
24 | 24 | |
25 | 25 | // Action hooks |
26 | - add_action( 'after_setup_theme', [$controller, 'afterSetupTheme'], 20 ); |
|
27 | - add_action( 'login_head', [$controller, 'login'] ); |
|
28 | - add_action( 'wp_enqueue_scripts', [$controller, 'registerAssets'] ); |
|
29 | - add_action( 'customize_register', [$controller, 'registerCustomizer'] ); |
|
30 | - add_action( 'customize_preview_init', [$controller, 'registerCustomizerAssets'] ); |
|
31 | - add_action( 'widgets_init', [$controller, 'registerSidebars'] ); |
|
26 | + add_action('after_setup_theme', [$controller, 'afterSetupTheme'], 20); |
|
27 | + add_action('login_head', [$controller, 'login']); |
|
28 | + add_action('wp_enqueue_scripts', [$controller, 'registerAssets']); |
|
29 | + add_action('customize_register', [$controller, 'registerCustomizer']); |
|
30 | + add_action('customize_preview_init', [$controller, 'registerCustomizerAssets']); |
|
31 | + add_action('widgets_init', [$controller, 'registerSidebars']); |
|
32 | 32 | |
33 | 33 | // Filter hooks |
34 | - add_filter( 'template_include', [$controller, 'filterTemplate'] ); |
|
35 | - add_filter( 'login_headertitle', [$controller, 'filterLoginTitle'] ); |
|
36 | - add_filter( 'login_headerurl', [$controller, 'filterLoginUrl'] ); |
|
34 | + add_filter('template_include', [$controller, 'filterTemplate']); |
|
35 | + add_filter('login_headertitle', [$controller, 'filterLoginTitle']); |
|
36 | + add_filter('login_headerurl', [$controller, 'filterLoginUrl']); |
|
37 | 37 | |
38 | - foreach( $this->getTemplateTypes() as $type ) { |
|
39 | - add_filter( "{$type}_template_hierarchy", [$controller, 'filterTemplateHierarchy'] ); |
|
38 | + foreach ($this->getTemplateTypes() as $type) { |
|
39 | + add_filter("{$type}_template_hierarchy", [$controller, 'filterTemplateHierarchy']); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | 'Utility' => Facades\Utility::class, |
57 | 57 | ]; |
58 | 58 | |
59 | - $aliases = apply_filters( 'castor/register/aliases', $aliases ); |
|
59 | + $aliases = apply_filters('castor/register/aliases', $aliases); |
|
60 | 60 | |
61 | - AliasLoader::getInstance( $aliases )->register(); |
|
61 | + AliasLoader::getInstance($aliases)->register(); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |