@@ -14,38 +14,38 @@ discard block |
||
14 | 14 | */ |
15 | 15 | |
16 | 16 | // Exit if accessed directly. |
17 | -if ( ! defined( 'ABSPATH' ) ) { |
|
17 | +if ( ! defined('ABSPATH')) { |
|
18 | 18 | exit; |
19 | 19 | } |
20 | 20 | |
21 | 21 | // Composer fallback for PHP < 5.3.0. |
22 | -if ( version_compare( PHP_VERSION, '5.3.0' ) === -1 ) { |
|
22 | +if (version_compare(PHP_VERSION, '5.3.0') === -1) { |
|
23 | 23 | include_once 'vendor/autoload_52.php'; |
24 | 24 | } else { |
25 | 25 | include_once 'vendor/autoload.php'; |
26 | 26 | } |
27 | 27 | |
28 | 28 | // Plugin constants. |
29 | -$this_plugin_path = trailingslashit( dirname( __FILE__ ) ); |
|
30 | -$this_plugin_dir = plugin_dir_url( __FILE__ ); |
|
29 | +$this_plugin_path = trailingslashit(dirname(__FILE__)); |
|
30 | +$this_plugin_dir = plugin_dir_url(__FILE__); |
|
31 | 31 | $this_plugin_constants = array( |
32 | 32 | 'SIMPLE_CALENDAR_VERSION' => '3.0.6', |
33 | 33 | 'SIMPLE_CALENDAR_MAIN_FILE' => __FILE__, |
34 | 34 | 'SIMPLE_CALENDAR_URL' => $this_plugin_dir, |
35 | - 'SIMPLE_CALENDAR_ASSETS' => $this_plugin_dir . 'assets/', |
|
35 | + 'SIMPLE_CALENDAR_ASSETS' => $this_plugin_dir.'assets/', |
|
36 | 36 | 'SIMPLE_CALENDAR_PATH' => $this_plugin_path, |
37 | - 'SIMPLE_CALENDAR_INC' => $this_plugin_path . 'includes/', |
|
37 | + 'SIMPLE_CALENDAR_INC' => $this_plugin_path.'includes/', |
|
38 | 38 | ); |
39 | -foreach ( $this_plugin_constants as $constant => $value ) { |
|
40 | - if ( ! defined( $constant ) ) { |
|
41 | - define( $constant, $value ); |
|
39 | +foreach ($this_plugin_constants as $constant => $value) { |
|
40 | + if ( ! defined($constant)) { |
|
41 | + define($constant, $value); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | // Check plugin requirements before loading plugin. |
46 | 46 | $this_plugin_checks = new WP_Requirements( |
47 | 47 | 'Simple Calendar', |
48 | - plugin_basename( __FILE__ ), |
|
48 | + plugin_basename(__FILE__), |
|
49 | 49 | array( |
50 | 50 | 'PHP' => '5.3.0', |
51 | 51 | 'WordPress' => '4.0.0', |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | ) |
56 | 56 | ) |
57 | 57 | ); |
58 | -if ( $this_plugin_checks->pass() === false ) { |
|
58 | +if ($this_plugin_checks->pass() === false) { |
|
59 | 59 | $this_plugin_checks->halt(); |
60 | 60 | return; |
61 | 61 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar\Abstracts; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -84,27 +84,27 @@ discard block |
||
84 | 84 | |
85 | 85 | $settings = array(); |
86 | 86 | |
87 | - $settings[ $this->id ] = array( |
|
87 | + $settings[$this->id] = array( |
|
88 | 88 | 'label' => $this->label, |
89 | 89 | 'description' => $this->description, |
90 | 90 | ); |
91 | 91 | |
92 | - if ( ! empty( $this->sections ) && is_array( $this->sections ) ) { |
|
92 | + if ( ! empty($this->sections) && is_array($this->sections)) { |
|
93 | 93 | |
94 | - foreach ( $this->sections as $section => $content ) { |
|
94 | + foreach ($this->sections as $section => $content) { |
|
95 | 95 | |
96 | - $settings[ $this->id ]['sections'][ $section ] = array( |
|
97 | - 'title' => isset( $content['title'] ) ? $content['title'] : '', |
|
98 | - 'description' => isset( $content['description'] ) ? $content['description'] : '', |
|
99 | - 'callback' => array( $this, 'add_settings_section_callback' ), |
|
100 | - 'fields' => isset( $this->fields[ $section ] ) ? $this->fields[ $section ] : '', |
|
96 | + $settings[$this->id]['sections'][$section] = array( |
|
97 | + 'title' => isset($content['title']) ? $content['title'] : '', |
|
98 | + 'description' => isset($content['description']) ? $content['description'] : '', |
|
99 | + 'callback' => array($this, 'add_settings_section_callback'), |
|
100 | + 'fields' => isset($this->fields[$section]) ? $this->fields[$section] : '', |
|
101 | 101 | ); |
102 | 102 | |
103 | 103 | } |
104 | 104 | |
105 | 105 | } |
106 | 106 | |
107 | - return apply_filters( 'simcal_get_' . $this->option_group . '_' . $this->id , $settings ); |
|
107 | + return apply_filters('simcal_get_'.$this->option_group.'_'.$this->id, $settings); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return string |
120 | 120 | */ |
121 | - protected function get_option_value( $section, $setting ) { |
|
121 | + protected function get_option_value($section, $setting) { |
|
122 | 122 | |
123 | 123 | $option = $this->values; |
124 | 124 | |
125 | - if ( ! empty( $option ) && is_array( $option ) ) { |
|
126 | - return isset( $option[ $section ][ $setting ] ) ? $option[ $section ][ $setting ] : ''; |
|
125 | + if ( ! empty($option) && is_array($option)) { |
|
126 | + return isset($option[$section][$setting]) ? $option[$section][$setting] : ''; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | return ''; |
@@ -156,14 +156,14 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @return string |
158 | 158 | */ |
159 | - public function add_settings_section_callback( $section ) { |
|
159 | + public function add_settings_section_callback($section) { |
|
160 | 160 | |
161 | - $callback = isset( $section['callback'][0] ) ? $section['callback'][0] : ''; |
|
162 | - $sections = isset( $callback->sections ) ? $callback->sections : ''; |
|
163 | - $description = isset( $sections[ $section['id'] ]['description'] ) ? $sections[ $section['id'] ]['description'] : ''; |
|
164 | - $default = $description ? '<p>' . $description . '</p>' : ''; |
|
161 | + $callback = isset($section['callback'][0]) ? $section['callback'][0] : ''; |
|
162 | + $sections = isset($callback->sections) ? $callback->sections : ''; |
|
163 | + $description = isset($sections[$section['id']]['description']) ? $sections[$section['id']]['description'] : ''; |
|
164 | + $default = $description ? '<p>'.$description.'</p>' : ''; |
|
165 | 165 | |
166 | - echo apply_filters( 'simcal_' . $this->option_group . '_' . $this->id . '_sections_callback', $default ); |
|
166 | + echo apply_filters('simcal_'.$this->option_group.'_'.$this->id.'_sections_callback', $default); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return array Sanitized settings. |
179 | 179 | */ |
180 | - public function validate( $settings ) { |
|
180 | + public function validate($settings) { |
|
181 | 181 | |
182 | 182 | $sanitized = ''; |
183 | 183 | |
184 | - if ( is_array( $settings ) ) { |
|
185 | - foreach ( $settings as $k => $v ) { |
|
186 | - $sanitized[ $k ] = simcal_sanitize_input( $v ); |
|
184 | + if (is_array($settings)) { |
|
185 | + foreach ($settings as $k => $v) { |
|
186 | + $sanitized[$k] = simcal_sanitize_input($v); |
|
187 | 187 | } |
188 | 188 | } else { |
189 | - $sanitized = simcal_sanitize_input( $settings ); |
|
189 | + $sanitized = simcal_sanitize_input($settings); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | return $sanitized; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar\Abstracts; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @param mixed $args |
28 | 28 | */ |
29 | - public function __construct( $args = '' ); |
|
29 | + public function __construct($args = ''); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Return the parent calendar type. |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return array |
77 | 77 | */ |
78 | - public function scripts( $min = '' ); |
|
78 | + public function scripts($min = ''); |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Styles. |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return array |
90 | 90 | */ |
91 | - public function styles( $min = '' ); |
|
91 | + public function styles($min = ''); |
|
92 | 92 | |
93 | 93 | /** |
94 | 94 | * Print HTML. |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar\Abstracts; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -148,68 +148,68 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @param array $field Field data. |
150 | 150 | */ |
151 | - public function __construct( $field ) { |
|
151 | + public function __construct($field) { |
|
152 | 152 | |
153 | 153 | // Field properties. |
154 | - if ( isset( $field['title'] ) ) { |
|
155 | - $this->title = esc_attr( $field['title'] ); |
|
154 | + if (isset($field['title'])) { |
|
155 | + $this->title = esc_attr($field['title']); |
|
156 | 156 | } |
157 | - if ( isset( $field['description'] ) ) { |
|
158 | - $this->description = wp_kses_post( $field['description'] ); |
|
157 | + if (isset($field['description'])) { |
|
158 | + $this->description = wp_kses_post($field['description']); |
|
159 | 159 | } |
160 | - if ( isset( $field['type'] ) ) { |
|
161 | - $this->type = esc_attr( $field['type'] ); |
|
160 | + if (isset($field['type'])) { |
|
161 | + $this->type = esc_attr($field['type']); |
|
162 | 162 | } |
163 | - if ( isset( $field['name'] ) ) { |
|
164 | - $this->name = esc_attr( $field['name'] ); |
|
163 | + if (isset($field['name'])) { |
|
164 | + $this->name = esc_attr($field['name']); |
|
165 | 165 | } |
166 | - if ( isset( $field['id'] ) ) { |
|
167 | - $this->id = esc_attr( $field['id'] ); |
|
166 | + if (isset($field['id'])) { |
|
167 | + $this->id = esc_attr($field['id']); |
|
168 | 168 | } |
169 | - if ( isset( $field['placeholder'] ) ) { |
|
170 | - $this->placeholder = esc_attr( $field['placeholder'] ); |
|
169 | + if (isset($field['placeholder'])) { |
|
170 | + $this->placeholder = esc_attr($field['placeholder']); |
|
171 | 171 | } |
172 | - if ( isset( $field['options'] ) && is_array( $field['options'] ) ) { |
|
173 | - $this->options = array_map( 'esc_attr', $field['options'] ); |
|
172 | + if (isset($field['options']) && is_array($field['options'])) { |
|
173 | + $this->options = array_map('esc_attr', $field['options']); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | // Escaping. |
177 | - if ( ! empty( $field['escaping'] ) && ( is_string( $field['escaping'] ) || is_array( $field['escaping'] ) ) ) { |
|
178 | - if ( isset( $field['default'] ) ) { |
|
179 | - $this->default = $this->escape_callback( $field['escaping'], $field['default'] ); |
|
177 | + if ( ! empty($field['escaping']) && (is_string($field['escaping']) || is_array($field['escaping']))) { |
|
178 | + if (isset($field['default'])) { |
|
179 | + $this->default = $this->escape_callback($field['escaping'], $field['default']); |
|
180 | 180 | } |
181 | - if ( isset( $field['value'] ) ) { |
|
182 | - $this->value = $this->escape_callback( $field['escaping'], $field['value'] ); |
|
181 | + if (isset($field['value'])) { |
|
182 | + $this->value = $this->escape_callback($field['escaping'], $field['value']); |
|
183 | 183 | } |
184 | 184 | } else { |
185 | - if ( isset( $field['default'] ) ) { |
|
186 | - $this->default = $this->escape( $field['default'] ); |
|
185 | + if (isset($field['default'])) { |
|
186 | + $this->default = $this->escape($field['default']); |
|
187 | 187 | } |
188 | - if ( isset( $field['value'] ) ) { |
|
189 | - $this->value = $this->escape( $field['value'] ); |
|
188 | + if (isset($field['value'])) { |
|
189 | + $this->value = $this->escape($field['value']); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
193 | 193 | // Validation. |
194 | - if ( ! empty( $field['validation'] ) ) { |
|
195 | - $this->validation = $this->validate( $field['validation'], $this->value ); |
|
194 | + if ( ! empty($field['validation'])) { |
|
195 | + $this->validation = $this->validate($field['validation'], $this->value); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | // CSS classes and styles. |
199 | - $classes = isset( $field['class'] ) ? $field['class'] : ''; |
|
200 | - $this->set_class( $classes ); |
|
201 | - if ( isset( $field['style'] ) ) { |
|
202 | - $this->set_style( $field['style'] ); |
|
199 | + $classes = isset($field['class']) ? $field['class'] : ''; |
|
200 | + $this->set_class($classes); |
|
201 | + if (isset($field['style'])) { |
|
202 | + $this->set_style($field['style']); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // Custom attributes. |
206 | - if ( isset( $field['attributes'] ) ) { |
|
207 | - $this->set_attributes( $field['attributes'] ); |
|
206 | + if (isset($field['attributes'])) { |
|
207 | + $this->set_attributes($field['attributes']); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | // Tooltip markup. |
211 | - if ( isset( $field['tooltip'] ) ) { |
|
212 | - $this->tooltip = ' <i class="simcal-icon-help simcal-help-tip" data-tip="' . esc_attr( $field['tooltip'] ) . '"></i> ' ; |
|
211 | + if (isset($field['tooltip'])) { |
|
212 | + $this->tooltip = ' <i class="simcal-icon-help simcal-help-tip" data-tip="'.esc_attr($field['tooltip']).'"></i> '; |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
@@ -222,13 +222,13 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return void |
224 | 224 | */ |
225 | - public function set_attributes( $attributes ) { |
|
225 | + public function set_attributes($attributes) { |
|
226 | 226 | |
227 | 227 | $attr = ''; |
228 | 228 | |
229 | - if ( ! empty( $attributes ) && is_array( $attributes ) ) { |
|
230 | - foreach ( $attributes as $k => $v ) { |
|
231 | - $attr .= esc_attr( $k ) . '="' . esc_attr( $v ) . '" '; |
|
229 | + if ( ! empty($attributes) && is_array($attributes)) { |
|
230 | + foreach ($attributes as $k => $v) { |
|
231 | + $attr .= esc_attr($k).'="'.esc_attr($v).'" '; |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return void |
246 | 246 | */ |
247 | - public function set_style( $css ) { |
|
247 | + public function set_style($css) { |
|
248 | 248 | |
249 | 249 | $styles = ''; |
250 | 250 | |
251 | - if ( ! empty( $css ) && is_array( $css ) ) { |
|
252 | - foreach ( $css as $k => $v ) { |
|
253 | - $styles .= esc_attr( $k ) . ': ' . esc_attr( $v ) . '; '; |
|
251 | + if ( ! empty($css) && is_array($css)) { |
|
252 | + foreach ($css as $k => $v) { |
|
253 | + $styles .= esc_attr($k).': '.esc_attr($v).'; '; |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
@@ -266,23 +266,23 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return void |
268 | 268 | */ |
269 | - public function set_class( $class ) { |
|
269 | + public function set_class($class) { |
|
270 | 270 | |
271 | 271 | $classes = ''; |
272 | 272 | $type_class = ''; |
273 | 273 | $error = ''; |
274 | 274 | |
275 | - if ( ! empty( $class ) && is_array( $class ) ) { |
|
276 | - $classes = implode( ' ', array_map( 'esc_attr', $class ) ); |
|
275 | + if ( ! empty($class) && is_array($class)) { |
|
276 | + $classes = implode(' ', array_map('esc_attr', $class)); |
|
277 | 277 | } |
278 | - if ( ! empty( $this->type_class ) ) { |
|
279 | - $type_class = esc_attr( $this->type_class ); |
|
278 | + if ( ! empty($this->type_class)) { |
|
279 | + $type_class = esc_attr($this->type_class); |
|
280 | 280 | } |
281 | - if ( true !== $this->validation && ! empty( $this->validation ) ) { |
|
281 | + if (true !== $this->validation && ! empty($this->validation)) { |
|
282 | 282 | $error = 'simcal-field-error '; |
283 | 283 | } |
284 | 284 | |
285 | - $this->class = trim( $error . 'simcal-field ' . $type_class . ' ' . $classes ); |
|
285 | + $this->class = trim($error.'simcal-field '.$type_class.' '.$classes); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return array|string |
299 | 299 | */ |
300 | - protected function escape( $value ) { |
|
301 | - return ! empty( $value ) ? ( is_array( $value ) ? array_map( 'esc_attr', $value ) : esc_attr( $value ) ) : ''; |
|
300 | + protected function escape($value) { |
|
301 | + return ! empty($value) ? (is_array($value) ? array_map('esc_attr', $value) : esc_attr($value)) : ''; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -314,11 +314,11 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @return mixed |
316 | 316 | */ |
317 | - protected function escape_callback( $callback, $value ) { |
|
318 | - if ( $callback && ( is_string( $callback ) || is_array( $callback ) ) ) { |
|
319 | - return call_user_func( $callback, $value ); |
|
317 | + protected function escape_callback($callback, $value) { |
|
318 | + if ($callback && (is_string($callback) || is_array($callback))) { |
|
319 | + return call_user_func($callback, $value); |
|
320 | 320 | } |
321 | - return esc_attr( $value ); |
|
321 | + return esc_attr($value); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @return true|string Expected to return bool (true) if passes, message string if not. |
336 | 336 | */ |
337 | - protected function validate( $callback, $value ) { |
|
338 | - if ( $callback && ( is_string( $callback ) || is_array( $callback ) ) ) { |
|
339 | - $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : ''; |
|
340 | - return call_user_func( $callback, $value, $screen ); |
|
337 | + protected function validate($callback, $value) { |
|
338 | + if ($callback && (is_string($callback) || is_array($callback))) { |
|
339 | + $screen = function_exists('get_current_screen') ? get_current_screen() : ''; |
|
340 | + return call_user_func($callback, $value, $screen); |
|
341 | 341 | } |
342 | 342 | return true; |
343 | 343 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar\Abstracts; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return void |
30 | 30 | */ |
31 | - public static function html( $post ); |
|
31 | + public static function html($post); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Validate and save the meta box fields. |
@@ -40,6 +40,6 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return void |
42 | 42 | */ |
43 | - public static function save( $post_id, $post ); |
|
43 | + public static function save($post_id, $post); |
|
44 | 44 | |
45 | 45 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar\Abstracts; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return void |
38 | 38 | */ |
39 | - public function widget( $args, $instance ); |
|
39 | + public function widget($args, $instance); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Update a particular instance of the widget. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return array Settings to save or bool false to cancel saving. |
54 | 54 | */ |
55 | - public function update( $new_instance, $old_instance ); |
|
55 | + public function update($new_instance, $old_instance); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Print the settings update form. |
@@ -63,6 +63,6 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return string |
65 | 65 | */ |
66 | - public function form( $instance ); |
|
66 | + public function form($instance); |
|
67 | 67 | |
68 | 68 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar\Admin; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct() { |
36 | 36 | |
37 | - $this->min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG == true ) ? '' : '.min'; |
|
37 | + $this->min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG == true) ? '' : '.min'; |
|
38 | 38 | |
39 | - add_action( 'admin_enqueue_scripts', array( $this, 'load' ) ); |
|
39 | + add_action('admin_enqueue_scripts', array($this, 'load')); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function load() { |
48 | 48 | |
49 | - $css_path = SIMPLE_CALENDAR_ASSETS . 'css/'; |
|
50 | - $css_path_vendor = $css_path . 'vendor/'; |
|
51 | - $js_path = SIMPLE_CALENDAR_ASSETS . 'js/'; |
|
52 | - $js_path_vendor = $js_path . 'vendor/'; |
|
49 | + $css_path = SIMPLE_CALENDAR_ASSETS.'css/'; |
|
50 | + $css_path_vendor = $css_path.'vendor/'; |
|
51 | + $js_path = SIMPLE_CALENDAR_ASSETS.'js/'; |
|
52 | + $js_path_vendor = $js_path.'vendor/'; |
|
53 | 53 | |
54 | 54 | /* ====================== * |
55 | 55 | * Register Admin Scripts * |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | |
58 | 58 | wp_register_script( |
59 | 59 | 'simcal-tiptip', |
60 | - $js_path_vendor . 'tiptip' . $this->min . '.js', |
|
61 | - array( 'jquery' ), |
|
60 | + $js_path_vendor.'tiptip'.$this->min.'.js', |
|
61 | + array('jquery'), |
|
62 | 62 | '1.3', |
63 | 63 | true |
64 | 64 | ); |
65 | 65 | wp_register_script( |
66 | 66 | 'simcal-select2', |
67 | - $js_path_vendor . 'select2' . $this->min . '.js', |
|
67 | + $js_path_vendor.'select2'.$this->min.'.js', |
|
68 | 68 | array(), |
69 | 69 | '4.0', |
70 | 70 | true |
71 | 71 | ); |
72 | 72 | wp_register_script( |
73 | 73 | 'simcal-admin', |
74 | - $js_path . 'admin' . $this->min . '.js', |
|
74 | + $js_path.'admin'.$this->min.'.js', |
|
75 | 75 | array( |
76 | 76 | 'jquery', |
77 | 77 | 'jquery-ui-sortable', |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | ); |
86 | 86 | wp_register_script( |
87 | 87 | 'simcal-admin-add-calendar', |
88 | - $js_path . 'admin-add-calendar' . $this->min . '.js', |
|
89 | - array( 'simcal-select2' ), |
|
88 | + $js_path.'admin-add-calendar'.$this->min.'.js', |
|
89 | + array('simcal-select2'), |
|
90 | 90 | SIMPLE_CALENDAR_VERSION, |
91 | 91 | true |
92 | 92 | ); |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | |
98 | 98 | wp_register_style( |
99 | 99 | 'simcal-select2', |
100 | - $css_path_vendor . 'select2' . $this->min . '.css', |
|
100 | + $css_path_vendor.'select2'.$this->min.'.css', |
|
101 | 101 | array(), |
102 | 102 | '4.0.0' |
103 | 103 | ); |
104 | 104 | wp_register_style( |
105 | 105 | 'simcal-admin', |
106 | - $css_path . 'admin' . $this->min . '.css', |
|
106 | + $css_path.'admin'.$this->min.'.css', |
|
107 | 107 | array( |
108 | 108 | 'wp-color-picker', |
109 | 109 | 'simcal-select2', |
@@ -112,21 +112,21 @@ discard block |
||
112 | 112 | ); |
113 | 113 | wp_register_style( |
114 | 114 | 'simcal-admin-add-calendar', |
115 | - $css_path . 'admin-add-calendar' . $this->min . '.css', |
|
116 | - array( 'simcal-select2' ), |
|
115 | + $css_path.'admin-add-calendar'.$this->min.'.css', |
|
116 | + array('simcal-select2'), |
|
117 | 117 | SIMPLE_CALENDAR_VERSION |
118 | 118 | ); |
119 | 119 | |
120 | - if ( simcal_is_admin_screen() !== false ) { |
|
120 | + if (simcal_is_admin_screen() !== false) { |
|
121 | 121 | |
122 | - wp_enqueue_script( 'simcal-admin' ); |
|
122 | + wp_enqueue_script('simcal-admin'); |
|
123 | 123 | wp_localize_script( |
124 | 124 | 'simcal-admin', |
125 | 125 | 'simcal_admin', |
126 | 126 | simcal_common_scripts_variables() |
127 | 127 | ); |
128 | 128 | |
129 | - wp_enqueue_style( 'simcal-admin' ); |
|
129 | + wp_enqueue_style('simcal-admin'); |
|
130 | 130 | |
131 | 131 | } else { |
132 | 132 | |
@@ -134,25 +134,25 @@ discard block |
||
134 | 134 | $screen = get_current_screen(); |
135 | 135 | |
136 | 136 | $post_types = array(); |
137 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
138 | - if ( isset( $settings['general']['attach_calendars_posts'] ) ) { |
|
137 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
138 | + if (isset($settings['general']['attach_calendars_posts'])) { |
|
139 | 139 | $post_types = $settings['general']['attach_calendars_posts']; |
140 | 140 | } |
141 | 141 | |
142 | 142 | $conditions = array( |
143 | - in_array( $post_type, (array) $post_types ), |
|
143 | + in_array($post_type, (array) $post_types), |
|
144 | 144 | $screen->id == 'widgets', |
145 | 145 | ); |
146 | 146 | |
147 | - if ( in_array( true, $conditions ) ) { |
|
147 | + if (in_array(true, $conditions)) { |
|
148 | 148 | |
149 | - wp_enqueue_script( 'simcal-admin-add-calendar' ); |
|
150 | - wp_localize_script( 'simcal-admin-add-calendar', 'simcal_admin', array( |
|
149 | + wp_enqueue_script('simcal-admin-add-calendar'); |
|
150 | + wp_localize_script('simcal-admin-add-calendar', 'simcal_admin', array( |
|
151 | 151 | 'locale' => get_locale(), |
152 | 152 | 'text_dir' => is_rtl() ? 'rtl' : 'ltr', |
153 | - ) ); |
|
153 | + )); |
|
154 | 154 | |
155 | - wp_enqueue_style( 'simcal-admin-add-calendar' ); |
|
155 | + wp_enqueue_style('simcal-admin-add-calendar'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | */ |
10 | 10 | namespace SimpleCalendar\Admin; |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @param string $post_type |
43 | 43 | */ |
44 | - public function __construct( $post_type ) { |
|
45 | - $this->bulk_action_post_type = post_type_exists( $post_type ) ? $post_type : ''; |
|
44 | + public function __construct($post_type) { |
|
45 | + $this->bulk_action_post_type = post_type_exists($post_type) ? $post_type : ''; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -53,16 +53,16 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @param array $args |
55 | 55 | */ |
56 | - public function register_bulk_action( $args ) { |
|
56 | + public function register_bulk_action($args) { |
|
57 | 57 | |
58 | 58 | $func = array(); |
59 | - $func['action_name'] = isset( $args['action_name'] ) ? sanitize_key( $args['action_name'] ) : ''; |
|
60 | - $func['callback'] = isset( $args['callback'] ) ? $args['callback'] : ''; |
|
61 | - $func['menu_text'] = isset( $args['menu_text'] ) ? esc_attr( $args['menu_text'] ) : ''; |
|
62 | - $func['admin_notice'] = isset( $args['admin_notice'] ) ? esc_attr( $args['admin_notice'] ) : ''; |
|
59 | + $func['action_name'] = isset($args['action_name']) ? sanitize_key($args['action_name']) : ''; |
|
60 | + $func['callback'] = isset($args['callback']) ? $args['callback'] : ''; |
|
61 | + $func['menu_text'] = isset($args['menu_text']) ? esc_attr($args['menu_text']) : ''; |
|
62 | + $func['admin_notice'] = isset($args['admin_notice']) ? esc_attr($args['admin_notice']) : ''; |
|
63 | 63 | |
64 | - if ( $func['action_name'] && $func['callback'] ) { |
|
65 | - $this->actions[ $func['action_name'] ] = $func; |
|
64 | + if ($func['action_name'] && $func['callback']) { |
|
65 | + $this->actions[$func['action_name']] = $func; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | * @since 3.0.0 |
75 | 75 | */ |
76 | 76 | public function init() { |
77 | - if ( is_admin() ) { |
|
78 | - add_action( 'admin_footer-edit.php', array( $this, 'custom_bulk_admin_footer' ) ); |
|
79 | - add_action( 'load-edit.php', array( $this, 'custom_bulk_action' ) ); |
|
80 | - add_action( 'admin_notices', array( $this, 'custom_bulk_admin_notices' ) ); |
|
77 | + if (is_admin()) { |
|
78 | + add_action('admin_footer-edit.php', array($this, 'custom_bulk_admin_footer')); |
|
79 | + add_action('load-edit.php', array($this, 'custom_bulk_action')); |
|
80 | + add_action('admin_notices', array($this, 'custom_bulk_admin_notices')); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | global $post_type; |
92 | 92 | |
93 | 93 | // Only permit actions with defined post type. |
94 | - if ( $post_type == $this->bulk_action_post_type ) { |
|
94 | + if ($post_type == $this->bulk_action_post_type) { |
|
95 | 95 | |
96 | 96 | ?> |
97 | 97 | <script type="text/javascript"> |
98 | 98 | jQuery( document ).ready( function() { |
99 | - <?php foreach ( $this->actions as $action_name => $action ) : ?> |
|
99 | + <?php foreach ($this->actions as $action_name => $action) : ?> |
|
100 | 100 | jQuery( '<option>' ).val( '<?php echo $action_name ?>' ).text( '<?php echo $action['menu_text'] ?>').appendTo( 'select[name="action"]' ); |
101 | 101 | jQuery( '<option>' ).val( '<?php echo $action_name ?>' ).text( '<?php echo $action['menu_text'] ?>').appendTo( 'select[name="action2"]' ); |
102 | 102 | <?php endforeach; ?> |
@@ -120,65 +120,65 @@ discard block |
||
120 | 120 | global $typenow; |
121 | 121 | $post_type = $typenow; |
122 | 122 | |
123 | - if ( $post_type == $this->bulk_action_post_type ) { |
|
123 | + if ($post_type == $this->bulk_action_post_type) { |
|
124 | 124 | |
125 | 125 | // Get the action. |
126 | 126 | // Depending on your resource type this could be WP_Users_List_Table, WP_Comments_List_Table, etc. |
127 | - $wp_list_table = _get_list_table( 'WP_Posts_List_Table' ); |
|
127 | + $wp_list_table = _get_list_table('WP_Posts_List_Table'); |
|
128 | 128 | $action = $wp_list_table->current_action(); |
129 | 129 | |
130 | 130 | // Allow only defined actions. |
131 | - $allowed_actions = array_keys( $this->actions ); |
|
132 | - if ( ! in_array( $action, $allowed_actions ) ) { |
|
131 | + $allowed_actions = array_keys($this->actions); |
|
132 | + if ( ! in_array($action, $allowed_actions)) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Security check. |
137 | - check_admin_referer( 'bulk-posts' ); |
|
137 | + check_admin_referer('bulk-posts'); |
|
138 | 138 | |
139 | 139 | // Make sure ids are submitted. |
140 | 140 | // Depending on the resource type, this may be 'media' or 'ids'. |
141 | - if ( isset( $_REQUEST['post'] ) ) { |
|
142 | - $post_ids = array_map( 'intval', $_REQUEST['post'] ); |
|
141 | + if (isset($_REQUEST['post'])) { |
|
142 | + $post_ids = array_map('intval', $_REQUEST['post']); |
|
143 | 143 | } |
144 | 144 | |
145 | - if ( empty( $post_ids ) ) { |
|
145 | + if (empty($post_ids)) { |
|
146 | 146 | return; |
147 | 147 | } |
148 | 148 | |
149 | 149 | // This is based on wp-admin/edit.php. |
150 | 150 | $sendback = remove_query_arg( |
151 | - array( 'exported', 'untrashed', 'deleted', 'ids' ), |
|
151 | + array('exported', 'untrashed', 'deleted', 'ids'), |
|
152 | 152 | wp_get_referer() |
153 | 153 | ); |
154 | - if ( ! $sendback ) { |
|
155 | - $sendback = admin_url( "edit.php?post_type=$post_type" ); |
|
154 | + if ( ! $sendback) { |
|
155 | + $sendback = admin_url("edit.php?post_type=$post_type"); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | $pagenum = $wp_list_table->get_pagenum(); |
159 | - $sendback = add_query_arg( 'paged', $pagenum, $sendback ); |
|
159 | + $sendback = add_query_arg('paged', $pagenum, $sendback); |
|
160 | 160 | |
161 | 161 | // Check that we have anonymous function as a callback. |
162 | - $anon_fns = array_filter( $this->actions[ $action ], function( $el ) { |
|
162 | + $anon_fns = array_filter($this->actions[$action], function($el) { |
|
163 | 163 | return $el instanceof \Closure; |
164 | 164 | } ); |
165 | 165 | |
166 | - if ( count( $anon_fns ) > 0 ) { |
|
167 | - $this->actions[ $action ]['callback']( $post_ids ); |
|
166 | + if (count($anon_fns) > 0) { |
|
167 | + $this->actions[$action]['callback']($post_ids); |
|
168 | 168 | } else { |
169 | - call_user_func( $this->actions[ $action ]['callback'], $post_ids ); |
|
169 | + call_user_func($this->actions[$action]['callback'], $post_ids); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | $sendback = add_query_arg( |
173 | - array( 'success_action' => $action, 'ids' => join( ',', $post_ids ) ), |
|
173 | + array('success_action' => $action, 'ids' => join(',', $post_ids)), |
|
174 | 174 | $sendback |
175 | 175 | ); |
176 | 176 | $sendback = remove_query_arg( |
177 | - array( 'action', 'paged', 'mode', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view' ), |
|
177 | + array('action', 'paged', 'mode', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), |
|
178 | 178 | $sendback |
179 | 179 | ); |
180 | 180 | |
181 | - wp_redirect( $sendback ); |
|
181 | + wp_redirect($sendback); |
|
182 | 182 | |
183 | 183 | exit; |
184 | 184 | } |
@@ -193,31 +193,31 @@ discard block |
||
193 | 193 | |
194 | 194 | global $post_type, $pagenow; |
195 | 195 | |
196 | - if ( isset( $_REQUEST['ids'] ) ) { |
|
197 | - $post_ids = explode( ',', $_REQUEST['ids'] ); |
|
196 | + if (isset($_REQUEST['ids'])) { |
|
197 | + $post_ids = explode(',', $_REQUEST['ids']); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | // Make sure ids are submitted. |
201 | 201 | // Depending on the resource type, this may be 'media' or 'ids'. |
202 | - if ( empty( $post_ids ) ) { |
|
202 | + if (empty($post_ids)) { |
|
203 | 203 | return; |
204 | 204 | } |
205 | 205 | |
206 | - $post_ids_count = is_array( $post_ids ) ? count( $post_ids ) : 1; |
|
206 | + $post_ids_count = is_array($post_ids) ? count($post_ids) : 1; |
|
207 | 207 | |
208 | - if ( $pagenow == 'edit.php' && $post_type == $this->bulk_action_post_type ) { |
|
208 | + if ($pagenow == 'edit.php' && $post_type == $this->bulk_action_post_type) { |
|
209 | 209 | |
210 | - if ( isset( $_REQUEST['success_action'] ) ) { |
|
210 | + if (isset($_REQUEST['success_action'])) { |
|
211 | 211 | |
212 | 212 | // Print notice in admin bar. |
213 | - $message = $this->actions[ $_REQUEST['success_action'] ]['admin_notice']; |
|
213 | + $message = $this->actions[$_REQUEST['success_action']]['admin_notice']; |
|
214 | 214 | |
215 | - if ( is_array( $message ) ) { |
|
216 | - $message = sprintf( _n( $message['single'], $message['plural'], $post_ids_count, 'google-calendar-events' ), $post_ids_count ); |
|
215 | + if (is_array($message)) { |
|
216 | + $message = sprintf(_n($message['single'], $message['plural'], $post_ids_count, 'google-calendar-events'), $post_ids_count); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | $class = 'updated notice is-dismissible above-h2'; |
220 | - if ( ! empty( $message ) ) { |
|
220 | + if ( ! empty($message)) { |
|
221 | 221 | echo "<div class=\"{$class}\"><p>{$message}</p></div>"; |
222 | 222 | } |
223 | 223 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Field; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -45,20 +45,20 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @param array $field |
47 | 47 | */ |
48 | - public function __construct( $field ) { |
|
48 | + public function __construct($field) { |
|
49 | 49 | |
50 | - $this->range = isset( $field['range'] ) ? ( $field['range'] === true ? true : false ) : false; |
|
51 | - $this->inline = isset( $field['inline'] ) ? ( $field['inline'] === true ? true : false ) : true; |
|
50 | + $this->range = isset($field['range']) ? ($field['range'] === true ? true : false) : false; |
|
51 | + $this->inline = isset($field['inline']) ? ($field['inline'] === true ? true : false) : true; |
|
52 | 52 | |
53 | 53 | $subtype = $this->range === true ? 'simcal-field-date-picker-range ' : ''; |
54 | - $this->type_class = 'simcal-field-date-picker ' . $subtype; |
|
54 | + $this->type_class = 'simcal-field-date-picker '.$subtype; |
|
55 | 55 | |
56 | 56 | $data = array( |
57 | 57 | 'data-inline' => $this->inline === true ? 'true' : 'false', |
58 | 58 | ); |
59 | - $field['attributes'] = isset( $field['attributes'] ) ? array_merge( $field['attributes'], $data ) : $data; |
|
59 | + $field['attributes'] = isset($field['attributes']) ? array_merge($field['attributes'], $data) : $data; |
|
60 | 60 | |
61 | - parent::__construct( $field ); |
|
61 | + parent::__construct($field); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -68,18 +68,18 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function html() { |
70 | 70 | |
71 | - if ( ! empty( $this->description ) ) { |
|
72 | - echo '<p class="description">' . wp_kses_post( $this->description ) . '</p>'; |
|
71 | + if ( ! empty($this->description)) { |
|
72 | + echo '<p class="description">'.wp_kses_post($this->description).'</p>'; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | ?> |
76 | 76 | <div id="<?php echo $this->id; ?>" |
77 | 77 | class="<?php echo $this->class; ?>" |
78 | - <?php echo $this->style ? 'style="' . $this->style . '"' : ''; ?> |
|
78 | + <?php echo $this->style ? 'style="'.$this->style.'"' : ''; ?> |
|
79 | 79 | <?php echo $this->attributes ?>> |
80 | 80 | <?php |
81 | 81 | |
82 | - if ( false === $this->range ) { |
|
82 | + if (false === $this->range) { |
|
83 | 83 | |
84 | 84 | ?> |
85 | 85 | <i class="simcal-icon-calendar"></i> |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | readonly="readonly" /> |
91 | 91 | <?php |
92 | 92 | |
93 | - if ( true === $this->inline ) { |
|
93 | + if (true === $this->inline) { |
|
94 | 94 | echo $this->tooltip; |
95 | 95 | } |
96 | 96 |