@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | use SimpleCalendar\Calendars\Views; |
| 14 | 14 | use SimpleCalendar\Events\Event; |
| 15 | 15 | |
| 16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 16 | +if ( ! defined('ABSPATH')) { |
|
| 17 | 17 | exit; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -105,36 +105,36 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @param int|object|\WP_Post|Calendar $calendar |
| 107 | 107 | */ |
| 108 | - public function __construct( $calendar ) { |
|
| 108 | + public function __construct($calendar) { |
|
| 109 | 109 | |
| 110 | 110 | $this->type = 'default-calendar'; |
| 111 | - $this->name = __( 'Default', 'google-calendar-events' ); |
|
| 112 | - $this->views = apply_filters( 'simcal_default_calendar_views', array( |
|
| 113 | - 'grid' => __( 'Grid', 'google-calendar-events' ), |
|
| 114 | - 'list' => __( 'List', 'google-calendar-events' ), |
|
| 115 | - ) ); |
|
| 111 | + $this->name = __('Default', 'google-calendar-events'); |
|
| 112 | + $this->views = apply_filters('simcal_default_calendar_views', array( |
|
| 113 | + 'grid' => __('Grid', 'google-calendar-events'), |
|
| 114 | + 'list' => __('List', 'google-calendar-events'), |
|
| 115 | + )); |
|
| 116 | 116 | |
| 117 | - parent::__construct( $calendar ); |
|
| 117 | + parent::__construct($calendar); |
|
| 118 | 118 | |
| 119 | - if ( ! is_null( $this->post ) ) { |
|
| 119 | + if ( ! is_null($this->post)) { |
|
| 120 | 120 | |
| 121 | - $this->set_properties( $this->view->get_type() ); |
|
| 121 | + $this->set_properties($this->view->get_type()); |
|
| 122 | 122 | |
| 123 | 123 | $id = $this->id; |
| 124 | 124 | $theme = $this->theme; |
| 125 | 125 | |
| 126 | - add_filter( 'simcal_calendar_class', function ( $class, $post_id ) use ( $theme, $id ) { |
|
| 127 | - if ( in_array( 'default-calendar', $class ) && $post_id === $id ) { |
|
| 128 | - array_push( $class, 'default-calendar-' . $theme ); |
|
| 126 | + add_filter('simcal_calendar_class', function($class, $post_id) use ($theme, $id) { |
|
| 127 | + if (in_array('default-calendar', $class) && $post_id === $id) { |
|
| 128 | + array_push($class, 'default-calendar-'.$theme); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | return $class; |
| 132 | - }, 10, 2 ); |
|
| 132 | + }, 10, 2); |
|
| 133 | 133 | |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // Calendar settings handling. |
| 137 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 137 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
| 138 | 138 | $admin = new Default_Calendar_Admin(); |
| 139 | 139 | $this->settings = $admin->settings_fields(); |
| 140 | 140 | } |
@@ -148,49 +148,49 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @param $view |
| 150 | 150 | */ |
| 151 | - private function set_properties( $view ) { |
|
| 151 | + private function set_properties($view) { |
|
| 152 | 152 | |
| 153 | 153 | // Set styles. |
| 154 | - if ( 'dark' == get_post_meta( $this->id, '_default_calendar_style_theme', true ) ) { |
|
| 154 | + if ('dark' == get_post_meta($this->id, '_default_calendar_style_theme', true)) { |
|
| 155 | 155 | $this->theme = 'dark'; |
| 156 | 156 | } |
| 157 | - if ( $today_color = get_post_meta( $this->id, '_default_calendar_style_today', true ) ) { |
|
| 158 | - $this->today_color = esc_attr( $today_color ); |
|
| 157 | + if ($today_color = get_post_meta($this->id, '_default_calendar_style_today', true)) { |
|
| 158 | + $this->today_color = esc_attr($today_color); |
|
| 159 | 159 | } |
| 160 | - if ( $day_events_color = get_post_meta( $this->id, '_default_calendar_style_days_events', true ) ) { |
|
| 161 | - $this->days_events_color = esc_attr( $day_events_color ); |
|
| 160 | + if ($day_events_color = get_post_meta($this->id, '_default_calendar_style_days_events', true)) { |
|
| 161 | + $this->days_events_color = esc_attr($day_events_color); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // Hide too many events. |
| 165 | - if ( 'yes' == get_post_meta( $this->id, '_default_calendar_limit_visible_events', true ) ) { |
|
| 166 | - $this->events_limit = absint( get_post_meta( $this->id, '_default_calendar_visible_events', true ) ); |
|
| 165 | + if ('yes' == get_post_meta($this->id, '_default_calendar_limit_visible_events', true)) { |
|
| 166 | + $this->events_limit = absint(get_post_meta($this->id, '_default_calendar_visible_events', true)); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // Expand multiple day events. |
| 170 | - if ( 'yes' == get_post_meta( $this->id, '_default_calendar_expand_multi_day_events', true ) || ( 'list' == $view && 'current_day_only' == get_post_meta( $this->id, '_default_calendar_expand_multi_day_events', true ) ) ) { |
|
| 170 | + if ('yes' == get_post_meta($this->id, '_default_calendar_expand_multi_day_events', true) || ('list' == $view && 'current_day_only' == get_post_meta($this->id, '_default_calendar_expand_multi_day_events', true))) { |
|
| 171 | 171 | $this->events = $this->expand_multiple_days_events(); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if ( 'grid' == $view ) { |
|
| 174 | + if ('grid' == $view) { |
|
| 175 | 175 | |
| 176 | 176 | // Use hover to open event bubbles. |
| 177 | - if ( 'hover' == get_post_meta( $this->id, '_default_calendar_event_bubble_trigger', true ) ) { |
|
| 177 | + if ('hover' == get_post_meta($this->id, '_default_calendar_event_bubble_trigger', true)) { |
|
| 178 | 178 | $this->event_bubble_trigger = 'hover'; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Trim long event titles. |
| 182 | - if ( 'yes' == get_post_meta( $this->id, '_default_calendar_trim_titles', true ) ) { |
|
| 183 | - $this->trim_titles = max( absint( get_post_meta( $this->id, '_default_calendar_trim_titles_chars', true ) ), 1 ); |
|
| 182 | + if ('yes' == get_post_meta($this->id, '_default_calendar_trim_titles', true)) { |
|
| 183 | + $this->trim_titles = max(absint(get_post_meta($this->id, '_default_calendar_trim_titles_chars', true)), 1); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | } else { |
| 187 | 187 | |
| 188 | 188 | // List range. |
| 189 | - $this->group_type = esc_attr( get_post_meta( $this->id, '_default_calendar_list_range_type', true ) ); |
|
| 190 | - $this->group_span = max( absint( get_post_meta( $this->id, '_default_calendar_list_range_span', true ) ), 1 ); |
|
| 189 | + $this->group_type = esc_attr(get_post_meta($this->id, '_default_calendar_list_range_type', true)); |
|
| 190 | + $this->group_span = max(absint(get_post_meta($this->id, '_default_calendar_list_range_span', true)), 1); |
|
| 191 | 191 | |
| 192 | 192 | // Make the list look more compact. |
| 193 | - if ( 'yes' == get_post_meta( $this->id, '_default_calendar_compact_list', true ) ) { |
|
| 193 | + if ('yes' == get_post_meta($this->id, '_default_calendar_compact_list', true)) { |
|
| 194 | 194 | $this->compact_list = true; |
| 195 | 195 | } |
| 196 | 196 | |
@@ -211,18 +211,18 @@ discard block |
||
| 211 | 211 | $old_events = $this->events; |
| 212 | 212 | $new_events = array(); |
| 213 | 213 | |
| 214 | - if ( ! empty( $old_events ) ) { |
|
| 214 | + if ( ! empty($old_events)) { |
|
| 215 | 215 | |
| 216 | - foreach ( $old_events as $events ) { |
|
| 217 | - foreach ( $events as $event ) { |
|
| 218 | - if ( $event instanceof Event ) { |
|
| 219 | - if ( false !== $event->multiple_days ) { |
|
| 216 | + foreach ($old_events as $events) { |
|
| 217 | + foreach ($events as $event) { |
|
| 218 | + if ($event instanceof Event) { |
|
| 219 | + if (false !== $event->multiple_days) { |
|
| 220 | 220 | $days = $event->multiple_days; |
| 221 | 221 | |
| 222 | - if ( $days > 0 ) { |
|
| 222 | + if ($days > 0) { |
|
| 223 | 223 | |
| 224 | - for ( $d = 1; $d <= $days; $d++ ) { |
|
| 225 | - $new_events[ intval( $event->start + ( $d * DAY_IN_SECONDS ) - 1 ) ][] = $event; |
|
| 224 | + for ($d = 1; $d <= $days; $d++) { |
|
| 225 | + $new_events[intval($event->start + ($d * DAY_IN_SECONDS) - 1)][] = $event; |
|
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | $events = $old_events + $new_events; |
| 237 | - ksort( $events, SORT_NUMERIC ); |
|
| 237 | + ksort($events, SORT_NUMERIC); |
|
| 238 | 238 | |
| 239 | 239 | return $events; |
| 240 | 240 | } |
@@ -250,16 +250,16 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @return null|Calendar_View |
| 252 | 252 | */ |
| 253 | - public function get_view( $view = '' ) { |
|
| 253 | + public function get_view($view = '') { |
|
| 254 | 254 | |
| 255 | - $view = ! empty( $view ) ? $view : 'grid'; |
|
| 255 | + $view = ! empty($view) ? $view : 'grid'; |
|
| 256 | 256 | |
| 257 | - do_action( 'simcal_calendar_get_view', $this->type, $view ); |
|
| 257 | + do_action('simcal_calendar_get_view', $this->type, $view); |
|
| 258 | 258 | |
| 259 | - if ( 'grid' == $view ) { |
|
| 260 | - return new Views\Default_Calendar_Grid( $this ); |
|
| 261 | - } elseif ( 'list' == $view ) { |
|
| 262 | - return new Views\Default_Calendar_List( $this ); |
|
| 259 | + if ('grid' == $view) { |
|
| 260 | + return new Views\Default_Calendar_Grid($this); |
|
| 261 | + } elseif ('list' == $view) { |
|
| 262 | + return new Views\Default_Calendar_List($this); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | return null; |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | use SimpleCalendar\Calendars\Default_Calendar; |
| 14 | 14 | use SimpleCalendar\Events\Event; |
| 15 | 15 | |
| 16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 16 | +if ( ! defined('ABSPATH')) { |
|
| 17 | 17 | exit; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @param string|Calendar $calendar |
| 77 | 77 | */ |
| 78 | - public function __construct( $calendar = '' ) { |
|
| 78 | + public function __construct($calendar = '') { |
|
| 79 | 79 | $this->calendar = $calendar; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @return string |
| 110 | 110 | */ |
| 111 | 111 | public function get_name() { |
| 112 | - return __( 'List', 'google-calendar-events' ); |
|
| 112 | + return __('List', 'google-calendar-events'); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -118,8 +118,8 @@ discard block |
||
| 118 | 118 | * @since 3.0.0 |
| 119 | 119 | */ |
| 120 | 120 | public function add_ajax_actions() { |
| 121 | - add_action( 'wp_ajax_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) ); |
|
| 122 | - add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) ); |
|
| 121 | + add_action('wp_ajax_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax')); |
|
| 122 | + add_action('wp_ajax_nopriv_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax')); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -133,16 +133,16 @@ discard block |
||
| 133 | 133 | * |
| 134 | 134 | * @return array |
| 135 | 135 | */ |
| 136 | - public function scripts( $min = '' ) { |
|
| 136 | + public function scripts($min = '') { |
|
| 137 | 137 | return array( |
| 138 | 138 | 'simcal-qtip' => array( |
| 139 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js', |
|
| 140 | - 'deps' => array( 'jquery' ), |
|
| 139 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$min.'.js', |
|
| 140 | + 'deps' => array('jquery'), |
|
| 141 | 141 | 'ver' => '2.2.1', |
| 142 | 142 | 'in_footer' => true, |
| 143 | 143 | ), |
| 144 | 144 | 'simcal-default-calendar' => array( |
| 145 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js', |
|
| 145 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js', |
|
| 146 | 146 | 'deps' => array( |
| 147 | 147 | 'jquery', |
| 148 | 148 | 'simcal-qtip', |
@@ -167,10 +167,10 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @return array |
| 169 | 169 | */ |
| 170 | - public function styles( $min = '' ) { |
|
| 170 | + public function styles($min = '') { |
|
| 171 | 171 | return array( |
| 172 | 172 | 'simcal-default-calendar-list' => array( |
| 173 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-list' . $min . '.css', |
|
| 173 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-list'.$min.'.css', |
|
| 174 | 174 | 'ver' => SIMPLE_CALENDAR_VERSION, |
| 175 | 175 | 'media' => 'all', |
| 176 | 176 | ), |
@@ -186,49 +186,49 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | $calendar = $this->calendar; |
| 188 | 188 | |
| 189 | - if ( $calendar instanceof Default_Calendar ) { |
|
| 189 | + if ($calendar instanceof Default_Calendar) { |
|
| 190 | 190 | |
| 191 | - $disabled = $calendar->static === true || empty( $calendar->events ) ? ' disabled="disabled"' : ''; |
|
| 191 | + $disabled = $calendar->static === true || empty($calendar->events) ? ' disabled="disabled"' : ''; |
|
| 192 | 192 | |
| 193 | 193 | |
| 194 | - $hide_header = get_post_meta( $this->calendar->id, '_default_calendar_list_header', true ) == 'yes' ? true : false; |
|
| 195 | - $static_calendar = get_post_meta( $this->calendar->id, '_calendar_is_static', true ) == 'yes' ? true : false; |
|
| 194 | + $hide_header = get_post_meta($this->calendar->id, '_default_calendar_list_header', true) == 'yes' ? true : false; |
|
| 195 | + $static_calendar = get_post_meta($this->calendar->id, '_calendar_is_static', true) == 'yes' ? true : false; |
|
| 196 | 196 | |
| 197 | 197 | $header_class = ''; |
| 198 | 198 | $compact_list_class = $calendar->compact_list ? 'simcal-calendar-list-compact' : ''; |
| 199 | 199 | |
| 200 | - edit_post_link( __( 'Edit Calendar', 'google-calendar-events' ), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id ); |
|
| 200 | + edit_post_link(__('Edit Calendar', 'google-calendar-events'), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id); |
|
| 201 | 201 | |
| 202 | - echo '<div class="simcal-calendar-list ' . $compact_list_class . '">'; |
|
| 202 | + echo '<div class="simcal-calendar-list '.$compact_list_class.'">'; |
|
| 203 | 203 | |
| 204 | - if ( ! $hide_header && ! $static_calendar ) { |
|
| 205 | - echo '<nav class="simcal-calendar-head">' . "\n"; |
|
| 204 | + if ( ! $hide_header && ! $static_calendar) { |
|
| 205 | + echo '<nav class="simcal-calendar-head">'."\n"; |
|
| 206 | 206 | |
| 207 | - echo "\t" . '<div class="simcal-nav">' . "\n"; |
|
| 208 | - echo "\t\t" . '<button class="simcal-nav-button simcal-prev" title="' . __('Previous', 'google-calendar-events') . '"' . $disabled . '>' . "\n"; |
|
| 209 | - echo "\t\t\t" . '<i class="simcal-icon-left"></i>' . "\n"; |
|
| 210 | - echo "\t\t" . '</button>' . "\n"; |
|
| 211 | - echo "\t" . '</div>' . "\n"; |
|
| 207 | + echo "\t".'<div class="simcal-nav">'."\n"; |
|
| 208 | + echo "\t\t".'<button class="simcal-nav-button simcal-prev" title="'.__('Previous', 'google-calendar-events').'"'.$disabled.'>'."\n"; |
|
| 209 | + echo "\t\t\t".'<i class="simcal-icon-left"></i>'."\n"; |
|
| 210 | + echo "\t\t".'</button>'."\n"; |
|
| 211 | + echo "\t".'</div>'."\n"; |
|
| 212 | 212 | |
| 213 | - if ( $hide_header ) { |
|
| 213 | + if ($hide_header) { |
|
| 214 | 214 | $header_class = 'simcal-hide-header'; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
| 218 | - echo "\t" . '<div class="simcal-nav simcal-current ' . $header_class . '" data-calendar-current="' . $calendar->start . '">' . "\n"; |
|
| 219 | - echo "\t\t" . '<h3 class="simcal-current-label"> </h3>' . "\n"; |
|
| 220 | - echo "\t" . '</div>' . "\n"; |
|
| 218 | + echo "\t".'<div class="simcal-nav simcal-current '.$header_class.'" data-calendar-current="'.$calendar->start.'">'."\n"; |
|
| 219 | + echo "\t\t".'<h3 class="simcal-current-label"> </h3>'."\n"; |
|
| 220 | + echo "\t".'</div>'."\n"; |
|
| 221 | 221 | |
| 222 | - echo "\t" . '<div class="simcal-nav">'; |
|
| 223 | - echo "\t\t" . '<button class="simcal-nav-button simcal-next" title="' . __('Next', 'google-calendar-events') . '"' . $disabled . '>'; |
|
| 224 | - echo "\t\t\t" . '<i class="simcal-icon-right"></i>' . "\n"; |
|
| 225 | - echo "\t\t" . '</button>' . "\n"; |
|
| 226 | - echo "\t" . '</div>' . "\n"; |
|
| 222 | + echo "\t".'<div class="simcal-nav">'; |
|
| 223 | + echo "\t\t".'<button class="simcal-nav-button simcal-next" title="'.__('Next', 'google-calendar-events').'"'.$disabled.'>'; |
|
| 224 | + echo "\t\t\t".'<i class="simcal-icon-right"></i>'."\n"; |
|
| 225 | + echo "\t\t".'</button>'."\n"; |
|
| 226 | + echo "\t".'</div>'."\n"; |
|
| 227 | 227 | |
| 228 | - echo '</nav>' . "\n"; |
|
| 228 | + echo '</nav>'."\n"; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - echo $this->draw_list( $calendar->start ); |
|
| 231 | + echo $this->draw_list($calendar->start); |
|
| 232 | 232 | |
| 233 | 233 | echo '<div class="simcal-ajax-loader simcal-spinner-top" style="display: none;"><i class="simcal-icon-spinner simcal-icon-spin"></i></div>'; |
| 234 | 234 | |
@@ -248,99 +248,99 @@ discard block |
||
| 248 | 248 | * |
| 249 | 249 | * @return array |
| 250 | 250 | */ |
| 251 | - private function get_events( $timestamp ) { |
|
| 251 | + private function get_events($timestamp) { |
|
| 252 | 252 | |
| 253 | 253 | $calendar = $this->calendar; |
| 254 | 254 | $timezone = $calendar->timezone; |
| 255 | 255 | |
| 256 | - if ( ! $calendar->group_type || ! $calendar->group_span ) { |
|
| 256 | + if ( ! $calendar->group_type || ! $calendar->group_span) { |
|
| 257 | 257 | return array(); |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - $current = Carbon::createFromTimestamp( $timestamp, $timezone ); |
|
| 260 | + $current = Carbon::createFromTimestamp($timestamp, $timezone); |
|
| 261 | 261 | $prev = clone $current; |
| 262 | 262 | $next = clone $current; |
| 263 | 263 | |
| 264 | 264 | $this->start = $current->getTimestamp(); |
| 265 | 265 | |
| 266 | - $interval = $span = max( absint( $calendar->group_span ), 1 ); |
|
| 267 | - |
|
| 268 | - if ( 'monthly' == $calendar->group_type ) { |
|
| 269 | - $this->prev = $prev->subMonths( $span )->getTimestamp(); |
|
| 270 | - $this->next = $next->addMonths( $span )->getTimestamp(); |
|
| 271 | - } elseif ( 'weekly' == $calendar->group_type ) { |
|
| 272 | - $week = new Carbon( $calendar->timezone ); |
|
| 273 | - $week->setTimestamp( $timestamp ); |
|
| 274 | - $week->setWeekStartsAt( $calendar->week_starts ); |
|
| 275 | - $this->prev = $prev->subWeeks( $span )->getTimestamp(); |
|
| 276 | - $this->next = $next->addWeeks( $span )->getTimestamp(); |
|
| 277 | - } elseif ( 'daily' == $calendar->group_type ) { |
|
| 278 | - $this->prev = $prev->subDays( $span )->getTimestamp(); |
|
| 279 | - $this->next = $next->addDays( $span )->getTimestamp(); |
|
| 266 | + $interval = $span = max(absint($calendar->group_span), 1); |
|
| 267 | + |
|
| 268 | + if ('monthly' == $calendar->group_type) { |
|
| 269 | + $this->prev = $prev->subMonths($span)->getTimestamp(); |
|
| 270 | + $this->next = $next->addMonths($span)->getTimestamp(); |
|
| 271 | + } elseif ('weekly' == $calendar->group_type) { |
|
| 272 | + $week = new Carbon($calendar->timezone); |
|
| 273 | + $week->setTimestamp($timestamp); |
|
| 274 | + $week->setWeekStartsAt($calendar->week_starts); |
|
| 275 | + $this->prev = $prev->subWeeks($span)->getTimestamp(); |
|
| 276 | + $this->next = $next->addWeeks($span)->getTimestamp(); |
|
| 277 | + } elseif ('daily' == $calendar->group_type) { |
|
| 278 | + $this->prev = $prev->subDays($span)->getTimestamp(); |
|
| 279 | + $this->next = $next->addDays($span)->getTimestamp(); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | $events = $calendar->events; |
| 283 | 283 | $daily_events = $paged_events = $flattened_events = array(); |
| 284 | 284 | |
| 285 | - if ( 'events' != $calendar->group_type ) { |
|
| 285 | + if ('events' != $calendar->group_type) { |
|
| 286 | 286 | |
| 287 | - $this->end = $this->next - 1; |
|
| 287 | + $this->end = $this->next - 1; |
|
| 288 | 288 | |
| 289 | - $timestamps = array_keys( $events ); |
|
| 290 | - $lower_bound = array_filter( $timestamps, array( $this, 'filter_events_before' ) ); |
|
| 291 | - $higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after' ) ); |
|
| 289 | + $timestamps = array_keys($events); |
|
| 290 | + $lower_bound = array_filter($timestamps, array($this, 'filter_events_before')); |
|
| 291 | + $higher_bound = array_filter($lower_bound, array($this, 'filter_events_after')); |
|
| 292 | 292 | |
| 293 | - if ( is_array( $higher_bound ) && !empty( $higher_bound ) ) { |
|
| 294 | - $filtered = array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) ); |
|
| 295 | - foreach ( $filtered as $timestamp => $events ) { |
|
| 296 | - $paged_events[ intval( $timestamp ) ] = $events; |
|
| 293 | + if (is_array($higher_bound) && ! empty($higher_bound)) { |
|
| 294 | + $filtered = array_intersect_key($events, array_combine($higher_bound, $higher_bound)); |
|
| 295 | + foreach ($filtered as $timestamp => $events) { |
|
| 296 | + $paged_events[intval($timestamp)] = $events; |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | } else { |
| 301 | 301 | |
| 302 | - foreach ( $events as $timestamp => $e ) { |
|
| 302 | + foreach ($events as $timestamp => $e) { |
|
| 303 | 303 | $second = 0; |
| 304 | - foreach ( $e as $event ) { |
|
| 305 | - $flattened_events[ intval( $timestamp + $second ) ][] = $event; |
|
| 304 | + foreach ($e as $event) { |
|
| 305 | + $flattened_events[intval($timestamp + $second)][] = $event; |
|
| 306 | 306 | $second++; |
| 307 | 307 | } |
| 308 | 308 | } |
| 309 | - ksort( $flattened_events, SORT_NUMERIC ); |
|
| 309 | + ksort($flattened_events, SORT_NUMERIC); |
|
| 310 | 310 | |
| 311 | - $keys = array_keys( $flattened_events ); |
|
| 311 | + $keys = array_keys($flattened_events); |
|
| 312 | 312 | $current = 0; |
| 313 | - foreach ( $keys as $timestamp ) { |
|
| 314 | - if ( $timestamp < $this->start ) { |
|
| 313 | + foreach ($keys as $timestamp) { |
|
| 314 | + if ($timestamp < $this->start) { |
|
| 315 | 315 | $current++; |
| 316 | 316 | } |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - $paged_events = array_slice( $flattened_events, $current, $interval, true ); |
|
| 319 | + $paged_events = array_slice($flattened_events, $current, $interval, true); |
|
| 320 | 320 | |
| 321 | - $events_end = isset( $keys[ $current + $interval ] ) ? $keys[ $current + $interval ] : $calendar->end; |
|
| 321 | + $events_end = isset($keys[$current + $interval]) ? $keys[$current + $interval] : $calendar->end; |
|
| 322 | 322 | $this->end = $events_end > $calendar->end ? $calendar->end : $events_end; |
| 323 | 323 | |
| 324 | - $this->prev = isset( $keys[ $current - $interval ] ) ? $keys[ $current - $interval ] : $calendar->earliest_event; |
|
| 325 | - $this->next = isset( $keys[ $current + $interval ] ) ? $keys[ $current + $interval ] : $this->end; |
|
| 324 | + $this->prev = isset($keys[$current - $interval]) ? $keys[$current - $interval] : $calendar->earliest_event; |
|
| 325 | + $this->next = isset($keys[$current + $interval]) ? $keys[$current + $interval] : $this->end; |
|
| 326 | 326 | |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | // Put resulting events in an associative array, with Ymd date as key for easy retrieval in calendar days loop. |
| 330 | - foreach ( $paged_events as $timestamp => $events ) { |
|
| 331 | - if ( $timestamp <= $this->end ) { |
|
| 332 | - $date = Carbon::createFromTimestamp( $timestamp, $calendar->timezone )->endOfDay()->format( 'Ymd' ); |
|
| 333 | - $daily_events[ intval( $date ) ][] = $events; |
|
| 330 | + foreach ($paged_events as $timestamp => $events) { |
|
| 331 | + if ($timestamp <= $this->end) { |
|
| 332 | + $date = Carbon::createFromTimestamp($timestamp, $calendar->timezone)->endOfDay()->format('Ymd'); |
|
| 333 | + $daily_events[intval($date)][] = $events; |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | - ksort( $daily_events, SORT_NUMERIC ); |
|
| 336 | + ksort($daily_events, SORT_NUMERIC); |
|
| 337 | 337 | |
| 338 | - if ( ! empty( $paged_events ) ) { |
|
| 339 | - $first_event = array_slice( $paged_events, 0, 1, true ); |
|
| 340 | - $first_event = array_pop( $first_event ); |
|
| 338 | + if ( ! empty($paged_events)) { |
|
| 339 | + $first_event = array_slice($paged_events, 0, 1, true); |
|
| 340 | + $first_event = array_pop($first_event); |
|
| 341 | 341 | $this->first_event = $first_event[0]->start; |
| 342 | 342 | |
| 343 | - $last_event = array_pop( $paged_events ); |
|
| 343 | + $last_event = array_pop($paged_events); |
|
| 344 | 344 | $this->last_event = $last_event[0]->start; |
| 345 | 345 | } |
| 346 | 346 | |
@@ -360,84 +360,84 @@ discard block |
||
| 360 | 360 | private function get_heading() { |
| 361 | 361 | |
| 362 | 362 | $calendar = $this->calendar; |
| 363 | - $start = Carbon::createFromTimestamp( $calendar->start, $calendar->timezone ); |
|
| 364 | - $end = Carbon::createFromTimestamp( $this->end, $calendar->timezone ); |
|
| 363 | + $start = Carbon::createFromTimestamp($calendar->start, $calendar->timezone); |
|
| 364 | + $end = Carbon::createFromTimestamp($this->end, $calendar->timezone); |
|
| 365 | 365 | $date_format = $this->calendar->date_format; |
| 366 | - $date_order = simcal_get_date_format_order( $date_format ); |
|
| 366 | + $date_order = simcal_get_date_format_order($date_format); |
|
| 367 | 367 | |
| 368 | 368 | $st = $this->start; |
| 369 | 369 | $et = $this->end; |
| 370 | 370 | |
| 371 | - if ( $this->first_event !== 0 ) { |
|
| 372 | - $start = Carbon::createFromTimestamp( $this->first_event, $calendar->timezone ); |
|
| 371 | + if ($this->first_event !== 0) { |
|
| 372 | + $start = Carbon::createFromTimestamp($this->first_event, $calendar->timezone); |
|
| 373 | 373 | $st = $this->first_event; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - if ( $this->last_event !== 0 ) { |
|
| 377 | - $end = Carbon::createFromTimestamp( $this->last_event, $calendar->timezone ); |
|
| 376 | + if ($this->last_event !== 0) { |
|
| 377 | + $end = Carbon::createFromTimestamp($this->last_event, $calendar->timezone); |
|
| 378 | 378 | $et = $this->last_event; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - if ( ( $start->day == $end->day ) && ( $start->month == $end->month ) && ( $start->year == $end->year ) ) { |
|
| 381 | + if (($start->day == $end->day) && ($start->month == $end->month) && ($start->year == $end->year)) { |
|
| 382 | 382 | // Start and end on the same day. |
| 383 | 383 | // e.g. 1 February 2020 |
| 384 | - $large = $small = date_i18n( $calendar->date_format , $st ); |
|
| 385 | - if ( ( $date_order['d'] !== false ) && ( $date_order['m'] !== false ) ) { |
|
| 386 | - if ( $date_order['m'] > $date_order['d'] ) { |
|
| 387 | - if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) { |
|
| 388 | - $small = date_i18n( 'Y, d M', $st ); |
|
| 384 | + $large = $small = date_i18n($calendar->date_format, $st); |
|
| 385 | + if (($date_order['d'] !== false) && ($date_order['m'] !== false)) { |
|
| 386 | + if ($date_order['m'] > $date_order['d']) { |
|
| 387 | + if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) { |
|
| 388 | + $small = date_i18n('Y, d M', $st); |
|
| 389 | 389 | } else { |
| 390 | - $small = date_i18n( 'd M Y', $st ); |
|
| 390 | + $small = date_i18n('d M Y', $st); |
|
| 391 | 391 | } |
| 392 | 392 | } else { |
| 393 | - if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) { |
|
| 394 | - $small = date_i18n( 'Y, M d', $st ); |
|
| 393 | + if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) { |
|
| 394 | + $small = date_i18n('Y, M d', $st); |
|
| 395 | 395 | } else { |
| 396 | - $small = date_i18n( 'M d Y', $st ); |
|
| 396 | + $small = date_i18n('M d Y', $st); |
|
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | - } elseif ( ( $start->month == $end->month ) && ( $start->year == $end->year ) ) { |
|
| 400 | + } elseif (($start->month == $end->month) && ($start->year == $end->year)) { |
|
| 401 | 401 | // Start and end days on the same month. |
| 402 | 402 | // e.g. August 2020 |
| 403 | - if ( $date_order['y'] === false ) { |
|
| 403 | + if ($date_order['y'] === false) { |
|
| 404 | 404 | // August. |
| 405 | - $large = $small = date_i18n( 'F', $st ); |
|
| 405 | + $large = $small = date_i18n('F', $st); |
|
| 406 | 406 | } else { |
| 407 | - if ( $date_order['y'] < $date_order['m'] ) { |
|
| 407 | + if ($date_order['y'] < $date_order['m']) { |
|
| 408 | 408 | // 2020 August. |
| 409 | - $large = date_i18n( 'Y F', $st ); |
|
| 410 | - $small = date_i18n( 'Y M', $st ); |
|
| 409 | + $large = date_i18n('Y F', $st); |
|
| 410 | + $small = date_i18n('Y M', $st); |
|
| 411 | 411 | } else { |
| 412 | 412 | // August 2020. |
| 413 | - $large = date_i18n( 'F Y', $st ); |
|
| 414 | - $small = date_i18n( 'M Y', $st ); |
|
| 413 | + $large = date_i18n('F Y', $st); |
|
| 414 | + $small = date_i18n('M Y', $st); |
|
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | - } elseif ( $start->year == $end->year ) { |
|
| 417 | + } elseif ($start->year == $end->year) { |
|
| 418 | 418 | // Start and end days on months of the same year. |
| 419 | 419 | // e.g. August - September 2020 |
| 420 | - if ( $date_order['y'] === false ) { |
|
| 420 | + if ($date_order['y'] === false) { |
|
| 421 | 421 | // August - September. |
| 422 | - $large = date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et ); |
|
| 423 | - $small = date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et ); |
|
| 422 | + $large = date_i18n('F', $st).' - '.date_i18n('F', $et); |
|
| 423 | + $small = date_i18n('M', $st).' - '.date_i18n('M', $et); |
|
| 424 | 424 | } else { |
| 425 | - if ( $date_order['y'] < $date_order['m'] ) { |
|
| 425 | + if ($date_order['y'] < $date_order['m']) { |
|
| 426 | 426 | // 2020, August - September. |
| 427 | - $large = $small = date( 'Y', $st ) . ', '; |
|
| 428 | - $large .= date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et ); |
|
| 429 | - $small .= date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et ); |
|
| 427 | + $large = $small = date('Y', $st).', '; |
|
| 428 | + $large .= date_i18n('F', $st).' - '.date_i18n('F', $et); |
|
| 429 | + $small .= date_i18n('M', $st).' - '.date_i18n('M', $et); |
|
| 430 | 430 | } else { |
| 431 | 431 | // August - September, 2020. |
| 432 | - $large = date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et ) . ', '; |
|
| 433 | - $small = date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et ) . ' '; |
|
| 434 | - $year = date( 'Y', $st ); |
|
| 432 | + $large = date_i18n('F', $st).' - '.date_i18n('F', $et).', '; |
|
| 433 | + $small = date_i18n('M', $st).' - '.date_i18n('M', $et).' '; |
|
| 434 | + $year = date('Y', $st); |
|
| 435 | 435 | $large .= $year; |
| 436 | 436 | $small .= $year; |
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | } else { |
| 440 | - $large = $small = date( 'Y', $st ) . ' - ' . date( 'Y', $et ); |
|
| 440 | + $large = $small = date('Y', $st).' - '.date('Y', $et); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | return array( |
@@ -459,133 +459,133 @@ discard block |
||
| 459 | 459 | * |
| 460 | 460 | * @return string |
| 461 | 461 | */ |
| 462 | - private function draw_list( $timestamp, $id = 0 ) { |
|
| 462 | + private function draw_list($timestamp, $id = 0) { |
|
| 463 | 463 | |
| 464 | 464 | $calendar = $this->calendar; |
| 465 | 465 | |
| 466 | - if ( empty( $calendar ) ) { |
|
| 467 | - $calendar = $this->calendar = simcal_get_calendar( intval( $id ) ); |
|
| 468 | - if ( ! $calendar instanceof Default_Calendar ) { |
|
| 466 | + if (empty($calendar)) { |
|
| 467 | + $calendar = $this->calendar = simcal_get_calendar(intval($id)); |
|
| 468 | + if ( ! $calendar instanceof Default_Calendar) { |
|
| 469 | 469 | return ''; |
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - $feed = simcal_get_feed( $calendar ); |
|
| 474 | - $feed_timezone = get_post_meta( $feed->post_id, '_feed_timezone', true ); |
|
| 473 | + $feed = simcal_get_feed($calendar); |
|
| 474 | + $feed_timezone = get_post_meta($feed->post_id, '_feed_timezone', true); |
|
| 475 | 475 | |
| 476 | 476 | $now = $calendar->now; |
| 477 | - $current_events = $this->get_events( $timestamp ); |
|
| 478 | - $day_format = explode( ' ', $calendar->date_format ); |
|
| 477 | + $current_events = $this->get_events($timestamp); |
|
| 478 | + $day_format = explode(' ', $calendar->date_format); |
|
| 479 | 479 | |
| 480 | 480 | ob_start(); |
| 481 | 481 | |
| 482 | 482 | // Draw the events. |
| 483 | 483 | |
| 484 | - $block_tag = $calendar->compact_list && ! empty( $current_events ) ? 'div' : 'dl'; |
|
| 484 | + $block_tag = $calendar->compact_list && ! empty($current_events) ? 'div' : 'dl'; |
|
| 485 | 485 | |
| 486 | 486 | $data_heading = ''; |
| 487 | 487 | $heading = $this->get_heading(); |
| 488 | - foreach ( $heading as $k => $v ) { |
|
| 489 | - $data_heading .= ' data-heading-' . $k . '="' . $v . '"'; |
|
| 488 | + foreach ($heading as $k => $v) { |
|
| 489 | + $data_heading .= ' data-heading-'.$k.'="'.$v.'"'; |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - echo '<' . $block_tag . ' class="simcal-events-list-container"' . |
|
| 493 | - ' data-prev="' . $this->prev . '"' . |
|
| 494 | - ' data-next="' . $this->next . '"' . |
|
| 495 | - $data_heading . '>'; |
|
| 492 | + echo '<'.$block_tag.' class="simcal-events-list-container"'. |
|
| 493 | + ' data-prev="'.$this->prev.'"'. |
|
| 494 | + ' data-next="'.$this->next.'"'. |
|
| 495 | + $data_heading.'>'; |
|
| 496 | 496 | |
| 497 | - if ( ! empty( $current_events ) && is_array( $current_events ) ) : |
|
| 497 | + if ( ! empty($current_events) && is_array($current_events)) : |
|
| 498 | 498 | |
| 499 | - foreach ( $current_events as $ymd => $events ) : |
|
| 499 | + foreach ($current_events as $ymd => $events) : |
|
| 500 | 500 | |
| 501 | 501 | |
| 502 | 502 | |
| 503 | 503 | // This is where we can find out if an event is a multi-day event and if it needs to be shown. |
| 504 | 504 | // Since this is for list view we are showing the event on the day viewed if it is part of that day even when |
| 505 | 505 | // expand multi-day events are turned off. |
| 506 | - if ( isset( $events[0][0]->multiple_days ) && $events[0][0]->multiple_days > 0 ) { |
|
| 507 | - if ( 'current_day_only' == get_post_meta($calendar->id, '_default_calendar_expand_multi_day_events', true ) ) { |
|
| 506 | + if (isset($events[0][0]->multiple_days) && $events[0][0]->multiple_days > 0) { |
|
| 507 | + if ('current_day_only' == get_post_meta($calendar->id, '_default_calendar_expand_multi_day_events', true)) { |
|
| 508 | 508 | |
| 509 | - $year = substr( $ymd, 0, 4 ); |
|
| 510 | - $month = substr( $ymd, 4, 2 ); |
|
| 511 | - $day = substr( $ymd, 6, 2 ); |
|
| 509 | + $year = substr($ymd, 0, 4); |
|
| 510 | + $month = substr($ymd, 4, 2); |
|
| 511 | + $day = substr($ymd, 6, 2); |
|
| 512 | 512 | |
| 513 | - $temp_date = Carbon::createFromDate( $year, $month, $day ); |
|
| 513 | + $temp_date = Carbon::createFromDate($year, $month, $day); |
|
| 514 | 514 | |
| 515 | - if( ! ( $temp_date < Carbon::now()->endOfDay() ) ) { |
|
| 515 | + if ( ! ($temp_date < Carbon::now()->endOfDay())) { |
|
| 516 | 516 | continue; |
| 517 | 517 | } |
| 518 | 518 | } |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - $day_ts = Carbon::createFromFormat( 'Ymd', $ymd, $calendar->timezone )->startOfDay()->getTimestamp(); |
|
| 521 | + $day_ts = Carbon::createFromFormat('Ymd', $ymd, $calendar->timezone)->startOfDay()->getTimestamp(); |
|
| 522 | 522 | |
| 523 | - if ( ! $calendar->compact_list ) : |
|
| 523 | + if ( ! $calendar->compact_list) : |
|
| 524 | 524 | |
| 525 | - $date = new Carbon( 'now', $calendar->timezone ); |
|
| 526 | - $date->setLocale( substr( get_locale(), 0, 2 ) ); |
|
| 527 | - $date->setTimestamp( $day_ts ); |
|
| 525 | + $date = new Carbon('now', $calendar->timezone); |
|
| 526 | + $date->setLocale(substr(get_locale(), 0, 2)); |
|
| 527 | + $date->setTimestamp($day_ts); |
|
| 528 | 528 | |
| 529 | - if ( $date->isToday() ) { |
|
| 530 | - $the_color = new Color( $calendar->today_color ); |
|
| 529 | + if ($date->isToday()) { |
|
| 530 | + $the_color = new Color($calendar->today_color); |
|
| 531 | 531 | } else { |
| 532 | - $the_color = new Color( $calendar->days_events_color ); |
|
| 532 | + $the_color = new Color($calendar->days_events_color); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - $bg_color = '#' . $the_color->getHex(); |
|
| 535 | + $bg_color = '#'.$the_color->getHex(); |
|
| 536 | 536 | $color = $the_color->isDark() ? '#ffffff' : '#000000'; |
| 537 | - $border_style = ' style="border-bottom: 1px solid ' . $bg_color . ';" '; |
|
| 538 | - $bg_style = ' style="background-color: ' . $bg_color . '; color: ' . $color . ';"'; |
|
| 537 | + $border_style = ' style="border-bottom: 1px solid '.$bg_color.';" '; |
|
| 538 | + $bg_style = ' style="background-color: '.$bg_color.'; color: '.$color.';"'; |
|
| 539 | 539 | |
| 540 | - echo "\t" . '<dt class="simcal-day-label"' . $border_style . '>'; |
|
| 541 | - echo '<span' . $bg_style .'>'; |
|
| 542 | - foreach ( $day_format as $format ) { |
|
| 543 | - echo $format ? '<span class="simcal-date-format" data-date-format="' . $format . '">' . date_i18n( $format, $day_ts ) . '</span> ' : ' '; |
|
| 540 | + echo "\t".'<dt class="simcal-day-label"'.$border_style.'>'; |
|
| 541 | + echo '<span'.$bg_style.'>'; |
|
| 542 | + foreach ($day_format as $format) { |
|
| 543 | + echo $format ? '<span class="simcal-date-format" data-date-format="'.$format.'">'.date_i18n($format, $day_ts).'</span> ' : ' '; |
|
| 544 | 544 | } |
| 545 | 545 | echo '</span>'; |
| 546 | - echo '</dt>' . "\n"; |
|
| 546 | + echo '</dt>'."\n"; |
|
| 547 | 547 | |
| 548 | 548 | endif; |
| 549 | 549 | |
| 550 | - $list_events = '<ul class="simcal-events">' . "\n"; |
|
| 550 | + $list_events = '<ul class="simcal-events">'."\n"; |
|
| 551 | 551 | |
| 552 | 552 | $calendar_classes = array(); |
| 553 | - $day_classes = 'simcal-weekday-' . date( 'w', $day_ts ); |
|
| 553 | + $day_classes = 'simcal-weekday-'.date('w', $day_ts); |
|
| 554 | 554 | |
| 555 | 555 | // Is this the present, the past or the future, Doc? |
| 556 | - if ( $timestamp <= $now && $timestamp >= $now ) { |
|
| 556 | + if ($timestamp <= $now && $timestamp >= $now) { |
|
| 557 | 557 | $day_classes .= ' simcal-today simcal-present simcal-day'; |
| 558 | - } elseif ( $timestamp < $now ) { |
|
| 558 | + } elseif ($timestamp < $now) { |
|
| 559 | 559 | $day_classes .= ' simcal-past simcal-day'; |
| 560 | - } elseif ( $this->end > $now ) { |
|
| 560 | + } elseif ($this->end > $now) { |
|
| 561 | 561 | $day_classes .= ' simcal-future simcal-day'; |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | $count = 0; |
| 565 | 565 | |
| 566 | - foreach ( $events as $day_events ) : |
|
| 567 | - foreach ( $day_events as $event ) : |
|
| 566 | + foreach ($events as $day_events) : |
|
| 567 | + foreach ($day_events as $event) : |
|
| 568 | 568 | |
| 569 | - if ( $event instanceof Event ) : |
|
| 569 | + if ($event instanceof Event) : |
|
| 570 | 570 | |
| 571 | - if ( $feed->type == 'grouped-calendars' ) { |
|
| 572 | - date_default_timezone_set( $feed_timezone ); |
|
| 571 | + if ($feed->type == 'grouped-calendars') { |
|
| 572 | + date_default_timezone_set($feed_timezone); |
|
| 573 | 573 | } else { |
| 574 | - date_default_timezone_set( $event->timezone ); |
|
| 574 | + date_default_timezone_set($event->timezone); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | $event_classes = $event_visibility = ''; |
| 578 | 578 | |
| 579 | - $calendar_class = 'simcal-events-calendar-' . strval( $event->calendar ); |
|
| 579 | + $calendar_class = 'simcal-events-calendar-'.strval($event->calendar); |
|
| 580 | 580 | $calendar_classes[] = $calendar_class; |
| 581 | 581 | |
| 582 | 582 | $recurring = $event->recurrence ? 'simcal-event-recurring ' : ''; |
| 583 | 583 | $has_location = $event->venue ? 'simcal-event-has-location ' : ''; |
| 584 | 584 | |
| 585 | - $event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class; |
|
| 585 | + $event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class; |
|
| 586 | 586 | |
| 587 | 587 | // Toggle some events visibility if more than optional limit. |
| 588 | - if ( ( $calendar->events_limit > - 1 ) && ( $count >= $calendar->events_limit ) ) : |
|
| 588 | + if (($calendar->events_limit > - 1) && ($count >= $calendar->events_limit)) : |
|
| 589 | 589 | $event_classes .= ' simcal-event-toggled'; |
| 590 | 590 | $event_visibility = ' style="display: none"'; |
| 591 | 591 | endif; |
@@ -593,75 +593,75 @@ discard block |
||
| 593 | 593 | $event_color = ''; |
| 594 | 594 | $bullet = ''; |
| 595 | 595 | $event_color = $event->get_color(); |
| 596 | - if ( ! empty( $event_color ) ) { |
|
| 596 | + if ( ! empty($event_color)) { |
|
| 597 | 597 | $side = is_rtl() ? 'right' : 'left'; |
| 598 | - $event_color = ' style="border-' . $side . ': 4px solid ' . $event_color . '; padding-' . $side . ': 8px;"'; |
|
| 598 | + $event_color = ' style="border-'.$side.': 4px solid '.$event_color.'; padding-'.$side.': 8px;"'; |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - $list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . $event_color . ' itemscope itemtype="http://schema.org/Event" data-start="' . esc_attr( $event->start ) . '">' . "\n"; |
|
| 602 | - $list_events .= "\t\t" . '<div class="simcal-event-details">' . $calendar->get_event_html( $event ) . '</div>' . "\n"; |
|
| 603 | - $list_events .= "\t" . '</li>' . "\n"; |
|
| 601 | + $list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.$event_color.' itemscope itemtype="http://schema.org/Event" data-start="'.esc_attr($event->start).'">'."\n"; |
|
| 602 | + $list_events .= "\t\t".'<div class="simcal-event-details">'.$calendar->get_event_html($event).'</div>'."\n"; |
|
| 603 | + $list_events .= "\t".'</li>'."\n"; |
|
| 604 | 604 | |
| 605 | - $count ++; |
|
| 605 | + $count++; |
|
| 606 | 606 | |
| 607 | 607 | // Event falls within today. |
| 608 | - if ( ( $this->end <= $now ) && ( $this->start >= $now ) ) : |
|
| 608 | + if (($this->end <= $now) && ($this->start >= $now)) : |
|
| 609 | 609 | $day_classes .= ' simcal-today-has-events'; |
| 610 | 610 | endif; |
| 611 | - $day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events'; |
|
| 611 | + $day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events'; |
|
| 612 | 612 | |
| 613 | - if ( $calendar_classes ) : |
|
| 614 | - $day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) ); |
|
| 613 | + if ($calendar_classes) : |
|
| 614 | + $day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes))); |
|
| 615 | 615 | endif; |
| 616 | 616 | |
| 617 | 617 | endif; |
| 618 | 618 | endforeach; |
| 619 | 619 | endforeach; |
| 620 | 620 | |
| 621 | - $list_events .= '</ul>' . "\n"; |
|
| 621 | + $list_events .= '</ul>'."\n"; |
|
| 622 | 622 | |
| 623 | 623 | // If events visibility is limited, print the button toggle. |
| 624 | - if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) : |
|
| 624 | + if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) : |
|
| 625 | 625 | $list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>'; |
| 626 | 626 | endif; |
| 627 | 627 | |
| 628 | 628 | // Print final list of events for the current day. |
| 629 | 629 | $tag = $calendar->compact_list ? 'div' : 'dd'; |
| 630 | - echo '<' . $tag . ' class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n"; |
|
| 631 | - echo "\t" . $list_events . "\n"; |
|
| 632 | - echo '</' . $tag . '>' . "\n"; |
|
| 630 | + echo '<'.$tag.' class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n"; |
|
| 631 | + echo "\t".$list_events."\n"; |
|
| 632 | + echo '</'.$tag.'>'."\n"; |
|
| 633 | 633 | |
| 634 | 634 | endforeach; |
| 635 | 635 | |
| 636 | 636 | else : |
| 637 | 637 | |
| 638 | - echo "\t" . '<p>'; |
|
| 638 | + echo "\t".'<p>'; |
|
| 639 | 639 | |
| 640 | - $message = get_post_meta( $calendar->id, '_no_events_message', true ); |
|
| 640 | + $message = get_post_meta($calendar->id, '_no_events_message', true); |
|
| 641 | 641 | |
| 642 | - if ( 'events' == $calendar->group_type ) { |
|
| 643 | - echo ! empty( $message ) ? $message : __( 'There are no upcoming events.', 'google-calendar-events' ); |
|
| 642 | + if ('events' == $calendar->group_type) { |
|
| 643 | + echo ! empty($message) ? $message : __('There are no upcoming events.', 'google-calendar-events'); |
|
| 644 | 644 | } else { |
| 645 | - if ( ! empty( $message ) ) { |
|
| 645 | + if ( ! empty($message)) { |
|
| 646 | 646 | echo $message; |
| 647 | 647 | } else { |
| 648 | - $from = Carbon::createFromTimestamp( $this->start, $calendar->timezone )->getTimestamp(); |
|
| 649 | - $to = Carbon::createFromTimestamp( $this->end, $calendar->timezone )->getTimestamp(); |
|
| 650 | - echo apply_filters( 'simcal_no_events_message', sprintf( |
|
| 651 | - __( 'Nothing from %1$s to %2$s.', 'google-calendar-events' ), |
|
| 652 | - date_i18n( $calendar->date_format, $from ), |
|
| 653 | - date_i18n( $calendar->date_format, $to ) |
|
| 654 | - ), $calendar->id, $from, $to ); |
|
| 648 | + $from = Carbon::createFromTimestamp($this->start, $calendar->timezone)->getTimestamp(); |
|
| 649 | + $to = Carbon::createFromTimestamp($this->end, $calendar->timezone)->getTimestamp(); |
|
| 650 | + echo apply_filters('simcal_no_events_message', sprintf( |
|
| 651 | + __('Nothing from %1$s to %2$s.', 'google-calendar-events'), |
|
| 652 | + date_i18n($calendar->date_format, $from), |
|
| 653 | + date_i18n($calendar->date_format, $to) |
|
| 654 | + ), $calendar->id, $from, $to); |
|
| 655 | 655 | } |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | - echo "\t" . '</p>' . "\n"; |
|
| 658 | + echo "\t".'</p>'."\n"; |
|
| 659 | 659 | |
| 660 | 660 | endif; |
| 661 | 661 | |
| 662 | - echo '</' . $block_tag . '>'; |
|
| 662 | + echo '</'.$block_tag.'>'; |
|
| 663 | 663 | |
| 664 | - date_default_timezone_set( $calendar->site_timezone ); |
|
| 664 | + date_default_timezone_set($calendar->site_timezone); |
|
| 665 | 665 | |
| 666 | 666 | return ob_get_clean(); |
| 667 | 667 | } |
@@ -673,16 +673,16 @@ discard block |
||
| 673 | 673 | */ |
| 674 | 674 | public function draw_list_ajax() { |
| 675 | 675 | |
| 676 | - if ( isset( $_POST['ts'] ) && isset( $_POST['id'] ) ) { |
|
| 676 | + if (isset($_POST['ts']) && isset($_POST['id'])) { |
|
| 677 | 677 | |
| 678 | - $ts = absint( $_POST['ts'] ); |
|
| 679 | - $id = absint( $_POST['id'] ); |
|
| 678 | + $ts = absint($_POST['ts']); |
|
| 679 | + $id = absint($_POST['id']); |
|
| 680 | 680 | |
| 681 | - wp_send_json_success( $this->draw_list( $ts, $id ) ); |
|
| 681 | + wp_send_json_success($this->draw_list($ts, $id)); |
|
| 682 | 682 | |
| 683 | 683 | } else { |
| 684 | 684 | |
| 685 | - wp_send_json_error( 'Missing arguments in default calendar list ajax request.' ); |
|
| 685 | + wp_send_json_error('Missing arguments in default calendar list ajax request.'); |
|
| 686 | 686 | |
| 687 | 687 | } |
| 688 | 688 | } |
@@ -697,8 +697,8 @@ discard block |
||
| 697 | 697 | * |
| 698 | 698 | * @return bool |
| 699 | 699 | */ |
| 700 | - private function filter_events_before( $event ) { |
|
| 701 | - return intval( $event ) >= intval( $this->start ); |
|
| 700 | + private function filter_events_before($event) { |
|
| 701 | + return intval($event) >= intval($this->start); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | /** |
@@ -711,8 +711,8 @@ discard block |
||
| 711 | 711 | * |
| 712 | 712 | * @return bool |
| 713 | 713 | */ |
| 714 | - private function filter_events_after( $event ) { |
|
| 715 | - return intval( $event ) < intval( $this->end ); |
|
| 714 | + private function filter_events_after($event) { |
|
| 715 | + return intval($event) < intval($this->end); |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | */ |
| 7 | 7 | namespace SimpleCalendar\Calendars\Admin; |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if ( ! defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct() { |
| 26 | 26 | |
| 27 | - if ( simcal_is_admin_screen() !== false ) { |
|
| 28 | - add_action( 'simcal_settings_meta_calendar_panel', array( $this, 'add_settings_meta_calendar_panel' ), 10, 1 ); |
|
| 27 | + if (simcal_is_admin_screen() !== false) { |
|
| 28 | + add_action('simcal_settings_meta_calendar_panel', array($this, 'add_settings_meta_calendar_panel'), 10, 1); |
|
| 29 | 29 | } |
| 30 | - add_action( 'simcal_process_settings_meta', array( $this, 'process_meta' ), 10, 1 ); |
|
| 30 | + add_action('simcal_process_settings_meta', array($this, 'process_meta'), 10, 1); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -76,47 +76,47 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @param int $post_id |
| 78 | 78 | */ |
| 79 | - public function add_settings_meta_calendar_panel( $post_id ) { |
|
| 79 | + public function add_settings_meta_calendar_panel($post_id) { |
|
| 80 | 80 | |
| 81 | 81 | ?> |
| 82 | 82 | <table id="default-calendar-settings"> |
| 83 | 83 | <thead> |
| 84 | - <tr><th colspan="2"><?php _e( 'Default Calendar', 'google-calendar-events' ); ?></th></tr> |
|
| 84 | + <tr><th colspan="2"><?php _e('Default Calendar', 'google-calendar-events'); ?></th></tr> |
|
| 85 | 85 | </thead> |
| 86 | 86 | <tbody class="simcal-panel-section"> |
| 87 | 87 | |
| 88 | 88 | <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> |
| 89 | - <th><label for="_default_calendar_event_bubbles_action"><?php _e( 'Event Bubbles', 'google-calendar-events' ); ?></label></th> |
|
| 89 | + <th><label for="_default_calendar_event_bubbles_action"><?php _e('Event Bubbles', 'google-calendar-events'); ?></label></th> |
|
| 90 | 90 | <td> |
| 91 | 91 | <?php |
| 92 | 92 | |
| 93 | - $bubbles = get_post_meta( $post_id, '_default_calendar_event_bubble_trigger', true ); |
|
| 93 | + $bubbles = get_post_meta($post_id, '_default_calendar_event_bubble_trigger', true); |
|
| 94 | 94 | |
| 95 | - simcal_print_field( array( |
|
| 95 | + simcal_print_field(array( |
|
| 96 | 96 | 'type' => 'radio', |
| 97 | 97 | 'inline' => 'inline', |
| 98 | 98 | 'name' => '_default_calendar_event_bubble_trigger', |
| 99 | 99 | 'id' => '_default_calendar_event_bubble_trigger', |
| 100 | - 'tooltip' => __( 'Open event bubbles in calendar grid by clicking or hovering on event titles. On mobile devices it will always default to tapping.', 'google-calendar-events' ), |
|
| 100 | + 'tooltip' => __('Open event bubbles in calendar grid by clicking or hovering on event titles. On mobile devices it will always default to tapping.', 'google-calendar-events'), |
|
| 101 | 101 | 'value' => $bubbles ? $bubbles : 'hover', |
| 102 | 102 | 'default' => 'hover', |
| 103 | 103 | 'options' => array( |
| 104 | - 'click' => __( 'Click', 'google-calendar-events' ), |
|
| 105 | - 'hover' => __( 'Hover', 'google-calendar-events' ), |
|
| 104 | + 'click' => __('Click', 'google-calendar-events'), |
|
| 105 | + 'hover' => __('Hover', 'google-calendar-events'), |
|
| 106 | 106 | ), |
| 107 | - ) ); |
|
| 107 | + )); |
|
| 108 | 108 | |
| 109 | 109 | ?> |
| 110 | 110 | </td> |
| 111 | 111 | </tr> |
| 112 | 112 | <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> |
| 113 | - <th><label for="_default_calendar_trim_titles"><?php _e( 'Trim Event Titles', 'google-calendar-events' ); ?></label></th> |
|
| 113 | + <th><label for="_default_calendar_trim_titles"><?php _e('Trim Event Titles', 'google-calendar-events'); ?></label></th> |
|
| 114 | 114 | <td> |
| 115 | 115 | <?php |
| 116 | 116 | |
| 117 | - $trim = get_post_meta( $post_id, '_default_calendar_trim_titles', true ); |
|
| 117 | + $trim = get_post_meta($post_id, '_default_calendar_trim_titles', true); |
|
| 118 | 118 | |
| 119 | - simcal_print_field( array( |
|
| 119 | + simcal_print_field(array( |
|
| 120 | 120 | 'type' => 'checkbox', |
| 121 | 121 | 'name' => '_default_calendar_trim_titles', |
| 122 | 122 | 'id' => '_default_calendar_trim_titles', |
@@ -127,34 +127,34 @@ discard block |
||
| 127 | 127 | 'attributes' => array( |
| 128 | 128 | 'data-show-next-if-value' => 'yes', |
| 129 | 129 | ), |
| 130 | - ) ); |
|
| 130 | + )); |
|
| 131 | 131 | |
| 132 | - simcal_print_field( array( |
|
| 132 | + simcal_print_field(array( |
|
| 133 | 133 | 'type' => 'standard', |
| 134 | 134 | 'subtype' => 'number', |
| 135 | 135 | 'name' => '_default_calendar_trim_titles_chars', |
| 136 | 136 | 'id' => '_default_calendar_trim_titles_chars', |
| 137 | - 'tooltip' => __( 'Shorten event titles in calendar grid to a specified length in characters.', 'google-calendar-events' ), |
|
| 137 | + 'tooltip' => __('Shorten event titles in calendar grid to a specified length in characters.', 'google-calendar-events'), |
|
| 138 | 138 | 'class' => array( |
| 139 | 139 | 'simcal-field-tiny', |
| 140 | 140 | ), |
| 141 | - 'value' => 'yes' == $trim ? strval( max( absint( get_post_meta( $post_id, '_default_calendar_trim_titles_chars', true ) ), 1 ) ) : '20', |
|
| 141 | + 'value' => 'yes' == $trim ? strval(max(absint(get_post_meta($post_id, '_default_calendar_trim_titles_chars', true)), 1)) : '20', |
|
| 142 | 142 | 'attributes' => array( |
| 143 | 143 | 'min' => '1', |
| 144 | 144 | ), |
| 145 | - ) ); |
|
| 145 | + )); |
|
| 146 | 146 | |
| 147 | 147 | ?> |
| 148 | 148 | </td> |
| 149 | 149 | </tr> |
| 150 | 150 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
| 151 | - <th><label for="_default_calendar_list_grouped_span"><?php _e( 'Span', 'google-calendar-events' ); ?></label></th> |
|
| 151 | + <th><label for="_default_calendar_list_grouped_span"><?php _e('Span', 'google-calendar-events'); ?></label></th> |
|
| 152 | 152 | <td> |
| 153 | 153 | <?php |
| 154 | 154 | |
| 155 | - $list_span = max( absint( get_post_meta( $post_id, '_default_calendar_list_range_span', true ) ), 1 ); |
|
| 155 | + $list_span = max(absint(get_post_meta($post_id, '_default_calendar_list_range_span', true)), 1); |
|
| 156 | 156 | |
| 157 | - simcal_print_field( array( |
|
| 157 | + simcal_print_field(array( |
|
| 158 | 158 | 'type' => 'standard', |
| 159 | 159 | 'subtype' => 'number', |
| 160 | 160 | 'name' => '_default_calendar_list_range_span', |
@@ -163,78 +163,78 @@ discard block |
||
| 163 | 163 | 'simcal-field-tiny', |
| 164 | 164 | 'simcal-field-inline', |
| 165 | 165 | ), |
| 166 | - 'value' => strval( $list_span ), |
|
| 166 | + 'value' => strval($list_span), |
|
| 167 | 167 | 'attributes' => array( |
| 168 | 168 | 'min' => '1', |
| 169 | 169 | ), |
| 170 | - ) ); |
|
| 170 | + )); |
|
| 171 | 171 | |
| 172 | - $list_type = get_post_meta( $post_id, '_default_calendar_list_range_type', true ); |
|
| 172 | + $list_type = get_post_meta($post_id, '_default_calendar_list_range_type', true); |
|
| 173 | 173 | |
| 174 | - simcal_print_field( array( |
|
| 174 | + simcal_print_field(array( |
|
| 175 | 175 | 'type' => 'select', |
| 176 | 176 | 'name' => '_default_calendar_list_range_type', |
| 177 | 177 | 'id' => '_default_calendar_list_range_type', |
| 178 | - 'tooltip' => __( 'Range of events to show on each calendar page.', 'google-calendar-events' ), |
|
| 178 | + 'tooltip' => __('Range of events to show on each calendar page.', 'google-calendar-events'), |
|
| 179 | 179 | 'class' => array( |
| 180 | 180 | 'simcal-field-inline', |
| 181 | 181 | ), |
| 182 | 182 | 'value' => $list_type, |
| 183 | 183 | 'options' => array( |
| 184 | - 'monthly' => __( 'Month(s)', 'google-calendar-events' ), |
|
| 185 | - 'weekly' => __( 'Week(s)', 'google-calendar-events' ), |
|
| 186 | - 'daily' => __( 'Day(s)', 'google-calendar-events' ), |
|
| 187 | - 'events' => __( 'Event(s)', 'google-calendar-events' ), |
|
| 184 | + 'monthly' => __('Month(s)', 'google-calendar-events'), |
|
| 185 | + 'weekly' => __('Week(s)', 'google-calendar-events'), |
|
| 186 | + 'daily' => __('Day(s)', 'google-calendar-events'), |
|
| 187 | + 'events' => __('Event(s)', 'google-calendar-events'), |
|
| 188 | 188 | ), |
| 189 | - ) ); |
|
| 189 | + )); |
|
| 190 | 190 | |
| 191 | 191 | ?> |
| 192 | 192 | </td> |
| 193 | 193 | </tr> |
| 194 | 194 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
| 195 | - <th><label for="_default_calendar_list_header"><?php _e( 'Hide Header', 'google-calendar-events' ); ?></label></th> |
|
| 195 | + <th><label for="_default_calendar_list_header"><?php _e('Hide Header', 'google-calendar-events'); ?></label></th> |
|
| 196 | 196 | <td> |
| 197 | 197 | <?php |
| 198 | 198 | |
| 199 | - $header = get_post_meta( $post_id, '_default_calendar_list_header', true ); |
|
| 199 | + $header = get_post_meta($post_id, '_default_calendar_list_header', true); |
|
| 200 | 200 | |
| 201 | - simcal_print_field( array( |
|
| 201 | + simcal_print_field(array( |
|
| 202 | 202 | 'type' => 'checkbox', |
| 203 | 203 | 'name' => '_default_calendar_list_header', |
| 204 | 204 | 'id' => '_default_calendar_list_header', |
| 205 | - 'tooltip' => __( 'You can use this to hide the month header for this calendar.', 'google-calendar-events' ), |
|
| 205 | + 'tooltip' => __('You can use this to hide the month header for this calendar.', 'google-calendar-events'), |
|
| 206 | 206 | 'value' => 'yes' == $header ? 'yes' : 'no', |
| 207 | - ) ); |
|
| 207 | + )); |
|
| 208 | 208 | |
| 209 | 209 | ?> |
| 210 | 210 | </td> |
| 211 | 211 | </tr> |
| 212 | 212 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
| 213 | - <th><label for="_default_calendar_compact_list"><?php _e( 'Compact List', 'google-calendar-events' ); ?></label></th> |
|
| 213 | + <th><label for="_default_calendar_compact_list"><?php _e('Compact List', 'google-calendar-events'); ?></label></th> |
|
| 214 | 214 | <td> |
| 215 | 215 | <?php |
| 216 | 216 | |
| 217 | - $compact = get_post_meta( $post_id, '_default_calendar_compact_list', true ); |
|
| 217 | + $compact = get_post_meta($post_id, '_default_calendar_compact_list', true); |
|
| 218 | 218 | |
| 219 | - simcal_print_field( array( |
|
| 219 | + simcal_print_field(array( |
|
| 220 | 220 | 'type' => 'checkbox', |
| 221 | 221 | 'name' => '_default_calendar_compact_list', |
| 222 | 222 | 'id' => '_default_calendar_compact_list', |
| 223 | - 'tooltip' => __( 'Make an events list more compact by grouping together events from different days in a single list.', 'google-calendar-events' ), |
|
| 223 | + 'tooltip' => __('Make an events list more compact by grouping together events from different days in a single list.', 'google-calendar-events'), |
|
| 224 | 224 | 'value' => 'yes' == $compact ? 'yes' : 'no', |
| 225 | - ) ); |
|
| 225 | + )); |
|
| 226 | 226 | |
| 227 | 227 | ?> |
| 228 | 228 | </td> |
| 229 | 229 | </tr> |
| 230 | 230 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 231 | - <th><label for="_default_calendar_limit_visible_events"><?php _e( 'Limit Visible Events', 'google-calendar-events' ); ?></label></th> |
|
| 231 | + <th><label for="_default_calendar_limit_visible_events"><?php _e('Limit Visible Events', 'google-calendar-events'); ?></label></th> |
|
| 232 | 232 | <td> |
| 233 | 233 | <?php |
| 234 | 234 | |
| 235 | - $limit = get_post_meta( $post_id, '_default_calendar_limit_visible_events', true ); |
|
| 235 | + $limit = get_post_meta($post_id, '_default_calendar_limit_visible_events', true); |
|
| 236 | 236 | |
| 237 | - simcal_print_field( array( |
|
| 237 | + simcal_print_field(array( |
|
| 238 | 238 | 'type' => 'checkbox', |
| 239 | 239 | 'name' => '_default_calendar_limit_visible_events', |
| 240 | 240 | 'id' => '_default_calendar_limit_visible_events', |
@@ -245,17 +245,17 @@ discard block |
||
| 245 | 245 | 'attributes' => array( |
| 246 | 246 | 'data-show-next-if-value' => 'yes', |
| 247 | 247 | ) |
| 248 | - ) ); |
|
| 248 | + )); |
|
| 249 | 249 | |
| 250 | - $visible_events = absint( get_post_meta( $post_id, '_default_calendar_visible_events', true ) ); |
|
| 250 | + $visible_events = absint(get_post_meta($post_id, '_default_calendar_visible_events', true)); |
|
| 251 | 251 | $visible_events = $visible_events > 0 ? $visible_events : 3; |
| 252 | 252 | |
| 253 | - simcal_print_field( array( |
|
| 253 | + simcal_print_field(array( |
|
| 254 | 254 | 'type' => 'standard', |
| 255 | 255 | 'subtype' => 'number', |
| 256 | 256 | 'name' => '_default_calendar_visible_events', |
| 257 | 257 | 'id' => '_default_calendar_visible_events', |
| 258 | - 'tooltip' => __( 'Limit the number of initial visible events on each day to a set maximum.', 'google-calendar-events' ), |
|
| 258 | + 'tooltip' => __('Limit the number of initial visible events on each day to a set maximum.', 'google-calendar-events'), |
|
| 259 | 259 | 'class' => array( |
| 260 | 260 | 'simcal-field-tiny', |
| 261 | 261 | ), |
@@ -263,39 +263,39 @@ discard block |
||
| 263 | 263 | 'attributes' => array( |
| 264 | 264 | 'min' => '1', |
| 265 | 265 | ) |
| 266 | - ) ); |
|
| 266 | + )); |
|
| 267 | 267 | |
| 268 | 268 | ?> |
| 269 | 269 | </td> |
| 270 | 270 | </tr> |
| 271 | 271 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 272 | - <th><label for="_default_calendar_event_bubbles_action"><?php _e( 'Expand Multi-day Events', 'google-calendar-events' ); ?></label></th> |
|
| 272 | + <th><label for="_default_calendar_event_bubbles_action"><?php _e('Expand Multi-day Events', 'google-calendar-events'); ?></label></th> |
|
| 273 | 273 | <td> |
| 274 | 274 | <?php |
| 275 | 275 | |
| 276 | - $post_meta = get_post_meta( $post_id ); |
|
| 276 | + $post_meta = get_post_meta($post_id); |
|
| 277 | 277 | |
| 278 | - if ( ! is_array( $post_meta ) && ! empty( $post_meta ) ) { |
|
| 278 | + if ( ! is_array($post_meta) && ! empty($post_meta)) { |
|
| 279 | 279 | $multi_day_value = 'current_day_only'; |
| 280 | 280 | } else { |
| 281 | - $multi_day_value = get_post_meta( $post_id, '_default_calendar_expand_multi_day_events', true ); |
|
| 281 | + $multi_day_value = get_post_meta($post_id, '_default_calendar_expand_multi_day_events', true); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - simcal_print_field( array( |
|
| 284 | + simcal_print_field(array( |
|
| 285 | 285 | 'type' => 'select', |
| 286 | 286 | 'name' => '_default_calendar_expand_multi_day_events', |
| 287 | 287 | 'id' => '_default_calendar_expand_multi_day_events', |
| 288 | - 'tooltip' => __( 'For events spanning multiple days, you can display them on each day of the event, ' . |
|
| 289 | - 'only on the first day of the event, or on all days of the event, but only up to the current day. ' . |
|
| 290 | - 'Third option applies to list views only.', 'google-calendar-events' ), |
|
| 288 | + 'tooltip' => __('For events spanning multiple days, you can display them on each day of the event, '. |
|
| 289 | + 'only on the first day of the event, or on all days of the event, but only up to the current day. '. |
|
| 290 | + 'Third option applies to list views only.', 'google-calendar-events'), |
|
| 291 | 291 | 'value' => $multi_day_value, |
| 292 | 292 | 'options' => array( |
| 293 | - 'yes' => __( 'Yes, display on all days of event', 'google-calendar-events' ), |
|
| 294 | - 'no' => __( 'No, display only on first day of event', 'google-calendar-events' ), |
|
| 295 | - 'current_day_only' => __( 'No, display on all days of event up to current day (list view only)', 'google-calendar-events' ), |
|
| 293 | + 'yes' => __('Yes, display on all days of event', 'google-calendar-events'), |
|
| 294 | + 'no' => __('No, display only on first day of event', 'google-calendar-events'), |
|
| 295 | + 'current_day_only' => __('No, display on all days of event up to current day (list view only)', 'google-calendar-events'), |
|
| 296 | 296 | ), |
| 297 | 297 | 'default' => 'current_day_only', |
| 298 | - ) ); |
|
| 298 | + )); |
|
| 299 | 299 | |
| 300 | 300 | ?> |
| 301 | 301 | </td> |
@@ -304,72 +304,72 @@ discard block |
||
| 304 | 304 | <?php |
| 305 | 305 | |
| 306 | 306 | // TODO Defaults repeated here and in process_meta(). Need to consolidate at some point. |
| 307 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
| 308 | - $default_theme = isset( $settings['default-calendar']['theme'] ) ? $settings['default-calendar']['theme'] : 'light'; |
|
| 309 | - $default_today_color = isset( $settings['default-calendar']['today_color'] ) ? $settings['default-calendar']['today_color'] : '#1e73be'; |
|
| 310 | - $default_days_events_color = isset( $settings['default-calendar']['days_events_color'] ) ? $settings['default-calendar']['days_events_color'] : '#000000'; |
|
| 307 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
| 308 | + $default_theme = isset($settings['default-calendar']['theme']) ? $settings['default-calendar']['theme'] : 'light'; |
|
| 309 | + $default_today_color = isset($settings['default-calendar']['today_color']) ? $settings['default-calendar']['today_color'] : '#1e73be'; |
|
| 310 | + $default_days_events_color = isset($settings['default-calendar']['days_events_color']) ? $settings['default-calendar']['days_events_color'] : '#000000'; |
|
| 311 | 311 | |
| 312 | 312 | ?> |
| 313 | 313 | <tbody class="simcal-panel-section"> |
| 314 | 314 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 315 | - <th><label for="_default_calendar_style_theme"><?php _e( 'Theme', 'google-calendar-events' ); ?></label></th> |
|
| 315 | + <th><label for="_default_calendar_style_theme"><?php _e('Theme', 'google-calendar-events'); ?></label></th> |
|
| 316 | 316 | <td> |
| 317 | 317 | <?php |
| 318 | 318 | |
| 319 | - $saved = get_post_meta( $post_id, '_default_calendar_style_theme', true ); |
|
| 319 | + $saved = get_post_meta($post_id, '_default_calendar_style_theme', true); |
|
| 320 | 320 | $value = ! $saved ? $default_theme : $saved; |
| 321 | 321 | |
| 322 | - simcal_print_field( array( |
|
| 322 | + simcal_print_field(array( |
|
| 323 | 323 | 'type' => 'select', |
| 324 | 324 | 'name' => '_default_calendar_style_theme', |
| 325 | 325 | 'id' => '_default_calendar_style_theme', |
| 326 | 326 | 'value' => $value, |
| 327 | - 'tooltip' => __( 'Choose a calendar theme to match your site theme.', 'google-calendar-events' ), |
|
| 327 | + 'tooltip' => __('Choose a calendar theme to match your site theme.', 'google-calendar-events'), |
|
| 328 | 328 | 'options' => array( |
| 329 | - 'light' => __( 'Light', 'google-calendar-events' ), |
|
| 330 | - 'dark' => __( 'Dark', 'google-calendar-events' ), |
|
| 329 | + 'light' => __('Light', 'google-calendar-events'), |
|
| 330 | + 'dark' => __('Dark', 'google-calendar-events'), |
|
| 331 | 331 | ), |
| 332 | - ) ); |
|
| 332 | + )); |
|
| 333 | 333 | |
| 334 | 334 | ?> |
| 335 | 335 | </td> |
| 336 | 336 | </tr> |
| 337 | 337 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 338 | - <th><label for="_default_calendar_style_today"><?php _e( 'Today', 'google-calendar-events' ); ?></label></th> |
|
| 338 | + <th><label for="_default_calendar_style_today"><?php _e('Today', 'google-calendar-events'); ?></label></th> |
|
| 339 | 339 | <td> |
| 340 | 340 | <?php |
| 341 | 341 | |
| 342 | - $saved = get_post_meta( $post_id, '_default_calendar_style_today', true ); |
|
| 342 | + $saved = get_post_meta($post_id, '_default_calendar_style_today', true); |
|
| 343 | 343 | $value = ! $saved ? $default_today_color : $saved; |
| 344 | 344 | |
| 345 | - simcal_print_field( array( |
|
| 345 | + simcal_print_field(array( |
|
| 346 | 346 | 'type' => 'standard', |
| 347 | 347 | 'subtype' => 'color-picker', |
| 348 | 348 | 'name' => '_default_calendar_style_today', |
| 349 | 349 | 'id' => '_default_calendar_style_today', |
| 350 | 350 | 'value' => $value, |
| 351 | - 'tooltip' => __( "This option will set the background color for today's date. It will change the day number background and the border around the current day.", 'google-calendar-events' ), |
|
| 352 | - ) ); |
|
| 351 | + 'tooltip' => __("This option will set the background color for today's date. It will change the day number background and the border around the current day.", 'google-calendar-events'), |
|
| 352 | + )); |
|
| 353 | 353 | |
| 354 | 354 | ?> |
| 355 | 355 | </td> |
| 356 | 356 | </tr> |
| 357 | 357 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 358 | - <th><label for="_default_calendar_style_days_events"><?php _e( 'Days with Events', 'google-calendar-events' ); ?></label></th> |
|
| 358 | + <th><label for="_default_calendar_style_days_events"><?php _e('Days with Events', 'google-calendar-events'); ?></label></th> |
|
| 359 | 359 | <td> |
| 360 | 360 | <?php |
| 361 | 361 | |
| 362 | - $saved = get_post_meta( $post_id, '_default_calendar_style_days_events', true ); |
|
| 362 | + $saved = get_post_meta($post_id, '_default_calendar_style_days_events', true); |
|
| 363 | 363 | $value = ! $saved ? $default_days_events_color : $saved; |
| 364 | 364 | |
| 365 | - simcal_print_field( array( |
|
| 365 | + simcal_print_field(array( |
|
| 366 | 366 | 'type' => 'standard', |
| 367 | 367 | 'subtype' => 'color-picker', |
| 368 | 368 | 'name' => '_default_calendar_style_days_events', |
| 369 | 369 | 'id' => '_default_calendar_style_days_events', |
| 370 | 370 | 'value' => $value, |
| 371 | - 'tooltip' => __( 'This setting will modify the day number background for any days that have events on them.', 'google-calendar-events' ), |
|
| 372 | - ) ); |
|
| 371 | + 'tooltip' => __('This setting will modify the day number background for any days that have events on them.', 'google-calendar-events'), |
|
| 372 | + )); |
|
| 373 | 373 | |
| 374 | 374 | ?> |
| 375 | 375 | </td> |
@@ -391,55 +391,55 @@ discard block |
||
| 391 | 391 | * |
| 392 | 392 | * @param int $post_id |
| 393 | 393 | */ |
| 394 | - public function process_meta( $post_id ) { |
|
| 394 | + public function process_meta($post_id) { |
|
| 395 | 395 | |
| 396 | 396 | // Theme. |
| 397 | - $theme = isset( $_POST['_default_calendar_style_theme'] ) ? sanitize_key( $_POST['_default_calendar_style_theme'] ) : 'light'; |
|
| 398 | - update_post_meta( $post_id, '_default_calendar_style_theme', $theme ); |
|
| 397 | + $theme = isset($_POST['_default_calendar_style_theme']) ? sanitize_key($_POST['_default_calendar_style_theme']) : 'light'; |
|
| 398 | + update_post_meta($post_id, '_default_calendar_style_theme', $theme); |
|
| 399 | 399 | |
| 400 | 400 | // Today color. |
| 401 | - $today_color = isset( $_POST['_default_calendar_style_today'] ) ? sanitize_text_field( $_POST['_default_calendar_style_today'] ) : '#1e73be'; |
|
| 402 | - update_post_meta( $post_id, '_default_calendar_style_today', $today_color ); |
|
| 401 | + $today_color = isset($_POST['_default_calendar_style_today']) ? sanitize_text_field($_POST['_default_calendar_style_today']) : '#1e73be'; |
|
| 402 | + update_post_meta($post_id, '_default_calendar_style_today', $today_color); |
|
| 403 | 403 | |
| 404 | 404 | // Days with events color. |
| 405 | - $days_events_color = isset( $_POST['_default_calendar_style_days_events'] ) ? sanitize_text_field( $_POST['_default_calendar_style_days_events'] ) : '#000000'; |
|
| 406 | - update_post_meta( $post_id, '_default_calendar_style_days_events', $days_events_color ); |
|
| 405 | + $days_events_color = isset($_POST['_default_calendar_style_days_events']) ? sanitize_text_field($_POST['_default_calendar_style_days_events']) : '#000000'; |
|
| 406 | + update_post_meta($post_id, '_default_calendar_style_days_events', $days_events_color); |
|
| 407 | 407 | |
| 408 | 408 | // List range span. |
| 409 | - $span = isset( $_POST['_default_calendar_list_range_span'] ) ? max( absint( $_POST['_default_calendar_list_range_span'] ), 1 ) : 1; |
|
| 410 | - update_post_meta( $post_id, '_default_calendar_list_range_span', $span ); |
|
| 409 | + $span = isset($_POST['_default_calendar_list_range_span']) ? max(absint($_POST['_default_calendar_list_range_span']), 1) : 1; |
|
| 410 | + update_post_meta($post_id, '_default_calendar_list_range_span', $span); |
|
| 411 | 411 | |
| 412 | 412 | // List range type. |
| 413 | - $group = isset( $_POST['_default_calendar_list_range_type'] ) ? sanitize_key( $_POST['_default_calendar_list_range_type'] ) : 'monthly'; |
|
| 414 | - update_post_meta( $post_id, '_default_calendar_list_range_type', $group ); |
|
| 413 | + $group = isset($_POST['_default_calendar_list_range_type']) ? sanitize_key($_POST['_default_calendar_list_range_type']) : 'monthly'; |
|
| 414 | + update_post_meta($post_id, '_default_calendar_list_range_type', $group); |
|
| 415 | 415 | |
| 416 | 416 | // Hide header. |
| 417 | - $header = isset( $_POST['_default_calendar_list_header'] ) ? 'yes' : 'no'; |
|
| 418 | - update_post_meta( $post_id, '_default_calendar_list_header', $header ); |
|
| 417 | + $header = isset($_POST['_default_calendar_list_header']) ? 'yes' : 'no'; |
|
| 418 | + update_post_meta($post_id, '_default_calendar_list_header', $header); |
|
| 419 | 419 | |
| 420 | 420 | // Compact list. |
| 421 | - $compact = isset( $_POST['_default_calendar_compact_list'] ) ? 'yes' : 'no'; |
|
| 422 | - update_post_meta( $post_id, '_default_calendar_compact_list', $compact ); |
|
| 421 | + $compact = isset($_POST['_default_calendar_compact_list']) ? 'yes' : 'no'; |
|
| 422 | + update_post_meta($post_id, '_default_calendar_compact_list', $compact); |
|
| 423 | 423 | |
| 424 | 424 | // Limit number of initially visible daily events. |
| 425 | - $limit = isset( $_POST['_default_calendar_limit_visible_events'] ) ? 'yes' : 'no'; |
|
| 426 | - update_post_meta( $post_id, '_default_calendar_limit_visible_events', $limit ); |
|
| 427 | - $number = isset( $_POST['_default_calendar_visible_events'] ) ? absint( $_POST['_default_calendar_visible_events'] ) : 3; |
|
| 428 | - update_post_meta( $post_id, '_default_calendar_visible_events', $number ); |
|
| 425 | + $limit = isset($_POST['_default_calendar_limit_visible_events']) ? 'yes' : 'no'; |
|
| 426 | + update_post_meta($post_id, '_default_calendar_limit_visible_events', $limit); |
|
| 427 | + $number = isset($_POST['_default_calendar_visible_events']) ? absint($_POST['_default_calendar_visible_events']) : 3; |
|
| 428 | + update_post_meta($post_id, '_default_calendar_visible_events', $number); |
|
| 429 | 429 | |
| 430 | 430 | // Grid event bubbles action. |
| 431 | - $bubbles = isset( $_POST['_default_calendar_event_bubble_trigger'] ) ? esc_attr( $_POST['_default_calendar_event_bubble_trigger'] ) : 'hover'; |
|
| 432 | - update_post_meta( $post_id, '_default_calendar_event_bubble_trigger', $bubbles ); |
|
| 431 | + $bubbles = isset($_POST['_default_calendar_event_bubble_trigger']) ? esc_attr($_POST['_default_calendar_event_bubble_trigger']) : 'hover'; |
|
| 432 | + update_post_meta($post_id, '_default_calendar_event_bubble_trigger', $bubbles); |
|
| 433 | 433 | |
| 434 | 434 | // Trim event titles characters length. |
| 435 | - $trim = isset( $_POST['_default_calendar_trim_titles'] ) ? 'yes' : 'no'; |
|
| 436 | - update_post_meta( $post_id, '_default_calendar_trim_titles', $trim ); |
|
| 437 | - $chars = isset( $_POST['_default_calendar_trim_titles_chars'] ) ? max( absint( $_POST['_default_calendar_trim_titles_chars'] ), 1 ) : 20; |
|
| 438 | - update_post_meta( $post_id, '_default_calendar_trim_titles_chars', $chars ); |
|
| 435 | + $trim = isset($_POST['_default_calendar_trim_titles']) ? 'yes' : 'no'; |
|
| 436 | + update_post_meta($post_id, '_default_calendar_trim_titles', $trim); |
|
| 437 | + $chars = isset($_POST['_default_calendar_trim_titles_chars']) ? max(absint($_POST['_default_calendar_trim_titles_chars']), 1) : 20; |
|
| 438 | + update_post_meta($post_id, '_default_calendar_trim_titles_chars', $chars); |
|
| 439 | 439 | |
| 440 | 440 | // Expand multiple day events on each day. |
| 441 | - $multi_day = isset( $_POST['_default_calendar_expand_multi_day_events'] ) && ! empty( $_POST['_default_calendar_expand_multi_day_events'] ) ? sanitize_key( $_POST['_default_calendar_expand_multi_day_events'] ) : 'current_day_only'; |
|
| 442 | - update_post_meta( $post_id, '_default_calendar_expand_multi_day_events', $multi_day ); |
|
| 441 | + $multi_day = isset($_POST['_default_calendar_expand_multi_day_events']) && ! empty($_POST['_default_calendar_expand_multi_day_events']) ? sanitize_key($_POST['_default_calendar_expand_multi_day_events']) : 'current_day_only'; |
|
| 442 | + update_post_meta($post_id, '_default_calendar_expand_multi_day_events', $multi_day); |
|
| 443 | 443 | |
| 444 | 444 | } |
| 445 | 445 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | use Carbon\Carbon; |
| 10 | 10 | use SimpleCalendar\Abstracts\Calendar; |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param Event $event |
| 55 | 55 | * @param Calendar $calendar |
| 56 | 56 | */ |
| 57 | - public function __construct( Event $event, Calendar $calendar ) { |
|
| 57 | + public function __construct(Event $event, Calendar $calendar) { |
|
| 58 | 58 | $this->event = $event; |
| 59 | 59 | $this->calendar = $calendar; |
| 60 | 60 | $this->tags = $this->get_content_tags(); |
@@ -74,86 +74,86 @@ discard block |
||
| 74 | 74 | * Content Tags * |
| 75 | 75 | * ============ */ |
| 76 | 76 | |
| 77 | - 'title', // The event title. |
|
| 78 | - 'event-title', // @deprecated An alias for 'title' tag. |
|
| 79 | - 'description', // The event description. |
|
| 80 | - |
|
| 81 | - 'when', // Date and time of the event. |
|
| 82 | - 'start-time', // Start time of the event. |
|
| 83 | - 'start-date', // Start date of the event. |
|
| 84 | - 'start-custom', // @deprecated Start time in a user defined format (set by tag 'format' attribute). |
|
| 85 | - 'start-human', // Start time in a human friendly format. |
|
| 86 | - 'end-time', // End time of the event. |
|
| 87 | - 'end-date', // End date of the event. |
|
| 88 | - 'end-custom', // @deprecated End date-time in a user defined format (set by tag 'format' attribute). |
|
| 89 | - 'end-human', // End date-time in a human friendly format. |
|
| 90 | - |
|
| 91 | - 'duration', // How long the events lasts, in a human-readable format. |
|
| 92 | - 'length', // @deprecated An alias of 'duration' tag. |
|
| 93 | - |
|
| 94 | - 'location', // Alias of start-location. |
|
| 95 | - 'start-location', // Location name where the event starts. |
|
| 96 | - 'maps-link', // @deprecated An alias for 'start-location-link' tag. |
|
| 97 | - 'start-location-link', // Link to Google Maps querying the event start location address. |
|
| 98 | - 'end-location', // Location name where the event ends. |
|
| 99 | - 'end-location-link', // Link to Google Maps querying the event end location address. |
|
| 100 | - |
|
| 101 | - 'link', // An HTML link to the event URL. |
|
| 102 | - 'url', // A string with the raw event link URL. |
|
| 103 | - 'add-to-gcal-link', // Link for viewers to add to their GCals. |
|
| 104 | - |
|
| 105 | - 'calendar', // The title of the source calendar. |
|
| 106 | - 'feed-title', // @deprecated An alias of 'calendar'. |
|
| 107 | - |
|
| 108 | - 'id', // The event unique ID. |
|
| 109 | - 'uid', // An alias of ID. |
|
| 110 | - 'ical-id', // iCal ID. |
|
| 111 | - 'event-id', // @deprecated An alias for 'id' tag. |
|
| 112 | - 'calendar-id', // The calendar ID. |
|
| 113 | - 'feed-id', // @deprecated An alias for 'calendar-id' tag. |
|
| 114 | - 'cal-id', // @deprecated An alias for 'calendar-id' tag. |
|
| 77 | + 'title', // The event title. |
|
| 78 | + 'event-title', // @deprecated An alias for 'title' tag. |
|
| 79 | + 'description', // The event description. |
|
| 80 | + |
|
| 81 | + 'when', // Date and time of the event. |
|
| 82 | + 'start-time', // Start time of the event. |
|
| 83 | + 'start-date', // Start date of the event. |
|
| 84 | + 'start-custom', // @deprecated Start time in a user defined format (set by tag 'format' attribute). |
|
| 85 | + 'start-human', // Start time in a human friendly format. |
|
| 86 | + 'end-time', // End time of the event. |
|
| 87 | + 'end-date', // End date of the event. |
|
| 88 | + 'end-custom', // @deprecated End date-time in a user defined format (set by tag 'format' attribute). |
|
| 89 | + 'end-human', // End date-time in a human friendly format. |
|
| 90 | + |
|
| 91 | + 'duration', // How long the events lasts, in a human-readable format. |
|
| 92 | + 'length', // @deprecated An alias of 'duration' tag. |
|
| 93 | + |
|
| 94 | + 'location', // Alias of start-location. |
|
| 95 | + 'start-location', // Location name where the event starts. |
|
| 96 | + 'maps-link', // @deprecated An alias for 'start-location-link' tag. |
|
| 97 | + 'start-location-link', // Link to Google Maps querying the event start location address. |
|
| 98 | + 'end-location', // Location name where the event ends. |
|
| 99 | + 'end-location-link', // Link to Google Maps querying the event end location address. |
|
| 100 | + |
|
| 101 | + 'link', // An HTML link to the event URL. |
|
| 102 | + 'url', // A string with the raw event link URL. |
|
| 103 | + 'add-to-gcal-link', // Link for viewers to add to their GCals. |
|
| 104 | + |
|
| 105 | + 'calendar', // The title of the source calendar. |
|
| 106 | + 'feed-title', // @deprecated An alias of 'calendar'. |
|
| 107 | + |
|
| 108 | + 'id', // The event unique ID. |
|
| 109 | + 'uid', // An alias of ID. |
|
| 110 | + 'ical-id', // iCal ID. |
|
| 111 | + 'event-id', // @deprecated An alias for 'id' tag. |
|
| 112 | + 'calendar-id', // The calendar ID. |
|
| 113 | + 'feed-id', // @deprecated An alias for 'calendar-id' tag. |
|
| 114 | + 'cal-id', // @deprecated An alias for 'calendar-id' tag. |
|
| 115 | 115 | |
| 116 | 116 | /* ========= * |
| 117 | 117 | * Meta Tags * |
| 118 | 118 | * ========= */ |
| 119 | 119 | |
| 120 | - 'attachments', // List of attachments. |
|
| 121 | - 'attendees', // List of attendees. |
|
| 122 | - 'organizer', // Creator info. |
|
| 120 | + 'attachments', // List of attachments. |
|
| 121 | + 'attendees', // List of attendees. |
|
| 122 | + 'organizer', // Creator info. |
|
| 123 | 123 | |
| 124 | 124 | /* ================ * |
| 125 | 125 | * Conditional Tags * |
| 126 | 126 | * ================ */ |
| 127 | 127 | |
| 128 | - 'if-title', // If the event has a title. |
|
| 129 | - 'if-description', // If the event has a description. |
|
| 130 | - |
|
| 131 | - 'if-now', // If the event is taking place now. |
|
| 132 | - 'if-not-now', // If the event is not taking place now (may have ended or just not started yet). |
|
| 133 | - 'if-started', // If the event has started (and may as well as ended). |
|
| 134 | - 'if-not-started', // If the event has NOT started yet (event could be any time in the future). |
|
| 135 | - 'if-ended', // If the event has ended (event could be any time in the past). |
|
| 136 | - 'if-not-ended', // If the event has NOT ended (may as well as not started yet). |
|
| 137 | - |
|
| 138 | - 'if-whole-day', // If the event lasts the whole day. |
|
| 139 | - 'if-all-day', // @deprecated Alias for 'if-whole-day'. |
|
| 140 | - 'if-not-whole-day', // If the event does NOT last the whole day. |
|
| 141 | - 'if-not-all-day', // @deprecated Alias for 'if-not-whole-day'. |
|
| 142 | - 'if-end-time', // If the event has a set end time. |
|
| 143 | - 'if-no-end-time', // If the event has NOT a set end time. |
|
| 144 | - |
|
| 145 | - 'if-multi-day', // If the event spans multiple days. |
|
| 146 | - 'if-single-day', // If the event does not span multiple days. |
|
| 147 | - |
|
| 148 | - 'if-recurring', // If the event is a recurring event. |
|
| 149 | - 'if-not-recurring', // If the event is NOT a recurring event. |
|
| 150 | - |
|
| 151 | - 'if-location', // @deprecated Alias for 'if-start-location'. |
|
| 152 | - 'if-start-location', // Does the event has a start location? |
|
| 153 | - 'if-end-location', // Does the event has an end location? |
|
| 154 | - 'if-not-location', // @deprecated Alias for 'if-not-start-location'. |
|
| 128 | + 'if-title', // If the event has a title. |
|
| 129 | + 'if-description', // If the event has a description. |
|
| 130 | + |
|
| 131 | + 'if-now', // If the event is taking place now. |
|
| 132 | + 'if-not-now', // If the event is not taking place now (may have ended or just not started yet). |
|
| 133 | + 'if-started', // If the event has started (and may as well as ended). |
|
| 134 | + 'if-not-started', // If the event has NOT started yet (event could be any time in the future). |
|
| 135 | + 'if-ended', // If the event has ended (event could be any time in the past). |
|
| 136 | + 'if-not-ended', // If the event has NOT ended (may as well as not started yet). |
|
| 137 | + |
|
| 138 | + 'if-whole-day', // If the event lasts the whole day. |
|
| 139 | + 'if-all-day', // @deprecated Alias for 'if-whole-day'. |
|
| 140 | + 'if-not-whole-day', // If the event does NOT last the whole day. |
|
| 141 | + 'if-not-all-day', // @deprecated Alias for 'if-not-whole-day'. |
|
| 142 | + 'if-end-time', // If the event has a set end time. |
|
| 143 | + 'if-no-end-time', // If the event has NOT a set end time. |
|
| 144 | + |
|
| 145 | + 'if-multi-day', // If the event spans multiple days. |
|
| 146 | + 'if-single-day', // If the event does not span multiple days. |
|
| 147 | + |
|
| 148 | + 'if-recurring', // If the event is a recurring event. |
|
| 149 | + 'if-not-recurring', // If the event is NOT a recurring event. |
|
| 150 | + |
|
| 151 | + 'if-location', // @deprecated Alias for 'if-start-location'. |
|
| 152 | + 'if-start-location', // Does the event has a start location? |
|
| 153 | + 'if-end-location', // Does the event has an end location? |
|
| 154 | + 'if-not-location', // @deprecated Alias for 'if-not-start-location'. |
|
| 155 | 155 | 'if-not-start-location', // Does the event has NOT a start location? |
| 156 | - 'if-not-end-location', // Does the event has NOT an end location? |
|
| 156 | + 'if-not-end-location', // Does the event has NOT an end location? |
|
| 157 | 157 | |
| 158 | 158 | ); |
| 159 | 159 | } |
@@ -167,19 +167,19 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @return string |
| 169 | 169 | */ |
| 170 | - public function parse_event_template_tags( $template_tags = '' ) { |
|
| 170 | + public function parse_event_template_tags($template_tags = '') { |
|
| 171 | 171 | |
| 172 | 172 | // Process tags. |
| 173 | 173 | $result = preg_replace_callback( |
| 174 | 174 | $this->get_regex(), |
| 175 | - array( $this, 'process_event_content' ), |
|
| 175 | + array($this, 'process_event_content'), |
|
| 176 | 176 | $template_tags |
| 177 | 177 | ); |
| 178 | 178 | |
| 179 | 179 | // Removes extra consecutive <br> tags. |
| 180 | 180 | // TODO: Doesn't seem to work but going to remove it to allow multiple <br> tags in the editor |
| 181 | 181 | /*return preg_replace( '#(<br *//*?>\s*)+#i', '<br />', trim( $result ) );*/ |
| 182 | - return do_shortcode( trim( $result ) ); |
|
| 182 | + return do_shortcode(trim($result)); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @return string |
| 193 | 193 | */ |
| 194 | - public function process_event_content( $match ) { |
|
| 194 | + public function process_event_content($match) { |
|
| 195 | 195 | |
| 196 | - if ( $match[1] == '[' && $match[6] == ']' ) { |
|
| 197 | - return substr( $match[0], 1, - 1 ); |
|
| 196 | + if ($match[1] == '[' && $match[6] == ']') { |
|
| 197 | + return substr($match[0], 1, - 1); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | $tag = $match[2]; // Tag name without square brackets. |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | $calendar = $this->calendar; |
| 207 | 207 | $event = $this->event; |
| 208 | 208 | |
| 209 | - if ( ( $calendar instanceof Calendar ) && ( $event instanceof Event ) ) { |
|
| 209 | + if (($calendar instanceof Calendar) && ($event instanceof Event)) { |
|
| 210 | 210 | |
| 211 | - switch ( $tag ) { |
|
| 211 | + switch ($tag) { |
|
| 212 | 212 | |
| 213 | 213 | /* ============ * |
| 214 | 214 | * Content Tags * |
@@ -216,13 +216,13 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | case 'title' : |
| 218 | 218 | case 'event-title' : |
| 219 | - return $this->get_title( $event->title, $attr ); |
|
| 219 | + return $this->get_title($event->title, $attr); |
|
| 220 | 220 | |
| 221 | 221 | case 'description' : |
| 222 | - return $this->get_description( $event->description, $attr ); |
|
| 222 | + return $this->get_description($event->description, $attr); |
|
| 223 | 223 | |
| 224 | 224 | case 'when' : |
| 225 | - return $this->get_when( $event ); |
|
| 225 | + return $this->get_when($event); |
|
| 226 | 226 | |
| 227 | 227 | case 'end-date' : |
| 228 | 228 | case 'end-custom' : |
@@ -232,59 +232,59 @@ discard block |
||
| 232 | 232 | case 'start-date' : |
| 233 | 233 | case 'start-human' : |
| 234 | 234 | case 'start-time' : |
| 235 | - return $this->get_dt( $tag, $event, $attr ); |
|
| 235 | + return $this->get_dt($tag, $event, $attr); |
|
| 236 | 236 | |
| 237 | 237 | case 'length' : |
| 238 | 238 | case 'duration' : |
| 239 | - if ( false !== $event->end ) { |
|
| 239 | + if (false !== $event->end) { |
|
| 240 | 240 | $duration = $event->start - $event->end; |
| 241 | - $value = human_time_diff( $event->start, $event->end ); |
|
| 241 | + $value = human_time_diff($event->start, $event->end); |
|
| 242 | 242 | } else { |
| 243 | 243 | $duration = '-1'; |
| 244 | - $value = __( 'No end time', 'google-calendar-events' ); |
|
| 244 | + $value = __('No end time', 'google-calendar-events'); |
|
| 245 | 245 | } |
| 246 | - return ' <span class="simcal-event-duration" data-event-duration="' . $duration . '">' . $value . '</span>'; |
|
| 246 | + return ' <span class="simcal-event-duration" data-event-duration="'.$duration.'">'.$value.'</span>'; |
|
| 247 | 247 | |
| 248 | 248 | case 'location' : |
| 249 | 249 | case 'start-location' : |
| 250 | 250 | case 'end-location' : |
| 251 | - $location = ( 'end-location' == $tag ) ? $event->end_location['address'] : $event->start_location['address']; |
|
| 252 | - $location_class = ( 'end-location' == $tag ) ? 'end' : 'start'; |
|
| 251 | + $location = ('end-location' == $tag) ? $event->end_location['address'] : $event->start_location['address']; |
|
| 252 | + $location_class = ('end-location' == $tag) ? 'end' : 'start'; |
|
| 253 | 253 | |
| 254 | 254 | // location, location.name, location.address (type PostalAddress) all required for schema data. |
| 255 | 255 | // Need to use event name where location data doesn't exist. |
| 256 | 256 | // Since we have 1 location field, use it as the name and address. |
| 257 | 257 | // If the location is blank, use the event title as the name and address. |
| 258 | 258 | // Wrap with wp_strip_all_tags(). |
| 259 | - $meta_location_name_and_address = empty( $location ) ? wp_strip_all_tags( $event->title ) : wp_strip_all_tags( $location ); |
|
| 259 | + $meta_location_name_and_address = empty($location) ? wp_strip_all_tags($event->title) : wp_strip_all_tags($location); |
|
| 260 | 260 | |
| 261 | - return ' <span class="simcal-event-address simcal-event-' . $location_class . '-location" itemprop="location" itemscope itemtype="http://schema.org/Place">' . |
|
| 262 | - '<meta itemprop="name" content="' . $meta_location_name_and_address . '" />' . |
|
| 263 | - '<meta itemprop="address" content="' . $meta_location_name_and_address . '" />' . |
|
| 264 | - wp_strip_all_tags( $location ) . |
|
| 261 | + return ' <span class="simcal-event-address simcal-event-'.$location_class.'-location" itemprop="location" itemscope itemtype="http://schema.org/Place">'. |
|
| 262 | + '<meta itemprop="name" content="'.$meta_location_name_and_address.'" />'. |
|
| 263 | + '<meta itemprop="address" content="'.$meta_location_name_and_address.'" />'. |
|
| 264 | + wp_strip_all_tags($location). |
|
| 265 | 265 | '</span>'; |
| 266 | 266 | |
| 267 | 267 | case 'start-location-link': |
| 268 | 268 | case 'end-location-link' : |
| 269 | 269 | case 'maps-link' : |
| 270 | - $location = ( 'end-location-link' == $tag ) ? $event->end_location['address'] : $event->start_location['address']; |
|
| 271 | - if ( ! empty( $location ) ) { |
|
| 272 | - $url = '//maps.google.com?q=' . urlencode( $location ); |
|
| 273 | - return $this->make_link( $tag, $url, $calendar->get_event_html( $event, $partial ), $attr ); |
|
| 270 | + $location = ('end-location-link' == $tag) ? $event->end_location['address'] : $event->start_location['address']; |
|
| 271 | + if ( ! empty($location)) { |
|
| 272 | + $url = '//maps.google.com?q='.urlencode($location); |
|
| 273 | + return $this->make_link($tag, $url, $calendar->get_event_html($event, $partial), $attr); |
|
| 274 | 274 | } |
| 275 | 275 | break; |
| 276 | 276 | |
| 277 | 277 | case 'link' : |
| 278 | 278 | case 'url' : |
| 279 | - $content = ( 'link' == $tag ) ? $calendar->get_event_html( $event, $partial ) : ''; |
|
| 280 | - return $this->make_link( $tag, $event->link, $content , $attr ); |
|
| 279 | + $content = ('link' == $tag) ? $calendar->get_event_html($event, $partial) : ''; |
|
| 280 | + return $this->make_link($tag, $event->link, $content, $attr); |
|
| 281 | 281 | |
| 282 | 282 | case 'add-to-gcal-link'; |
| 283 | - $content = ( 'add-to-gcal-link' == $tag ) ? $calendar->get_event_html( $event, $partial ) : ''; |
|
| 284 | - if ( ! empty( $content ) ) { |
|
| 285 | - $url = $calendar->get_add_to_gcal_url( $event ); |
|
| 283 | + $content = ('add-to-gcal-link' == $tag) ? $calendar->get_event_html($event, $partial) : ''; |
|
| 284 | + if ( ! empty($content)) { |
|
| 285 | + $url = $calendar->get_add_to_gcal_url($event); |
|
| 286 | 286 | |
| 287 | - return $this->make_link( $tag, $url, $content, $attr ); |
|
| 287 | + return $this->make_link($tag, $url, $content, $attr); |
|
| 288 | 288 | } |
| 289 | 289 | break; |
| 290 | 290 | |
@@ -311,22 +311,22 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | case 'attachments' : |
| 313 | 313 | $attachments = $event->get_attachments(); |
| 314 | - if ( ! empty( $attachments ) ) { |
|
| 315 | - return $this->get_attachments( $attachments ); |
|
| 314 | + if ( ! empty($attachments)) { |
|
| 315 | + return $this->get_attachments($attachments); |
|
| 316 | 316 | } |
| 317 | 317 | break; |
| 318 | 318 | |
| 319 | 319 | case 'attendees' : |
| 320 | 320 | $attendees = $event->get_attendees(); |
| 321 | - if ( ! empty( $attendees ) ) { |
|
| 322 | - return $this->get_attendees( $attendees, $attr ); |
|
| 321 | + if ( ! empty($attendees)) { |
|
| 322 | + return $this->get_attendees($attendees, $attr); |
|
| 323 | 323 | } |
| 324 | 324 | break; |
| 325 | 325 | |
| 326 | 326 | case 'organizer' : |
| 327 | 327 | $organizer = $event->get_organizer(); |
| 328 | - if ( ! empty( $organizer ) ) { |
|
| 329 | - return $this->get_organizer( $organizer, $attr ); |
|
| 328 | + if ( ! empty($organizer)) { |
|
| 329 | + return $this->get_organizer($organizer, $attr); |
|
| 330 | 330 | } |
| 331 | 331 | break; |
| 332 | 332 | |
@@ -335,35 +335,35 @@ discard block |
||
| 335 | 335 | * ================ */ |
| 336 | 336 | |
| 337 | 337 | case 'if-title': |
| 338 | - if ( ! empty( $event->title ) ) { |
|
| 339 | - return $calendar->get_event_html( $event, $partial ); |
|
| 338 | + if ( ! empty($event->title)) { |
|
| 339 | + return $calendar->get_event_html($event, $partial); |
|
| 340 | 340 | } |
| 341 | 341 | break; |
| 342 | 342 | |
| 343 | 343 | case 'if-description': |
| 344 | - if ( ! empty( $event->description ) ) { |
|
| 345 | - return $calendar->get_event_html( $event, $partial ); |
|
| 344 | + if ( ! empty($event->description)) { |
|
| 345 | + return $calendar->get_event_html($event, $partial); |
|
| 346 | 346 | } |
| 347 | 347 | break; |
| 348 | 348 | |
| 349 | 349 | case 'if-now' : |
| 350 | 350 | case 'if-not-now' : |
| 351 | 351 | |
| 352 | - $start_dt = $event->start_dt->setTimezone( $calendar->timezone ); |
|
| 352 | + $start_dt = $event->start_dt->setTimezone($calendar->timezone); |
|
| 353 | 353 | $start = $start_dt->getTimestamp(); |
| 354 | 354 | |
| 355 | - if ( $event->end_dt instanceof Carbon ) { |
|
| 356 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
| 355 | + if ($event->end_dt instanceof Carbon) { |
|
| 356 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
| 357 | 357 | } else { |
| 358 | 358 | return ''; |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - $now = ( $start <= $calendar->now ) && ( $end >= $calendar->now ); |
|
| 361 | + $now = ($start <= $calendar->now) && ($end >= $calendar->now); |
|
| 362 | 362 | |
| 363 | - if ( ( 'if-now' == $tag ) && $now ) { |
|
| 364 | - return $calendar->get_event_html( $event, $partial ); |
|
| 365 | - } elseif ( ( 'if-not-now' == $tag ) && ( false == $now ) ) { |
|
| 366 | - return $calendar->get_event_html( $event, $partial ); |
|
| 363 | + if (('if-now' == $tag) && $now) { |
|
| 364 | + return $calendar->get_event_html($event, $partial); |
|
| 365 | + } elseif (('if-not-now' == $tag) && (false == $now)) { |
|
| 366 | + return $calendar->get_event_html($event, $partial); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | break; |
@@ -371,15 +371,15 @@ discard block |
||
| 371 | 371 | case 'if-started' : |
| 372 | 372 | case 'if-not-started' : |
| 373 | 373 | |
| 374 | - $start = $event->start_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
| 374 | + $start = $event->start_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
| 375 | 375 | |
| 376 | - if ( 'if-started' == $tag ) { |
|
| 377 | - if ( $start < $calendar->now ) { |
|
| 378 | - return $calendar->get_event_html( $event, $partial ); |
|
| 376 | + if ('if-started' == $tag) { |
|
| 377 | + if ($start < $calendar->now) { |
|
| 378 | + return $calendar->get_event_html($event, $partial); |
|
| 379 | 379 | } |
| 380 | - } elseif ( 'if-not-started' == $tag ) { |
|
| 381 | - if ( $start > $calendar->now ) { |
|
| 382 | - return $calendar->get_event_html( $event, $partial ); |
|
| 380 | + } elseif ('if-not-started' == $tag) { |
|
| 381 | + if ($start > $calendar->now) { |
|
| 382 | + return $calendar->get_event_html($event, $partial); |
|
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | 385 | |
@@ -388,17 +388,17 @@ discard block |
||
| 388 | 388 | case 'if-ended' : |
| 389 | 389 | case 'if-not-ended' : |
| 390 | 390 | |
| 391 | - if ( false !== $event->end ) { |
|
| 391 | + if (false !== $event->end) { |
|
| 392 | 392 | |
| 393 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
| 393 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
| 394 | 394 | |
| 395 | - if ( 'if-ended' == $tag ) { |
|
| 396 | - if ( $end < $calendar->now ) { |
|
| 397 | - return $calendar->get_event_html( $event, $partial ); |
|
| 395 | + if ('if-ended' == $tag) { |
|
| 396 | + if ($end < $calendar->now) { |
|
| 397 | + return $calendar->get_event_html($event, $partial); |
|
| 398 | 398 | } |
| 399 | - } elseif ( 'if-not-ended' == $tag ) { |
|
| 400 | - if ( $end > $calendar->now ) { |
|
| 401 | - return $calendar->get_event_html( $event, $partial ); |
|
| 399 | + } elseif ('if-not-ended' == $tag) { |
|
| 400 | + if ($end > $calendar->now) { |
|
| 401 | + return $calendar->get_event_html($event, $partial); |
|
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | |
@@ -407,14 +407,14 @@ discard block |
||
| 407 | 407 | break; |
| 408 | 408 | |
| 409 | 409 | case 'if-end-time' : |
| 410 | - if ( false !== $event->end ) { |
|
| 411 | - return $calendar->get_event_html( $event, $partial ); |
|
| 410 | + if (false !== $event->end) { |
|
| 411 | + return $calendar->get_event_html($event, $partial); |
|
| 412 | 412 | } |
| 413 | 413 | break; |
| 414 | 414 | |
| 415 | 415 | case 'if-no-end-time' : |
| 416 | - if ( false === $event->end ) { |
|
| 417 | - return $calendar->get_event_html( $event, $partial ); |
|
| 416 | + if (false === $event->end) { |
|
| 417 | + return $calendar->get_event_html($event, $partial); |
|
| 418 | 418 | } |
| 419 | 419 | break; |
| 420 | 420 | |
@@ -422,59 +422,59 @@ discard block |
||
| 422 | 422 | case 'if-whole-day' : |
| 423 | 423 | case 'if-not-all-day' : |
| 424 | 424 | case 'if-not-whole-day' : |
| 425 | - $bool = strstr( $tag, 'not' ) ? false : true; |
|
| 426 | - if ( $bool === $event->whole_day ) { |
|
| 427 | - return $calendar->get_event_html( $event, $partial ); |
|
| 425 | + $bool = strstr($tag, 'not') ? false : true; |
|
| 426 | + if ($bool === $event->whole_day) { |
|
| 427 | + return $calendar->get_event_html($event, $partial); |
|
| 428 | 428 | } |
| 429 | 429 | break; |
| 430 | 430 | |
| 431 | 431 | case 'if-recurring' : |
| 432 | - if ( ! empty( $event->recurrence ) ) { |
|
| 433 | - return $calendar->get_event_html( $event, $partial ); |
|
| 432 | + if ( ! empty($event->recurrence)) { |
|
| 433 | + return $calendar->get_event_html($event, $partial); |
|
| 434 | 434 | } |
| 435 | 435 | break; |
| 436 | 436 | |
| 437 | 437 | case 'if-not-recurring' : |
| 438 | - if ( false === $event->recurrence ) { |
|
| 439 | - return $calendar->get_event_html( $event, $partial ); |
|
| 438 | + if (false === $event->recurrence) { |
|
| 439 | + return $calendar->get_event_html($event, $partial); |
|
| 440 | 440 | } |
| 441 | 441 | break; |
| 442 | 442 | |
| 443 | 443 | case 'if-multi-day' : |
| 444 | - if ( false !== $event->multiple_days ) { |
|
| 445 | - return $calendar->get_event_html( $event, $partial ); |
|
| 444 | + if (false !== $event->multiple_days) { |
|
| 445 | + return $calendar->get_event_html($event, $partial); |
|
| 446 | 446 | } |
| 447 | 447 | break; |
| 448 | 448 | |
| 449 | 449 | case 'if-single-day' : |
| 450 | - if ( false === $event->multiple_days ) { |
|
| 451 | - return $calendar->get_event_html( $event, $partial ); |
|
| 450 | + if (false === $event->multiple_days) { |
|
| 451 | + return $calendar->get_event_html($event, $partial); |
|
| 452 | 452 | } |
| 453 | 453 | break; |
| 454 | 454 | |
| 455 | 455 | case 'if-location' : |
| 456 | 456 | case 'if-start-location' : |
| 457 | - if ( ! empty( $event->start_location['address'] ) ) { |
|
| 458 | - return $calendar->get_event_html( $event, $partial ); |
|
| 457 | + if ( ! empty($event->start_location['address'])) { |
|
| 458 | + return $calendar->get_event_html($event, $partial); |
|
| 459 | 459 | } |
| 460 | 460 | return false; |
| 461 | 461 | |
| 462 | 462 | case 'if-not-location' : |
| 463 | 463 | case 'if-not-start-location' : |
| 464 | - if ( empty( $event->start_location['address'] ) ) { |
|
| 465 | - return $calendar->get_event_html( $event, $partial ); |
|
| 464 | + if (empty($event->start_location['address'])) { |
|
| 465 | + return $calendar->get_event_html($event, $partial); |
|
| 466 | 466 | } |
| 467 | 467 | return ''; |
| 468 | 468 | |
| 469 | 469 | case 'if-not-end-location' : |
| 470 | - if ( empty( $event->end_location['address'] ) ) { |
|
| 471 | - return $calendar->get_event_html( $event, $partial ); |
|
| 470 | + if (empty($event->end_location['address'])) { |
|
| 471 | + return $calendar->get_event_html($event, $partial); |
|
| 472 | 472 | } |
| 473 | 473 | return ''; |
| 474 | 474 | |
| 475 | 475 | case 'if-end-location' : |
| 476 | - if ( ! empty( $event->end_location['address'] ) ) { |
|
| 477 | - return $calendar->get_event_html( $event, $partial ); |
|
| 476 | + if ( ! empty($event->end_location['address'])) { |
|
| 477 | + return $calendar->get_event_html($event, $partial); |
|
| 478 | 478 | } |
| 479 | 479 | return ''; |
| 480 | 480 | |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | * ======= */ |
| 484 | 484 | |
| 485 | 485 | default : |
| 486 | - return wp_kses_post( $before . $partial . $after ); |
|
| 486 | + return wp_kses_post($before.$partial.$after); |
|
| 487 | 487 | } |
| 488 | 488 | } |
| 489 | 489 | |
@@ -501,14 +501,14 @@ discard block |
||
| 501 | 501 | * |
| 502 | 502 | * @return string |
| 503 | 503 | */ |
| 504 | - private function limit_words( $text, $limit ) { |
|
| 504 | + private function limit_words($text, $limit) { |
|
| 505 | 505 | |
| 506 | - $limit = max( absint( $limit ), 0 ); |
|
| 506 | + $limit = max(absint($limit), 0); |
|
| 507 | 507 | |
| 508 | - if ( $limit > 0 && ( str_word_count( $text, 0 ) > $limit ) ) { |
|
| 509 | - $words = str_word_count( $text, 2 ); |
|
| 510 | - $pos = array_keys( $words ); |
|
| 511 | - $text = trim( substr( $text, 0, $pos[ $limit ] ) ) . '…'; |
|
| 508 | + if ($limit > 0 && (str_word_count($text, 0) > $limit)) { |
|
| 509 | + $words = str_word_count($text, 2); |
|
| 510 | + $pos = array_keys($words); |
|
| 511 | + $text = trim(substr($text, 0, $pos[$limit])).'…'; |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | return $text; |
@@ -525,26 +525,26 @@ discard block |
||
| 525 | 525 | * |
| 526 | 526 | * @return string |
| 527 | 527 | */ |
| 528 | - private function get_title( $title, $attr ) { |
|
| 528 | + private function get_title($title, $attr) { |
|
| 529 | 529 | |
| 530 | - if ( empty( $title ) ) { |
|
| 530 | + if (empty($title)) { |
|
| 531 | 531 | return ''; |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - $attr = array_merge( array( |
|
| 535 | - 'html' => '', // Parse HTML |
|
| 536 | - 'limit' => 0, // Trim length to amount of words |
|
| 537 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 534 | + $attr = array_merge(array( |
|
| 535 | + 'html' => '', // Parse HTML |
|
| 536 | + 'limit' => 0, // Trim length to amount of words |
|
| 537 | + ), (array) shortcode_parse_atts($attr)); |
|
| 538 | 538 | |
| 539 | - if ( ! empty( $attr['html'] ) ) { |
|
| 540 | - $title = wp_kses_post( $title ); |
|
| 539 | + if ( ! empty($attr['html'])) { |
|
| 540 | + $title = wp_kses_post($title); |
|
| 541 | 541 | $tag = 'div'; |
| 542 | 542 | } else { |
| 543 | - $title = $this->limit_words( $title, $attr['limit'] ); |
|
| 543 | + $title = $this->limit_words($title, $attr['limit']); |
|
| 544 | 544 | $tag = 'span'; |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - return '<' . $tag . ' class="simcal-event-title" itemprop="name">' . $title . '</' . $tag . '>'; |
|
| 547 | + return '<'.$tag.' class="simcal-event-title" itemprop="name">'.$title.'</'.$tag.'>'; |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | /** |
@@ -558,42 +558,42 @@ discard block |
||
| 558 | 558 | * |
| 559 | 559 | * @return string |
| 560 | 560 | */ |
| 561 | - private function get_description( $description, $attr ) { |
|
| 561 | + private function get_description($description, $attr) { |
|
| 562 | 562 | |
| 563 | - if ( empty( $description ) ) { |
|
| 563 | + if (empty($description)) { |
|
| 564 | 564 | return ''; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - $attr = array_merge( array( |
|
| 568 | - 'limit' => 0, // Trim length to number of words |
|
| 569 | - 'html' => 'no', // Parse HTML content |
|
| 570 | - 'markdown' => 'no', // Parse Markdown content |
|
| 571 | - 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
| 572 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 567 | + $attr = array_merge(array( |
|
| 568 | + 'limit' => 0, // Trim length to number of words |
|
| 569 | + 'html' => 'no', // Parse HTML content |
|
| 570 | + 'markdown' => 'no', // Parse Markdown content |
|
| 571 | + 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
| 572 | + ), (array) shortcode_parse_atts($attr)); |
|
| 573 | 573 | |
| 574 | - $allow_html = 'no' != $attr['html'] ? true : false; |
|
| 574 | + $allow_html = 'no' != $attr['html'] ? true : false; |
|
| 575 | 575 | $allow_md = 'no' != $attr['markdown'] ? true : false; |
| 576 | 576 | |
| 577 | 577 | $html = '<div class="simcal-event-description" itemprop="description">'; |
| 578 | 578 | |
| 579 | 579 | // Markdown and HTML don't play well together, use one or the other in the same tag. |
| 580 | - if ( $allow_html || $allow_md ) { |
|
| 581 | - if ( $allow_html ) { |
|
| 582 | - $description = wp_kses_post( $description ); |
|
| 583 | - } elseif ( $allow_md ) { |
|
| 580 | + if ($allow_html || $allow_md) { |
|
| 581 | + if ($allow_html) { |
|
| 582 | + $description = wp_kses_post($description); |
|
| 583 | + } elseif ($allow_md) { |
|
| 584 | 584 | $markdown = new \Parsedown(); |
| 585 | - $description = $markdown->text( wp_strip_all_tags( $description ) ); |
|
| 585 | + $description = $markdown->text(wp_strip_all_tags($description)); |
|
| 586 | 586 | } |
| 587 | 587 | } else { |
| 588 | - $description = wpautop( $description ); |
|
| 588 | + $description = wpautop($description); |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - $description = $this->limit_words( $description, $attr['limit'] ); |
|
| 591 | + $description = $this->limit_words($description, $attr['limit']); |
|
| 592 | 592 | |
| 593 | - $html .= $description . '</div>'; |
|
| 593 | + $html .= $description.'</div>'; |
|
| 594 | 594 | |
| 595 | - if ( 'no' != $attr['autolink'] ) { |
|
| 596 | - $html = ' ' . make_clickable( $html ); |
|
| 595 | + if ('no' != $attr['autolink']) { |
|
| 596 | + $html = ' '.make_clickable($html); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | return $html; |
@@ -609,76 +609,76 @@ discard block |
||
| 609 | 609 | * |
| 610 | 610 | * @return string |
| 611 | 611 | */ |
| 612 | - private function get_when( Event $event ) { |
|
| 612 | + private function get_when(Event $event) { |
|
| 613 | 613 | |
| 614 | - $start = $event->start_dt->setTimezone( $event->timezone ); |
|
| 615 | - $end = ! is_null( $event->end_dt ) ? $event->end_dt->setTimezone( $event->timezone ) : null; |
|
| 614 | + $start = $event->start_dt->setTimezone($event->timezone); |
|
| 615 | + $end = ! is_null($event->end_dt) ? $event->end_dt->setTimezone($event->timezone) : null; |
|
| 616 | 616 | |
| 617 | 617 | $time_start = ''; |
| 618 | 618 | $time_end = ''; |
| 619 | 619 | |
| 620 | - if ( ! $event->whole_day ) { |
|
| 620 | + if ( ! $event->whole_day) { |
|
| 621 | 621 | |
| 622 | - $time_start = $this->calendar->datetime_separator . |
|
| 623 | - ' <span class="simcal-event-start simcal-event-start-time" ' . |
|
| 624 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
| 625 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
| 626 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
| 627 | - date_i18n( $this->calendar->time_format, $start->getTimestamp() ) . |
|
| 622 | + $time_start = $this->calendar->datetime_separator. |
|
| 623 | + ' <span class="simcal-event-start simcal-event-start-time" '. |
|
| 624 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
| 625 | + 'data-event-format="'.$this->calendar->time_format.'" '. |
|
| 626 | + 'itemprop="startDate" content="'.$start->toIso8601String().'">'. |
|
| 627 | + date_i18n($this->calendar->time_format, $start->getTimestamp()). |
|
| 628 | 628 | '</span> '; |
| 629 | 629 | |
| 630 | - if ( $end instanceof Carbon ) { |
|
| 630 | + if ($end instanceof Carbon) { |
|
| 631 | 631 | |
| 632 | - $time_end = ' <span class="simcal-event-end simcal-event-end-time" ' . |
|
| 633 | - 'data-event-end="' . $end->getTimestamp() . '" ' . |
|
| 634 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
| 635 | - 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
| 636 | - date_i18n( $this->calendar->time_format, $end->getTimestamp() ) . |
|
| 632 | + $time_end = ' <span class="simcal-event-end simcal-event-end-time" '. |
|
| 633 | + 'data-event-end="'.$end->getTimestamp().'" '. |
|
| 634 | + 'data-event-format="'.$this->calendar->time_format.'" '. |
|
| 635 | + 'itemprop="endDate" content="'.$end->toIso8601String().'">'. |
|
| 636 | + date_i18n($this->calendar->time_format, $end->getTimestamp()). |
|
| 637 | 637 | '</span> '; |
| 638 | 638 | |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | - if ( $event->multiple_days ) { |
|
| 643 | + if ($event->multiple_days) { |
|
| 644 | 644 | |
| 645 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
|
| 646 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
| 647 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
| 648 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
| 649 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
| 650 | - '</span> ' . |
|
| 645 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '. |
|
| 646 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
| 647 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
| 648 | + 'itemprop="startDate" content="'.$start->toIso8601String().'">'. |
|
| 649 | + date_i18n($this->calendar->date_format, $start->getTimestamp()). |
|
| 650 | + '</span> '. |
|
| 651 | 651 | $time_start; |
| 652 | 652 | |
| 653 | - if ( $end instanceof Carbon ) { |
|
| 653 | + if ($end instanceof Carbon) { |
|
| 654 | 654 | |
| 655 | - $output .= '-' . |
|
| 656 | - ' <span class="simcal-event-start simcal-event-end-date" ' . |
|
| 657 | - 'data-event-start="' . $end->getTimestamp() . '" ' . |
|
| 658 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
| 659 | - 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
| 660 | - date_i18n( $this->calendar->date_format, $end->getTimestamp() ) . |
|
| 661 | - '</span> ' . |
|
| 655 | + $output .= '-'. |
|
| 656 | + ' <span class="simcal-event-start simcal-event-end-date" '. |
|
| 657 | + 'data-event-start="'.$end->getTimestamp().'" '. |
|
| 658 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
| 659 | + 'itemprop="endDate" content="'.$end->toIso8601String().'">'. |
|
| 660 | + date_i18n($this->calendar->date_format, $end->getTimestamp()). |
|
| 661 | + '</span> '. |
|
| 662 | 662 | $time_end; |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | } else { |
| 666 | 666 | |
| 667 | - $time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : ''; |
|
| 667 | + $time_end = ! empty($time_start) && ! empty($time_end) ? ' - '.$time_end : ''; |
|
| 668 | 668 | |
| 669 | 669 | // All-day events also need startDate for schema data. |
| 670 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
|
| 671 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
| 672 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
| 673 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
| 674 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
| 675 | - '</span> ' . |
|
| 676 | - $time_start . |
|
| 670 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '. |
|
| 671 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
| 672 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
| 673 | + 'itemprop="startDate" content="'.$start->toIso8601String().'">'. |
|
| 674 | + date_i18n($this->calendar->date_format, $start->getTimestamp()). |
|
| 675 | + '</span> '. |
|
| 676 | + $time_start. |
|
| 677 | 677 | $time_end; |
| 678 | 678 | |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | - return trim( $output ); |
|
| 681 | + return trim($output); |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | /** |
@@ -693,50 +693,50 @@ discard block |
||
| 693 | 693 | * |
| 694 | 694 | * @return string |
| 695 | 695 | */ |
| 696 | - private function get_dt( $tag, Event $event, $attr ) { |
|
| 696 | + private function get_dt($tag, Event $event, $attr) { |
|
| 697 | 697 | |
| 698 | - $bound = 0 === strpos( $tag, 'end' ) ? 'end' : 'start'; |
|
| 699 | - if ( ( 'end' == $bound ) && ( false === $event->end ) ) { |
|
| 698 | + $bound = 0 === strpos($tag, 'end') ? 'end' : 'start'; |
|
| 699 | + if (('end' == $bound) && (false === $event->end)) { |
|
| 700 | 700 | return ''; |
| 701 | 701 | } |
| 702 | 702 | |
| 703 | - $dt = $bound . '_dt'; |
|
| 704 | - if ( ! $event->$dt instanceof Carbon ) { |
|
| 703 | + $dt = $bound.'_dt'; |
|
| 704 | + if ( ! $event->$dt instanceof Carbon) { |
|
| 705 | 705 | return ''; |
| 706 | 706 | } |
| 707 | - $event_dt = $event->$dt->setTimezone( $event->timezone ); |
|
| 707 | + $event_dt = $event->$dt->setTimezone($event->timezone); |
|
| 708 | 708 | |
| 709 | - $attr = array_merge( array( |
|
| 709 | + $attr = array_merge(array( |
|
| 710 | 710 | 'format' => '', |
| 711 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 711 | + ), (array) shortcode_parse_atts($attr)); |
|
| 712 | 712 | |
| 713 | - $format = ltrim( strstr( $tag, '-' ), '-' ); |
|
| 713 | + $format = ltrim(strstr($tag, '-'), '-'); |
|
| 714 | 714 | $dt_format = ''; |
| 715 | - if ( ! empty( $attr['format'] ) ) { |
|
| 716 | - $dt_format = esc_attr( wp_strip_all_tags( $attr['format'] ) ); |
|
| 717 | - } elseif ( 'date' == $format ) { |
|
| 715 | + if ( ! empty($attr['format'])) { |
|
| 716 | + $dt_format = esc_attr(wp_strip_all_tags($attr['format'])); |
|
| 717 | + } elseif ('date' == $format) { |
|
| 718 | 718 | $dt_format = $this->calendar->date_format; |
| 719 | - } elseif ( 'time' == $format ) { |
|
| 719 | + } elseif ('time' == $format) { |
|
| 720 | 720 | $dt_format = $this->calendar->time_format; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - if ( 'human' == $format ) { |
|
| 724 | - $value = human_time_diff( $event_dt->getTimestamp(), Carbon::now( $event->timezone )->getTimestamp() ); |
|
| 723 | + if ('human' == $format) { |
|
| 724 | + $value = human_time_diff($event_dt->getTimestamp(), Carbon::now($event->timezone)->getTimestamp()); |
|
| 725 | 725 | |
| 726 | - if ( $event_dt->getTimestamp() < Carbon::now( $event->timezone )->getTimestamp() ) { |
|
| 727 | - $value .= ' ' . _x( 'ago', 'human date event builder code modifier', 'google-calendar-events' ); |
|
| 726 | + if ($event_dt->getTimestamp() < Carbon::now($event->timezone)->getTimestamp()) { |
|
| 727 | + $value .= ' '._x('ago', 'human date event builder code modifier', 'google-calendar-events'); |
|
| 728 | 728 | } else { |
| 729 | - $value .= ' ' . _x( 'from now', 'human date event builder code modifier', 'google-calendar-events' ); |
|
| 729 | + $value .= ' '._x('from now', 'human date event builder code modifier', 'google-calendar-events'); |
|
| 730 | 730 | } |
| 731 | 731 | } else { |
| 732 | - $value = date_i18n( $dt_format, $event_dt->getTimestamp() ); |
|
| 732 | + $value = date_i18n($dt_format, $event_dt->getTimestamp()); |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | - return '<span class="simcal-event-' . $bound . ' ' . 'simcal-event-' . $bound . '-' . $format . '" ' . |
|
| 736 | - 'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '" ' . |
|
| 737 | - 'data-event-format="' . $dt_format . '" ' . |
|
| 738 | - 'itemprop="' . $bound . 'Date" content="' . $event_dt->toIso8601String() . '">' . |
|
| 739 | - $value . |
|
| 735 | + return '<span class="simcal-event-'.$bound.' '.'simcal-event-'.$bound.'-'.$format.'" '. |
|
| 736 | + 'data-event-'.$bound.'="'.$event_dt->getTimestamp().'" '. |
|
| 737 | + 'data-event-format="'.$dt_format.'" '. |
|
| 738 | + 'itemprop="'.$bound.'Date" content="'.$event_dt->toIso8601String().'">'. |
|
| 739 | + $value. |
|
| 740 | 740 | '</span>'; |
| 741 | 741 | } |
| 742 | 742 | |
@@ -753,23 +753,23 @@ discard block |
||
| 753 | 753 | * |
| 754 | 754 | * @return string |
| 755 | 755 | */ |
| 756 | - private function make_link( $tag, $url, $content, $attr ) { |
|
| 756 | + private function make_link($tag, $url, $content, $attr) { |
|
| 757 | 757 | |
| 758 | - if ( empty( $url ) ) { |
|
| 758 | + if (empty($url)) { |
|
| 759 | 759 | return ''; |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | - $text = empty( $content ) ? $url : $content; |
|
| 762 | + $text = empty($content) ? $url : $content; |
|
| 763 | 763 | |
| 764 | - $attr = array_merge( array( |
|
| 765 | - 'autolink' => false, // Convert url to link anchor |
|
| 766 | - 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
| 767 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 764 | + $attr = array_merge(array( |
|
| 765 | + 'autolink' => false, // Convert url to link anchor |
|
| 766 | + 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
| 767 | + ), (array) shortcode_parse_atts($attr)); |
|
| 768 | 768 | |
| 769 | 769 | $anchor = $tag != 'url' ? 'yes' : $attr['autolink']; |
| 770 | 770 | $target = $attr['newwindow'] !== false ? 'target="_blank"' : ''; |
| 771 | 771 | |
| 772 | - return $anchor !== false ? ' <a href="' . esc_url( $url ) . '" ' . $target . '>' . $text . '</a>' : ' ' . $text; |
|
| 772 | + return $anchor !== false ? ' <a href="'.esc_url($url).'" '.$target.'>'.$text.'</a>' : ' '.$text; |
|
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | /** |
@@ -782,20 +782,20 @@ discard block |
||
| 782 | 782 | * |
| 783 | 783 | * @return string |
| 784 | 784 | */ |
| 785 | - private function get_attachments( $attachments ) { |
|
| 785 | + private function get_attachments($attachments) { |
|
| 786 | 786 | |
| 787 | - $html = '<ul class="simcal-attachments">' . "\n\t"; |
|
| 787 | + $html = '<ul class="simcal-attachments">'."\n\t"; |
|
| 788 | 788 | |
| 789 | - foreach ( $attachments as $attachment ) { |
|
| 789 | + foreach ($attachments as $attachment) { |
|
| 790 | 790 | $html .= '<li class="simcal-attachment">'; |
| 791 | - $html .= '<a href="' . $attachment['url'] . '" target="_blank">'; |
|
| 792 | - $html .= ! empty( $attachment['icon'] ) ? '<img src="' . $attachment['icon'] . '" />' : ''; |
|
| 793 | - $html .= '<span>' . $attachment['name'] . '</span>'; |
|
| 791 | + $html .= '<a href="'.$attachment['url'].'" target="_blank">'; |
|
| 792 | + $html .= ! empty($attachment['icon']) ? '<img src="'.$attachment['icon'].'" />' : ''; |
|
| 793 | + $html .= '<span>'.$attachment['name'].'</span>'; |
|
| 794 | 794 | $html .= '</a>'; |
| 795 | - $html .= '</li>' . "\n"; |
|
| 795 | + $html .= '</li>'."\n"; |
|
| 796 | 796 | } |
| 797 | 797 | |
| 798 | - $html .= '</ul>' . "\n"; |
|
| 798 | + $html .= '</ul>'."\n"; |
|
| 799 | 799 | |
| 800 | 800 | return $html; |
| 801 | 801 | } |
@@ -811,41 +811,41 @@ discard block |
||
| 811 | 811 | * |
| 812 | 812 | * @return string |
| 813 | 813 | */ |
| 814 | - private function get_attendees( $attendees, $attr ) { |
|
| 814 | + private function get_attendees($attendees, $attr) { |
|
| 815 | 815 | |
| 816 | - $attr = array_merge( array( |
|
| 817 | - 'photo' => 'show', // show/hide attendee photo |
|
| 818 | - 'email' => 'hide', // show/hide attendee email address |
|
| 819 | - 'rsvp' => 'hide', // show/hide rsvp response status |
|
| 820 | - 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
| 821 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 816 | + $attr = array_merge(array( |
|
| 817 | + 'photo' => 'show', // show/hide attendee photo |
|
| 818 | + 'email' => 'hide', // show/hide attendee email address |
|
| 819 | + 'rsvp' => 'hide', // show/hide rsvp response status |
|
| 820 | + 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
| 821 | + ), (array) shortcode_parse_atts($attr)); |
|
| 822 | 822 | |
| 823 | - $html = '<ul class="simcal-attendees" itemprop="attendees">' . "\n\t"; |
|
| 823 | + $html = '<ul class="simcal-attendees" itemprop="attendees">'."\n\t"; |
|
| 824 | 824 | |
| 825 | 825 | $known = 0; |
| 826 | 826 | $unknown = 0; |
| 827 | 827 | |
| 828 | - foreach ( $attendees as $attendee ) { |
|
| 828 | + foreach ($attendees as $attendee) { |
|
| 829 | 829 | |
| 830 | - if ( 'yes' == $attr['response'] && 'yes' != $attendee['response'] ) { |
|
| 830 | + if ('yes' == $attr['response'] && 'yes' != $attendee['response']) { |
|
| 831 | 831 | continue; |
| 832 | - } elseif ( 'no' == $attr['response'] && 'no' != $attendee['response'] ) { |
|
| 832 | + } elseif ('no' == $attr['response'] && 'no' != $attendee['response']) { |
|
| 833 | 833 | continue; |
| 834 | - } elseif ( 'maybe' == $attr['response'] && ! in_array( $attendee['response'], array( 'yes', 'maybe' ) ) ) { |
|
| 834 | + } elseif ('maybe' == $attr['response'] && ! in_array($attendee['response'], array('yes', 'maybe'))) { |
|
| 835 | 835 | continue; |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | - if ( ! empty( $attendee['name'] ) ) { |
|
| 838 | + if ( ! empty($attendee['name'])) { |
|
| 839 | 839 | |
| 840 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $attendee['photo'] . '" itemprop="image" />' : ''; |
|
| 841 | - $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response( $attendee['response'] ) : ''; |
|
| 842 | - $guest = $photo . '<span itemprop="name">' . $attendee['name'] . $response . '</span>'; |
|
| 840 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$attendee['photo'].'" itemprop="image" />' : ''; |
|
| 841 | + $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response($attendee['response']) : ''; |
|
| 842 | + $guest = $photo.'<span itemprop="name">'.$attendee['name'].$response.'</span>'; |
|
| 843 | 843 | |
| 844 | - if ( ! empty( $attendee['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
| 845 | - $guest = sprintf( '<a href="mailto:' . $attendee['email'] . '" itemprop="email">%s</a>', $guest ); |
|
| 844 | + if ( ! empty($attendee['email']) && ('show' == $attr['email'])) { |
|
| 845 | + $guest = sprintf('<a href="mailto:'.$attendee['email'].'" itemprop="email">%s</a>', $guest); |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | - $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">' . $guest . '</li>' . "\n"; |
|
| 848 | + $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">'.$guest.'</li>'."\n"; |
|
| 849 | 849 | |
| 850 | 850 | $known++; |
| 851 | 851 | |
@@ -856,21 +856,21 @@ discard block |
||
| 856 | 856 | } |
| 857 | 857 | } |
| 858 | 858 | |
| 859 | - if ( $unknown > 0 ) { |
|
| 860 | - if ( $known > 0 ) { |
|
| 859 | + if ($unknown > 0) { |
|
| 860 | + if ($known > 0) { |
|
| 861 | 861 | /* translators: One more person attending the event. */ |
| 862 | - $others = sprintf( _n( '1 more attendee', '%s more attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
| 862 | + $others = sprintf(_n('1 more attendee', '%s more attendees', $unknown, 'google-calendar-events'), $unknown); |
|
| 863 | 863 | } else { |
| 864 | 864 | /* translators: One or more persons attending the event whose name is unknown. */ |
| 865 | - $others = sprintf( _n( '1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
| 865 | + $others = sprintf(_n('1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events'), $unknown); |
|
| 866 | 866 | } |
| 867 | - $photo = $attr['photo'] !== 'hide' ? get_avatar( '', 128 ) : ''; |
|
| 868 | - $html .= '<li class="simcal-attendee simcal-attendee-anonymous">' . $photo . '<span>' . $others . '</span></li>' . "\n"; |
|
| 869 | - } elseif ( $known === 0 ) { |
|
| 870 | - $html .= '<li class="simcal-attendee">' . _x( 'No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events' ) . '</li>' . "\n"; |
|
| 867 | + $photo = $attr['photo'] !== 'hide' ? get_avatar('', 128) : ''; |
|
| 868 | + $html .= '<li class="simcal-attendee simcal-attendee-anonymous">'.$photo.'<span>'.$others.'</span></li>'."\n"; |
|
| 869 | + } elseif ($known === 0) { |
|
| 870 | + $html .= '<li class="simcal-attendee">'._x('No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events').'</li>'."\n"; |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | - $html .= '</ul>' . "\n"; |
|
| 873 | + $html .= '</ul>'."\n"; |
|
| 874 | 874 | |
| 875 | 875 | return $html; |
| 876 | 876 | } |
@@ -884,23 +884,23 @@ discard block |
||
| 884 | 884 | * |
| 885 | 885 | * @return string |
| 886 | 886 | */ |
| 887 | - private function get_rsvp_response( $response ) { |
|
| 887 | + private function get_rsvp_response($response) { |
|
| 888 | 888 | |
| 889 | - if ( 'yes' == $response ) { |
|
| 889 | + if ('yes' == $response) { |
|
| 890 | 890 | /* translators: Someone replied with 'yes' to a rsvp request. */ |
| 891 | - $rsvp = __( 'Attending', 'google-calendar-events' ); |
|
| 892 | - } elseif ( 'no' == $response ) { |
|
| 891 | + $rsvp = __('Attending', 'google-calendar-events'); |
|
| 892 | + } elseif ('no' == $response) { |
|
| 893 | 893 | /* translators: Someone replied with 'no' to a rsvp request. */ |
| 894 | - $rsvp = __( 'Not attending', 'google-calendar-events' ); |
|
| 895 | - } elseif ( 'maybe' == $response ) { |
|
| 894 | + $rsvp = __('Not attending', 'google-calendar-events'); |
|
| 895 | + } elseif ('maybe' == $response) { |
|
| 896 | 896 | /* translators: Someone replied with 'maybe' to a rsvp request. */ |
| 897 | - $rsvp = __( 'Maybe attending', 'google-calendar-events' ); |
|
| 897 | + $rsvp = __('Maybe attending', 'google-calendar-events'); |
|
| 898 | 898 | } else { |
| 899 | 899 | /* translators: Someone did not send yet a rsvp confirmation to join an event. */ |
| 900 | - $rsvp = __( 'Response pending', 'google-calendar-events' ); |
|
| 900 | + $rsvp = __('Response pending', 'google-calendar-events'); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | - return ' <small>(' . $rsvp . ')</small>'; |
|
| 903 | + return ' <small>('.$rsvp.')</small>'; |
|
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | /** |
@@ -914,21 +914,21 @@ discard block |
||
| 914 | 914 | * |
| 915 | 915 | * @return string |
| 916 | 916 | */ |
| 917 | - private function get_organizer( $organizer, $attr ) { |
|
| 917 | + private function get_organizer($organizer, $attr) { |
|
| 918 | 918 | |
| 919 | - $attr = array_merge( array( |
|
| 920 | - 'photo' => 'show', // show/hide attendee photo |
|
| 921 | - 'email' => 'hide', // show/hide attendee email address |
|
| 922 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 919 | + $attr = array_merge(array( |
|
| 920 | + 'photo' => 'show', // show/hide attendee photo |
|
| 921 | + 'email' => 'hide', // show/hide attendee email address |
|
| 922 | + ), (array) shortcode_parse_atts($attr)); |
|
| 923 | 923 | |
| 924 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $organizer['photo'] . '" itemprop="image" />' : ''; |
|
| 925 | - $organizer_html = $photo . '<span itemprop="name">' . $organizer['name'] . '</span>'; |
|
| 924 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$organizer['photo'].'" itemprop="image" />' : ''; |
|
| 925 | + $organizer_html = $photo.'<span itemprop="name">'.$organizer['name'].'</span>'; |
|
| 926 | 926 | |
| 927 | - if ( ! empty( $organizer['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
| 928 | - $organizer_html = sprintf( '<a href="mailto:' . $organizer['email'] . '" itemprop="email">%s</a>', $organizer_html ); |
|
| 927 | + if ( ! empty($organizer['email']) && ('show' == $attr['email'])) { |
|
| 928 | + $organizer_html = sprintf('<a href="mailto:'.$organizer['email'].'" itemprop="email">%s</a>', $organizer_html); |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | - return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">' . $organizer_html . '</div>'; |
|
| 931 | + return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">'.$organizer_html.'</div>'; |
|
| 932 | 932 | } |
| 933 | 933 | |
| 934 | 934 | /** |
@@ -953,7 +953,7 @@ discard block |
||
| 953 | 953 | // This is largely borrowed on get_shortcode_regex() from WordPress Core. |
| 954 | 954 | // @see /wp-includes/shortcodes.php (with some modification) |
| 955 | 955 | |
| 956 | - $tagregexp = implode( '|', array_values( $this->tags ) ); |
|
| 956 | + $tagregexp = implode('|', array_values($this->tags)); |
|
| 957 | 957 | |
| 958 | 958 | return '/' |
| 959 | 959 | . '\\[' // Opening bracket |
@@ -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 | |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function __construct() { |
| 62 | 62 | |
| 63 | - $this->min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG == true ) ? '' : '.min'; |
|
| 63 | + $this->min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG == true) ? '' : '.min'; |
|
| 64 | 64 | |
| 65 | - $settings = get_option( 'simple-calendar_settings_advanced' ); |
|
| 65 | + $settings = get_option('simple-calendar_settings_advanced'); |
|
| 66 | 66 | |
| 67 | - if ( isset( $settings['assets']['disable_css'] ) ) { |
|
| 67 | + if (isset($settings['assets']['disable_css'])) { |
|
| 68 | 68 | $this->disable_styles = 'yes' == $settings['assets']['disable_css'] ? true : false; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - add_action( 'init', array( $this, 'register' ), 20 ); |
|
| 72 | - add_action( 'init', array( $this, 'enqueue' ), 40 ); |
|
| 71 | + add_action('init', array($this, 'register'), 20); |
|
| 72 | + add_action('init', array($this, 'enqueue'), 40); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @since 3.0.0 |
| 79 | 79 | */ |
| 80 | 80 | public function register() { |
| 81 | - do_action( 'simcal_register_assets', $this->min ); |
|
| 81 | + do_action('simcal_register_assets', $this->min); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -88,25 +88,25 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function enqueue() { |
| 90 | 90 | |
| 91 | - add_action( 'wp_enqueue_scripts', array( $this, 'load' ), 10 ); |
|
| 91 | + add_action('wp_enqueue_scripts', array($this, 'load'), 10); |
|
| 92 | 92 | |
| 93 | - do_action( 'simcal_enqueue_assets', $this->min ); |
|
| 93 | + do_action('simcal_enqueue_assets', $this->min); |
|
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | $min = $this->min; |
| 97 | 97 | // Improves compatibility with themes and plugins using Isotope and Masonry. |
| 98 | - add_action( 'wp_enqueue_scripts', |
|
| 99 | - function () use ( $min ) { |
|
| 100 | - if ( wp_script_is( 'simcal-qtip', 'enqueued' ) ) { |
|
| 98 | + add_action('wp_enqueue_scripts', |
|
| 99 | + function() use ($min) { |
|
| 100 | + if (wp_script_is('simcal-qtip', 'enqueued')) { |
|
| 101 | 101 | wp_enqueue_script( |
| 102 | 102 | 'simplecalendar-imagesloaded', |
| 103 | - SIMPLE_CALENDAR_ASSETS . 'js/vendor/imagesloaded.pkgd' . $min . '.js', |
|
| 104 | - array( 'simcal-qtip' ), |
|
| 103 | + SIMPLE_CALENDAR_ASSETS.'js/vendor/imagesloaded.pkgd'.$min.'.js', |
|
| 104 | + array('simcal-qtip'), |
|
| 105 | 105 | SIMPLE_CALENDAR_VERSION, |
| 106 | 106 | true |
| 107 | 107 | ); |
| 108 | 108 | } |
| 109 | - }, 1000 ); |
|
| 109 | + }, 1000); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -118,34 +118,34 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $types = simcal_get_calendar_types(); |
| 120 | 120 | |
| 121 | - foreach ( $types as $calendar => $views ) { |
|
| 122 | - foreach( $views as $key => $view ) { |
|
| 121 | + foreach ($types as $calendar => $views) { |
|
| 122 | + foreach ($views as $key => $view) { |
|
| 123 | 123 | |
| 124 | - $view = simcal_get_calendar_view( 0, $calendar . '-' . $view ); |
|
| 124 | + $view = simcal_get_calendar_view(0, $calendar.'-'.$view); |
|
| 125 | 125 | |
| 126 | - $scripts[] = $view->scripts( $this->min ); |
|
| 127 | - $styles[] = $view->styles( $this->min ); |
|
| 126 | + $scripts[] = $view->scripts($this->min); |
|
| 127 | + $styles[] = $view->styles($this->min); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | $this->get_widgets_assets(); |
| 132 | - $this->scripts = apply_filters( 'simcal_front_end_scripts', $scripts, $this->min ); |
|
| 132 | + $this->scripts = apply_filters('simcal_front_end_scripts', $scripts, $this->min); |
|
| 133 | 133 | // First check if there is a multi-dimensional array of scripts |
| 134 | - if ( isset( $this->scripts[0] ) ) { |
|
| 135 | - foreach ( $this->scripts as $script ) { |
|
| 136 | - $this->load_scripts ( $script ); |
|
| 134 | + if (isset($this->scripts[0])) { |
|
| 135 | + foreach ($this->scripts as $script) { |
|
| 136 | + $this->load_scripts($script); |
|
| 137 | 137 | } |
| 138 | 138 | } else { |
| 139 | - $this->load_scripts( $this->scripts ); |
|
| 139 | + $this->load_scripts($this->scripts); |
|
| 140 | 140 | } |
| 141 | - $this->styles = apply_filters( 'simcal_front_end_styles', $styles, $this->min ); |
|
| 141 | + $this->styles = apply_filters('simcal_front_end_styles', $styles, $this->min); |
|
| 142 | 142 | // First check if there is a multi-dimensional array of styles |
| 143 | - if ( isset( $this->styles[0] ) ) { |
|
| 144 | - foreach( $this->styles as $style ) { |
|
| 145 | - $this->load_styles( $style ); |
|
| 143 | + if (isset($this->styles[0])) { |
|
| 144 | + foreach ($this->styles as $style) { |
|
| 145 | + $this->load_styles($style); |
|
| 146 | 146 | } |
| 147 | 147 | } else { |
| 148 | - $this->load_styles( $this->styles ); |
|
| 148 | + $this->load_styles($this->styles); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
@@ -156,25 +156,25 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | public function get_widgets_assets() { |
| 158 | 158 | |
| 159 | - $widgets = get_option( 'widget_gce_widget' ); |
|
| 159 | + $widgets = get_option('widget_gce_widget'); |
|
| 160 | 160 | |
| 161 | - if ( ! empty( $widgets ) && is_array( $widgets ) ) { |
|
| 161 | + if ( ! empty($widgets) && is_array($widgets)) { |
|
| 162 | 162 | |
| 163 | - foreach ( $widgets as $settings ) { |
|
| 163 | + foreach ($widgets as $settings) { |
|
| 164 | 164 | |
| 165 | - if ( ! empty( $settings ) && is_array( $settings ) ) { |
|
| 165 | + if ( ! empty($settings) && is_array($settings)) { |
|
| 166 | 166 | |
| 167 | - if ( isset( $settings['calendar_id'] ) ) { |
|
| 167 | + if (isset($settings['calendar_id'])) { |
|
| 168 | 168 | |
| 169 | - $view = simcal_get_calendar_view( absint( $settings['calendar_id'] ) ); |
|
| 169 | + $view = simcal_get_calendar_view(absint($settings['calendar_id'])); |
|
| 170 | 170 | |
| 171 | - if ( $view instanceof Calendar_View ) { |
|
| 172 | - add_filter( 'simcal_front_end_scripts', function ( $scripts, $min ) use ( $view ) { |
|
| 173 | - return array_merge( $scripts, $view->scripts( $min ) ); |
|
| 174 | - }, 100, 2 ); |
|
| 175 | - add_filter( 'simcal_front_end_styles', function ( $styles, $min ) use ( $view ) { |
|
| 176 | - return array_merge( $styles, $view->styles( $min ) ); |
|
| 177 | - }, 100, 2 ); |
|
| 171 | + if ($view instanceof Calendar_View) { |
|
| 172 | + add_filter('simcal_front_end_scripts', function($scripts, $min) use ($view) { |
|
| 173 | + return array_merge($scripts, $view->scripts($min)); |
|
| 174 | + }, 100, 2); |
|
| 175 | + add_filter('simcal_front_end_styles', function($styles, $min) use ($view) { |
|
| 176 | + return array_merge($styles, $view->styles($min)); |
|
| 177 | + }, 100, 2); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | } |
@@ -192,39 +192,39 @@ discard block |
||
| 192 | 192 | * |
| 193 | 193 | * @param array $scripts |
| 194 | 194 | */ |
| 195 | - public function load_scripts( $scripts ) { |
|
| 195 | + public function load_scripts($scripts) { |
|
| 196 | 196 | |
| 197 | 197 | // Only load if not disabled in the settings |
| 198 | - if ( ! empty( $scripts ) && is_array( $scripts ) ) { |
|
| 198 | + if ( ! empty($scripts) && is_array($scripts)) { |
|
| 199 | 199 | |
| 200 | - foreach ( $scripts as $script => $v ) { |
|
| 200 | + foreach ($scripts as $script => $v) { |
|
| 201 | 201 | |
| 202 | 202 | /** Plugin compatibility fixes */ |
| 203 | 203 | |
| 204 | 204 | // Dequeue moment.js if detected from WP Simple Pay Pro. |
| 205 | - if ( ( wp_script_is( 'stripe-checkout-pro-moment', 'enqueued' ) ) && $script == 'simcal-fullcal-moment' ) { |
|
| 205 | + if ((wp_script_is('stripe-checkout-pro-moment', 'enqueued')) && $script == 'simcal-fullcal-moment') { |
|
| 206 | 206 | continue; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if ( ! empty( $v['src'] ) ) { |
|
| 209 | + if ( ! empty($v['src'])) { |
|
| 210 | 210 | |
| 211 | 211 | // Enqueued individually so we can dequeue if already enqueued by another plugin. |
| 212 | 212 | // TODO Rework dependencies part (or remove completely). |
| 213 | 213 | |
| 214 | - $src = esc_url( $v['src'] ); |
|
| 215 | - $in_footer = isset( $v['in_footer'] ) ? $v['in_footer'] : false; |
|
| 214 | + $src = esc_url($v['src']); |
|
| 215 | + $in_footer = isset($v['in_footer']) ? $v['in_footer'] : false; |
|
| 216 | 216 | |
| 217 | - wp_enqueue_script( $script, $src, array(), SIMPLE_CALENDAR_VERSION, $in_footer ); |
|
| 217 | + wp_enqueue_script($script, $src, array(), SIMPLE_CALENDAR_VERSION, $in_footer); |
|
| 218 | 218 | |
| 219 | - if ( ! empty( $v['localize'] ) && is_array( $v['localize'] ) ) { |
|
| 220 | - foreach ( $v['localize'] as $object => $l10n ) { |
|
| 221 | - wp_localize_script( $script, $object, $l10n ); |
|
| 219 | + if ( ! empty($v['localize']) && is_array($v['localize'])) { |
|
| 220 | + foreach ($v['localize'] as $object => $l10n) { |
|
| 221 | + wp_localize_script($script, $object, $l10n); |
|
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - } elseif ( is_string( $v ) && ! empty( $v ) ) { |
|
| 225 | + } elseif (is_string($v) && ! empty($v)) { |
|
| 226 | 226 | |
| 227 | - wp_enqueue_script( $v ); |
|
| 227 | + wp_enqueue_script($v); |
|
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
@@ -238,26 +238,26 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @param array $styles |
| 240 | 240 | */ |
| 241 | - public function load_styles( $styles ) { |
|
| 241 | + public function load_styles($styles) { |
|
| 242 | 242 | |
| 243 | 243 | // Only load if not disabled in the settings |
| 244 | - if ( ! empty( $styles ) && is_array( $styles ) && false === $this->disable_styles ) { |
|
| 244 | + if ( ! empty($styles) && is_array($styles) && false === $this->disable_styles) { |
|
| 245 | 245 | |
| 246 | - foreach ( $styles as $style => $v ) { |
|
| 246 | + foreach ($styles as $style => $v) { |
|
| 247 | 247 | |
| 248 | - if ( ! empty( $v['src'] ) ) { |
|
| 248 | + if ( ! empty($v['src'])) { |
|
| 249 | 249 | |
| 250 | 250 | // Enqueued individually so we can dequeue if already enqueued by another plugin. |
| 251 | 251 | // TODO Rework dependencies part (or remove completely). |
| 252 | 252 | |
| 253 | - $src = esc_url( $v['src'] ); |
|
| 254 | - $media = isset( $v['media'] ) ? $v['media'] : 'all'; |
|
| 253 | + $src = esc_url($v['src']); |
|
| 254 | + $media = isset($v['media']) ? $v['media'] : 'all'; |
|
| 255 | 255 | |
| 256 | - wp_enqueue_style( $style, $src, array(), SIMPLE_CALENDAR_VERSION, $media ); |
|
| 256 | + wp_enqueue_style($style, $src, array(), SIMPLE_CALENDAR_VERSION, $media); |
|
| 257 | 257 | |
| 258 | - } elseif ( is_string( $v ) && ! empty( $v ) ) { |
|
| 258 | + } elseif (is_string($v) && ! empty($v)) { |
|
| 259 | 259 | |
| 260 | - wp_enqueue_style( $v ); |
|
| 260 | + wp_enqueue_style($v); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | namespace SimpleCalendar\Admin; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function __construct() { |
| 38 | 38 | |
| 39 | - $this->install = isset( $_GET['simcal_install'] ) ? esc_attr( $_GET['simcal_install'] ) : ''; |
|
| 39 | + $this->install = isset($_GET['simcal_install']) ? esc_attr($_GET['simcal_install']) : ''; |
|
| 40 | 40 | |
| 41 | - add_action( 'admin_menu', array( $this, 'welcome_page_tabs' ) ); |
|
| 42 | - add_action( 'admin_head', array( $this, 'remove_submenu_pages' ) ); |
|
| 41 | + add_action('admin_menu', array($this, 'welcome_page_tabs')); |
|
| 42 | + add_action('admin_head', array($this, 'remove_submenu_pages')); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -49,32 +49,32 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function welcome_page_tabs() { |
| 51 | 51 | |
| 52 | - $welcome_page_name = __( 'About Simple Calendar', 'google-calendar-events' ); |
|
| 53 | - $welcome_page_title = __( 'Welcome to Simple Calendar', 'google-calendar-events' ); |
|
| 52 | + $welcome_page_name = __('About Simple Calendar', 'google-calendar-events'); |
|
| 53 | + $welcome_page_title = __('Welcome to Simple Calendar', 'google-calendar-events'); |
|
| 54 | 54 | |
| 55 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : 'simple-calendar_about'; |
|
| 55 | + $page = isset($_GET['page']) ? $_GET['page'] : 'simple-calendar_about'; |
|
| 56 | 56 | |
| 57 | - switch ( $page ) { |
|
| 57 | + switch ($page) { |
|
| 58 | 58 | |
| 59 | 59 | case 'simple-calendar_about' : |
| 60 | - $page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'simple-calendar_about', array( |
|
| 60 | + $page = add_dashboard_page($welcome_page_title, $welcome_page_name, 'manage_options', 'simple-calendar_about', array( |
|
| 61 | 61 | $this, |
| 62 | 62 | 'about_screen', |
| 63 | - ) ); |
|
| 63 | + )); |
|
| 64 | 64 | break; |
| 65 | 65 | |
| 66 | 66 | case 'simple-calendar_credits' : |
| 67 | - $page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'simple-calendar_credits', array( |
|
| 67 | + $page = add_dashboard_page($welcome_page_title, $welcome_page_name, 'manage_options', 'simple-calendar_credits', array( |
|
| 68 | 68 | $this, |
| 69 | 69 | 'credits_screen', |
| 70 | - ) ); |
|
| 70 | + )); |
|
| 71 | 71 | break; |
| 72 | 72 | |
| 73 | 73 | case 'simple-calendar_translators' : |
| 74 | - $page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'simple-calendar_translators', array( |
|
| 74 | + $page = add_dashboard_page($welcome_page_title, $welcome_page_name, 'manage_options', 'simple-calendar_translators', array( |
|
| 75 | 75 | $this, |
| 76 | 76 | 'translators_screen', |
| 77 | - ) ); |
|
| 77 | + )); |
|
| 78 | 78 | break; |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | * @since 3.0.0 |
| 86 | 86 | */ |
| 87 | 87 | public function remove_submenu_pages() { |
| 88 | - remove_submenu_page( 'index.php', 'simple-calendar_about' ); |
|
| 89 | - remove_submenu_page( 'index.php', 'simple-calendar_credits' ); |
|
| 90 | - remove_submenu_page( 'index.php', 'simple-calendar_translators' ); |
|
| 88 | + remove_submenu_page('index.php', 'simple-calendar_about'); |
|
| 89 | + remove_submenu_page('index.php', 'simple-calendar_credits'); |
|
| 90 | + remove_submenu_page('index.php', 'simple-calendar_translators'); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -99,18 +99,18 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | ?> |
| 101 | 101 | <p> |
| 102 | - <a href="<?php echo admin_url( 'edit.php?post_type=calendar' ); ?>" |
|
| 102 | + <a href="<?php echo admin_url('edit.php?post_type=calendar'); ?>" |
|
| 103 | 103 | class="button button-primary" |
| 104 | - ><?php _e( 'Calendars', 'google-calendar-events' ); ?></a> |
|
| 105 | - <a href="<?php echo esc_url( add_query_arg( 'page', 'simple-calendar_settings', admin_url( 'admin.php' ) ) ); ?>" |
|
| 104 | + ><?php _e('Calendars', 'google-calendar-events'); ?></a> |
|
| 105 | + <a href="<?php echo esc_url(add_query_arg('page', 'simple-calendar_settings', admin_url('admin.php'))); ?>" |
|
| 106 | 106 | class="button button-primary" |
| 107 | - ><?php _e( 'Settings', 'google-calendar-events' ); ?></a> |
|
| 108 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'welcome-page' ); ?>" |
|
| 107 | + ><?php _e('Settings', 'google-calendar-events'); ?></a> |
|
| 108 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'welcome-page'); ?>" |
|
| 109 | 109 | class="docs button button-primary" target="_blank" |
| 110 | - ><?php _e( 'Add-ons', 'google-calendar-events' ); ?></a> |
|
| 111 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'docs' ), 'core-plugin', 'welcome-page' ); ?>" |
|
| 110 | + ><?php _e('Add-ons', 'google-calendar-events'); ?></a> |
|
| 111 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('docs'), 'core-plugin', 'welcome-page'); ?>" |
|
| 112 | 112 | class="docs button button-primary" target="_blank" |
| 113 | - ><?php _e( 'Documentation', 'google-calendar-events' ); ?></a> |
|
| 113 | + ><?php _e('Documentation', 'google-calendar-events'); ?></a> |
|
| 114 | 114 | </p> |
| 115 | 115 | <?php |
| 116 | 116 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | <h1> |
| 128 | 128 | <?php |
| 129 | 129 | /* translators: %s prints the current version of the plugin. */ |
| 130 | - printf( __( 'Welcome to Simple Calendar %s', 'google-calendar-events' ), SIMPLE_CALENDAR_VERSION ); |
|
| 130 | + printf(__('Welcome to Simple Calendar %s', 'google-calendar-events'), SIMPLE_CALENDAR_VERSION); |
|
| 131 | 131 | ?> |
| 132 | 132 | </h1> |
| 133 | 133 | |
@@ -135,21 +135,21 @@ discard block |
||
| 135 | 135 | <?php |
| 136 | 136 | |
| 137 | 137 | // Difference message if updating vs fresh install. |
| 138 | - if ( 'update' == $this->install ) { |
|
| 139 | - $message = __( 'Thanks for updating to the latest version!', 'google-calendar-events' ); |
|
| 138 | + if ('update' == $this->install) { |
|
| 139 | + $message = __('Thanks for updating to the latest version!', 'google-calendar-events'); |
|
| 140 | 140 | } else { |
| 141 | - $message = __( 'Thanks for installing!', 'google-calendar-events' ); |
|
| 141 | + $message = __('Thanks for installing!', 'google-calendar-events'); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | echo $message; |
| 145 | 145 | |
| 146 | 146 | /* translators: %s prints the current version of the plugin. */ |
| 147 | - printf( ' ' . __( "Simple Calendar %s has a few display options to configure. ", 'google-calendar-events' ), SIMPLE_CALENDAR_VERSION ); |
|
| 147 | + printf(' '.__("Simple Calendar %s has a few display options to configure. ", 'google-calendar-events'), SIMPLE_CALENDAR_VERSION); |
|
| 148 | 148 | ?> |
| 149 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'docs' ), 'core-plugin', 'welcome-page' ); ?>" |
|
| 149 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('docs'), 'core-plugin', 'welcome-page'); ?>" |
|
| 150 | 150 | target="_blank" |
| 151 | - ><?php _e( 'Check out our documentation', 'google-calendar-events' ); ?></a> |
|
| 152 | - <?php _e( 'to get started now.', 'google-calendar-events' ); ?> |
|
| 151 | + ><?php _e('Check out our documentation', 'google-calendar-events'); ?></a> |
|
| 152 | + <?php _e('to get started now.', 'google-calendar-events'); ?> |
|
| 153 | 153 | </div> |
| 154 | 154 | |
| 155 | 155 | <div class="simcal-badge"> </div> |
@@ -157,21 +157,21 @@ discard block |
||
| 157 | 157 | <?php $this->main_nav_links(); ?> |
| 158 | 158 | |
| 159 | 159 | <h2 class="nav-tab-wrapper"> |
| 160 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_about' ) { |
|
| 160 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_about') { |
|
| 161 | 161 | echo 'nav-tab-active'; |
| 162 | 162 | } ?>" |
| 163 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_about' ), 'index.php' ) ) ); ?>" |
|
| 164 | - ><?php _e( "What's New", 'google-calendar-events' ); ?></a> |
|
| 165 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_credits' ) { |
|
| 163 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_about'), 'index.php'))); ?>" |
|
| 164 | + ><?php _e("What's New", 'google-calendar-events'); ?></a> |
|
| 165 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_credits') { |
|
| 166 | 166 | echo 'nav-tab-active'; |
| 167 | 167 | } ?>" |
| 168 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_credits' ), 'index.php' ) ) ); ?>" |
|
| 169 | - ><?php _e( 'Credits', 'google-calendar-events' ); ?></a> |
|
| 170 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_translators' ) { |
|
| 168 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_credits'), 'index.php'))); ?>" |
|
| 169 | + ><?php _e('Credits', 'google-calendar-events'); ?></a> |
|
| 170 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_translators') { |
|
| 171 | 171 | echo 'nav-tab-active'; |
| 172 | 172 | } ?>" |
| 173 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_translators' ), 'index.php' ) ) ); ?>" |
|
| 174 | - ><?php _e( 'Translators', 'google-calendar-events' ); ?></a> |
|
| 173 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_translators'), 'index.php'))); ?>" |
|
| 174 | + ><?php _e('Translators', 'google-calendar-events'); ?></a> |
|
| 175 | 175 | </h2> |
| 176 | 176 | <?php |
| 177 | 177 | |
@@ -183,8 +183,8 @@ discard block |
||
| 183 | 183 | * @since 3.0.0 |
| 184 | 184 | */ |
| 185 | 185 | public function about_screen() { |
| 186 | - $welcome_image_about_path = SIMPLE_CALENDAR_ASSETS . '/images/welcome'; |
|
| 187 | - $welcome_addons_link = simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'welcome-page' ); |
|
| 186 | + $welcome_image_about_path = SIMPLE_CALENDAR_ASSETS.'/images/welcome'; |
|
| 187 | + $welcome_addons_link = simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'welcome-page'); |
|
| 188 | 188 | |
| 189 | 189 | ?> |
| 190 | 190 | <div id="simcal-welcome"> |
@@ -192,20 +192,20 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | <?php $this->intro(); ?> |
| 194 | 194 | |
| 195 | - <h3><?php _e( 'Configure event colors, number of events to display, grid or list style and more.', 'google-calendar-events' ); ?></h3> |
|
| 196 | - <img src="<?php echo $welcome_image_about_path . '/grid-view-basic.png'; ?>" /> |
|
| 195 | + <h3><?php _e('Configure event colors, number of events to display, grid or list style and more.', 'google-calendar-events'); ?></h3> |
|
| 196 | + <img src="<?php echo $welcome_image_about_path.'/grid-view-basic.png'; ?>" /> |
|
| 197 | 197 | |
| 198 | - <h3><?php _e( 'Mobile responsive and widget ready.', 'google-calendar-events' ); ?></h3> |
|
| 199 | - <img src="<?php echo $welcome_image_about_path . '/list-view-widget.png'; ?>" /> |
|
| 200 | - <img src="<?php echo $welcome_image_about_path . '/grid-view-widget-dark-theme.png'; ?>" /> |
|
| 198 | + <h3><?php _e('Mobile responsive and widget ready.', 'google-calendar-events'); ?></h3> |
|
| 199 | + <img src="<?php echo $welcome_image_about_path.'/list-view-widget.png'; ?>" /> |
|
| 200 | + <img src="<?php echo $welcome_image_about_path.'/grid-view-widget-dark-theme.png'; ?>" /> |
|
| 201 | 201 | |
| 202 | 202 | <h3> |
| 203 | - <?php _e( 'Add even more display options with add-ons like', 'google-calendar-events' ); ?> |
|
| 204 | - <a href="<?php echo $welcome_addons_link; ?>" target="_blank"><?php _e( 'FullCalendar and Google Calendar Pro', 'google-calendar-events' ); ?></a>. |
|
| 203 | + <?php _e('Add even more display options with add-ons like', 'google-calendar-events'); ?> |
|
| 204 | + <a href="<?php echo $welcome_addons_link; ?>" target="_blank"><?php _e('FullCalendar and Google Calendar Pro', 'google-calendar-events'); ?></a>. |
|
| 205 | 205 | </h3> |
| 206 | - <a href="<?php echo $welcome_addons_link; ?>" target="_blank"><img src="<?php echo $welcome_image_about_path . '/fullcalendar-google-calendar-pro-grid-view.png'; ?>" /></a> |
|
| 206 | + <a href="<?php echo $welcome_addons_link; ?>" target="_blank"><img src="<?php echo $welcome_image_about_path.'/fullcalendar-google-calendar-pro-grid-view.png'; ?>" /></a> |
|
| 207 | 207 | |
| 208 | - <h3><a href="<?php echo $welcome_addons_link; ?>" target="_blank"><?php _e( 'View Pricing and Try a Demo of our Simple Calendar Pro Add-ons.', 'google-calendar-events' ); ?></a></h3> |
|
| 208 | + <h3><a href="<?php echo $welcome_addons_link; ?>" target="_blank"><?php _e('View Pricing and Try a Demo of our Simple Calendar Pro Add-ons.', 'google-calendar-events'); ?></a></h3> |
|
| 209 | 209 | |
| 210 | 210 | <hr/> |
| 211 | 211 | |
@@ -232,8 +232,8 @@ discard block |
||
| 232 | 232 | <?php |
| 233 | 233 | |
| 234 | 234 | printf( |
| 235 | - __( "Simple Calendar is created by a worldwide team of developers. If you'd like to contribute please visit our <a href='%s' target='_blank'>GitHub repo</a>.", 'google-calendar-events' ), |
|
| 236 | - simcal_get_url( 'github' ) |
|
| 235 | + __("Simple Calendar is created by a worldwide team of developers. If you'd like to contribute please visit our <a href='%s' target='_blank'>GitHub repo</a>.", 'google-calendar-events'), |
|
| 236 | + simcal_get_url('github') |
|
| 237 | 237 | ); |
| 238 | 238 | |
| 239 | 239 | ?> |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | <div class="wrap about-wrap translators-wrap"> |
| 258 | 258 | <?php $this->intro(); ?> |
| 259 | 259 | <p class="about-description"> |
| 260 | - <?php _e( 'Simple Calendar has been kindly translated into several other languages by contributors from all over the world.', 'google-calendar-events' ); ?> |
|
| 260 | + <?php _e('Simple Calendar has been kindly translated into several other languages by contributors from all over the world.', 'google-calendar-events'); ?> |
|
| 261 | 261 | </p> |
| 262 | 262 | <p class="about-description"> |
| 263 | - <a href="https://translate.wordpress.org/projects/wp-plugins/google-calendar-events" target="_blank"><?php _e( 'Click here to help translate', 'google-calendar-events' ); ?></a> |
|
| 263 | + <a href="https://translate.wordpress.org/projects/wp-plugins/google-calendar-events" target="_blank"><?php _e('Click here to help translate', 'google-calendar-events'); ?></a> |
|
| 264 | 264 | </p> |
| 265 | 265 | <?php |
| 266 | 266 | |
@@ -289,31 +289,31 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | $contributors = $this->get_contributors(); |
| 291 | 291 | |
| 292 | - if ( empty( $contributors ) ) { |
|
| 292 | + if (empty($contributors)) { |
|
| 293 | 293 | return ''; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | $contributor_list = '<ul class="wp-people-group">'; |
| 297 | 297 | |
| 298 | - foreach ( $contributors as $contributor ) { |
|
| 298 | + foreach ($contributors as $contributor) { |
|
| 299 | 299 | |
| 300 | 300 | // Skip contributor bots |
| 301 | - $contributor_bots = array( 'gitter-badger' ); |
|
| 302 | - if ( in_array( $contributor->login, $contributor_bots ) ) { |
|
| 301 | + $contributor_bots = array('gitter-badger'); |
|
| 302 | + if (in_array($contributor->login, $contributor_bots)) { |
|
| 303 | 303 | continue; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | $contributor_list .= '<li class="wp-person">'; |
| 307 | 307 | $contributor_list .= sprintf( |
| 308 | 308 | '<a href="%s" title="%s" target="_blank">%s</a>', |
| 309 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
| 310 | - esc_html( sprintf( __( 'View %s', 'google-calendar-events' ), $contributor->login ) ), |
|
| 311 | - sprintf( '<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url( $contributor->avatar_url ), esc_html( $contributor->login ) ) |
|
| 309 | + esc_url('https://github.com/'.$contributor->login), |
|
| 310 | + esc_html(sprintf(__('View %s', 'google-calendar-events'), $contributor->login)), |
|
| 311 | + sprintf('<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url($contributor->avatar_url), esc_html($contributor->login)) |
|
| 312 | 312 | ); |
| 313 | 313 | $contributor_list .= sprintf( |
| 314 | 314 | '<a class="web" href="%s" target="_blank">%s</a>', |
| 315 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
| 316 | - esc_html( $contributor->login ) |
|
| 315 | + esc_url('https://github.com/'.$contributor->login), |
|
| 316 | + esc_html($contributor->login) |
|
| 317 | 317 | ); |
| 318 | 318 | $contributor_list .= '</li>'; |
| 319 | 319 | |
@@ -333,24 +333,24 @@ discard block |
||
| 333 | 333 | */ |
| 334 | 334 | public function get_contributors() { |
| 335 | 335 | |
| 336 | - $contributors = get_transient( '_simple-calendar_contributors' ); |
|
| 337 | - if ( false !== $contributors ) { |
|
| 336 | + $contributors = get_transient('_simple-calendar_contributors'); |
|
| 337 | + if (false !== $contributors) { |
|
| 338 | 338 | return $contributors; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | $response = wp_safe_remote_get( |
| 342 | 342 | 'https://api.github.com/repos/moonstonemedia/Simple-Calendar/contributors' |
| 343 | 343 | ); |
| 344 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
| 344 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { |
|
| 345 | 345 | return array(); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - $contributors = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 349 | - if ( ! is_array( $contributors ) ) { |
|
| 348 | + $contributors = json_decode(wp_remote_retrieve_body($response)); |
|
| 349 | + if ( ! is_array($contributors)) { |
|
| 350 | 350 | return array(); |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - set_transient( '_simple-calendar_contributors', $contributors, HOUR_IN_SECONDS ); |
|
| 353 | + set_transient('_simple-calendar_contributors', $contributors, HOUR_IN_SECONDS); |
|
| 354 | 354 | |
| 355 | 355 | return $contributors; |
| 356 | 356 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Abstracts\Admin_Page; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -30,16 +30,16 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | $this->id = $tab = 'system-status'; |
| 32 | 32 | $this->option_group = $page = 'tools'; |
| 33 | - $this->label = __( 'System Report', 'google-calendar-events' ); |
|
| 33 | + $this->label = __('System Report', 'google-calendar-events'); |
|
| 34 | 34 | $this->description = ''; |
| 35 | 35 | $this->sections = $this->add_sections(); |
| 36 | 36 | $this->fields = $this->add_fields(); |
| 37 | 37 | |
| 38 | 38 | // Disable the submit button for this page. |
| 39 | - add_filter( 'simcal_admin_page_' . $page . '_' . $tab . '_submit', function() { return false; } ); |
|
| 39 | + add_filter('simcal_admin_page_'.$page.'_'.$tab.'_submit', function() { return false; } ); |
|
| 40 | 40 | |
| 41 | 41 | // Add html. |
| 42 | - add_action( 'simcal_admin_page_' . $page . '_' . $tab . '_end', array( $this, 'html' ) ); |
|
| 42 | + add_action('simcal_admin_page_'.$page.'_'.$tab.'_end', array($this, 'html')); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -51,37 +51,37 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | ?> |
| 53 | 53 | <div id="simcal-system-status-report"> |
| 54 | - <p><?php _e( 'Please copy and paste this information when contacting support:', 'google-calendar-events' ); ?> </p> |
|
| 54 | + <p><?php _e('Please copy and paste this information when contacting support:', 'google-calendar-events'); ?> </p> |
|
| 55 | 55 | <textarea readonly="readonly" onclick="this.select();"></textarea> |
| 56 | - <p><?php _e( 'You can also download your information as a text file to attach, or simply view it below.', 'google-calendar-events' ); ?></p> |
|
| 57 | - <p><a href="#" id="simcal-system-status-report-download" class="button button-primary"><?php _e( 'Download System Report', 'google-calendar-events' ); ?></a></p> |
|
| 56 | + <p><?php _e('You can also download your information as a text file to attach, or simply view it below.', 'google-calendar-events'); ?></p> |
|
| 57 | + <p><a href="#" id="simcal-system-status-report-download" class="button button-primary"><?php _e('Download System Report', 'google-calendar-events'); ?></a></p> |
|
| 58 | 58 | </div> |
| 59 | 59 | <hr> |
| 60 | 60 | <?php |
| 61 | 61 | |
| 62 | 62 | global $wpdb; |
| 63 | - $wp_version = get_bloginfo( 'version' ); |
|
| 63 | + $wp_version = get_bloginfo('version'); |
|
| 64 | 64 | |
| 65 | 65 | $sections = array(); |
| 66 | 66 | $panels = array( |
| 67 | 67 | 'wordpress' => array( |
| 68 | - 'label' => __( 'WordPress Installation', 'google-calendar-events' ), |
|
| 68 | + 'label' => __('WordPress Installation', 'google-calendar-events'), |
|
| 69 | 69 | 'export' => 'WordPress Installation', |
| 70 | 70 | ), |
| 71 | 71 | 'theme' => array( |
| 72 | - 'label' => __( 'Active Theme', 'google-calendar-events' ), |
|
| 72 | + 'label' => __('Active Theme', 'google-calendar-events'), |
|
| 73 | 73 | 'export' => 'Active Theme', |
| 74 | 74 | ), |
| 75 | 75 | 'plugins' => array( |
| 76 | - 'label' => __( 'Active Plugins', 'google-calendar-events' ), |
|
| 76 | + 'label' => __('Active Plugins', 'google-calendar-events'), |
|
| 77 | 77 | 'export' => 'Active Plugins', |
| 78 | 78 | ), |
| 79 | 79 | 'server' => array( |
| 80 | - 'label' => __( 'Server Environment', 'google-calendar-events' ), |
|
| 80 | + 'label' => __('Server Environment', 'google-calendar-events'), |
|
| 81 | 81 | 'export' => 'Server Environment', |
| 82 | 82 | ), |
| 83 | 83 | 'client' => array( |
| 84 | - 'label' => __( 'Client Information', 'google-calendar-events' ), |
|
| 84 | + 'label' => __('Client Information', 'google-calendar-events'), |
|
| 85 | 85 | 'export' => 'Client Information', |
| 86 | 86 | ) |
| 87 | 87 | ); |
@@ -98,68 +98,68 @@ discard block |
||
| 98 | 98 | * ====================== |
| 99 | 99 | */ |
| 100 | 100 | |
| 101 | - $debug_mode = $script_debug = __( 'No', 'google-calendar-events' ); |
|
| 102 | - if ( defined( 'WP_DEBUG' ) ) { |
|
| 103 | - $debug_mode = true === WP_DEBUG ? __( 'Yes', 'google-calendar-events' ) : $debug_mode; |
|
| 101 | + $debug_mode = $script_debug = __('No', 'google-calendar-events'); |
|
| 102 | + if (defined('WP_DEBUG')) { |
|
| 103 | + $debug_mode = true === WP_DEBUG ? __('Yes', 'google-calendar-events') : $debug_mode; |
|
| 104 | 104 | } |
| 105 | - if ( defined( 'SCRIPT_DEBUG' ) ) { |
|
| 106 | - $script_debug = true === SCRIPT_DEBUG ? __( 'Yes', 'google-calendar-events' ) : $script_debug; |
|
| 105 | + if (defined('SCRIPT_DEBUG')) { |
|
| 106 | + $script_debug = true === SCRIPT_DEBUG ? __('Yes', 'google-calendar-events') : $script_debug; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $memory = $this->let_to_num( WP_MEMORY_LIMIT ); |
|
| 110 | - $memory_export = size_format( $memory ); |
|
| 111 | - if ( $memory < 67108864 ) { |
|
| 112 | - $memory = '<mark class="error">' . sprintf( __( '%1$s - It is recomendend to set memory to at least 64MB. See: <a href="%2$s" target="_blank">Increasing memory allocated to PHP</a>', 'google-calendar-events' ), $memory_export, 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP' ) . '</mark>'; |
|
| 109 | + $memory = $this->let_to_num(WP_MEMORY_LIMIT); |
|
| 110 | + $memory_export = size_format($memory); |
|
| 111 | + if ($memory < 67108864) { |
|
| 112 | + $memory = '<mark class="error">'.sprintf(__('%1$s - It is recomendend to set memory to at least 64MB. See: <a href="%2$s" target="_blank">Increasing memory allocated to PHP</a>', 'google-calendar-events'), $memory_export, 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP').'</mark>'; |
|
| 113 | 113 | } else { |
| 114 | - $memory = '<mark class="ok">' . $memory_export . '</mark>'; |
|
| 114 | + $memory = '<mark class="ok">'.$memory_export.'</mark>'; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $permalinks = get_option( 'permalink_structure' ); |
|
| 118 | - $permalinks = empty( $permalinks ) ? '/?' : $permalinks; |
|
| 117 | + $permalinks = get_option('permalink_structure'); |
|
| 118 | + $permalinks = empty($permalinks) ? '/?' : $permalinks; |
|
| 119 | 119 | |
| 120 | 120 | $is_multisite = is_multisite(); |
| 121 | 121 | |
| 122 | 122 | $sections['wordpress'] = array( |
| 123 | 123 | 'name' => array( |
| 124 | - 'label' => __( 'Site Name', 'google-calendar-events' ), |
|
| 124 | + 'label' => __('Site Name', 'google-calendar-events'), |
|
| 125 | 125 | 'label_export' => 'Site Name', |
| 126 | - 'result' => get_bloginfo( 'name' ), |
|
| 126 | + 'result' => get_bloginfo('name'), |
|
| 127 | 127 | ), |
| 128 | 128 | 'home_url' => array( |
| 129 | - 'label' => __( 'Home URL', 'google-calendar-events' ), |
|
| 129 | + 'label' => __('Home URL', 'google-calendar-events'), |
|
| 130 | 130 | 'label_export' => 'Home URL', |
| 131 | 131 | 'result' => home_url(), |
| 132 | 132 | ), |
| 133 | 133 | 'site_url' => array( |
| 134 | - 'label' => __( 'Site URL', 'google-calendar-events' ), |
|
| 134 | + 'label' => __('Site URL', 'google-calendar-events'), |
|
| 135 | 135 | 'label_export' => 'Site URL', |
| 136 | 136 | 'result' => site_url(), |
| 137 | 137 | ), |
| 138 | 138 | 'version' => array( |
| 139 | - 'label' => __( 'Version', 'google-calendar-events' ), |
|
| 139 | + 'label' => __('Version', 'google-calendar-events'), |
|
| 140 | 140 | 'label_export' => 'Version', |
| 141 | 141 | 'result' => $wp_version, |
| 142 | 142 | ), |
| 143 | 143 | 'locale' => array( |
| 144 | - 'label' => __( 'Locale', 'google-calendar-events' ), |
|
| 144 | + 'label' => __('Locale', 'google-calendar-events'), |
|
| 145 | 145 | 'label_export' => 'Locale', |
| 146 | 146 | 'result' => get_locale(), |
| 147 | 147 | ), |
| 148 | 148 | 'wp_timezone' => array( |
| 149 | - 'label' => __( 'Timezone', 'google-calendar-events' ), |
|
| 149 | + 'label' => __('Timezone', 'google-calendar-events'), |
|
| 150 | 150 | 'label_export' => 'Timezone', |
| 151 | 151 | 'result' => simcal_get_wp_timezone(), |
| 152 | 152 | ), |
| 153 | 153 | 'multisite' => array( |
| 154 | - 'label' => __( 'Multisite', 'google-calendar-events' ), |
|
| 154 | + 'label' => __('Multisite', 'google-calendar-events'), |
|
| 155 | 155 | 'label_export' => 'Multisite', |
| 156 | - 'result' => $is_multisite ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
|
| 156 | + 'result' => $is_multisite ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), |
|
| 157 | 157 | 'result_export' => $is_multisite ? 'Yes' : 'No' |
| 158 | 158 | ), |
| 159 | 159 | 'permalink' => array( |
| 160 | - 'label' => __( 'Permalinks', 'google-calendar-events' ), |
|
| 160 | + 'label' => __('Permalinks', 'google-calendar-events'), |
|
| 161 | 161 | 'label_export' => 'Permalinks', |
| 162 | - 'result' => '<code>' . $permalinks . '</code>', |
|
| 162 | + 'result' => '<code>'.$permalinks.'</code>', |
|
| 163 | 163 | 'result_export' => $permalinks, |
| 164 | 164 | ), |
| 165 | 165 | 'memory_limit' => array( |
@@ -182,86 +182,86 @@ discard block |
||
| 182 | 182 | * ============ |
| 183 | 183 | */ |
| 184 | 184 | |
| 185 | - include_once ABSPATH . 'wp-admin/includes/theme-install.php'; |
|
| 185 | + include_once ABSPATH.'wp-admin/includes/theme-install.php'; |
|
| 186 | 186 | |
| 187 | - if ( version_compare( $wp_version, '3.4', '<' ) ) { |
|
| 188 | - $active_theme = get_theme_data( get_stylesheet_directory() . '/style.css' ); |
|
| 189 | - $theme_name = '<a href="' . $active_theme['URI'] . '" target="_blank">' . $active_theme['Name'] . '</a>'; |
|
| 187 | + if (version_compare($wp_version, '3.4', '<')) { |
|
| 188 | + $active_theme = get_theme_data(get_stylesheet_directory().'/style.css'); |
|
| 189 | + $theme_name = '<a href="'.$active_theme['URI'].'" target="_blank">'.$active_theme['Name'].'</a>'; |
|
| 190 | 190 | $theme_version = $active_theme['Version']; |
| 191 | - $theme_author = '<a href="' . $active_theme['AuthorURI'] . '" target="_blank">' . $active_theme['Author'] . '</a>'; |
|
| 192 | - $theme_export = $active_theme['Name'] . ' - ' . $theme_version; |
|
| 191 | + $theme_author = '<a href="'.$active_theme['AuthorURI'].'" target="_blank">'.$active_theme['Author'].'</a>'; |
|
| 192 | + $theme_export = $active_theme['Name'].' - '.$theme_version; |
|
| 193 | 193 | } else { |
| 194 | 194 | $active_theme = wp_get_theme(); |
| 195 | - $theme_name = '<a href="' . $active_theme->ThemeURI . '" target="_blank">' . $active_theme->Name . '</a>'; |
|
| 195 | + $theme_name = '<a href="'.$active_theme->ThemeURI.'" target="_blank">'.$active_theme->Name.'</a>'; |
|
| 196 | 196 | $theme_version = $active_theme->Version; |
| 197 | 197 | $theme_author = $active_theme->Author; |
| 198 | - $theme_export = $active_theme->Name . ' - ' . $theme_version; |
|
| 198 | + $theme_export = $active_theme->Name.' - '.$theme_version; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | $theme_update_version = $theme_version; |
| 202 | 202 | |
| 203 | - $api = themes_api( 'theme_information', array( |
|
| 203 | + $api = themes_api('theme_information', array( |
|
| 204 | 204 | 'slug' => get_template(), |
| 205 | - 'fields' => array( 'sections' => false, 'tags' => false ), |
|
| 206 | - ) ); |
|
| 207 | - if ( $api && ! is_wp_error( $api ) ) { |
|
| 205 | + 'fields' => array('sections' => false, 'tags' => false), |
|
| 206 | + )); |
|
| 207 | + if ($api && ! is_wp_error($api)) { |
|
| 208 | 208 | $theme_update_version = $api->version; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if ( version_compare( $theme_version, $theme_update_version, '<' ) ) { |
|
| 212 | - $theme_version = '<mark class="error">' . $theme_version . ' (' . sprintf( __( '%s is available', 'google-calendar-events' ), esc_html( $theme_update_version ) ) . ')</mark>'; |
|
| 211 | + if (version_compare($theme_version, $theme_update_version, '<')) { |
|
| 212 | + $theme_version = '<mark class="error">'.$theme_version.' ('.sprintf(__('%s is available', 'google-calendar-events'), esc_html($theme_update_version)).')</mark>'; |
|
| 213 | 213 | } else { |
| 214 | - $theme_version = '<mark class="ok">' . $theme_version . '</mark>'; |
|
| 214 | + $theme_version = '<mark class="ok">'.$theme_version.'</mark>'; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | $theme = '<dl>'; |
| 218 | - $theme .= '<dt>' . __( 'Name', 'google-calendar-events' ) . '</dt>'; |
|
| 219 | - $theme .= '<dd>' . $theme_name . '</dd>'; |
|
| 220 | - $theme .= '<dt>' . __( 'Author', 'google-calendar-events' ) . '</dt>'; |
|
| 221 | - $theme .= '<dd>' . $theme_author . '</dd>'; |
|
| 222 | - $theme .= '<dt>' . __( 'Version', 'google-calendar-events' ) . '</dt>'; |
|
| 223 | - $theme .= '<dd>' . $theme_version . '</dd>'; |
|
| 218 | + $theme .= '<dt>'.__('Name', 'google-calendar-events').'</dt>'; |
|
| 219 | + $theme .= '<dd>'.$theme_name.'</dd>'; |
|
| 220 | + $theme .= '<dt>'.__('Author', 'google-calendar-events').'</dt>'; |
|
| 221 | + $theme .= '<dd>'.$theme_author.'</dd>'; |
|
| 222 | + $theme .= '<dt>'.__('Version', 'google-calendar-events').'</dt>'; |
|
| 223 | + $theme .= '<dd>'.$theme_version.'</dd>'; |
|
| 224 | 224 | $theme .= '</dl>'; |
| 225 | 225 | |
| 226 | 226 | $is_child_theme = is_child_theme(); |
| 227 | 227 | $parent_theme = $parent_theme_export = '-'; |
| 228 | 228 | |
| 229 | - if ( $is_child_theme ) { |
|
| 230 | - if ( version_compare( $wp_version, '3.4', '<' ) ) { |
|
| 229 | + if ($is_child_theme) { |
|
| 230 | + if (version_compare($wp_version, '3.4', '<')) { |
|
| 231 | 231 | |
| 232 | 232 | $parent_theme = $parent_theme_export = $active_theme['Template']; |
| 233 | 233 | |
| 234 | 234 | } else { |
| 235 | 235 | |
| 236 | - $parent = wp_get_theme( $active_theme->Template ); |
|
| 236 | + $parent = wp_get_theme($active_theme->Template); |
|
| 237 | 237 | $parent_theme = '<dl>'; |
| 238 | - $parent_theme .= '<dt>' . __( 'Name', 'google-calendar-events' ) . '</dt>'; |
|
| 239 | - $parent_theme .= '<dd>' . $parent->Name . '</dd>'; |
|
| 240 | - $parent_theme .= '<dt>' . __( 'Author', 'google-calendar-events' ) . '</dt>'; |
|
| 241 | - $parent_theme .= '<dd>' . $parent->Author . '</dd>'; |
|
| 242 | - $parent_theme .= '<dt>' . __( 'Version', 'google-calendar-events' ) . '</dt>'; |
|
| 243 | - $parent_theme .= '<dd>' . $parent->Version . '</dd>'; |
|
| 238 | + $parent_theme .= '<dt>'.__('Name', 'google-calendar-events').'</dt>'; |
|
| 239 | + $parent_theme .= '<dd>'.$parent->Name.'</dd>'; |
|
| 240 | + $parent_theme .= '<dt>'.__('Author', 'google-calendar-events').'</dt>'; |
|
| 241 | + $parent_theme .= '<dd>'.$parent->Author.'</dd>'; |
|
| 242 | + $parent_theme .= '<dt>'.__('Version', 'google-calendar-events').'</dt>'; |
|
| 243 | + $parent_theme .= '<dd>'.$parent->Version.'</dd>'; |
|
| 244 | 244 | $parent_theme .= '</dl>'; |
| 245 | 245 | |
| 246 | - $parent_theme_export = strip_tags( $parent->Name ) . ' - ' . $parent->Version; |
|
| 246 | + $parent_theme_export = strip_tags($parent->Name).' - '.$parent->Version; |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | $sections['theme'] = array( |
| 251 | 251 | 'theme' => array( |
| 252 | - 'label' => __( 'Theme Information', 'google-calendar-events' ), |
|
| 252 | + 'label' => __('Theme Information', 'google-calendar-events'), |
|
| 253 | 253 | 'label_export' => 'Theme', |
| 254 | 254 | 'result' => $theme, |
| 255 | 255 | 'result_export' => $theme_export, |
| 256 | 256 | ), |
| 257 | 257 | 'theme_child' => array( |
| 258 | - 'label' => __( 'Child Theme', 'google-calendar-events' ), |
|
| 258 | + 'label' => __('Child Theme', 'google-calendar-events'), |
|
| 259 | 259 | 'label_export' => 'Child Theme', |
| 260 | - 'result' => $is_child_theme ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
|
| 260 | + 'result' => $is_child_theme ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), |
|
| 261 | 261 | 'result_export' => $is_child_theme ? 'Yes' : 'No', |
| 262 | 262 | ), |
| 263 | 263 | 'theme_parent' => array( |
| 264 | - 'label' => __( 'Parent Theme', 'google-calendar-events' ), |
|
| 264 | + 'label' => __('Parent Theme', 'google-calendar-events'), |
|
| 265 | 265 | 'label_export' => 'Parent Theme', |
| 266 | 266 | 'result' => $parent_theme, |
| 267 | 267 | 'result_export' => $parent_theme_export, |
@@ -273,61 +273,61 @@ discard block |
||
| 273 | 273 | * ============== |
| 274 | 274 | */ |
| 275 | 275 | |
| 276 | - include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
|
| 276 | + include_once ABSPATH.'wp-admin/includes/plugin-install.php'; |
|
| 277 | 277 | |
| 278 | - $active_plugins = (array) get_option( 'active_plugins', array() ); |
|
| 279 | - if ( is_multisite() ) { |
|
| 280 | - $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) ); |
|
| 278 | + $active_plugins = (array) get_option('active_plugins', array()); |
|
| 279 | + if (is_multisite()) { |
|
| 280 | + $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array())); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - foreach ( $active_plugins as $plugin ) { |
|
| 283 | + foreach ($active_plugins as $plugin) { |
|
| 284 | 284 | |
| 285 | - $plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
|
| 285 | + $plugin_data = @get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin); |
|
| 286 | 286 | |
| 287 | - if ( ! empty( $plugin_data['Name'] ) ) { |
|
| 287 | + if ( ! empty($plugin_data['Name'])) { |
|
| 288 | 288 | |
| 289 | 289 | $plugin_name = $plugin_data['Title']; |
| 290 | 290 | $plugin_author = $plugin_data['Author']; |
| 291 | 291 | $plugin_version = $plugin_update_version = $plugin_data['Version']; |
| 292 | 292 | |
| 293 | 293 | // Afraid that querying many plugins may risk a timeout. |
| 294 | - if ( count( $active_plugins ) <= 10 ) { |
|
| 295 | - $api = plugins_api( 'plugin_information', array( |
|
| 294 | + if (count($active_plugins) <= 10) { |
|
| 295 | + $api = plugins_api('plugin_information', array( |
|
| 296 | 296 | 'slug' => $plugin_data['Name'], |
| 297 | 297 | 'fields' => array( |
| 298 | 298 | 'version' => true, |
| 299 | 299 | ), |
| 300 | - ) ); |
|
| 301 | - if ( $api && ! is_wp_error( $api ) ) { |
|
| 302 | - if ( ! empty( $api->version ) ) { |
|
| 300 | + )); |
|
| 301 | + if ($api && ! is_wp_error($api)) { |
|
| 302 | + if ( ! empty($api->version)) { |
|
| 303 | 303 | $plugin_update_version = $api->version; |
| 304 | - if ( version_compare( $plugin_version, $plugin_update_version, '<' ) ) { |
|
| 305 | - $plugin_version = '<mark class="error">' . $plugin_version . ' (' . sprintf( __( '%s is available', 'google-calendar-events' ), esc_html( $plugin_update_version ) ) . ')</mark>'; |
|
| 304 | + if (version_compare($plugin_version, $plugin_update_version, '<')) { |
|
| 305 | + $plugin_version = '<mark class="error">'.$plugin_version.' ('.sprintf(__('%s is available', 'google-calendar-events'), esc_html($plugin_update_version)).')</mark>'; |
|
| 306 | 306 | } else { |
| 307 | - $plugin_version = '<mark class="ok">' . $plugin_version . '</mark>'; |
|
| 307 | + $plugin_version = '<mark class="ok">'.$plugin_version.'</mark>'; |
|
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | $plugin = '<dl>'; |
| 314 | - $plugin .= '<dt>' . __( 'Author', 'google-calendar-events' ) . '</dt>'; |
|
| 315 | - $plugin .= '<dd>' . $plugin_author . '</dd>'; |
|
| 316 | - $plugin .= '<dt>' . __( 'Version', 'google-calendar-events' ) . '</dt>'; |
|
| 317 | - $plugin .= '<dd>' . $plugin_version . '</dd>'; |
|
| 314 | + $plugin .= '<dt>'.__('Author', 'google-calendar-events').'</dt>'; |
|
| 315 | + $plugin .= '<dd>'.$plugin_author.'</dd>'; |
|
| 316 | + $plugin .= '<dt>'.__('Version', 'google-calendar-events').'</dt>'; |
|
| 317 | + $plugin .= '<dd>'.$plugin_version.'</dd>'; |
|
| 318 | 318 | $plugin .= '</dl>'; |
| 319 | 319 | |
| 320 | - $sections['plugins'][ sanitize_key( strip_tags( $plugin_name ) ) ] = array( |
|
| 320 | + $sections['plugins'][sanitize_key(strip_tags($plugin_name))] = array( |
|
| 321 | 321 | 'label' => $plugin_name, |
| 322 | - 'label_export' => strip_tags( $plugin_data['Title'] ), |
|
| 322 | + 'label_export' => strip_tags($plugin_data['Title']), |
|
| 323 | 323 | 'result' => $plugin, |
| 324 | 324 | 'result_export' => $plugin_data['Version'], |
| 325 | 325 | ); |
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - if ( isset( $sections['plugins'] ) ) { |
|
| 330 | - rsort( $sections['plugins'] ); |
|
| 329 | + if (isset($sections['plugins'])) { |
|
| 330 | + rsort($sections['plugins']); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -335,54 +335,54 @@ discard block |
||
| 335 | 335 | * ================== |
| 336 | 336 | */ |
| 337 | 337 | |
| 338 | - if ( version_compare( PHP_VERSION, '5.6', '<' ) ) { |
|
| 339 | - $php = '<mark>' . PHP_VERSION . ' - ' . |
|
| 340 | - __( 'WordPress.org recommends upgrading to PHP 5.6 or higher for better security.', 'google-calendar-events' ) . |
|
| 341 | - ' <a href="https://wordpress.org/about/requirements/" target="_blank">' . __( 'Read more.', 'google-calendar-events' ) . '</a>' . |
|
| 338 | + if (version_compare(PHP_VERSION, '5.6', '<')) { |
|
| 339 | + $php = '<mark>'.PHP_VERSION.' - '. |
|
| 340 | + __('WordPress.org recommends upgrading to PHP 5.6 or higher for better security.', 'google-calendar-events'). |
|
| 341 | + ' <a href="https://wordpress.org/about/requirements/" target="_blank">'.__('Read more.', 'google-calendar-events').'</a>'. |
|
| 342 | 342 | '</mark>'; |
| 343 | 343 | } else { |
| 344 | - $php = '<mark class="ok">' . PHP_VERSION . '</mark>'; |
|
| 344 | + $php = '<mark class="ok">'.PHP_VERSION.'</mark>'; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - if ( $wpdb->use_mysqli ) { |
|
| 348 | - $mysql = @mysqli_get_server_info( $wpdb->dbh ); |
|
| 347 | + if ($wpdb->use_mysqli) { |
|
| 348 | + $mysql = @mysqli_get_server_info($wpdb->dbh); |
|
| 349 | 349 | } else { |
| 350 | 350 | $mysql = @mysql_get_server_info(); |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | $host = $_SERVER['SERVER_SOFTWARE']; |
| 354 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 354 | + if (defined('WPE_APIKEY')) { |
|
| 355 | 355 | $host .= ' (WP Engine)'; |
| 356 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
| 356 | + } elseif (defined('PAGELYBIN')) { |
|
| 357 | 357 | $host .= ' (Pagely)'; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | $default_timezone = $server_timezone_export = date_default_timezone_get(); |
| 361 | - if ( 'UTC' !== $default_timezone ) { |
|
| 362 | - $server_timezone = '<mark class="error">' . sprintf( __( 'Server default timezone is %s - it should be UTC', 'google-calendar-events' ), $default_timezone ) . '</mark>'; |
|
| 361 | + if ('UTC' !== $default_timezone) { |
|
| 362 | + $server_timezone = '<mark class="error">'.sprintf(__('Server default timezone is %s - it should be UTC', 'google-calendar-events'), $default_timezone).'</mark>'; |
|
| 363 | 363 | } else { |
| 364 | 364 | $server_timezone = '<mark class="ok">UTC</mark>'; |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | // WP Remote POST test. |
| 368 | - $response = wp_safe_remote_post( 'https://www.paypal.com/cgi-bin/webscr', array( |
|
| 368 | + $response = wp_safe_remote_post('https://www.paypal.com/cgi-bin/webscr', array( |
|
| 369 | 369 | 'timeout' => 60, |
| 370 | 370 | 'body' => array( |
| 371 | 371 | 'cmd' => '_notify-validate', |
| 372 | 372 | ), |
| 373 | - ) ); |
|
| 374 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
| 373 | + )); |
|
| 374 | + if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { |
|
| 375 | 375 | $wp_post_export = 'Yes'; |
| 376 | - $wp_post = '<mark class="ok">' . __( 'Yes', 'google-calendar-events' ) . '</mark>'; |
|
| 376 | + $wp_post = '<mark class="ok">'.__('Yes', 'google-calendar-events').'</mark>'; |
|
| 377 | 377 | } else { |
| 378 | 378 | $wp_post_export = 'No'; |
| 379 | - $wp_post = '<mark class="error">' . __( 'No', 'google-calendar-events' ); |
|
| 380 | - if ( is_wp_error( $response ) ) { |
|
| 381 | - $error = ' (' . $response->get_error_message() . ')'; |
|
| 379 | + $wp_post = '<mark class="error">'.__('No', 'google-calendar-events'); |
|
| 380 | + if (is_wp_error($response)) { |
|
| 381 | + $error = ' ('.$response->get_error_message().')'; |
|
| 382 | 382 | $wp_post .= $error; |
| 383 | 383 | $wp_post_export .= $error; |
| 384 | 384 | } else { |
| 385 | - $error = ' (' . $response['response']['code'] . ')'; |
|
| 385 | + $error = ' ('.$response['response']['code'].')'; |
|
| 386 | 386 | $wp_post .= $error; |
| 387 | 387 | $wp_post_export .= $error; |
| 388 | 388 | } |
@@ -390,65 +390,65 @@ discard block |
||
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | // WP Remote GET test. |
| 393 | - $response = wp_safe_remote_get( get_home_url( '/?p=1' ) ); |
|
| 394 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
| 393 | + $response = wp_safe_remote_get(get_home_url('/?p=1')); |
|
| 394 | + if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { |
|
| 395 | 395 | $wp_get_export = 'Yes'; |
| 396 | - $wp_get = '<mark class="ok">' . __( 'Yes', 'google-calendar-events' ) . '</mark>'; |
|
| 396 | + $wp_get = '<mark class="ok">'.__('Yes', 'google-calendar-events').'</mark>'; |
|
| 397 | 397 | } else { |
| 398 | 398 | $wp_get_export = 'No'; |
| 399 | - $wp_get = '<mark class="error">' . __( 'No', 'google-calendar-events' ); |
|
| 400 | - if ( is_wp_error( $response ) ) { |
|
| 401 | - $error = ' (' . $response->get_error_message() . ')'; |
|
| 399 | + $wp_get = '<mark class="error">'.__('No', 'google-calendar-events'); |
|
| 400 | + if (is_wp_error($response)) { |
|
| 401 | + $error = ' ('.$response->get_error_message().')'; |
|
| 402 | 402 | $wp_get .= $error; |
| 403 | 403 | $wp_get_export .= $error; |
| 404 | 404 | } else { |
| 405 | - $error = ' (' . $response['response']['code'] . ')'; |
|
| 405 | + $error = ' ('.$response['response']['code'].')'; |
|
| 406 | 406 | $wp_get .= $error; |
| 407 | 407 | $wp_get_export .= $error; |
| 408 | 408 | } |
| 409 | 409 | $wp_get .= '</mark>'; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - $php_memory_limit = ini_get( 'memory_limit' ); |
|
| 413 | - $php_max_upload_filesize = ini_get( 'upload_max_filesize' ); |
|
| 414 | - $php_post_max_size = ini_get( 'post_max_size' ); |
|
| 415 | - $php_max_execution_time = ini_get( 'max_execution_time' ); |
|
| 416 | - $php_max_input_vars = ini_get( 'max_input_vars' ); |
|
| 412 | + $php_memory_limit = ini_get('memory_limit'); |
|
| 413 | + $php_max_upload_filesize = ini_get('upload_max_filesize'); |
|
| 414 | + $php_post_max_size = ini_get('post_max_size'); |
|
| 415 | + $php_max_execution_time = ini_get('max_execution_time'); |
|
| 416 | + $php_max_input_vars = ini_get('max_input_vars'); |
|
| 417 | 417 | |
| 418 | 418 | $curl_info = ''; |
| 419 | 419 | |
| 420 | - if ( function_exists( 'curl_version' ) ) { |
|
| 420 | + if (function_exists('curl_version')) { |
|
| 421 | 421 | $curl_info = curl_version(); |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | $sections['server'] = array( |
| 425 | 425 | 'host' => array( |
| 426 | - 'label' => __( 'Web Server', 'google-calendar-events' ), |
|
| 426 | + 'label' => __('Web Server', 'google-calendar-events'), |
|
| 427 | 427 | 'label_export' => 'Web Server', |
| 428 | 428 | 'result' => $host, |
| 429 | 429 | ), |
| 430 | 430 | 'php_version' => array( |
| 431 | - 'label' => __( 'PHP Version', 'google-calendar-events' ), |
|
| 431 | + 'label' => __('PHP Version', 'google-calendar-events'), |
|
| 432 | 432 | 'label_export' => 'PHP Version', |
| 433 | 433 | 'result' => $php, |
| 434 | 434 | 'result_export' => PHP_VERSION, |
| 435 | 435 | ), |
| 436 | 436 | 'mysql_version' => array( |
| 437 | - 'label' => __( 'MySQL Version', 'google-calendar-events' ), |
|
| 437 | + 'label' => __('MySQL Version', 'google-calendar-events'), |
|
| 438 | 438 | 'label_export' => 'MySQL Version', |
| 439 | - 'result' => version_compare( $mysql, '5.5', '>' ) ? '<mark class="ok">' . $mysql . '</mark>' : $mysql, |
|
| 439 | + 'result' => version_compare($mysql, '5.5', '>') ? '<mark class="ok">'.$mysql.'</mark>' : $mysql, |
|
| 440 | 440 | 'result_export' => $mysql, |
| 441 | 441 | ), |
| 442 | 442 | 'server_timezone' => array( |
| 443 | - 'label' => __( 'Server Timezone', 'google-calendar-events' ), |
|
| 443 | + 'label' => __('Server Timezone', 'google-calendar-events'), |
|
| 444 | 444 | 'label_export' => 'Server Timezone', |
| 445 | 445 | 'result' => $server_timezone, |
| 446 | 446 | 'result_export' => $server_timezone_export, |
| 447 | 447 | ), |
| 448 | 448 | 'display_errors' => array( |
| 449 | 449 | 'label' => 'Display Errors', |
| 450 | - 'result' => ( ini_get( 'display_errors' ) ) ? __( 'Yes', 'google-calendar-events' ) . ' (' . ini_get( 'display_errors' ) . ')' : '-', |
|
| 451 | - 'result_export' => ( ini_get( 'display_errors' ) ) ? 'Yes' : 'No', |
|
| 450 | + 'result' => (ini_get('display_errors')) ? __('Yes', 'google-calendar-events').' ('.ini_get('display_errors').')' : '-', |
|
| 451 | + 'result_export' => (ini_get('display_errors')) ? 'Yes' : 'No', |
|
| 452 | 452 | ), |
| 453 | 453 | 'php_memory_limit' => array( |
| 454 | 454 | 'label' => 'Memory Limit', |
@@ -472,23 +472,23 @@ discard block |
||
| 472 | 472 | ), |
| 473 | 473 | 'fsockopen' => array( |
| 474 | 474 | 'label' => 'fsockopen', |
| 475 | - 'result' => function_exists( 'fsockopen' ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
|
| 476 | - 'result_export' => function_exists( 'fsockopen' ) ? 'Yes' : 'No', |
|
| 475 | + 'result' => function_exists('fsockopen') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), |
|
| 476 | + 'result_export' => function_exists('fsockopen') ? 'Yes' : 'No', |
|
| 477 | 477 | ), |
| 478 | 478 | 'curl_init' => array( |
| 479 | 479 | 'label' => 'cURL', |
| 480 | - 'result' => ! empty( $curl_info ) ? $curl_info['version'] . ', ' . $curl_info['ssl_version'] : __( 'No version found.', 'google-calendar-events' ), |
|
| 481 | - 'result_export' => ! empty( $curl_info ) ? $curl_info['version'] . ', ' . $curl_info['ssl_version'] : 'No version found.', |
|
| 480 | + 'result' => ! empty($curl_info) ? $curl_info['version'].', '.$curl_info['ssl_version'] : __('No version found.', 'google-calendar-events'), |
|
| 481 | + 'result_export' => ! empty($curl_info) ? $curl_info['version'].', '.$curl_info['ssl_version'] : 'No version found.', |
|
| 482 | 482 | ), |
| 483 | 483 | 'soap' => array( |
| 484 | 484 | 'label' => 'SOAP', |
| 485 | - 'result' => class_exists( 'SoapClient' ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
|
| 486 | - 'result_export' => class_exists( 'SoapClient' ) ? 'Yes' : 'No', |
|
| 485 | + 'result' => class_exists('SoapClient') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), |
|
| 486 | + 'result_export' => class_exists('SoapClient') ? 'Yes' : 'No', |
|
| 487 | 487 | ), |
| 488 | 488 | 'suhosin' => array( |
| 489 | 489 | 'label' => 'SUHOSIN', |
| 490 | - 'result' => extension_loaded( 'suhosin' ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
|
| 491 | - 'result_export' => extension_loaded( 'suhosin' ) ? 'Yes' : 'No', |
|
| 490 | + 'result' => extension_loaded('suhosin') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), |
|
| 491 | + 'result_export' => extension_loaded('suhosin') ? 'Yes' : 'No', |
|
| 492 | 492 | ), |
| 493 | 493 | 'wp_remote_post' => array( |
| 494 | 494 | 'label' => 'WP Remote POST', |
@@ -510,26 +510,26 @@ discard block |
||
| 510 | 510 | $user_client = new \SimpleCalendar\Browser(); |
| 511 | 511 | |
| 512 | 512 | $browser = '<dl>'; |
| 513 | - $browser .= '<dt>' . __( 'Name:', 'google-calendar-events' ) . '</dt>'; |
|
| 514 | - $browser .= '<dd>' . $user_client->getBrowser() . '</dd>'; |
|
| 515 | - $browser .= '<dt>' . __( 'Version:', 'google-calendar-events' ) . '</dt>'; |
|
| 516 | - $browser .= '<dd>' . $user_client->getVersion() . '</dd>'; |
|
| 517 | - $browser .= '<dt>' . __( 'User Agent:', 'google-calendar-events' ) . '</dt>'; |
|
| 518 | - $browser .= '<dd>' . $user_client->getUserAgent() . '</dd>'; |
|
| 519 | - $browser .= '<dt>' . __( 'Platform:', 'google-calendar-events' ) . '</dt>'; |
|
| 520 | - $browser .= '<dd>' . $user_client->getPlatform() . '</dd>'; |
|
| 513 | + $browser .= '<dt>'.__('Name:', 'google-calendar-events').'</dt>'; |
|
| 514 | + $browser .= '<dd>'.$user_client->getBrowser().'</dd>'; |
|
| 515 | + $browser .= '<dt>'.__('Version:', 'google-calendar-events').'</dt>'; |
|
| 516 | + $browser .= '<dd>'.$user_client->getVersion().'</dd>'; |
|
| 517 | + $browser .= '<dt>'.__('User Agent:', 'google-calendar-events').'</dt>'; |
|
| 518 | + $browser .= '<dd>'.$user_client->getUserAgent().'</dd>'; |
|
| 519 | + $browser .= '<dt>'.__('Platform:', 'google-calendar-events').'</dt>'; |
|
| 520 | + $browser .= '<dd>'.$user_client->getPlatform().'</dd>'; |
|
| 521 | 521 | $browser .= '</dl>'; |
| 522 | 522 | |
| 523 | - $browser_export = $user_client->getBrowser() . ' ' . $user_client->getVersion() . ' (' . $user_client->getPlatform() . ')'; |
|
| 523 | + $browser_export = $user_client->getBrowser().' '.$user_client->getVersion().' ('.$user_client->getPlatform().')'; |
|
| 524 | 524 | |
| 525 | 525 | $sections['client'] = array( |
| 526 | 526 | 'user_ip' => array( |
| 527 | - 'label' => __( 'IP Address', 'google-calendar-events' ), |
|
| 527 | + 'label' => __('IP Address', 'google-calendar-events'), |
|
| 528 | 528 | 'label_export' => 'IP Address', |
| 529 | 529 | 'result' => $_SERVER['SERVER_ADDR'], |
| 530 | 530 | ), |
| 531 | 531 | 'browser' => array( |
| 532 | - 'label' => __( 'Browser', 'google-calendar-events' ), |
|
| 532 | + 'label' => __('Browser', 'google-calendar-events'), |
|
| 533 | 533 | 'result' => $browser, |
| 534 | 534 | 'result_export' => $browser_export, |
| 535 | 535 | ) |
@@ -540,12 +540,12 @@ discard block |
||
| 540 | 540 | * ============ |
| 541 | 541 | */ |
| 542 | 542 | |
| 543 | - $panels = apply_filters( 'simcal_system_status_report_panels', $panels ); |
|
| 544 | - $sections = apply_filters( 'simcal_system_status_report_sections', $sections ); |
|
| 543 | + $panels = apply_filters('simcal_system_status_report_panels', $panels); |
|
| 544 | + $sections = apply_filters('simcal_system_status_report_sections', $sections); |
|
| 545 | 545 | |
| 546 | - foreach ( $panels as $panel => $v ) : |
|
| 546 | + foreach ($panels as $panel => $v) : |
|
| 547 | 547 | |
| 548 | - if ( isset( $sections[ $panel ] ) ) : |
|
| 548 | + if (isset($sections[$panel])) : |
|
| 549 | 549 | |
| 550 | 550 | ?> |
| 551 | 551 | <table class="widefat simcal-system-status-report-panel"> |
@@ -555,15 +555,15 @@ discard block |
||
| 555 | 555 | </tr> |
| 556 | 556 | </thead> |
| 557 | 557 | <tbody> |
| 558 | - <?php foreach ( $sections[ $panel ] as $row => $cell ) : ?> |
|
| 558 | + <?php foreach ($sections[$panel] as $row => $cell) : ?> |
|
| 559 | 559 | <tr> |
| 560 | 560 | <?php |
| 561 | - $label_export = isset( $cell['label_export'] ) ? $cell['label_export'] : $cell['label']; |
|
| 562 | - $result_export = isset( $cell['result_export'] ) ? $cell['result_export'] : $cell['result']; |
|
| 561 | + $label_export = isset($cell['label_export']) ? $cell['label_export'] : $cell['label']; |
|
| 562 | + $result_export = isset($cell['result_export']) ? $cell['result_export'] : $cell['result']; |
|
| 563 | 563 | ?> |
| 564 | - <td class="tooltip"><?php echo isset( $cell['tooltip'] ) ? ' <i class="simcal-icon-help simcal-help-tip" data-tip="' . $cell['tooltip'] . '"></i> ' : ''; ?></td> |
|
| 565 | - <td class="label" data-export="<?php echo trim( $label_export ); ?>"><?php echo $cell['label']; ?></td> |
|
| 566 | - <td class="result" data-export="<?php echo trim( $result_export ); ?>"><?php echo $cell['result']; ?></td> |
|
| 564 | + <td class="tooltip"><?php echo isset($cell['tooltip']) ? ' <i class="simcal-icon-help simcal-help-tip" data-tip="'.$cell['tooltip'].'"></i> ' : ''; ?></td> |
|
| 565 | + <td class="label" data-export="<?php echo trim($label_export); ?>"><?php echo $cell['label']; ?></td> |
|
| 566 | + <td class="result" data-export="<?php echo trim($result_export); ?>"><?php echo $cell['result']; ?></td> |
|
| 567 | 567 | </tr> |
| 568 | 568 | <?php endforeach; ?> |
| 569 | 569 | </tbody> |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | jQuery( '#simcal-system-status-report-download' ).on( 'click', function() { |
| 642 | 642 | var file = new Blob( [ report ], { type: 'text/plain' } ); |
| 643 | 643 | jQuery( this ).attr( 'href', URL.createObjectURL( file ) ); |
| 644 | - jQuery( this ).attr( 'download', '<?php echo sanitize_title( str_replace( array( 'http://', 'https://' ), '', get_bloginfo( 'url' ) ) . '-system-report-' . date( 'Y-m-d', time() ) ); ?>' ); |
|
| 644 | + jQuery( this ).attr( 'download', '<?php echo sanitize_title(str_replace(array('http://', 'https://'), '', get_bloginfo('url')).'-system-report-'.date('Y-m-d', time())); ?>' ); |
|
| 645 | 645 | } ); |
| 646 | 646 | |
| 647 | 647 | </script> |
@@ -661,13 +661,13 @@ discard block |
||
| 661 | 661 | * |
| 662 | 662 | * @return int|double|string |
| 663 | 663 | */ |
| 664 | - private function let_to_num( $size ) { |
|
| 664 | + private function let_to_num($size) { |
|
| 665 | 665 | |
| 666 | - $l = substr( $size, -1 ); |
|
| 667 | - $ret = substr( $size, 0, -1 ); |
|
| 666 | + $l = substr($size, -1); |
|
| 667 | + $ret = substr($size, 0, -1); |
|
| 668 | 668 | |
| 669 | 669 | // Note: do not insert break or default in this switch loop. |
| 670 | - switch ( strtoupper( $l ) ) { |
|
| 670 | + switch (strtoupper($l)) { |
|
| 671 | 671 | case 'P': |
| 672 | 672 | $ret *= 1024; |
| 673 | 673 | // no break |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | $ret *= 1024; |
| 682 | 682 | // no break |
| 683 | 683 | case 'K': |
| 684 | - $ret *= 1024;; |
|
| 684 | + $ret *= 1024; ; |
|
| 685 | 685 | // no break |
| 686 | 686 | } |
| 687 | 687 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | use SimpleCalendar\Admin\Notice; |
| 11 | 11 | use SimpleCalendar\Feeds\Google; |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param string $google_api_key |
| 55 | 55 | * @param string $google_calendar_id |
| 56 | 56 | */ |
| 57 | - public function __construct( Google $feed, $google_api_key, $google_calendar_id ) { |
|
| 57 | + public function __construct(Google $feed, $google_api_key, $google_calendar_id) { |
|
| 58 | 58 | |
| 59 | 59 | $this->feed = $feed; |
| 60 | 60 | $this->google_api_key = $google_api_key; |
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $screen = simcal_is_admin_screen(); |
| 64 | 64 | |
| 65 | - if ( 'calendar' == $screen ) { |
|
| 66 | - $this->test_api_key_connection( $this->google_calendar_id ); |
|
| 67 | - add_filter( 'simcal_settings_meta_tabs_li', array( $this, 'add_settings_meta_tab_li' ), 10, 1 ); |
|
| 68 | - add_action( 'simcal_settings_meta_panels', array( $this, 'add_settings_meta_panel' ), 10, 1 ); |
|
| 65 | + if ('calendar' == $screen) { |
|
| 66 | + $this->test_api_key_connection($this->google_calendar_id); |
|
| 67 | + add_filter('simcal_settings_meta_tabs_li', array($this, 'add_settings_meta_tab_li'), 10, 1); |
|
| 68 | + add_action('simcal_settings_meta_panels', array($this, 'add_settings_meta_panel'), 10, 1); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - add_action( 'simcal_process_settings_meta', array( $this, 'process_meta' ), 10, 1 ); |
|
| 71 | + add_action('simcal_process_settings_meta', array($this, 'process_meta'), 10, 1); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -81,20 +81,20 @@ discard block |
||
| 81 | 81 | public function settings_fields() { |
| 82 | 82 | return array( |
| 83 | 83 | 'name' => $this->feed->name, |
| 84 | - 'description' => __( "To read events from your public Google Calendars you'll need create a Google API key and save it here.", 'google-calendar-events' ) . |
|
| 85 | - '<br/><br/>' . |
|
| 86 | - '<em style="font-size: 14px;">' . |
|
| 87 | - sprintf( __( '<strong>Note:</strong> Calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong> use a different method of authorization.', 'google-calendar-events' ), |
|
| 88 | - simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'settings-link' ) |
|
| 89 | - ) . |
|
| 84 | + 'description' => __("To read events from your public Google Calendars you'll need create a Google API key and save it here.", 'google-calendar-events'). |
|
| 85 | + '<br/><br/>'. |
|
| 86 | + '<em style="font-size: 14px;">'. |
|
| 87 | + sprintf(__('<strong>Note:</strong> Calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong> use a different method of authorization.', 'google-calendar-events'), |
|
| 88 | + simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'settings-link') |
|
| 89 | + ). |
|
| 90 | 90 | '</em>', |
| 91 | 91 | 'fields' => array( |
| 92 | 92 | 'api_key' => array( |
| 93 | 93 | 'type' => 'standard', |
| 94 | 94 | 'subtype' => 'text', |
| 95 | - 'class' => array( 'simcal-wide-text regular-text', 'ltr' ), |
|
| 96 | - 'title' => __( 'Google API Key', 'google-calendar-events' ), |
|
| 97 | - 'validation' => array( $this, 'check_google_api_key' ), |
|
| 95 | + 'class' => array('simcal-wide-text regular-text', 'ltr'), |
|
| 96 | + 'title' => __('Google API Key', 'google-calendar-events'), |
|
| 97 | + 'validation' => array($this, 'check_google_api_key'), |
|
| 98 | 98 | ), |
| 99 | 99 | ), |
| 100 | 100 | ); |
@@ -113,27 +113,27 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return true|string |
| 115 | 115 | */ |
| 116 | - public function check_google_api_key( $api_key = '' ) { |
|
| 116 | + public function check_google_api_key($api_key = '') { |
|
| 117 | 117 | |
| 118 | 118 | $message = ''; |
| 119 | 119 | $has_errors = false; |
| 120 | 120 | |
| 121 | - if ( empty( $api_key ) ){ |
|
| 121 | + if (empty($api_key)) { |
|
| 122 | 122 | $api_key = $this->google_api_key; |
| 123 | - if ( empty( $api_key ) ) { |
|
| 124 | - $settings = get_option( 'simple-calendar_settings_feeds' ); |
|
| 125 | - $api_key = isset( $settings['google']['api_key'] ) ? esc_attr( $settings['google']['api_key'] ) : ''; |
|
| 123 | + if (empty($api_key)) { |
|
| 124 | + $settings = get_option('simple-calendar_settings_feeds'); |
|
| 125 | + $api_key = isset($settings['google']['api_key']) ? esc_attr($settings['google']['api_key']) : ''; |
|
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - $message = '<p class="description">' . |
|
| 130 | - sprintf( __( '<a href="%s" target="_blank">Step-by-step instructions</a> ', 'google-calendar-events' ), |
|
| 131 | - simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/google-api-key/', 'core-plugin', 'settings-link' ) |
|
| 132 | - ) . |
|
| 133 | - '<br/>' . |
|
| 134 | - sprintf( __( '<a href="%s" target="_blank">Google Developers Console</a> ', 'google-calendar-events' ), |
|
| 135 | - simcal_get_url( 'gdev-console' ) |
|
| 136 | - ) . |
|
| 129 | + $message = '<p class="description">'. |
|
| 130 | + sprintf(__('<a href="%s" target="_blank">Step-by-step instructions</a> ', 'google-calendar-events'), |
|
| 131 | + simcal_ga_campaign_url(simcal_get_url('docs').'/google-api-key/', 'core-plugin', 'settings-link') |
|
| 132 | + ). |
|
| 133 | + '<br/>'. |
|
| 134 | + sprintf(__('<a href="%s" target="_blank">Google Developers Console</a> ', 'google-calendar-events'), |
|
| 135 | + simcal_get_url('gdev-console') |
|
| 136 | + ). |
|
| 137 | 137 | '</p>'; |
| 138 | 138 | |
| 139 | 139 | return $message; |
@@ -148,15 +148,15 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @return array |
| 150 | 150 | */ |
| 151 | - public function add_settings_meta_tab_li( $tabs ) { |
|
| 152 | - return array_merge( $tabs, array( |
|
| 151 | + public function add_settings_meta_tab_li($tabs) { |
|
| 152 | + return array_merge($tabs, array( |
|
| 153 | 153 | 'google' => array( |
| 154 | 154 | 'label' => $this->feed->name, |
| 155 | 155 | 'target' => 'google-settings-panel', |
| 156 | - 'class' => array( 'simcal-feed-type', 'simcal-feed-type-google' ), |
|
| 156 | + 'class' => array('simcal-feed-type', 'simcal-feed-type-google'), |
|
| 157 | 157 | 'icon' => 'simcal-icon-google', |
| 158 | 158 | ), |
| 159 | - ) ); |
|
| 159 | + )); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @param int $post_id |
| 168 | 168 | */ |
| 169 | - public function add_settings_meta_panel( $post_id ) { |
|
| 169 | + public function add_settings_meta_panel($post_id) { |
|
| 170 | 170 | |
| 171 | 171 | $inputs = array( |
| 172 | 172 | $this->feed->type => array( |
@@ -175,30 +175,30 @@ discard block |
||
| 175 | 175 | 'subtype' => 'text', |
| 176 | 176 | 'name' => '_google_calendar_id', |
| 177 | 177 | 'id' => '_google_calendar_id', |
| 178 | - 'title' => __( 'Calendar ID', 'google-calendar-events' ), |
|
| 179 | - 'tooltip' => __( 'Visit your Google Calendar account, copy your public calendar ID, then paste it here.', 'google-calendar-events' ), |
|
| 180 | - 'placeholder' => __( 'Enter a valid Google Calendar ID from a public calendar', 'google-calendar-events' ), |
|
| 181 | - 'escaping' => array( $this->feed, 'esc_google_calendar_id' ), |
|
| 182 | - 'validation' => array( $this, 'test_api_key_connection' ), |
|
| 178 | + 'title' => __('Calendar ID', 'google-calendar-events'), |
|
| 179 | + 'tooltip' => __('Visit your Google Calendar account, copy your public calendar ID, then paste it here.', 'google-calendar-events'), |
|
| 180 | + 'placeholder' => __('Enter a valid Google Calendar ID from a public calendar', 'google-calendar-events'), |
|
| 181 | + 'escaping' => array($this->feed, 'esc_google_calendar_id'), |
|
| 182 | + 'validation' => array($this, 'test_api_key_connection'), |
|
| 183 | 183 | ), |
| 184 | 184 | '_google_events_search_query' => array( |
| 185 | 185 | 'type' => 'standard', |
| 186 | 186 | 'subtype' => 'text', |
| 187 | 187 | 'name' => '_google_events_search_query', |
| 188 | 188 | 'id' => '_google_events_search_query', |
| 189 | - 'title' => __( 'Search Query', 'google-calendar-events' ), |
|
| 190 | - 'tooltip' => __( 'Type in keywords if you only want display events that match these terms. You can use basic boolean search operators too.', 'google-calendar-events' ), |
|
| 191 | - 'placeholder' => __( 'Filter events to display by search terms...', 'google-calendar-events' ), |
|
| 189 | + 'title' => __('Search Query', 'google-calendar-events'), |
|
| 190 | + 'tooltip' => __('Type in keywords if you only want display events that match these terms. You can use basic boolean search operators too.', 'google-calendar-events'), |
|
| 191 | + 'placeholder' => __('Filter events to display by search terms...', 'google-calendar-events'), |
|
| 192 | 192 | ), |
| 193 | 193 | '_google_events_recurring' => array( |
| 194 | 194 | 'type' => 'select', |
| 195 | 195 | 'name' => '_google_events_recurring', |
| 196 | 196 | 'id' => '_google_events_recurring', |
| 197 | - 'title' => __( 'Recurring Events', 'google-calendar-events' ), |
|
| 198 | - 'tooltip' => __( 'Events that are programmed to repeat themselves periodically.', 'google-calendar-events' ), |
|
| 197 | + 'title' => __('Recurring Events', 'google-calendar-events'), |
|
| 198 | + 'tooltip' => __('Events that are programmed to repeat themselves periodically.', 'google-calendar-events'), |
|
| 199 | 199 | 'options' => array( |
| 200 | - 'show' => __( 'Show all', 'google-calendar-events' ), |
|
| 201 | - 'first-only' => __( 'Only show first occurrence', 'google-calendar-events' ), |
|
| 200 | + 'show' => __('Show all', 'google-calendar-events'), |
|
| 201 | + 'first-only' => __('Only show first occurrence', 'google-calendar-events'), |
|
| 202 | 202 | ), |
| 203 | 203 | ), |
| 204 | 204 | '_google_events_max_results' => array( |
@@ -206,8 +206,8 @@ discard block |
||
| 206 | 206 | 'subtype' => 'number', |
| 207 | 207 | 'name' => '_google_events_max_results', |
| 208 | 208 | 'id' => '_google_events_max_results', |
| 209 | - 'title' => __( 'Maximum Events', 'google-calendar-events' ), |
|
| 210 | - 'tooltip' => __( 'Google Calendar only allows to query for a maximum amount of 2500 events from a calendar each time.', 'google-calendar-events' ), |
|
| 209 | + 'title' => __('Maximum Events', 'google-calendar-events'), |
|
| 210 | + 'tooltip' => __('Google Calendar only allows to query for a maximum amount of 2500 events from a calendar each time.', 'google-calendar-events'), |
|
| 211 | 211 | 'class' => array( |
| 212 | 212 | 'simcal-field-small', |
| 213 | 213 | ), |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | <div id="google-settings-panel" class="simcal-panel"> |
| 225 | 225 | <table> |
| 226 | 226 | <thead> |
| 227 | - <tr><th colspan="2"><?php _e( 'Google Calendar Settings', 'google-calendar-events' ); ?></th></tr> |
|
| 227 | + <tr><th colspan="2"><?php _e('Google Calendar Settings', 'google-calendar-events'); ?></th></tr> |
|
| 228 | 228 | </thead> |
| 229 | - <?php Settings::print_panel_fields( $inputs, $post_id ); ?> |
|
| 229 | + <?php Settings::print_panel_fields($inputs, $post_id); ?> |
|
| 230 | 230 | </table> |
| 231 | 231 | </div> |
| 232 | 232 | <?php |
@@ -242,47 +242,47 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @return true|string |
| 244 | 244 | */ |
| 245 | - public function test_api_key_connection( $google_calendar_id ) { |
|
| 245 | + public function test_api_key_connection($google_calendar_id) { |
|
| 246 | 246 | |
| 247 | 247 | global $post; |
| 248 | 248 | |
| 249 | - $post_id = isset( $post->ID ) ? $post->ID : 0; |
|
| 249 | + $post_id = isset($post->ID) ? $post->ID : 0; |
|
| 250 | 250 | $feed = null; |
| 251 | - if ( $feed_type = wp_get_object_terms( $post_id, 'calendar_feed' ) ) { |
|
| 252 | - $feed = sanitize_title( current( $feed_type )->name ); |
|
| 251 | + if ($feed_type = wp_get_object_terms($post_id, 'calendar_feed')) { |
|
| 252 | + $feed = sanitize_title(current($feed_type)->name); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | $message = ''; |
| 256 | 256 | $error = ''; |
| 257 | 257 | $has_errors = false; |
| 258 | 258 | |
| 259 | - $message .= '<p class="description">' . |
|
| 259 | + $message .= '<p class="description">'. |
|
| 260 | 260 | sprintf( |
| 261 | - __( 'Step 1: Set the Google Calendar you want to use as <strong>"public."</strong> <a href="%1s" target="_blank">Detailed instructions</a>', 'google-calendar-events' ) . '<br />' . |
|
| 262 | - __( 'Step 2: Copy and paste your Google Calendar ID here. <a href="%2s" target="_blank">Detailed instructions</a>', 'google-calendar-events' ), |
|
| 263 | - simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/make-google-calendar-public/', 'core-plugin', 'settings-link' ), |
|
| 264 | - simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/find-google-calendar-id/', 'core-plugin', 'settings-link' ) |
|
| 265 | - ) . '</p>'; |
|
| 261 | + __('Step 1: Set the Google Calendar you want to use as <strong>"public."</strong> <a href="%1s" target="_blank">Detailed instructions</a>', 'google-calendar-events').'<br />'. |
|
| 262 | + __('Step 2: Copy and paste your Google Calendar ID here. <a href="%2s" target="_blank">Detailed instructions</a>', 'google-calendar-events'), |
|
| 263 | + simcal_ga_campaign_url(simcal_get_url('docs').'/make-google-calendar-public/', 'core-plugin', 'settings-link'), |
|
| 264 | + simcal_ga_campaign_url(simcal_get_url('docs').'/find-google-calendar-id/', 'core-plugin', 'settings-link') |
|
| 265 | + ).'</p>'; |
|
| 266 | 266 | |
| 267 | - if ( $post_id > 0 && ! is_null( $feed ) && ! empty( $this->feed->type ) ) { |
|
| 267 | + if ($post_id > 0 && ! is_null($feed) && ! empty($this->feed->type)) { |
|
| 268 | 268 | |
| 269 | - $no_key_notice = new Notice( array( |
|
| 270 | - 'id' => array( 'calendar_' . $post_id => 'google-no-api-key' ), |
|
| 269 | + $no_key_notice = new Notice(array( |
|
| 270 | + 'id' => array('calendar_'.$post_id => 'google-no-api-key'), |
|
| 271 | 271 | 'type' => 'error', |
| 272 | 272 | 'screen' => 'calendar', |
| 273 | 273 | 'post' => $post_id, |
| 274 | 274 | 'dismissable' => false, |
| 275 | - 'content' => '<p>' . |
|
| 276 | - '<i class="simcal-icon-warning"></i> ' . |
|
| 275 | + 'content' => '<p>'. |
|
| 276 | + '<i class="simcal-icon-warning"></i> '. |
|
| 277 | 277 | sprintf( |
| 278 | - __( 'Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events' ), |
|
| 279 | - admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds' ) |
|
| 280 | - ) . |
|
| 278 | + __('Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events'), |
|
| 279 | + admin_url('edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds') |
|
| 280 | + ). |
|
| 281 | 281 | '</p>', |
| 282 | 282 | ) |
| 283 | 283 | ); |
| 284 | 284 | |
| 285 | - if ( empty( $this->google_api_key ) && ( $feed == $this->feed->type ) ) { |
|
| 285 | + if (empty($this->google_api_key) && ($feed == $this->feed->type)) { |
|
| 286 | 286 | |
| 287 | 287 | $has_errors = true; |
| 288 | 288 | $no_key_notice->add(); |
@@ -292,28 +292,28 @@ discard block |
||
| 292 | 292 | $no_key_notice->remove(); |
| 293 | 293 | |
| 294 | 294 | try { |
| 295 | - $this->feed->make_request( $google_calendar_id ); |
|
| 296 | - } catch ( \Exception $e ) { |
|
| 295 | + $this->feed->make_request($google_calendar_id); |
|
| 296 | + } catch (\Exception $e) { |
|
| 297 | 297 | $error = $e->getMessage(); |
| 298 | - $message = ! empty( $error ) ? '<blockquote>' . $error . '</blockquote>' : ''; |
|
| 298 | + $message = ! empty($error) ? '<blockquote>'.$error.'</blockquote>' : ''; |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - $error_notice = new Notice( array( |
|
| 302 | - 'id' => array( 'calendar_' . $post_id => 'google-error-response' ), |
|
| 301 | + $error_notice = new Notice(array( |
|
| 302 | + 'id' => array('calendar_'.$post_id => 'google-error-response'), |
|
| 303 | 303 | 'type' => 'error', |
| 304 | 304 | 'screen' => 'calendar', |
| 305 | 305 | 'post' => $post_id, |
| 306 | 306 | 'dismissable' => false, |
| 307 | - 'content' => '<p>' . |
|
| 308 | - '<i class="simcal-icon-warning"></i> ' . |
|
| 309 | - __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' ) . |
|
| 310 | - '<br>' . $message . '<br>' . |
|
| 311 | - __( 'Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events' ) . |
|
| 307 | + 'content' => '<p>'. |
|
| 308 | + '<i class="simcal-icon-warning"></i> '. |
|
| 309 | + __('While trying to retrieve events, Google returned an error:', 'google-calendar-events'). |
|
| 310 | + '<br>'.$message.'<br>'. |
|
| 311 | + __('Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events'). |
|
| 312 | 312 | '</p>', |
| 313 | 313 | ) |
| 314 | 314 | ); |
| 315 | 315 | |
| 316 | - if ( ! empty( $error ) && ( $feed == $this->feed->type ) ) { |
|
| 316 | + if ( ! empty($error) && ($feed == $this->feed->type)) { |
|
| 317 | 317 | $error_notice->add(); |
| 318 | 318 | $has_errors = true; |
| 319 | 319 | } else { |
@@ -335,21 +335,21 @@ discard block |
||
| 335 | 335 | * |
| 336 | 336 | * @param int $post_id |
| 337 | 337 | */ |
| 338 | - public function process_meta( $post_id ) { |
|
| 338 | + public function process_meta($post_id) { |
|
| 339 | 339 | |
| 340 | - $calendar_id = isset( $_POST['_google_calendar_id'] ) ? base64_encode( trim( $_POST['_google_calendar_id'] ) ): ''; |
|
| 341 | - update_post_meta( $post_id, '_google_calendar_id', $calendar_id ); |
|
| 340 | + $calendar_id = isset($_POST['_google_calendar_id']) ? base64_encode(trim($_POST['_google_calendar_id'])) : ''; |
|
| 341 | + update_post_meta($post_id, '_google_calendar_id', $calendar_id); |
|
| 342 | 342 | |
| 343 | - $search_query = isset( $_POST['_google_events_search_query'] ) ? sanitize_text_field( $_POST['_google_events_search_query'] ) : ''; |
|
| 344 | - update_post_meta( $post_id, '_google_events_search_query', $search_query ); |
|
| 343 | + $search_query = isset($_POST['_google_events_search_query']) ? sanitize_text_field($_POST['_google_events_search_query']) : ''; |
|
| 344 | + update_post_meta($post_id, '_google_events_search_query', $search_query); |
|
| 345 | 345 | |
| 346 | - $recurring = isset( $_POST['_google_events_recurring'] ) ? sanitize_key( $_POST['_google_events_recurring'] ) : 'show'; |
|
| 347 | - update_post_meta( $post_id, '_google_events_recurring', $recurring ); |
|
| 346 | + $recurring = isset($_POST['_google_events_recurring']) ? sanitize_key($_POST['_google_events_recurring']) : 'show'; |
|
| 347 | + update_post_meta($post_id, '_google_events_recurring', $recurring); |
|
| 348 | 348 | |
| 349 | - $max_results = isset( $_POST['_google_events_max_results'] ) ? absint( $_POST['_google_events_max_results'] ) : '2500'; |
|
| 350 | - update_post_meta( $post_id, '_google_events_max_results', $max_results ); |
|
| 349 | + $max_results = isset($_POST['_google_events_max_results']) ? absint($_POST['_google_events_max_results']) : '2500'; |
|
| 350 | + update_post_meta($post_id, '_google_events_max_results', $max_results); |
|
| 351 | 351 | |
| 352 | - $this->test_api_key_connection( $calendar_id ); |
|
| 352 | + $this->test_api_key_connection($calendar_id); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Admin\License_Manager; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @return Plugin |
| 72 | 72 | */ |
| 73 | 73 | public static function get_instance() { |
| 74 | - if ( is_null( self::$_instance ) ) { |
|
| 74 | + if (is_null(self::$_instance)) { |
|
| 75 | 75 | self::$_instance = new self(); |
| 76 | 76 | } |
| 77 | 77 | return self::$_instance; |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | * Cloning is forbidden. |
| 82 | 82 | */ |
| 83 | 83 | public function __clone() { |
| 84 | - _doing_it_wrong( __FUNCTION__, 'Cloning the main instance of this plugin is forbidden.', '1.0.0' ); |
|
| 84 | + _doing_it_wrong(__FUNCTION__, 'Cloning the main instance of this plugin is forbidden.', '1.0.0'); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * Unserializing instances of this class is forbidden. |
| 89 | 89 | */ |
| 90 | 90 | public function __wakeup() { |
| 91 | - _doing_it_wrong( __FUNCTION__, 'Unserializing instances of this plugin is forbidden.', '1.0.0' ); |
|
| 91 | + _doing_it_wrong(__FUNCTION__, 'Unserializing instances of this plugin is forbidden.', '1.0.0'); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -100,22 +100,22 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | // Load plugin. |
| 102 | 102 | require_once 'autoload.php'; |
| 103 | - $this->locale = apply_filters( 'plugin_locale', get_locale(), 'google-calendar-events' ); |
|
| 103 | + $this->locale = apply_filters('plugin_locale', get_locale(), 'google-calendar-events'); |
|
| 104 | 104 | $this->load(); |
| 105 | 105 | |
| 106 | 106 | // Installation hooks. |
| 107 | - register_activation_hook( SIMPLE_CALENDAR_MAIN_FILE, array( 'SimpleCalendar\Installation', 'activate' ) ); |
|
| 108 | - register_deactivation_hook( SIMPLE_CALENDAR_MAIN_FILE, array( 'SimpleCalendar\Installation', 'deactivate' ) ); |
|
| 107 | + register_activation_hook(SIMPLE_CALENDAR_MAIN_FILE, array('SimpleCalendar\Installation', 'activate')); |
|
| 108 | + register_deactivation_hook(SIMPLE_CALENDAR_MAIN_FILE, array('SimpleCalendar\Installation', 'deactivate')); |
|
| 109 | 109 | |
| 110 | 110 | // Do update call here. |
| 111 | - add_action( 'admin_init', array( $this, 'update' ), 999 ); |
|
| 111 | + add_action('admin_init', array($this, 'update'), 999); |
|
| 112 | 112 | |
| 113 | 113 | // Init hooks. |
| 114 | - add_action( 'init', array( $this, 'init' ), 5 ); |
|
| 115 | - add_action( 'admin_init', array( $this, 'register_settings' ), 5 ); |
|
| 114 | + add_action('init', array($this, 'init'), 5); |
|
| 115 | + add_action('admin_init', array($this, 'register_settings'), 5); |
|
| 116 | 116 | |
| 117 | 117 | // Upon plugin loaded action hook. |
| 118 | - do_action( 'simcal_loaded' ); |
|
| 118 | + do_action('simcal_loaded'); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | new Post_Types(); |
| 133 | 133 | |
| 134 | 134 | // Load back end. |
| 135 | - if ( is_admin() ) { |
|
| 135 | + if (is_admin()) { |
|
| 136 | 136 | $this->load_admin(); |
| 137 | 137 | } else { |
| 138 | 138 | // Load front end scripts and styles. |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | // Init menus and settings. |
| 175 | 175 | new Admin\Menus(); |
| 176 | 176 | |
| 177 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 177 | + if (defined('DOING_AJAX')) { |
|
| 178 | 178 | // Admin ajax callbacks. |
| 179 | 179 | new Admin\Ajax(); |
| 180 | 180 | } |
@@ -188,16 +188,16 @@ discard block |
||
| 188 | 188 | public function init() { |
| 189 | 189 | |
| 190 | 190 | // Before init action hook. |
| 191 | - do_action( 'before_simcal_init' ); |
|
| 191 | + do_action('before_simcal_init'); |
|
| 192 | 192 | |
| 193 | 193 | // Set up localization. |
| 194 | - add_action( 'plugins_loaded', array( $this, 'load_plugin_textdomain' ) ); |
|
| 194 | + add_action('plugins_loaded', array($this, 'load_plugin_textdomain')); |
|
| 195 | 195 | |
| 196 | 196 | // Init objects factory. |
| 197 | 197 | $this->objects = new Objects(); |
| 198 | 198 | |
| 199 | 199 | // Upon init action hook. |
| 200 | - do_action( 'simcal_init' ); |
|
| 200 | + do_action('simcal_init'); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | public function load_plugin_textdomain() { |
| 209 | 209 | |
| 210 | - load_plugin_textdomain( 'google-calendar-events', false, dirname( plugin_basename( SIMPLE_CALENDAR_MAIN_FILE ) ) . '/i18n/' ); |
|
| 210 | + load_plugin_textdomain('google-calendar-events', false, dirname(plugin_basename(SIMPLE_CALENDAR_MAIN_FILE)).'/i18n/'); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | * @since 3.0.0 |
| 217 | 217 | */ |
| 218 | 218 | public function register_settings() { |
| 219 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 219 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
| 220 | 220 | $settings = new Admin\Pages(); |
| 221 | - $settings->register_settings( $settings->get_settings() ); |
|
| 221 | + $settings->register_settings($settings->get_settings()); |
|
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | * @return string |
| 231 | 231 | */ |
| 232 | 232 | public function ajax_url() { |
| 233 | - return admin_url( 'admin-ajax.php', 'relative' ); |
|
| 233 | + return admin_url('admin-ajax.php', 'relative'); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -242,17 +242,17 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @return string |
| 244 | 244 | */ |
| 245 | - public function get_url( $case ) { |
|
| 246 | - switch ( $case ) { |
|
| 245 | + public function get_url($case) { |
|
| 246 | + switch ($case) { |
|
| 247 | 247 | case 'codex' : |
| 248 | 248 | case 'apidocs' : |
| 249 | 249 | return 'http://codex.simplecalendar.io'; |
| 250 | 250 | case 'addons' : |
| 251 | - return self::$homepage . '/addons/'; |
|
| 251 | + return self::$homepage.'/addons/'; |
|
| 252 | 252 | case 'gcal-pro' : |
| 253 | - return self::$homepage . '/addons/google-calendar-pro/'; |
|
| 253 | + return self::$homepage.'/addons/google-calendar-pro/'; |
|
| 254 | 254 | case 'fullcal' : |
| 255 | - return self::$homepage . '/addons/full-calendar/'; |
|
| 255 | + return self::$homepage.'/addons/full-calendar/'; |
|
| 256 | 256 | case 'docs' : |
| 257 | 257 | return 'http://docs.simplecalendar.io'; |
| 258 | 258 | case 'github' : |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * @since 3.0.0 |
| 274 | 274 | */ |
| 275 | 275 | public static function update() { |
| 276 | - $update = new Update( SIMPLE_CALENDAR_VERSION ); |
|
| 276 | + $update = new Update(SIMPLE_CALENDAR_VERSION); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | } |