@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | * |
11 | 11 | * @param array $script |
12 | 12 | */ |
13 | - public function register_script( $script ); |
|
13 | + public function register_script($script); |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Provides a method to register new styles outside of the constructor. |
17 | 17 | * |
18 | 18 | * @param array $style |
19 | 19 | */ |
20 | - public function register_style( $style ); |
|
20 | + public function register_style($style); |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Enqueues the web & shared scripts on the Register. |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param string $hook Passes a string representing the current page. |
36 | 36 | */ |
37 | - public function enqueue_admin_scripts( $hook ); |
|
37 | + public function enqueue_admin_scripts($hook); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Enqueues the admin & shared styles on the Register. |
41 | 41 | * |
42 | 42 | * @param string $hook Passes a string representing the current page. |
43 | 43 | */ |
44 | - public function enqueue_admin_styles( $hook ); |
|
44 | + public function enqueue_admin_styles($hook); |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Enqueues the block styles & registers the block. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param string $url |
53 | 53 | * @param string $version |
54 | 54 | */ |
55 | - public function __construct( $url, $version = null ) { |
|
55 | + public function __construct($url, $version = null) { |
|
56 | 56 | $this->url = $url; |
57 | 57 | $this->version = $version ?: null; // Empty string should remain null. |
58 | 58 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param array $script |
64 | 64 | */ |
65 | - public function register_script( $script ) { |
|
65 | + public function register_script($script) { |
|
66 | 66 | $this->scripts[] = $script; |
67 | 67 | } |
68 | 68 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param array $style |
73 | 73 | */ |
74 | - public function register_style( $style ) { |
|
74 | + public function register_style($style) { |
|
75 | 75 | $this->styles[] = $style; |
76 | 76 | } |
77 | 77 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * {@inheritDoc} |
80 | 80 | */ |
81 | 81 | public function enqueue_web_scripts() { |
82 | - foreach ( $this->scripts as $script ) { |
|
83 | - if ( in_array( $script['type'], array( 'web', 'shared' ) ) ) { |
|
84 | - $this->enqueue_script( $script ); |
|
82 | + foreach ($this->scripts as $script) { |
|
83 | + if (in_array($script['type'], array('web', 'shared'))) { |
|
84 | + $this->enqueue_script($script); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | * {@inheritDoc} |
91 | 91 | */ |
92 | 92 | public function enqueue_web_styles() { |
93 | - foreach ( $this->styles as $style ) { |
|
94 | - if ( in_array( $style['type'], array( 'web', 'shared' ) ) ) { |
|
95 | - $this->enqueue_style( $style ); |
|
93 | + foreach ($this->styles as $style) { |
|
94 | + if (in_array($style['type'], array('web', 'shared'))) { |
|
95 | + $this->enqueue_style($style); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @param string $hook Passes a string representing the current page. |
104 | 104 | */ |
105 | - public function enqueue_admin_scripts( $hook ) { |
|
106 | - foreach ( $this->scripts as $script ) { |
|
107 | - if ( in_array( $script['type'], array( 'admin', 'shared' ) ) ) { |
|
108 | - $this->enqueue_script( $script, $hook ); |
|
105 | + public function enqueue_admin_scripts($hook) { |
|
106 | + foreach ($this->scripts as $script) { |
|
107 | + if (in_array($script['type'], array('admin', 'shared'))) { |
|
108 | + $this->enqueue_script($script, $hook); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @param string $hook Passes a string representing the current page. |
117 | 117 | */ |
118 | - public function enqueue_admin_styles( $hook ) { |
|
119 | - foreach ( $this->styles as $style ) { |
|
120 | - if ( in_array( $style['type'], array( 'admin', 'shared' ) ) ) { |
|
121 | - $this->enqueue_style( $style, $hook ); |
|
118 | + public function enqueue_admin_styles($hook) { |
|
119 | + foreach ($this->styles as $style) { |
|
120 | + if (in_array($style['type'], array('admin', 'shared'))) { |
|
121 | + $this->enqueue_style($style, $hook); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | } |
@@ -129,46 +129,46 @@ discard block |
||
129 | 129 | public function register_blocks() { |
130 | 130 | $blocks = array(); |
131 | 131 | |
132 | - foreach ( $this->styles as $style ) { |
|
133 | - if ( in_array( $style['type'], array( 'block' ) ) ) { |
|
132 | + foreach ($this->styles as $style) { |
|
133 | + if (in_array($style['type'], array('block'))) { |
|
134 | 134 | wp_register_style( |
135 | 135 | $style['handle'], |
136 | - $this->url . $style['src'], |
|
137 | - isset( $style['deps'] ) ? $style['deps'] : array(), |
|
136 | + $this->url.$style['src'], |
|
137 | + isset($style['deps']) ? $style['deps'] : array(), |
|
138 | 138 | $this->version, |
139 | - isset( $style['media'] ) ? $style['media'] : 'all' |
|
139 | + isset($style['media']) ? $style['media'] : 'all' |
|
140 | 140 | ); |
141 | 141 | |
142 | - if ( ! isset( $blocks[ $style['block'] ] ) ) { |
|
143 | - $blocks[ $style['block'] ] = array(); |
|
142 | + if (!isset($blocks[$style['block']])) { |
|
143 | + $blocks[$style['block']] = array(); |
|
144 | 144 | } |
145 | 145 | |
146 | - $blocks[ $style['block'] ]['editor_style'] = $style['handle']; |
|
146 | + $blocks[$style['block']]['editor_style'] = $style['handle']; |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | - foreach ( $this->scripts as $script ) { |
|
151 | - if ( in_array( $script['type'], array( 'block' ) ) ) { |
|
150 | + foreach ($this->scripts as $script) { |
|
151 | + if (in_array($script['type'], array('block'))) { |
|
152 | 152 | wp_register_script( |
153 | 153 | $script['handle'], |
154 | - $this->url . $script['src'], |
|
155 | - isset( $script['deps'] ) ? $script['deps'] : array(), |
|
154 | + $this->url.$script['src'], |
|
155 | + isset($script['deps']) ? $script['deps'] : array(), |
|
156 | 156 | $this->version, |
157 | - isset( $script['footer'] ) ? $script['footer'] : false |
|
157 | + isset($script['footer']) ? $script['footer'] : false |
|
158 | 158 | ); |
159 | 159 | |
160 | - $this->localize_script( $script ); |
|
160 | + $this->localize_script($script); |
|
161 | 161 | |
162 | - if ( ! isset( $blocks[ $script['block'] ] ) ) { |
|
163 | - $blocks[ $script['block'] ] = array(); |
|
162 | + if (!isset($blocks[$script['block']])) { |
|
163 | + $blocks[$script['block']] = array(); |
|
164 | 164 | } |
165 | 165 | |
166 | - $blocks[ $script['block'] ]['editor_script'] = $script['handle']; |
|
166 | + $blocks[$script['block']]['editor_script'] = $script['handle']; |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - foreach ( $blocks as $slug => $opts ) { |
|
171 | - register_block_type( $slug, $opts ); |
|
170 | + foreach ($blocks as $slug => $opts) { |
|
171 | + register_block_type($slug, $opts); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -208,17 +208,17 @@ discard block |
||
208 | 208 | * @param array $script The script attachment callback. |
209 | 209 | * @param string $hook The location hook. Only passed on admin side. |
210 | 210 | */ |
211 | - protected function enqueue_script( $script, $hook = null ) { |
|
212 | - if ( $script['condition']( $hook ) ) { |
|
211 | + protected function enqueue_script($script, $hook = null) { |
|
212 | + if ($script['condition']($hook)) { |
|
213 | 213 | wp_enqueue_script( |
214 | 214 | $script['handle'], |
215 | - $this->url . $script['src'], |
|
216 | - isset( $script['deps'] ) ? $script['deps'] : array(), |
|
215 | + $this->url.$script['src'], |
|
216 | + isset($script['deps']) ? $script['deps'] : array(), |
|
217 | 217 | $this->version, |
218 | - isset( $script['footer'] ) ? $script['footer'] : false |
|
218 | + isset($script['footer']) ? $script['footer'] : false |
|
219 | 219 | ); |
220 | 220 | |
221 | - $this->localize_script( $script ); |
|
221 | + $this->localize_script($script); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | * @param array $style The style attachment callback. |
229 | 229 | * @param string $hook The location hook. |
230 | 230 | */ |
231 | - protected function enqueue_style( $style, $hook = null ) { |
|
232 | - if ( $style['condition']( $hook ) ) { |
|
231 | + protected function enqueue_style($style, $hook = null) { |
|
232 | + if ($style['condition']($hook)) { |
|
233 | 233 | wp_enqueue_style( |
234 | 234 | $style['handle'], |
235 | - $this->url . $style['src'], |
|
236 | - isset( $style['deps'] ) ? $style['deps'] : array(), |
|
235 | + $this->url.$style['src'], |
|
236 | + isset($style['deps']) ? $style['deps'] : array(), |
|
237 | 237 | $this->version, |
238 | - isset( $style['media'] ) ? $style['media'] : 'all' |
|
238 | + isset($style['media']) ? $style['media'] : 'all' |
|
239 | 239 | ); |
240 | 240 | } |
241 | 241 | } |
@@ -245,13 +245,13 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @param array $script Script defintion. |
247 | 247 | */ |
248 | - protected function localize_script( $script ) { |
|
249 | - if ( ! isset( $script['localize'] ) ) { |
|
248 | + protected function localize_script($script) { |
|
249 | + if (!isset($script['localize'])) { |
|
250 | 250 | return; |
251 | 251 | } |
252 | 252 | |
253 | - if ( is_callable( $script['localize'] ) ) { // @todo make all properties callables |
|
254 | - $script['localize'] = call_user_func( $script['localize'] ); |
|
253 | + if (is_callable($script['localize'])) { // @todo make all properties callables |
|
254 | + $script['localize'] = call_user_func($script['localize']); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | wp_localize_script( |