@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Admin_Page; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | |
31 | 31 | $this->id = $tab = 'system-status'; |
32 | 32 | $this->option_group = $page = 'tools'; |
33 | - $this->label = __( 'System Report', 'google-calendar-events' ); |
|
33 | + $this->label = __('System Report', 'google-calendar-events'); |
|
34 | 34 | $this->description = ''; |
35 | 35 | $this->sections = $this->add_sections(); |
36 | 36 | $this->fields = $this->add_fields(); |
37 | 37 | |
38 | 38 | // Disable the submit button for this page. |
39 | - add_filter( 'simcal_admin_page_' . $page . '_' . $tab . '_submit', function() { return false; } ); |
|
39 | + add_filter('simcal_admin_page_'.$page.'_'.$tab.'_submit', function() { return false; } ); |
|
40 | 40 | |
41 | 41 | // Add html. |
42 | - add_action( 'simcal_admin_page_' . $page . '_' . $tab . '_end', array( $this, 'html' ) ); |
|
42 | + add_action('simcal_admin_page_'.$page.'_'.$tab.'_end', array($this, 'html')); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -51,37 +51,37 @@ discard block |
||
51 | 51 | |
52 | 52 | ?> |
53 | 53 | <div id="simcal-system-status-report"> |
54 | - <p><?php _e( 'Please copy and paste this information when contacting support:', 'google-calendar-events' ); ?> </p> |
|
54 | + <p><?php _e('Please copy and paste this information when contacting support:', 'google-calendar-events'); ?> </p> |
|
55 | 55 | <textarea readonly="readonly" onclick="this.select();"></textarea> |
56 | - <p><?php _e( 'You can also download your information as a text file to attach, or simply view it below.', 'google-calendar-events' ); ?></p> |
|
57 | - <p><a href="#" id="simcal-system-status-report-download" class="button button-primary"><?php _e( 'Download System Report', 'google-calendar-events' ); ?></a></p> |
|
56 | + <p><?php _e('You can also download your information as a text file to attach, or simply view it below.', 'google-calendar-events'); ?></p> |
|
57 | + <p><a href="#" id="simcal-system-status-report-download" class="button button-primary"><?php _e('Download System Report', 'google-calendar-events'); ?></a></p> |
|
58 | 58 | </div> |
59 | 59 | <hr> |
60 | 60 | <?php |
61 | 61 | |
62 | 62 | global $wpdb; |
63 | - $wp_version = get_bloginfo( 'version' ); |
|
63 | + $wp_version = get_bloginfo('version'); |
|
64 | 64 | |
65 | 65 | $sections = array(); |
66 | 66 | $panels = array( |
67 | 67 | 'wordpress' => array( |
68 | - 'label' => __( 'WordPress Installation', 'google-calendar-events' ), |
|
68 | + 'label' => __('WordPress Installation', 'google-calendar-events'), |
|
69 | 69 | 'export' => 'WordPress Installation', |
70 | 70 | ), |
71 | 71 | 'theme' => array( |
72 | - 'label' => __( 'Active Theme', 'google-calendar-events' ), |
|
72 | + 'label' => __('Active Theme', 'google-calendar-events'), |
|
73 | 73 | 'export' => 'Active Theme', |
74 | 74 | ), |
75 | 75 | 'plugins' => array( |
76 | - 'label' => __( 'Active Plugins', 'google-calendar-events' ), |
|
76 | + 'label' => __('Active Plugins', 'google-calendar-events'), |
|
77 | 77 | 'export' => 'Active Plugins', |
78 | 78 | ), |
79 | 79 | 'server' => array( |
80 | - 'label' => __( 'Server Environment', 'google-calendar-events' ), |
|
80 | + 'label' => __('Server Environment', 'google-calendar-events'), |
|
81 | 81 | 'export' => 'Server Environment', |
82 | 82 | ), |
83 | 83 | 'client' => array( |
84 | - 'label' => __( 'Client Information', 'google-calendar-events' ), |
|
84 | + 'label' => __('Client Information', 'google-calendar-events'), |
|
85 | 85 | 'export' => 'Client Information', |
86 | 86 | ) |
87 | 87 | ); |
@@ -98,68 +98,68 @@ discard block |
||
98 | 98 | * ====================== |
99 | 99 | */ |
100 | 100 | |
101 | - $debug_mode = $script_debug = __( 'No', 'google-calendar-events' ); |
|
102 | - if ( defined( 'WP_DEBUG' ) ) { |
|
103 | - $debug_mode = true === WP_DEBUG ? __( 'Yes', 'google-calendar-events' ) : $debug_mode; |
|
101 | + $debug_mode = $script_debug = __('No', 'google-calendar-events'); |
|
102 | + if (defined('WP_DEBUG')) { |
|
103 | + $debug_mode = true === WP_DEBUG ? __('Yes', 'google-calendar-events') : $debug_mode; |
|
104 | 104 | } |
105 | - if ( defined( 'SCRIPT_DEBUG' ) ) { |
|
106 | - $script_debug = true === SCRIPT_DEBUG ? __( 'Yes', 'google-calendar-events' ) : $script_debug; |
|
105 | + if (defined('SCRIPT_DEBUG')) { |
|
106 | + $script_debug = true === SCRIPT_DEBUG ? __('Yes', 'google-calendar-events') : $script_debug; |
|
107 | 107 | } |
108 | 108 | |
109 | - $memory = $this->let_to_num( WP_MEMORY_LIMIT ); |
|
110 | - $memory_export = size_format( $memory ); |
|
111 | - if ( $memory < 67108864 ) { |
|
112 | - $memory = '<mark class="error">' . sprintf( __( '%1$s - It is recomendend to set memory to at least 64MB. See: <a href="%2$s" target="_blank">Increasing memory allocated to PHP</a>', 'google-calendar-events' ), $memory_export, 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP' ) . '</mark>'; |
|
109 | + $memory = $this->let_to_num(WP_MEMORY_LIMIT); |
|
110 | + $memory_export = size_format($memory); |
|
111 | + if ($memory < 67108864) { |
|
112 | + $memory = '<mark class="error">'.sprintf(__('%1$s - It is recomendend to set memory to at least 64MB. See: <a href="%2$s" target="_blank">Increasing memory allocated to PHP</a>', 'google-calendar-events'), $memory_export, 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP').'</mark>'; |
|
113 | 113 | } else { |
114 | - $memory = '<mark class="ok">' . $memory_export . '</mark>'; |
|
114 | + $memory = '<mark class="ok">'.$memory_export.'</mark>'; |
|
115 | 115 | } |
116 | 116 | |
117 | - $permalinks = get_option( 'permalink_structure' ); |
|
118 | - $permalinks = empty( $permalinks ) ? '/?' : $permalinks; |
|
117 | + $permalinks = get_option('permalink_structure'); |
|
118 | + $permalinks = empty($permalinks) ? '/?' : $permalinks; |
|
119 | 119 | |
120 | 120 | $is_multisite = is_multisite(); |
121 | 121 | |
122 | 122 | $sections['wordpress'] = array( |
123 | 123 | 'name' => array( |
124 | - 'label' => __( 'Site Name', 'google-calendar-events' ), |
|
124 | + 'label' => __('Site Name', 'google-calendar-events'), |
|
125 | 125 | 'label_export' => 'Site Name', |
126 | - 'result' => get_bloginfo( 'name' ), |
|
126 | + 'result' => get_bloginfo('name'), |
|
127 | 127 | ), |
128 | 128 | 'home_url' => array( |
129 | - 'label' => __( 'Home URL', 'google-calendar-events' ), |
|
129 | + 'label' => __('Home URL', 'google-calendar-events'), |
|
130 | 130 | 'label_export' => 'Home URL', |
131 | 131 | 'result' => home_url(), |
132 | 132 | ), |
133 | 133 | 'site_url' => array( |
134 | - 'label' => __( 'Site URL', 'google-calendar-events' ), |
|
134 | + 'label' => __('Site URL', 'google-calendar-events'), |
|
135 | 135 | 'label_export' => 'Site URL', |
136 | 136 | 'result' => site_url(), |
137 | 137 | ), |
138 | 138 | 'version' => array( |
139 | - 'label' => __( 'Version', 'google-calendar-events' ), |
|
139 | + 'label' => __('Version', 'google-calendar-events'), |
|
140 | 140 | 'label_export' => 'Version', |
141 | 141 | 'result' => $wp_version, |
142 | 142 | ), |
143 | 143 | 'locale' => array( |
144 | - 'label' => __( 'Locale', 'google-calendar-events' ), |
|
144 | + 'label' => __('Locale', 'google-calendar-events'), |
|
145 | 145 | 'label_export' => 'Locale', |
146 | 146 | 'result' => get_locale(), |
147 | 147 | ), |
148 | 148 | 'wp_timezone' => array( |
149 | - 'label' => __( 'Timezone', 'google-calendar-events' ), |
|
149 | + 'label' => __('Timezone', 'google-calendar-events'), |
|
150 | 150 | 'label_export' => 'Timezone', |
151 | 151 | 'result' => simcal_get_wp_timezone(), |
152 | 152 | ), |
153 | 153 | 'multisite' => array( |
154 | - 'label' => __( 'Multisite', 'google-calendar-events' ), |
|
154 | + 'label' => __('Multisite', 'google-calendar-events'), |
|
155 | 155 | 'label_export' => 'Multisite', |
156 | - 'result' => $is_multisite ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
|
156 | + 'result' => $is_multisite ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), |
|
157 | 157 | 'result_export' => $is_multisite ? 'Yes' : 'No' |
158 | 158 | ), |
159 | 159 | 'permalink' => array( |
160 | - 'label' => __( 'Permalinks', 'google-calendar-events' ), |
|
160 | + 'label' => __('Permalinks', 'google-calendar-events'), |
|
161 | 161 | 'label_export' => 'Permalinks', |
162 | - 'result' => '<code>' . $permalinks . '</code>', |
|
162 | + 'result' => '<code>'.$permalinks.'</code>', |
|
163 | 163 | 'result_export' => $permalinks, |
164 | 164 | ), |
165 | 165 | 'memory_limit' => array( |
@@ -182,86 +182,86 @@ discard block |
||
182 | 182 | * ============ |
183 | 183 | */ |
184 | 184 | |
185 | - include_once ABSPATH . 'wp-admin/includes/theme-install.php'; |
|
185 | + include_once ABSPATH.'wp-admin/includes/theme-install.php'; |
|
186 | 186 | |
187 | - if ( version_compare( $wp_version, '3.4', '<' ) ) { |
|
188 | - $active_theme = get_theme_data( get_stylesheet_directory() . '/style.css' ); |
|
189 | - $theme_name = '<a href="' . $active_theme['URI'] . '" target="_blank">' . $active_theme['Name'] . '</a>'; |
|
187 | + if (version_compare($wp_version, '3.4', '<')) { |
|
188 | + $active_theme = get_theme_data(get_stylesheet_directory().'/style.css'); |
|
189 | + $theme_name = '<a href="'.$active_theme['URI'].'" target="_blank">'.$active_theme['Name'].'</a>'; |
|
190 | 190 | $theme_version = $active_theme['Version']; |
191 | - $theme_author = '<a href="' . $active_theme['AuthorURI'] . '" target="_blank">' . $active_theme['Author'] . '</a>'; |
|
192 | - $theme_export = $active_theme['Name'] . ' - ' . $theme_version; |
|
191 | + $theme_author = '<a href="'.$active_theme['AuthorURI'].'" target="_blank">'.$active_theme['Author'].'</a>'; |
|
192 | + $theme_export = $active_theme['Name'].' - '.$theme_version; |
|
193 | 193 | } else { |
194 | 194 | $active_theme = wp_get_theme(); |
195 | - $theme_name = '<a href="' . $active_theme->ThemeURI . '" target="_blank">' . $active_theme->Name . '</a>'; |
|
195 | + $theme_name = '<a href="'.$active_theme->ThemeURI.'" target="_blank">'.$active_theme->Name.'</a>'; |
|
196 | 196 | $theme_version = $active_theme->Version; |
197 | 197 | $theme_author = $active_theme->Author; |
198 | - $theme_export = $active_theme->Name . ' - ' . $theme_version; |
|
198 | + $theme_export = $active_theme->Name.' - '.$theme_version; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | $theme_update_version = $theme_version; |
202 | 202 | |
203 | - $api = themes_api( 'theme_information', array( |
|
203 | + $api = themes_api('theme_information', array( |
|
204 | 204 | 'slug' => get_template(), |
205 | - 'fields' => array( 'sections' => false, 'tags' => false ), |
|
206 | - ) ); |
|
207 | - if ( $api && ! is_wp_error( $api ) ) { |
|
205 | + 'fields' => array('sections' => false, 'tags' => false), |
|
206 | + )); |
|
207 | + if ($api && ! is_wp_error($api)) { |
|
208 | 208 | $theme_update_version = $api->version; |
209 | 209 | } |
210 | 210 | |
211 | - if ( version_compare( $theme_version, $theme_update_version, '<' ) ) { |
|
212 | - $theme_version = '<mark class="error">' . $theme_version . ' (' . sprintf( __( '%s is available', 'google-calendar-events' ), esc_html( $theme_update_version ) ) . ')</mark>'; |
|
211 | + if (version_compare($theme_version, $theme_update_version, '<')) { |
|
212 | + $theme_version = '<mark class="error">'.$theme_version.' ('.sprintf(__('%s is available', 'google-calendar-events'), esc_html($theme_update_version)).')</mark>'; |
|
213 | 213 | } else { |
214 | - $theme_version = '<mark class="ok">' . $theme_version . '</mark>'; |
|
214 | + $theme_version = '<mark class="ok">'.$theme_version.'</mark>'; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | $theme = '<dl>'; |
218 | - $theme .= '<dt>' . __( 'Name', 'google-calendar-events' ) . '</dt>'; |
|
219 | - $theme .= '<dd>' . $theme_name . '</dd>'; |
|
220 | - $theme .= '<dt>' . __( 'Author', 'google-calendar-events' ) . '</dt>'; |
|
221 | - $theme .= '<dd>' . $theme_author . '</dd>'; |
|
222 | - $theme .= '<dt>' . __( 'Version', 'google-calendar-events' ) . '</dt>'; |
|
223 | - $theme .= '<dd>' . $theme_version . '</dd>'; |
|
218 | + $theme .= '<dt>'.__('Name', 'google-calendar-events').'</dt>'; |
|
219 | + $theme .= '<dd>'.$theme_name.'</dd>'; |
|
220 | + $theme .= '<dt>'.__('Author', 'google-calendar-events').'</dt>'; |
|
221 | + $theme .= '<dd>'.$theme_author.'</dd>'; |
|
222 | + $theme .= '<dt>'.__('Version', 'google-calendar-events').'</dt>'; |
|
223 | + $theme .= '<dd>'.$theme_version.'</dd>'; |
|
224 | 224 | $theme .= '</dl>'; |
225 | 225 | |
226 | 226 | $is_child_theme = is_child_theme(); |
227 | 227 | $parent_theme = $parent_theme_export = '-'; |
228 | 228 | |
229 | - if ( $is_child_theme ) { |
|
230 | - if ( version_compare( $wp_version, '3.4', '<' ) ) { |
|
229 | + if ($is_child_theme) { |
|
230 | + if (version_compare($wp_version, '3.4', '<')) { |
|
231 | 231 | |
232 | 232 | $parent_theme = $parent_theme_export = $active_theme['Template']; |
233 | 233 | |
234 | 234 | } else { |
235 | 235 | |
236 | - $parent = wp_get_theme( $active_theme->Template ); |
|
236 | + $parent = wp_get_theme($active_theme->Template); |
|
237 | 237 | $parent_theme = '<dl>'; |
238 | - $parent_theme .= '<dt>' . __( 'Name', 'google-calendar-events' ) . '</dt>'; |
|
239 | - $parent_theme .= '<dd>' . $parent->Name . '</dd>'; |
|
240 | - $parent_theme .= '<dt>' . __( 'Author', 'google-calendar-events' ) . '</dt>'; |
|
241 | - $parent_theme .= '<dd>' . $parent->Author . '</dd>'; |
|
242 | - $parent_theme .= '<dt>' . __( 'Version', 'google-calendar-events' ) . '</dt>'; |
|
243 | - $parent_theme .= '<dd>' . $parent->Version . '</dd>'; |
|
238 | + $parent_theme .= '<dt>'.__('Name', 'google-calendar-events').'</dt>'; |
|
239 | + $parent_theme .= '<dd>'.$parent->Name.'</dd>'; |
|
240 | + $parent_theme .= '<dt>'.__('Author', 'google-calendar-events').'</dt>'; |
|
241 | + $parent_theme .= '<dd>'.$parent->Author.'</dd>'; |
|
242 | + $parent_theme .= '<dt>'.__('Version', 'google-calendar-events').'</dt>'; |
|
243 | + $parent_theme .= '<dd>'.$parent->Version.'</dd>'; |
|
244 | 244 | $parent_theme .= '</dl>'; |
245 | 245 | |
246 | - $parent_theme_export = strip_tags( $parent->Name ) . ' - ' . $parent->Version; |
|
246 | + $parent_theme_export = strip_tags($parent->Name).' - '.$parent->Version; |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
250 | 250 | $sections['theme'] = array( |
251 | 251 | 'theme' => array( |
252 | - 'label' => __( 'Theme Information', 'google-calendar-events' ), |
|
252 | + 'label' => __('Theme Information', 'google-calendar-events'), |
|
253 | 253 | 'label_export' => 'Theme', |
254 | 254 | 'result' => $theme, |
255 | 255 | 'result_export' => $theme_export, |
256 | 256 | ), |
257 | 257 | 'theme_child' => array( |
258 | - 'label' => __( 'Child Theme', 'google-calendar-events' ), |
|
258 | + 'label' => __('Child Theme', 'google-calendar-events'), |
|
259 | 259 | 'label_export' => 'Child Theme', |
260 | - 'result' => $is_child_theme ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
|
260 | + 'result' => $is_child_theme ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), |
|
261 | 261 | 'result_export' => $is_child_theme ? 'Yes' : 'No', |
262 | 262 | ), |
263 | 263 | 'theme_parent' => array( |
264 | - 'label' => __( 'Parent Theme', 'google-calendar-events' ), |
|
264 | + 'label' => __('Parent Theme', 'google-calendar-events'), |
|
265 | 265 | 'label_export' => 'Parent Theme', |
266 | 266 | 'result' => $parent_theme, |
267 | 267 | 'result_export' => $parent_theme_export, |
@@ -273,61 +273,61 @@ discard block |
||
273 | 273 | * ============== |
274 | 274 | */ |
275 | 275 | |
276 | - include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
|
276 | + include_once ABSPATH.'wp-admin/includes/plugin-install.php'; |
|
277 | 277 | |
278 | - $active_plugins = (array) get_option( 'active_plugins', array() ); |
|
279 | - if ( is_multisite() ) { |
|
280 | - $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) ); |
|
278 | + $active_plugins = (array) get_option('active_plugins', array()); |
|
279 | + if (is_multisite()) { |
|
280 | + $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array())); |
|
281 | 281 | } |
282 | 282 | |
283 | - foreach ( $active_plugins as $plugin ) { |
|
283 | + foreach ($active_plugins as $plugin) { |
|
284 | 284 | |
285 | - $plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
|
285 | + $plugin_data = @get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin); |
|
286 | 286 | |
287 | - if ( ! empty( $plugin_data['Name'] ) ) { |
|
287 | + if ( ! empty($plugin_data['Name'])) { |
|
288 | 288 | |
289 | 289 | $plugin_name = $plugin_data['Title']; |
290 | 290 | $plugin_author = $plugin_data['Author']; |
291 | 291 | $plugin_version = $plugin_update_version = $plugin_data['Version']; |
292 | 292 | |
293 | 293 | // Afraid that querying many plugins may risk a timeout. |
294 | - if ( count( $active_plugins ) <= 10 ) { |
|
295 | - $api = plugins_api( 'plugin_information', array( |
|
294 | + if (count($active_plugins) <= 10) { |
|
295 | + $api = plugins_api('plugin_information', array( |
|
296 | 296 | 'slug' => $plugin_data['Name'], |
297 | 297 | 'fields' => array( |
298 | 298 | 'version' => true, |
299 | 299 | ), |
300 | - ) ); |
|
301 | - if ( $api && ! is_wp_error( $api ) ) { |
|
302 | - if ( ! empty( $api->version ) ) { |
|
300 | + )); |
|
301 | + if ($api && ! is_wp_error($api)) { |
|
302 | + if ( ! empty($api->version)) { |
|
303 | 303 | $plugin_update_version = $api->version; |
304 | - if ( version_compare( $plugin_version, $plugin_update_version, '<' ) ) { |
|
305 | - $plugin_version = '<mark class="error">' . $plugin_version . ' (' . sprintf( __( '%s is available', 'google-calendar-events' ), esc_html( $plugin_update_version ) ) . ')</mark>'; |
|
304 | + if (version_compare($plugin_version, $plugin_update_version, '<')) { |
|
305 | + $plugin_version = '<mark class="error">'.$plugin_version.' ('.sprintf(__('%s is available', 'google-calendar-events'), esc_html($plugin_update_version)).')</mark>'; |
|
306 | 306 | } else { |
307 | - $plugin_version = '<mark class="ok">' . $plugin_version . '</mark>'; |
|
307 | + $plugin_version = '<mark class="ok">'.$plugin_version.'</mark>'; |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
313 | 313 | $plugin = '<dl>'; |
314 | - $plugin .= '<dt>' . __( 'Author', 'google-calendar-events' ) . '</dt>'; |
|
315 | - $plugin .= '<dd>' . $plugin_author . '</dd>'; |
|
316 | - $plugin .= '<dt>' . __( 'Version', 'google-calendar-events' ) . '</dt>'; |
|
317 | - $plugin .= '<dd>' . $plugin_version . '</dd>'; |
|
314 | + $plugin .= '<dt>'.__('Author', 'google-calendar-events').'</dt>'; |
|
315 | + $plugin .= '<dd>'.$plugin_author.'</dd>'; |
|
316 | + $plugin .= '<dt>'.__('Version', 'google-calendar-events').'</dt>'; |
|
317 | + $plugin .= '<dd>'.$plugin_version.'</dd>'; |
|
318 | 318 | $plugin .= '</dl>'; |
319 | 319 | |
320 | - $sections['plugins'][ sanitize_key( strip_tags( $plugin_name ) ) ] = array( |
|
320 | + $sections['plugins'][sanitize_key(strip_tags($plugin_name))] = array( |
|
321 | 321 | 'label' => $plugin_name, |
322 | - 'label_export' => strip_tags( $plugin_data['Title'] ), |
|
322 | + 'label_export' => strip_tags($plugin_data['Title']), |
|
323 | 323 | 'result' => $plugin, |
324 | 324 | 'result_export' => $plugin_data['Version'], |
325 | 325 | ); |
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
329 | - if ( isset( $sections['plugins'] ) ) { |
|
330 | - rsort( $sections['plugins'] ); |
|
329 | + if (isset($sections['plugins'])) { |
|
330 | + rsort($sections['plugins']); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -335,51 +335,51 @@ discard block |
||
335 | 335 | * ================== |
336 | 336 | */ |
337 | 337 | |
338 | - if ( version_compare( PHP_VERSION, '5.4', '<' ) ) { |
|
339 | - $php = '<mark class="error">' . sprintf( __( '%1$s - It is recomendend to upgrade at least to PHP version 5.4 for security reasons. <a href="%2$s" target="_blank">Read more.</a>', 'google-calendar-events' ), PHP_VERSION, 'http://www.wpupdatephp.com/update/' ) . '</mark>'; |
|
338 | + if (version_compare(PHP_VERSION, '5.4', '<')) { |
|
339 | + $php = '<mark class="error">'.sprintf(__('%1$s - It is recomendend to upgrade at least to PHP version 5.4 for security reasons. <a href="%2$s" target="_blank">Read more.</a>', 'google-calendar-events'), PHP_VERSION, 'http://www.wpupdatephp.com/update/').'</mark>'; |
|
340 | 340 | } else { |
341 | - $php = '<mark class="ok">' . PHP_VERSION . '</mark>'; |
|
341 | + $php = '<mark class="ok">'.PHP_VERSION.'</mark>'; |
|
342 | 342 | } |
343 | 343 | |
344 | - if ( $wpdb->use_mysqli ) { |
|
345 | - $mysql = @mysqli_get_server_info( $wpdb->dbh ); |
|
344 | + if ($wpdb->use_mysqli) { |
|
345 | + $mysql = @mysqli_get_server_info($wpdb->dbh); |
|
346 | 346 | } else { |
347 | 347 | $mysql = @mysql_get_server_info(); |
348 | 348 | } |
349 | 349 | |
350 | 350 | $host = $_SERVER['SERVER_SOFTWARE']; |
351 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
351 | + if (defined('WPE_APIKEY')) { |
|
352 | 352 | $host .= ' (WP Engine)'; |
353 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
353 | + } elseif (defined('PAGELYBIN')) { |
|
354 | 354 | $host .= ' (Pagely)'; |
355 | 355 | } |
356 | 356 | |
357 | 357 | $default_timezone = $server_timezone_export = date_default_timezone_get(); |
358 | - if ( 'UTC' !== $default_timezone ) { |
|
359 | - $server_timezone = '<mark class="error">' . sprintf( __( 'Server default timezone is %s - it should be UTC', 'google-calendar-events' ), $default_timezone ) . '</mark>'; |
|
358 | + if ('UTC' !== $default_timezone) { |
|
359 | + $server_timezone = '<mark class="error">'.sprintf(__('Server default timezone is %s - it should be UTC', 'google-calendar-events'), $default_timezone).'</mark>'; |
|
360 | 360 | } else { |
361 | 361 | $server_timezone = '<mark class="ok">UTC</mark>'; |
362 | 362 | } |
363 | 363 | |
364 | 364 | // WP Remote POST test. |
365 | - $response = wp_safe_remote_post( 'https://www.paypal.com/cgi-bin/webscr', array( |
|
365 | + $response = wp_safe_remote_post('https://www.paypal.com/cgi-bin/webscr', array( |
|
366 | 366 | 'timeout' => 60, |
367 | 367 | 'body' => array( |
368 | 368 | 'cmd' => '_notify-validate', |
369 | 369 | ), |
370 | - ) ); |
|
371 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
370 | + )); |
|
371 | + if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { |
|
372 | 372 | $wp_post_export = 'Yes'; |
373 | - $wp_post = '<mark class="ok">' . __( 'Yes', 'google-calendar-events' ) . '</mark>'; |
|
373 | + $wp_post = '<mark class="ok">'.__('Yes', 'google-calendar-events').'</mark>'; |
|
374 | 374 | } else { |
375 | 375 | $wp_post_export = 'No'; |
376 | - $wp_post = '<mark class="error">' . __( 'No', 'google-calendar-events' ); |
|
377 | - if ( is_wp_error( $response ) ) { |
|
378 | - $error = ' (' . $response->get_error_message() . ')'; |
|
376 | + $wp_post = '<mark class="error">'.__('No', 'google-calendar-events'); |
|
377 | + if (is_wp_error($response)) { |
|
378 | + $error = ' ('.$response->get_error_message().')'; |
|
379 | 379 | $wp_post .= $error; |
380 | 380 | $wp_post_export .= $error; |
381 | 381 | } else { |
382 | - $error = ' (' . $response['response']['code'] . ')'; |
|
382 | + $error = ' ('.$response['response']['code'].')'; |
|
383 | 383 | $wp_post .= $error; |
384 | 384 | $wp_post_export .= $error; |
385 | 385 | } |
@@ -387,64 +387,64 @@ discard block |
||
387 | 387 | } |
388 | 388 | |
389 | 389 | // WP Remote GET test. |
390 | - $response = wp_safe_remote_get( get_home_url( '/?p=1' ) ); |
|
391 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
390 | + $response = wp_safe_remote_get(get_home_url('/?p=1')); |
|
391 | + if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { |
|
392 | 392 | $wp_get_export = 'Yes'; |
393 | - $wp_get = '<mark class="ok">' . __( 'Yes', 'google-calendar-events' ) . '</mark>'; |
|
393 | + $wp_get = '<mark class="ok">'.__('Yes', 'google-calendar-events').'</mark>'; |
|
394 | 394 | } else { |
395 | 395 | $wp_get_export = 'No'; |
396 | - $wp_get = '<mark class="error">' . __( 'No', 'google-calendar-events' ); |
|
397 | - if ( is_wp_error( $response ) ) { |
|
398 | - $error = ' (' . $response->get_error_message() . ')'; |
|
396 | + $wp_get = '<mark class="error">'.__('No', 'google-calendar-events'); |
|
397 | + if (is_wp_error($response)) { |
|
398 | + $error = ' ('.$response->get_error_message().')'; |
|
399 | 399 | $wp_get .= $error; |
400 | 400 | $wp_get_export .= $error; |
401 | 401 | } else { |
402 | - $error = ' (' . $response['response']['code'] . ')'; |
|
402 | + $error = ' ('.$response['response']['code'].')'; |
|
403 | 403 | $wp_get .= $error; |
404 | 404 | $wp_get_export .= $error; |
405 | 405 | } |
406 | 406 | $wp_get .= '</mark>'; |
407 | 407 | } |
408 | 408 | |
409 | - $php_memory_limit = ini_get( 'memory_limit' ); |
|
410 | - $php_max_upload_filesize = ini_get( 'upload_max_filesize' ); |
|
411 | - $php_post_max_size = ini_get( 'post_max_size' ); |
|
412 | - $php_max_execution_time = ini_get( 'max_execution_time' ); |
|
413 | - $php_max_input_vars = ini_get( 'max_input_vars' ); |
|
409 | + $php_memory_limit = ini_get('memory_limit'); |
|
410 | + $php_max_upload_filesize = ini_get('upload_max_filesize'); |
|
411 | + $php_post_max_size = ini_get('post_max_size'); |
|
412 | + $php_max_execution_time = ini_get('max_execution_time'); |
|
413 | + $php_max_input_vars = ini_get('max_input_vars'); |
|
414 | 414 | |
415 | 415 | $sections['server'] = array( |
416 | 416 | 'host' => array( |
417 | - 'label' => __( 'Web Server', 'google-calendar-events' ), |
|
417 | + 'label' => __('Web Server', 'google-calendar-events'), |
|
418 | 418 | 'label_export' => 'Web Server', |
419 | 419 | 'result' => $host, |
420 | 420 | ), |
421 | 421 | 'php_version' => array( |
422 | - 'label' => __( 'PHP Version', 'google-calendar-events' ), |
|
422 | + 'label' => __('PHP Version', 'google-calendar-events'), |
|
423 | 423 | 'label_export' => 'PHP Version', |
424 | 424 | 'result' => $php, |
425 | 425 | 'result_export' => PHP_VERSION, |
426 | 426 | ), |
427 | 427 | 'mysql_version' => array( |
428 | - 'label' => __( 'MySQL Version', 'google-calendar-events' ), |
|
428 | + 'label' => __('MySQL Version', 'google-calendar-events'), |
|
429 | 429 | 'label_export' => 'MySQL Version', |
430 | - 'result' => version_compare( $mysql, '5.5', '>' ) ? '<mark class="ok">' . $mysql . '</mark>' : $mysql, |
|
430 | + 'result' => version_compare($mysql, '5.5', '>') ? '<mark class="ok">'.$mysql.'</mark>' : $mysql, |
|
431 | 431 | 'result_export' => $mysql, |
432 | 432 | ), |
433 | 433 | 'server_timezone' => array( |
434 | - 'label' => __( 'Server Timezone', 'google-calendar-events' ), |
|
434 | + 'label' => __('Server Timezone', 'google-calendar-events'), |
|
435 | 435 | 'label_export' => 'Server Timezone', |
436 | 436 | 'result' => $server_timezone, |
437 | 437 | 'result_export' => $server_timezone_export, |
438 | 438 | ), |
439 | 439 | 'display_errors' => array( |
440 | 440 | 'label' => 'Display Errors', |
441 | - 'result' => ( ini_get( 'display_errors' ) ) ? __( 'Yes', 'google-calendar-events' ) . ' (' . ini_get( 'display_errors' ) . ')' : '-', |
|
442 | - 'result_export' => ( ini_get( 'display_errors' ) ) ? 'Yes' : 'No', |
|
441 | + 'result' => (ini_get('display_errors')) ? __('Yes', 'google-calendar-events').' ('.ini_get('display_errors').')' : '-', |
|
442 | + 'result_export' => (ini_get('display_errors')) ? 'Yes' : 'No', |
|
443 | 443 | ), |
444 | 444 | 'php_safe_mode' => array( |
445 | 445 | 'label' => 'Safe Mode', |
446 | - 'result' => ( ini_get( 'safe_mode' ) ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
|
447 | - 'result_export' => ( ini_get( 'safe_mode' ) ) ? 'Yes' : 'No', |
|
446 | + 'result' => (ini_get('safe_mode')) ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), |
|
447 | + 'result_export' => (ini_get('safe_mode')) ? 'Yes' : 'No', |
|
448 | 448 | ), |
449 | 449 | 'php_memory_limit' => array( |
450 | 450 | 'label' => 'Memory Limit', |
@@ -468,23 +468,23 @@ discard block |
||
468 | 468 | ), |
469 | 469 | 'fsockopen' => array( |
470 | 470 | 'label' => 'fsockopen', |
471 | - 'result' => function_exists( 'fsockopen' ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
|
472 | - 'result_export' => function_exists( 'fsockopen' ) ? 'Yes' : 'No', |
|
471 | + 'result' => function_exists('fsockopen') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), |
|
472 | + 'result_export' => function_exists('fsockopen') ? 'Yes' : 'No', |
|
473 | 473 | ), |
474 | 474 | 'curl_init' => array( |
475 | 475 | 'label' => 'cURL', |
476 | - 'result' => function_exists( 'curl_init' ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
|
477 | - 'result_export' => function_exists( 'curl_init' ) ? 'Yes' : 'No', |
|
476 | + 'result' => function_exists('curl_init') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), |
|
477 | + 'result_export' => function_exists('curl_init') ? 'Yes' : 'No', |
|
478 | 478 | ), |
479 | 479 | 'soap' => array( |
480 | 480 | 'label' => 'SOAP', |
481 | - 'result' => class_exists( 'SoapClient' ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
|
482 | - 'result_export' => class_exists( 'SoapClient' ) ? 'Yes' : 'No', |
|
481 | + 'result' => class_exists('SoapClient') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), |
|
482 | + 'result_export' => class_exists('SoapClient') ? 'Yes' : 'No', |
|
483 | 483 | ), |
484 | 484 | 'suhosin' => array( |
485 | 485 | 'label' => 'SUHOSIN', |
486 | - 'result' => extension_loaded( 'suhosin' ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
|
487 | - 'result_export' => extension_loaded( 'suhosin' ) ? 'Yes' : 'No', |
|
486 | + 'result' => extension_loaded('suhosin') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), |
|
487 | + 'result_export' => extension_loaded('suhosin') ? 'Yes' : 'No', |
|
488 | 488 | ), |
489 | 489 | 'wp_remote_post' => array( |
490 | 490 | 'label' => 'WP Remote POST', |
@@ -506,26 +506,26 @@ discard block |
||
506 | 506 | $user_client = new \Browser(); |
507 | 507 | |
508 | 508 | $browser = '<dl>'; |
509 | - $browser .= '<dt>' . __( 'Name:', 'google-calendar-events' ) . '</dt>'; |
|
510 | - $browser .= '<dd>' . $user_client->getBrowser() . '</dd>'; |
|
511 | - $browser .= '<dt>' . __( 'Version:', 'google-calendar-events' ) . '</dt>'; |
|
512 | - $browser .= '<dd>' . $user_client->getVersion() . '</dd>'; |
|
513 | - $browser .= '<dt>' . __( 'User Agent:', 'google-calendar-events' ) . '</dt>'; |
|
514 | - $browser .= '<dd>' . $user_client->getUserAgent() . '</dd>'; |
|
515 | - $browser .= '<dt>' . __( 'Platform:', 'google-calendar-events' ) . '</dt>'; |
|
516 | - $browser .= '<dd>' . $user_client->getPlatform() . '</dd>'; |
|
509 | + $browser .= '<dt>'.__('Name:', 'google-calendar-events').'</dt>'; |
|
510 | + $browser .= '<dd>'.$user_client->getBrowser().'</dd>'; |
|
511 | + $browser .= '<dt>'.__('Version:', 'google-calendar-events').'</dt>'; |
|
512 | + $browser .= '<dd>'.$user_client->getVersion().'</dd>'; |
|
513 | + $browser .= '<dt>'.__('User Agent:', 'google-calendar-events').'</dt>'; |
|
514 | + $browser .= '<dd>'.$user_client->getUserAgent().'</dd>'; |
|
515 | + $browser .= '<dt>'.__('Platform:', 'google-calendar-events').'</dt>'; |
|
516 | + $browser .= '<dd>'.$user_client->getPlatform().'</dd>'; |
|
517 | 517 | $browser .= '</dl>'; |
518 | 518 | |
519 | - $browser_export = $user_client->getBrowser() . ' ' . $user_client->getVersion() . ' (' . $user_client->getPlatform() . ')'; |
|
519 | + $browser_export = $user_client->getBrowser().' '.$user_client->getVersion().' ('.$user_client->getPlatform().')'; |
|
520 | 520 | |
521 | 521 | $sections['client'] = array( |
522 | 522 | 'user_ip' => array( |
523 | - 'label' => __( 'IP Address', 'google-calendar-events' ), |
|
523 | + 'label' => __('IP Address', 'google-calendar-events'), |
|
524 | 524 | 'label_export' => 'IP Address', |
525 | 525 | 'result' => $_SERVER['SERVER_ADDR'], |
526 | 526 | ), |
527 | 527 | 'browser' => array( |
528 | - 'label' => __( 'Browser', 'google-calendar-events' ), |
|
528 | + 'label' => __('Browser', 'google-calendar-events'), |
|
529 | 529 | 'result' => $browser, |
530 | 530 | 'result_export' => $browser_export, |
531 | 531 | ) |
@@ -536,12 +536,12 @@ discard block |
||
536 | 536 | * ============ |
537 | 537 | */ |
538 | 538 | |
539 | - $panels = apply_filters( 'simcal_system_status_report_panels', $panels ); |
|
540 | - $sections = apply_filters( 'simcal_system_status_report_sections', $sections ); |
|
539 | + $panels = apply_filters('simcal_system_status_report_panels', $panels); |
|
540 | + $sections = apply_filters('simcal_system_status_report_sections', $sections); |
|
541 | 541 | |
542 | - foreach ( $panels as $panel => $v ) : |
|
542 | + foreach ($panels as $panel => $v) : |
|
543 | 543 | |
544 | - if ( isset( $sections[ $panel ] ) ) : |
|
544 | + if (isset($sections[$panel])) : |
|
545 | 545 | |
546 | 546 | ?> |
547 | 547 | <table class="widefat simcal-system-status-report-panel"> |
@@ -551,15 +551,15 @@ discard block |
||
551 | 551 | </tr> |
552 | 552 | </thead> |
553 | 553 | <tbody> |
554 | - <?php foreach ( $sections[ $panel ] as $row => $cell ) : ?> |
|
554 | + <?php foreach ($sections[$panel] as $row => $cell) : ?> |
|
555 | 555 | <tr> |
556 | 556 | <?php |
557 | - $label_export = isset( $cell['label_export'] ) ? $cell['label_export'] : $cell['label']; |
|
558 | - $result_export = isset( $cell['result_export'] ) ? $cell['result_export'] : $cell['result']; |
|
557 | + $label_export = isset($cell['label_export']) ? $cell['label_export'] : $cell['label']; |
|
558 | + $result_export = isset($cell['result_export']) ? $cell['result_export'] : $cell['result']; |
|
559 | 559 | ?> |
560 | - <td class="tooltip"><?php echo isset( $cell['tooltip'] ) ? ' <i class="simcal-icon-help simcal-help-tip" data-tip="' . $cell['tooltip'] . '"></i> ' : ''; ?></td> |
|
561 | - <td class="label" data-export="<?php echo trim( $label_export ); ?>"><?php echo $cell['label']; ?></td> |
|
562 | - <td class="result" data-export="<?php echo trim( $result_export ); ?>"><?php echo $cell['result']; ?></td> |
|
560 | + <td class="tooltip"><?php echo isset($cell['tooltip']) ? ' <i class="simcal-icon-help simcal-help-tip" data-tip="'.$cell['tooltip'].'"></i> ' : ''; ?></td> |
|
561 | + <td class="label" data-export="<?php echo trim($label_export); ?>"><?php echo $cell['label']; ?></td> |
|
562 | + <td class="result" data-export="<?php echo trim($result_export); ?>"><?php echo $cell['result']; ?></td> |
|
563 | 563 | </tr> |
564 | 564 | <?php endforeach; ?> |
565 | 565 | </tbody> |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | jQuery( '#simcal-system-status-report-download' ).on( 'click', function() { |
638 | 638 | var file = new Blob( [ report ], { type: 'text/plain' } ); |
639 | 639 | jQuery( this ).attr( 'href', URL.createObjectURL( file ) ); |
640 | - jQuery( this ).attr( 'download', '<?php echo sanitize_title( str_replace( array( 'http://', 'https://' ), '', get_bloginfo( 'url' ) ) . '-system-report-' . date( 'Y-m-d', time() ) ); ?>' ); |
|
640 | + jQuery( this ).attr( 'download', '<?php echo sanitize_title(str_replace(array('http://', 'https://'), '', get_bloginfo('url')).'-system-report-'.date('Y-m-d', time())); ?>' ); |
|
641 | 641 | } ); |
642 | 642 | |
643 | 643 | </script> |
@@ -657,13 +657,13 @@ discard block |
||
657 | 657 | * |
658 | 658 | * @return int|double|string |
659 | 659 | */ |
660 | - private function let_to_num( $size ) { |
|
660 | + private function let_to_num($size) { |
|
661 | 661 | |
662 | - $l = substr( $size, -1 ); |
|
663 | - $ret = substr( $size, 0, -1 ); |
|
662 | + $l = substr($size, -1); |
|
663 | + $ret = substr($size, 0, -1); |
|
664 | 664 | |
665 | 665 | // Note: do not insert break or default in this switch loop. |
666 | - switch ( strtoupper( $l ) ) { |
|
666 | + switch (strtoupper($l)) { |
|
667 | 667 | case 'P': |
668 | 668 | $ret *= 1024; |
669 | 669 | // no break |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | $ret *= 1024; |
678 | 678 | // no break |
679 | 679 | case 'K': |
680 | - $ret *= 1024;; |
|
680 | + $ret *= 1024; ; |
|
681 | 681 | // no break |
682 | 682 | } |
683 | 683 |
@@ -272,9 +272,9 @@ |
||
272 | 272 | |
273 | 273 | if ( $post_type == 'calendar' && isset( $post->ID ) ) { |
274 | 274 | echo '<a id="simcal-clear-cache" class="button" data-id="' . $post->ID . ' ">' . |
275 | - '<i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i> ' . |
|
276 | - __( 'Clear cache', 'google-calendar-events' ) . |
|
277 | - '</a>'; |
|
275 | + '<i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i> ' . |
|
276 | + __( 'Clear cache', 'google-calendar-events' ) . |
|
277 | + '</a>'; |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Calendar; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -32,26 +32,26 @@ discard block |
||
32 | 32 | new Meta_Boxes(); |
33 | 33 | |
34 | 34 | // Add column headers in calendar feeds admin archives. |
35 | - add_filter( 'manage_calendar_posts_columns', array( $this, 'add_calendar_feed_column_headers' ) ); |
|
35 | + add_filter('manage_calendar_posts_columns', array($this, 'add_calendar_feed_column_headers')); |
|
36 | 36 | // Process column contents for calendar feeds. |
37 | - add_action( 'manage_calendar_posts_custom_column', array( $this, 'calendar_feed_column_content' ), 10, 2 ); |
|
37 | + add_action('manage_calendar_posts_custom_column', array($this, 'calendar_feed_column_content'), 10, 2); |
|
38 | 38 | |
39 | 39 | // Add actions in calendar feed rows. |
40 | - add_filter( 'post_row_actions', array( $this, 'row_actions' ), 10, 2 ); |
|
40 | + add_filter('post_row_actions', array($this, 'row_actions'), 10, 2); |
|
41 | 41 | // Add bulk actions. |
42 | - add_action( 'admin_init', array( $this, 'bulk_actions' ) ); |
|
42 | + add_action('admin_init', array($this, 'bulk_actions')); |
|
43 | 43 | // Add content to edit calendars page. |
44 | - add_action( 'load-edit.php', array( $this, 'edit_table_hooks' ) ); |
|
44 | + add_action('load-edit.php', array($this, 'edit_table_hooks')); |
|
45 | 45 | |
46 | 46 | // Default calendar post type content (default event template). |
47 | - add_filter( 'default_content', array( $this, 'default_event_template' ), 10, 2 ); |
|
47 | + add_filter('default_content', array($this, 'default_event_template'), 10, 2); |
|
48 | 48 | |
49 | 49 | // Add a clear cache link in submit post box. |
50 | - add_action( 'post_submitbox_misc_actions', array( $this, 'clear_cache_button' ) ); |
|
50 | + add_action('post_submitbox_misc_actions', array($this, 'clear_cache_button')); |
|
51 | 51 | |
52 | 52 | // Add media button to post editor for adding a shortcode. |
53 | - add_action( 'media_buttons', array( $this, 'add_shortcode_button' ), 100 ); |
|
54 | - add_action( 'edit_form_after_editor', array( $this, 'add_shortcode_panel' ), 100 ); |
|
53 | + add_action('media_buttons', array($this, 'add_shortcode_button'), 100); |
|
54 | + add_action('edit_form_after_editor', array($this, 'add_shortcode_panel'), 100); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -63,15 +63,15 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return array Filtered output. |
65 | 65 | */ |
66 | - public function add_calendar_feed_column_headers( $columns ) { |
|
66 | + public function add_calendar_feed_column_headers($columns) { |
|
67 | 67 | |
68 | 68 | // New columns. |
69 | - $feed_info = array( 'feed' => __( 'Events Source', 'google-calendar-events' ) ); |
|
70 | - $calendar_info = array( 'calendar' => __( 'Calendar Type', 'google-calendar-events' ) ); |
|
71 | - $shortcode = array( 'shortcode' => __( 'Shortcode', 'google-calendar-events' ) ); |
|
69 | + $feed_info = array('feed' => __('Events Source', 'google-calendar-events')); |
|
70 | + $calendar_info = array('calendar' => __('Calendar Type', 'google-calendar-events')); |
|
71 | + $shortcode = array('shortcode' => __('Shortcode', 'google-calendar-events')); |
|
72 | 72 | |
73 | 73 | // Merge with existing columns and rearrange. |
74 | - $columns = array_slice( $columns, 0, 2, true ) + $feed_info + $calendar_info + $shortcode + array_slice( $columns, 2, null, true ); |
|
74 | + $columns = array_slice($columns, 0, 2, true) + $feed_info + $calendar_info + $shortcode + array_slice($columns, 2, null, true); |
|
75 | 75 | |
76 | 76 | return $columns; |
77 | 77 | } |
@@ -86,32 +86,32 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return void |
88 | 88 | */ |
89 | - public function calendar_feed_column_content( $column_name, $post_id ) { |
|
89 | + public function calendar_feed_column_content($column_name, $post_id) { |
|
90 | 90 | |
91 | - switch ( $column_name ) { |
|
91 | + switch ($column_name) { |
|
92 | 92 | |
93 | 93 | case 'feed': |
94 | 94 | |
95 | - $feed = simcal_get_feed( $post_id ); |
|
96 | - echo isset( $feed->name ) ? $feed->name : '—'; |
|
95 | + $feed = simcal_get_feed($post_id); |
|
96 | + echo isset($feed->name) ? $feed->name : '—'; |
|
97 | 97 | break; |
98 | 98 | |
99 | 99 | case 'calendar': |
100 | 100 | |
101 | 101 | $info = '—'; |
102 | 102 | |
103 | - if ( $terms = wp_get_object_terms( $post_id, 'calendar_type' ) ) { |
|
103 | + if ($terms = wp_get_object_terms($post_id, 'calendar_type')) { |
|
104 | 104 | |
105 | - $calendar_type = sanitize_title( current( $terms )->name ); |
|
106 | - $calendar = simcal_get_calendar( $calendar_type ); |
|
105 | + $calendar_type = sanitize_title(current($terms)->name); |
|
106 | + $calendar = simcal_get_calendar($calendar_type); |
|
107 | 107 | |
108 | - if ( $calendar instanceof Calendar ) { |
|
108 | + if ($calendar instanceof Calendar) { |
|
109 | 109 | $info = $calendar->name; |
110 | - $views = get_post_meta( $post_id, '_calendar_view', true );; |
|
111 | - $view = isset( $views[ $calendar->type ] ) ? $views[ $calendar->type ] : ''; |
|
110 | + $views = get_post_meta($post_id, '_calendar_view', true); ; |
|
111 | + $view = isset($views[$calendar->type]) ? $views[$calendar->type] : ''; |
|
112 | 112 | |
113 | - if ( isset( $calendar->views[ $view ] ) ) { |
|
114 | - $info .= ' → ' . $calendar->views[ $view ]; |
|
113 | + if (isset($calendar->views[$view])) { |
|
114 | + $info .= ' → '.$calendar->views[$view]; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | case 'shortcode' : |
123 | 123 | |
124 | - simcal_print_shortcode_tip( $post_id ); |
|
124 | + simcal_print_shortcode_tip($post_id); |
|
125 | 125 | break; |
126 | 126 | } |
127 | 127 | } |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return array Filtered output. |
138 | 138 | */ |
139 | - public function row_actions( $actions, $post ) { |
|
139 | + public function row_actions($actions, $post) { |
|
140 | 140 | |
141 | 141 | // Add a clear feed cache action link. |
142 | - if ( $post->post_type == 'calendar' ) { |
|
143 | - $actions['duplicate_feed'] = '<a href="' . esc_url( add_query_arg( array( 'duplicate_feed' => $post->ID ) ) ) . '">' . __( 'Clone', 'google-calendar-events' ) . '</a>'; |
|
144 | - $actions['clear_cache'] = '<a href="' . esc_url( add_query_arg( array( 'clear_cache' => $post->ID ) ) ) . '">' . __( 'Clear Cache', 'google-calendar-events' ) . '</a>'; |
|
142 | + if ($post->post_type == 'calendar') { |
|
143 | + $actions['duplicate_feed'] = '<a href="'.esc_url(add_query_arg(array('duplicate_feed' => $post->ID))).'">'.__('Clone', 'google-calendar-events').'</a>'; |
|
144 | + $actions['clear_cache'] = '<a href="'.esc_url(add_query_arg(array('clear_cache' => $post->ID))).'">'.__('Clear Cache', 'google-calendar-events').'</a>'; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | return $actions; |
@@ -156,38 +156,38 @@ discard block |
||
156 | 156 | |
157 | 157 | // Clear an individual feed cache. |
158 | 158 | // @todo Convert the clear cache request to ajax. |
159 | - if ( isset( $_REQUEST['clear_cache'] ) ) { |
|
159 | + if (isset($_REQUEST['clear_cache'])) { |
|
160 | 160 | |
161 | - $id = intval( $_REQUEST['clear_cache'] ); |
|
161 | + $id = intval($_REQUEST['clear_cache']); |
|
162 | 162 | |
163 | - if ( $id > 0 ) { |
|
164 | - simcal_delete_feed_transients( $id ); |
|
163 | + if ($id > 0) { |
|
164 | + simcal_delete_feed_transients($id); |
|
165 | 165 | } |
166 | 166 | |
167 | - wp_redirect( remove_query_arg( 'clear_cache' ) ); |
|
167 | + wp_redirect(remove_query_arg('clear_cache')); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | // Duplicate a feed post type. |
171 | - if ( isset( $_REQUEST['duplicate_feed'] ) ) { |
|
171 | + if (isset($_REQUEST['duplicate_feed'])) { |
|
172 | 172 | |
173 | - $id = intval( $_REQUEST['duplicate_feed'] ); |
|
173 | + $id = intval($_REQUEST['duplicate_feed']); |
|
174 | 174 | |
175 | - if ( $id > 0 ) { |
|
176 | - $this->duplicate_feed( $id ); |
|
175 | + if ($id > 0) { |
|
176 | + $this->duplicate_feed($id); |
|
177 | 177 | } |
178 | 178 | |
179 | - wp_redirect( remove_query_arg( 'duplicate_feed' ) ); |
|
179 | + wp_redirect(remove_query_arg('duplicate_feed')); |
|
180 | 180 | } |
181 | 181 | |
182 | - $bulk_actions = new Bulk_Actions( 'calendar' ); |
|
182 | + $bulk_actions = new Bulk_Actions('calendar'); |
|
183 | 183 | |
184 | - $bulk_actions->register_bulk_action( array( |
|
185 | - 'menu_text' => __( 'Clear cache', 'google-calendar-events' ), |
|
184 | + $bulk_actions->register_bulk_action(array( |
|
185 | + 'menu_text' => __('Clear cache', 'google-calendar-events'), |
|
186 | 186 | 'action_name' => 'clear_calendars_cache', |
187 | - 'callback' => function( $post_ids ) { |
|
188 | - simcal_delete_feed_transients( $post_ids ); |
|
187 | + 'callback' => function($post_ids) { |
|
188 | + simcal_delete_feed_transients($post_ids); |
|
189 | 189 | }, |
190 | - 'admin_notice' => __( 'Cache cleared.', 'google-calendar-events' ), |
|
190 | + 'admin_notice' => __('Cache cleared.', 'google-calendar-events'), |
|
191 | 191 | ) |
192 | 192 | ); |
193 | 193 | |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | |
205 | 205 | $screen = simcal_is_admin_screen(); |
206 | 206 | |
207 | - if ( 'edit-calendar' == $screen ) { |
|
208 | - add_action( 'in_admin_footer', function() { |
|
207 | + if ('edit-calendar' == $screen) { |
|
208 | + add_action('in_admin_footer', function() { |
|
209 | 209 | |
210 | 210 | } ); |
211 | 211 | } |
@@ -218,29 +218,29 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @param int $post_id |
220 | 220 | */ |
221 | - private function duplicate_feed( $post_id ) { |
|
221 | + private function duplicate_feed($post_id) { |
|
222 | 222 | |
223 | - if ( $duplicate = get_post( intval( $post_id ), 'ARRAY_A' ) ) { |
|
223 | + if ($duplicate = get_post(intval($post_id), 'ARRAY_A')) { |
|
224 | 224 | |
225 | - if ( 'calendar' == $duplicate['post_type'] ) { |
|
225 | + if ('calendar' == $duplicate['post_type']) { |
|
226 | 226 | |
227 | - $duplicate['post_title'] = $duplicate['post_title'] . ' (' . __( 'Copy', 'google-calendar-events' ) . ')'; |
|
227 | + $duplicate['post_title'] = $duplicate['post_title'].' ('.__('Copy', 'google-calendar-events').')'; |
|
228 | 228 | |
229 | - unset( $duplicate['ID'] ); |
|
230 | - unset( $duplicate['guid'] ); |
|
231 | - unset( $duplicate['comment_count'] ); |
|
229 | + unset($duplicate['ID']); |
|
230 | + unset($duplicate['guid']); |
|
231 | + unset($duplicate['comment_count']); |
|
232 | 232 | |
233 | - $duplicate_id = wp_insert_post( $duplicate ); |
|
233 | + $duplicate_id = wp_insert_post($duplicate); |
|
234 | 234 | |
235 | - $taxonomies = get_object_taxonomies( $duplicate['post_type'] ); |
|
236 | - foreach ( $taxonomies as $taxonomy ) { |
|
237 | - $terms = wp_get_post_terms( $post_id, $taxonomy, array( 'fields' => 'names' ) ); |
|
238 | - wp_set_object_terms( $duplicate_id, $terms, $taxonomy ); |
|
235 | + $taxonomies = get_object_taxonomies($duplicate['post_type']); |
|
236 | + foreach ($taxonomies as $taxonomy) { |
|
237 | + $terms = wp_get_post_terms($post_id, $taxonomy, array('fields' => 'names')); |
|
238 | + wp_set_object_terms($duplicate_id, $terms, $taxonomy); |
|
239 | 239 | } |
240 | 240 | |
241 | - $custom_fields = get_post_custom( $post_id ); |
|
242 | - foreach ( $custom_fields as $key => $value ) { |
|
243 | - add_post_meta( $duplicate_id, $key, maybe_unserialize( $value[0] ) ); |
|
241 | + $custom_fields = get_post_custom($post_id); |
|
242 | + foreach ($custom_fields as $key => $value) { |
|
243 | + add_post_meta($duplicate_id, $key, maybe_unserialize($value[0])); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return string |
259 | 259 | */ |
260 | - public function default_event_template( $content, $post ) { |
|
260 | + public function default_event_template($content, $post) { |
|
261 | 261 | return 'calendar' == $post->post_type ? simcal_default_event_template() : $content; |
262 | 262 | } |
263 | 263 | |
@@ -270,10 +270,10 @@ discard block |
||
270 | 270 | |
271 | 271 | global $post, $post_type; |
272 | 272 | |
273 | - if ( $post_type == 'calendar' && isset( $post->ID ) ) { |
|
274 | - echo '<a id="simcal-clear-cache" class="button" data-id="' . $post->ID . ' ">' . |
|
275 | - '<i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i> ' . |
|
276 | - __( 'Clear cache', 'google-calendar-events' ) . |
|
273 | + if ($post_type == 'calendar' && isset($post->ID)) { |
|
274 | + echo '<a id="simcal-clear-cache" class="button" data-id="'.$post->ID.' ">'. |
|
275 | + '<i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i> '. |
|
276 | + __('Clear cache', 'google-calendar-events'). |
|
277 | 277 | '</a>'; |
278 | 278 | } |
279 | 279 | } |
@@ -290,20 +290,20 @@ discard block |
||
290 | 290 | |
291 | 291 | $post_types = array(); |
292 | 292 | |
293 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
294 | - if ( isset( $settings['general']['attach_calendars_posts'] ) ) { |
|
293 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
294 | + if (isset($settings['general']['attach_calendars_posts'])) { |
|
295 | 295 | $post_types = $settings['general']['attach_calendars_posts']; |
296 | 296 | } |
297 | 297 | |
298 | 298 | global $post_type; |
299 | 299 | |
300 | - if ( in_array( $post_type, $post_types ) ) { |
|
300 | + if (in_array($post_type, $post_types)) { |
|
301 | 301 | |
302 | 302 | // Thickbox will ignore height and width, will adjust these in js. |
303 | 303 | // @see https://core.trac.wordpress.org/ticket/17249 |
304 | 304 | ?> |
305 | 305 | <a href="#TB_inline?height=250&width=500&inlineId=simcal-insert-shortcode-panel" id="simcal-insert-shortcode-button" class="thickbox button insert-calendar add_calendar"> |
306 | - <span class="wp-media-buttons-icon dashicons-before dashicons-calendar-alt"></span> <?php _e( 'Add Calendar', 'google-calendar-events' ); ?> |
|
306 | + <span class="wp-media-buttons-icon dashicons-before dashicons-calendar-alt"></span> <?php _e('Add Calendar', 'google-calendar-events'); ?> |
|
307 | 307 | </a> |
308 | 308 | <?php |
309 | 309 | |
@@ -325,25 +325,25 @@ discard block |
||
325 | 325 | ?> |
326 | 326 | <div id="simcal-insert-shortcode-panel" style="display:none;"> |
327 | 327 | <div class="simcal-insert-shortcode-panel"> |
328 | - <h1><?php _e( 'Add Calendar', 'google-calendar-events' ); ?></h1> |
|
329 | - <?php _e( 'Add a calendar to your post.', 'google-calendar-events' ); ?> |
|
330 | - <?php if ( ! empty( $calendars ) && is_array( $calendars ) ) : ?> |
|
328 | + <h1><?php _e('Add Calendar', 'google-calendar-events'); ?></h1> |
|
329 | + <?php _e('Add a calendar to your post.', 'google-calendar-events'); ?> |
|
330 | + <?php if ( ! empty($calendars) && is_array($calendars)) : ?> |
|
331 | 331 | <p> |
332 | 332 | <label for="simcal-choose-calendar"> |
333 | - <?php $multiselect = count( $calendars ) > 15 ? ' simcal-field-select-enhanced' : ''; ?> |
|
333 | + <?php $multiselect = count($calendars) > 15 ? ' simcal-field-select-enhanced' : ''; ?> |
|
334 | 334 | <select id="simcal-choose-calendar" |
335 | 335 | class="simcal-field simcal-field-select<?php echo $multiselect; ?>" |
336 | 336 | name=""> |
337 | - <?php foreach ( $calendars as $id => $title ) : ?> |
|
337 | + <?php foreach ($calendars as $id => $title) : ?> |
|
338 | 338 | <option value="<?php echo $id ?>"><?php echo $title ?></option> |
339 | 339 | <?php endforeach; ?> |
340 | 340 | </select> |
341 | 341 | </label> |
342 | 342 | </p> |
343 | - <p><input type="button" value="<?php _e( 'Insert Calendar', 'google-calendar-events' ); ?>" id="simcal-insert-shortcode" class="button button-primary button-large" name="" /></p> |
|
343 | + <p><input type="button" value="<?php _e('Insert Calendar', 'google-calendar-events'); ?>" id="simcal-insert-shortcode" class="button button-primary button-large" name="" /></p> |
|
344 | 344 | <?php else : ?> |
345 | - <p><em><?php _e( 'Could not find any calendars to add to this post.', 'google-calendar-events' ); ?></em></p> |
|
346 | - <strong><a href="post-new.php?post_type=calendar"><?php _e( 'Please add and configure new calendar first.', 'google-calendar-events' ); ?></a></strong> |
|
345 | + <p><em><?php _e('Could not find any calendars to add to this post.', 'google-calendar-events'); ?></em></p> |
|
346 | + <strong><a href="post-new.php?post_type=calendar"><?php _e('Please add and configure new calendar first.', 'google-calendar-events'); ?></a></strong> |
|
347 | 347 | <?php endif; ?> |
348 | 348 | </div> |
349 | 349 | </div> |
@@ -341,8 +341,11 @@ |
||
341 | 341 | </label> |
342 | 342 | </p> |
343 | 343 | <p><input type="button" value="<?php _e( 'Insert Calendar', 'google-calendar-events' ); ?>" id="simcal-insert-shortcode" class="button button-primary button-large" name="" /></p> |
344 | - <?php else : ?> |
|
345 | - <p><em><?php _e( 'Could not find any calendars to add to this post.', 'google-calendar-events' ); ?></em></p> |
|
344 | + <?php else { |
|
345 | + : ?> |
|
346 | + <p><em><?php _e( 'Could not find any calendars to add to this post.', 'google-calendar-events' ); |
|
347 | +} |
|
348 | +?></em></p> |
|
346 | 349 | <strong><a href="post-new.php?post_type=calendar"><?php _e( 'Please add and configure new calendar first.', 'google-calendar-events' ); ?></a></strong> |
347 | 350 | <?php endif; ?> |
348 | 351 | </div> |
@@ -62,17 +62,17 @@ discard block |
||
62 | 62 | * @param string $_plugin_file Path to the plugin file. |
63 | 63 | * @param array $_api_data Optional data to send with API calls. |
64 | 64 | */ |
65 | - public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
65 | + public function __construct($_api_url, $_plugin_file, $_api_data = null) { |
|
66 | 66 | |
67 | - $this->api_url = trailingslashit( $_api_url ); |
|
67 | + $this->api_url = trailingslashit($_api_url); |
|
68 | 68 | $this->api_data = $_api_data; |
69 | - $this->name = plugin_basename( $_plugin_file ); |
|
70 | - $this->slug = basename( $_plugin_file, '.php' ); |
|
69 | + $this->name = plugin_basename($_plugin_file); |
|
70 | + $this->slug = basename($_plugin_file, '.php'); |
|
71 | 71 | $this->version = $_api_data['version']; |
72 | 72 | |
73 | 73 | // Set up hooks. |
74 | 74 | $this->init(); |
75 | - add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
75 | + add_action('admin_init', array($this, 'show_changelog')); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | * @return void |
84 | 84 | */ |
85 | 85 | public function init() { |
86 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
87 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
88 | - remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 ); |
|
89 | - add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
86 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
87 | + add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3); |
|
88 | + remove_action('after_plugin_row_'.$this->name, 'wp_plugin_update_row', 10); |
|
89 | + add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -103,30 +103,30 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return array|\stdClass Modified update array with custom plugin data. |
105 | 105 | */ |
106 | - public function check_update( $_transient_data ) { |
|
106 | + public function check_update($_transient_data) { |
|
107 | 107 | |
108 | 108 | global $pagenow; |
109 | 109 | |
110 | - if ( ! is_object( $_transient_data ) ) { |
|
110 | + if ( ! is_object($_transient_data)) { |
|
111 | 111 | $_transient_data = new \stdClass(); |
112 | 112 | } |
113 | 113 | |
114 | - if ( 'plugins.php' == $pagenow && is_multisite() ) { |
|
114 | + if ('plugins.php' == $pagenow && is_multisite()) { |
|
115 | 115 | return $_transient_data; |
116 | 116 | } |
117 | 117 | |
118 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
118 | + if (empty($_transient_data->response) || empty($_transient_data->response[$this->name])) { |
|
119 | 119 | |
120 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
120 | + $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug)); |
|
121 | 121 | |
122 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
122 | + if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) { |
|
123 | 123 | |
124 | - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
125 | - $_transient_data->response[ $this->name ] = $version_info; |
|
124 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
125 | + $_transient_data->response[$this->name] = $version_info; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | $_transient_data->last_checked = time(); |
129 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
129 | + $_transient_data->checked[$this->name] = $this->version; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | } |
@@ -144,81 +144,81 @@ discard block |
||
144 | 144 | * @param string $file |
145 | 145 | * @param array $plugin |
146 | 146 | */ |
147 | - public function show_update_notification( $file, $plugin ) { |
|
147 | + public function show_update_notification($file, $plugin) { |
|
148 | 148 | |
149 | - if ( ! current_user_can( 'update_plugins' ) ) { |
|
149 | + if ( ! current_user_can('update_plugins')) { |
|
150 | 150 | return; |
151 | 151 | } |
152 | 152 | |
153 | - if ( ! is_multisite() ) { |
|
153 | + if ( ! is_multisite()) { |
|
154 | 154 | return; |
155 | 155 | } |
156 | 156 | |
157 | - if ( $this->name != $file ) { |
|
157 | + if ($this->name != $file) { |
|
158 | 158 | return; |
159 | 159 | } |
160 | 160 | |
161 | 161 | // Remove our filter on the site transient |
162 | - remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
162 | + remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10); |
|
163 | 163 | |
164 | - $update_cache = get_site_transient( 'update_plugins' ); |
|
164 | + $update_cache = get_site_transient('update_plugins'); |
|
165 | 165 | |
166 | - if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
166 | + if ( ! is_object($update_cache) || empty($update_cache->response) || empty($update_cache->response[$this->name])) { |
|
167 | 167 | |
168 | - $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); |
|
169 | - $version_info = get_transient( $cache_key ); |
|
168 | + $cache_key = md5('edd_plugin_'.sanitize_key($this->name).'_version_info'); |
|
169 | + $version_info = get_transient($cache_key); |
|
170 | 170 | |
171 | - if ( false === $version_info ) { |
|
171 | + if (false === $version_info) { |
|
172 | 172 | |
173 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
173 | + $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug)); |
|
174 | 174 | |
175 | - set_transient( $cache_key, $version_info, 3600 ); |
|
175 | + set_transient($cache_key, $version_info, 3600); |
|
176 | 176 | } |
177 | 177 | |
178 | - if ( ! is_object( $version_info ) ) { |
|
178 | + if ( ! is_object($version_info)) { |
|
179 | 179 | return; |
180 | 180 | } |
181 | 181 | |
182 | - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
183 | - $update_cache->response[ $this->name ] = $version_info; |
|
182 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
183 | + $update_cache->response[$this->name] = $version_info; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | $update_cache->last_checked = time(); |
187 | - $update_cache->checked[ $this->name ] = $this->version; |
|
187 | + $update_cache->checked[$this->name] = $this->version; |
|
188 | 188 | |
189 | - set_site_transient( 'update_plugins', $update_cache ); |
|
189 | + set_site_transient('update_plugins', $update_cache); |
|
190 | 190 | |
191 | 191 | } else { |
192 | 192 | |
193 | - $version_info = $update_cache->response[ $this->name ]; |
|
193 | + $version_info = $update_cache->response[$this->name]; |
|
194 | 194 | |
195 | 195 | } |
196 | 196 | |
197 | 197 | // Restore our filter |
198 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
198 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
199 | 199 | |
200 | - if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
200 | + if ( ! empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) { |
|
201 | 201 | |
202 | 202 | // build a plugin list row, with update notification |
203 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
204 | - echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
203 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
204 | + echo '<tr class="plugin-update-tr"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message">'; |
|
205 | 205 | |
206 | - $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
206 | + $changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911'); |
|
207 | 207 | |
208 | - if ( empty( $version_info->download_link ) ) { |
|
208 | + if (empty($version_info->download_link)) { |
|
209 | 209 | printf( |
210 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'google-calendar-events' ), |
|
211 | - esc_html( $version_info->name ), |
|
212 | - esc_url( $changelog_link ), |
|
213 | - esc_html( $version_info->new_version ) |
|
210 | + __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'google-calendar-events'), |
|
211 | + esc_html($version_info->name), |
|
212 | + esc_url($changelog_link), |
|
213 | + esc_html($version_info->new_version) |
|
214 | 214 | ); |
215 | 215 | } else { |
216 | 216 | printf( |
217 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'google-calendar-events' ), |
|
218 | - esc_html( $version_info->name ), |
|
219 | - esc_url( $changelog_link ), |
|
220 | - esc_html( $version_info->new_version ), |
|
221 | - esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
217 | + __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'google-calendar-events'), |
|
218 | + esc_html($version_info->name), |
|
219 | + esc_url($changelog_link), |
|
220 | + esc_html($version_info->new_version), |
|
221 | + esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name)) |
|
222 | 222 | ); |
223 | 223 | } |
224 | 224 | |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return object |
240 | 240 | */ |
241 | - public function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
241 | + public function plugins_api_filter($_data, $_action = '', $_args = null) { |
|
242 | 242 | |
243 | - if ( 'plugin_information' != $_action ) { |
|
243 | + if ('plugin_information' != $_action) { |
|
244 | 244 | return $_data; |
245 | 245 | } |
246 | 246 | |
247 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
247 | + if ( ! isset($_args->slug) || ($_args->slug != $this->slug)) { |
|
248 | 248 | return $_data; |
249 | 249 | } |
250 | 250 | |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | ), |
258 | 258 | ); |
259 | 259 | |
260 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
260 | + $api_response = $this->api_request('plugin_information', $to_send); |
|
261 | 261 | |
262 | - if ( false !== $api_response ) { |
|
262 | + if (false !== $api_response) { |
|
263 | 263 | $_data = $api_response; |
264 | 264 | } |
265 | 265 | |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | * @param string $url |
277 | 277 | * @return object|array $array |
278 | 278 | */ |
279 | - public function http_request_args( $args, $url ) { |
|
279 | + public function http_request_args($args, $url) { |
|
280 | 280 | // If it is an https request and we are performing a package download, disable ssl verification |
281 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
281 | + if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) { |
|
282 | 282 | $args['sslverify'] = false; |
283 | 283 | } |
284 | 284 | return $args; |
@@ -293,42 +293,42 @@ discard block |
||
293 | 293 | * @param array $_data Parameters for the API action. |
294 | 294 | * @return false|object |
295 | 295 | */ |
296 | - private function api_request( $_action, $_data ) { |
|
296 | + private function api_request($_action, $_data) { |
|
297 | 297 | |
298 | 298 | global $wp_version; |
299 | 299 | |
300 | - $data = array_merge( $this->api_data, $_data ); |
|
300 | + $data = array_merge($this->api_data, $_data); |
|
301 | 301 | |
302 | - if ( $data['slug'] != $this->slug ) { |
|
302 | + if ($data['slug'] != $this->slug) { |
|
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
306 | - if ( empty( $data['license'] ) ) { |
|
306 | + if (empty($data['license'])) { |
|
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | - if ( $this->api_url == home_url() ) { |
|
310 | + if ($this->api_url == home_url()) { |
|
311 | 311 | return false; // Don't allow a plugin to ping itself |
312 | 312 | } |
313 | 313 | |
314 | 314 | $api_params = array( |
315 | 315 | 'edd_action' => 'get_version', |
316 | 316 | 'license' => $data['license'], |
317 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
318 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
317 | + 'item_name' => isset($data['item_name']) ? $data['item_name'] : false, |
|
318 | + 'item_id' => isset($data['item_id']) ? $data['item_id'] : false, |
|
319 | 319 | 'slug' => $data['slug'], |
320 | 320 | 'author' => $data['author'], |
321 | 321 | 'url' => home_url() |
322 | 322 | ); |
323 | 323 | |
324 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
324 | + $request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params)); |
|
325 | 325 | |
326 | - if ( ! is_wp_error( $request ) ) { |
|
327 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
326 | + if ( ! is_wp_error($request)) { |
|
327 | + $request = json_decode(wp_remote_retrieve_body($request)); |
|
328 | 328 | } |
329 | 329 | |
330 | - if ( $request && isset( $request->sections ) ) { |
|
331 | - $request->sections = maybe_unserialize( $request->sections ); |
|
330 | + if ($request && isset($request->sections)) { |
|
331 | + $request->sections = maybe_unserialize($request->sections); |
|
332 | 332 | } else { |
333 | 333 | $request = false; |
334 | 334 | } |
@@ -343,26 +343,26 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public function show_changelog() { |
345 | 345 | |
346 | - if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
346 | + if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) { |
|
347 | 347 | return; |
348 | 348 | } |
349 | 349 | |
350 | - if ( empty( $_REQUEST['plugin'] ) ) { |
|
350 | + if (empty($_REQUEST['plugin'])) { |
|
351 | 351 | return; |
352 | 352 | } |
353 | 353 | |
354 | - if ( empty( $_REQUEST['slug'] ) ) { |
|
354 | + if (empty($_REQUEST['slug'])) { |
|
355 | 355 | return; |
356 | 356 | } |
357 | 357 | |
358 | - if ( ! current_user_can( 'update_plugins' ) ) { |
|
359 | - wp_die( __( 'You do not have permission to install plugin updates', 'google-calendar-events' ), __( 'Error', 'google-calendar-events' ), array( 'response' => 403 ) ); |
|
358 | + if ( ! current_user_can('update_plugins')) { |
|
359 | + wp_die(__('You do not have permission to install plugin updates', 'google-calendar-events'), __('Error', 'google-calendar-events'), array('response' => 403)); |
|
360 | 360 | } |
361 | 361 | |
362 | - $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
362 | + $response = $this->api_request('plugin_latest_version', array('slug' => $_REQUEST['slug'])); |
|
363 | 363 | |
364 | - if ( $response && isset( $response->sections['changelog'] ) ) { |
|
365 | - echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
364 | + if ($response && isset($response->sections['changelog'])) { |
|
365 | + echo '<div style="background:#fff;padding:10px;">'.$response->sections['changelog'].'</div>'; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | exit; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Calendar_View; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @since 3.0.0 |
26 | 26 | */ |
27 | 27 | public function __construct() { |
28 | - add_action( 'init', array( $this, 'add_callbacks' ), 100 ); |
|
28 | + add_action('init', array($this, 'add_callbacks'), 100); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -37,19 +37,19 @@ discard block |
||
37 | 37 | |
38 | 38 | $calendars = simcal_get_calendar_types(); |
39 | 39 | |
40 | - foreach ( $calendars as $calendar => $views ) { |
|
40 | + foreach ($calendars as $calendar => $views) { |
|
41 | 41 | |
42 | - foreach ( $views as $view ) { |
|
42 | + foreach ($views as $view) { |
|
43 | 43 | |
44 | - $the_view = simcal_get_calendar_view( 0, $calendar . '-' . $view ); |
|
44 | + $the_view = simcal_get_calendar_view(0, $calendar.'-'.$view); |
|
45 | 45 | |
46 | - if ( $the_view instanceof Calendar_View ) { |
|
46 | + if ($the_view instanceof Calendar_View) { |
|
47 | 47 | $the_view->add_ajax_actions(); |
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - do_action( 'simcal_add_ajax_callbacks' ); |
|
52 | + do_action('simcal_add_ajax_callbacks'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Calendar_View; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -76,24 +76,24 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function __construct() { |
78 | 78 | |
79 | - $this->min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG == true ) ? '' : '.min'; |
|
79 | + $this->min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG == true) ? '' : '.min'; |
|
80 | 80 | |
81 | - $settings = get_option( 'simple-calendar_settings_advanced' ); |
|
82 | - if ( isset( $settings['assets']['disable_js'] ) ) { |
|
81 | + $settings = get_option('simple-calendar_settings_advanced'); |
|
82 | + if (isset($settings['assets']['disable_js'])) { |
|
83 | 83 | $this->disable_scripts = 'yes' == $settings['assets']['disable_js'] ? true : false; |
84 | 84 | } |
85 | 85 | |
86 | - if ( isset( $settings['assets']['disable_css'] ) ) { |
|
86 | + if (isset($settings['assets']['disable_css'])) { |
|
87 | 87 | $this->disable_styles = 'yes' == $settings['assets']['disable_css'] ? true : false; |
88 | 88 | } |
89 | 89 | |
90 | - if ( isset( $settings['assets']['always_enqueue'] ) ) { |
|
90 | + if (isset($settings['assets']['always_enqueue'])) { |
|
91 | 91 | $this->always_enqueue = 'yes' == $settings['assets']['always_enqueue'] ? true : false; |
92 | 92 | } |
93 | 93 | |
94 | - add_action( 'init', array( $this, 'register' ), 20 ); |
|
95 | - add_action( 'init', array( $this, 'enqueue' ), 40 ); |
|
96 | - add_action( 'wp_print_styles', array( $this, 'disable' ), 100 ); |
|
94 | + add_action('init', array($this, 'register'), 20); |
|
95 | + add_action('init', array($this, 'enqueue'), 40); |
|
96 | + add_action('wp_print_styles', array($this, 'disable'), 100); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @since 3.0.0 |
103 | 103 | */ |
104 | 104 | public function register() { |
105 | - do_action( 'simcal_register_assets', $this->min ); |
|
105 | + do_action('simcal_register_assets', $this->min); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -112,25 +112,25 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function enqueue() { |
114 | 114 | |
115 | - add_action( 'wp_enqueue_scripts', array( $this, 'load' ), 10 ); |
|
115 | + add_action('wp_enqueue_scripts', array($this, 'load'), 10); |
|
116 | 116 | |
117 | - do_action( 'simcal_enqueue_assets', $this->min ); |
|
117 | + do_action('simcal_enqueue_assets', $this->min); |
|
118 | 118 | |
119 | - if ( false === $this->disable_scripts ) { |
|
119 | + if (false === $this->disable_scripts) { |
|
120 | 120 | $min = $this->min; |
121 | 121 | // Improves compatibility with themes and plugins using Isotope and Masonry. |
122 | - add_action( 'wp_enqueue_scripts', |
|
123 | - function () use ( $min ) { |
|
124 | - if ( wp_script_is( 'simcal-qtip', 'enqueued' ) ) { |
|
122 | + add_action('wp_enqueue_scripts', |
|
123 | + function() use ($min) { |
|
124 | + if (wp_script_is('simcal-qtip', 'enqueued')) { |
|
125 | 125 | wp_enqueue_script( |
126 | 126 | 'simplecalendar-imagesloaded', |
127 | - SIMPLE_CALENDAR_ASSETS . 'js/vendor/imagesloaded' . $min . '.js', |
|
128 | - array( 'simcal-qtip' ), |
|
127 | + SIMPLE_CALENDAR_ASSETS.'js/vendor/imagesloaded'.$min.'.js', |
|
128 | + array('simcal-qtip'), |
|
129 | 129 | '3.1.8', |
130 | 130 | true |
131 | 131 | ); |
132 | 132 | } |
133 | - }, 1000 ); |
|
133 | + }, 1000); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -141,15 +141,15 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function load() { |
143 | 143 | |
144 | - if ( $this->always_enqueue ) { |
|
144 | + if ($this->always_enqueue) { |
|
145 | 145 | $scripts = $this->get_default_scripts(); |
146 | 146 | $styles = $this->get_default_styles(); |
147 | 147 | |
148 | - $this->scripts = apply_filters( 'simcal_front_end_scripts', $scripts, $this->min ); |
|
149 | - $this->styles = apply_filters( 'simcal_front_end_styles', $styles, $this->min ); |
|
148 | + $this->scripts = apply_filters('simcal_front_end_scripts', $scripts, $this->min); |
|
149 | + $this->styles = apply_filters('simcal_front_end_styles', $styles, $this->min); |
|
150 | 150 | |
151 | - $this->load_scripts( $this->scripts ); |
|
152 | - $this->load_styles( $this->styles ); |
|
151 | + $this->load_scripts($this->scripts); |
|
152 | + $this->load_styles($this->styles); |
|
153 | 153 | |
154 | 154 | return; |
155 | 155 | } |
@@ -158,33 +158,33 @@ discard block |
||
158 | 158 | $cal_id = array(); |
159 | 159 | $scripts = $styles = array(); |
160 | 160 | |
161 | - if ( is_singular() ) { |
|
161 | + if (is_singular()) { |
|
162 | 162 | |
163 | 163 | global $post, $post_type; |
164 | 164 | |
165 | - if ( 'calendar' == $post_type ) { |
|
165 | + if ('calendar' == $post_type) { |
|
166 | 166 | |
167 | 167 | $id = get_queried_object_id(); |
168 | 168 | |
169 | - $view = simcal_get_calendar_view( $id ); |
|
170 | - if ( $view instanceof Calendar_View ) { |
|
171 | - $scripts[] = $view->scripts( $this->min ); |
|
172 | - $styles[] = $view->styles( $this->min ); |
|
169 | + $view = simcal_get_calendar_view($id); |
|
170 | + if ($view instanceof Calendar_View) { |
|
171 | + $scripts[] = $view->scripts($this->min); |
|
172 | + $styles[] = $view->styles($this->min); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | } else { |
176 | 176 | |
177 | - $id = absint( get_post_meta( $post->ID, '_simcal_attach_calendar_id', true ) ); |
|
177 | + $id = absint(get_post_meta($post->ID, '_simcal_attach_calendar_id', true)); |
|
178 | 178 | |
179 | - if ( $id === 0 ) { |
|
179 | + if ($id === 0) { |
|
180 | 180 | |
181 | - preg_match_all( '/' . get_shortcode_regex() . '/s', $post->post_content, $matches, PREG_SET_ORDER ); |
|
181 | + preg_match_all('/'.get_shortcode_regex().'/s', $post->post_content, $matches, PREG_SET_ORDER); |
|
182 | 182 | |
183 | - if ( ! empty( $matches ) && is_array( $matches ) ) { |
|
184 | - foreach ( $matches as $shortcode ) { |
|
185 | - if ( 'calendar' === $shortcode[2] || 'gcal' === $shortcode[2] ) { |
|
186 | - $atts = shortcode_parse_atts( $shortcode[3] ); |
|
187 | - $cal_id[] = isset( $atts['id'] ) ? intval( $atts['id'] ) : 0; |
|
183 | + if ( ! empty($matches) && is_array($matches)) { |
|
184 | + foreach ($matches as $shortcode) { |
|
185 | + if ('calendar' === $shortcode[2] || 'gcal' === $shortcode[2]) { |
|
186 | + $atts = shortcode_parse_atts($shortcode[3]); |
|
187 | + $cal_id[] = isset($atts['id']) ? intval($atts['id']) : 0; |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | } |
@@ -192,41 +192,41 @@ discard block |
||
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - foreach( $cal_id as $i ) { |
|
195 | + foreach ($cal_id as $i) { |
|
196 | 196 | |
197 | - if ( $i > 0 ) { |
|
197 | + if ($i > 0) { |
|
198 | 198 | |
199 | - $view = simcal_get_calendar_view( $i ); |
|
199 | + $view = simcal_get_calendar_view($i); |
|
200 | 200 | |
201 | - if ( $view instanceof Calendar_View ) { |
|
202 | - $scripts[] = $view->scripts( $this->min ); |
|
203 | - $styles[] = $view->styles( $this->min ); |
|
201 | + if ($view instanceof Calendar_View) { |
|
202 | + $scripts[] = $view->scripts($this->min); |
|
203 | + $styles[] = $view->styles($this->min); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | 208 | $this->get_widgets_assets(); |
209 | 209 | |
210 | - $this->scripts = apply_filters( 'simcal_front_end_scripts', $scripts, $this->min ); |
|
210 | + $this->scripts = apply_filters('simcal_front_end_scripts', $scripts, $this->min); |
|
211 | 211 | |
212 | 212 | // First check if there is a multi-dimensional array of scripts |
213 | - if ( isset( $this->scripts[0] ) ) { |
|
214 | - foreach ( $this->scripts as $script ) { |
|
215 | - $this->load_scripts ( $script ); |
|
213 | + if (isset($this->scripts[0])) { |
|
214 | + foreach ($this->scripts as $script) { |
|
215 | + $this->load_scripts($script); |
|
216 | 216 | } |
217 | 217 | } else { |
218 | - $this->load_scripts( $this->scripts ); |
|
218 | + $this->load_scripts($this->scripts); |
|
219 | 219 | } |
220 | 220 | |
221 | - $this->styles = apply_filters( 'simcal_front_end_styles', $styles, $this->min ); |
|
221 | + $this->styles = apply_filters('simcal_front_end_styles', $styles, $this->min); |
|
222 | 222 | |
223 | 223 | // First check if there is a multi-dimensional array of styles |
224 | - if ( isset( $this->styles[0] ) ) { |
|
225 | - foreach( $this->styles as $style ) { |
|
226 | - $this->load_styles( $style ); |
|
224 | + if (isset($this->styles[0])) { |
|
225 | + foreach ($this->styles as $style) { |
|
226 | + $this->load_styles($style); |
|
227 | 227 | } |
228 | 228 | } else { |
229 | - $this->load_styles( $this->styles ); |
|
229 | + $this->load_styles($this->styles); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
@@ -237,25 +237,25 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function get_widgets_assets() { |
239 | 239 | |
240 | - $widgets = get_option( 'widget_gce_widget' ); |
|
240 | + $widgets = get_option('widget_gce_widget'); |
|
241 | 241 | |
242 | - if ( ! empty( $widgets ) && is_array( $widgets ) ) { |
|
242 | + if ( ! empty($widgets) && is_array($widgets)) { |
|
243 | 243 | |
244 | - foreach ( $widgets as $settings ) { |
|
244 | + foreach ($widgets as $settings) { |
|
245 | 245 | |
246 | - if ( ! empty( $settings ) && is_array( $settings ) ) { |
|
246 | + if ( ! empty($settings) && is_array($settings)) { |
|
247 | 247 | |
248 | - if ( isset( $settings['calendar_id'] ) ) { |
|
248 | + if (isset($settings['calendar_id'])) { |
|
249 | 249 | |
250 | - $view = simcal_get_calendar_view( absint( $settings['calendar_id'] ) ); |
|
250 | + $view = simcal_get_calendar_view(absint($settings['calendar_id'])); |
|
251 | 251 | |
252 | - if ( $view instanceof Calendar_View ) { |
|
253 | - add_filter( 'simcal_front_end_scripts', function ( $scripts, $min ) use ( $view ) { |
|
254 | - return array_merge( $scripts, $view->scripts( $min ) ); |
|
255 | - }, 100, 2 ); |
|
256 | - add_filter( 'simcal_front_end_styles', function ( $styles, $min ) use ( $view ) { |
|
257 | - return array_merge( $styles, $view->styles( $min ) ); |
|
258 | - }, 100, 2 ); |
|
252 | + if ($view instanceof Calendar_View) { |
|
253 | + add_filter('simcal_front_end_scripts', function($scripts, $min) use ($view) { |
|
254 | + return array_merge($scripts, $view->scripts($min)); |
|
255 | + }, 100, 2); |
|
256 | + add_filter('simcal_front_end_styles', function($styles, $min) use ($view) { |
|
257 | + return array_merge($styles, $view->styles($min)); |
|
258 | + }, 100, 2); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | } |
@@ -272,16 +272,16 @@ discard block |
||
272 | 272 | * @since 3.0.0 |
273 | 273 | */ |
274 | 274 | public function disable() { |
275 | - if ( true === $this->disable_scripts ) { |
|
276 | - $scripts = apply_filters( 'simcal_front_end_scripts', $this->scripts, $this->min ); |
|
277 | - foreach ( $scripts as $script => $v ) { |
|
278 | - wp_dequeue_script( $script ); |
|
275 | + if (true === $this->disable_scripts) { |
|
276 | + $scripts = apply_filters('simcal_front_end_scripts', $this->scripts, $this->min); |
|
277 | + foreach ($scripts as $script => $v) { |
|
278 | + wp_dequeue_script($script); |
|
279 | 279 | } |
280 | 280 | } |
281 | - if ( true === $this->disable_styles ) { |
|
282 | - $styles = apply_filters( 'simcal_front_end_styles', $this->styles, $this->min ); |
|
283 | - foreach ( $styles as $style => $v ) { |
|
284 | - wp_dequeue_style( $style ); |
|
281 | + if (true === $this->disable_styles) { |
|
282 | + $styles = apply_filters('simcal_front_end_styles', $this->styles, $this->min); |
|
283 | + foreach ($styles as $style => $v) { |
|
284 | + wp_dequeue_style($style); |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | } |
@@ -293,30 +293,30 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @param array $scripts |
295 | 295 | */ |
296 | - public function load_scripts( $scripts ) { |
|
296 | + public function load_scripts($scripts) { |
|
297 | 297 | |
298 | - if ( ! empty( $scripts ) && is_array( $scripts ) ) { |
|
298 | + if ( ! empty($scripts) && is_array($scripts)) { |
|
299 | 299 | |
300 | - foreach ( $scripts as $script => $v ) { |
|
300 | + foreach ($scripts as $script => $v) { |
|
301 | 301 | |
302 | - if ( ! empty( $v['src'] ) ) { |
|
302 | + if ( ! empty($v['src'])) { |
|
303 | 303 | |
304 | - $src = esc_url( $v['src'] ); |
|
305 | - $deps = isset( $v['deps'] ) ? $v['deps'] : array(); |
|
306 | - $ver = isset( $v['ver'] ) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
307 | - $in_footer = isset( $v['in_footer'] ) ? $v['in_footer'] : false; |
|
304 | + $src = esc_url($v['src']); |
|
305 | + $deps = isset($v['deps']) ? $v['deps'] : array(); |
|
306 | + $ver = isset($v['ver']) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
307 | + $in_footer = isset($v['in_footer']) ? $v['in_footer'] : false; |
|
308 | 308 | |
309 | - wp_enqueue_script( $script, $src, $deps, $ver, $in_footer ); |
|
309 | + wp_enqueue_script($script, $src, $deps, $ver, $in_footer); |
|
310 | 310 | |
311 | - if ( ! empty( $v['localize'] ) && is_array( $v['localize'] ) ) { |
|
312 | - foreach ( $v['localize'] as $object => $l10n ) { |
|
313 | - wp_localize_script( $script, $object, $l10n ); |
|
311 | + if ( ! empty($v['localize']) && is_array($v['localize'])) { |
|
312 | + foreach ($v['localize'] as $object => $l10n) { |
|
313 | + wp_localize_script($script, $object, $l10n); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | |
317 | - } elseif ( is_string( $v ) && ! empty( $v ) ) { |
|
317 | + } elseif (is_string($v) && ! empty($v)) { |
|
318 | 318 | |
319 | - wp_enqueue_script( $v ); |
|
319 | + wp_enqueue_script($v); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
@@ -330,24 +330,24 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @param array $styles |
332 | 332 | */ |
333 | - public function load_styles( $styles ) { |
|
333 | + public function load_styles($styles) { |
|
334 | 334 | |
335 | - if ( ! empty( $styles ) && is_array( $styles ) ) { |
|
335 | + if ( ! empty($styles) && is_array($styles)) { |
|
336 | 336 | |
337 | - foreach ( $styles as $style => $v ) { |
|
337 | + foreach ($styles as $style => $v) { |
|
338 | 338 | |
339 | - if ( ! empty( $v['src'] ) ) { |
|
339 | + if ( ! empty($v['src'])) { |
|
340 | 340 | |
341 | - $src = esc_url( $v['src'] ); |
|
342 | - $deps = isset( $v['deps'] ) ? $v['deps'] : array(); |
|
343 | - $ver = isset( $v['ver'] ) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
344 | - $media = isset( $v['media'] ) ? $v['media'] : 'all'; |
|
341 | + $src = esc_url($v['src']); |
|
342 | + $deps = isset($v['deps']) ? $v['deps'] : array(); |
|
343 | + $ver = isset($v['ver']) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
344 | + $media = isset($v['media']) ? $v['media'] : 'all'; |
|
345 | 345 | |
346 | - wp_enqueue_style( $style, $src, $deps, $ver, $media ); |
|
346 | + wp_enqueue_style($style, $src, $deps, $ver, $media); |
|
347 | 347 | |
348 | - } elseif ( is_string( $v ) && ! empty( $v ) ) { |
|
348 | + } elseif (is_string($v) && ! empty($v)) { |
|
349 | 349 | |
350 | - wp_enqueue_style( $v ); |
|
350 | + wp_enqueue_style($v); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | } |
@@ -363,13 +363,13 @@ discard block |
||
363 | 363 | public function get_default_scripts() { |
364 | 364 | return array( |
365 | 365 | 'simcal-qtip' => array( |
366 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $this->min . '.js', |
|
367 | - 'deps' => array( 'jquery' ), |
|
366 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$this->min.'.js', |
|
367 | + 'deps' => array('jquery'), |
|
368 | 368 | 'ver' => '2.2.1', |
369 | 369 | 'in_footer' => true, |
370 | 370 | ), |
371 | 371 | 'simcal-default-calendar' => array( |
372 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $this->min . '.js', |
|
372 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$this->min.'.js', |
|
373 | 373 | 'deps' => array( |
374 | 374 | 'jquery', |
375 | 375 | 'simcal-qtip', |
@@ -391,12 +391,12 @@ discard block |
||
391 | 391 | public function get_default_styles() { |
392 | 392 | return array( |
393 | 393 | 'simcal-qtip' => array( |
394 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/vendor/qtip' . $this->min . '.css', |
|
394 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/vendor/qtip'.$this->min.'.css', |
|
395 | 395 | 'ver' => '2.2.1', |
396 | 396 | 'media' => 'all', |
397 | 397 | ), |
398 | 398 | 'simcal-default-calendar-grid' => array( |
399 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-grid' . $this->min . '.css', |
|
399 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-grid'.$this->min.'.css', |
|
400 | 400 | 'deps' => array( |
401 | 401 | 'simcal-qtip', |
402 | 402 | ), |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | 'media' => 'all', |
405 | 405 | ), |
406 | 406 | 'simcal-default-calendar-list' => array( |
407 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-list' . $this->min . '.css', |
|
407 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-list'.$this->min.'.css', |
|
408 | 408 | 'deps' => array( |
409 | 409 | 'simcal-qtip', |
410 | 410 | ), |
@@ -5,11 +5,11 @@ discard block |
||
5 | 5 | * @package SimpleCalendar |
6 | 6 | */ |
7 | 7 | |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if ( ! defined('ABSPATH')) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | 11 | |
12 | -if ( ! function_exists( 'SimpleCalendar_Autoload' ) ) { |
|
12 | +if ( ! function_exists('SimpleCalendar_Autoload')) { |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Plugin autoloader. |
@@ -22,31 +22,31 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param $class |
24 | 24 | */ |
25 | - function SimpleCalendar_Autoload( $class ) { |
|
25 | + function SimpleCalendar_Autoload($class) { |
|
26 | 26 | |
27 | 27 | // Do not load unless in plugin domain. |
28 | 28 | $namespace = 'SimpleCalendar'; |
29 | - if ( strpos( $class, $namespace ) !== 0 ) { |
|
29 | + if (strpos($class, $namespace) !== 0) { |
|
30 | 30 | return; |
31 | 31 | } |
32 | 32 | |
33 | 33 | // Converts Class_Name (class convention) to class-name (file convention). |
34 | - $class_name = implode( '-', array_map( 'lcfirst', explode( '_', strtolower( $class ) ) ) ); |
|
34 | + $class_name = implode('-', array_map('lcfirst', explode('_', strtolower($class)))); |
|
35 | 35 | |
36 | 36 | // Remove the root namespace. |
37 | - $unprefixed = substr( $class_name, strlen( $namespace ) ); |
|
37 | + $unprefixed = substr($class_name, strlen($namespace)); |
|
38 | 38 | |
39 | 39 | // Build the file path. |
40 | - $file_path = str_replace( '\\', DIRECTORY_SEPARATOR, $unprefixed ); |
|
41 | - $file = dirname( __FILE__ ) . '/' . $file_path . '.php'; |
|
40 | + $file_path = str_replace('\\', DIRECTORY_SEPARATOR, $unprefixed); |
|
41 | + $file = dirname(__FILE__).'/'.$file_path.'.php'; |
|
42 | 42 | |
43 | - if ( file_exists( $file ) ) { |
|
43 | + if (file_exists($file)) { |
|
44 | 44 | require $file; |
45 | 45 | } |
46 | 46 | |
47 | 47 | } |
48 | 48 | |
49 | 49 | // Register the autoloader. |
50 | - spl_autoload_register( 'SimpleCalendar_Autoload' ); |
|
50 | + spl_autoload_register('SimpleCalendar_Autoload'); |
|
51 | 51 | |
52 | 52 | } |
@@ -453,10 +453,12 @@ |
||
453 | 453 | $list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>'; |
454 | 454 | endif; |
455 | 455 | |
456 | - else : |
|
456 | + else { |
|
457 | + : |
|
457 | 458 | |
458 | 459 | // Empty cell for day with no events. |
459 | 460 | $list_events = '<span class="simcal-no-events"></span>'; |
461 | + } |
|
460 | 462 | |
461 | 463 | endif; |
462 | 464 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | use SimpleCalendar\Events\Event; |
14 | 14 | use SimpleCalendar\Calendars\Default_Calendar; |
15 | 15 | |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @param string|Calendar $calendar |
57 | 57 | */ |
58 | - public function __construct( $calendar = '' ) { |
|
58 | + public function __construct($calendar = '') { |
|
59 | 59 | $this->calendar = $calendar; |
60 | 60 | } |
61 | 61 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return string |
90 | 90 | */ |
91 | 91 | public function get_name() { |
92 | - return __( 'Grid', 'google-calendar-events' ); |
|
92 | + return __('Grid', 'google-calendar-events'); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @since 3.0.0 |
99 | 99 | */ |
100 | 100 | public function add_ajax_actions() { |
101 | - add_action( 'wp_ajax_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) ); |
|
102 | - add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) ); |
|
101 | + add_action('wp_ajax_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax')); |
|
102 | + add_action('wp_ajax_nopriv_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax')); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -113,16 +113,16 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return array |
115 | 115 | */ |
116 | - public function scripts( $min = '' ) { |
|
116 | + public function scripts($min = '') { |
|
117 | 117 | return array( |
118 | 118 | 'simcal-qtip' => array( |
119 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js', |
|
120 | - 'deps' => array( 'jquery' ), |
|
119 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$min.'.js', |
|
120 | + 'deps' => array('jquery'), |
|
121 | 121 | 'ver' => '2.2.1', |
122 | 122 | 'in_footer' => true, |
123 | 123 | ), |
124 | 124 | 'simcal-default-calendar' => array( |
125 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js', |
|
125 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js', |
|
126 | 126 | 'deps' => array( |
127 | 127 | 'jquery', |
128 | 128 | 'simcal-qtip', |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return array |
149 | 149 | */ |
150 | - public function styles( $min = '' ) { |
|
150 | + public function styles($min = '') { |
|
151 | 151 | return array( |
152 | 152 | 'simcal-qtip' => array( |
153 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/vendor/qtip' . $min . '.css', |
|
153 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/vendor/qtip'.$min.'.css', |
|
154 | 154 | 'ver' => '2.2.1', |
155 | 155 | 'media' => 'all', |
156 | 156 | ), |
157 | 157 | 'simcal-default-calendar-grid' => array( |
158 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-grid' . $min . '.css', |
|
158 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-grid'.$min.'.css', |
|
159 | 159 | 'deps' => array( |
160 | 160 | 'simcal-qtip', |
161 | 161 | ), |
@@ -174,16 +174,16 @@ discard block |
||
174 | 174 | |
175 | 175 | $calendar = $this->calendar; |
176 | 176 | |
177 | - if ( $calendar instanceof Default_Calendar ) { |
|
177 | + if ($calendar instanceof Default_Calendar) { |
|
178 | 178 | |
179 | 179 | ?> |
180 | 180 | <table class="simcal-calendar-grid" |
181 | 181 | data-event-bubble-trigger="<?php echo $calendar->event_bubble_trigger; ?>"> |
182 | 182 | <thead class="simcal-calendar-head"> |
183 | 183 | <tr> |
184 | - <?php if ( ! $calendar->static ) { ?> |
|
184 | + <?php if ( ! $calendar->static) { ?> |
|
185 | 185 | <th class="simcal-nav simcal-prev-wrapper" colspan="1"> |
186 | - <button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e( 'Previous Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-left"></i></button> |
|
186 | + <button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e('Previous Month', 'google-calendar-events'); ?>"><i class="simcal-icon-left"></i></button> |
|
187 | 187 | </th> |
188 | 188 | <?php } ?> |
189 | 189 | <th colspan="<?php echo $calendar->static ? '7' : '5'; ?>" |
@@ -195,26 +195,26 @@ discard block |
||
195 | 195 | |
196 | 196 | // Display month and year according to user date format preference. |
197 | 197 | |
198 | - $year_pos = strcspn( $calendar->date_format, 'Y y' ); |
|
199 | - $month_pos = strcspn( $calendar->date_format, 'F M m n' ); |
|
198 | + $year_pos = strcspn($calendar->date_format, 'Y y'); |
|
199 | + $month_pos = strcspn($calendar->date_format, 'F M m n'); |
|
200 | 200 | |
201 | - $current = array( 'month' => 'F', 'year' => 'Y' ); |
|
201 | + $current = array('month' => 'F', 'year' => 'Y'); |
|
202 | 202 | |
203 | - if ( $year_pos < $month_pos ) { |
|
204 | - $current = array_reverse( $current ); |
|
203 | + if ($year_pos < $month_pos) { |
|
204 | + $current = array_reverse($current); |
|
205 | 205 | } |
206 | 206 | |
207 | - foreach ( $current as $k => $v ) { |
|
208 | - echo ' <span class="simcal-current-' . $k , '">' . date_i18n( $v, $calendar->start ) . '</span> '; |
|
207 | + foreach ($current as $k => $v) { |
|
208 | + echo ' <span class="simcal-current-'.$k, '">'.date_i18n($v, $calendar->start).'</span> '; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | echo '</h3>'; |
212 | 212 | |
213 | 213 | ?> |
214 | 214 | </th> |
215 | - <?php if ( ! $calendar->static ) { ?> |
|
215 | + <?php if ( ! $calendar->static) { ?> |
|
216 | 216 | <th class="simcal-nav simcal-next-wrapper" colspan="1"> |
217 | - <button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e( 'Next Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-right"></i></button> |
|
217 | + <button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e('Next Month', 'google-calendar-events'); ?>"><i class="simcal-icon-right"></i></button> |
|
218 | 218 | </th> |
219 | 219 | <?php } ?> |
220 | 220 | </tr> |
@@ -224,28 +224,28 @@ discard block |
||
224 | 224 | // Print day names in short or long form for different viewport sizes. |
225 | 225 | |
226 | 226 | $week_starts = $calendar->week_starts; |
227 | - $week_days_short = simcal_get_calendar_names_i18n( 'day', 'short' ); |
|
228 | - $week_days_full = simcal_get_calendar_names_i18n( 'day', 'full' ); |
|
227 | + $week_days_short = simcal_get_calendar_names_i18n('day', 'short'); |
|
228 | + $week_days_full = simcal_get_calendar_names_i18n('day', 'full'); |
|
229 | 229 | |
230 | - for ( $i = $week_starts; $i <= 6; $i ++ ) : |
|
230 | + for ($i = $week_starts; $i <= 6; $i++) : |
|
231 | 231 | |
232 | 232 | ?> |
233 | 233 | <th class="simcal-week-day simcal-week-day-<?php echo $i ?>" |
234 | - data-screen-small="<?php echo mb_substr( $week_days_short[ $i ], 0, 1, 'UTF-8' ); ?>" |
|
235 | - data-screen-medium="<?php echo $week_days_short[ $i ]; ?>" |
|
236 | - data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th> |
|
234 | + data-screen-small="<?php echo mb_substr($week_days_short[$i], 0, 1, 'UTF-8'); ?>" |
|
235 | + data-screen-medium="<?php echo $week_days_short[$i]; ?>" |
|
236 | + data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th> |
|
237 | 237 | <?php |
238 | 238 | |
239 | 239 | endfor; |
240 | 240 | |
241 | - if ( $week_starts !== 0 ) : |
|
242 | - for ( $i = 0; $i < $week_starts; $i ++ ) : |
|
241 | + if ($week_starts !== 0) : |
|
242 | + for ($i = 0; $i < $week_starts; $i++) : |
|
243 | 243 | |
244 | 244 | ?> |
245 | 245 | <th class="simcal-week-day simcal-week-day-<?php echo $i ?>" |
246 | - data-screen-small="<?php echo substr( $week_days_short[ $i ], 0, 1 ); ?>" |
|
247 | - data-screen-medium="<?php echo $week_days_short[ $i ]; ?>" |
|
248 | - data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th> |
|
246 | + data-screen-small="<?php echo substr($week_days_short[$i], 0, 1); ?>" |
|
247 | + data-screen-medium="<?php echo $week_days_short[$i]; ?>" |
|
248 | + data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th> |
|
249 | 249 | <?php |
250 | 250 | |
251 | 251 | endfor; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | </tr> |
256 | 256 | </thead> |
257 | 257 | |
258 | - <?php echo $this->draw_month( date( 'n', $calendar->start ), date( 'Y', $calendar->start ) ); ?> |
|
258 | + <?php echo $this->draw_month(date('n', $calendar->start), date('Y', $calendar->start)); ?> |
|
259 | 259 | |
260 | 260 | </table> |
261 | 261 | <?php |
@@ -280,82 +280,82 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return string |
282 | 282 | */ |
283 | - private function draw_month( $month, $year, $id = 0 ) { |
|
283 | + private function draw_month($month, $year, $id = 0) { |
|
284 | 284 | |
285 | 285 | $calendar = $this->calendar; |
286 | - if ( empty( $calendar ) ) { |
|
287 | - $calendar = simcal_get_calendar( intval( $id ) ); |
|
288 | - if ( ! $calendar ) { |
|
286 | + if (empty($calendar)) { |
|
287 | + $calendar = simcal_get_calendar(intval($id)); |
|
288 | + if ( ! $calendar) { |
|
289 | 289 | return ''; |
290 | 290 | } |
291 | 291 | } |
292 | - date_default_timezone_set( $calendar->timezone ); |
|
292 | + date_default_timezone_set($calendar->timezone); |
|
293 | 293 | $events = $calendar->events; |
294 | 294 | |
295 | 295 | // Variables to cycle days in current month and find today in calendar. |
296 | 296 | $now = $calendar->now; |
297 | - $current = Carbon::create( $year, $month, 1, 0, 0, 59, $calendar->timezone ); |
|
297 | + $current = Carbon::create($year, $month, 1, 0, 0, 59, $calendar->timezone); |
|
298 | 298 | $current_min = $current->getTimestamp(); |
299 | 299 | $current_max = $current->endOfDay()->getTimestamp(); |
300 | 300 | |
301 | 301 | // Calendar grid variables. |
302 | 302 | $week_starts = $calendar->week_starts; |
303 | - $week_of_year = $current->weekOfYear; // Relative count of the week number of the year. |
|
304 | - $month_starts = $current->dayOfWeek; // Day upon which the month starts. |
|
305 | - $days_in_month = $current->daysInMonth; // Number of days in the given month. |
|
303 | + $week_of_year = $current->weekOfYear; // Relative count of the week number of the year. |
|
304 | + $month_starts = $current->dayOfWeek; // Day upon which the month starts. |
|
305 | + $days_in_month = $current->daysInMonth; // Number of days in the given month. |
|
306 | 306 | |
307 | 307 | // Set current month events timestamp boundaries. |
308 | 308 | $this->start = $current_min; |
309 | 309 | $this->end = $current->endOfMonth()->timestamp; |
310 | 310 | |
311 | 311 | // Get daily events for this month. |
312 | - if ( $events && is_array( $events ) ) { |
|
312 | + if ($events && is_array($events)) { |
|
313 | 313 | |
314 | 314 | // Filter events within the boundaries previously set above. |
315 | - $timestamps = array_keys( $events ); |
|
316 | - $lower_bound = array_filter( $timestamps, array( $this, 'filter_events_before' ) ); |
|
317 | - $higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after' ) ); |
|
318 | - $filtered = ( is_array( $events ) && is_array( $higher_bound) ) && ! empty( $events ) && ! empty( $higher_bound ) ? array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) ) : array(); |
|
315 | + $timestamps = array_keys($events); |
|
316 | + $lower_bound = array_filter($timestamps, array($this, 'filter_events_before')); |
|
317 | + $higher_bound = array_filter($lower_bound, array($this, 'filter_events_after')); |
|
318 | + $filtered = (is_array($events) && is_array($higher_bound)) && ! empty($events) && ! empty($higher_bound) ? array_intersect_key($events, array_combine($higher_bound, $higher_bound)) : array(); |
|
319 | 319 | |
320 | 320 | // Put resulting events in an associative array, with day of the month as key for easy retrieval in calendar days loop. |
321 | 321 | $day_events = array(); |
322 | - foreach ( $filtered as $timestamp => $events_in_day ) { |
|
323 | - foreach ( $events_in_day as $event ) { |
|
324 | - if ( $event instanceof Event ){ |
|
325 | - $day = intval( Carbon::createFromTimestamp( $timestamp, $event->timezone )->endOfDay()->day ); |
|
326 | - $day_events[ $day ][] = $event; |
|
322 | + foreach ($filtered as $timestamp => $events_in_day) { |
|
323 | + foreach ($events_in_day as $event) { |
|
324 | + if ($event instanceof Event) { |
|
325 | + $day = intval(Carbon::createFromTimestamp($timestamp, $event->timezone)->endOfDay()->day); |
|
326 | + $day_events[$day][] = $event; |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
331 | - ksort( $day_events, SORT_NUMERIC ); |
|
331 | + ksort($day_events, SORT_NUMERIC); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | ob_start(); |
335 | 335 | |
336 | - echo '<tbody class="simcal-month simcal-month-' . $month . '">' . "\n"; |
|
337 | - echo "\t" . '<tr class="simcal-week simcal-week-' . $week_of_year . '">'; |
|
336 | + echo '<tbody class="simcal-month simcal-month-'.$month.'">'."\n"; |
|
337 | + echo "\t".'<tr class="simcal-week simcal-week-'.$week_of_year.'">'; |
|
338 | 338 | |
339 | 339 | $days_in_row = 0; |
340 | 340 | // Week may start on an arbitrary day (sun, 0 - sat, 6). |
341 | 341 | $week_day = $week_starts; |
342 | 342 | |
343 | 343 | // This fixes a possible bug when a month starts by Sunday (0). |
344 | - if ( 0 !== $week_starts ) { |
|
344 | + if (0 !== $week_starts) { |
|
345 | 345 | $b = $month_starts === 0 ? 7 : $month_starts; |
346 | 346 | } else { |
347 | 347 | $b = $month_starts; |
348 | 348 | } |
349 | 349 | |
350 | 350 | // Void days in first week. |
351 | - for ( $a = $week_starts; $a < $b; $a++ ) : |
|
351 | + for ($a = $week_starts; $a < $b; $a++) : |
|
352 | 352 | |
353 | - $last_void_day_class = ( $a === ( $b - 1 ) ) ? 'simcal-day-void-last' : ''; |
|
353 | + $last_void_day_class = ($a === ($b - 1)) ? 'simcal-day-void-last' : ''; |
|
354 | 354 | |
355 | - echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n"; |
|
355 | + echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n"; |
|
356 | 356 | |
357 | 357 | // Reset day of the week count (sun, 0 - sat, 6). |
358 | - if ( $week_day === 6 ) { |
|
358 | + if ($week_day === 6) { |
|
359 | 359 | $week_day = -1; |
360 | 360 | } |
361 | 361 | $week_day++; |
@@ -365,91 +365,91 @@ discard block |
||
365 | 365 | endfor; |
366 | 366 | |
367 | 367 | // Actual days of the month. |
368 | - for ( $day = 1; $day <= $days_in_month; $day++ ) : |
|
368 | + for ($day = 1; $day <= $days_in_month; $day++) : |
|
369 | 369 | |
370 | 370 | $count = 0; |
371 | 371 | $calendar_classes = array(); |
372 | - $day_classes = 'simcal-day-' . $day . ' simcal-weekday-' . $week_day; |
|
372 | + $day_classes = 'simcal-day-'.$day.' simcal-weekday-'.$week_day; |
|
373 | 373 | |
374 | 374 | $border_style = $bg_color = $color = ''; |
375 | 375 | |
376 | 376 | // Is this the present, the past or the future, Doc? |
377 | - if ( $current_min <= $now && $current_max >= $now ) { |
|
377 | + if ($current_min <= $now && $current_max >= $now) { |
|
378 | 378 | $day_classes .= ' simcal-today simcal-present simcal-day'; |
379 | - $the_color = new Color( $calendar->today_color ); |
|
380 | - $bg_color = '#' . $the_color->getHex(); |
|
379 | + $the_color = new Color($calendar->today_color); |
|
380 | + $bg_color = '#'.$the_color->getHex(); |
|
381 | 381 | $color = $the_color->isDark() ? '#ffffff' : '#000000'; |
382 | - $border_style = ' style="border: 1px solid ' . $bg_color . ';"'; |
|
383 | - } elseif ( $current_max < $now ) { |
|
382 | + $border_style = ' style="border: 1px solid '.$bg_color.';"'; |
|
383 | + } elseif ($current_max < $now) { |
|
384 | 384 | $day_classes .= ' simcal-past simcal-day'; |
385 | - } elseif ( $current_min > $now ) { |
|
385 | + } elseif ($current_min > $now) { |
|
386 | 386 | $day_classes .= ' simcal-future simcal-day'; |
387 | 387 | } |
388 | 388 | |
389 | 389 | // Print events for the current day in loop, if found any. |
390 | - if ( isset( $day_events[ $day ] ) ) : |
|
390 | + if (isset($day_events[$day])) : |
|
391 | 391 | |
392 | 392 | $list_events = '<ul class="simcal-events">'; |
393 | 393 | |
394 | - foreach ( $day_events[ $day ] as $event ) : |
|
394 | + foreach ($day_events[$day] as $event) : |
|
395 | 395 | |
396 | 396 | $event_classes = $event_visibility = ''; |
397 | 397 | |
398 | - if ( $event instanceof Event ) : |
|
398 | + if ($event instanceof Event) : |
|
399 | 399 | |
400 | 400 | // Store the calendar id where the event belongs (useful in grouped calendar feeds) |
401 | - $calendar_class = 'simcal-events-calendar-' . strval( $event->calendar ); |
|
402 | - $calendar_classes[] = $calendar_class ; |
|
401 | + $calendar_class = 'simcal-events-calendar-'.strval($event->calendar); |
|
402 | + $calendar_classes[] = $calendar_class; |
|
403 | 403 | |
404 | 404 | $recurring = $event->recurrence ? 'simcal-event-recurring ' : ''; |
405 | 405 | $has_location = $event->venue ? 'simcal-event-has-location ' : ''; |
406 | 406 | |
407 | - $event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class . ' simcal-tooltip'; |
|
407 | + $event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class.' simcal-tooltip'; |
|
408 | 408 | |
409 | 409 | // Toggle some events visibility if more than optional limit. |
410 | - if ( ( $calendar->events_limit > -1 ) && ( $count >= $calendar->events_limit ) ) : |
|
410 | + if (($calendar->events_limit > -1) && ($count >= $calendar->events_limit)) : |
|
411 | 411 | $event_classes .= ' simcal-event-toggled'; |
412 | 412 | $event_visibility = ' style="display: none"'; |
413 | 413 | endif; |
414 | 414 | |
415 | 415 | // Event title in list. |
416 | - $title = ! empty( $event->title ) ? trim( $event->title ) : __( 'Event', 'google-calendar-events' ); |
|
417 | - if ( $calendar->trim_titles >= 1 ) { |
|
418 | - $title = strlen( $title ) > $calendar->trim_titles ? mb_substr( $title, 0, $calendar->trim_titles ) . '…' : $title; |
|
416 | + $title = ! empty($event->title) ? trim($event->title) : __('Event', 'google-calendar-events'); |
|
417 | + if ($calendar->trim_titles >= 1) { |
|
418 | + $title = strlen($title) > $calendar->trim_titles ? mb_substr($title, 0, $calendar->trim_titles).'…' : $title; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | // Event color. |
422 | 422 | $bullet = ''; |
423 | 423 | $event_color = $event->get_color(); |
424 | - if ( ! empty( $event_color ) ) { |
|
425 | - $bullet = '<span style="color: ' . $event_color . ';">■</span> '; |
|
424 | + if ( ! empty($event_color)) { |
|
425 | + $bullet = '<span style="color: '.$event_color.';">■</span> '; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | // Event contents. |
429 | - $list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . ' itemprop="event" itemscope itemtype="http://schema.org/Event">' . "\n"; |
|
430 | - $list_events .= "\t\t" . '<span class="simcal-event-title">' . $bullet . $title . '</span>' . "\n"; |
|
431 | - $list_events .= "\t\t" . '<div class="simcal-event-details simcal-tooltip-content" style="display: none;">' . $calendar->get_event_html( $event ) . '</div>' . "\n"; |
|
432 | - $list_events .= "\t" . '</li>' . "\n"; |
|
429 | + $list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.' itemprop="event" itemscope itemtype="http://schema.org/Event">'."\n"; |
|
430 | + $list_events .= "\t\t".'<span class="simcal-event-title">'.$bullet.$title.'</span>'."\n"; |
|
431 | + $list_events .= "\t\t".'<div class="simcal-event-details simcal-tooltip-content" style="display: none;">'.$calendar->get_event_html($event).'</div>'."\n"; |
|
432 | + $list_events .= "\t".'</li>'."\n"; |
|
433 | 433 | |
434 | - $count ++; |
|
434 | + $count++; |
|
435 | 435 | |
436 | 436 | endif; |
437 | 437 | |
438 | 438 | endforeach; |
439 | 439 | |
440 | - if ( ( $current_min <= $now ) && ( $current_max >= $now ) ) { |
|
440 | + if (($current_min <= $now) && ($current_max >= $now)) { |
|
441 | 441 | $day_classes .= ' simcal-today-has-events'; |
442 | 442 | } |
443 | - $day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events'; |
|
443 | + $day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events'; |
|
444 | 444 | |
445 | - if ( $calendar_classes ) { |
|
446 | - $day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) ); |
|
445 | + if ($calendar_classes) { |
|
446 | + $day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes))); |
|
447 | 447 | } |
448 | 448 | |
449 | - $list_events .= '</ul>' . "\n"; |
|
449 | + $list_events .= '</ul>'."\n"; |
|
450 | 450 | |
451 | 451 | // Optional button to toggle hidden events in list. |
452 | - if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) : |
|
452 | + if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) : |
|
453 | 453 | $list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>'; |
454 | 454 | endif; |
455 | 455 | |
@@ -461,49 +461,49 @@ discard block |
||
461 | 461 | endif; |
462 | 462 | |
463 | 463 | // The actual days with numbers and events in each row cell. |
464 | - echo '<td class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n"; |
|
465 | - |
|
466 | - if ( $color ) { |
|
467 | - $day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"'; |
|
468 | - } elseif ( $count > 0 ) { |
|
469 | - $the_color = new Color( $calendar->days_events_color ); |
|
470 | - $color = ! $color ? ( $the_color->isDark() ? '#ffffff' : '#000000' ) : $color; |
|
471 | - $bg_color = ! $bg_color ? '#' . $the_color->getHex() : $bg_color; |
|
472 | - $day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"'; |
|
464 | + echo '<td class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n"; |
|
465 | + |
|
466 | + if ($color) { |
|
467 | + $day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"'; |
|
468 | + } elseif ($count > 0) { |
|
469 | + $the_color = new Color($calendar->days_events_color); |
|
470 | + $color = ! $color ? ($the_color->isDark() ? '#ffffff' : '#000000') : $color; |
|
471 | + $bg_color = ! $bg_color ? '#'.$the_color->getHex() : $bg_color; |
|
472 | + $day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"'; |
|
473 | 473 | } else { |
474 | 474 | $day_style = ''; |
475 | 475 | } |
476 | 476 | |
477 | - echo "\t" . '<div' . $border_style . '>' . "\n"; |
|
478 | - echo "\t\t" . '<span class="simcal-day-label simcal-day-number"' . $day_style . '>' . $day . '</span>' . "\n"; |
|
479 | - echo "\t\t" . $list_events . "\n"; |
|
477 | + echo "\t".'<div'.$border_style.'>'."\n"; |
|
478 | + echo "\t\t".'<span class="simcal-day-label simcal-day-number"'.$day_style.'>'.$day.'</span>'."\n"; |
|
479 | + echo "\t\t".$list_events."\n"; |
|
480 | 480 | echo "\t\t"; |
481 | 481 | echo '<span class="simcal-events-dots" style="display: none;">'; |
482 | 482 | |
483 | 483 | // Event bullets for calendar mobile mode. |
484 | - for( $i = 0; $i < $count; $i++ ) { |
|
484 | + for ($i = 0; $i < $count; $i++) { |
|
485 | 485 | echo '<b> • </b>'; |
486 | 486 | } |
487 | 487 | |
488 | - echo '</span>' . "\n"; |
|
489 | - echo "\t" . '</div>' . "\n"; |
|
490 | - echo '</td>' . "\n"; |
|
488 | + echo '</span>'."\n"; |
|
489 | + echo "\t".'</div>'."\n"; |
|
490 | + echo '</td>'."\n"; |
|
491 | 491 | |
492 | 492 | // Reset day of the week count (sun, 0 - sat, 6). |
493 | - if ( $week_day === 6 ) { |
|
493 | + if ($week_day === 6) { |
|
494 | 494 | $week_day = - 1; |
495 | 495 | } |
496 | 496 | $week_day++; |
497 | 497 | |
498 | 498 | // Reset count of days for this row (0-6). |
499 | - if ( $days_in_row === 6 ) : |
|
499 | + if ($days_in_row === 6) : |
|
500 | 500 | |
501 | 501 | // Close the week row. |
502 | 502 | echo '</tr>'; |
503 | 503 | |
504 | 504 | // Open a new week row. |
505 | - if ( $day < $days_in_month ) { |
|
506 | - echo '<tr class="simcal-week simcal-week-' . $week_of_year++ . '">' . "\n"; |
|
505 | + if ($day < $days_in_month) { |
|
506 | + echo '<tr class="simcal-week simcal-week-'.$week_of_year++.'">'."\n"; |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | $days_in_row = -1; |
@@ -512,27 +512,27 @@ discard block |
||
512 | 512 | |
513 | 513 | $days_in_row++; |
514 | 514 | |
515 | - $current_min = Carbon::createFromTimestamp( $current_min, $calendar->timezone )->addDay()->getTimestamp(); |
|
516 | - $current_max = Carbon::createFromTimestamp( $current_max, $calendar->timezone )->addDay()->getTimestamp(); |
|
515 | + $current_min = Carbon::createFromTimestamp($current_min, $calendar->timezone)->addDay()->getTimestamp(); |
|
516 | + $current_max = Carbon::createFromTimestamp($current_max, $calendar->timezone)->addDay()->getTimestamp(); |
|
517 | 517 | |
518 | 518 | endfor; |
519 | 519 | |
520 | 520 | // Void days at the end of the month. |
521 | - $remainder_days = ( 6 - $days_in_row ); |
|
521 | + $remainder_days = (6 - $days_in_row); |
|
522 | 522 | |
523 | - for ( $i = 0; $i <= $remainder_days; $i ++ ) { |
|
523 | + for ($i = 0; $i <= $remainder_days; $i++) { |
|
524 | 524 | |
525 | - $last_void_day_class = ( $i == $remainder_days ) ? 'simcal-day-void-last' : ''; |
|
525 | + $last_void_day_class = ($i == $remainder_days) ? 'simcal-day-void-last' : ''; |
|
526 | 526 | |
527 | - echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n"; |
|
527 | + echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n"; |
|
528 | 528 | |
529 | 529 | $week_day++; |
530 | 530 | } |
531 | 531 | |
532 | - echo "\t" . '</tr>' . "\n"; |
|
533 | - echo '</tbody>' . "\n"; |
|
532 | + echo "\t".'</tr>'."\n"; |
|
533 | + echo '</tbody>'."\n"; |
|
534 | 534 | |
535 | - date_default_timezone_set( $calendar->site_timezone ); |
|
535 | + date_default_timezone_set($calendar->site_timezone); |
|
536 | 536 | |
537 | 537 | return ob_get_clean(); |
538 | 538 | } |
@@ -544,17 +544,17 @@ discard block |
||
544 | 544 | */ |
545 | 545 | public function draw_grid_ajax() { |
546 | 546 | |
547 | - if ( isset( $_POST['month'] ) && isset( $_POST['year'] ) && isset( $_POST['id'] ) ) { |
|
547 | + if (isset($_POST['month']) && isset($_POST['year']) && isset($_POST['id'])) { |
|
548 | 548 | |
549 | - $month = absint( $_POST['month'] ); |
|
550 | - $year = absint( $_POST['year'] ); |
|
551 | - $id = absint( $_POST['id'] ); |
|
549 | + $month = absint($_POST['month']); |
|
550 | + $year = absint($_POST['year']); |
|
551 | + $id = absint($_POST['id']); |
|
552 | 552 | |
553 | - wp_send_json_success( $this->draw_month( $month, $year, $id ) ); |
|
553 | + wp_send_json_success($this->draw_month($month, $year, $id)); |
|
554 | 554 | |
555 | 555 | } else { |
556 | 556 | |
557 | - wp_send_json_error( 'Missing arguments in default calendar grid ajax request.' ); |
|
557 | + wp_send_json_error('Missing arguments in default calendar grid ajax request.'); |
|
558 | 558 | |
559 | 559 | } |
560 | 560 | |
@@ -570,8 +570,8 @@ discard block |
||
570 | 570 | * |
571 | 571 | * @return bool |
572 | 572 | */ |
573 | - private function filter_events_before( $event ) { |
|
574 | - return intval( $event ) > intval( $this->start ); |
|
573 | + private function filter_events_before($event) { |
|
574 | + return intval($event) > intval($this->start); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | * |
585 | 585 | * @return bool |
586 | 586 | */ |
587 | - private function filter_events_after( $event ) { |
|
588 | - return intval( $event ) < intval( $this->end ); |
|
587 | + private function filter_events_after($event) { |
|
588 | + return intval($event) < intval($this->end); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | } |
@@ -576,9 +576,11 @@ |
||
576 | 576 | |
577 | 577 | endforeach; |
578 | 578 | |
579 | - else : |
|
579 | + else { |
|
580 | + : |
|
580 | 581 | |
581 | 582 | echo "\t" . '<p>'; |
583 | + } |
|
582 | 584 | |
583 | 585 | $message = get_post_meta( $calendar->id, '_no_events_message', true ); |
584 | 586 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | use SimpleCalendar\Calendars\Default_Calendar; |
14 | 14 | use SimpleCalendar\Events\Event; |
15 | 15 | |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param string|Calendar $calendar |
73 | 73 | */ |
74 | - public function __construct( $calendar = '' ) { |
|
74 | + public function __construct($calendar = '') { |
|
75 | 75 | $this->calendar = $calendar; |
76 | 76 | } |
77 | 77 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return string |
106 | 106 | */ |
107 | 107 | public function get_name() { |
108 | - return __( 'List', 'google-calendar-events' ); |
|
108 | + return __('List', 'google-calendar-events'); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @since 3.0.0 |
115 | 115 | */ |
116 | 116 | public function add_ajax_actions() { |
117 | - add_action( 'wp_ajax_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) ); |
|
118 | - add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) ); |
|
117 | + add_action('wp_ajax_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax')); |
|
118 | + add_action('wp_ajax_nopriv_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax')); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -129,16 +129,16 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - public function scripts( $min = '' ) { |
|
132 | + public function scripts($min = '') { |
|
133 | 133 | return array( |
134 | 134 | 'simcal-qtip' => array( |
135 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js', |
|
136 | - 'deps' => array( 'jquery' ), |
|
135 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$min.'.js', |
|
136 | + 'deps' => array('jquery'), |
|
137 | 137 | 'ver' => '2.2.1', |
138 | 138 | 'in_footer' => true, |
139 | 139 | ), |
140 | 140 | 'simcal-default-calendar' => array( |
141 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js', |
|
141 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js', |
|
142 | 142 | 'deps' => array( |
143 | 143 | 'jquery', |
144 | 144 | 'simcal-qtip', |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array |
165 | 165 | */ |
166 | - public function styles( $min = '' ) { |
|
166 | + public function styles($min = '') { |
|
167 | 167 | return array( |
168 | 168 | 'simcal-default-calendar-list' => array( |
169 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-list' . $min . '.css', |
|
169 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-list'.$min.'.css', |
|
170 | 170 | 'ver' => SIMPLE_CALENDAR_VERSION, |
171 | 171 | 'media' => 'all', |
172 | 172 | ), |
@@ -182,47 +182,47 @@ discard block |
||
182 | 182 | |
183 | 183 | $calendar = $this->calendar; |
184 | 184 | |
185 | - if ( $calendar instanceof Default_Calendar ) { |
|
185 | + if ($calendar instanceof Default_Calendar) { |
|
186 | 186 | |
187 | 187 | $disabled = $calendar->static === true ? ' disabled="disabled"' : ''; |
188 | 188 | |
189 | 189 | |
190 | - $hide_header = get_post_meta( $this->calendar->id, '_default_calendar_list_header', true ) == 'yes' ? true : false; |
|
191 | - $static_calendar = get_post_meta( $this->calendar->id, '_calendar_is_static', true ) == 'yes' ? true : false; |
|
190 | + $hide_header = get_post_meta($this->calendar->id, '_default_calendar_list_header', true) == 'yes' ? true : false; |
|
191 | + $static_calendar = get_post_meta($this->calendar->id, '_calendar_is_static', true) == 'yes' ? true : false; |
|
192 | 192 | |
193 | 193 | $header_class = ''; |
194 | 194 | $compact_list_class = $calendar->compact_list ? 'simcal-calendar-list-compact' : ''; |
195 | 195 | |
196 | - echo '<div class="simcal-calendar-list ' . $compact_list_class . '">'; |
|
196 | + echo '<div class="simcal-calendar-list '.$compact_list_class.'">'; |
|
197 | 197 | |
198 | - if ( ! $hide_header && ! $static_calendar ) { |
|
199 | - echo '<nav class="simcal-calendar-head">' . "\n"; |
|
198 | + if ( ! $hide_header && ! $static_calendar) { |
|
199 | + echo '<nav class="simcal-calendar-head">'."\n"; |
|
200 | 200 | |
201 | - echo "\t" . '<div class="simcal-nav">' . "\n"; |
|
202 | - echo "\t\t" . '<button class="simcal-nav-button simcal-prev" title="' . __('Previous', 'google-calendar-events') . '"' . $disabled . '>' . "\n"; |
|
203 | - echo "\t\t\t" . '<i class="simcal-icon-left"></i>' . "\n"; |
|
204 | - echo "\t\t" . '</button>' . "\n"; |
|
205 | - echo "\t" . '</div>' . "\n"; |
|
201 | + echo "\t".'<div class="simcal-nav">'."\n"; |
|
202 | + echo "\t\t".'<button class="simcal-nav-button simcal-prev" title="'.__('Previous', 'google-calendar-events').'"'.$disabled.'>'."\n"; |
|
203 | + echo "\t\t\t".'<i class="simcal-icon-left"></i>'."\n"; |
|
204 | + echo "\t\t".'</button>'."\n"; |
|
205 | + echo "\t".'</div>'."\n"; |
|
206 | 206 | |
207 | - if ( $hide_header ) { |
|
207 | + if ($hide_header) { |
|
208 | 208 | $header_class = 'simcal-hide-header'; |
209 | 209 | } |
210 | 210 | |
211 | 211 | |
212 | - echo "\t" . '<div class="simcal-nav simcal-current ' . $header_class . '" data-calendar-current="' . $calendar->start . '">' . "\n"; |
|
213 | - echo "\t\t" . '<h3 class="simcal-current-label"> </h3>' . "\n"; |
|
214 | - echo "\t" . '</div>' . "\n"; |
|
212 | + echo "\t".'<div class="simcal-nav simcal-current '.$header_class.'" data-calendar-current="'.$calendar->start.'">'."\n"; |
|
213 | + echo "\t\t".'<h3 class="simcal-current-label"> </h3>'."\n"; |
|
214 | + echo "\t".'</div>'."\n"; |
|
215 | 215 | |
216 | - echo "\t" . '<div class="simcal-nav">'; |
|
217 | - echo "\t\t" . '<button class="simcal-nav-button simcal-next" title="' . __('Next', 'google-calendar-events') . '"' . $disabled . '>'; |
|
218 | - echo "\t\t\t" . '<i class="simcal-icon-right"></i>' . "\n"; |
|
219 | - echo "\t\t" . '</button>' . "\n"; |
|
220 | - echo "\t" . '</div>' . "\n"; |
|
216 | + echo "\t".'<div class="simcal-nav">'; |
|
217 | + echo "\t\t".'<button class="simcal-nav-button simcal-next" title="'.__('Next', 'google-calendar-events').'"'.$disabled.'>'; |
|
218 | + echo "\t\t\t".'<i class="simcal-icon-right"></i>'."\n"; |
|
219 | + echo "\t\t".'</button>'."\n"; |
|
220 | + echo "\t".'</div>'."\n"; |
|
221 | 221 | |
222 | - echo '</nav>' . "\n"; |
|
222 | + echo '</nav>'."\n"; |
|
223 | 223 | } |
224 | 224 | |
225 | - echo $this->draw_list( $calendar->start ); |
|
225 | + echo $this->draw_list($calendar->start); |
|
226 | 226 | |
227 | 227 | echo '<div class="simcal-ajax-loader simcal-spinner-top" style="display: none;"><i class="simcal-icon-spinner simcal-icon-spin"></i></div>'; |
228 | 228 | |
@@ -241,92 +241,92 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return array |
243 | 243 | */ |
244 | - private function get_events( $timestamp ) { |
|
244 | + private function get_events($timestamp) { |
|
245 | 245 | |
246 | 246 | $calendar = $this->calendar; |
247 | 247 | $timezone = $calendar->timezone; |
248 | 248 | |
249 | - if ( ! $calendar->group_type || ! $calendar->group_span ) { |
|
249 | + if ( ! $calendar->group_type || ! $calendar->group_span) { |
|
250 | 250 | return array(); |
251 | 251 | } |
252 | 252 | |
253 | - $current = Carbon::createFromTimestamp( $timestamp, $timezone ); |
|
253 | + $current = Carbon::createFromTimestamp($timestamp, $timezone); |
|
254 | 254 | $prev = clone $current; |
255 | 255 | $next = clone $current; |
256 | 256 | |
257 | 257 | $this->start = $current->getTimestamp(); |
258 | 258 | |
259 | - $interval = $span = max( absint( $calendar->group_span ), 1 ); |
|
260 | - |
|
261 | - if ( 'monthly' == $calendar->group_type ) { |
|
262 | - $this->prev = $prev->subMonths( $span )->getTimestamp(); |
|
263 | - $this->next = $next->addMonths( $span )->getTimestamp(); |
|
264 | - } elseif ( 'weekly' == $calendar->group_type ) { |
|
265 | - $week = new Carbon( $calendar->timezone ); |
|
266 | - $week->setTimestamp( $timestamp ); |
|
267 | - $week->setWeekStartsAt( $calendar->week_starts ); |
|
268 | - $this->prev = $prev->subWeeks( $span )->getTimestamp(); |
|
269 | - $this->next = $next->addWeeks( $span )->getTimestamp(); |
|
270 | - } elseif ( 'daily' == $calendar->group_type ) { |
|
271 | - $this->prev = $prev->subDays( $span )->getTimestamp(); |
|
272 | - $this->next = $next->addDays( $span )->getTimestamp(); |
|
259 | + $interval = $span = max(absint($calendar->group_span), 1); |
|
260 | + |
|
261 | + if ('monthly' == $calendar->group_type) { |
|
262 | + $this->prev = $prev->subMonths($span)->getTimestamp(); |
|
263 | + $this->next = $next->addMonths($span)->getTimestamp(); |
|
264 | + } elseif ('weekly' == $calendar->group_type) { |
|
265 | + $week = new Carbon($calendar->timezone); |
|
266 | + $week->setTimestamp($timestamp); |
|
267 | + $week->setWeekStartsAt($calendar->week_starts); |
|
268 | + $this->prev = $prev->subWeeks($span)->getTimestamp(); |
|
269 | + $this->next = $next->addWeeks($span)->getTimestamp(); |
|
270 | + } elseif ('daily' == $calendar->group_type) { |
|
271 | + $this->prev = $prev->subDays($span)->getTimestamp(); |
|
272 | + $this->next = $next->addDays($span)->getTimestamp(); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | $events = $calendar->events; |
276 | 276 | $daily_events = $paged_events = $flattened_events = array(); |
277 | 277 | |
278 | - if ( 'events' != $calendar->group_type ) { |
|
278 | + if ('events' != $calendar->group_type) { |
|
279 | 279 | |
280 | - $this->end = $this->next - 1; |
|
280 | + $this->end = $this->next - 1; |
|
281 | 281 | |
282 | - $timestamps = array_keys( $events ); |
|
283 | - $lower_bound = array_filter( $timestamps, array( $this, 'filter_events_before' ) ); |
|
284 | - $higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after' ) ); |
|
282 | + $timestamps = array_keys($events); |
|
283 | + $lower_bound = array_filter($timestamps, array($this, 'filter_events_before')); |
|
284 | + $higher_bound = array_filter($lower_bound, array($this, 'filter_events_after')); |
|
285 | 285 | |
286 | - if ( is_array( $higher_bound ) && !empty( $higher_bound ) ) { |
|
287 | - $filtered = array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) ); |
|
288 | - foreach ( $filtered as $timestamp => $events ) { |
|
289 | - $paged_events[ intval( $timestamp ) ] = $events; |
|
286 | + if (is_array($higher_bound) && ! empty($higher_bound)) { |
|
287 | + $filtered = array_intersect_key($events, array_combine($higher_bound, $higher_bound)); |
|
288 | + foreach ($filtered as $timestamp => $events) { |
|
289 | + $paged_events[intval($timestamp)] = $events; |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | 293 | } else { |
294 | 294 | |
295 | - foreach ( $events as $timestamp => $e ) { |
|
295 | + foreach ($events as $timestamp => $e) { |
|
296 | 296 | $second = 0; |
297 | - foreach ( $e as $event ) { |
|
298 | - $flattened_events[ intval( $timestamp + $second ) ][] = $event; |
|
297 | + foreach ($e as $event) { |
|
298 | + $flattened_events[intval($timestamp + $second)][] = $event; |
|
299 | 299 | $second++; |
300 | 300 | } |
301 | 301 | } |
302 | - ksort( $flattened_events, SORT_NUMERIC ); |
|
302 | + ksort($flattened_events, SORT_NUMERIC); |
|
303 | 303 | |
304 | - $keys = array_keys( $flattened_events ); |
|
304 | + $keys = array_keys($flattened_events); |
|
305 | 305 | $current = 0; |
306 | - foreach ( $keys as $timestamp ) { |
|
307 | - if ( $timestamp <= $this->start ) { |
|
306 | + foreach ($keys as $timestamp) { |
|
307 | + if ($timestamp <= $this->start) { |
|
308 | 308 | $current++; |
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
312 | - $paged_events = array_slice( $flattened_events, $current, $interval, true ); |
|
312 | + $paged_events = array_slice($flattened_events, $current, $interval, true); |
|
313 | 313 | |
314 | - $events_end = isset( $keys[ $current + $interval ] ) ? $keys[ $current + $interval ] : $calendar->end; |
|
314 | + $events_end = isset($keys[$current + $interval]) ? $keys[$current + $interval] : $calendar->end; |
|
315 | 315 | $this->end = $events_end > $calendar->end ? $calendar->end : $events_end; |
316 | 316 | // -1 adjusts the interval count to index count, which starts at 0. |
317 | - $this->prev = isset( $keys[ $current - $interval - 1 ] ) ? $keys[ $current - $interval - 1 ] : $calendar->earliest_event; |
|
318 | - $this->next = isset( $keys[ $current + $interval - 1 ] ) ? $keys[ $current + $interval - 1 ] : $this->end; |
|
317 | + $this->prev = isset($keys[$current - $interval - 1]) ? $keys[$current - $interval - 1] : $calendar->earliest_event; |
|
318 | + $this->next = isset($keys[$current + $interval - 1]) ? $keys[$current + $interval - 1] : $this->end; |
|
319 | 319 | |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Put resulting events in an associative array, with Ymd date as key for easy retrieval in calendar days loop. |
323 | - foreach ( $paged_events as $timestamp => $events ) { |
|
324 | - if ( $timestamp <= $this->end ) { |
|
325 | - $date = Carbon::createFromTimestamp( $timestamp, $calendar->timezone )->endOfDay()->format( 'Ymd' ); |
|
326 | - $daily_events[ intval( $date ) ][] = $events; |
|
323 | + foreach ($paged_events as $timestamp => $events) { |
|
324 | + if ($timestamp <= $this->end) { |
|
325 | + $date = Carbon::createFromTimestamp($timestamp, $calendar->timezone)->endOfDay()->format('Ymd'); |
|
326 | + $daily_events[intval($date)][] = $events; |
|
327 | 327 | } |
328 | 328 | } |
329 | - ksort( $daily_events, SORT_NUMERIC ); |
|
329 | + ksort($daily_events, SORT_NUMERIC); |
|
330 | 330 | |
331 | 331 | return $daily_events; |
332 | 332 | } |
@@ -344,71 +344,71 @@ discard block |
||
344 | 344 | private function get_heading() { |
345 | 345 | |
346 | 346 | $calendar = $this->calendar; |
347 | - $start = Carbon::createFromTimestamp( $this->start, $calendar->timezone ); |
|
348 | - $end = Carbon::createFromTimestamp( $this->end, $calendar->timezone ); |
|
347 | + $start = Carbon::createFromTimestamp($this->start, $calendar->timezone); |
|
348 | + $end = Carbon::createFromTimestamp($this->end, $calendar->timezone); |
|
349 | 349 | $date_format = $this->calendar->date_format; |
350 | - $date_order = simcal_get_date_format_order( $date_format ); |
|
350 | + $date_order = simcal_get_date_format_order($date_format); |
|
351 | 351 | |
352 | - if ( ( $start->day == $end->day ) && ( $start->month == $end->month ) && ( $start->year == $end->year ) ) { |
|
352 | + if (($start->day == $end->day) && ($start->month == $end->month) && ($start->year == $end->year)) { |
|
353 | 353 | // Start and end on the same day. |
354 | 354 | // e.g. 1 February 2020 |
355 | - $large = $small = date_i18n( $calendar->date_format , $this->start ); |
|
356 | - if ( ( $date_order['d'] !== false ) && ( $date_order['m'] !== false ) ) { |
|
357 | - if ( $date_order['m'] > $date_order['d'] ) { |
|
358 | - if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) { |
|
359 | - $small = date_i18n( 'Y, d M', $this->start ); |
|
355 | + $large = $small = date_i18n($calendar->date_format, $this->start); |
|
356 | + if (($date_order['d'] !== false) && ($date_order['m'] !== false)) { |
|
357 | + if ($date_order['m'] > $date_order['d']) { |
|
358 | + if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) { |
|
359 | + $small = date_i18n('Y, d M', $this->start); |
|
360 | 360 | } else { |
361 | - $small = date_i18n( 'd M Y', $this->start ); |
|
361 | + $small = date_i18n('d M Y', $this->start); |
|
362 | 362 | } |
363 | 363 | } else { |
364 | - if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) { |
|
365 | - $small = date_i18n( 'Y, M d', $this->start ); |
|
364 | + if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) { |
|
365 | + $small = date_i18n('Y, M d', $this->start); |
|
366 | 366 | } else { |
367 | - $small = date_i18n( 'M d Y', $this->start ); |
|
367 | + $small = date_i18n('M d Y', $this->start); |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 | } |
371 | - } elseif ( ( $start->month == $end->month ) && ( $start->year == $end->year ) ) { |
|
371 | + } elseif (($start->month == $end->month) && ($start->year == $end->year)) { |
|
372 | 372 | // Start and end days on the same month. |
373 | 373 | // e.g. August 2020 |
374 | - if ( $date_order['y'] === false ) { |
|
374 | + if ($date_order['y'] === false) { |
|
375 | 375 | // August. |
376 | - $large = $small = date_i18n( 'F', $this->start ); |
|
376 | + $large = $small = date_i18n('F', $this->start); |
|
377 | 377 | } else { |
378 | - if ( $date_order['y'] < $date_order['m'] ) { |
|
378 | + if ($date_order['y'] < $date_order['m']) { |
|
379 | 379 | // 2020 August. |
380 | - $large = date_i18n( 'Y F', $this->start ); |
|
381 | - $small = date_i18n( 'Y M', $this->start ); |
|
380 | + $large = date_i18n('Y F', $this->start); |
|
381 | + $small = date_i18n('Y M', $this->start); |
|
382 | 382 | } else { |
383 | 383 | // August 2020. |
384 | - $large = date_i18n( 'F Y', $this->start ); |
|
385 | - $small = date_i18n( 'M Y', $this->start ); |
|
384 | + $large = date_i18n('F Y', $this->start); |
|
385 | + $small = date_i18n('M Y', $this->start); |
|
386 | 386 | } |
387 | 387 | } |
388 | - } elseif ( $start->year == $end->year ) { |
|
388 | + } elseif ($start->year == $end->year) { |
|
389 | 389 | // Start and end days on months of the same year. |
390 | 390 | // e.g. August - September 2020 |
391 | - if ( $date_order['y'] === false ) { |
|
391 | + if ($date_order['y'] === false) { |
|
392 | 392 | // August - September. |
393 | - $large = date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end ); |
|
394 | - $small = date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end ); |
|
393 | + $large = date_i18n('F', $this->start).' - '.date_i18n('F', $this->end); |
|
394 | + $small = date_i18n('M', $this->start).' - '.date_i18n('M', $this->end); |
|
395 | 395 | } else { |
396 | - if ( $date_order['y'] < $date_order['m'] ) { |
|
396 | + if ($date_order['y'] < $date_order['m']) { |
|
397 | 397 | // 2020, August - September. |
398 | - $large = $small = date( 'Y', $this->start ) . ', '; |
|
399 | - $large .= date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end ); |
|
400 | - $small .= date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end ); |
|
398 | + $large = $small = date('Y', $this->start).', '; |
|
399 | + $large .= date_i18n('F', $this->start).' - '.date_i18n('F', $this->end); |
|
400 | + $small .= date_i18n('M', $this->start).' - '.date_i18n('M', $this->end); |
|
401 | 401 | } else { |
402 | 402 | // August - September, 2020. |
403 | - $large = date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end ) . ', '; |
|
404 | - $small = date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end ) . ' '; |
|
405 | - $year = date( 'Y', $this->start ); |
|
403 | + $large = date_i18n('F', $this->start).' - '.date_i18n('F', $this->end).', '; |
|
404 | + $small = date_i18n('M', $this->start).' - '.date_i18n('M', $this->end).' '; |
|
405 | + $year = date('Y', $this->start); |
|
406 | 406 | $large .= $year; |
407 | 407 | $small .= $year; |
408 | 408 | } |
409 | 409 | } |
410 | 410 | } else { |
411 | - $large = $small = date( 'Y', $this->start ) . ' - ' . date( 'Y', $this->end ); |
|
411 | + $large = $small = date('Y', $this->start).' - '.date('Y', $this->end); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | return array( |
@@ -430,105 +430,105 @@ discard block |
||
430 | 430 | * |
431 | 431 | * @return string |
432 | 432 | */ |
433 | - private function draw_list( $timestamp, $id = 0 ) { |
|
433 | + private function draw_list($timestamp, $id = 0) { |
|
434 | 434 | |
435 | 435 | $calendar = $this->calendar; |
436 | 436 | |
437 | - if ( empty( $calendar ) ) { |
|
438 | - $calendar = $this->calendar = simcal_get_calendar( intval( $id ) ); |
|
439 | - if ( ! $calendar instanceof Default_Calendar ) { |
|
437 | + if (empty($calendar)) { |
|
438 | + $calendar = $this->calendar = simcal_get_calendar(intval($id)); |
|
439 | + if ( ! $calendar instanceof Default_Calendar) { |
|
440 | 440 | return ''; |
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | - date_default_timezone_set( $calendar->timezone ); |
|
444 | + date_default_timezone_set($calendar->timezone); |
|
445 | 445 | |
446 | 446 | $now = $calendar->now; |
447 | - $current_events = $this->get_events( $timestamp ); |
|
448 | - $day_format = explode( ' ', $calendar->date_format ); |
|
447 | + $current_events = $this->get_events($timestamp); |
|
448 | + $day_format = explode(' ', $calendar->date_format); |
|
449 | 449 | |
450 | 450 | ob_start(); |
451 | 451 | |
452 | 452 | // Draw the events. |
453 | 453 | |
454 | - $block_tag = $calendar->compact_list && ! empty( $current_events ) ? 'div' : 'dl'; |
|
454 | + $block_tag = $calendar->compact_list && ! empty($current_events) ? 'div' : 'dl'; |
|
455 | 455 | |
456 | 456 | $data_heading = ''; |
457 | 457 | $heading = $this->get_heading(); |
458 | - foreach ( $heading as $k => $v ) { |
|
459 | - $data_heading .= ' data-heading-' . $k . '="' . $v . '"'; |
|
458 | + foreach ($heading as $k => $v) { |
|
459 | + $data_heading .= ' data-heading-'.$k.'="'.$v.'"'; |
|
460 | 460 | } |
461 | 461 | |
462 | - echo '<' . $block_tag . ' class="simcal-events-list-container"' . |
|
463 | - ' data-prev="' . $this->prev . '"' . |
|
464 | - ' data-next="' . $this->next . '"' . |
|
465 | - $data_heading . '>'; |
|
462 | + echo '<'.$block_tag.' class="simcal-events-list-container"'. |
|
463 | + ' data-prev="'.$this->prev.'"'. |
|
464 | + ' data-next="'.$this->next.'"'. |
|
465 | + $data_heading.'>'; |
|
466 | 466 | |
467 | - if ( ! empty( $current_events ) && is_array( $current_events ) ) : |
|
467 | + if ( ! empty($current_events) && is_array($current_events)) : |
|
468 | 468 | |
469 | - foreach ( $current_events as $ymd => $events ) : |
|
469 | + foreach ($current_events as $ymd => $events) : |
|
470 | 470 | |
471 | - $day_ts = Carbon::createFromFormat( 'Ymd', $ymd, $calendar->timezone )->getTimestamp(); |
|
471 | + $day_ts = Carbon::createFromFormat('Ymd', $ymd, $calendar->timezone)->getTimestamp(); |
|
472 | 472 | |
473 | - if ( ! $calendar->compact_list ) : |
|
473 | + if ( ! $calendar->compact_list) : |
|
474 | 474 | |
475 | - $date = new Carbon( 'now', $calendar->timezone ); |
|
476 | - $date->setLocale( substr( get_locale(), 0, 2 ) ); |
|
477 | - $date->setTimestamp( $day_ts ); |
|
475 | + $date = new Carbon('now', $calendar->timezone); |
|
476 | + $date->setLocale(substr(get_locale(), 0, 2)); |
|
477 | + $date->setTimestamp($day_ts); |
|
478 | 478 | |
479 | - if ( $date->isToday() ) { |
|
480 | - $the_color = new Color( $calendar->today_color ); |
|
479 | + if ($date->isToday()) { |
|
480 | + $the_color = new Color($calendar->today_color); |
|
481 | 481 | } else { |
482 | - $the_color = new Color( $calendar->days_events_color ); |
|
482 | + $the_color = new Color($calendar->days_events_color); |
|
483 | 483 | } |
484 | 484 | |
485 | - $bg_color = '#' . $the_color->getHex(); |
|
485 | + $bg_color = '#'.$the_color->getHex(); |
|
486 | 486 | $color = $the_color->isDark() ? '#ffffff' : '#000000'; |
487 | - $border_style = ' style="border-bottom: 1px solid ' . $bg_color . ';" '; |
|
488 | - $bg_style = ' style="background-color: ' . $bg_color . '; color: ' . $color . ';"'; |
|
487 | + $border_style = ' style="border-bottom: 1px solid '.$bg_color.';" '; |
|
488 | + $bg_style = ' style="background-color: '.$bg_color.'; color: '.$color.';"'; |
|
489 | 489 | |
490 | - echo "\t" . '<dt class="simcal-day-label"' . $border_style . '>'; |
|
491 | - echo '<span' . $bg_style .'>'; |
|
492 | - foreach ( $day_format as $format ) { |
|
493 | - echo $format ? '<span class="simcal-date-format" data-date-format="' . $format . '">' . date_i18n( $format, $day_ts ) . '</span> ' : ' '; |
|
490 | + echo "\t".'<dt class="simcal-day-label"'.$border_style.'>'; |
|
491 | + echo '<span'.$bg_style.'>'; |
|
492 | + foreach ($day_format as $format) { |
|
493 | + echo $format ? '<span class="simcal-date-format" data-date-format="'.$format.'">'.date_i18n($format, $day_ts).'</span> ' : ' '; |
|
494 | 494 | } |
495 | 495 | echo '</span>'; |
496 | - echo '</dt>' . "\n"; |
|
496 | + echo '</dt>'."\n"; |
|
497 | 497 | |
498 | 498 | endif; |
499 | 499 | |
500 | - $list_events = '<ul class="simcal-events">' . "\n"; |
|
500 | + $list_events = '<ul class="simcal-events">'."\n"; |
|
501 | 501 | |
502 | 502 | $calendar_classes = array(); |
503 | - $day_classes = 'simcal-weekday-' . date( 'w', $day_ts ); |
|
503 | + $day_classes = 'simcal-weekday-'.date('w', $day_ts); |
|
504 | 504 | |
505 | 505 | // Is this the present, the past or the future, Doc? |
506 | - if ( $timestamp <= $now && $timestamp >= $now ) { |
|
506 | + if ($timestamp <= $now && $timestamp >= $now) { |
|
507 | 507 | $day_classes .= ' simcal-today simcal-present simcal-day'; |
508 | - } elseif ( $timestamp < $now ) { |
|
508 | + } elseif ($timestamp < $now) { |
|
509 | 509 | $day_classes .= ' simcal-past simcal-day'; |
510 | - } elseif ( $this->end > $now ) { |
|
510 | + } elseif ($this->end > $now) { |
|
511 | 511 | $day_classes .= ' simcal-future simcal-day'; |
512 | 512 | } |
513 | 513 | |
514 | 514 | $count = 0; |
515 | 515 | |
516 | - foreach ( $events as $day_events ) : |
|
517 | - foreach ( $day_events as $event ) : |
|
518 | - if ( $event instanceof Event ) : |
|
516 | + foreach ($events as $day_events) : |
|
517 | + foreach ($day_events as $event) : |
|
518 | + if ($event instanceof Event) : |
|
519 | 519 | |
520 | 520 | $event_classes = $event_visibility = ''; |
521 | 521 | |
522 | - $calendar_class = 'simcal-events-calendar-' . strval( $event->calendar ); |
|
522 | + $calendar_class = 'simcal-events-calendar-'.strval($event->calendar); |
|
523 | 523 | $calendar_classes[] = $calendar_class; |
524 | 524 | |
525 | 525 | $recurring = $event->recurrence ? 'simcal-event-recurring ' : ''; |
526 | 526 | $has_location = $event->venue ? 'simcal-event-has-location ' : ''; |
527 | 527 | |
528 | - $event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class; |
|
528 | + $event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class; |
|
529 | 529 | |
530 | 530 | // Toggle some events visibility if more than optional limit. |
531 | - if ( ( $calendar->events_limit > - 1 ) && ( $count >= $calendar->events_limit ) ) : |
|
531 | + if (($calendar->events_limit > - 1) && ($count >= $calendar->events_limit)) : |
|
532 | 532 | $event_classes .= ' simcal-event-toggled'; |
533 | 533 | $event_visibility = ' style="display: none"'; |
534 | 534 | endif; |
@@ -536,75 +536,75 @@ discard block |
||
536 | 536 | $event_color = ''; |
537 | 537 | $bullet = ''; |
538 | 538 | $event_color = $event->get_color(); |
539 | - if ( ! empty( $event_color ) ) { |
|
539 | + if ( ! empty($event_color)) { |
|
540 | 540 | $side = is_rtl() ? 'right' : 'left'; |
541 | - $event_color = ' style="border-' . $side . ': 4px solid ' . $event_color . '; padding-' . $side . ': 8px;"'; |
|
541 | + $event_color = ' style="border-'.$side.': 4px solid '.$event_color.'; padding-'.$side.': 8px;"'; |
|
542 | 542 | } |
543 | 543 | |
544 | - $list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . $event_color . ' itemprop="event" itemscope itemtype="http://schema.org/Event">' . "\n"; |
|
545 | - $list_events .= "\t\t" . '<div class="simcal-event-details">' . $calendar->get_event_html( $event ) . '</div>' . "\n"; |
|
546 | - $list_events .= "\t" . '</li>' . "\n"; |
|
544 | + $list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.$event_color.' itemprop="event" itemscope itemtype="http://schema.org/Event">'."\n"; |
|
545 | + $list_events .= "\t\t".'<div class="simcal-event-details">'.$calendar->get_event_html($event).'</div>'."\n"; |
|
546 | + $list_events .= "\t".'</li>'."\n"; |
|
547 | 547 | |
548 | - $count ++; |
|
548 | + $count++; |
|
549 | 549 | |
550 | 550 | // Event falls within today. |
551 | - if ( ( $this->end <= $now ) && ( $this->start >= $now ) ) : |
|
551 | + if (($this->end <= $now) && ($this->start >= $now)) : |
|
552 | 552 | $day_classes .= ' simcal-today-has-events'; |
553 | 553 | endif; |
554 | - $day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events'; |
|
554 | + $day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events'; |
|
555 | 555 | |
556 | - if ( $calendar_classes ) : |
|
557 | - $day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) ); |
|
556 | + if ($calendar_classes) : |
|
557 | + $day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes))); |
|
558 | 558 | endif; |
559 | 559 | |
560 | 560 | endif; |
561 | 561 | endforeach; |
562 | 562 | endforeach; |
563 | 563 | |
564 | - $list_events .= '</ul>' . "\n"; |
|
564 | + $list_events .= '</ul>'."\n"; |
|
565 | 565 | |
566 | 566 | // If events visibility is limited, print the button toggle. |
567 | - if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) : |
|
567 | + if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) : |
|
568 | 568 | $list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>'; |
569 | 569 | endif; |
570 | 570 | |
571 | 571 | // Print final list of events for the current day. |
572 | 572 | $tag = $calendar->compact_list ? 'div' : 'dd'; |
573 | - echo '<' . $tag . ' class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n"; |
|
574 | - echo "\t" . $list_events . "\n"; |
|
575 | - echo '</' . $tag . '>' . "\n"; |
|
573 | + echo '<'.$tag.' class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n"; |
|
574 | + echo "\t".$list_events."\n"; |
|
575 | + echo '</'.$tag.'>'."\n"; |
|
576 | 576 | |
577 | 577 | endforeach; |
578 | 578 | |
579 | 579 | else : |
580 | 580 | |
581 | - echo "\t" . '<p>'; |
|
581 | + echo "\t".'<p>'; |
|
582 | 582 | |
583 | - $message = get_post_meta( $calendar->id, '_no_events_message', true ); |
|
583 | + $message = get_post_meta($calendar->id, '_no_events_message', true); |
|
584 | 584 | |
585 | - if ( 'events' == $calendar->group_type ) { |
|
586 | - echo ! empty( $message ) ? $message : __( 'Nothing to show.', 'google-calendar-events' ); |
|
585 | + if ('events' == $calendar->group_type) { |
|
586 | + echo ! empty($message) ? $message : __('Nothing to show.', 'google-calendar-events'); |
|
587 | 587 | } else { |
588 | - if ( ! empty( $message ) ) { |
|
588 | + if ( ! empty($message)) { |
|
589 | 589 | echo $message; |
590 | 590 | } else { |
591 | - $from = Carbon::createFromTimestamp( $this->start, $calendar->timezone )->getTimestamp(); |
|
592 | - $to = Carbon::createFromTimestamp( $this->end, $calendar->timezone )->getTimestamp(); |
|
593 | - echo apply_filters( 'simcal_no_events_message', sprintf( |
|
594 | - __( 'Nothing from %1$s to %2$s.', 'google-calendar-events' ), |
|
595 | - date_i18n( $calendar->date_format, $from ), |
|
596 | - date_i18n( $calendar->date_format, $to ) |
|
597 | - ), $calendar->id, $from, $to ); |
|
591 | + $from = Carbon::createFromTimestamp($this->start, $calendar->timezone)->getTimestamp(); |
|
592 | + $to = Carbon::createFromTimestamp($this->end, $calendar->timezone)->getTimestamp(); |
|
593 | + echo apply_filters('simcal_no_events_message', sprintf( |
|
594 | + __('Nothing from %1$s to %2$s.', 'google-calendar-events'), |
|
595 | + date_i18n($calendar->date_format, $from), |
|
596 | + date_i18n($calendar->date_format, $to) |
|
597 | + ), $calendar->id, $from, $to); |
|
598 | 598 | } |
599 | 599 | } |
600 | 600 | |
601 | - echo "\t" . '</p>' . "\n"; |
|
601 | + echo "\t".'</p>'."\n"; |
|
602 | 602 | |
603 | 603 | endif; |
604 | 604 | |
605 | - echo '</' . $block_tag . '>'; |
|
605 | + echo '</'.$block_tag.'>'; |
|
606 | 606 | |
607 | - date_default_timezone_set( $calendar->site_timezone ); |
|
607 | + date_default_timezone_set($calendar->site_timezone); |
|
608 | 608 | |
609 | 609 | return ob_get_clean(); |
610 | 610 | } |
@@ -616,16 +616,16 @@ discard block |
||
616 | 616 | */ |
617 | 617 | public function draw_list_ajax() { |
618 | 618 | |
619 | - if ( isset( $_POST['ts'] ) && isset( $_POST['id'] ) ) { |
|
619 | + if (isset($_POST['ts']) && isset($_POST['id'])) { |
|
620 | 620 | |
621 | - $ts = absint( $_POST['ts'] ); |
|
622 | - $id = absint( $_POST['id'] ); |
|
621 | + $ts = absint($_POST['ts']); |
|
622 | + $id = absint($_POST['id']); |
|
623 | 623 | |
624 | - wp_send_json_success( $this->draw_list( $ts, $id ) ); |
|
624 | + wp_send_json_success($this->draw_list($ts, $id)); |
|
625 | 625 | |
626 | 626 | } else { |
627 | 627 | |
628 | - wp_send_json_error( 'Missing arguments in default calendar list ajax request.' ); |
|
628 | + wp_send_json_error('Missing arguments in default calendar list ajax request.'); |
|
629 | 629 | |
630 | 630 | } |
631 | 631 | } |
@@ -640,8 +640,8 @@ discard block |
||
640 | 640 | * |
641 | 641 | * @return bool |
642 | 642 | */ |
643 | - private function filter_events_before( $event ) { |
|
644 | - return intval( $event ) > intval( $this->start ); |
|
643 | + private function filter_events_before($event) { |
|
644 | + return intval($event) > intval($this->start); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
@@ -654,8 +654,8 @@ discard block |
||
654 | 654 | * |
655 | 655 | * @return bool |
656 | 656 | */ |
657 | - private function filter_events_after( $event ) { |
|
658 | - return intval( $event ) < intval( $this->end ); |
|
657 | + private function filter_events_after($event) { |
|
658 | + return intval($event) < intval($this->end); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | } |
@@ -590,21 +590,21 @@ discard block |
||
590 | 590 | if ( ! $event->whole_day ) { |
591 | 591 | |
592 | 592 | $time_start = $this->calendar->datetime_separator . |
593 | - ' <span class="simcal-event-start simcal-event-start-time" ' . |
|
594 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
595 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
596 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
597 | - date_i18n( $this->calendar->time_format, $start->getTimestamp() ) . |
|
598 | - '</span> '; |
|
593 | + ' <span class="simcal-event-start simcal-event-start-time" ' . |
|
594 | + 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
595 | + 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
596 | + 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
597 | + date_i18n( $this->calendar->time_format, $start->getTimestamp() ) . |
|
598 | + '</span> '; |
|
599 | 599 | |
600 | 600 | if ( $end instanceof Carbon ) { |
601 | 601 | |
602 | 602 | $time_end = ' <span class="simcal-event-end simcal-event-end-time" ' . |
603 | - 'data-event-end="' . $end->getTimestamp() . '" ' . |
|
604 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
605 | - 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
606 | - date_i18n( $this->calendar->time_format, $end->getTimestamp() ) . |
|
607 | - '</span> '; |
|
603 | + 'data-event-end="' . $end->getTimestamp() . '" ' . |
|
604 | + 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
605 | + 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
606 | + date_i18n( $this->calendar->time_format, $end->getTimestamp() ) . |
|
607 | + '</span> '; |
|
608 | 608 | |
609 | 609 | } |
610 | 610 | |
@@ -613,23 +613,23 @@ discard block |
||
613 | 613 | if ( $event->multiple_days ) { |
614 | 614 | |
615 | 615 | $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
616 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
617 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
618 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
619 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
620 | - '</span> ' . |
|
621 | - $time_start; |
|
616 | + 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
617 | + 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
618 | + 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
619 | + date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
620 | + '</span> ' . |
|
621 | + $time_start; |
|
622 | 622 | |
623 | 623 | if ( $end instanceof Carbon ) { |
624 | 624 | |
625 | 625 | $output .= '-' . |
626 | - ' <span class="simcal-event-start simcal-event-end-date" ' . |
|
627 | - 'data-event-start="' . $end->getTimestamp() . '" ' . |
|
628 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
629 | - 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
630 | - date_i18n( $this->calendar->date_format, $end->getTimestamp() ) . |
|
631 | - '</span> ' . |
|
632 | - $time_end; |
|
626 | + ' <span class="simcal-event-start simcal-event-end-date" ' . |
|
627 | + 'data-event-start="' . $end->getTimestamp() . '" ' . |
|
628 | + 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
629 | + 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
630 | + date_i18n( $this->calendar->date_format, $end->getTimestamp() ) . |
|
631 | + '</span> ' . |
|
632 | + $time_end; |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | } else { |
@@ -637,12 +637,12 @@ discard block |
||
637 | 637 | $time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : ''; |
638 | 638 | |
639 | 639 | $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
640 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
641 | - 'data-event-format="' . $this->calendar->date_format . '">' . |
|
642 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
643 | - '</span> ' . |
|
644 | - $time_start . |
|
645 | - $time_end; |
|
640 | + 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
641 | + 'data-event-format="' . $this->calendar->date_format . '">' . |
|
642 | + date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
643 | + '</span> ' . |
|
644 | + $time_start . |
|
645 | + $time_end; |
|
646 | 646 | |
647 | 647 | } |
648 | 648 | |
@@ -695,11 +695,11 @@ discard block |
||
695 | 695 | } |
696 | 696 | |
697 | 697 | return '<span class="simcal-event-' . $bound . ' ' . 'simcal-event-' . $bound . '-' . $format . '"' . |
698 | - 'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '"' . |
|
699 | - 'data-event-format="' . $dt_format . '"' . |
|
700 | - 'itemprop="' . $bound . 'Date" content="' . $event_dt->toIso8601String() . '">' . |
|
701 | - $value . |
|
702 | - '</span>'; |
|
698 | + 'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '"' . |
|
699 | + 'data-event-format="' . $dt_format . '"' . |
|
700 | + 'itemprop="' . $bound . 'Date" content="' . $event_dt->toIso8601String() . '">' . |
|
701 | + $value . |
|
702 | + '</span>'; |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | /** |
@@ -918,35 +918,35 @@ discard block |
||
918 | 918 | $tagregexp = implode( '|', array_values( $this->tags ) ); |
919 | 919 | |
920 | 920 | return '/' |
921 | - . '\\[' // Opening bracket |
|
922 | - . '(\\[?)' // 1: Optional second opening bracket for escaping tags: [[tag]] |
|
923 | - . "($tagregexp)" // 2: Tag name |
|
924 | - . '(?![\\w-])' // Not followed by word character or hyphen |
|
925 | - . '(' // 3: Unroll the loop: Inside the opening tag |
|
926 | - . '[^\\]\\/]*' // Not a closing bracket or forward slash |
|
927 | - . '(?:' |
|
928 | - . '\\/(?!\\])' // A forward slash not followed by a closing bracket |
|
929 | - . '[^\\]\\/]*' // Not a closing bracket or forward slash |
|
930 | - . ')*?' |
|
931 | - . ')' |
|
932 | - . '(?:' |
|
933 | - . '(\\/)' // 4: Self closing tag ... |
|
934 | - . '\\]' // ... and closing bracket |
|
935 | - . '|' |
|
936 | - . '\\]' // Closing bracket |
|
937 | - . '(?:' |
|
938 | - . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing tags |
|
939 | - . '[^\\[]*+' // Not an opening bracket |
|
940 | - . '(?:' |
|
941 | - . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag |
|
942 | - . '[^\\[]*+' // Not an opening bracket |
|
943 | - . ')*+' |
|
944 | - . ')' |
|
945 | - . '\\[\\/\\2\\]' // Closing tag |
|
946 | - . ')?' |
|
947 | - . ')' |
|
948 | - . '(\\]?)' // 6: Optional second closing bracket for escaping tags: [[tag]] |
|
949 | - . '/s'; |
|
921 | + . '\\[' // Opening bracket |
|
922 | + . '(\\[?)' // 1: Optional second opening bracket for escaping tags: [[tag]] |
|
923 | + . "($tagregexp)" // 2: Tag name |
|
924 | + . '(?![\\w-])' // Not followed by word character or hyphen |
|
925 | + . '(' // 3: Unroll the loop: Inside the opening tag |
|
926 | + . '[^\\]\\/]*' // Not a closing bracket or forward slash |
|
927 | + . '(?:' |
|
928 | + . '\\/(?!\\])' // A forward slash not followed by a closing bracket |
|
929 | + . '[^\\]\\/]*' // Not a closing bracket or forward slash |
|
930 | + . ')*?' |
|
931 | + . ')' |
|
932 | + . '(?:' |
|
933 | + . '(\\/)' // 4: Self closing tag ... |
|
934 | + . '\\]' // ... and closing bracket |
|
935 | + . '|' |
|
936 | + . '\\]' // Closing bracket |
|
937 | + . '(?:' |
|
938 | + . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing tags |
|
939 | + . '[^\\[]*+' // Not an opening bracket |
|
940 | + . '(?:' |
|
941 | + . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag |
|
942 | + . '[^\\[]*+' // Not an opening bracket |
|
943 | + . ')*+' |
|
944 | + . ')' |
|
945 | + . '\\[\\/\\2\\]' // Closing tag |
|
946 | + . ')?' |
|
947 | + . ')' |
|
948 | + . '(\\]?)' // 6: Optional second closing bracket for escaping tags: [[tag]] |
|
949 | + . '/s'; |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Carbon\Carbon; |
10 | 10 | use SimpleCalendar\Abstracts\Calendar; |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param Event $event |
55 | 55 | * @param Calendar $calendar |
56 | 56 | */ |
57 | - public function __construct( Event $event, Calendar $calendar ) { |
|
57 | + public function __construct(Event $event, Calendar $calendar) { |
|
58 | 58 | $this->event = $event; |
59 | 59 | $this->calendar = $calendar; |
60 | 60 | $this->tags = $this->get_content_tags(); |
@@ -74,84 +74,84 @@ discard block |
||
74 | 74 | * Content Tags * |
75 | 75 | * ============ */ |
76 | 76 | |
77 | - 'title', // The event title. |
|
78 | - 'event-title', // @deprecated An alias for 'title' tag. |
|
79 | - 'description', // The event description. |
|
80 | - |
|
81 | - 'when', // Date and time of the event. |
|
82 | - 'start-time', // Start time of the event. |
|
83 | - 'start-date', // Start date of the event. |
|
84 | - 'start-custom', // @deprecated Start time in a user defined format (set by tag 'format' attribute). |
|
85 | - 'start-human', // Start time in a human friendly format. |
|
86 | - 'end-time', // End time of the event. |
|
87 | - 'end-date', // End date of the event. |
|
88 | - 'end-custom', // @deprecated End date-time in a user defined format (set by tag 'format' attribute). |
|
89 | - 'end-human', // End date-time in a human friendly format. |
|
90 | - |
|
91 | - 'duration', // How long the events lasts, in a human-readable format. |
|
92 | - 'length', // @deprecated An alias of 'duration' tag. |
|
93 | - |
|
94 | - 'location', // Alias of start-location. |
|
95 | - 'start-location', // Location name where the event starts. |
|
96 | - 'maps-link', // @deprecated An alias for 'start-location-link' tag. |
|
97 | - 'start-location-link', // Link to Google Maps querying the event start location address. |
|
98 | - 'end-location', // Location name where the event ends. |
|
99 | - 'end-location-link', // Link to Google Maps querying the event end location address. |
|
100 | - |
|
101 | - 'link', // An HTML link to the event URL. |
|
102 | - 'url', // A string with the raw event link URL. |
|
103 | - |
|
104 | - 'calendar', // The title of the source calendar. |
|
105 | - 'feed-title', // @deprecated An alias of 'calendar'. |
|
106 | - |
|
107 | - 'id', // The event unique ID. |
|
108 | - 'uid', // An alias of ID. |
|
109 | - 'event-id', // @deprecated An alias for 'id' tag. |
|
110 | - 'calendar-id', // The calendar ID. |
|
111 | - 'feed-id', // @deprecated An alias for 'calendar-id' tag. |
|
112 | - 'cal-id', // @deprecated An alias for 'calendar-id' tag. |
|
77 | + 'title', // The event title. |
|
78 | + 'event-title', // @deprecated An alias for 'title' tag. |
|
79 | + 'description', // The event description. |
|
80 | + |
|
81 | + 'when', // Date and time of the event. |
|
82 | + 'start-time', // Start time of the event. |
|
83 | + 'start-date', // Start date of the event. |
|
84 | + 'start-custom', // @deprecated Start time in a user defined format (set by tag 'format' attribute). |
|
85 | + 'start-human', // Start time in a human friendly format. |
|
86 | + 'end-time', // End time of the event. |
|
87 | + 'end-date', // End date of the event. |
|
88 | + 'end-custom', // @deprecated End date-time in a user defined format (set by tag 'format' attribute). |
|
89 | + 'end-human', // End date-time in a human friendly format. |
|
90 | + |
|
91 | + 'duration', // How long the events lasts, in a human-readable format. |
|
92 | + 'length', // @deprecated An alias of 'duration' tag. |
|
93 | + |
|
94 | + 'location', // Alias of start-location. |
|
95 | + 'start-location', // Location name where the event starts. |
|
96 | + 'maps-link', // @deprecated An alias for 'start-location-link' tag. |
|
97 | + 'start-location-link', // Link to Google Maps querying the event start location address. |
|
98 | + 'end-location', // Location name where the event ends. |
|
99 | + 'end-location-link', // Link to Google Maps querying the event end location address. |
|
100 | + |
|
101 | + 'link', // An HTML link to the event URL. |
|
102 | + 'url', // A string with the raw event link URL. |
|
103 | + |
|
104 | + 'calendar', // The title of the source calendar. |
|
105 | + 'feed-title', // @deprecated An alias of 'calendar'. |
|
106 | + |
|
107 | + 'id', // The event unique ID. |
|
108 | + 'uid', // An alias of ID. |
|
109 | + 'event-id', // @deprecated An alias for 'id' tag. |
|
110 | + 'calendar-id', // The calendar ID. |
|
111 | + 'feed-id', // @deprecated An alias for 'calendar-id' tag. |
|
112 | + 'cal-id', // @deprecated An alias for 'calendar-id' tag. |
|
113 | 113 | |
114 | 114 | /* ========= * |
115 | 115 | * Meta Tags * |
116 | 116 | * ========= */ |
117 | 117 | |
118 | - 'attachments', // List of attachments. |
|
119 | - 'attendees', // List of attendees. |
|
120 | - 'organizer', // Creator info. |
|
118 | + 'attachments', // List of attachments. |
|
119 | + 'attendees', // List of attendees. |
|
120 | + 'organizer', // Creator info. |
|
121 | 121 | |
122 | 122 | /* ================ * |
123 | 123 | * Conditional Tags * |
124 | 124 | * ================ */ |
125 | 125 | |
126 | - 'if-title', // If the event has a title. |
|
127 | - 'if-description', // If the event has a description. |
|
128 | - |
|
129 | - 'if-now', // If the event is taking place now. |
|
130 | - 'if-not-now', // If the event is not taking place now (may have ended or just not started yet). |
|
131 | - 'if-started', // If the event has started (and may as well as ended). |
|
132 | - 'if-not-started', // If the event has NOT started yet (event could be any time in the future). |
|
133 | - 'if-ended', // If the event has ended (event could be any time in the past). |
|
134 | - 'if-not-ended', // If the event has NOT ended (may as well as not started yet). |
|
135 | - |
|
136 | - 'if-whole-day', // If the event lasts the whole day. |
|
137 | - 'if-all-day', // @deprecated Alias for 'if-whole-day'. |
|
138 | - 'if-not-whole-day', // If the event does NOT last the whole day. |
|
139 | - 'if-not-all-day', // @deprecated Alias for 'if-not-whole-day'. |
|
140 | - 'if-end-time', // If the event has a set end time. |
|
141 | - 'if-no-end-time', // If the event has NOT a set end time. |
|
142 | - |
|
143 | - 'if-multi-day', // If the event spans multiple days. |
|
144 | - 'if-single-day', // If the event does not span multiple days. |
|
145 | - |
|
146 | - 'if-recurring', // If the event is a recurring event. |
|
147 | - 'if-not-recurring', // If the event is NOT a recurring event. |
|
148 | - |
|
149 | - 'if-location', // @deprecated Alias for 'if-start-location'. |
|
150 | - 'if-start-location', // Does the event has a start location? |
|
151 | - 'if-end-location', // Does the event has an end location? |
|
152 | - 'if-not-location', // @deprecated Alias for 'if-not-start-location'. |
|
126 | + 'if-title', // If the event has a title. |
|
127 | + 'if-description', // If the event has a description. |
|
128 | + |
|
129 | + 'if-now', // If the event is taking place now. |
|
130 | + 'if-not-now', // If the event is not taking place now (may have ended or just not started yet). |
|
131 | + 'if-started', // If the event has started (and may as well as ended). |
|
132 | + 'if-not-started', // If the event has NOT started yet (event could be any time in the future). |
|
133 | + 'if-ended', // If the event has ended (event could be any time in the past). |
|
134 | + 'if-not-ended', // If the event has NOT ended (may as well as not started yet). |
|
135 | + |
|
136 | + 'if-whole-day', // If the event lasts the whole day. |
|
137 | + 'if-all-day', // @deprecated Alias for 'if-whole-day'. |
|
138 | + 'if-not-whole-day', // If the event does NOT last the whole day. |
|
139 | + 'if-not-all-day', // @deprecated Alias for 'if-not-whole-day'. |
|
140 | + 'if-end-time', // If the event has a set end time. |
|
141 | + 'if-no-end-time', // If the event has NOT a set end time. |
|
142 | + |
|
143 | + 'if-multi-day', // If the event spans multiple days. |
|
144 | + 'if-single-day', // If the event does not span multiple days. |
|
145 | + |
|
146 | + 'if-recurring', // If the event is a recurring event. |
|
147 | + 'if-not-recurring', // If the event is NOT a recurring event. |
|
148 | + |
|
149 | + 'if-location', // @deprecated Alias for 'if-start-location'. |
|
150 | + 'if-start-location', // Does the event has a start location? |
|
151 | + 'if-end-location', // Does the event has an end location? |
|
152 | + 'if-not-location', // @deprecated Alias for 'if-not-start-location'. |
|
153 | 153 | 'if-not-start-location', // Does the event has NOT a start location? |
154 | - 'if-not-end-location', // Does the event has NOT an end location? |
|
154 | + 'if-not-end-location', // Does the event has NOT an end location? |
|
155 | 155 | |
156 | 156 | ); |
157 | 157 | } |
@@ -165,17 +165,17 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return string |
167 | 167 | */ |
168 | - public function parse_event_template_tags( $template_tags = '' ) { |
|
168 | + public function parse_event_template_tags($template_tags = '') { |
|
169 | 169 | |
170 | 170 | // Process tags. |
171 | 171 | $result = preg_replace_callback( |
172 | 172 | $this->get_regex(), |
173 | - array( $this, 'process_event_content' ), |
|
173 | + array($this, 'process_event_content'), |
|
174 | 174 | $template_tags |
175 | 175 | ); |
176 | 176 | |
177 | 177 | // Removes extra consecutive <br> tags. |
178 | - return preg_replace( '#(<br */?>\s*)+#i', '<br />', trim( $result ) ); |
|
178 | + return preg_replace('#(<br */?>\s*)+#i', '<br />', trim($result)); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return string |
189 | 189 | */ |
190 | - public function process_event_content( $match ) { |
|
190 | + public function process_event_content($match) { |
|
191 | 191 | |
192 | - if ( $match[1] == '[' && $match[6] == ']' ) { |
|
193 | - return substr( $match[0], 1, - 1 ); |
|
192 | + if ($match[1] == '[' && $match[6] == ']') { |
|
193 | + return substr($match[0], 1, - 1); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | $tag = $match[2]; // Tag name without square brackets. |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | $calendar = $this->calendar; |
203 | 203 | $event = $this->event; |
204 | 204 | |
205 | - if ( ( $calendar instanceof Calendar ) && ( $event instanceof Event ) ) { |
|
205 | + if (($calendar instanceof Calendar) && ($event instanceof Event)) { |
|
206 | 206 | |
207 | - switch ( $tag ) { |
|
207 | + switch ($tag) { |
|
208 | 208 | |
209 | 209 | /* ============ * |
210 | 210 | * Content Tags * |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | |
213 | 213 | case 'title' : |
214 | 214 | case 'event-title' : |
215 | - return $this->get_title( $event->title, $attr ); |
|
215 | + return $this->get_title($event->title, $attr); |
|
216 | 216 | |
217 | 217 | case 'description' : |
218 | - return $this->get_description( $event->description, $attr ); |
|
218 | + return $this->get_description($event->description, $attr); |
|
219 | 219 | |
220 | 220 | case 'when' : |
221 | - return $this->get_when( $event ); |
|
221 | + return $this->get_when($event); |
|
222 | 222 | |
223 | 223 | case 'end-date' : |
224 | 224 | case 'end-custom' : |
@@ -228,40 +228,40 @@ discard block |
||
228 | 228 | case 'start-date' : |
229 | 229 | case 'start-human' : |
230 | 230 | case 'start-time' : |
231 | - return $this->get_dt( $tag, $event, $attr ); |
|
231 | + return $this->get_dt($tag, $event, $attr); |
|
232 | 232 | |
233 | 233 | case 'length' : |
234 | 234 | case 'duration' : |
235 | - if ( false !== $event->end ) { |
|
235 | + if (false !== $event->end) { |
|
236 | 236 | $duration = $event->start - $event->end; |
237 | - $value = human_time_diff( $event->start, $event->end ); |
|
237 | + $value = human_time_diff($event->start, $event->end); |
|
238 | 238 | } else { |
239 | 239 | $duration = '-1'; |
240 | - $value = __( 'No end time', 'google-calendar-events' ); |
|
240 | + $value = __('No end time', 'google-calendar-events'); |
|
241 | 241 | } |
242 | - return ' <span class="simcal-event-duration" data-event-duration="' . $duration . '">' . $value . '</span>'; |
|
242 | + return ' <span class="simcal-event-duration" data-event-duration="'.$duration.'">'.$value.'</span>'; |
|
243 | 243 | |
244 | 244 | case 'location' : |
245 | 245 | case 'start-location' : |
246 | 246 | case 'end-location' : |
247 | 247 | $location = $tag == 'end-location' ? $event->end_location['address'] : $event->start_location['address']; |
248 | 248 | $location_class = $tag == 'end-location' ? 'end' : 'start'; |
249 | - return ' <span class="simcal-event-address simcal-event-' . $location_class . '-location" itemprop="location" itemscope itemtype="http://schema.org/Place">' . wp_strip_all_tags( $location ) . '</span>'; |
|
249 | + return ' <span class="simcal-event-address simcal-event-'.$location_class.'-location" itemprop="location" itemscope itemtype="http://schema.org/Place">'.wp_strip_all_tags($location).'</span>'; |
|
250 | 250 | |
251 | 251 | case 'start-location-link': |
252 | 252 | case 'end-location-link' : |
253 | 253 | case 'maps-link' : |
254 | 254 | $location = $tag == 'end-location-link' ? $event->end_location['address'] : $event->start_location['address']; |
255 | - if ( ! empty( $location ) ) { |
|
256 | - $url = '//maps.google.com?q=' . urlencode( $location ); |
|
257 | - return $this->make_link( $tag, $url, $calendar->get_event_html( $event, $partial ), $attr ); |
|
255 | + if ( ! empty($location)) { |
|
256 | + $url = '//maps.google.com?q='.urlencode($location); |
|
257 | + return $this->make_link($tag, $url, $calendar->get_event_html($event, $partial), $attr); |
|
258 | 258 | } |
259 | 259 | break; |
260 | 260 | |
261 | 261 | case 'link' : |
262 | 262 | case 'url' : |
263 | - $content = 'link' == $tag ? $calendar->get_event_html( $event, $partial ) : ''; |
|
264 | - return $this->make_link( $tag, $event->link, $content , $attr ); |
|
263 | + $content = 'link' == $tag ? $calendar->get_event_html($event, $partial) : ''; |
|
264 | + return $this->make_link($tag, $event->link, $content, $attr); |
|
265 | 265 | |
266 | 266 | case 'calendar' : |
267 | 267 | case 'feed-title' : |
@@ -283,22 +283,22 @@ discard block |
||
283 | 283 | |
284 | 284 | case 'attachments' : |
285 | 285 | $attachments = $event->get_attachments(); |
286 | - if ( ! empty( $attachments ) ) { |
|
287 | - return $this->get_attachments( $attachments ); |
|
286 | + if ( ! empty($attachments)) { |
|
287 | + return $this->get_attachments($attachments); |
|
288 | 288 | } |
289 | 289 | break; |
290 | 290 | |
291 | 291 | case 'attendees' : |
292 | 292 | $attendees = $event->get_attendees(); |
293 | - if ( ! empty( $attendees ) ) { |
|
294 | - return $this->get_attendees( $attendees, $attr ); |
|
293 | + if ( ! empty($attendees)) { |
|
294 | + return $this->get_attendees($attendees, $attr); |
|
295 | 295 | } |
296 | 296 | break; |
297 | 297 | |
298 | 298 | case 'organizer' : |
299 | 299 | $organizer = $event->get_organizer(); |
300 | - if ( ! empty( $organizer ) ) { |
|
301 | - return $this->get_organizer( $organizer, $attr ); |
|
300 | + if ( ! empty($organizer)) { |
|
301 | + return $this->get_organizer($organizer, $attr); |
|
302 | 302 | } |
303 | 303 | break; |
304 | 304 | |
@@ -307,35 +307,35 @@ discard block |
||
307 | 307 | * ================ */ |
308 | 308 | |
309 | 309 | case 'if-title': |
310 | - if ( ! empty( $event->title ) ) { |
|
311 | - return $calendar->get_event_html( $event, $partial ); |
|
310 | + if ( ! empty($event->title)) { |
|
311 | + return $calendar->get_event_html($event, $partial); |
|
312 | 312 | } |
313 | 313 | break; |
314 | 314 | |
315 | 315 | case 'if-description': |
316 | - if ( ! empty( $event->description ) ) { |
|
317 | - return $calendar->get_event_html( $event, $partial ); |
|
316 | + if ( ! empty($event->description)) { |
|
317 | + return $calendar->get_event_html($event, $partial); |
|
318 | 318 | } |
319 | 319 | break; |
320 | 320 | |
321 | 321 | case 'if-now' : |
322 | 322 | case 'if-not-now' : |
323 | 323 | |
324 | - $start_dt = $event->start_dt->setTimezone( $calendar->timezone ); |
|
324 | + $start_dt = $event->start_dt->setTimezone($calendar->timezone); |
|
325 | 325 | $start = $start_dt->getTimestamp(); |
326 | 326 | |
327 | - if ( $event->end_dt instanceof Carbon ) { |
|
328 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
327 | + if ($event->end_dt instanceof Carbon) { |
|
328 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
329 | 329 | } else { |
330 | 330 | return ''; |
331 | 331 | } |
332 | 332 | |
333 | - $now = ( $start <= $calendar->now ) && ( $end >= $calendar->now ); |
|
333 | + $now = ($start <= $calendar->now) && ($end >= $calendar->now); |
|
334 | 334 | |
335 | - if ( ( 'if-now' == $tag ) && $now ) { |
|
336 | - return $calendar->get_event_html( $event, $partial ); |
|
337 | - } elseif ( ( 'if-not-now' == $tag ) && ( false == $now ) ) { |
|
338 | - return $calendar->get_event_html( $event, $partial ); |
|
335 | + if (('if-now' == $tag) && $now) { |
|
336 | + return $calendar->get_event_html($event, $partial); |
|
337 | + } elseif (('if-not-now' == $tag) && (false == $now)) { |
|
338 | + return $calendar->get_event_html($event, $partial); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | break; |
@@ -343,15 +343,15 @@ discard block |
||
343 | 343 | case 'if-started' : |
344 | 344 | case 'if-not-started' : |
345 | 345 | |
346 | - $start = $event->start_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
346 | + $start = $event->start_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
347 | 347 | |
348 | - if ( 'if-started' == $tag ) { |
|
349 | - if ( $start < $calendar->now ) { |
|
350 | - return $calendar->get_event_html( $event, $partial ); |
|
348 | + if ('if-started' == $tag) { |
|
349 | + if ($start < $calendar->now) { |
|
350 | + return $calendar->get_event_html($event, $partial); |
|
351 | 351 | } |
352 | - } elseif ( 'if-not-started' == $tag ) { |
|
353 | - if ( $start > $calendar->now ) { |
|
354 | - return $calendar->get_event_html( $event, $partial ); |
|
352 | + } elseif ('if-not-started' == $tag) { |
|
353 | + if ($start > $calendar->now) { |
|
354 | + return $calendar->get_event_html($event, $partial); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
@@ -360,17 +360,17 @@ discard block |
||
360 | 360 | case 'if-ended' : |
361 | 361 | case 'if-not-ended' : |
362 | 362 | |
363 | - if ( false !== $event->end ) { |
|
363 | + if (false !== $event->end) { |
|
364 | 364 | |
365 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
365 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
366 | 366 | |
367 | - if ( 'if-ended' == $tag ) { |
|
368 | - if ( $end < $calendar->now ) { |
|
369 | - return $calendar->get_event_html( $event, $partial ); |
|
367 | + if ('if-ended' == $tag) { |
|
368 | + if ($end < $calendar->now) { |
|
369 | + return $calendar->get_event_html($event, $partial); |
|
370 | 370 | } |
371 | - } elseif ( 'if-not-ended' == $tag ) { |
|
372 | - if ( $end > $calendar->now ) { |
|
373 | - return $calendar->get_event_html( $event, $partial ); |
|
371 | + } elseif ('if-not-ended' == $tag) { |
|
372 | + if ($end > $calendar->now) { |
|
373 | + return $calendar->get_event_html($event, $partial); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
@@ -379,14 +379,14 @@ discard block |
||
379 | 379 | break; |
380 | 380 | |
381 | 381 | case 'if-end-time' : |
382 | - if ( false !== $event->end ) { |
|
383 | - return $calendar->get_event_html( $event, $partial ); |
|
382 | + if (false !== $event->end) { |
|
383 | + return $calendar->get_event_html($event, $partial); |
|
384 | 384 | } |
385 | 385 | break; |
386 | 386 | |
387 | 387 | case 'if-no-end-time' : |
388 | - if ( false === $event->end ) { |
|
389 | - return $calendar->get_event_html( $event, $partial ); |
|
388 | + if (false === $event->end) { |
|
389 | + return $calendar->get_event_html($event, $partial); |
|
390 | 390 | } |
391 | 391 | break; |
392 | 392 | |
@@ -394,59 +394,59 @@ discard block |
||
394 | 394 | case 'if-whole-day' : |
395 | 395 | case 'if-not-all-day' : |
396 | 396 | case 'if-not-whole-day' : |
397 | - $bool = strstr( $tag, 'not' ) ? false : true; |
|
398 | - if ( $bool === $event->whole_day ) { |
|
399 | - return $calendar->get_event_html( $event, $partial ); |
|
397 | + $bool = strstr($tag, 'not') ? false : true; |
|
398 | + if ($bool === $event->whole_day) { |
|
399 | + return $calendar->get_event_html($event, $partial); |
|
400 | 400 | } |
401 | 401 | break; |
402 | 402 | |
403 | 403 | case 'if-recurring' : |
404 | - if ( ! empty( $event->recurrence ) ) { |
|
405 | - return $calendar->get_event_html( $event, $partial ); |
|
404 | + if ( ! empty($event->recurrence)) { |
|
405 | + return $calendar->get_event_html($event, $partial); |
|
406 | 406 | } |
407 | 407 | break; |
408 | 408 | |
409 | 409 | case 'if-not-recurring' : |
410 | - if ( false === $event->recurrence ) { |
|
411 | - return $calendar->get_event_html( $event, $partial ); |
|
410 | + if (false === $event->recurrence) { |
|
411 | + return $calendar->get_event_html($event, $partial); |
|
412 | 412 | } |
413 | 413 | break; |
414 | 414 | |
415 | 415 | case 'if-multi-day' : |
416 | - if ( false !== $event->multiple_days ) { |
|
417 | - return $calendar->get_event_html( $event, $partial ); |
|
416 | + if (false !== $event->multiple_days) { |
|
417 | + return $calendar->get_event_html($event, $partial); |
|
418 | 418 | } |
419 | 419 | break; |
420 | 420 | |
421 | 421 | case 'if-single-day' : |
422 | - if ( false === $event->multiple_days ) { |
|
423 | - return $calendar->get_event_html( $event, $partial ); |
|
422 | + if (false === $event->multiple_days) { |
|
423 | + return $calendar->get_event_html($event, $partial); |
|
424 | 424 | } |
425 | 425 | break; |
426 | 426 | |
427 | 427 | case 'if-location' : |
428 | 428 | case 'if-start-location' : |
429 | - if ( ! empty( $event->start_location['address'] ) ) { |
|
430 | - return $calendar->get_event_html( $event, $partial ); |
|
429 | + if ( ! empty($event->start_location['address'])) { |
|
430 | + return $calendar->get_event_html($event, $partial); |
|
431 | 431 | } |
432 | 432 | return false; |
433 | 433 | |
434 | 434 | case 'if-not-location' : |
435 | 435 | case 'if-not-start-location' : |
436 | - if ( empty( $event->start_location['address'] ) ) { |
|
437 | - return $calendar->get_event_html( $event, $partial ); |
|
436 | + if (empty($event->start_location['address'])) { |
|
437 | + return $calendar->get_event_html($event, $partial); |
|
438 | 438 | } |
439 | 439 | return ''; |
440 | 440 | |
441 | 441 | case 'if-not-end-location' : |
442 | - if ( empty( $event->end_location['address'] ) ) { |
|
443 | - return $calendar->get_event_html( $event, $partial ); |
|
442 | + if (empty($event->end_location['address'])) { |
|
443 | + return $calendar->get_event_html($event, $partial); |
|
444 | 444 | } |
445 | 445 | return ''; |
446 | 446 | |
447 | 447 | case 'if-end-location' : |
448 | - if ( ! empty( $event->end_location['address'] ) ) { |
|
449 | - return $calendar->get_event_html( $event, $partial ); |
|
448 | + if ( ! empty($event->end_location['address'])) { |
|
449 | + return $calendar->get_event_html($event, $partial); |
|
450 | 450 | } |
451 | 451 | return ''; |
452 | 452 | |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | * ======= */ |
456 | 456 | |
457 | 457 | default : |
458 | - return wp_kses_post( $before . $partial . $after ); |
|
458 | + return wp_kses_post($before.$partial.$after); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
@@ -473,14 +473,14 @@ discard block |
||
473 | 473 | * |
474 | 474 | * @return string |
475 | 475 | */ |
476 | - private function limit_words( $text, $limit ) { |
|
476 | + private function limit_words($text, $limit) { |
|
477 | 477 | |
478 | - $limit = max( absint( $limit ), 0 ); |
|
478 | + $limit = max(absint($limit), 0); |
|
479 | 479 | |
480 | - if ( $limit > 0 && ( str_word_count( $text, 0 ) > $limit ) ) { |
|
481 | - $words = str_word_count( $text, 2 ); |
|
482 | - $pos = array_keys( $words ); |
|
483 | - $text = trim( substr( $text, 0, $pos[ $limit ] ) ) . '…'; |
|
480 | + if ($limit > 0 && (str_word_count($text, 0) > $limit)) { |
|
481 | + $words = str_word_count($text, 2); |
|
482 | + $pos = array_keys($words); |
|
483 | + $text = trim(substr($text, 0, $pos[$limit])).'…'; |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | return $text; |
@@ -497,26 +497,26 @@ discard block |
||
497 | 497 | * |
498 | 498 | * @return string |
499 | 499 | */ |
500 | - private function get_title( $title, $attr ) { |
|
500 | + private function get_title($title, $attr) { |
|
501 | 501 | |
502 | - if ( empty( $title ) ) { |
|
502 | + if (empty($title)) { |
|
503 | 503 | return ''; |
504 | 504 | } |
505 | 505 | |
506 | - $attr = array_merge( array( |
|
507 | - 'html' => '', // Parse HTML |
|
508 | - 'limit' => 0, // Trim length to amount of words |
|
509 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
506 | + $attr = array_merge(array( |
|
507 | + 'html' => '', // Parse HTML |
|
508 | + 'limit' => 0, // Trim length to amount of words |
|
509 | + ), (array) shortcode_parse_atts($attr)); |
|
510 | 510 | |
511 | - if ( ! empty( $attr['html'] ) ) { |
|
512 | - $title = wp_kses_post( $title ); |
|
511 | + if ( ! empty($attr['html'])) { |
|
512 | + $title = wp_kses_post($title); |
|
513 | 513 | $tag = 'div'; |
514 | 514 | } else { |
515 | - $title = $this->limit_words( $title, $attr['limit'] ); |
|
515 | + $title = $this->limit_words($title, $attr['limit']); |
|
516 | 516 | $tag = 'span'; |
517 | 517 | } |
518 | 518 | |
519 | - return '<' . $tag . ' class="simcal-event-title" itemprop="name">' . $title . '</' . $tag . '>'; |
|
519 | + return '<'.$tag.' class="simcal-event-title" itemprop="name">'.$title.'</'.$tag.'>'; |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -530,40 +530,40 @@ discard block |
||
530 | 530 | * |
531 | 531 | * @return string |
532 | 532 | */ |
533 | - private function get_description( $description, $attr ) { |
|
533 | + private function get_description($description, $attr) { |
|
534 | 534 | |
535 | - if ( empty( $description ) ) { |
|
535 | + if (empty($description)) { |
|
536 | 536 | return ''; |
537 | 537 | } |
538 | 538 | |
539 | - $attr = array_merge( array( |
|
540 | - 'limit' => 0, // Trim length to number of words |
|
541 | - 'html' => 'no', // Parse HTML content |
|
542 | - 'markdown' => 'no', // Parse Markdown content |
|
543 | - 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
544 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
539 | + $attr = array_merge(array( |
|
540 | + 'limit' => 0, // Trim length to number of words |
|
541 | + 'html' => 'no', // Parse HTML content |
|
542 | + 'markdown' => 'no', // Parse Markdown content |
|
543 | + 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
544 | + ), (array) shortcode_parse_atts($attr)); |
|
545 | 545 | |
546 | - $allow_html = 'no' != $attr['html'] ? true : false; |
|
546 | + $allow_html = 'no' != $attr['html'] ? true : false; |
|
547 | 547 | $allow_md = 'no' != $attr['markdown'] ? true : false; |
548 | 548 | |
549 | 549 | $html = '<div class="simcal-event-description" itemprop="description">'; |
550 | 550 | |
551 | 551 | // Markdown and HTML don't play well together, use one or the other in the same tag. |
552 | - if ( $allow_html || $allow_md ) { |
|
553 | - if ( $allow_html ) { |
|
554 | - $description = wp_kses_post( $description ); |
|
555 | - } elseif ( $allow_md ) { |
|
552 | + if ($allow_html || $allow_md) { |
|
553 | + if ($allow_html) { |
|
554 | + $description = wp_kses_post($description); |
|
555 | + } elseif ($allow_md) { |
|
556 | 556 | $markdown = new \Parsedown(); |
557 | - $description = $markdown->text( wp_strip_all_tags( $description ) ); |
|
557 | + $description = $markdown->text(wp_strip_all_tags($description)); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
561 | - $description = $this->limit_words( $description, $attr['limit'] ); |
|
561 | + $description = $this->limit_words($description, $attr['limit']); |
|
562 | 562 | |
563 | - $html .= $description . '</div>'; |
|
563 | + $html .= $description.'</div>'; |
|
564 | 564 | |
565 | - if ( 'no' != $attr['autolink'] ) { |
|
566 | - $html = ' ' . make_clickable( $html ); |
|
565 | + if ('no' != $attr['autolink']) { |
|
566 | + $html = ' '.make_clickable($html); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | return $html; |
@@ -579,74 +579,74 @@ discard block |
||
579 | 579 | * |
580 | 580 | * @return string |
581 | 581 | */ |
582 | - private function get_when( Event $event ) { |
|
582 | + private function get_when(Event $event) { |
|
583 | 583 | |
584 | - $start = $event->start_dt->setTimezone( $event->timezone ); |
|
585 | - $end = ! is_null( $event->end_dt ) ? $event->end_dt->setTimezone( $event->timezone ) : null; |
|
584 | + $start = $event->start_dt->setTimezone($event->timezone); |
|
585 | + $end = ! is_null($event->end_dt) ? $event->end_dt->setTimezone($event->timezone) : null; |
|
586 | 586 | |
587 | 587 | $time_start = ''; |
588 | 588 | $time_end = ''; |
589 | 589 | |
590 | - if ( ! $event->whole_day ) { |
|
590 | + if ( ! $event->whole_day) { |
|
591 | 591 | |
592 | - $time_start = $this->calendar->datetime_separator . |
|
593 | - ' <span class="simcal-event-start simcal-event-start-time" ' . |
|
594 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
595 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
596 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
597 | - date_i18n( $this->calendar->time_format, $start->getTimestamp() ) . |
|
592 | + $time_start = $this->calendar->datetime_separator. |
|
593 | + ' <span class="simcal-event-start simcal-event-start-time" '. |
|
594 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
595 | + 'data-event-format="'.$this->calendar->time_format.'" '. |
|
596 | + 'itemprop="startDate" content="'.$start->toIso8601String().'">'. |
|
597 | + date_i18n($this->calendar->time_format, $start->getTimestamp()). |
|
598 | 598 | '</span> '; |
599 | 599 | |
600 | - if ( $end instanceof Carbon ) { |
|
600 | + if ($end instanceof Carbon) { |
|
601 | 601 | |
602 | - $time_end = ' <span class="simcal-event-end simcal-event-end-time" ' . |
|
603 | - 'data-event-end="' . $end->getTimestamp() . '" ' . |
|
604 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
605 | - 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
606 | - date_i18n( $this->calendar->time_format, $end->getTimestamp() ) . |
|
602 | + $time_end = ' <span class="simcal-event-end simcal-event-end-time" '. |
|
603 | + 'data-event-end="'.$end->getTimestamp().'" '. |
|
604 | + 'data-event-format="'.$this->calendar->time_format.'" '. |
|
605 | + 'itemprop="endDate" content="'.$end->toIso8601String().'">'. |
|
606 | + date_i18n($this->calendar->time_format, $end->getTimestamp()). |
|
607 | 607 | '</span> '; |
608 | 608 | |
609 | 609 | } |
610 | 610 | |
611 | 611 | } |
612 | 612 | |
613 | - if ( $event->multiple_days ) { |
|
613 | + if ($event->multiple_days) { |
|
614 | 614 | |
615 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
|
616 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
617 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
618 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
619 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
620 | - '</span> ' . |
|
615 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '. |
|
616 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
617 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
618 | + 'itemprop="startDate" content="'.$start->toIso8601String().'">'. |
|
619 | + date_i18n($this->calendar->date_format, $start->getTimestamp()). |
|
620 | + '</span> '. |
|
621 | 621 | $time_start; |
622 | 622 | |
623 | - if ( $end instanceof Carbon ) { |
|
623 | + if ($end instanceof Carbon) { |
|
624 | 624 | |
625 | - $output .= '-' . |
|
626 | - ' <span class="simcal-event-start simcal-event-end-date" ' . |
|
627 | - 'data-event-start="' . $end->getTimestamp() . '" ' . |
|
628 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
629 | - 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
630 | - date_i18n( $this->calendar->date_format, $end->getTimestamp() ) . |
|
631 | - '</span> ' . |
|
625 | + $output .= '-'. |
|
626 | + ' <span class="simcal-event-start simcal-event-end-date" '. |
|
627 | + 'data-event-start="'.$end->getTimestamp().'" '. |
|
628 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
629 | + 'itemprop="endDate" content="'.$end->toIso8601String().'">'. |
|
630 | + date_i18n($this->calendar->date_format, $end->getTimestamp()). |
|
631 | + '</span> '. |
|
632 | 632 | $time_end; |
633 | 633 | } |
634 | 634 | |
635 | 635 | } else { |
636 | 636 | |
637 | - $time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : ''; |
|
637 | + $time_end = ! empty($time_start) && ! empty($time_end) ? ' - '.$time_end : ''; |
|
638 | 638 | |
639 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
|
640 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
641 | - 'data-event-format="' . $this->calendar->date_format . '">' . |
|
642 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
643 | - '</span> ' . |
|
644 | - $time_start . |
|
639 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '. |
|
640 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
641 | + 'data-event-format="'.$this->calendar->date_format.'">'. |
|
642 | + date_i18n($this->calendar->date_format, $start->getTimestamp()). |
|
643 | + '</span> '. |
|
644 | + $time_start. |
|
645 | 645 | $time_end; |
646 | 646 | |
647 | 647 | } |
648 | 648 | |
649 | - return trim( $output ); |
|
649 | + return trim($output); |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | /** |
@@ -661,44 +661,44 @@ discard block |
||
661 | 661 | * |
662 | 662 | * @return string |
663 | 663 | */ |
664 | - private function get_dt( $tag, Event $event, $attr ) { |
|
664 | + private function get_dt($tag, Event $event, $attr) { |
|
665 | 665 | |
666 | - $bound = 0 === strpos( $tag, 'end' ) ? 'end' : 'start'; |
|
667 | - if ( ( 'end' == $bound ) && ( false === $event->end ) ) { |
|
666 | + $bound = 0 === strpos($tag, 'end') ? 'end' : 'start'; |
|
667 | + if (('end' == $bound) && (false === $event->end)) { |
|
668 | 668 | return ''; |
669 | 669 | } |
670 | 670 | |
671 | - $dt = $bound . '_dt'; |
|
672 | - if ( ! $event->$dt instanceof Carbon ) { |
|
671 | + $dt = $bound.'_dt'; |
|
672 | + if ( ! $event->$dt instanceof Carbon) { |
|
673 | 673 | return ''; |
674 | 674 | } |
675 | - $event_dt = $event->$dt->setTimezone( $event->timezone ); |
|
675 | + $event_dt = $event->$dt->setTimezone($event->timezone); |
|
676 | 676 | |
677 | - $attr = array_merge( array( |
|
677 | + $attr = array_merge(array( |
|
678 | 678 | 'format' => '', |
679 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
679 | + ), (array) shortcode_parse_atts($attr)); |
|
680 | 680 | |
681 | - $format = ltrim( strstr( $tag, '-' ), '-' ); |
|
681 | + $format = ltrim(strstr($tag, '-'), '-'); |
|
682 | 682 | $dt_format = ''; |
683 | - if ( ! empty( $attr['format'] ) ) { |
|
684 | - $dt_format = esc_attr( wp_strip_all_tags( $attr['format'] ) ); |
|
685 | - } elseif ( 'date' == $format ) { |
|
683 | + if ( ! empty($attr['format'])) { |
|
684 | + $dt_format = esc_attr(wp_strip_all_tags($attr['format'])); |
|
685 | + } elseif ('date' == $format) { |
|
686 | 686 | $dt_format = $this->calendar->date_format; |
687 | - } elseif ( 'time' == $format ) { |
|
687 | + } elseif ('time' == $format) { |
|
688 | 688 | $dt_format = $this->calendar->time_format; |
689 | 689 | } |
690 | 690 | |
691 | - if ( 'human' == $format ) { |
|
692 | - $value = human_time_diff( $event_dt->getTimestamp(), Carbon::now( $event->timezone )->getTimestamp() ); |
|
691 | + if ('human' == $format) { |
|
692 | + $value = human_time_diff($event_dt->getTimestamp(), Carbon::now($event->timezone)->getTimestamp()); |
|
693 | 693 | } else { |
694 | - $value = date_i18n( $dt_format, $event_dt->getTimestamp() ); |
|
694 | + $value = date_i18n($dt_format, $event_dt->getTimestamp()); |
|
695 | 695 | } |
696 | 696 | |
697 | - return '<span class="simcal-event-' . $bound . ' ' . 'simcal-event-' . $bound . '-' . $format . '"' . |
|
698 | - 'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '"' . |
|
699 | - 'data-event-format="' . $dt_format . '"' . |
|
700 | - 'itemprop="' . $bound . 'Date" content="' . $event_dt->toIso8601String() . '">' . |
|
701 | - $value . |
|
697 | + return '<span class="simcal-event-'.$bound.' '.'simcal-event-'.$bound.'-'.$format.'"'. |
|
698 | + 'data-event-'.$bound.'="'.$event_dt->getTimestamp().'"'. |
|
699 | + 'data-event-format="'.$dt_format.'"'. |
|
700 | + 'itemprop="'.$bound.'Date" content="'.$event_dt->toIso8601String().'">'. |
|
701 | + $value. |
|
702 | 702 | '</span>'; |
703 | 703 | } |
704 | 704 | |
@@ -715,23 +715,23 @@ discard block |
||
715 | 715 | * |
716 | 716 | * @return string |
717 | 717 | */ |
718 | - private function make_link( $tag, $url, $content, $attr ) { |
|
718 | + private function make_link($tag, $url, $content, $attr) { |
|
719 | 719 | |
720 | - if ( empty( $url ) ) { |
|
720 | + if (empty($url)) { |
|
721 | 721 | return ''; |
722 | 722 | } |
723 | 723 | |
724 | - $text = empty( $content ) ? $url : $content; |
|
724 | + $text = empty($content) ? $url : $content; |
|
725 | 725 | |
726 | - $attr = array_merge( array( |
|
727 | - 'autolink' => false, // Convert url to link anchor |
|
728 | - 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
729 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
726 | + $attr = array_merge(array( |
|
727 | + 'autolink' => false, // Convert url to link anchor |
|
728 | + 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
729 | + ), (array) shortcode_parse_atts($attr)); |
|
730 | 730 | |
731 | 731 | $anchor = $tag != 'url' ? 'yes' : $attr['autolink']; |
732 | 732 | $target = $attr['newwindow'] !== false ? 'target="_blank"' : ''; |
733 | 733 | |
734 | - return $anchor !== false ? ' <a href="' . esc_url( $url ) . '" ' . $target . '>' . $text . '</a>' : ' ' . $text; |
|
734 | + return $anchor !== false ? ' <a href="'.esc_url($url).'" '.$target.'>'.$text.'</a>' : ' '.$text; |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
@@ -744,20 +744,20 @@ discard block |
||
744 | 744 | * |
745 | 745 | * @return string |
746 | 746 | */ |
747 | - private function get_attachments( $attachments ) { |
|
747 | + private function get_attachments($attachments) { |
|
748 | 748 | |
749 | - $html = '<ul class="simcal-attachments">' . "\n\t"; |
|
749 | + $html = '<ul class="simcal-attachments">'."\n\t"; |
|
750 | 750 | |
751 | - foreach ( $attachments as $attachment ) { |
|
751 | + foreach ($attachments as $attachment) { |
|
752 | 752 | $html .= '<li class="simcal-attachment">'; |
753 | - $html .= '<a href="' . $attachment['url'] . '" target="_blank">'; |
|
754 | - $html .= ! empty( $attachment['icon'] ) ? '<img src="' . $attachment['icon'] . '" />' : ''; |
|
755 | - $html .= '<span>' . $attachment['name'] . '</span>'; |
|
753 | + $html .= '<a href="'.$attachment['url'].'" target="_blank">'; |
|
754 | + $html .= ! empty($attachment['icon']) ? '<img src="'.$attachment['icon'].'" />' : ''; |
|
755 | + $html .= '<span>'.$attachment['name'].'</span>'; |
|
756 | 756 | $html .= '</a>'; |
757 | - $html .= '</li>' . "\n"; |
|
757 | + $html .= '</li>'."\n"; |
|
758 | 758 | } |
759 | 759 | |
760 | - $html .= '</ul>' . "\n"; |
|
760 | + $html .= '</ul>'."\n"; |
|
761 | 761 | |
762 | 762 | return $html; |
763 | 763 | } |
@@ -773,41 +773,41 @@ discard block |
||
773 | 773 | * |
774 | 774 | * @return string |
775 | 775 | */ |
776 | - private function get_attendees( $attendees, $attr ) { |
|
776 | + private function get_attendees($attendees, $attr) { |
|
777 | 777 | |
778 | - $attr = array_merge( array( |
|
779 | - 'photo' => 'show', // show/hide attendee photo |
|
780 | - 'email' => 'hide', // show/hide attendee email address |
|
781 | - 'rsvp' => 'hide', // show/hide rsvp response status |
|
782 | - 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
783 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
778 | + $attr = array_merge(array( |
|
779 | + 'photo' => 'show', // show/hide attendee photo |
|
780 | + 'email' => 'hide', // show/hide attendee email address |
|
781 | + 'rsvp' => 'hide', // show/hide rsvp response status |
|
782 | + 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
783 | + ), (array) shortcode_parse_atts($attr)); |
|
784 | 784 | |
785 | - $html = '<ul class="simcal-attendees" itemprop="attendees">' . "\n\t"; |
|
785 | + $html = '<ul class="simcal-attendees" itemprop="attendees">'."\n\t"; |
|
786 | 786 | |
787 | 787 | $known = 0; |
788 | 788 | $unknown = 0; |
789 | 789 | |
790 | - foreach ( $attendees as $attendee ) { |
|
790 | + foreach ($attendees as $attendee) { |
|
791 | 791 | |
792 | - if ( 'yes' == $attr['response'] && 'yes' != $attendee['response'] ) { |
|
792 | + if ('yes' == $attr['response'] && 'yes' != $attendee['response']) { |
|
793 | 793 | continue; |
794 | - } elseif ( 'no' == $attr['response'] && 'no' != $attendee['response'] ) { |
|
794 | + } elseif ('no' == $attr['response'] && 'no' != $attendee['response']) { |
|
795 | 795 | continue; |
796 | - } elseif ( 'maybe' == $attr['response'] && ! in_array( $attendee['response'], array( 'yes', 'maybe' ) ) ) { |
|
796 | + } elseif ('maybe' == $attr['response'] && ! in_array($attendee['response'], array('yes', 'maybe'))) { |
|
797 | 797 | continue; |
798 | 798 | } |
799 | 799 | |
800 | - if ( ! empty( $attendee['name'] ) ) { |
|
800 | + if ( ! empty($attendee['name'])) { |
|
801 | 801 | |
802 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $attendee['photo'] . '" itemprop="image" />' : ''; |
|
803 | - $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response( $attendee['response'] ) : ''; |
|
804 | - $guest = $photo . '<span itemprop="name">' . $attendee['name'] . $response . '</span>'; |
|
802 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$attendee['photo'].'" itemprop="image" />' : ''; |
|
803 | + $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response($attendee['response']) : ''; |
|
804 | + $guest = $photo.'<span itemprop="name">'.$attendee['name'].$response.'</span>'; |
|
805 | 805 | |
806 | - if ( ! empty( $attendee['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
807 | - $guest = sprintf( '<a href="mailto:' . $attendee['email'] . '" itemprop="email">%s</a>', $guest ); |
|
806 | + if ( ! empty($attendee['email']) && ('show' == $attr['email'])) { |
|
807 | + $guest = sprintf('<a href="mailto:'.$attendee['email'].'" itemprop="email">%s</a>', $guest); |
|
808 | 808 | } |
809 | 809 | |
810 | - $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">' . $guest . '</li>' . "\n"; |
|
810 | + $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">'.$guest.'</li>'."\n"; |
|
811 | 811 | |
812 | 812 | $known++; |
813 | 813 | |
@@ -818,21 +818,21 @@ discard block |
||
818 | 818 | } |
819 | 819 | } |
820 | 820 | |
821 | - if ( $unknown > 0 ) { |
|
822 | - if ( $known > 0 ) { |
|
821 | + if ($unknown > 0) { |
|
822 | + if ($known > 0) { |
|
823 | 823 | /* translators: One more person attending the event. */ |
824 | - $others = sprintf( _n( '1 more attendee', '%s more attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
824 | + $others = sprintf(_n('1 more attendee', '%s more attendees', $unknown, 'google-calendar-events'), $unknown); |
|
825 | 825 | } else { |
826 | 826 | /* translators: One or more persons attending the event whose name is unknown. */ |
827 | - $others = sprintf( _n( '1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
827 | + $others = sprintf(_n('1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events'), $unknown); |
|
828 | 828 | } |
829 | - $photo = $attr['photo'] !== 'hide' ? get_avatar( '', 128 ) : ''; |
|
830 | - $html .= '<li class="simcal-attendee simcal-attendee-anonymous">' . $photo . '<span>' . $others . '</span></li>' . "\n"; |
|
831 | - } elseif ( $known === 0 ) { |
|
832 | - $html .= '<li class="simcal-attendee">' . _x( 'No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events' ) . '</li>' . "\n"; |
|
829 | + $photo = $attr['photo'] !== 'hide' ? get_avatar('', 128) : ''; |
|
830 | + $html .= '<li class="simcal-attendee simcal-attendee-anonymous">'.$photo.'<span>'.$others.'</span></li>'."\n"; |
|
831 | + } elseif ($known === 0) { |
|
832 | + $html .= '<li class="simcal-attendee">'._x('No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events').'</li>'."\n"; |
|
833 | 833 | } |
834 | 834 | |
835 | - $html .= '</ul>' . "\n"; |
|
835 | + $html .= '</ul>'."\n"; |
|
836 | 836 | |
837 | 837 | return $html; |
838 | 838 | } |
@@ -846,23 +846,23 @@ discard block |
||
846 | 846 | * |
847 | 847 | * @return string |
848 | 848 | */ |
849 | - private function get_rsvp_response( $response ) { |
|
849 | + private function get_rsvp_response($response) { |
|
850 | 850 | |
851 | - if ( 'yes' == $response ) { |
|
851 | + if ('yes' == $response) { |
|
852 | 852 | /* translators: Someone replied with 'yes' to a rsvp request. */ |
853 | - $rsvp = __( 'Attending', 'google-calendar-events' ); |
|
854 | - } elseif ( 'no' == $response ) { |
|
853 | + $rsvp = __('Attending', 'google-calendar-events'); |
|
854 | + } elseif ('no' == $response) { |
|
855 | 855 | /* translators: Someone replied with 'no' to a rsvp request. */ |
856 | - $rsvp = __( 'Not attending', 'google-calendar-events' ); |
|
857 | - } elseif ( 'maybe' == $response ) { |
|
856 | + $rsvp = __('Not attending', 'google-calendar-events'); |
|
857 | + } elseif ('maybe' == $response) { |
|
858 | 858 | /* translators: Someone replied with 'maybe' to a rsvp request. */ |
859 | - $rsvp = __( 'Maybe attending', 'google-calendar-events' ); |
|
859 | + $rsvp = __('Maybe attending', 'google-calendar-events'); |
|
860 | 860 | } else { |
861 | 861 | /* translators: Someone did not send yet a rsvp confirmation to join an event. */ |
862 | - $rsvp = __( 'Response pending', 'google-calendar-events' ); |
|
862 | + $rsvp = __('Response pending', 'google-calendar-events'); |
|
863 | 863 | } |
864 | 864 | |
865 | - return ' <small>(' . $rsvp . ')</small>'; |
|
865 | + return ' <small>('.$rsvp.')</small>'; |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | /** |
@@ -876,21 +876,21 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return string |
878 | 878 | */ |
879 | - private function get_organizer( $organizer, $attr ) { |
|
879 | + private function get_organizer($organizer, $attr) { |
|
880 | 880 | |
881 | - $attr = array_merge( array( |
|
882 | - 'photo' => 'show', // show/hide attendee photo |
|
883 | - 'email' => 'hide', // show/hide attendee email address |
|
884 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
881 | + $attr = array_merge(array( |
|
882 | + 'photo' => 'show', // show/hide attendee photo |
|
883 | + 'email' => 'hide', // show/hide attendee email address |
|
884 | + ), (array) shortcode_parse_atts($attr)); |
|
885 | 885 | |
886 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $organizer['photo'] . '" itemprop="image" />' : ''; |
|
887 | - $organizer_html = $photo . '<span itemprop="name">' . $organizer['name'] . '</span>'; |
|
886 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$organizer['photo'].'" itemprop="image" />' : ''; |
|
887 | + $organizer_html = $photo.'<span itemprop="name">'.$organizer['name'].'</span>'; |
|
888 | 888 | |
889 | - if ( ! empty( $organizer['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
890 | - $organizer_html = sprintf( '<a href="mailto:' . $organizer['email'] . '" itemprop="email">%s</a>', $organizer_html ); |
|
889 | + if ( ! empty($organizer['email']) && ('show' == $attr['email'])) { |
|
890 | + $organizer_html = sprintf('<a href="mailto:'.$organizer['email'].'" itemprop="email">%s</a>', $organizer_html); |
|
891 | 891 | } |
892 | 892 | |
893 | - return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">' . $organizer_html . '</div>'; |
|
893 | + return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">'.$organizer_html.'</div>'; |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | /** |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | // This is largely borrowed on get_shortcode_regex() from WordPress Core. |
916 | 916 | // @see /wp-includes/shortcodes.php (with some modification) |
917 | 917 | |
918 | - $tagregexp = implode( '|', array_values( $this->tags ) ); |
|
918 | + $tagregexp = implode('|', array_values($this->tags)); |
|
919 | 919 | |
920 | 920 | return '/' |
921 | 921 | . '\\[' // Opening bracket |