@@ -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> |
@@ -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 | } |
@@ -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 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use Carbon\Carbon; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | * @param array $e Events. |
| 46 | 46 | * @param string|\DateTimeZone $tz Timezone. |
| 47 | 47 | */ |
| 48 | - public function __construct( $e = array(), $tz = 'UTC' ) { |
|
| 49 | - $this->set_events( $e ); |
|
| 50 | - $this->set_timezone( $tz ); |
|
| 48 | + public function __construct($e = array(), $tz = 'UTC') { |
|
| 49 | + $this->set_events($e); |
|
| 50 | + $this->set_timezone($tz); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -59,10 +59,10 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @return array |
| 61 | 61 | */ |
| 62 | - public function get_events( $n = '' ) { |
|
| 63 | - if ( ! empty( $n ) && ! empty( $this->events ) ) { |
|
| 64 | - $length = absint( $n ); |
|
| 65 | - return array_slice( $this->events, 0, $length, true ); |
|
| 62 | + public function get_events($n = '') { |
|
| 63 | + if ( ! empty($n) && ! empty($this->events)) { |
|
| 64 | + $length = absint($n); |
|
| 65 | + return array_slice($this->events, 0, $length, true); |
|
| 66 | 66 | } |
| 67 | 67 | return $this->events; |
| 68 | 68 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @param array $ev Events. |
| 76 | 76 | */ |
| 77 | - public function set_events( array $ev ) { |
|
| 77 | + public function set_events(array $ev) { |
|
| 78 | 78 | $this->events = $ev; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | * |
| 88 | 88 | * @return Events |
| 89 | 89 | */ |
| 90 | - public function set_timezone( $tz ) { |
|
| 91 | - if ( $tz instanceof \DateTimeZone ) { |
|
| 90 | + public function set_timezone($tz) { |
|
| 91 | + if ($tz instanceof \DateTimeZone) { |
|
| 92 | 92 | $tz = $tz->getName(); |
| 93 | 93 | } |
| 94 | - $this->timezone = simcal_esc_timezone( $tz, $this->timezone ); |
|
| 94 | + $this->timezone = simcal_esc_timezone($tz, $this->timezone); |
|
| 95 | 95 | return $this; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -104,11 +104,11 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @return Events |
| 106 | 106 | */ |
| 107 | - public function shift( $n ) { |
|
| 108 | - if ( ! empty( $this->events ) ) { |
|
| 109 | - $offset = intval( $n ); |
|
| 110 | - $length = count( $this->events ); |
|
| 111 | - $this->set_events( array_slice( $this->events, $offset, $length, true ) ); |
|
| 107 | + public function shift($n) { |
|
| 108 | + if ( ! empty($this->events)) { |
|
| 109 | + $offset = intval($n); |
|
| 110 | + $length = count($this->events); |
|
| 111 | + $this->set_events(array_slice($this->events, $offset, $length, true)); |
|
| 112 | 112 | } |
| 113 | 113 | return $this; |
| 114 | 114 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @return Events |
| 122 | 122 | */ |
| 123 | 123 | public function private_only() { |
| 124 | - $this->set_events( $this->filter_property( 'public', 'hide' ) ); |
|
| 124 | + $this->set_events($this->filter_property('public', 'hide')); |
|
| 125 | 125 | return $this; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @return Events |
| 134 | 134 | */ |
| 135 | 135 | public function public_only() { |
| 136 | - $this->set_events( $this->filter_property( 'public', 'show' ) ); |
|
| 136 | + $this->set_events($this->filter_property('public', 'show')); |
|
| 137 | 137 | return $this; |
| 138 | 138 | } |
| 139 | 139 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @return Events |
| 146 | 146 | */ |
| 147 | 147 | public function recurring() { |
| 148 | - $this->set_events( $this->filter_property( 'recurrence', 'show' ) ); |
|
| 148 | + $this->set_events($this->filter_property('recurrence', 'show')); |
|
| 149 | 149 | return $this; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @return Events |
| 158 | 158 | */ |
| 159 | 159 | public function not_recurring() { |
| 160 | - $this->set_events( $this->filter_property( 'recurrence', 'hide' ) ); |
|
| 160 | + $this->set_events($this->filter_property('recurrence', 'hide')); |
|
| 161 | 161 | return $this; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @return Events |
| 170 | 170 | */ |
| 171 | 171 | public function whole_day() { |
| 172 | - $this->set_events( $this->filter_property( 'whole_day', 'show' ) ); |
|
| 172 | + $this->set_events($this->filter_property('whole_day', 'show')); |
|
| 173 | 173 | return $this; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @return Events |
| 182 | 182 | */ |
| 183 | 183 | public function not_whole_day() { |
| 184 | - $this->set_events( $this->filter_property( 'whole_day', 'hide' ) ); |
|
| 184 | + $this->set_events($this->filter_property('whole_day', 'hide')); |
|
| 185 | 185 | return $this; |
| 186 | 186 | } |
| 187 | 187 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @return Events |
| 194 | 194 | */ |
| 195 | 195 | public function multi_day() { |
| 196 | - $this->set_events( $this->filter_property( 'multiple_days', 'show' ) ); |
|
| 196 | + $this->set_events($this->filter_property('multiple_days', 'show')); |
|
| 197 | 197 | return $this; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @return Events |
| 206 | 206 | */ |
| 207 | 207 | public function single_day() { |
| 208 | - $this->set_events( $this->filter_property( 'multiple_days', 'hide' ) ); |
|
| 208 | + $this->set_events($this->filter_property('multiple_days', 'hide')); |
|
| 209 | 209 | return $this; |
| 210 | 210 | } |
| 211 | 211 | |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * @return Events |
| 218 | 218 | */ |
| 219 | 219 | public function with_location() { |
| 220 | - $this->set_events( $this->filter_property( 'venue', 'show' ) ); |
|
| 220 | + $this->set_events($this->filter_property('venue', 'show')); |
|
| 221 | 221 | return $this; |
| 222 | 222 | } |
| 223 | 223 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @return Events |
| 230 | 230 | */ |
| 231 | 231 | public function without_location() { |
| 232 | - $this->set_events( $this->filter_property( 'venue', 'hide' ) ); |
|
| 232 | + $this->set_events($this->filter_property('venue', 'hide')); |
|
| 233 | 233 | return $this; |
| 234 | 234 | } |
| 235 | 235 | |
@@ -244,18 +244,18 @@ discard block |
||
| 244 | 244 | * |
| 245 | 245 | * @return array |
| 246 | 246 | */ |
| 247 | - private function filter_property( $property, $toggle ) { |
|
| 247 | + private function filter_property($property, $toggle) { |
|
| 248 | 248 | $filtered = array(); |
| 249 | - if ( ! empty( $this->events ) ) { |
|
| 250 | - foreach ( $this->events as $ts => $events ) { |
|
| 251 | - foreach ( $events as $event ) { |
|
| 252 | - if ( 'hide' == $toggle ) { |
|
| 253 | - if ( ! $event->$property ) { |
|
| 254 | - $filtered[ $ts ][] = $event; |
|
| 249 | + if ( ! empty($this->events)) { |
|
| 250 | + foreach ($this->events as $ts => $events) { |
|
| 251 | + foreach ($events as $event) { |
|
| 252 | + if ('hide' == $toggle) { |
|
| 253 | + if ( ! $event->$property) { |
|
| 254 | + $filtered[$ts][] = $event; |
|
| 255 | 255 | } |
| 256 | - } elseif ( 'show' == $toggle ) { |
|
| 257 | - if ( $event->$property ) { |
|
| 258 | - $filtered[ $ts ][] = $event; |
|
| 256 | + } elseif ('show' == $toggle) { |
|
| 257 | + if ($event->$property) { |
|
| 258 | + $filtered[$ts][] = $event; |
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | } |
@@ -273,14 +273,14 @@ discard block |
||
| 273 | 273 | * |
| 274 | 274 | * @return Events |
| 275 | 275 | */ |
| 276 | - public function future( $present = '' ) { |
|
| 276 | + public function future($present = '') { |
|
| 277 | 277 | $last = $this->get_last(); |
| 278 | 278 | $to = $last instanceof Event ? $last->start_utc : false; |
| 279 | - if ( $to ) { |
|
| 280 | - if ( empty( $present ) ) { |
|
| 281 | - $present = Carbon::now( $this->timezone )->getTimestamp(); |
|
| 279 | + if ($to) { |
|
| 280 | + if (empty($present)) { |
|
| 281 | + $present = Carbon::now($this->timezone)->getTimestamp(); |
|
| 282 | 282 | } |
| 283 | - $this->set_events( $this->filter_events( intval( $present ), $to ) ); |
|
| 283 | + $this->set_events($this->filter_events(intval($present), $to)); |
|
| 284 | 284 | } |
| 285 | 285 | return $this; |
| 286 | 286 | } |
@@ -294,14 +294,14 @@ discard block |
||
| 294 | 294 | * |
| 295 | 295 | * @return Events |
| 296 | 296 | */ |
| 297 | - public function past( $present = '' ) { |
|
| 297 | + public function past($present = '') { |
|
| 298 | 298 | $first = $this->get_last(); |
| 299 | 299 | $from = $first instanceof Event ? $first->start_utc : false; |
| 300 | - if ( $from ) { |
|
| 301 | - if ( empty( $present ) ) { |
|
| 302 | - $present = Carbon::now( $this->timezone )->getTimestamp(); |
|
| 300 | + if ($from) { |
|
| 301 | + if (empty($present)) { |
|
| 302 | + $present = Carbon::now($this->timezone)->getTimestamp(); |
|
| 303 | 303 | } |
| 304 | - $this->set_events( $this->filter_events( $from, intval( $present ) ) ); |
|
| 304 | + $this->set_events($this->filter_events($from, intval($present))); |
|
| 305 | 305 | } |
| 306 | 306 | return $this; |
| 307 | 307 | } |
@@ -315,9 +315,9 @@ discard block |
||
| 315 | 315 | * |
| 316 | 316 | * @return Events |
| 317 | 317 | */ |
| 318 | - public function after( $time ) { |
|
| 319 | - $dt = $this->parse( $time ); |
|
| 320 | - return ! is_null( $dt ) ? $this->future( $dt->getTimestamp() ) : $this; |
|
| 318 | + public function after($time) { |
|
| 319 | + $dt = $this->parse($time); |
|
| 320 | + return ! is_null($dt) ? $this->future($dt->getTimestamp()) : $this; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -329,9 +329,9 @@ discard block |
||
| 329 | 329 | * |
| 330 | 330 | * @return Events |
| 331 | 331 | */ |
| 332 | - public function before( $time ) { |
|
| 333 | - $dt = $this->parse( $time ); |
|
| 334 | - return ! is_null( $dt ) ? $this->past( $dt->getTimestamp() ) : $this; |
|
| 332 | + public function before($time) { |
|
| 333 | + $dt = $this->parse($time); |
|
| 334 | + return ! is_null($dt) ? $this->past($dt->getTimestamp()) : $this; |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -343,10 +343,10 @@ discard block |
||
| 343 | 343 | * |
| 344 | 344 | * @return Events |
| 345 | 345 | */ |
| 346 | - public function from( $time ) { |
|
| 347 | - $last = $this->parse( $time ); |
|
| 348 | - if ( ! is_null( $last ) ) { |
|
| 349 | - $this->set_events( $this->filter_events( $time, $last->getTimestamp() ) ); |
|
| 346 | + public function from($time) { |
|
| 347 | + $last = $this->parse($time); |
|
| 348 | + if ( ! is_null($last)) { |
|
| 349 | + $this->set_events($this->filter_events($time, $last->getTimestamp())); |
|
| 350 | 350 | } |
| 351 | 351 | return $this; |
| 352 | 352 | } |
@@ -360,10 +360,10 @@ discard block |
||
| 360 | 360 | * |
| 361 | 361 | * @return Events |
| 362 | 362 | */ |
| 363 | - public function to( $time ) { |
|
| 364 | - $first = $this->parse( $time ); |
|
| 365 | - if ( ! is_null( $first ) ) { |
|
| 366 | - $this->set_events( $this->filter_events( $first->getTimestamp(), $time ) ); |
|
| 363 | + public function to($time) { |
|
| 364 | + $first = $this->parse($time); |
|
| 365 | + if ( ! is_null($first)) { |
|
| 366 | + $this->set_events($this->filter_events($first->getTimestamp(), $time)); |
|
| 367 | 367 | } |
| 368 | 368 | return $this; |
| 369 | 369 | } |
@@ -377,15 +377,15 @@ discard block |
||
| 377 | 377 | * |
| 378 | 378 | * @return null|Carbon |
| 379 | 379 | */ |
| 380 | - private function parse( $time ) { |
|
| 381 | - if ( is_int( $time ) ) { |
|
| 382 | - return Carbon::createFromTimestamp( $time, $this->timezone ); |
|
| 383 | - } elseif ( is_string( $time ) && ! empty( $time ) ) { |
|
| 384 | - return Carbon::parse( $time, $this->timezone ); |
|
| 385 | - } elseif ( $time instanceof Carbon ) { |
|
| 386 | - return $time->setTimezone( $this->timezone ); |
|
| 387 | - } elseif ( $time instanceof \DateTime ) { |
|
| 388 | - return Carbon::instance( $time )->setTimezone( $this->timezone ); |
|
| 380 | + private function parse($time) { |
|
| 381 | + if (is_int($time)) { |
|
| 382 | + return Carbon::createFromTimestamp($time, $this->timezone); |
|
| 383 | + } elseif (is_string($time) && ! empty($time)) { |
|
| 384 | + return Carbon::parse($time, $this->timezone); |
|
| 385 | + } elseif ($time instanceof Carbon) { |
|
| 386 | + return $time->setTimezone($this->timezone); |
|
| 387 | + } elseif ($time instanceof \DateTime) { |
|
| 388 | + return Carbon::instance($time)->setTimezone($this->timezone); |
|
| 389 | 389 | } |
| 390 | 390 | return null; |
| 391 | 391 | } |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | * @return null|Event |
| 399 | 399 | */ |
| 400 | 400 | public function get_first() { |
| 401 | - return array_shift( $this->events ); |
|
| 401 | + return array_shift($this->events); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | /** |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | * @return null|Event |
| 410 | 410 | */ |
| 411 | 411 | public function get_last() { |
| 412 | - return array_pop( $this->events ); |
|
| 412 | + return array_pop($this->events); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | /** |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | * @return null|Event |
| 421 | 421 | */ |
| 422 | 422 | public function get_upcoming() { |
| 423 | - return $this->get_closest( 'future' ); |
|
| 423 | + return $this->get_closest('future'); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | * @return null|Event |
| 432 | 432 | */ |
| 433 | 433 | public function get_latest() { |
| 434 | - return $this->get_closest( 'past' ); |
|
| 434 | + return $this->get_closest('past'); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** |
@@ -444,11 +444,11 @@ discard block |
||
| 444 | 444 | * |
| 445 | 445 | * @return null|Event |
| 446 | 446 | */ |
| 447 | - private function get_closest( $dir ) { |
|
| 448 | - if ( 'future' == $dir ) { |
|
| 449 | - return array_shift( $this->future()->get_events() ); |
|
| 450 | - } elseif ( 'past' == $dir ) { |
|
| 451 | - return array_shift( $this->past()->get_events() ); |
|
| 447 | + private function get_closest($dir) { |
|
| 448 | + if ('future' == $dir) { |
|
| 449 | + return array_shift($this->future()->get_events()); |
|
| 450 | + } elseif ('past' == $dir) { |
|
| 451 | + return array_shift($this->past()->get_events()); |
|
| 452 | 452 | } |
| 453 | 453 | return null; |
| 454 | 454 | } |
@@ -462,11 +462,11 @@ discard block |
||
| 462 | 462 | * |
| 463 | 463 | * @return array Multidimensional array with month number, week number and Event objects for each weekday. |
| 464 | 464 | */ |
| 465 | - public function get_year( $year ) { |
|
| 466 | - $y = intval( $year ); |
|
| 465 | + public function get_year($year) { |
|
| 466 | + $y = intval($year); |
|
| 467 | 467 | $months = array(); |
| 468 | - for ( $m = 1; $m <= 12; $m++ ) { |
|
| 469 | - $months[ strval( $m ) ] = $this->get_month( $y, $m ); |
|
| 468 | + for ($m = 1; $m <= 12; $m++) { |
|
| 469 | + $months[strval($m)] = $this->get_month($y, $m); |
|
| 470 | 470 | } |
| 471 | 471 | return $months; |
| 472 | 472 | } |
@@ -481,16 +481,16 @@ discard block |
||
| 481 | 481 | * |
| 482 | 482 | * @return array Multidimensional array with week number, day of the week and array of Event objects for each week day. |
| 483 | 483 | */ |
| 484 | - public function get_month( $year, $month ) { |
|
| 485 | - $y = intval( $year ); |
|
| 486 | - $m = min( max( 1, absint( $month ) ), 12 ); |
|
| 487 | - $days = Carbon::createFromDate( $y, $m, 2, $this->timezone )->startOfMonth()->daysInMonth; |
|
| 484 | + public function get_month($year, $month) { |
|
| 485 | + $y = intval($year); |
|
| 486 | + $m = min(max(1, absint($month)), 12); |
|
| 487 | + $days = Carbon::createFromDate($y, $m, 2, $this->timezone)->startOfMonth()->daysInMonth; |
|
| 488 | 488 | $weeks = array(); |
| 489 | - for ( $d = 1; $d < $days; $d++ ) { |
|
| 490 | - $current = Carbon::createFromDate( $y, $m, $d ); |
|
| 489 | + for ($d = 1; $d < $days; $d++) { |
|
| 490 | + $current = Carbon::createFromDate($y, $m, $d); |
|
| 491 | 491 | $week = $current->weekOfYear; |
| 492 | 492 | $day = $current->dayOfWeek; |
| 493 | - $weeks[ strval( $week ) ][ strval( $day ) ] = $this->get_day( $y, $m, $d ); |
|
| 493 | + $weeks[strval($week)][strval($day)] = $this->get_day($y, $m, $d); |
|
| 494 | 494 | } |
| 495 | 495 | return $weeks; |
| 496 | 496 | } |
@@ -505,16 +505,16 @@ discard block |
||
| 505 | 505 | * |
| 506 | 506 | * @return array Associative array with day of the week for key and array of Event objects for value. |
| 507 | 507 | */ |
| 508 | - public function get_week( $year, $week ) { |
|
| 509 | - $y = intval( $year ); |
|
| 510 | - $w = absint( $week ); |
|
| 511 | - $m = date( 'n', strtotime( strval( $y ) . '-W' . strval( $w ) ) ); |
|
| 512 | - $month_dt = Carbon::createFromDate( $y, $m, 2, $this->timezone ); |
|
| 508 | + public function get_week($year, $week) { |
|
| 509 | + $y = intval($year); |
|
| 510 | + $w = absint($week); |
|
| 511 | + $m = date('n', strtotime(strval($y).'-W'.strval($w))); |
|
| 512 | + $month_dt = Carbon::createFromDate($y, $m, 2, $this->timezone); |
|
| 513 | 513 | $days = array(); |
| 514 | - for ( $d = 1; $d < $month_dt->daysInMonth; $d++ ) { |
|
| 515 | - $current = Carbon::createFromDate( $y, $m, $d ); |
|
| 516 | - if ( $w == $current->weekOfYear ) { |
|
| 517 | - $days[ strval( $current->dayOfWeek ) ] = $this->get_day( $y, $m, $d ); |
|
| 514 | + for ($d = 1; $d < $month_dt->daysInMonth; $d++) { |
|
| 515 | + $current = Carbon::createFromDate($y, $m, $d); |
|
| 516 | + if ($w == $current->weekOfYear) { |
|
| 517 | + $days[strval($current->dayOfWeek)] = $this->get_day($y, $m, $d); |
|
| 518 | 518 | } |
| 519 | 519 | } |
| 520 | 520 | return $days; |
@@ -531,13 +531,13 @@ discard block |
||
| 531 | 531 | * |
| 532 | 532 | * @return array Event objects for the day. |
| 533 | 533 | */ |
| 534 | - public function get_day( $year, $month, $day ) { |
|
| 535 | - $y = intval( $year ); |
|
| 536 | - $m = min( max( 1, absint( $month ) ), 12 ); |
|
| 537 | - $d = min( absint( $day ), 31 ); |
|
| 538 | - $from = Carbon::createFromDate( $y, $m, $d, $this->timezone )->startOfDay()->getTimestamp(); |
|
| 539 | - $to = Carbon::createFromDate( $y, $m, $d, $this->timezone )->endOfDay()->getTimestamp(); |
|
| 540 | - return $this->filter_events( $from, $to ); |
|
| 534 | + public function get_day($year, $month, $day) { |
|
| 535 | + $y = intval($year); |
|
| 536 | + $m = min(max(1, absint($month)), 12); |
|
| 537 | + $d = min(absint($day), 31); |
|
| 538 | + $from = Carbon::createFromDate($y, $m, $d, $this->timezone)->startOfDay()->getTimestamp(); |
|
| 539 | + $to = Carbon::createFromDate($y, $m, $d, $this->timezone)->endOfDay()->getTimestamp(); |
|
| 540 | + return $this->filter_events($from, $to); |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | /** |
@@ -548,9 +548,9 @@ discard block |
||
| 548 | 548 | * @return array Event objects for today. |
| 549 | 549 | */ |
| 550 | 550 | public function get_today() { |
| 551 | - $start = Carbon::today( $this->timezone )->startOfDay()->getTimestamp(); |
|
| 552 | - $end = Carbon::today( $this->timezone )->endOfDay()->getTimestamp(); |
|
| 553 | - return $this->filter_events( $start, $end ); |
|
| 551 | + $start = Carbon::today($this->timezone)->startOfDay()->getTimestamp(); |
|
| 552 | + $end = Carbon::today($this->timezone)->endOfDay()->getTimestamp(); |
|
| 553 | + return $this->filter_events($start, $end); |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | /** |
@@ -561,9 +561,9 @@ discard block |
||
| 561 | 561 | * @return array Event objects for tomorrow. |
| 562 | 562 | */ |
| 563 | 563 | public function get_tomorrow() { |
| 564 | - $start = Carbon::tomorrow( $this->timezone )->startOfDay()->getTimestamp(); |
|
| 565 | - $end = Carbon::tomorrow( $this->timezone )->endOfDay()->getTimestamp(); |
|
| 566 | - return $this->filter_events( $start, $end ); |
|
| 564 | + $start = Carbon::tomorrow($this->timezone)->startOfDay()->getTimestamp(); |
|
| 565 | + $end = Carbon::tomorrow($this->timezone)->endOfDay()->getTimestamp(); |
|
| 566 | + return $this->filter_events($start, $end); |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | /** |
@@ -574,9 +574,9 @@ discard block |
||
| 574 | 574 | * @return array Event objects for yesterday. |
| 575 | 575 | */ |
| 576 | 576 | public function get_yesterday() { |
| 577 | - $start = Carbon::yesterday( $this->timezone )->startOfDay()->getTimestamp(); |
|
| 578 | - $end = Carbon::yesterday( $this->timezone )->endOfDay()->getTimestamp(); |
|
| 579 | - return $this->filter_events( $start, $end ); |
|
| 577 | + $start = Carbon::yesterday($this->timezone)->startOfDay()->getTimestamp(); |
|
| 578 | + $end = Carbon::yesterday($this->timezone)->endOfDay()->getTimestamp(); |
|
| 579 | + return $this->filter_events($start, $end); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | /** |
@@ -590,16 +590,16 @@ discard block |
||
| 590 | 590 | * |
| 591 | 591 | * @return array Filtered array of Event objects. |
| 592 | 592 | */ |
| 593 | - private function filter_events( $from, $to ) { |
|
| 594 | - $timestamps = array_keys( $this->events ); |
|
| 595 | - $lower_bound = array_filter( $timestamps, function( $ts ) use( $from ) { |
|
| 596 | - return intval( $ts ) > intval( $from ); |
|
| 593 | + private function filter_events($from, $to) { |
|
| 594 | + $timestamps = array_keys($this->events); |
|
| 595 | + $lower_bound = array_filter($timestamps, function($ts) use($from) { |
|
| 596 | + return intval($ts) > intval($from); |
|
| 597 | 597 | } ); |
| 598 | - $higher_bound = array_filter( $lower_bound, function( $ts ) use( $to ) { |
|
| 599 | - return intval( $ts ) > intval( $to ); |
|
| 598 | + $higher_bound = array_filter($lower_bound, function($ts) use($to) { |
|
| 599 | + return intval($ts) > intval($to); |
|
| 600 | 600 | } ); |
| 601 | - $filtered = array_combine( $higher_bound, $higher_bound ); |
|
| 602 | - return array_intersect_key( $this->events, $filtered ); |
|
| 601 | + $filtered = array_combine($higher_bound, $higher_bound); |
|
| 602 | + return array_intersect_key($this->events, $filtered); |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @deprecated |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -16,18 +16,18 @@ discard block |
||
| 16 | 16 | * Print a calendar. |
| 17 | 17 | * @deprecated Use simcal_print_calendar() |
| 18 | 18 | */ |
| 19 | -function gce_print_calendar( $feed_ids, $display, $args ) { |
|
| 19 | +function gce_print_calendar($feed_ids, $display, $args) { |
|
| 20 | 20 | |
| 21 | 21 | $id = 0; |
| 22 | 22 | |
| 23 | - if ( is_numeric( $feed_ids ) ) { |
|
| 24 | - $id = intval( $feed_ids ); |
|
| 25 | - } elseif ( is_array( $feed_ids ) ) { |
|
| 26 | - $id = isset( $feed_ids[0] ) ? intval( $feed_ids[0] ) : ''; |
|
| 23 | + if (is_numeric($feed_ids)) { |
|
| 24 | + $id = intval($feed_ids); |
|
| 25 | + } elseif (is_array($feed_ids)) { |
|
| 26 | + $id = isset($feed_ids[0]) ? intval($feed_ids[0]) : ''; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - if ( $id > 0 ) { |
|
| 30 | - simcal_print_calendar( $id ); |
|
| 29 | + if ($id > 0) { |
|
| 30 | + simcal_print_calendar($id); |
|
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
@@ -35,16 +35,16 @@ discard block |
||
| 35 | 35 | * Convert date from mm/dd/yyyy to unix timestamp. |
| 36 | 36 | * @deprecated Assumes a US-only time format. |
| 37 | 37 | */ |
| 38 | -function gce_date_unix( $date = '' ) { |
|
| 39 | - if ( empty( $date ) ) { |
|
| 40 | - $current_time = current_time( 'timestamp' ); |
|
| 41 | - $timestamp = mktime( 0, 0, 0, date( 'm', $current_time ), date( 'd', $current_time ), date( 'Y', $current_time ) ); |
|
| 38 | +function gce_date_unix($date = '') { |
|
| 39 | + if (empty($date)) { |
|
| 40 | + $current_time = current_time('timestamp'); |
|
| 41 | + $timestamp = mktime(0, 0, 0, date('m', $current_time), date('d', $current_time), date('Y', $current_time)); |
|
| 42 | 42 | } else { |
| 43 | - $date = explode( '/', $date ); |
|
| 43 | + $date = explode('/', $date); |
|
| 44 | 44 | $month = $date[0]; |
| 45 | 45 | $day = $date[1]; |
| 46 | 46 | $year = $date[2]; |
| 47 | - $timestamp = mktime( 0, 0, 0, $month, $day, $year ); |
|
| 47 | + $timestamp = mktime(0, 0, 0, $month, $day, $year); |
|
| 48 | 48 | } |
| 49 | 49 | return $timestamp; |
| 50 | 50 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Admin\Pages; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | self::create_terms(); |
| 35 | 35 | self::create_options(); |
| 36 | 36 | |
| 37 | - do_action( 'simcal_activated' ); |
|
| 37 | + do_action('simcal_activated'); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | flush_rewrite_rules(); |
| 48 | 48 | |
| 49 | - do_action( 'simcal_deactivated' ); |
|
| 49 | + do_action('simcal_deactivated'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | ) |
| 67 | 67 | ); |
| 68 | 68 | |
| 69 | - foreach ( $taxonomies as $taxonomy => $terms ) { |
|
| 70 | - foreach ( $terms as $term ) { |
|
| 71 | - if ( ! get_term_by( 'slug', sanitize_title( $term ), $taxonomy ) ) { |
|
| 72 | - wp_insert_term( $term, $taxonomy ); |
|
| 69 | + foreach ($taxonomies as $taxonomy => $terms) { |
|
| 70 | + foreach ($terms as $term) { |
|
| 71 | + if ( ! get_term_by('slug', sanitize_title($term), $taxonomy)) { |
|
| 72 | + wp_insert_term($term, $taxonomy); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -85,33 +85,33 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $default = ''; |
| 87 | 87 | $page = 'settings'; |
| 88 | - $settings_pages = new Pages( $page ); |
|
| 88 | + $settings_pages = new Pages($page); |
|
| 89 | 89 | $plugin_settings = $settings_pages->get_settings(); |
| 90 | 90 | |
| 91 | - if ( $plugin_settings && is_array( $plugin_settings ) ) { |
|
| 91 | + if ($plugin_settings && is_array($plugin_settings)) { |
|
| 92 | 92 | |
| 93 | - foreach ( $plugin_settings as $id => $settings ) { |
|
| 93 | + foreach ($plugin_settings as $id => $settings) { |
|
| 94 | 94 | |
| 95 | - $group = 'simple-calendar_' . $page . '_' . $id; |
|
| 95 | + $group = 'simple-calendar_'.$page.'_'.$id; |
|
| 96 | 96 | |
| 97 | - if ( isset( $settings['sections'] ) ) { |
|
| 97 | + if (isset($settings['sections'])) { |
|
| 98 | 98 | |
| 99 | - if ( $settings['sections'] && is_array( $settings['sections'] ) ) { |
|
| 99 | + if ($settings['sections'] && is_array($settings['sections'])) { |
|
| 100 | 100 | |
| 101 | - foreach ( $settings['sections'] as $section_id => $section ) { |
|
| 101 | + foreach ($settings['sections'] as $section_id => $section) { |
|
| 102 | 102 | |
| 103 | - if ( isset( $section['fields'] ) ) { |
|
| 103 | + if (isset($section['fields'])) { |
|
| 104 | 104 | |
| 105 | - if ( $section['fields'] && is_array( $section['fields'] ) ) { |
|
| 105 | + if ($section['fields'] && is_array($section['fields'])) { |
|
| 106 | 106 | |
| 107 | - foreach ( $section['fields'] as $key => $field ) { |
|
| 107 | + foreach ($section['fields'] as $key => $field) { |
|
| 108 | 108 | |
| 109 | - if ( isset ( $field['type'] ) ) { |
|
| 109 | + if (isset ($field['type'])) { |
|
| 110 | 110 | // Maybe an associative array. |
| 111 | - if ( is_int( $key ) ) { |
|
| 112 | - $default[ $section_id ] = self::get_field_default_value( $field ); |
|
| 111 | + if (is_int($key)) { |
|
| 112 | + $default[$section_id] = self::get_field_default_value($field); |
|
| 113 | 113 | } else { |
| 114 | - $default[ $section_id ][ $key ] = self::get_field_default_value( $field ); |
|
| 114 | + $default[$section_id][$key] = self::get_field_default_value($field); |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | } // Are there sections? |
| 129 | 129 | |
| 130 | - add_option( $group, $default, '', true ); |
|
| 130 | + add_option($group, $default, '', true); |
|
| 131 | 131 | |
| 132 | 132 | // Reset before looping next settings page. |
| 133 | 133 | $default = ''; |
@@ -147,12 +147,12 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return mixed |
| 149 | 149 | */ |
| 150 | - private static function get_field_default_value( $field ) { |
|
| 150 | + private static function get_field_default_value($field) { |
|
| 151 | 151 | |
| 152 | - $saved_value = isset( $field['value'] ) ? $field['value'] : ''; |
|
| 153 | - $default_value = isset( $field['default'] ) ? $field['default'] : ''; |
|
| 152 | + $saved_value = isset($field['value']) ? $field['value'] : ''; |
|
| 153 | + $default_value = isset($field['default']) ? $field['default'] : ''; |
|
| 154 | 154 | |
| 155 | - return ! empty( $saved_value ) ? $saved_value : $default_value; |
|
| 155 | + return ! empty($saved_value) ? $saved_value : $default_value; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | */ |
| 7 | 7 | namespace SimpleCalendar; |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if ( ! defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -26,13 +26,13 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function __construct() { |
| 28 | 28 | // Register custom taxonomies. |
| 29 | - add_action( 'init', array( __CLASS__, 'register_taxonomies' ), 5 ); |
|
| 29 | + add_action('init', array(__CLASS__, 'register_taxonomies'), 5); |
|
| 30 | 30 | // Register custom post types. |
| 31 | - add_action( 'init', array( __CLASS__, 'register_post_types' ), 5 ); |
|
| 31 | + add_action('init', array(__CLASS__, 'register_post_types'), 5); |
|
| 32 | 32 | // Filter the calendar feed post content to display a calendar view. |
| 33 | - add_filter( 'the_content', array( $this, 'filter_post_content' ), 100 ); |
|
| 33 | + add_filter('the_content', array($this, 'filter_post_content'), 100); |
|
| 34 | 34 | // Delete calendar transients and notices upon post deletion. |
| 35 | - add_action( 'before_delete_post', array( $this, 'upon_deletion' ), 10, 1 ); |
|
| 35 | + add_action('before_delete_post', array($this, 'upon_deletion'), 10, 1); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -42,32 +42,32 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public static function register_taxonomies() { |
| 44 | 44 | |
| 45 | - do_action( 'simcal_register_taxonomies' ); |
|
| 45 | + do_action('simcal_register_taxonomies'); |
|
| 46 | 46 | |
| 47 | - if ( ! taxonomy_exists( 'calendar_feed' ) ) { |
|
| 47 | + if ( ! taxonomy_exists('calendar_feed')) { |
|
| 48 | 48 | |
| 49 | 49 | // Feed Type. |
| 50 | 50 | $labels = array( |
| 51 | - 'name' => __( 'Events Source Types', 'google-calendar-events' ), |
|
| 52 | - 'singular_name' => __( 'Events Source Type', 'google-calendar-events' ), |
|
| 53 | - 'menu_name' => __( 'Events Source Type', 'google-calendar-events' ), |
|
| 54 | - 'all_items' => __( 'All Events Source Types', 'google-calendar-events' ), |
|
| 55 | - 'parent_item' => __( 'Parent Events Source Type', 'google-calendar-events' ), |
|
| 56 | - 'parent_item_colon' => __( 'Parent Events Source Type:', 'google-calendar-events' ), |
|
| 57 | - 'new_item_name' => __( 'New Events Source Type', 'google-calendar-events' ), |
|
| 58 | - 'add_new_item' => __( 'Add New Events Source Type', 'google-calendar-events' ), |
|
| 59 | - 'edit_item' => __( 'Edit Events Source Type', 'google-calendar-events' ), |
|
| 60 | - 'update_item' => __( 'Update Events Source Type', 'google-calendar-events' ), |
|
| 61 | - 'view_item' => __( 'View Events Source Type', 'google-calendar-events' ), |
|
| 62 | - 'separate_items_with_commas' => __( 'Separate events source types with commas', 'google-calendar-events' ), |
|
| 63 | - 'add_or_remove_items' => __( 'Add or remove events source types', 'google-calendar-events' ), |
|
| 64 | - 'choose_from_most_used' => __( 'Choose from the most used', 'google-calendar-events' ), |
|
| 65 | - 'popular_items' => __( 'Popular events source types', 'google-calendar-events' ), |
|
| 66 | - 'search_items' => __( 'Search Events Source Types', 'google-calendar-events' ), |
|
| 67 | - 'not_found' => __( 'Not Found', 'google-calendar-events' ), |
|
| 51 | + 'name' => __('Events Source Types', 'google-calendar-events'), |
|
| 52 | + 'singular_name' => __('Events Source Type', 'google-calendar-events'), |
|
| 53 | + 'menu_name' => __('Events Source Type', 'google-calendar-events'), |
|
| 54 | + 'all_items' => __('All Events Source Types', 'google-calendar-events'), |
|
| 55 | + 'parent_item' => __('Parent Events Source Type', 'google-calendar-events'), |
|
| 56 | + 'parent_item_colon' => __('Parent Events Source Type:', 'google-calendar-events'), |
|
| 57 | + 'new_item_name' => __('New Events Source Type', 'google-calendar-events'), |
|
| 58 | + 'add_new_item' => __('Add New Events Source Type', 'google-calendar-events'), |
|
| 59 | + 'edit_item' => __('Edit Events Source Type', 'google-calendar-events'), |
|
| 60 | + 'update_item' => __('Update Events Source Type', 'google-calendar-events'), |
|
| 61 | + 'view_item' => __('View Events Source Type', 'google-calendar-events'), |
|
| 62 | + 'separate_items_with_commas' => __('Separate events source types with commas', 'google-calendar-events'), |
|
| 63 | + 'add_or_remove_items' => __('Add or remove events source types', 'google-calendar-events'), |
|
| 64 | + 'choose_from_most_used' => __('Choose from the most used', 'google-calendar-events'), |
|
| 65 | + 'popular_items' => __('Popular events source types', 'google-calendar-events'), |
|
| 66 | + 'search_items' => __('Search Events Source Types', 'google-calendar-events'), |
|
| 67 | + 'not_found' => __('Not Found', 'google-calendar-events'), |
|
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | - $args = array( |
|
| 70 | + $args = array( |
|
| 71 | 71 | 'hierarchical' => true, |
| 72 | 72 | 'labels' => $labels, |
| 73 | 73 | 'public' => false, |
@@ -76,34 +76,34 @@ discard block |
||
| 76 | 76 | 'show_tagcloud' => false, |
| 77 | 77 | 'show_ui' => false, |
| 78 | 78 | ); |
| 79 | - register_taxonomy( 'calendar_feed', array( 'calendar' ), $args ); |
|
| 79 | + register_taxonomy('calendar_feed', array('calendar'), $args); |
|
| 80 | 80 | |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( ! taxonomy_exists( 'calendar_type' ) ) { |
|
| 83 | + if ( ! taxonomy_exists('calendar_type')) { |
|
| 84 | 84 | |
| 85 | 85 | // Calendar Type. |
| 86 | 86 | $labels = array( |
| 87 | - 'name' => __( 'Calendar Types', 'google-calendar-events' ), |
|
| 88 | - 'singular_name' => __( 'Calendar Type', 'google-calendar-events' ), |
|
| 89 | - 'menu_name' => __( 'Calendar Type', 'google-calendar-events' ), |
|
| 90 | - 'all_items' => __( 'All Calendar Types', 'google-calendar-events' ), |
|
| 91 | - 'parent_item' => __( 'Parent Calendar Type', 'google-calendar-events' ), |
|
| 92 | - 'parent_item_colon' => __( 'Parent Calendar Type:', 'google-calendar-events' ), |
|
| 93 | - 'new_item_name' => __( 'New Calendar Type', 'google-calendar-events' ), |
|
| 94 | - 'add_new_item' => __( 'Add New Calendar Type', 'google-calendar-events' ), |
|
| 95 | - 'edit_item' => __( 'Edit Calendar Type', 'google-calendar-events' ), |
|
| 96 | - 'update_item' => __( 'Update Calendar Type', 'google-calendar-events' ), |
|
| 97 | - 'view_item' => __( 'View Calendar Type', 'google-calendar-events' ), |
|
| 98 | - 'separate_items_with_commas' => __( 'Separate calendar types with commas', 'google-calendar-events' ), |
|
| 99 | - 'add_or_remove_items' => __( 'Add or remove calendar types', 'google-calendar-events' ), |
|
| 100 | - 'choose_from_most_used' => __( 'Choose from the most used', 'google-calendar-events' ), |
|
| 101 | - 'popular_items' => __( 'Popular calendar types', 'google-calendar-events' ), |
|
| 102 | - 'search_items' => __( 'Search Calendar Types', 'google-calendar-events' ), |
|
| 103 | - 'not_found' => __( 'Not Found', 'google-calendar-events' ), |
|
| 87 | + 'name' => __('Calendar Types', 'google-calendar-events'), |
|
| 88 | + 'singular_name' => __('Calendar Type', 'google-calendar-events'), |
|
| 89 | + 'menu_name' => __('Calendar Type', 'google-calendar-events'), |
|
| 90 | + 'all_items' => __('All Calendar Types', 'google-calendar-events'), |
|
| 91 | + 'parent_item' => __('Parent Calendar Type', 'google-calendar-events'), |
|
| 92 | + 'parent_item_colon' => __('Parent Calendar Type:', 'google-calendar-events'), |
|
| 93 | + 'new_item_name' => __('New Calendar Type', 'google-calendar-events'), |
|
| 94 | + 'add_new_item' => __('Add New Calendar Type', 'google-calendar-events'), |
|
| 95 | + 'edit_item' => __('Edit Calendar Type', 'google-calendar-events'), |
|
| 96 | + 'update_item' => __('Update Calendar Type', 'google-calendar-events'), |
|
| 97 | + 'view_item' => __('View Calendar Type', 'google-calendar-events'), |
|
| 98 | + 'separate_items_with_commas' => __('Separate calendar types with commas', 'google-calendar-events'), |
|
| 99 | + 'add_or_remove_items' => __('Add or remove calendar types', 'google-calendar-events'), |
|
| 100 | + 'choose_from_most_used' => __('Choose from the most used', 'google-calendar-events'), |
|
| 101 | + 'popular_items' => __('Popular calendar types', 'google-calendar-events'), |
|
| 102 | + 'search_items' => __('Search Calendar Types', 'google-calendar-events'), |
|
| 103 | + 'not_found' => __('Not Found', 'google-calendar-events'), |
|
| 104 | 104 | ); |
| 105 | 105 | |
| 106 | - $args = array( |
|
| 106 | + $args = array( |
|
| 107 | 107 | 'hierarchical' => true, |
| 108 | 108 | 'labels' => $labels, |
| 109 | 109 | 'public' => false, |
@@ -112,34 +112,34 @@ discard block |
||
| 112 | 112 | 'show_tagcloud' => false, |
| 113 | 113 | 'show_ui' => false, |
| 114 | 114 | ); |
| 115 | - register_taxonomy( 'calendar_type', array( 'calendar' ), $args ); |
|
| 115 | + register_taxonomy('calendar_type', array('calendar'), $args); |
|
| 116 | 116 | |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if ( ! taxonomy_exists( 'calendar_category' ) ) { |
|
| 119 | + if ( ! taxonomy_exists('calendar_category')) { |
|
| 120 | 120 | |
| 121 | 121 | // Feed Category. |
| 122 | 122 | $labels = array( |
| 123 | - 'name' => __( 'Categories', 'google-calendar-events' ), |
|
| 124 | - 'singular_name' => __( 'Category', 'google-calendar-events' ), |
|
| 125 | - 'menu_name' => __( 'Categories', 'google-calendar-events' ), |
|
| 126 | - 'all_items' => __( 'All Categories', 'google-calendar-events' ), |
|
| 127 | - 'parent_item' => __( 'Parent Category', 'google-calendar-events' ), |
|
| 128 | - 'parent_item_colon' => __( 'Parent Category:', 'google-calendar-events' ), |
|
| 129 | - 'new_item_name' => __( 'New Category', 'google-calendar-events' ), |
|
| 130 | - 'add_new_item' => __( 'Add New Category', 'google-calendar-events' ), |
|
| 131 | - 'edit_item' => __( 'Edit Category', 'google-calendar-events' ), |
|
| 132 | - 'update_item' => __( 'Update Category', 'google-calendar-events' ), |
|
| 133 | - 'view_item' => __( 'View Category', 'google-calendar-events' ), |
|
| 134 | - 'separate_items_with_commas' => __( 'Separate categories with commas', 'google-calendar-events' ), |
|
| 135 | - 'add_or_remove_items' => __( 'Add or remove categories', 'google-calendar-events' ), |
|
| 136 | - 'choose_from_most_used' => __( 'Choose from the most used', 'google-calendar-events' ), |
|
| 137 | - 'popular_items' => __( 'Popular Categories', 'google-calendar-events' ), |
|
| 138 | - 'search_items' => __( 'Search Categories', 'google-calendar-events' ), |
|
| 139 | - 'not_found' => __( 'Not Found', 'google-calendar-events' ), |
|
| 123 | + 'name' => __('Categories', 'google-calendar-events'), |
|
| 124 | + 'singular_name' => __('Category', 'google-calendar-events'), |
|
| 125 | + 'menu_name' => __('Categories', 'google-calendar-events'), |
|
| 126 | + 'all_items' => __('All Categories', 'google-calendar-events'), |
|
| 127 | + 'parent_item' => __('Parent Category', 'google-calendar-events'), |
|
| 128 | + 'parent_item_colon' => __('Parent Category:', 'google-calendar-events'), |
|
| 129 | + 'new_item_name' => __('New Category', 'google-calendar-events'), |
|
| 130 | + 'add_new_item' => __('Add New Category', 'google-calendar-events'), |
|
| 131 | + 'edit_item' => __('Edit Category', 'google-calendar-events'), |
|
| 132 | + 'update_item' => __('Update Category', 'google-calendar-events'), |
|
| 133 | + 'view_item' => __('View Category', 'google-calendar-events'), |
|
| 134 | + 'separate_items_with_commas' => __('Separate categories with commas', 'google-calendar-events'), |
|
| 135 | + 'add_or_remove_items' => __('Add or remove categories', 'google-calendar-events'), |
|
| 136 | + 'choose_from_most_used' => __('Choose from the most used', 'google-calendar-events'), |
|
| 137 | + 'popular_items' => __('Popular Categories', 'google-calendar-events'), |
|
| 138 | + 'search_items' => __('Search Categories', 'google-calendar-events'), |
|
| 139 | + 'not_found' => __('Not Found', 'google-calendar-events'), |
|
| 140 | 140 | ); |
| 141 | 141 | |
| 142 | - $args = array( |
|
| 142 | + $args = array( |
|
| 143 | 143 | 'hierarchical' => true, |
| 144 | 144 | 'labels' => $labels, |
| 145 | 145 | 'public' => true, |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | 'show_ui' => true, |
| 150 | 150 | ); |
| 151 | 151 | |
| 152 | - register_taxonomy( 'calendar_category', array( 'calendar' ), $args ); |
|
| 152 | + register_taxonomy('calendar_category', array('calendar'), $args); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | } |
@@ -161,27 +161,27 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public static function register_post_types() { |
| 163 | 163 | |
| 164 | - do_action( 'simcal_register_post_types' ); |
|
| 164 | + do_action('simcal_register_post_types'); |
|
| 165 | 165 | |
| 166 | - if ( ! post_type_exists( 'calendar' ) ) { |
|
| 166 | + if ( ! post_type_exists('calendar')) { |
|
| 167 | 167 | |
| 168 | 168 | // Calendar feed post type. |
| 169 | - $labels = array( |
|
| 170 | - 'name' => _x( 'Calendars', 'Post Type General Name', 'google-calendar-events' ), |
|
| 171 | - 'singular_name' => _x( 'Calendar', 'Post Type Singular Name', 'google-calendar-events' ), |
|
| 172 | - 'menu_name' => __( 'Calendars', 'google-calendar-events' ), |
|
| 173 | - 'name_admin_bar' => __( 'Calendar', 'google-calendar-events' ), |
|
| 174 | - 'parent_item_colon' => __( 'Parent Calendar:', 'google-calendar-events' ), |
|
| 175 | - 'all_items' => __( 'All Calendars', 'google-calendar-events' ), |
|
| 176 | - 'add_new_item' => __( 'Add New Calendar', 'google-calendar-events' ), |
|
| 177 | - 'add_new' => __( 'Add New', 'google-calendar-events' ), |
|
| 178 | - 'new_item' => __( 'New Calendar', 'google-calendar-events' ), |
|
| 179 | - 'edit_item' => __( 'Edit Calendar', 'google-calendar-events' ), |
|
| 180 | - 'update_item' => __( 'Update Calendar', 'google-calendar-events' ), |
|
| 181 | - 'view_item' => __( 'View Calendar', 'google-calendar-events' ), |
|
| 182 | - 'search_items' => __( 'Search Calendar', 'google-calendar-events' ), |
|
| 183 | - 'not_found' => __( 'Calendars not found', 'google-calendar-events' ), |
|
| 184 | - 'not_found_in_trash' => __( 'Calendars not found in Trash', 'google-calendar-events' ), |
|
| 169 | + $labels = array( |
|
| 170 | + 'name' => _x('Calendars', 'Post Type General Name', 'google-calendar-events'), |
|
| 171 | + 'singular_name' => _x('Calendar', 'Post Type Singular Name', 'google-calendar-events'), |
|
| 172 | + 'menu_name' => __('Calendars', 'google-calendar-events'), |
|
| 173 | + 'name_admin_bar' => __('Calendar', 'google-calendar-events'), |
|
| 174 | + 'parent_item_colon' => __('Parent Calendar:', 'google-calendar-events'), |
|
| 175 | + 'all_items' => __('All Calendars', 'google-calendar-events'), |
|
| 176 | + 'add_new_item' => __('Add New Calendar', 'google-calendar-events'), |
|
| 177 | + 'add_new' => __('Add New', 'google-calendar-events'), |
|
| 178 | + 'new_item' => __('New Calendar', 'google-calendar-events'), |
|
| 179 | + 'edit_item' => __('Edit Calendar', 'google-calendar-events'), |
|
| 180 | + 'update_item' => __('Update Calendar', 'google-calendar-events'), |
|
| 181 | + 'view_item' => __('View Calendar', 'google-calendar-events'), |
|
| 182 | + 'search_items' => __('Search Calendar', 'google-calendar-events'), |
|
| 183 | + 'not_found' => __('Calendars not found', 'google-calendar-events'), |
|
| 184 | + 'not_found_in_trash' => __('Calendars not found in Trash', 'google-calendar-events'), |
|
| 185 | 185 | ); |
| 186 | 186 | |
| 187 | 187 | $rewrite_rules = array( |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | $svg_icon = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iU2hhcGVzX3hBMF9JbWFnZV8xXyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDEwMjQgMTAyNCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIGQ9Ik01MTMuNCwxMDEzLjNjLTE2My44LDAtMzI3LjcsMC00OTEuNSwwYy05LjcsMC04LjgsMC45LTguOC04LjljMC0yNDMuNywwLjItNDg3LjMtMC4zLTczMWMtMC4xLTM5LjYsMjcuNy03Ni40LDY5LjYtODIuM2MzLTAuNCw2LTAuNSw5LTAuNWMzNSwwLDcwLDAuMSwxMDUtMC4xYzUuMSwwLDYuNSwxLjQsNi41LDYuNWMtMC4yLDI2LjgsMC4xLDUzLjctMC4yLDgwLjVjLTAuMiwxNS4yLDMuOSwyOC4yLDE1LjksMzguMmMyLjcsMi4yLDUsNC44LDcuNCw3LjRjOCw4LjYsMTguMSwxMi40LDI5LjYsMTIuNGMzMC43LDAuMiw2MS4zLDAuMiw5MiwwYzExLjItMC4xLDIxLjItMy45LDI5LjEtMTIuMmMzLjQtMy42LDctNy4yLDEwLjYtMTAuNmM5LTguNCwxMi43LTE4LjksMTIuNy0zMWMwLjEtMjguMiwwLTU2LjMsMC04NC41YzAtNi42LDAtNi42LDYuNi02LjZjNzEuNSwwLDE0MywwLDIxNC41LDBjNi42LDAsNi42LDAsNi42LDYuN2MwLDI2LjgsMC4yLDUzLjctMC4xLDgwLjVjLTAuMiwxNSw1LjEsMjYuOCwxNS40LDM4YzEzLjYsMTQuNywyOC45LDIwLjgsNDguNywyMC4xYzI1LjYtMSw1MS4zLTAuNCw3Ny0wLjJjMTMuOSwwLjEsMjQuOC01LjEsMzUuNC0xNC40YzE1LjktMTQsMjIuMS0zMC40LDIxLjEtNTEuM2MtMS4xLTI0LjMtMC4xLTQ4LjctMC40LTczYzAtNS4xLDEuNC02LjUsNi41LTYuNWMzNC43LDAuMiw2OS4zLDAsMTA0LDAuMWM0Mi4zLDAuMiw3OC4zLDM2LDc4LjMsNzguM2MwLjEsMjQ2LDAsNDkyLDAsNzM4YzAsNi40LDAsNi40LTcuMyw2LjRDODQyLDEwMTMuMyw2NzcuNywxMDEzLjMsNTEzLjQsMTAxMy4zeiBNNDM5LjUsNjc4LjljMS42LTEsMi4yLTEuNSwzLTEuOGMxMS44LTUuOCwyMS41LTE0LjIsMjktMjQuOGMyNC4zLTM0LjEsMjQuMy03MC45LDguNi0xMDcuOGMtMTMuMy0zMS4zLTM5LjMtNDkuMy03MS01OS40Yy0yNy42LTguOC01Ni05LjQtODQuNS01LjZjLTIwLjMsMi43LTM5LjIsOS42LTU1LjUsMjIuMmMtMzUuNSwyNy4yLTQ4LjQsNjUuMS01MC40LDEwOGMtMC4yLDMuNywyLjEsMy45LDQuOCwzLjljMjIuMiwwLDQ0LjMtMC4xLDY2LjUsMGMzLjgsMCw1LjQtMS4xLDUuMy01LjFjLTAuMS03LjcsMS0xNS4zLDMtMjIuN2M1LjQtMjAsMTYuNS0zNC43LDM3LjgtMzkuN2M4LjEtMS45LDE2LjMtMi4xLDI0LjQtMS4zYzIxLjQsMi4xLDM2LjMsMTMuMSw0My41LDMzLjdjMy41LDEwLjEsMy45LDIwLjQsMi45LDMxYy0yLjIsMjMuNC0xNi4yLDM5LjctMzkuMSw0NC42Yy0xMy4yLDIuOC0yNi42LDQuMS00MC4yLDRjLTMuNywwLTUsMS4yLTQuOSw0LjljMC4xLDE2LjUsMC4yLDMzLDAsNDkuNWMwLDQsMS41LDUuMiw1LjMsNS4xYzEyLjktMC4zLDI1LjYsMC45LDM4LjMsM2MyNi4zLDQuMiw0My41LDE4LjgsNDkuMiw0MmMzLjMsMTMuNSwzLDI3LjEtMC4yLDQwLjZjLTIuMyw5LjctNi44LDE4LjQtMTMuOCwyNS43Yy0xNS40LDE2LjEtMzQuNSwyMS42LTU2LDE4LjljLTI3LjUtMy40LTQzLjUtMTgtNTAuNS00NC44Yy0xLjktNy4zLTMuMS0xNC43LTIuOC0yMi4yYzAuMi00LTEuMS01LjYtNS40LTUuNmMtMjMuNywwLjItNDcuMywwLjItNzEsMGMtNCwwLTUuNCwxLjItNC45LDUuMmMxLjQsMTMuMiwyLjcsMjYuNSw1LjksMzkuNWMxMS4xLDQ1LjIsMzguMiw3NS42LDgzLjQsODguMmMzNi43LDEwLjMsNzMuOCwxMC4xLDExMC41LDAuMWMyNC41LTYuNiw0NC43LTIwLjEsNjEtMzkuOGMyNC41LTI5LjcsMzQuNC02My45LDMxLjQtMTAxLjljLTIuMi0yNy40LTEyLjUtNTEuMy0zMy42LTY5LjhDNDYwLjcsNjg5LjMsNDUxLjksNjgyLDQzOS41LDY3OC45eiBNNzU1LDY5Mi41YzAtNjguNi0wLjEtMTM3LjMsMC4xLTIwNS45YzAtNS4xLTEuNC02LjUtNi41LTYuNGMtMTguMywwLjMtMzYuNywwLjQtNTUsMGMtNS43LTAuMS03LjIsMS45LTguMiw3Yy01LjksMzIuMS0yNC40LDUzLTU2LjMsNjEuMWMtMTcuNSw0LjUtMzUuNiw1LTUzLjUsNS44Yy0zLjksMC4yLTUuMiwxLjQtNS4yLDUuM2MwLjIsMTUuMywwLjIsMzAuNywwLDQ2Yy0wLjEsNC4zLDEuNiw1LjQsNS42LDUuM2MxNC4yLTAuMiwyOC4zLTAuMSw0Mi41LTAuMWMxNS41LDAsMzEsMC4xLDQ2LjUtMC4xYzQuMSwwLDUuOSwxLjMsNS41LDUuNGMtMC4xLDEuNywwLDMuMywwLDVjMCw5Mi4xLDAsMTg0LjMsMCwyNzYuNGMwLDcuMiwwLDcuMiw3LDcuMmMyMy41LDAsNDcsMCw3MC41LDBjNywwLDcsMCw3LTcuMkM3NTUsODI5LjEsNzU1LDc2MC44LDc1NSw2OTIuNXoiLz48cGF0aCBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgZD0iTTM3Ni43LDE5OS4yYzAsMjQuMiwwLDQ4LjMsMCw3Mi41Yy0wLjEsMjMuMS0xNy40LDQwLjUtNDAuNCw0MC42Yy0yMy4zLDAuMS00Ni42LDAuMS03MCwwYy0yMi44LTAuMS00MC4zLTE3LjQtNDAuMy00MC4xYy0wLjEtNDguNS0wLjEtOTYuOSwwLTE0NS40YzAtMjIuNCwxNy41LTQwLDM5LjktNDAuMWMyMy43LTAuMSw0Ny4zLTAuMSw3MSwwYzIyLjQsMC4xLDM5LjgsMTcuNywzOS44LDQwLjFDMzc2LjgsMTUwLjksMzc2LjcsMTc1LjEsMzc2LjcsMTk5LjJ6Ii8+PHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIGQ9Ik04MDEuNywxOTkuNmMwLDI0LDAsNDgsMCw3MmMwLDIzLjQtMTcuMyw0MC43LTQwLjcsNDAuOGMtMjMuMiwwLjEtNDYuMywwLjEtNjkuNSwwYy0yMy4xLTAuMS00MC41LTE3LjQtNDAuNS00MC41Yy0wLjEtNDguMy0wLjEtOTYuNiwwLTE0NC45YzAtMjIuNywxNy41LTQwLjIsNDAuMi00MC4zYzIzLjMtMC4xLDQ2LjYtMC4xLDcwLDBjMjMuMSwwLjEsNDAuNCwxNy40LDQwLjUsNDAuNUM4MDEuOCwxNTEuMyw4MDEuNywxNzUuNCw4MDEuNywxOTkuNnoiLz48L3N2Zz4='; |
| 195 | 195 | |
| 196 | - $args = array( |
|
| 196 | + $args = array( |
|
| 197 | 197 | 'capability_type' => 'post', |
| 198 | 198 | 'exclude_from_search' => false, |
| 199 | 199 | 'has_archive' => false, |
| 200 | 200 | 'hierarchical' => false, |
| 201 | - 'label' => __( 'Calendar', 'google-calendar-events' ), |
|
| 201 | + 'label' => __('Calendar', 'google-calendar-events'), |
|
| 202 | 202 | 'labels' => $labels, |
| 203 | 203 | 'query_var' => true, |
| 204 | 204 | 'public' => true, |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | 'show_in_menu' => true, |
| 211 | 211 | 'show_in_nav_menus' => true, |
| 212 | 212 | 'show_ui' => true, |
| 213 | - 'supports' => array( 'title', 'editor' ), |
|
| 213 | + 'supports' => array('title', 'editor'), |
|
| 214 | 214 | 'taxonomies' => array( |
| 215 | 215 | 'calendar_category', |
| 216 | 216 | 'calendar_feed', |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | ), |
| 219 | 219 | ); |
| 220 | 220 | |
| 221 | - register_post_type( 'calendar', $args ); |
|
| 221 | + register_post_type('calendar', $args); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | } |
@@ -232,49 +232,49 @@ discard block |
||
| 232 | 232 | * |
| 233 | 233 | * @return string |
| 234 | 234 | */ |
| 235 | - public function filter_post_content( $the_content ) { |
|
| 235 | + public function filter_post_content($the_content) { |
|
| 236 | 236 | |
| 237 | - if ( is_singular() ) { |
|
| 237 | + if (is_singular()) { |
|
| 238 | 238 | |
| 239 | 239 | global $post; |
| 240 | 240 | |
| 241 | - if ( 'calendar' == $post->post_type ) { |
|
| 241 | + if ('calendar' == $post->post_type) { |
|
| 242 | 242 | |
| 243 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 243 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
| 244 | 244 | return ''; |
| 245 | 245 | } else { |
| 246 | 246 | ob_start(); |
| 247 | - simcal_print_calendar( $post ); |
|
| 247 | + simcal_print_calendar($post); |
|
| 248 | 248 | return ob_get_clean(); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | } else { |
| 252 | 252 | |
| 253 | 253 | $post_types = array(); |
| 254 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
| 255 | - if ( isset( $settings['general']['attach_calendars_posts'] ) ) { |
|
| 254 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
| 255 | + if (isset($settings['general']['attach_calendars_posts'])) { |
|
| 256 | 256 | $post_types = $settings['general']['attach_calendars_posts']; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if ( empty( $post_types ) ) { |
|
| 259 | + if (empty($post_types)) { |
|
| 260 | 260 | return $the_content; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if ( in_array( $post->post_type, (array) $post_types ) ) { |
|
| 263 | + if (in_array($post->post_type, (array) $post_types)) { |
|
| 264 | 264 | |
| 265 | - $id = absint( get_post_meta( $post->ID, '_simcal_attach_calendar_id', true ) ); |
|
| 265 | + $id = absint(get_post_meta($post->ID, '_simcal_attach_calendar_id', true)); |
|
| 266 | 266 | |
| 267 | - if ( $id > 0 ) { |
|
| 267 | + if ($id > 0) { |
|
| 268 | 268 | |
| 269 | - $pos = esc_attr( get_post_meta( $post->ID, '_simcal_attach_calendar_position', true ) ); |
|
| 269 | + $pos = esc_attr(get_post_meta($post->ID, '_simcal_attach_calendar_position', true)); |
|
| 270 | 270 | |
| 271 | 271 | ob_start(); |
| 272 | 272 | |
| 273 | - if ( 'after' == $pos ) { |
|
| 273 | + if ('after' == $pos) { |
|
| 274 | 274 | echo $the_content; |
| 275 | - simcal_print_calendar( $id ); |
|
| 276 | - } elseif ( 'before' == $pos ) { |
|
| 277 | - simcal_print_calendar( $id ); |
|
| 275 | + simcal_print_calendar($id); |
|
| 276 | + } elseif ('before' == $pos) { |
|
| 277 | + simcal_print_calendar($id); |
|
| 278 | 278 | echo $the_content; |
| 279 | 279 | } else { |
| 280 | 280 | echo $the_content; |
@@ -300,20 +300,20 @@ discard block |
||
| 300 | 300 | * |
| 301 | 301 | * @param $post_id |
| 302 | 302 | */ |
| 303 | - public function upon_deletion( $post_id ) { |
|
| 303 | + public function upon_deletion($post_id) { |
|
| 304 | 304 | |
| 305 | - $post_type = get_post_type( $post_id ); |
|
| 305 | + $post_type = get_post_type($post_id); |
|
| 306 | 306 | |
| 307 | - if ( 'calendar' == $post_type ) { |
|
| 307 | + if ('calendar' == $post_type) { |
|
| 308 | 308 | |
| 309 | - $notices = get_option( 'simple-calendar_admin_notices', array() ); |
|
| 309 | + $notices = get_option('simple-calendar_admin_notices', array()); |
|
| 310 | 310 | |
| 311 | - if ( ! empty( $notices ) && isset( $notices[ 'calendar_' . strval( $post_id ) ] ) ) { |
|
| 312 | - unset( $notices[ 'calendar_' . strval( $post_id ) ] ); |
|
| 313 | - update_option( 'simple-calendar_admin_notices', $notices ); |
|
| 311 | + if ( ! empty($notices) && isset($notices['calendar_'.strval($post_id)])) { |
|
| 312 | + unset($notices['calendar_'.strval($post_id)]); |
|
| 313 | + update_option('simple-calendar_admin_notices', $notices); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - simcal_delete_feed_transients( $post_id ); |
|
| 316 | + simcal_delete_feed_transients($post_id); |
|
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | 319 | |
@@ -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 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function __construct() { |
| 30 | 30 | |
| 31 | 31 | // Add shortcodes. |
| 32 | - add_action( 'init', array( $this, 'register' ) ); |
|
| 32 | + add_action('init', array($this, 'register')); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function register() { |
| 41 | 41 | |
| 42 | - add_shortcode( 'calendar', array( $this, 'print_calendar' ) ); |
|
| 42 | + add_shortcode('calendar', array($this, 'print_calendar')); |
|
| 43 | 43 | // @deprecated legacy shortcode |
| 44 | - add_shortcode( 'gcal', array( $this, 'print_calendar' ) ); |
|
| 44 | + add_shortcode('gcal', array($this, 'print_calendar')); |
|
| 45 | 45 | |
| 46 | - do_action( 'simcal_add_shortcodes' ); |
|
| 46 | + do_action('simcal_add_shortcodes'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -55,19 +55,19 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return string |
| 57 | 57 | */ |
| 58 | - public function print_calendar( $attributes ) { |
|
| 58 | + public function print_calendar($attributes) { |
|
| 59 | 59 | |
| 60 | - $args = shortcode_atts( array( |
|
| 60 | + $args = shortcode_atts(array( |
|
| 61 | 61 | 'id' => null, |
| 62 | - ), $attributes ); |
|
| 62 | + ), $attributes); |
|
| 63 | 63 | |
| 64 | - $id = absint( $args['id'] ); |
|
| 64 | + $id = absint($args['id']); |
|
| 65 | 65 | |
| 66 | - if ( $id > 0 ) { |
|
| 66 | + if ($id > 0) { |
|
| 67 | 67 | |
| 68 | - $calendar = simcal_get_calendar( $id ); |
|
| 68 | + $calendar = simcal_get_calendar($id); |
|
| 69 | 69 | |
| 70 | - if ( $calendar instanceof Calendar ) { |
|
| 70 | + if ($calendar instanceof Calendar) { |
|
| 71 | 71 | ob_start(); |
| 72 | 72 | $calendar->html(); |
| 73 | 73 | return ob_get_clean(); |