@@ -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 | '3.1.8', |
| 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,42 +192,42 @@ 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'] ); |
|
| 214 | + $src = esc_url($v['src']); |
|
| 215 | 215 | //$deps = isset( $v['deps'] ) ? $v['deps'] : array(); |
| 216 | - $ver = isset( $v['ver'] ) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
| 217 | - $in_footer = isset( $v['in_footer'] ) ? $v['in_footer'] : false; |
|
| 216 | + $ver = isset($v['ver']) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
| 217 | + $in_footer = isset($v['in_footer']) ? $v['in_footer'] : false; |
|
| 218 | 218 | |
| 219 | 219 | //wp_enqueue_script( $script, $src, $deps, $ver, $in_footer ); |
| 220 | - wp_enqueue_script( $script, $src, array(), $ver, $in_footer ); |
|
| 220 | + wp_enqueue_script($script, $src, array(), $ver, $in_footer); |
|
| 221 | 221 | |
| 222 | - if ( ! empty( $v['localize'] ) && is_array( $v['localize'] ) ) { |
|
| 223 | - foreach ( $v['localize'] as $object => $l10n ) { |
|
| 224 | - wp_localize_script( $script, $object, $l10n ); |
|
| 222 | + if ( ! empty($v['localize']) && is_array($v['localize'])) { |
|
| 223 | + foreach ($v['localize'] as $object => $l10n) { |
|
| 224 | + wp_localize_script($script, $object, $l10n); |
|
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - } elseif ( is_string( $v ) && ! empty( $v ) ) { |
|
| 228 | + } elseif (is_string($v) && ! empty($v)) { |
|
| 229 | 229 | |
| 230 | - wp_enqueue_script( $v ); |
|
| 230 | + wp_enqueue_script($v); |
|
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | |
@@ -241,29 +241,29 @@ discard block |
||
| 241 | 241 | * |
| 242 | 242 | * @param array $styles |
| 243 | 243 | */ |
| 244 | - public function load_styles( $styles ) { |
|
| 244 | + public function load_styles($styles) { |
|
| 245 | 245 | |
| 246 | 246 | // Only load if not disabled in the settings |
| 247 | - if ( ! empty( $styles ) && is_array( $styles ) && false === $this->disable_styles ) { |
|
| 247 | + if ( ! empty($styles) && is_array($styles) && false === $this->disable_styles) { |
|
| 248 | 248 | |
| 249 | - foreach ( $styles as $style => $v ) { |
|
| 249 | + foreach ($styles as $style => $v) { |
|
| 250 | 250 | |
| 251 | - if ( ! empty( $v['src'] ) ) { |
|
| 251 | + if ( ! empty($v['src'])) { |
|
| 252 | 252 | |
| 253 | 253 | // Enqueued individually so we can dequeue if already enqueued by another plugin. |
| 254 | 254 | // TODO Rework dependencies part (or remove completely). |
| 255 | 255 | |
| 256 | - $src = esc_url( $v['src'] ); |
|
| 256 | + $src = esc_url($v['src']); |
|
| 257 | 257 | //$deps = isset( $v['deps'] ) ? $v['deps'] : array(); |
| 258 | - $ver = isset( $v['ver'] ) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
| 259 | - $media = isset( $v['media'] ) ? $v['media'] : 'all'; |
|
| 258 | + $ver = isset($v['ver']) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
| 259 | + $media = isset($v['media']) ? $v['media'] : 'all'; |
|
| 260 | 260 | |
| 261 | 261 | //wp_enqueue_style( $style, $src, $deps, $ver, $media ); |
| 262 | - wp_enqueue_style( $style, $src, array(), $ver, $media ); |
|
| 262 | + wp_enqueue_style($style, $src, array(), $ver, $media); |
|
| 263 | 263 | |
| 264 | - } elseif ( is_string( $v ) && ! empty( $v ) ) { |
|
| 264 | + } elseif (is_string($v) && ! empty($v)) { |
|
| 265 | 265 | |
| 266 | - wp_enqueue_style( $v ); |
|
| 266 | + wp_enqueue_style($v); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | } |
@@ -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,24 +211,24 @@ 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 ( ! empty( $event->whole_day ) ) { |
|
| 222 | + if ( ! empty($event->whole_day)) { |
|
| 223 | 223 | $days--; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if ( $days == 1 ) { |
|
| 227 | - $new_events[ intval( $event->start + ( DAY_IN_SECONDS ) - 1 ) ][] = $event; |
|
| 226 | + if ($days == 1) { |
|
| 227 | + $new_events[intval($event->start + (DAY_IN_SECONDS) - 1)][] = $event; |
|
| 228 | 228 | } else { |
| 229 | 229 | |
| 230 | - for ( $d = 1; $d <= $days; $d++ ) { |
|
| 231 | - $new_events[ intval( $event->start + ( $d * DAY_IN_SECONDS ) - 1 ) ][] = $event; |
|
| 230 | + for ($d = 1; $d <= $days; $d++) { |
|
| 231 | + $new_events[intval($event->start + ($d * DAY_IN_SECONDS) - 1)][] = $event; |
|
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $events = $old_events + $new_events; |
| 243 | - ksort( $events, SORT_NUMERIC ); |
|
| 243 | + ksort($events, SORT_NUMERIC); |
|
| 244 | 244 | |
| 245 | 245 | return $events; |
| 246 | 246 | } |
@@ -256,16 +256,16 @@ discard block |
||
| 256 | 256 | * |
| 257 | 257 | * @return null|Calendar_View |
| 258 | 258 | */ |
| 259 | - public function get_view( $view = '' ) { |
|
| 259 | + public function get_view($view = '') { |
|
| 260 | 260 | |
| 261 | - $view = ! empty( $view ) ? $view : 'grid'; |
|
| 261 | + $view = ! empty($view) ? $view : 'grid'; |
|
| 262 | 262 | |
| 263 | - do_action( 'simcal_calendar_get_view', $this->type, $view ); |
|
| 263 | + do_action('simcal_calendar_get_view', $this->type, $view); |
|
| 264 | 264 | |
| 265 | - if ( 'grid' == $view ) { |
|
| 266 | - return new Views\Default_Calendar_Grid( $this ); |
|
| 267 | - } elseif ( 'list' == $view ) { |
|
| 268 | - return new Views\Default_Calendar_List( $this ); |
|
| 265 | + if ('grid' == $view) { |
|
| 266 | + return new Views\Default_Calendar_Grid($this); |
|
| 267 | + } elseif ('list' == $view) { |
|
| 268 | + return new Views\Default_Calendar_List($this); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | 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 | 191 | $disabled = $calendar->static === true ? ' 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,98 +248,98 @@ 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 | - $first_event = array_slice( $paged_events, 0, 1, true ); |
|
| 339 | - $first_event = array_pop( $first_event ); |
|
| 338 | + $first_event = array_slice($paged_events, 0, 1, true); |
|
| 339 | + $first_event = array_pop($first_event); |
|
| 340 | 340 | $this->first_event = $first_event[0]->start; |
| 341 | 341 | |
| 342 | - $last_event = array_pop( $paged_events ); |
|
| 342 | + $last_event = array_pop($paged_events); |
|
| 343 | 343 | $this->last_event = $last_event[0]->start; |
| 344 | 344 | |
| 345 | 345 | return $daily_events; |
@@ -358,84 +358,84 @@ discard block |
||
| 358 | 358 | private function get_heading() { |
| 359 | 359 | |
| 360 | 360 | $calendar = $this->calendar; |
| 361 | - $start = Carbon::createFromTimestamp( $calendar->start, $calendar->timezone ); |
|
| 362 | - $end = Carbon::createFromTimestamp( $this->end, $calendar->timezone ); |
|
| 361 | + $start = Carbon::createFromTimestamp($calendar->start, $calendar->timezone); |
|
| 362 | + $end = Carbon::createFromTimestamp($this->end, $calendar->timezone); |
|
| 363 | 363 | $date_format = $this->calendar->date_format; |
| 364 | - $date_order = simcal_get_date_format_order( $date_format ); |
|
| 364 | + $date_order = simcal_get_date_format_order($date_format); |
|
| 365 | 365 | |
| 366 | 366 | $st = $this->start; |
| 367 | 367 | $et = $this->end; |
| 368 | 368 | |
| 369 | - if ( $this->first_event !== 0 ) { |
|
| 370 | - $start = Carbon::createFromTimestamp( $this->first_event, $calendar->timezone ); |
|
| 369 | + if ($this->first_event !== 0) { |
|
| 370 | + $start = Carbon::createFromTimestamp($this->first_event, $calendar->timezone); |
|
| 371 | 371 | $st = $this->first_event; |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - if ( $this->last_event !== 0 ) { |
|
| 375 | - $end = Carbon::createFromTimestamp( $this->last_event, $calendar->timezone ); |
|
| 374 | + if ($this->last_event !== 0) { |
|
| 375 | + $end = Carbon::createFromTimestamp($this->last_event, $calendar->timezone); |
|
| 376 | 376 | $et = $this->last_event; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - if ( ( $start->day == $end->day ) && ( $start->month == $end->month ) && ( $start->year == $end->year ) ) { |
|
| 379 | + if (($start->day == $end->day) && ($start->month == $end->month) && ($start->year == $end->year)) { |
|
| 380 | 380 | // Start and end on the same day. |
| 381 | 381 | // e.g. 1 February 2020 |
| 382 | - $large = $small = date_i18n( $calendar->date_format , $st ); |
|
| 383 | - if ( ( $date_order['d'] !== false ) && ( $date_order['m'] !== false ) ) { |
|
| 384 | - if ( $date_order['m'] > $date_order['d'] ) { |
|
| 385 | - if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) { |
|
| 386 | - $small = date_i18n( 'Y, d M', $st ); |
|
| 382 | + $large = $small = date_i18n($calendar->date_format, $st); |
|
| 383 | + if (($date_order['d'] !== false) && ($date_order['m'] !== false)) { |
|
| 384 | + if ($date_order['m'] > $date_order['d']) { |
|
| 385 | + if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) { |
|
| 386 | + $small = date_i18n('Y, d M', $st); |
|
| 387 | 387 | } else { |
| 388 | - $small = date_i18n( 'd M Y', $st ); |
|
| 388 | + $small = date_i18n('d M Y', $st); |
|
| 389 | 389 | } |
| 390 | 390 | } else { |
| 391 | - if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) { |
|
| 392 | - $small = date_i18n( 'Y, M d', $st ); |
|
| 391 | + if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) { |
|
| 392 | + $small = date_i18n('Y, M d', $st); |
|
| 393 | 393 | } else { |
| 394 | - $small = date_i18n( 'M d Y', $st ); |
|
| 394 | + $small = date_i18n('M d Y', $st); |
|
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | 397 | } |
| 398 | - } elseif ( ( $start->month == $end->month ) && ( $start->year == $end->year ) ) { |
|
| 398 | + } elseif (($start->month == $end->month) && ($start->year == $end->year)) { |
|
| 399 | 399 | // Start and end days on the same month. |
| 400 | 400 | // e.g. August 2020 |
| 401 | - if ( $date_order['y'] === false ) { |
|
| 401 | + if ($date_order['y'] === false) { |
|
| 402 | 402 | // August. |
| 403 | - $large = $small = date_i18n( 'F', $st ); |
|
| 403 | + $large = $small = date_i18n('F', $st); |
|
| 404 | 404 | } else { |
| 405 | - if ( $date_order['y'] < $date_order['m'] ) { |
|
| 405 | + if ($date_order['y'] < $date_order['m']) { |
|
| 406 | 406 | // 2020 August. |
| 407 | - $large = date_i18n( 'Y F', $st ); |
|
| 408 | - $small = date_i18n( 'Y M', $st ); |
|
| 407 | + $large = date_i18n('Y F', $st); |
|
| 408 | + $small = date_i18n('Y M', $st); |
|
| 409 | 409 | } else { |
| 410 | 410 | // August 2020. |
| 411 | - $large = date_i18n( 'F Y', $st ); |
|
| 412 | - $small = date_i18n( 'M Y', $st ); |
|
| 411 | + $large = date_i18n('F Y', $st); |
|
| 412 | + $small = date_i18n('M Y', $st); |
|
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | - } elseif ( $start->year == $end->year ) { |
|
| 415 | + } elseif ($start->year == $end->year) { |
|
| 416 | 416 | // Start and end days on months of the same year. |
| 417 | 417 | // e.g. August - September 2020 |
| 418 | - if ( $date_order['y'] === false ) { |
|
| 418 | + if ($date_order['y'] === false) { |
|
| 419 | 419 | // August - September. |
| 420 | - $large = date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et ); |
|
| 421 | - $small = date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et ); |
|
| 420 | + $large = date_i18n('F', $st).' - '.date_i18n('F', $et); |
|
| 421 | + $small = date_i18n('M', $st).' - '.date_i18n('M', $et); |
|
| 422 | 422 | } else { |
| 423 | - if ( $date_order['y'] < $date_order['m'] ) { |
|
| 423 | + if ($date_order['y'] < $date_order['m']) { |
|
| 424 | 424 | // 2020, August - September. |
| 425 | - $large = $small = date( 'Y', $st ) . ', '; |
|
| 426 | - $large .= date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et ); |
|
| 427 | - $small .= date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et ); |
|
| 425 | + $large = $small = date('Y', $st).', '; |
|
| 426 | + $large .= date_i18n('F', $st).' - '.date_i18n('F', $et); |
|
| 427 | + $small .= date_i18n('M', $st).' - '.date_i18n('M', $et); |
|
| 428 | 428 | } else { |
| 429 | 429 | // August - September, 2020. |
| 430 | - $large = date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et ) . ', '; |
|
| 431 | - $small = date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et ) . ' '; |
|
| 432 | - $year = date( 'Y', $st ); |
|
| 430 | + $large = date_i18n('F', $st).' - '.date_i18n('F', $et).', '; |
|
| 431 | + $small = date_i18n('M', $st).' - '.date_i18n('M', $et).' '; |
|
| 432 | + $year = date('Y', $st); |
|
| 433 | 433 | $large .= $year; |
| 434 | 434 | $small .= $year; |
| 435 | 435 | } |
| 436 | 436 | } |
| 437 | 437 | } else { |
| 438 | - $large = $small = date( 'Y', $st ) . ' - ' . date( 'Y', $et ); |
|
| 438 | + $large = $small = date('Y', $st).' - '.date('Y', $et); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | return array( |
@@ -457,133 +457,133 @@ discard block |
||
| 457 | 457 | * |
| 458 | 458 | * @return string |
| 459 | 459 | */ |
| 460 | - private function draw_list( $timestamp, $id = 0 ) { |
|
| 460 | + private function draw_list($timestamp, $id = 0) { |
|
| 461 | 461 | |
| 462 | 462 | $calendar = $this->calendar; |
| 463 | 463 | |
| 464 | - if ( empty( $calendar ) ) { |
|
| 465 | - $calendar = $this->calendar = simcal_get_calendar( intval( $id ) ); |
|
| 466 | - if ( ! $calendar instanceof Default_Calendar ) { |
|
| 464 | + if (empty($calendar)) { |
|
| 465 | + $calendar = $this->calendar = simcal_get_calendar(intval($id)); |
|
| 466 | + if ( ! $calendar instanceof Default_Calendar) { |
|
| 467 | 467 | return ''; |
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - $feed = simcal_get_feed( $calendar ); |
|
| 472 | - $feed_timezone = get_post_meta( $feed->post_id, '_feed_timezone', true ); |
|
| 471 | + $feed = simcal_get_feed($calendar); |
|
| 472 | + $feed_timezone = get_post_meta($feed->post_id, '_feed_timezone', true); |
|
| 473 | 473 | |
| 474 | 474 | $now = $calendar->now; |
| 475 | - $current_events = $this->get_events( $timestamp ); |
|
| 476 | - $day_format = explode( ' ', $calendar->date_format ); |
|
| 475 | + $current_events = $this->get_events($timestamp); |
|
| 476 | + $day_format = explode(' ', $calendar->date_format); |
|
| 477 | 477 | |
| 478 | 478 | ob_start(); |
| 479 | 479 | |
| 480 | 480 | // Draw the events. |
| 481 | 481 | |
| 482 | - $block_tag = $calendar->compact_list && ! empty( $current_events ) ? 'div' : 'dl'; |
|
| 482 | + $block_tag = $calendar->compact_list && ! empty($current_events) ? 'div' : 'dl'; |
|
| 483 | 483 | |
| 484 | 484 | $data_heading = ''; |
| 485 | 485 | $heading = $this->get_heading(); |
| 486 | - foreach ( $heading as $k => $v ) { |
|
| 487 | - $data_heading .= ' data-heading-' . $k . '="' . $v . '"'; |
|
| 486 | + foreach ($heading as $k => $v) { |
|
| 487 | + $data_heading .= ' data-heading-'.$k.'="'.$v.'"'; |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - echo '<' . $block_tag . ' class="simcal-events-list-container"' . |
|
| 491 | - ' data-prev="' . $this->prev . '"' . |
|
| 492 | - ' data-next="' . $this->next . '"' . |
|
| 493 | - $data_heading . '>'; |
|
| 490 | + echo '<'.$block_tag.' class="simcal-events-list-container"'. |
|
| 491 | + ' data-prev="'.$this->prev.'"'. |
|
| 492 | + ' data-next="'.$this->next.'"'. |
|
| 493 | + $data_heading.'>'; |
|
| 494 | 494 | |
| 495 | - if ( ! empty( $current_events ) && is_array( $current_events ) ) : |
|
| 495 | + if ( ! empty($current_events) && is_array($current_events)) : |
|
| 496 | 496 | |
| 497 | - foreach ( $current_events as $ymd => $events ) : |
|
| 497 | + foreach ($current_events as $ymd => $events) : |
|
| 498 | 498 | |
| 499 | 499 | |
| 500 | 500 | |
| 501 | 501 | // This is where we can find out if an event is a multi-day event and if it needs to be shown. |
| 502 | 502 | // Since this is for list view we are showing the event on the day viewed if it is part of that day even when |
| 503 | 503 | // expand multi-day events are turned off. |
| 504 | - if ( isset( $events[0][0]->multiple_days ) && $events[0][0]->multiple_days > 0 ) { |
|
| 505 | - if ( 'current_day_only' == get_post_meta($calendar->id, '_default_calendar_expand_multi_day_events', true ) ) { |
|
| 504 | + if (isset($events[0][0]->multiple_days) && $events[0][0]->multiple_days > 0) { |
|
| 505 | + if ('current_day_only' == get_post_meta($calendar->id, '_default_calendar_expand_multi_day_events', true)) { |
|
| 506 | 506 | |
| 507 | - $year = substr( $ymd, 0, 4 ); |
|
| 508 | - $month = substr( $ymd, 4, 2 ); |
|
| 509 | - $day = substr( $ymd, 6, 2 ); |
|
| 507 | + $year = substr($ymd, 0, 4); |
|
| 508 | + $month = substr($ymd, 4, 2); |
|
| 509 | + $day = substr($ymd, 6, 2); |
|
| 510 | 510 | |
| 511 | - $temp_date = Carbon::createFromDate( $year, $month, $day ); |
|
| 511 | + $temp_date = Carbon::createFromDate($year, $month, $day); |
|
| 512 | 512 | |
| 513 | - if( ! ( $temp_date < Carbon::now()->endOfDay() ) ) { |
|
| 513 | + if ( ! ($temp_date < Carbon::now()->endOfDay())) { |
|
| 514 | 514 | continue; |
| 515 | 515 | } |
| 516 | 516 | } |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - $day_ts = Carbon::createFromFormat( 'Ymd', $ymd, $calendar->timezone )->startOfDay()->getTimestamp(); |
|
| 519 | + $day_ts = Carbon::createFromFormat('Ymd', $ymd, $calendar->timezone)->startOfDay()->getTimestamp(); |
|
| 520 | 520 | |
| 521 | - if ( ! $calendar->compact_list ) : |
|
| 521 | + if ( ! $calendar->compact_list) : |
|
| 522 | 522 | |
| 523 | - $date = new Carbon( 'now', $calendar->timezone ); |
|
| 524 | - $date->setLocale( substr( get_locale(), 0, 2 ) ); |
|
| 525 | - $date->setTimestamp( $day_ts ); |
|
| 523 | + $date = new Carbon('now', $calendar->timezone); |
|
| 524 | + $date->setLocale(substr(get_locale(), 0, 2)); |
|
| 525 | + $date->setTimestamp($day_ts); |
|
| 526 | 526 | |
| 527 | - if ( $date->isToday() ) { |
|
| 528 | - $the_color = new Color( $calendar->today_color ); |
|
| 527 | + if ($date->isToday()) { |
|
| 528 | + $the_color = new Color($calendar->today_color); |
|
| 529 | 529 | } else { |
| 530 | - $the_color = new Color( $calendar->days_events_color ); |
|
| 530 | + $the_color = new Color($calendar->days_events_color); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - $bg_color = '#' . $the_color->getHex(); |
|
| 533 | + $bg_color = '#'.$the_color->getHex(); |
|
| 534 | 534 | $color = $the_color->isDark() ? '#ffffff' : '#000000'; |
| 535 | - $border_style = ' style="border-bottom: 1px solid ' . $bg_color . ';" '; |
|
| 536 | - $bg_style = ' style="background-color: ' . $bg_color . '; color: ' . $color . ';"'; |
|
| 535 | + $border_style = ' style="border-bottom: 1px solid '.$bg_color.';" '; |
|
| 536 | + $bg_style = ' style="background-color: '.$bg_color.'; color: '.$color.';"'; |
|
| 537 | 537 | |
| 538 | - echo "\t" . '<dt class="simcal-day-label"' . $border_style . '>'; |
|
| 539 | - echo '<span' . $bg_style .'>'; |
|
| 540 | - foreach ( $day_format as $format ) { |
|
| 541 | - echo $format ? '<span class="simcal-date-format" data-date-format="' . $format . '">' . date_i18n( $format, $day_ts ) . '</span> ' : ' '; |
|
| 538 | + echo "\t".'<dt class="simcal-day-label"'.$border_style.'>'; |
|
| 539 | + echo '<span'.$bg_style.'>'; |
|
| 540 | + foreach ($day_format as $format) { |
|
| 541 | + echo $format ? '<span class="simcal-date-format" data-date-format="'.$format.'">'.date_i18n($format, $day_ts).'</span> ' : ' '; |
|
| 542 | 542 | } |
| 543 | 543 | echo '</span>'; |
| 544 | - echo '</dt>' . "\n"; |
|
| 544 | + echo '</dt>'."\n"; |
|
| 545 | 545 | |
| 546 | 546 | endif; |
| 547 | 547 | |
| 548 | - $list_events = '<ul class="simcal-events">' . "\n"; |
|
| 548 | + $list_events = '<ul class="simcal-events">'."\n"; |
|
| 549 | 549 | |
| 550 | 550 | $calendar_classes = array(); |
| 551 | - $day_classes = 'simcal-weekday-' . date( 'w', $day_ts ); |
|
| 551 | + $day_classes = 'simcal-weekday-'.date('w', $day_ts); |
|
| 552 | 552 | |
| 553 | 553 | // Is this the present, the past or the future, Doc? |
| 554 | - if ( $timestamp <= $now && $timestamp >= $now ) { |
|
| 554 | + if ($timestamp <= $now && $timestamp >= $now) { |
|
| 555 | 555 | $day_classes .= ' simcal-today simcal-present simcal-day'; |
| 556 | - } elseif ( $timestamp < $now ) { |
|
| 556 | + } elseif ($timestamp < $now) { |
|
| 557 | 557 | $day_classes .= ' simcal-past simcal-day'; |
| 558 | - } elseif ( $this->end > $now ) { |
|
| 558 | + } elseif ($this->end > $now) { |
|
| 559 | 559 | $day_classes .= ' simcal-future simcal-day'; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | $count = 0; |
| 563 | 563 | |
| 564 | - foreach ( $events as $day_events ) : |
|
| 565 | - foreach ( $day_events as $event ) : |
|
| 564 | + foreach ($events as $day_events) : |
|
| 565 | + foreach ($day_events as $event) : |
|
| 566 | 566 | |
| 567 | - if ( $event instanceof Event ) : |
|
| 567 | + if ($event instanceof Event) : |
|
| 568 | 568 | |
| 569 | - if ( $feed->type == 'grouped-calendars' ) { |
|
| 570 | - date_default_timezone_set( $feed_timezone ); |
|
| 569 | + if ($feed->type == 'grouped-calendars') { |
|
| 570 | + date_default_timezone_set($feed_timezone); |
|
| 571 | 571 | } else { |
| 572 | - date_default_timezone_set( $event->timezone ); |
|
| 572 | + date_default_timezone_set($event->timezone); |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | $event_classes = $event_visibility = ''; |
| 576 | 576 | |
| 577 | - $calendar_class = 'simcal-events-calendar-' . strval( $event->calendar ); |
|
| 577 | + $calendar_class = 'simcal-events-calendar-'.strval($event->calendar); |
|
| 578 | 578 | $calendar_classes[] = $calendar_class; |
| 579 | 579 | |
| 580 | 580 | $recurring = $event->recurrence ? 'simcal-event-recurring ' : ''; |
| 581 | 581 | $has_location = $event->venue ? 'simcal-event-has-location ' : ''; |
| 582 | 582 | |
| 583 | - $event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class; |
|
| 583 | + $event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class; |
|
| 584 | 584 | |
| 585 | 585 | // Toggle some events visibility if more than optional limit. |
| 586 | - if ( ( $calendar->events_limit > - 1 ) && ( $count >= $calendar->events_limit ) ) : |
|
| 586 | + if (($calendar->events_limit > - 1) && ($count >= $calendar->events_limit)) : |
|
| 587 | 587 | $event_classes .= ' simcal-event-toggled'; |
| 588 | 588 | $event_visibility = ' style="display: none"'; |
| 589 | 589 | endif; |
@@ -591,75 +591,75 @@ discard block |
||
| 591 | 591 | $event_color = ''; |
| 592 | 592 | $bullet = ''; |
| 593 | 593 | $event_color = $event->get_color(); |
| 594 | - if ( ! empty( $event_color ) ) { |
|
| 594 | + if ( ! empty($event_color)) { |
|
| 595 | 595 | $side = is_rtl() ? 'right' : 'left'; |
| 596 | - $event_color = ' style="border-' . $side . ': 4px solid ' . $event_color . '; padding-' . $side . ': 8px;"'; |
|
| 596 | + $event_color = ' style="border-'.$side.': 4px solid '.$event_color.'; padding-'.$side.': 8px;"'; |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - $list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . $event_color . ' itemscope itemtype="http://schema.org/Event" data-start="' . esc_attr( $event->start ) . '">' . "\n"; |
|
| 600 | - $list_events .= "\t\t" . '<div class="simcal-event-details">' . $calendar->get_event_html( $event ) . '</div>' . "\n"; |
|
| 601 | - $list_events .= "\t" . '</li>' . "\n"; |
|
| 599 | + $list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.$event_color.' itemscope itemtype="http://schema.org/Event" data-start="'.esc_attr($event->start).'">'."\n"; |
|
| 600 | + $list_events .= "\t\t".'<div class="simcal-event-details">'.$calendar->get_event_html($event).'</div>'."\n"; |
|
| 601 | + $list_events .= "\t".'</li>'."\n"; |
|
| 602 | 602 | |
| 603 | - $count ++; |
|
| 603 | + $count++; |
|
| 604 | 604 | |
| 605 | 605 | // Event falls within today. |
| 606 | - if ( ( $this->end <= $now ) && ( $this->start >= $now ) ) : |
|
| 606 | + if (($this->end <= $now) && ($this->start >= $now)) : |
|
| 607 | 607 | $day_classes .= ' simcal-today-has-events'; |
| 608 | 608 | endif; |
| 609 | - $day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events'; |
|
| 609 | + $day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events'; |
|
| 610 | 610 | |
| 611 | - if ( $calendar_classes ) : |
|
| 612 | - $day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) ); |
|
| 611 | + if ($calendar_classes) : |
|
| 612 | + $day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes))); |
|
| 613 | 613 | endif; |
| 614 | 614 | |
| 615 | 615 | endif; |
| 616 | 616 | endforeach; |
| 617 | 617 | endforeach; |
| 618 | 618 | |
| 619 | - $list_events .= '</ul>' . "\n"; |
|
| 619 | + $list_events .= '</ul>'."\n"; |
|
| 620 | 620 | |
| 621 | 621 | // If events visibility is limited, print the button toggle. |
| 622 | - if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) : |
|
| 622 | + if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) : |
|
| 623 | 623 | $list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>'; |
| 624 | 624 | endif; |
| 625 | 625 | |
| 626 | 626 | // Print final list of events for the current day. |
| 627 | 627 | $tag = $calendar->compact_list ? 'div' : 'dd'; |
| 628 | - echo '<' . $tag . ' class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n"; |
|
| 629 | - echo "\t" . $list_events . "\n"; |
|
| 630 | - echo '</' . $tag . '>' . "\n"; |
|
| 628 | + echo '<'.$tag.' class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n"; |
|
| 629 | + echo "\t".$list_events."\n"; |
|
| 630 | + echo '</'.$tag.'>'."\n"; |
|
| 631 | 631 | |
| 632 | 632 | endforeach; |
| 633 | 633 | |
| 634 | 634 | else : |
| 635 | 635 | |
| 636 | - echo "\t" . '<p>'; |
|
| 636 | + echo "\t".'<p>'; |
|
| 637 | 637 | |
| 638 | - $message = get_post_meta( $calendar->id, '_no_events_message', true ); |
|
| 638 | + $message = get_post_meta($calendar->id, '_no_events_message', true); |
|
| 639 | 639 | |
| 640 | - if ( 'events' == $calendar->group_type ) { |
|
| 641 | - echo ! empty( $message ) ? $message : __( 'Nothing to show.', 'google-calendar-events' ); |
|
| 640 | + if ('events' == $calendar->group_type) { |
|
| 641 | + echo ! empty($message) ? $message : __('Nothing to show.', 'google-calendar-events'); |
|
| 642 | 642 | } else { |
| 643 | - if ( ! empty( $message ) ) { |
|
| 643 | + if ( ! empty($message)) { |
|
| 644 | 644 | echo $message; |
| 645 | 645 | } else { |
| 646 | - $from = Carbon::createFromTimestamp( $this->start, $calendar->timezone )->getTimestamp(); |
|
| 647 | - $to = Carbon::createFromTimestamp( $this->end, $calendar->timezone )->getTimestamp(); |
|
| 648 | - echo apply_filters( 'simcal_no_events_message', sprintf( |
|
| 649 | - __( 'Nothing from %1$s to %2$s.', 'google-calendar-events' ), |
|
| 650 | - date_i18n( $calendar->date_format, $from ), |
|
| 651 | - date_i18n( $calendar->date_format, $to ) |
|
| 652 | - ), $calendar->id, $from, $to ); |
|
| 646 | + $from = Carbon::createFromTimestamp($this->start, $calendar->timezone)->getTimestamp(); |
|
| 647 | + $to = Carbon::createFromTimestamp($this->end, $calendar->timezone)->getTimestamp(); |
|
| 648 | + echo apply_filters('simcal_no_events_message', sprintf( |
|
| 649 | + __('Nothing from %1$s to %2$s.', 'google-calendar-events'), |
|
| 650 | + date_i18n($calendar->date_format, $from), |
|
| 651 | + date_i18n($calendar->date_format, $to) |
|
| 652 | + ), $calendar->id, $from, $to); |
|
| 653 | 653 | } |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - echo "\t" . '</p>' . "\n"; |
|
| 656 | + echo "\t".'</p>'."\n"; |
|
| 657 | 657 | |
| 658 | 658 | endif; |
| 659 | 659 | |
| 660 | - echo '</' . $block_tag . '>'; |
|
| 660 | + echo '</'.$block_tag.'>'; |
|
| 661 | 661 | |
| 662 | - date_default_timezone_set( $calendar->site_timezone ); |
|
| 662 | + date_default_timezone_set($calendar->site_timezone); |
|
| 663 | 663 | |
| 664 | 664 | return ob_get_clean(); |
| 665 | 665 | } |
@@ -671,16 +671,16 @@ discard block |
||
| 671 | 671 | */ |
| 672 | 672 | public function draw_list_ajax() { |
| 673 | 673 | |
| 674 | - if ( isset( $_POST['ts'] ) && isset( $_POST['id'] ) ) { |
|
| 674 | + if (isset($_POST['ts']) && isset($_POST['id'])) { |
|
| 675 | 675 | |
| 676 | - $ts = absint( $_POST['ts'] ); |
|
| 677 | - $id = absint( $_POST['id'] ); |
|
| 676 | + $ts = absint($_POST['ts']); |
|
| 677 | + $id = absint($_POST['id']); |
|
| 678 | 678 | |
| 679 | - wp_send_json_success( $this->draw_list( $ts, $id ) ); |
|
| 679 | + wp_send_json_success($this->draw_list($ts, $id)); |
|
| 680 | 680 | |
| 681 | 681 | } else { |
| 682 | 682 | |
| 683 | - wp_send_json_error( 'Missing arguments in default calendar list ajax request.' ); |
|
| 683 | + wp_send_json_error('Missing arguments in default calendar list ajax request.'); |
|
| 684 | 684 | |
| 685 | 685 | } |
| 686 | 686 | } |
@@ -695,8 +695,8 @@ discard block |
||
| 695 | 695 | * |
| 696 | 696 | * @return bool |
| 697 | 697 | */ |
| 698 | - private function filter_events_before( $event ) { |
|
| 699 | - return intval( $event ) >= intval( $this->start ); |
|
| 698 | + private function filter_events_before($event) { |
|
| 699 | + return intval($event) >= intval($this->start); |
|
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | /** |
@@ -709,8 +709,8 @@ discard block |
||
| 709 | 709 | * |
| 710 | 710 | * @return bool |
| 711 | 711 | */ |
| 712 | - private function filter_events_after( $event ) { |
|
| 713 | - return intval( $event ) < intval( $this->end ); |
|
| 712 | + private function filter_events_after($event) { |
|
| 713 | + return intval($event) < intval($this->end); |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | use SimpleCalendar\Events\Event; |
| 14 | 14 | use SimpleCalendar\Calendars\Default_Calendar; |
| 15 | 15 | |
| 16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 16 | +if ( ! defined('ABSPATH')) { |
|
| 17 | 17 | exit; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @param string|Calendar $calendar |
| 57 | 57 | */ |
| 58 | - public function __construct( $calendar = '' ) { |
|
| 58 | + public function __construct($calendar = '') { |
|
| 59 | 59 | $this->calendar = $calendar; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @return string |
| 90 | 90 | */ |
| 91 | 91 | public function get_name() { |
| 92 | - return __( 'Grid', 'google-calendar-events' ); |
|
| 92 | + return __('Grid', 'google-calendar-events'); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | * @since 3.0.0 |
| 99 | 99 | */ |
| 100 | 100 | public function add_ajax_actions() { |
| 101 | - add_action( 'wp_ajax_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) ); |
|
| 102 | - add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) ); |
|
| 101 | + add_action('wp_ajax_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax')); |
|
| 102 | + add_action('wp_ajax_nopriv_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax')); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -113,28 +113,28 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return array |
| 115 | 115 | */ |
| 116 | - public function scripts( $min = '' ) { |
|
| 116 | + public function scripts($min = '') { |
|
| 117 | 117 | return array( |
| 118 | 118 | 'simcal-qtip' => array( |
| 119 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/jquery.qtip' . $min . '.js', |
|
| 120 | - 'deps' => array( 'jquery' ), |
|
| 119 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/vendor/jquery.qtip'.$min.'.js', |
|
| 120 | + 'deps' => array('jquery'), |
|
| 121 | 121 | 'ver' => '2.2.1', |
| 122 | 122 | 'in_footer' => true, |
| 123 | 123 | ), |
| 124 | 124 | 'simcal-fullcal-moment' => array( |
| 125 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/moment' . $min . '.js', |
|
| 126 | - 'deps' => array( 'jquery' ), |
|
| 125 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/vendor/moment'.$min.'.js', |
|
| 126 | + 'deps' => array('jquery'), |
|
| 127 | 127 | 'ver' => '', |
| 128 | 128 | 'in_footer' => true, |
| 129 | 129 | ), |
| 130 | 130 | 'simcal-moment-timezone' => array( |
| 131 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/moment-timezone-with-data' . $min . '.js', |
|
| 132 | - 'deps' => array( 'jquery' ), |
|
| 131 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/vendor/moment-timezone-with-data'.$min.'.js', |
|
| 132 | + 'deps' => array('jquery'), |
|
| 133 | 133 | 'ver' => '', |
| 134 | 134 | 'in_footer' => true, |
| 135 | 135 | ), |
| 136 | 136 | 'simcal-default-calendar' => array( |
| 137 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js', |
|
| 137 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js', |
|
| 138 | 138 | 'deps' => array( |
| 139 | 139 | 'jquery', |
| 140 | 140 | 'simcal-qtip', |
@@ -161,15 +161,15 @@ discard block |
||
| 161 | 161 | * |
| 162 | 162 | * @return array |
| 163 | 163 | */ |
| 164 | - public function styles( $min = '' ) { |
|
| 164 | + public function styles($min = '') { |
|
| 165 | 165 | return array( |
| 166 | 166 | 'simcal-qtip' => array( |
| 167 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/vendor/jquery.qtip' . $min . '.css', |
|
| 167 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/vendor/jquery.qtip'.$min.'.css', |
|
| 168 | 168 | 'ver' => '2.2.1', |
| 169 | 169 | 'media' => 'all', |
| 170 | 170 | ), |
| 171 | 171 | 'simcal-default-calendar-grid' => array( |
| 172 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-grid' . $min . '.css', |
|
| 172 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-grid'.$min.'.css', |
|
| 173 | 173 | 'deps' => array( |
| 174 | 174 | 'simcal-qtip', |
| 175 | 175 | ), |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | 'media' => 'all', |
| 178 | 178 | ), |
| 179 | 179 | 'simcal-default-calendar-list' => array( |
| 180 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-list' . $min . '.css', |
|
| 180 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-list'.$min.'.css', |
|
| 181 | 181 | 'deps' => array( |
| 182 | 182 | 'simcal-qtip', |
| 183 | 183 | ), |
@@ -196,22 +196,22 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | $calendar = $this->calendar; |
| 198 | 198 | |
| 199 | - if ( $calendar instanceof Default_Calendar ) { |
|
| 199 | + if ($calendar instanceof Default_Calendar) { |
|
| 200 | 200 | |
| 201 | 201 | ?> |
| 202 | 202 | |
| 203 | - <?php edit_post_link( __( 'Edit Calendar', 'google-calendar-events' ), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id ); ?> |
|
| 203 | + <?php edit_post_link(__('Edit Calendar', 'google-calendar-events'), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id); ?> |
|
| 204 | 204 | |
| 205 | 205 | <table class="simcal-calendar-grid" |
| 206 | 206 | data-event-bubble-trigger="<?php echo $calendar->event_bubble_trigger; ?>"> |
| 207 | 207 | <thead class="simcal-calendar-head"> |
| 208 | 208 | <tr> |
| 209 | - <?php if ( ! $calendar->static ) { ?> |
|
| 210 | - <th class="simcal-nav simcal-prev-wrapper" colspan="<?php echo apply_filters( 'simcal_prev_cols', '1' ); ?>"> |
|
| 211 | - <button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e( 'Previous Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-left"></i></button> |
|
| 209 | + <?php if ( ! $calendar->static) { ?> |
|
| 210 | + <th class="simcal-nav simcal-prev-wrapper" colspan="<?php echo apply_filters('simcal_prev_cols', '1'); ?>"> |
|
| 211 | + <button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e('Previous Month', 'google-calendar-events'); ?>"><i class="simcal-icon-left"></i></button> |
|
| 212 | 212 | </th> |
| 213 | 213 | <?php } ?> |
| 214 | - <th colspan="<?php echo apply_filters( 'simcal_current_cols', $calendar->static ? '7' : '5' ); ?>" |
|
| 214 | + <th colspan="<?php echo apply_filters('simcal_current_cols', $calendar->static ? '7' : '5'); ?>" |
|
| 215 | 215 | class="simcal-nav simcal-current" |
| 216 | 216 | data-calendar-current="<?php echo $calendar->start; ?>"> |
| 217 | 217 | <?php |
@@ -220,26 +220,26 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | // Display month and year according to user date format preference. |
| 222 | 222 | |
| 223 | - $year_pos = strcspn( $calendar->date_format, 'Y y' ); |
|
| 224 | - $month_pos = strcspn( $calendar->date_format, 'F M m n' ); |
|
| 223 | + $year_pos = strcspn($calendar->date_format, 'Y y'); |
|
| 224 | + $month_pos = strcspn($calendar->date_format, 'F M m n'); |
|
| 225 | 225 | |
| 226 | - $current = array( 'month' => 'F', 'year' => 'Y' ); |
|
| 226 | + $current = array('month' => 'F', 'year' => 'Y'); |
|
| 227 | 227 | |
| 228 | - if ( $year_pos < $month_pos ) { |
|
| 229 | - $current = array_reverse( $current ); |
|
| 228 | + if ($year_pos < $month_pos) { |
|
| 229 | + $current = array_reverse($current); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - foreach ( $current as $k => $v ) { |
|
| 233 | - echo ' <span class="simcal-current-' . $k , '">' . date_i18n( $v, $calendar->start ) . '</span> '; |
|
| 232 | + foreach ($current as $k => $v) { |
|
| 233 | + echo ' <span class="simcal-current-'.$k, '">'.date_i18n($v, $calendar->start).'</span> '; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | echo '</h3>'; |
| 237 | 237 | |
| 238 | 238 | ?> |
| 239 | 239 | </th> |
| 240 | - <?php if ( ! $calendar->static ) { ?> |
|
| 241 | - <th class="simcal-nav simcal-next-wrapper" colspan="<?php echo apply_filters( 'simcal_next_cols', '1' ); ?>"> |
|
| 242 | - <button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e( 'Next Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-right"></i></button> |
|
| 240 | + <?php if ( ! $calendar->static) { ?> |
|
| 241 | + <th class="simcal-nav simcal-next-wrapper" colspan="<?php echo apply_filters('simcal_next_cols', '1'); ?>"> |
|
| 242 | + <button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e('Next Month', 'google-calendar-events'); ?>"><i class="simcal-icon-right"></i></button> |
|
| 243 | 243 | </th> |
| 244 | 244 | <?php } ?> |
| 245 | 245 | </tr> |
@@ -249,28 +249,28 @@ discard block |
||
| 249 | 249 | // Print day names in short or long form for different viewport sizes. |
| 250 | 250 | |
| 251 | 251 | $week_starts = $calendar->week_starts; |
| 252 | - $week_days_short = simcal_get_calendar_names_i18n( 'day', 'short' ); |
|
| 253 | - $week_days_full = simcal_get_calendar_names_i18n( 'day', 'full' ); |
|
| 252 | + $week_days_short = simcal_get_calendar_names_i18n('day', 'short'); |
|
| 253 | + $week_days_full = simcal_get_calendar_names_i18n('day', 'full'); |
|
| 254 | 254 | |
| 255 | - for ( $i = $week_starts; $i <= 6; $i ++ ) : |
|
| 255 | + for ($i = $week_starts; $i <= 6; $i++) : |
|
| 256 | 256 | |
| 257 | 257 | ?> |
| 258 | 258 | <th class="simcal-week-day simcal-week-day-<?php echo $i ?>" |
| 259 | - data-screen-small="<?php echo mb_substr( $week_days_short[ $i ], 0, 1, 'UTF-8' ); ?>" |
|
| 260 | - data-screen-medium="<?php echo $week_days_short[ $i ]; ?>" |
|
| 261 | - data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th> |
|
| 259 | + data-screen-small="<?php echo mb_substr($week_days_short[$i], 0, 1, 'UTF-8'); ?>" |
|
| 260 | + data-screen-medium="<?php echo $week_days_short[$i]; ?>" |
|
| 261 | + data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th> |
|
| 262 | 262 | <?php |
| 263 | 263 | |
| 264 | 264 | endfor; |
| 265 | 265 | |
| 266 | - if ( $week_starts !== 0 ) : |
|
| 267 | - for ( $i = 0; $i < $week_starts; $i ++ ) : |
|
| 266 | + if ($week_starts !== 0) : |
|
| 267 | + for ($i = 0; $i < $week_starts; $i++) : |
|
| 268 | 268 | |
| 269 | 269 | ?> |
| 270 | 270 | <th class="simcal-week-day simcal-week-day-<?php echo $i ?>" |
| 271 | - data-screen-small="<?php echo mb_substr( $week_days_short[ $i ], 0, 1, 'UTF-8' ); ?>" |
|
| 272 | - data-screen-medium="<?php echo $week_days_short[ $i ]; ?>" |
|
| 273 | - data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th> |
|
| 271 | + data-screen-small="<?php echo mb_substr($week_days_short[$i], 0, 1, 'UTF-8'); ?>" |
|
| 272 | + data-screen-medium="<?php echo $week_days_short[$i]; ?>" |
|
| 273 | + data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th> |
|
| 274 | 274 | <?php |
| 275 | 275 | |
| 276 | 276 | endfor; |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | </tr> |
| 281 | 281 | </thead> |
| 282 | 282 | |
| 283 | - <?php echo $this->draw_month( date( 'n', $calendar->start ), date( 'Y', $calendar->start ) ); ?> |
|
| 283 | + <?php echo $this->draw_month(date('n', $calendar->start), date('Y', $calendar->start)); ?> |
|
| 284 | 284 | |
| 285 | 285 | </table> |
| 286 | 286 | |
@@ -306,85 +306,85 @@ discard block |
||
| 306 | 306 | * |
| 307 | 307 | * @return string |
| 308 | 308 | */ |
| 309 | - private function draw_month( $month, $year, $id = 0 ) { |
|
| 309 | + private function draw_month($month, $year, $id = 0) { |
|
| 310 | 310 | |
| 311 | 311 | $calendar = $this->calendar; |
| 312 | - if ( empty( $calendar ) ) { |
|
| 313 | - $calendar = simcal_get_calendar( intval( $id ) ); |
|
| 314 | - if ( ! $calendar ) { |
|
| 312 | + if (empty($calendar)) { |
|
| 313 | + $calendar = simcal_get_calendar(intval($id)); |
|
| 314 | + if ( ! $calendar) { |
|
| 315 | 315 | return ''; |
| 316 | 316 | } |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | $events = $calendar->events; |
| 320 | 320 | |
| 321 | - $feed = simcal_get_feed( $calendar ); |
|
| 322 | - $feed_timezone = get_post_meta( $feed->post_id, '_feed_timezone', true ); |
|
| 321 | + $feed = simcal_get_feed($calendar); |
|
| 322 | + $feed_timezone = get_post_meta($feed->post_id, '_feed_timezone', true); |
|
| 323 | 323 | |
| 324 | 324 | // Variables to cycle days in current month and find today in calendar. |
| 325 | 325 | $now = $calendar->now; |
| 326 | - $current = Carbon::create( $year, $month, 1, 0, 0, 0, $calendar->timezone ); |
|
| 326 | + $current = Carbon::create($year, $month, 1, 0, 0, 0, $calendar->timezone); |
|
| 327 | 327 | $current_min = $current->getTimestamp(); |
| 328 | 328 | $current_max = $current->endOfDay()->getTimestamp(); |
| 329 | 329 | |
| 330 | 330 | // Calendar grid variables. |
| 331 | 331 | $week_starts = $calendar->week_starts; |
| 332 | - $week_of_year = $current->weekOfYear; // Relative count of the week number of the year. |
|
| 333 | - $month_starts = $current->dayOfWeek; // Day upon which the month starts. |
|
| 334 | - $days_in_month = $current->daysInMonth; // Number of days in the given month. |
|
| 332 | + $week_of_year = $current->weekOfYear; // Relative count of the week number of the year. |
|
| 333 | + $month_starts = $current->dayOfWeek; // Day upon which the month starts. |
|
| 334 | + $days_in_month = $current->daysInMonth; // Number of days in the given month. |
|
| 335 | 335 | |
| 336 | 336 | // Set current month events timestamp boundaries. |
| 337 | 337 | $this->start = $current_min; |
| 338 | 338 | $this->end = $current->endOfMonth()->timestamp; |
| 339 | 339 | |
| 340 | 340 | // Get daily events for this month. |
| 341 | - if ( $events && is_array( $events ) ) { |
|
| 341 | + if ($events && is_array($events)) { |
|
| 342 | 342 | |
| 343 | 343 | // Filter events within the boundaries previously set above. |
| 344 | - $timestamps = array_keys( $events ); |
|
| 345 | - $lower_bound = array_filter( $timestamps, array( $this, 'filter_events_before' ) ); |
|
| 346 | - $higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after' ) ); |
|
| 347 | - $filtered = ( is_array( $events ) && is_array( $higher_bound) ) && ! empty( $events ) && ! empty( $higher_bound ) ? array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) ) : array(); |
|
| 344 | + $timestamps = array_keys($events); |
|
| 345 | + $lower_bound = array_filter($timestamps, array($this, 'filter_events_before')); |
|
| 346 | + $higher_bound = array_filter($lower_bound, array($this, 'filter_events_after')); |
|
| 347 | + $filtered = (is_array($events) && is_array($higher_bound)) && ! empty($events) && ! empty($higher_bound) ? array_intersect_key($events, array_combine($higher_bound, $higher_bound)) : array(); |
|
| 348 | 348 | |
| 349 | 349 | // Put resulting events in an associative array, with day of the month as key for easy retrieval in calendar days loop. |
| 350 | 350 | $day_events = array(); |
| 351 | - foreach ( $filtered as $timestamp => $events_in_day ) { |
|
| 352 | - foreach ( $events_in_day as $event ) { |
|
| 353 | - if ( $event instanceof Event ){ |
|
| 354 | - $day = intval( Carbon::createFromTimestamp( $timestamp, $event->timezone )->endOfDay()->day ); |
|
| 355 | - $day_events[ $day ][] = $event; |
|
| 351 | + foreach ($filtered as $timestamp => $events_in_day) { |
|
| 352 | + foreach ($events_in_day as $event) { |
|
| 353 | + if ($event instanceof Event) { |
|
| 354 | + $day = intval(Carbon::createFromTimestamp($timestamp, $event->timezone)->endOfDay()->day); |
|
| 355 | + $day_events[$day][] = $event; |
|
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - ksort( $day_events, SORT_NUMERIC ); |
|
| 360 | + ksort($day_events, SORT_NUMERIC); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | ob_start(); |
| 364 | 364 | |
| 365 | - echo '<tbody class="simcal-month simcal-month-' . $month . '">' . "\n"; |
|
| 366 | - echo "\t" . '<tr class="simcal-week simcal-week-' . $week_of_year . '">'; |
|
| 365 | + echo '<tbody class="simcal-month simcal-month-'.$month.'">'."\n"; |
|
| 366 | + echo "\t".'<tr class="simcal-week simcal-week-'.$week_of_year.'">'; |
|
| 367 | 367 | |
| 368 | 368 | $days_in_row = 0; |
| 369 | 369 | // Week may start on an arbitrary day (sun, 0 - sat, 6). |
| 370 | 370 | $week_day = $week_starts; |
| 371 | 371 | |
| 372 | 372 | // This fixes a possible bug when a month starts by Sunday (0). |
| 373 | - if ( 0 !== $week_starts ) { |
|
| 373 | + if (0 !== $week_starts) { |
|
| 374 | 374 | $b = $month_starts === 0 ? 7 : $month_starts; |
| 375 | 375 | } else { |
| 376 | 376 | $b = $month_starts; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | // Void days in first week. |
| 380 | - for ( $a = $week_starts; $a < $b; $a++ ) : |
|
| 380 | + for ($a = $week_starts; $a < $b; $a++) : |
|
| 381 | 381 | |
| 382 | - $last_void_day_class = ( $a === ( $b - 1 ) ) ? 'simcal-day-void-last' : ''; |
|
| 382 | + $last_void_day_class = ($a === ($b - 1)) ? 'simcal-day-void-last' : ''; |
|
| 383 | 383 | |
| 384 | - echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n"; |
|
| 384 | + echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n"; |
|
| 385 | 385 | |
| 386 | 386 | // Reset day of the week count (sun, 0 - sat, 6). |
| 387 | - if ( $week_day === 6 ) { |
|
| 387 | + if ($week_day === 6) { |
|
| 388 | 388 | $week_day = -1; |
| 389 | 389 | } |
| 390 | 390 | $week_day++; |
@@ -394,103 +394,103 @@ discard block |
||
| 394 | 394 | endfor; |
| 395 | 395 | |
| 396 | 396 | // Actual days of the month. |
| 397 | - for ( $day = 1; $day <= $days_in_month; $day++ ) : |
|
| 397 | + for ($day = 1; $day <= $days_in_month; $day++) : |
|
| 398 | 398 | |
| 399 | 399 | $count = 0; |
| 400 | 400 | $calendar_classes = array(); |
| 401 | - $day_classes = 'simcal-day-' . $day . ' simcal-weekday-' . $week_day; |
|
| 401 | + $day_classes = 'simcal-day-'.$day.' simcal-weekday-'.$week_day; |
|
| 402 | 402 | |
| 403 | 403 | $border_style = $bg_color = $color = ''; |
| 404 | 404 | |
| 405 | 405 | // Is this the present, the past or the future, Doc? |
| 406 | - if ( $current_min <= $now && $current_max >= $now ) { |
|
| 406 | + if ($current_min <= $now && $current_max >= $now) { |
|
| 407 | 407 | $day_classes .= ' simcal-today simcal-present simcal-day'; |
| 408 | - $the_color = new Color( $calendar->today_color ); |
|
| 409 | - $bg_color = '#' . $the_color->getHex(); |
|
| 408 | + $the_color = new Color($calendar->today_color); |
|
| 409 | + $bg_color = '#'.$the_color->getHex(); |
|
| 410 | 410 | $color = $the_color->isDark() ? '#ffffff' : '#000000'; |
| 411 | - $border_style = ' style="border: 1px solid ' . $bg_color . ';"'; |
|
| 412 | - } elseif ( $current_max < $now ) { |
|
| 411 | + $border_style = ' style="border: 1px solid '.$bg_color.';"'; |
|
| 412 | + } elseif ($current_max < $now) { |
|
| 413 | 413 | $day_classes .= ' simcal-past simcal-day'; |
| 414 | - } elseif ( $current_min > $now ) { |
|
| 414 | + } elseif ($current_min > $now) { |
|
| 415 | 415 | $day_classes .= ' simcal-future simcal-day'; |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | // Print events for the current day in loop, if found any. |
| 419 | - if ( isset( $day_events[ $day ] ) ) : |
|
| 419 | + if (isset($day_events[$day])) : |
|
| 420 | 420 | |
| 421 | 421 | $bullet_colors = array(); |
| 422 | 422 | |
| 423 | 423 | $list_events = '<ul class="simcal-events">'; |
| 424 | 424 | |
| 425 | - foreach ( $day_events[ $day ] as $event ) : |
|
| 425 | + foreach ($day_events[$day] as $event) : |
|
| 426 | 426 | |
| 427 | 427 | $event_classes = $event_visibility = ''; |
| 428 | 428 | |
| 429 | - if ( $event instanceof Event ) : |
|
| 429 | + if ($event instanceof Event) : |
|
| 430 | 430 | |
| 431 | - if ( $feed->type == 'grouped-calendars' ) { |
|
| 432 | - date_default_timezone_set( $feed_timezone ); |
|
| 431 | + if ($feed->type == 'grouped-calendars') { |
|
| 432 | + date_default_timezone_set($feed_timezone); |
|
| 433 | 433 | } else { |
| 434 | - date_default_timezone_set( $event->timezone ); |
|
| 434 | + date_default_timezone_set($event->timezone); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | // Store the calendar id where the event belongs (useful in grouped calendar feeds) |
| 438 | - $calendar_class = 'simcal-events-calendar-' . strval( $event->calendar ); |
|
| 439 | - $calendar_classes[] = $calendar_class ; |
|
| 438 | + $calendar_class = 'simcal-events-calendar-'.strval($event->calendar); |
|
| 439 | + $calendar_classes[] = $calendar_class; |
|
| 440 | 440 | |
| 441 | 441 | $recurring = $event->recurrence ? 'simcal-event-recurring ' : ''; |
| 442 | 442 | $has_location = $event->venue ? 'simcal-event-has-location ' : ''; |
| 443 | 443 | |
| 444 | - $event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class . ' simcal-tooltip'; |
|
| 444 | + $event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class.' simcal-tooltip'; |
|
| 445 | 445 | |
| 446 | 446 | // Toggle some events visibility if more than optional limit. |
| 447 | - if ( ( $calendar->events_limit > -1 ) && ( $count >= $calendar->events_limit ) ) : |
|
| 447 | + if (($calendar->events_limit > -1) && ($count >= $calendar->events_limit)) : |
|
| 448 | 448 | $event_classes .= ' simcal-event-toggled'; |
| 449 | 449 | $event_visibility = ' style="display: none"'; |
| 450 | 450 | endif; |
| 451 | 451 | |
| 452 | 452 | // Event title in list. |
| 453 | - $title = ! empty( $event->title ) ? trim( $event->title ) : __( 'Event', 'google-calendar-events' ); |
|
| 454 | - if ( $calendar->trim_titles >= 1 ) { |
|
| 455 | - $title = strlen( $title ) > $calendar->trim_titles ? mb_substr( $title, 0, $calendar->trim_titles ) . '…' : $title; |
|
| 453 | + $title = ! empty($event->title) ? trim($event->title) : __('Event', 'google-calendar-events'); |
|
| 454 | + if ($calendar->trim_titles >= 1) { |
|
| 455 | + $title = strlen($title) > $calendar->trim_titles ? mb_substr($title, 0, $calendar->trim_titles).'…' : $title; |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | // Event color. |
| 459 | 459 | $bullet = ''; |
| 460 | 460 | //$bullet_color = '#000'; |
| 461 | 461 | $event_color = $event->get_color(); |
| 462 | - if ( ! empty( $event_color ) ) { |
|
| 463 | - $bullet = '<span style="color: ' . $event_color . ';">■</span> '; |
|
| 462 | + if ( ! empty($event_color)) { |
|
| 463 | + $bullet = '<span style="color: '.$event_color.';">■</span> '; |
|
| 464 | 464 | $bullet_colors[] = $event_color; |
| 465 | 465 | } else { |
| 466 | 466 | $bullet_colors[] = '#000'; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | // Event contents. |
| 470 | - $list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . ' itemscope itemtype="http://schema.org/Event">' . "\n"; |
|
| 471 | - $list_events .= "\t\t" . '<span class="simcal-event-title">' . $bullet . $title . '</span>' . "\n"; |
|
| 472 | - $list_events .= "\t\t" . '<div class="simcal-event-details simcal-tooltip-content" style="display: none;">' . $calendar->get_event_html( $event ) . '</div>' . "\n"; |
|
| 473 | - $list_events .= "\t" . '</li>' . "\n"; |
|
| 470 | + $list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.' itemscope itemtype="http://schema.org/Event">'."\n"; |
|
| 471 | + $list_events .= "\t\t".'<span class="simcal-event-title">'.$bullet.$title.'</span>'."\n"; |
|
| 472 | + $list_events .= "\t\t".'<div class="simcal-event-details simcal-tooltip-content" style="display: none;">'.$calendar->get_event_html($event).'</div>'."\n"; |
|
| 473 | + $list_events .= "\t".'</li>'."\n"; |
|
| 474 | 474 | |
| 475 | - $count ++; |
|
| 475 | + $count++; |
|
| 476 | 476 | |
| 477 | 477 | endif; |
| 478 | 478 | |
| 479 | 479 | endforeach; |
| 480 | 480 | |
| 481 | - if ( ( $current_min <= $now ) && ( $current_max >= $now ) ) { |
|
| 481 | + if (($current_min <= $now) && ($current_max >= $now)) { |
|
| 482 | 482 | $day_classes .= ' simcal-today-has-events'; |
| 483 | 483 | } |
| 484 | - $day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events'; |
|
| 484 | + $day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events'; |
|
| 485 | 485 | |
| 486 | - if ( $calendar_classes ) { |
|
| 487 | - $day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) ); |
|
| 486 | + if ($calendar_classes) { |
|
| 487 | + $day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes))); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - $list_events .= '</ul>' . "\n"; |
|
| 490 | + $list_events .= '</ul>'."\n"; |
|
| 491 | 491 | |
| 492 | 492 | // Optional button to toggle hidden events in list. |
| 493 | - if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) : |
|
| 493 | + if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) : |
|
| 494 | 494 | $list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>'; |
| 495 | 495 | endif; |
| 496 | 496 | |
@@ -502,49 +502,49 @@ discard block |
||
| 502 | 502 | endif; |
| 503 | 503 | |
| 504 | 504 | // The actual days with numbers and events in each row cell. |
| 505 | - echo '<td class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n"; |
|
| 506 | - |
|
| 507 | - if ( $color ) { |
|
| 508 | - $day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"'; |
|
| 509 | - } elseif ( $count > 0 ) { |
|
| 510 | - $the_color = new Color( $calendar->days_events_color ); |
|
| 511 | - $color = ! $color ? ( $the_color->isDark() ? '#ffffff' : '#000000' ) : $color; |
|
| 512 | - $bg_color = ! $bg_color ? '#' . $the_color->getHex() : $bg_color; |
|
| 513 | - $day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"'; |
|
| 505 | + echo '<td class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n"; |
|
| 506 | + |
|
| 507 | + if ($color) { |
|
| 508 | + $day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"'; |
|
| 509 | + } elseif ($count > 0) { |
|
| 510 | + $the_color = new Color($calendar->days_events_color); |
|
| 511 | + $color = ! $color ? ($the_color->isDark() ? '#ffffff' : '#000000') : $color; |
|
| 512 | + $bg_color = ! $bg_color ? '#'.$the_color->getHex() : $bg_color; |
|
| 513 | + $day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"'; |
|
| 514 | 514 | } else { |
| 515 | 515 | $day_style = ''; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - echo "\t" . '<div' . $border_style . '>' . "\n"; |
|
| 519 | - echo "\t\t" . '<span class="simcal-day-label simcal-day-number"' . $day_style . '>' . $day . '</span>' . "\n"; |
|
| 520 | - echo "\t\t" . $list_events . "\n"; |
|
| 518 | + echo "\t".'<div'.$border_style.'>'."\n"; |
|
| 519 | + echo "\t\t".'<span class="simcal-day-label simcal-day-number"'.$day_style.'>'.$day.'</span>'."\n"; |
|
| 520 | + echo "\t\t".$list_events."\n"; |
|
| 521 | 521 | echo "\t\t"; |
| 522 | 522 | echo '<span class="simcal-events-dots" style="display: none;">'; |
| 523 | 523 | |
| 524 | 524 | // Event bullets for calendar mobile mode. |
| 525 | - for( $i = 0; $i < $count; $i++ ) { |
|
| 526 | - echo '<b style="color: ' . $bullet_colors[ $i ] . ';"> • </b>'; |
|
| 525 | + for ($i = 0; $i < $count; $i++) { |
|
| 526 | + echo '<b style="color: '.$bullet_colors[$i].';"> • </b>'; |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | - echo '</span>' . "\n"; |
|
| 530 | - echo "\t" . '</div>' . "\n"; |
|
| 531 | - echo '</td>' . "\n"; |
|
| 529 | + echo '</span>'."\n"; |
|
| 530 | + echo "\t".'</div>'."\n"; |
|
| 531 | + echo '</td>'."\n"; |
|
| 532 | 532 | |
| 533 | 533 | // Reset day of the week count (sun, 0 - sat, 6). |
| 534 | - if ( $week_day === 6 ) { |
|
| 534 | + if ($week_day === 6) { |
|
| 535 | 535 | $week_day = - 1; |
| 536 | 536 | } |
| 537 | 537 | $week_day++; |
| 538 | 538 | |
| 539 | 539 | // Reset count of days for this row (0-6). |
| 540 | - if ( $days_in_row === 6 ) : |
|
| 540 | + if ($days_in_row === 6) : |
|
| 541 | 541 | |
| 542 | 542 | // Close the week row. |
| 543 | 543 | echo '</tr>'; |
| 544 | 544 | |
| 545 | 545 | // Open a new week row. |
| 546 | - if ( $day < $days_in_month ) { |
|
| 547 | - echo '<tr class="simcal-week simcal-week-' . $week_of_year++ . '">' . "\n"; |
|
| 546 | + if ($day < $days_in_month) { |
|
| 547 | + echo '<tr class="simcal-week simcal-week-'.$week_of_year++.'">'."\n"; |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | $days_in_row = -1; |
@@ -553,27 +553,27 @@ discard block |
||
| 553 | 553 | |
| 554 | 554 | $days_in_row++; |
| 555 | 555 | |
| 556 | - $current_min = Carbon::createFromTimestamp( $current_min, $calendar->timezone )->addDay()->getTimestamp(); |
|
| 557 | - $current_max = Carbon::createFromTimestamp( $current_max, $calendar->timezone )->addDay()->getTimestamp(); |
|
| 556 | + $current_min = Carbon::createFromTimestamp($current_min, $calendar->timezone)->addDay()->getTimestamp(); |
|
| 557 | + $current_max = Carbon::createFromTimestamp($current_max, $calendar->timezone)->addDay()->getTimestamp(); |
|
| 558 | 558 | |
| 559 | 559 | endfor; |
| 560 | 560 | |
| 561 | 561 | // Void days at the end of the month. |
| 562 | - $remainder_days = ( 6 - $days_in_row ); |
|
| 562 | + $remainder_days = (6 - $days_in_row); |
|
| 563 | 563 | |
| 564 | - for ( $i = 0; $i <= $remainder_days; $i ++ ) { |
|
| 564 | + for ($i = 0; $i <= $remainder_days; $i++) { |
|
| 565 | 565 | |
| 566 | - $last_void_day_class = ( $i == $remainder_days ) ? 'simcal-day-void-last' : ''; |
|
| 566 | + $last_void_day_class = ($i == $remainder_days) ? 'simcal-day-void-last' : ''; |
|
| 567 | 567 | |
| 568 | - echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n"; |
|
| 568 | + echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n"; |
|
| 569 | 569 | |
| 570 | 570 | $week_day++; |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - echo "\t" . '</tr>' . "\n"; |
|
| 574 | - echo '</tbody>' . "\n"; |
|
| 573 | + echo "\t".'</tr>'."\n"; |
|
| 574 | + echo '</tbody>'."\n"; |
|
| 575 | 575 | |
| 576 | - date_default_timezone_set( $calendar->site_timezone ); |
|
| 576 | + date_default_timezone_set($calendar->site_timezone); |
|
| 577 | 577 | |
| 578 | 578 | return ob_get_clean(); |
| 579 | 579 | } |
@@ -585,17 +585,17 @@ discard block |
||
| 585 | 585 | */ |
| 586 | 586 | public function draw_grid_ajax() { |
| 587 | 587 | |
| 588 | - if ( isset( $_POST['month'] ) && isset( $_POST['year'] ) && isset( $_POST['id'] ) ) { |
|
| 588 | + if (isset($_POST['month']) && isset($_POST['year']) && isset($_POST['id'])) { |
|
| 589 | 589 | |
| 590 | - $month = absint( $_POST['month'] ); |
|
| 591 | - $year = absint( $_POST['year'] ); |
|
| 592 | - $id = absint( $_POST['id'] ); |
|
| 590 | + $month = absint($_POST['month']); |
|
| 591 | + $year = absint($_POST['year']); |
|
| 592 | + $id = absint($_POST['id']); |
|
| 593 | 593 | |
| 594 | - wp_send_json_success( $this->draw_month( $month, $year, $id ) ); |
|
| 594 | + wp_send_json_success($this->draw_month($month, $year, $id)); |
|
| 595 | 595 | |
| 596 | 596 | } else { |
| 597 | 597 | |
| 598 | - wp_send_json_error( 'Missing arguments in default calendar grid ajax request.' ); |
|
| 598 | + wp_send_json_error('Missing arguments in default calendar grid ajax request.'); |
|
| 599 | 599 | |
| 600 | 600 | } |
| 601 | 601 | |
@@ -611,8 +611,8 @@ discard block |
||
| 611 | 611 | * |
| 612 | 612 | * @return bool |
| 613 | 613 | */ |
| 614 | - private function filter_events_before( $event ) { |
|
| 615 | - return intval( $event ) >= intval( $this->start ); |
|
| 614 | + private function filter_events_before($event) { |
|
| 615 | + return intval($event) >= intval($this->start); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | /** |
@@ -625,8 +625,8 @@ discard block |
||
| 625 | 625 | * |
| 626 | 626 | * @return bool |
| 627 | 627 | */ |
| 628 | - private function filter_events_after( $event ) { |
|
| 629 | - return intval( $event ) < intval( $this->end ); |
|
| 628 | + private function filter_events_after($event) { |
|
| 629 | + return intval($event) < intval($this->end); |
|
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | use SimpleCalendar\Abstracts\Calendar; |
| 10 | 10 | use SimpleCalendar\Abstracts\Admin_Page; |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -39,20 +39,20 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $this->id = 'calendars'; |
| 41 | 41 | $this->option_group = 'settings'; |
| 42 | - $this->label = __( 'Calendars', 'google-calendar-events' ); |
|
| 42 | + $this->label = __('Calendars', 'google-calendar-events'); |
|
| 43 | 43 | //$this->description = __( 'Manage calendar preferences and calendar types settings and options.', 'google-calendar-events' ); |
| 44 | 44 | |
| 45 | 45 | $calendars = simcal_get_calendar_types(); |
| 46 | 46 | $calendar_settings = array(); |
| 47 | - if ( ! empty( $calendars ) && is_array( $calendars ) ) { |
|
| 48 | - foreach ( $calendars as $calendar => $views ) { |
|
| 47 | + if ( ! empty($calendars) && is_array($calendars)) { |
|
| 48 | + foreach ($calendars as $calendar => $views) { |
|
| 49 | 49 | |
| 50 | - $calendar_type = simcal_get_calendar( $calendar ); |
|
| 50 | + $calendar_type = simcal_get_calendar($calendar); |
|
| 51 | 51 | |
| 52 | - if ( $calendar_type instanceof Calendar ) { |
|
| 52 | + if ($calendar_type instanceof Calendar) { |
|
| 53 | 53 | $settings = $calendar_type->settings_fields(); |
| 54 | - if ( ! empty( $settings ) ) { |
|
| 55 | - $calendar_settings[ $calendar ] = $settings; |
|
| 54 | + if ( ! empty($settings)) { |
|
| 55 | + $calendar_settings[$calendar] = $settings; |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -74,17 +74,17 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | $sections = array( |
| 76 | 76 | 'general' => array( |
| 77 | - 'title' => __( 'General', 'google-calendar-events' ), |
|
| 77 | + 'title' => __('General', 'google-calendar-events'), |
|
| 78 | 78 | 'description' => '', |
| 79 | 79 | ), |
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | 82 | $calendar_types = $this->calendar_types; |
| 83 | 83 | |
| 84 | - if ( ! empty( $calendar_types ) && is_array( $calendar_types ) ) { |
|
| 85 | - foreach ( $calendar_types as $calendar_type => $type ) { |
|
| 84 | + if ( ! empty($calendar_types) && is_array($calendar_types)) { |
|
| 85 | + foreach ($calendar_types as $calendar_type => $type) { |
|
| 86 | 86 | |
| 87 | - $sections[ $calendar_type ] = array( |
|
| 87 | + $sections[$calendar_type] = array( |
|
| 88 | 88 | 'title' => $type['name'], |
| 89 | 89 | 'description' => $type['description'], |
| 90 | 90 | ); |
@@ -92,9 +92,9 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - arsort( $calendar_types ); |
|
| 95 | + arsort($calendar_types); |
|
| 96 | 96 | |
| 97 | - return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id .'_sections', $sections ); |
|
| 97 | + return apply_filters('simcal_add_'.$this->option_group.'_'.$this->id.'_sections', $sections); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $fields = array(); |
| 110 | 110 | $feed_types = $this->calendar_types; |
| 111 | - $this->values = get_option( 'simple-calendar_' . $this->option_group . '_' . $this->id ); |
|
| 111 | + $this->values = get_option('simple-calendar_'.$this->option_group.'_'.$this->id); |
|
| 112 | 112 | |
| 113 | - foreach ( $this->sections as $section => $contents ) : |
|
| 113 | + foreach ($this->sections as $section => $contents) : |
|
| 114 | 114 | |
| 115 | - if ( 'general' == $section ) { |
|
| 115 | + if ('general' == $section) { |
|
| 116 | 116 | |
| 117 | 117 | $options = array(); |
| 118 | 118 | $post_types = get_post_types( |
@@ -124,36 +124,36 @@ discard block |
||
| 124 | 124 | 'objects', |
| 125 | 125 | 'not' |
| 126 | 126 | ); |
| 127 | - unset( $post_types['attachment'] ); |
|
| 128 | - unset( $post_types['calendar'] ); |
|
| 129 | - unset( $post_types['gce_feed'] ); |
|
| 130 | - foreach ( $post_types as $slug => $post_type ) { |
|
| 131 | - $options[ $slug ] = $post_type->label; |
|
| 127 | + unset($post_types['attachment']); |
|
| 128 | + unset($post_types['calendar']); |
|
| 129 | + unset($post_types['gce_feed']); |
|
| 130 | + foreach ($post_types as $slug => $post_type) { |
|
| 131 | + $options[$slug] = $post_type->label; |
|
| 132 | 132 | } |
| 133 | - asort( $options ); |
|
| 133 | + asort($options); |
|
| 134 | 134 | |
| 135 | - $fields[ $section ][] = array( |
|
| 135 | + $fields[$section][] = array( |
|
| 136 | 136 | 'type' => 'select', |
| 137 | 137 | 'multiselect' => 'multiselect', |
| 138 | 138 | 'enhanced' => 'enhanced', |
| 139 | - 'title' => __( 'Attach Calendars', 'google-calendar-events' ), |
|
| 140 | - 'tooltip' => __( 'You can choose on which content types to add the ability to attach calendars.', 'google-calendar-events' ), |
|
| 141 | - 'name' => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][attach_calendars_posts]', |
|
| 142 | - 'id' => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-attach-calendars-posts', |
|
| 143 | - 'value' => $this->get_option_value( $section, 'attach_calendars_posts' ), |
|
| 139 | + 'title' => __('Attach Calendars', 'google-calendar-events'), |
|
| 140 | + 'tooltip' => __('You can choose on which content types to add the ability to attach calendars.', 'google-calendar-events'), |
|
| 141 | + 'name' => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][attach_calendars_posts]', |
|
| 142 | + 'id' => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-attach-calendars-posts', |
|
| 143 | + 'value' => $this->get_option_value($section, 'attach_calendars_posts'), |
|
| 144 | 144 | 'default' => 'post,page', |
| 145 | 145 | 'options' => $options, |
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | - } elseif ( isset( $feed_types[ $section ]['fields'] ) ) { |
|
| 148 | + } elseif (isset($feed_types[$section]['fields'])) { |
|
| 149 | 149 | |
| 150 | - foreach ( $feed_types[ $section ]['fields'] as $key => $args ) { |
|
| 150 | + foreach ($feed_types[$section]['fields'] as $key => $args) { |
|
| 151 | 151 | |
| 152 | - $fields[ $section ][] = array_merge( $args, array( |
|
| 153 | - 'name' => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][' . $key . ']', |
|
| 154 | - 'id' => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $key, |
|
| 155 | - 'value' => $this->get_option_value( $section, $key ) |
|
| 156 | - ) ); |
|
| 152 | + $fields[$section][] = array_merge($args, array( |
|
| 153 | + 'name' => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.']['.$key.']', |
|
| 154 | + 'id' => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-'.$key, |
|
| 155 | + 'value' => $this->get_option_value($section, $key) |
|
| 156 | + )); |
|
| 157 | 157 | |
| 158 | 158 | } |
| 159 | 159 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | endforeach; |
| 163 | 163 | |
| 164 | - return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id . '_fields', $fields ); |
|
| 164 | + return apply_filters('simcal_add_'.$this->option_group.'_'.$this->id.'_fields', $fields); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | } |
@@ -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,12 +49,12 @@ 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 | 60 | $page = add_dashboard_page( |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | $welcome_page_name, |
| 63 | 63 | 'manage_options', |
| 64 | 64 | 'simple-calendar_about', |
| 65 | - array( $this, 'about_screen' ) |
|
| 65 | + array($this, 'about_screen') |
|
| 66 | 66 | ); |
| 67 | - add_action( 'admin_print_styles-' . $page, array( $this, 'styles' ) ); |
|
| 67 | + add_action('admin_print_styles-'.$page, array($this, 'styles')); |
|
| 68 | 68 | break; |
| 69 | 69 | |
| 70 | 70 | case 'simple-calendar_credits' : |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | $welcome_page_name, |
| 74 | 74 | 'manage_options', |
| 75 | 75 | 'simple-calendar_credits', |
| 76 | - array( $this, 'credits_screen' ) |
|
| 76 | + array($this, 'credits_screen') |
|
| 77 | 77 | ); |
| 78 | - add_action( 'admin_print_styles-' . $page, array( $this, 'styles' ) ); |
|
| 78 | + add_action('admin_print_styles-'.$page, array($this, 'styles')); |
|
| 79 | 79 | break; |
| 80 | 80 | |
| 81 | 81 | case 'simple-calendar_translators' : |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | $welcome_page_name, |
| 85 | 85 | 'manage_options', |
| 86 | 86 | 'simple-calendar_translators', |
| 87 | - array( $this, 'translators_screen' ) |
|
| 87 | + array($this, 'translators_screen') |
|
| 88 | 88 | ); |
| 89 | - add_action( 'admin_print_styles-' . $page, array( $this, 'styles' ) ); |
|
| 89 | + add_action('admin_print_styles-'.$page, array($this, 'styles')); |
|
| 90 | 90 | break; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | * @since 3.0.0 |
| 99 | 99 | */ |
| 100 | 100 | public function remove_submenu_pages() { |
| 101 | - remove_submenu_page( 'index.php', 'simple-calendar_about' ); |
|
| 102 | - remove_submenu_page( 'index.php', 'simple-calendar_credits' ); |
|
| 103 | - remove_submenu_page( 'index.php', 'simple-calendar_translators' ); |
|
| 101 | + remove_submenu_page('index.php', 'simple-calendar_about'); |
|
| 102 | + remove_submenu_page('index.php', 'simple-calendar_credits'); |
|
| 103 | + remove_submenu_page('index.php', 'simple-calendar_translators'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -129,18 +129,18 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | ?> |
| 131 | 131 | <p> |
| 132 | - <a href="<?php echo admin_url( 'edit.php?post_type=calendar' ); ?>" |
|
| 132 | + <a href="<?php echo admin_url('edit.php?post_type=calendar'); ?>" |
|
| 133 | 133 | class="button button-primary" |
| 134 | - ><?php _e( 'Calendars', 'google-calendar-events' ); ?></a> |
|
| 135 | - <a href="<?php echo esc_url( add_query_arg( 'page', 'simple-calendar_settings', admin_url( 'admin.php' ) ) ); ?>" |
|
| 134 | + ><?php _e('Calendars', 'google-calendar-events'); ?></a> |
|
| 135 | + <a href="<?php echo esc_url(add_query_arg('page', 'simple-calendar_settings', admin_url('admin.php'))); ?>" |
|
| 136 | 136 | class="button button-primary" |
| 137 | - ><?php _e( 'Settings', 'google-calendar-events' ); ?></a> |
|
| 138 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'welcome-page' ); ?>" |
|
| 137 | + ><?php _e('Settings', 'google-calendar-events'); ?></a> |
|
| 138 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'welcome-page'); ?>" |
|
| 139 | 139 | class="docs button button-primary" target="_blank" |
| 140 | - ><?php _e( 'Add-ons', 'google-calendar-events' ); ?></a> |
|
| 141 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'docs' ), 'core-plugin', 'welcome-page' ); ?>" |
|
| 140 | + ><?php _e('Add-ons', 'google-calendar-events'); ?></a> |
|
| 141 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('docs'), 'core-plugin', 'welcome-page'); ?>" |
|
| 142 | 142 | class="docs button button-primary" target="_blank" |
| 143 | - ><?php _e( 'Documentation', 'google-calendar-events' ); ?></a> |
|
| 143 | + ><?php _e('Documentation', 'google-calendar-events'); ?></a> |
|
| 144 | 144 | </p> |
| 145 | 145 | <?php |
| 146 | 146 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | <h1> |
| 158 | 158 | <?php |
| 159 | 159 | /* translators: %s prints the current version of the plugin. */ |
| 160 | - printf( __( 'Welcome to Simple Calendar %s', 'google-calendar-events' ), SIMPLE_CALENDAR_VERSION ); |
|
| 160 | + printf(__('Welcome to Simple Calendar %s', 'google-calendar-events'), SIMPLE_CALENDAR_VERSION); |
|
| 161 | 161 | ?> |
| 162 | 162 | </h1> |
| 163 | 163 | |
@@ -165,21 +165,21 @@ discard block |
||
| 165 | 165 | <?php |
| 166 | 166 | |
| 167 | 167 | // Difference message if updating vs fresh install. |
| 168 | - if ( 'update' == $this->install ) { |
|
| 169 | - $message = __( 'Thanks for updating to the latest version!', 'google-calendar-events' ); |
|
| 168 | + if ('update' == $this->install) { |
|
| 169 | + $message = __('Thanks for updating to the latest version!', 'google-calendar-events'); |
|
| 170 | 170 | } else { |
| 171 | - $message = __( 'Thanks for installing!', 'google-calendar-events' ); |
|
| 171 | + $message = __('Thanks for installing!', 'google-calendar-events'); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | echo $message; |
| 175 | 175 | |
| 176 | 176 | /* translators: %s prints the current version of the plugin. */ |
| 177 | - printf( ' ' . __( "Simple Calendar %s has a few display options to configure. ", 'google-calendar-events' ), SIMPLE_CALENDAR_VERSION ); |
|
| 177 | + printf(' '.__("Simple Calendar %s has a few display options to configure. ", 'google-calendar-events'), SIMPLE_CALENDAR_VERSION); |
|
| 178 | 178 | ?> |
| 179 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'docs' ), 'core-plugin', 'welcome-page' ); ?>" |
|
| 179 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('docs'), 'core-plugin', 'welcome-page'); ?>" |
|
| 180 | 180 | target="_blank" |
| 181 | - ><?php _e( 'Check out our documentation', 'google-calendar-events' ); ?></a> |
|
| 182 | - <?php _e( 'to get started now.', 'google-calendar-events' ); ?> |
|
| 181 | + ><?php _e('Check out our documentation', 'google-calendar-events'); ?></a> |
|
| 182 | + <?php _e('to get started now.', 'google-calendar-events'); ?> |
|
| 183 | 183 | </div> |
| 184 | 184 | |
| 185 | 185 | <div class="simcal-badge"> </div> |
@@ -187,21 +187,21 @@ discard block |
||
| 187 | 187 | <?php $this->main_nav_links(); ?> |
| 188 | 188 | |
| 189 | 189 | <h2 class="nav-tab-wrapper"> |
| 190 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_about' ) { |
|
| 190 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_about') { |
|
| 191 | 191 | echo 'nav-tab-active'; |
| 192 | 192 | } ?>" |
| 193 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_about' ), 'index.php' ) ) ); ?>" |
|
| 194 | - ><?php _e( "What's New", 'google-calendar-events' ); ?></a> |
|
| 195 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_credits' ) { |
|
| 193 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_about'), 'index.php'))); ?>" |
|
| 194 | + ><?php _e("What's New", 'google-calendar-events'); ?></a> |
|
| 195 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_credits') { |
|
| 196 | 196 | echo 'nav-tab-active'; |
| 197 | 197 | } ?>" |
| 198 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_credits' ), 'index.php' ) ) ); ?>" |
|
| 199 | - ><?php _e( 'Credits', 'google-calendar-events' ); ?></a> |
|
| 200 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_translators' ) { |
|
| 198 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_credits'), 'index.php'))); ?>" |
|
| 199 | + ><?php _e('Credits', 'google-calendar-events'); ?></a> |
|
| 200 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_translators') { |
|
| 201 | 201 | echo 'nav-tab-active'; |
| 202 | 202 | } ?>" |
| 203 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_translators' ), 'index.php' ) ) ); ?>" |
|
| 204 | - ><?php _e( 'Translators', 'google-calendar-events' ); ?></a> |
|
| 203 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_translators'), 'index.php'))); ?>" |
|
| 204 | + ><?php _e('Translators', 'google-calendar-events'); ?></a> |
|
| 205 | 205 | </h2> |
| 206 | 206 | <?php |
| 207 | 207 | |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | * @since 3.0.0 |
| 214 | 214 | */ |
| 215 | 215 | public function about_screen() { |
| 216 | - $welcome_image_about_path = SIMPLE_CALENDAR_ASSETS . '/images/welcome'; |
|
| 217 | - $welcome_addons_link = simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'welcome-page' ); |
|
| 216 | + $welcome_image_about_path = SIMPLE_CALENDAR_ASSETS.'/images/welcome'; |
|
| 217 | + $welcome_addons_link = simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'welcome-page'); |
|
| 218 | 218 | |
| 219 | 219 | ?> |
| 220 | 220 | <div id="simcal-welcome"> |
@@ -222,20 +222,20 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | <?php $this->intro(); ?> |
| 224 | 224 | |
| 225 | - <h3><?php _e( 'Configure event colors, number of events to display, grid or list style and more.', 'google-calendar-events' ); ?></h3> |
|
| 226 | - <img src="<?php echo $welcome_image_about_path . '/grid-view-basic.png'; ?>" /> |
|
| 225 | + <h3><?php _e('Configure event colors, number of events to display, grid or list style and more.', 'google-calendar-events'); ?></h3> |
|
| 226 | + <img src="<?php echo $welcome_image_about_path.'/grid-view-basic.png'; ?>" /> |
|
| 227 | 227 | |
| 228 | - <h3><?php _e( 'Mobile responsive and widget ready.', 'google-calendar-events' ); ?></h3> |
|
| 229 | - <img src="<?php echo $welcome_image_about_path . '/list-view-widget.png'; ?>" /> |
|
| 230 | - <img src="<?php echo $welcome_image_about_path . '/grid-view-widget-dark-theme.png'; ?>" /> |
|
| 228 | + <h3><?php _e('Mobile responsive and widget ready.', 'google-calendar-events'); ?></h3> |
|
| 229 | + <img src="<?php echo $welcome_image_about_path.'/list-view-widget.png'; ?>" /> |
|
| 230 | + <img src="<?php echo $welcome_image_about_path.'/grid-view-widget-dark-theme.png'; ?>" /> |
|
| 231 | 231 | |
| 232 | 232 | <h3> |
| 233 | - <?php _e( 'Add even more display options with add-ons like', 'google-calendar-events' ); ?> |
|
| 234 | - <a href="<?php echo $welcome_addons_link; ?>" target="_blank"><?php _e( 'FullCalendar and Google Calendar Pro', 'google-calendar-events' ); ?></a>. |
|
| 233 | + <?php _e('Add even more display options with add-ons like', 'google-calendar-events'); ?> |
|
| 234 | + <a href="<?php echo $welcome_addons_link; ?>" target="_blank"><?php _e('FullCalendar and Google Calendar Pro', 'google-calendar-events'); ?></a>. |
|
| 235 | 235 | </h3> |
| 236 | - <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> |
|
| 236 | + <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> |
|
| 237 | 237 | |
| 238 | - <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> |
|
| 238 | + <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> |
|
| 239 | 239 | |
| 240 | 240 | <hr/> |
| 241 | 241 | |
@@ -262,8 +262,8 @@ discard block |
||
| 262 | 262 | <?php |
| 263 | 263 | |
| 264 | 264 | printf( |
| 265 | - __( "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' ), |
|
| 266 | - simcal_get_url( 'github' ) |
|
| 265 | + __("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'), |
|
| 266 | + simcal_get_url('github') |
|
| 267 | 267 | ); |
| 268 | 268 | |
| 269 | 269 | ?> |
@@ -287,10 +287,10 @@ discard block |
||
| 287 | 287 | <div class="wrap about-wrap translators-wrap"> |
| 288 | 288 | <?php $this->intro(); ?> |
| 289 | 289 | <p class="about-description"> |
| 290 | - <?php _e( 'Simple Calendar has been kindly translated into several other languages by contributors from all over the world.', 'google-calendar-events' ); ?> |
|
| 290 | + <?php _e('Simple Calendar has been kindly translated into several other languages by contributors from all over the world.', 'google-calendar-events'); ?> |
|
| 291 | 291 | </p> |
| 292 | 292 | <p class="about-description"> |
| 293 | - <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> |
|
| 293 | + <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> |
|
| 294 | 294 | </p> |
| 295 | 295 | <?php |
| 296 | 296 | |
@@ -319,31 +319,31 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | $contributors = $this->get_contributors(); |
| 321 | 321 | |
| 322 | - if ( empty( $contributors ) ) { |
|
| 322 | + if (empty($contributors)) { |
|
| 323 | 323 | return ''; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | $contributor_list = '<ul class="wp-people-group">'; |
| 327 | 327 | |
| 328 | - foreach ( $contributors as $contributor ) { |
|
| 328 | + foreach ($contributors as $contributor) { |
|
| 329 | 329 | |
| 330 | 330 | // Skip contributor bots |
| 331 | - $contributor_bots = array( 'gitter-badger' ); |
|
| 332 | - if ( in_array( $contributor->login, $contributor_bots ) ) { |
|
| 331 | + $contributor_bots = array('gitter-badger'); |
|
| 332 | + if (in_array($contributor->login, $contributor_bots)) { |
|
| 333 | 333 | continue; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | $contributor_list .= '<li class="wp-person">'; |
| 337 | 337 | $contributor_list .= sprintf( |
| 338 | 338 | '<a href="%s" title="%s" target="_blank">%s</a>', |
| 339 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
| 340 | - esc_html( sprintf( __( 'View %s', 'google-calendar-events' ), $contributor->login ) ), |
|
| 341 | - sprintf( '<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url( $contributor->avatar_url ), esc_html( $contributor->login ) ) |
|
| 339 | + esc_url('https://github.com/'.$contributor->login), |
|
| 340 | + esc_html(sprintf(__('View %s', 'google-calendar-events'), $contributor->login)), |
|
| 341 | + sprintf('<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url($contributor->avatar_url), esc_html($contributor->login)) |
|
| 342 | 342 | ); |
| 343 | 343 | $contributor_list .= sprintf( |
| 344 | 344 | '<a class="web" href="%s" target="_blank">%s</a>', |
| 345 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
| 346 | - esc_html( $contributor->login ) |
|
| 345 | + esc_url('https://github.com/'.$contributor->login), |
|
| 346 | + esc_html($contributor->login) |
|
| 347 | 347 | ); |
| 348 | 348 | $contributor_list .= '</li>'; |
| 349 | 349 | |
@@ -363,24 +363,24 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | public function get_contributors() { |
| 365 | 365 | |
| 366 | - $contributors = get_transient( '_simple-calendar_contributors' ); |
|
| 367 | - if ( false !== $contributors ) { |
|
| 366 | + $contributors = get_transient('_simple-calendar_contributors'); |
|
| 367 | + if (false !== $contributors) { |
|
| 368 | 368 | return $contributors; |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | $response = wp_safe_remote_get( |
| 372 | 372 | 'https://api.github.com/repos/moonstonemedia/Simple-Calendar/contributors' |
| 373 | 373 | ); |
| 374 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
| 374 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { |
|
| 375 | 375 | return array(); |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - $contributors = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 379 | - if ( ! is_array( $contributors ) ) { |
|
| 378 | + $contributors = json_decode(wp_remote_retrieve_body($response)); |
|
| 379 | + if ( ! is_array($contributors)) { |
|
| 380 | 380 | return array(); |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - set_transient( '_simple-calendar_contributors', $contributors, HOUR_IN_SECONDS ); |
|
| 383 | + set_transient('_simple-calendar_contributors', $contributors, HOUR_IN_SECONDS); |
|
| 384 | 384 | |
| 385 | 385 | return $contributors; |
| 386 | 386 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | use SimpleCalendar\Abstracts\Feed; |
| 12 | 12 | use SimpleCalendar\Abstracts\Field; |
| 13 | 13 | |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -31,40 +31,40 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @param \WP_Post $post |
| 33 | 33 | */ |
| 34 | - public static function html( $post ) { |
|
| 34 | + public static function html($post) { |
|
| 35 | 35 | |
| 36 | 36 | // @see Meta_Boxes::save_meta_boxes() |
| 37 | - wp_nonce_field( 'simcal_save_data', 'simcal_meta_nonce' ); |
|
| 37 | + wp_nonce_field('simcal_save_data', 'simcal_meta_nonce'); |
|
| 38 | 38 | |
| 39 | 39 | ?> |
| 40 | 40 | <div class="simcal-panels-wrap"> |
| 41 | 41 | |
| 42 | 42 | <span class="simcal-box-handle"> |
| 43 | - <?php self::settings_handle( $post ); ?> |
|
| 43 | + <?php self::settings_handle($post); ?> |
|
| 44 | 44 | </span> |
| 45 | 45 | |
| 46 | 46 | <ul class="simcal-tabs"> |
| 47 | - <?php self::settings_tabs( $post ); ?> |
|
| 48 | - <?php do_action( 'simcal_settings_meta_tabs' ); ?> |
|
| 47 | + <?php self::settings_tabs($post); ?> |
|
| 48 | + <?php do_action('simcal_settings_meta_tabs'); ?> |
|
| 49 | 49 | </ul> |
| 50 | 50 | |
| 51 | 51 | <div class="simcal-panels"> |
| 52 | 52 | <div id="events-settings-panel" class="simcal-panel"> |
| 53 | - <?php self::events_settings_panel( $post ); ?> |
|
| 54 | - <?php do_action( 'simcal_settings_meta_events_panel', $post->ID ); ?> |
|
| 53 | + <?php self::events_settings_panel($post); ?> |
|
| 54 | + <?php do_action('simcal_settings_meta_events_panel', $post->ID); ?> |
|
| 55 | 55 | </div> |
| 56 | 56 | <div id="calendar-settings-panel" class="simcal-panel"> |
| 57 | - <?php do_action( 'simcal_settings_meta_calendar_panel', $post->ID ); ?> |
|
| 58 | - <?php self::calendar_settings_panel( $post ); ?> |
|
| 57 | + <?php do_action('simcal_settings_meta_calendar_panel', $post->ID); ?> |
|
| 58 | + <?php self::calendar_settings_panel($post); ?> |
|
| 59 | 59 | </div> |
| 60 | 60 | <?php |
| 61 | 61 | // Hook for additional settings panels. |
| 62 | - do_action( 'simcal_settings_meta_panels', $post->ID ); |
|
| 62 | + do_action('simcal_settings_meta_panels', $post->ID); |
|
| 63 | 63 | // Thus advanced panel is always the last one: |
| 64 | 64 | ?> |
| 65 | 65 | <div id="advanced-settings-panel" class="simcal-panel"> |
| 66 | - <?php self::advanced_settings_panel( $post ) ?> |
|
| 67 | - <?php do_action( 'simcal_settings_meta_advanced_panel', $post->ID ); ?> |
|
| 66 | + <?php self::advanced_settings_panel($post) ?> |
|
| 67 | + <?php do_action('simcal_settings_meta_advanced_panel', $post->ID); ?> |
|
| 68 | 68 | </div> |
| 69 | 69 | </div> |
| 70 | 70 | |
@@ -84,45 +84,45 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @param \WP_Post $post |
| 86 | 86 | */ |
| 87 | - private static function settings_handle( $post ) { |
|
| 87 | + private static function settings_handle($post) { |
|
| 88 | 88 | |
| 89 | 89 | $feed_options = $calendar_options = $calendar_views = array(); |
| 90 | 90 | |
| 91 | 91 | $feed_types = simcal_get_feed_types(); |
| 92 | - foreach ( $feed_types as $feed_type ) { |
|
| 92 | + foreach ($feed_types as $feed_type) { |
|
| 93 | 93 | |
| 94 | - $feed = simcal_get_feed( $feed_type ); |
|
| 94 | + $feed = simcal_get_feed($feed_type); |
|
| 95 | 95 | |
| 96 | - if ( $feed instanceof Feed ) { |
|
| 97 | - $feed_options[ $feed_type ] = $feed->name; |
|
| 96 | + if ($feed instanceof Feed) { |
|
| 97 | + $feed_options[$feed_type] = $feed->name; |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $calendar_types = simcal_get_calendar_types(); |
| 102 | - foreach ( $calendar_types as $calendar_type => $views ) { |
|
| 102 | + foreach ($calendar_types as $calendar_type => $views) { |
|
| 103 | 103 | |
| 104 | - $calendar = simcal_get_calendar( $calendar_type ); |
|
| 104 | + $calendar = simcal_get_calendar($calendar_type); |
|
| 105 | 105 | |
| 106 | - if ( $calendar instanceof Calendar ) { |
|
| 107 | - $calendar_options[ $calendar_type ] = $calendar->name; |
|
| 108 | - $calendar_views[ $calendar_type ] = $calendar->views; |
|
| 106 | + if ($calendar instanceof Calendar) { |
|
| 107 | + $calendar_options[$calendar_type] = $calendar->name; |
|
| 108 | + $calendar_views[$calendar_type] = $calendar->views; |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if ( $feed_options ) { |
|
| 112 | + if ($feed_options) { |
|
| 113 | 113 | |
| 114 | - if ( $feed_types = wp_get_object_terms( $post->ID, 'calendar_feed' ) ) { |
|
| 115 | - $feed_type = sanitize_title( current( $feed_types )->name ); |
|
| 114 | + if ($feed_types = wp_get_object_terms($post->ID, 'calendar_feed')) { |
|
| 115 | + $feed_type = sanitize_title(current($feed_types)->name); |
|
| 116 | 116 | } else { |
| 117 | - $feed_type = apply_filters( 'simcal_default_feed_type', 'google' ); |
|
| 117 | + $feed_type = apply_filters('simcal_default_feed_type', 'google'); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | ?> |
| 121 | - <label for="_feed_type"><span><?php _e( 'Event Source', 'google-calendar-events' ); ?></span> |
|
| 121 | + <label for="_feed_type"><span><?php _e('Event Source', 'google-calendar-events'); ?></span> |
|
| 122 | 122 | <select name="_feed_type" id="_feed_type"> |
| 123 | - <optgroup label="<?php _ex( 'Get events from', 'From which calendar source to load events from', 'google-calendar-events' ) ?>"> |
|
| 124 | - <?php foreach ( $feed_options as $feed => $name ) { ?> |
|
| 125 | - <option value="<?php echo $feed; ?>" <?php selected( $feed, $feed_type, true ); ?>><?php echo $name; ?></option> |
|
| 123 | + <optgroup label="<?php _ex('Get events from', 'From which calendar source to load events from', 'google-calendar-events') ?>"> |
|
| 124 | + <?php foreach ($feed_options as $feed => $name) { ?> |
|
| 125 | + <option value="<?php echo $feed; ?>" <?php selected($feed, $feed_type, true); ?>><?php echo $name; ?></option> |
|
| 126 | 126 | <?php } ?> |
| 127 | 127 | </optgroup> |
| 128 | 128 | </select> |
@@ -131,40 +131,40 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if ( $calendar_options ) { |
|
| 134 | + if ($calendar_options) { |
|
| 135 | 135 | |
| 136 | - if ( $calendar_types = wp_get_object_terms( $post->ID, 'calendar_type' ) ) { |
|
| 137 | - $calendar_type = sanitize_title( current( $calendar_types )->name ); |
|
| 136 | + if ($calendar_types = wp_get_object_terms($post->ID, 'calendar_type')) { |
|
| 137 | + $calendar_type = sanitize_title(current($calendar_types)->name); |
|
| 138 | 138 | } else { |
| 139 | - $calendar_type = apply_filters( 'simcal_default_calendar_type', 'default-calendar' ); |
|
| 139 | + $calendar_type = apply_filters('simcal_default_calendar_type', 'default-calendar'); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | ?> |
| 143 | - <label for="_calendar_type"><span><?php _e( 'Calendar Type', 'google-calendar-events' ); ?></span> |
|
| 143 | + <label for="_calendar_type"><span><?php _e('Calendar Type', 'google-calendar-events'); ?></span> |
|
| 144 | 144 | <select name="_calendar_type" id="_calendar_type"> |
| 145 | - <optgroup label="<?php _e( 'Calendar to use', 'google-calendar-events' ); ?>"> |
|
| 146 | - <?php foreach ( $calendar_options as $calendar => $name ) { ?> |
|
| 147 | - <option value="<?php echo $calendar; ?>" <?php selected( $calendar, $calendar_type, true ); ?>><?php echo $name; ?></option> |
|
| 145 | + <optgroup label="<?php _e('Calendar to use', 'google-calendar-events'); ?>"> |
|
| 146 | + <?php foreach ($calendar_options as $calendar => $name) { ?> |
|
| 147 | + <option value="<?php echo $calendar; ?>" <?php selected($calendar, $calendar_type, true); ?>><?php echo $name; ?></option> |
|
| 148 | 148 | <?php } ?> |
| 149 | 149 | </optgroup> |
| 150 | 150 | </select> |
| 151 | 151 | </label> |
| 152 | 152 | <?php |
| 153 | 153 | |
| 154 | - if ( $calendar_views ) { |
|
| 154 | + if ($calendar_views) { |
|
| 155 | 155 | |
| 156 | - $calendar_view = get_post_meta( $post->ID, '_calendar_view', true ); |
|
| 156 | + $calendar_view = get_post_meta($post->ID, '_calendar_view', true); |
|
| 157 | 157 | |
| 158 | - foreach ( $calendar_views as $calendar => $views ) { |
|
| 158 | + foreach ($calendar_views as $calendar => $views) { |
|
| 159 | 159 | |
| 160 | - $calendar_type_view = isset( $calendar_view[ $calendar ] ) ? $calendar_view[ $calendar ] : ''; |
|
| 160 | + $calendar_type_view = isset($calendar_view[$calendar]) ? $calendar_view[$calendar] : ''; |
|
| 161 | 161 | |
| 162 | 162 | ?> |
| 163 | - <label for="_calendar_view_<?php echo $calendar; ?>"><span><?php _e( 'View', 'google-calendar-events' ); ?></span> |
|
| 163 | + <label for="_calendar_view_<?php echo $calendar; ?>"><span><?php _e('View', 'google-calendar-events'); ?></span> |
|
| 164 | 164 | <select name="_calendar_view[<?php echo $calendar; ?>]" id="_calendar_view_<?php echo $calendar; ?>"> |
| 165 | - <optgroup label="<?php _e( 'View to display', 'google-calendar-events' ); ?>"> |
|
| 166 | - <?php foreach ( $views as $view => $name ) { ?> |
|
| 167 | - <option value="<?php echo $view; ?>" <?php selected( $view, $calendar_type_view, true ); ?>><?php echo $name; ?></option> |
|
| 165 | + <optgroup label="<?php _e('View to display', 'google-calendar-events'); ?>"> |
|
| 166 | + <?php foreach ($views as $view => $name) { ?> |
|
| 167 | + <option value="<?php echo $view; ?>" <?php selected($view, $calendar_type_view, true); ?>><?php echo $name; ?></option> |
|
| 168 | 168 | <?php } ?> |
| 169 | 169 | </optgroup> |
| 170 | 170 | </select> |
@@ -184,42 +184,42 @@ discard block |
||
| 184 | 184 | * |
| 185 | 185 | * @param \WP_Post $post |
| 186 | 186 | */ |
| 187 | - private static function settings_tabs( $post ) { |
|
| 187 | + private static function settings_tabs($post) { |
|
| 188 | 188 | |
| 189 | 189 | // Hook to add more tabs. |
| 190 | - $tabs = apply_filters( 'simcal_settings_meta_tabs_li', array( |
|
| 190 | + $tabs = apply_filters('simcal_settings_meta_tabs_li', array( |
|
| 191 | 191 | 'events' => array( |
| 192 | - 'label' => __( 'Events', 'google-calendar-events' ), |
|
| 192 | + 'label' => __('Events', 'google-calendar-events'), |
|
| 193 | 193 | 'target' => 'events-settings-panel', |
| 194 | - 'class' => array( 'active' ), |
|
| 194 | + 'class' => array('active'), |
|
| 195 | 195 | 'icon' => 'simcal-icon-event', |
| 196 | 196 | ), |
| 197 | 197 | 'calendar' => array( |
| 198 | - 'label' => __( 'Appearance', 'google-calendar-events' ), |
|
| 198 | + 'label' => __('Appearance', 'google-calendar-events'), |
|
| 199 | 199 | 'target' => 'calendar-settings-panel', |
| 200 | 200 | 'class' => array(), |
| 201 | 201 | 'icon' => 'simcal-icon-calendar', |
| 202 | 202 | ), |
| 203 | - ), $post->ID ); |
|
| 203 | + ), $post->ID); |
|
| 204 | 204 | |
| 205 | 205 | // Always keep advanced tab as the last one. |
| 206 | 206 | $tabs['advanced'] = array( |
| 207 | - 'label' => __( 'Advanced', 'google-calendar-events' ), |
|
| 207 | + 'label' => __('Advanced', 'google-calendar-events'), |
|
| 208 | 208 | 'target' => 'advanced-settings-panel', |
| 209 | 209 | 'class' => array(), |
| 210 | 210 | 'icon' => 'simcal-icon-settings', |
| 211 | 211 | ); |
| 212 | 212 | |
| 213 | 213 | // Output the tabs as list items. |
| 214 | - foreach ( $tabs as $key => $tab ) { |
|
| 214 | + foreach ($tabs as $key => $tab) { |
|
| 215 | 215 | |
| 216 | - if ( isset( $tab['target'] ) && isset( $tab['label'] ) ) { |
|
| 216 | + if (isset($tab['target']) && isset($tab['label'])) { |
|
| 217 | 217 | |
| 218 | 218 | $icon = $tab['icon'] ? $tab['icon'] : 'simcal-icon-panel'; |
| 219 | 219 | $class = $tab['class'] ? $tab['class'] : array(); |
| 220 | 220 | |
| 221 | - echo '<li class="' . $key . '-settings ' . $key . '-tab ' . implode( ' ', $class ) . '" data-tab="' . $key . '">'; |
|
| 222 | - echo '<a href="#' . $tab['target'] . '"><i class="' . $icon . '" ></i> <span>' . esc_html( $tab['label'] ) . '</span></a>'; |
|
| 221 | + echo '<li class="'.$key.'-settings '.$key.'-tab '.implode(' ', $class).'" data-tab="'.$key.'">'; |
|
| 222 | + echo '<a href="#'.$tab['target'].'"><i class="'.$icon.'" ></i> <span>'.esc_html($tab['label']).'</span></a>'; |
|
| 223 | 223 | echo '</li>'; |
| 224 | 224 | } |
| 225 | 225 | } |
@@ -233,22 +233,22 @@ discard block |
||
| 233 | 233 | * |
| 234 | 234 | * @param \WP_Post $post |
| 235 | 235 | */ |
| 236 | - private static function events_settings_panel( $post ) { |
|
| 236 | + private static function events_settings_panel($post) { |
|
| 237 | 237 | |
| 238 | 238 | ?> |
| 239 | 239 | <table> |
| 240 | 240 | <thead> |
| 241 | - <tr><th colspan="2"><?php _e( 'Event Settings', 'google-calendar-events' ); ?></th></tr> |
|
| 241 | + <tr><th colspan="2"><?php _e('Event Settings', 'google-calendar-events'); ?></th></tr> |
|
| 242 | 242 | </thead> |
| 243 | 243 | <tbody class="simcal-panel-section simcal-panel-section-events-range"> |
| 244 | 244 | <tr class="simcal-panel-field"> |
| 245 | - <th><label for="_calendar_begins"><?php _e( 'Calendar Start', 'google-calendar-events' ); ?></label></th> |
|
| 245 | + <th><label for="_calendar_begins"><?php _e('Calendar Start', 'google-calendar-events'); ?></label></th> |
|
| 246 | 246 | <td> |
| 247 | 247 | <?php |
| 248 | 248 | |
| 249 | - $calendar_begins = esc_attr( get_post_meta( $post->ID, '_calendar_begins', true ) ); |
|
| 250 | - $calendar_begins_nth = max( absint( get_post_meta( $post->ID, '_calendar_begins_nth', true ) ), 1 ); |
|
| 251 | - $calendar_begins_nth_show = in_array( $calendar_begins, array( |
|
| 249 | + $calendar_begins = esc_attr(get_post_meta($post->ID, '_calendar_begins', true)); |
|
| 250 | + $calendar_begins_nth = max(absint(get_post_meta($post->ID, '_calendar_begins_nth', true)), 1); |
|
| 251 | + $calendar_begins_nth_show = in_array($calendar_begins, array( |
|
| 252 | 252 | 'days_before', |
| 253 | 253 | 'days_after', |
| 254 | 254 | 'weeks_before', |
@@ -257,14 +257,14 @@ discard block |
||
| 257 | 257 | 'months_after', |
| 258 | 258 | 'years_before', |
| 259 | 259 | 'years_after', |
| 260 | - ) ); |
|
| 260 | + )); |
|
| 261 | 261 | |
| 262 | - simcal_print_field( array( |
|
| 262 | + simcal_print_field(array( |
|
| 263 | 263 | 'type' => 'standard', |
| 264 | 264 | 'subtype' => 'number', |
| 265 | 265 | 'name' => '_calendar_begins_nth', |
| 266 | 266 | 'id' => '_calendar_begins_nth', |
| 267 | - 'value' => strval( $calendar_begins_nth ), |
|
| 267 | + 'value' => strval($calendar_begins_nth), |
|
| 268 | 268 | 'attributes' => array( |
| 269 | 269 | 'min' => '1', |
| 270 | 270 | ), |
@@ -272,97 +272,97 @@ discard block |
||
| 272 | 272 | 'simcal-field-inline', |
| 273 | 273 | 'simcal-field-tiny', |
| 274 | 274 | ), |
| 275 | - 'style' => ! $calendar_begins_nth_show ? array( 'display' => 'none' ) : '', |
|
| 276 | - ) ); |
|
| 275 | + 'style' => ! $calendar_begins_nth_show ? array('display' => 'none') : '', |
|
| 276 | + )); |
|
| 277 | 277 | |
| 278 | 278 | ?> |
| 279 | 279 | <select name="_calendar_begins" |
| 280 | 280 | id="_calendar_begins" |
| 281 | 281 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
| 282 | - <optgroup label="<?php _e( 'Days', 'google-calendar-events' ); ?>"> |
|
| 282 | + <optgroup label="<?php _e('Days', 'google-calendar-events'); ?>"> |
|
| 283 | 283 | <option value="today" |
| 284 | 284 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
| 285 | - <?php selected( 'today', $calendar_begins, true ); ?>><?php _e( 'Today', 'google-calendar-events' ); ?></option> |
|
| 285 | + <?php selected('today', $calendar_begins, true); ?>><?php _e('Today', 'google-calendar-events'); ?></option> |
|
| 286 | 286 | <option value="now" |
| 287 | 287 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
| 288 | - <?php selected( 'now', $calendar_begins, true ); ?>><?php _e( 'Now', 'google-calendar-events' ); ?></option> |
|
| 288 | + <?php selected('now', $calendar_begins, true); ?>><?php _e('Now', 'google-calendar-events'); ?></option> |
|
| 289 | 289 | <option value="days_before" |
| 290 | 290 | data-hide-field="_calendar_begins_custom_date" |
| 291 | - data-show-field="_calendar_begins_nth" <?php selected( 'days_before', $calendar_begins, true ); ?>><?php _e( 'Day(s) before today', 'google-calendar-events' ); ?></option> |
|
| 291 | + data-show-field="_calendar_begins_nth" <?php selected('days_before', $calendar_begins, true); ?>><?php _e('Day(s) before today', 'google-calendar-events'); ?></option> |
|
| 292 | 292 | <option value="days_after" |
| 293 | 293 | data-hide-field="_calendar_begins_custom_date" |
| 294 | - data-show-field="_calendar_begins_nth" <?php selected( 'days_after', $calendar_begins, true ); ?>><?php _e( 'Day(s) after today', 'google-calendar-events' ); ?></option> |
|
| 294 | + data-show-field="_calendar_begins_nth" <?php selected('days_after', $calendar_begins, true); ?>><?php _e('Day(s) after today', 'google-calendar-events'); ?></option> |
|
| 295 | 295 | </optgroup> |
| 296 | - <optgroup label="<?php _e( 'Weeks', 'google-calendar-events' ); ?>"> |
|
| 296 | + <optgroup label="<?php _e('Weeks', 'google-calendar-events'); ?>"> |
|
| 297 | 297 | <option value="this_week" |
| 298 | 298 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
| 299 | - <?php selected( 'this_week', $calendar_begins, true ); ?>><?php _e( 'This week', 'google-calendar-events' ); ?></option> |
|
| 299 | + <?php selected('this_week', $calendar_begins, true); ?>><?php _e('This week', 'google-calendar-events'); ?></option> |
|
| 300 | 300 | <option value="weeks_before" |
| 301 | 301 | data-hide-field="_calendar_begins_custom_date" |
| 302 | - data-show-field="_calendar_begins_nth" <?php selected( 'weeks_before', $calendar_begins, true ); ?>><?php _e( 'Week(s) before current', 'google-calendar-events' ); ?></option> |
|
| 302 | + data-show-field="_calendar_begins_nth" <?php selected('weeks_before', $calendar_begins, true); ?>><?php _e('Week(s) before current', 'google-calendar-events'); ?></option> |
|
| 303 | 303 | <option value="weeks_after" |
| 304 | 304 | data-hide-field="_calendar_begins_custom_date" |
| 305 | - data-show-field="_calendar_begins_nth" <?php selected( 'weeks_after', $calendar_begins, true ); ?>><?php _e( 'Week(s) after current', 'google-calendar-events' ); ?></option> |
|
| 305 | + data-show-field="_calendar_begins_nth" <?php selected('weeks_after', $calendar_begins, true); ?>><?php _e('Week(s) after current', 'google-calendar-events'); ?></option> |
|
| 306 | 306 | </optgroup> |
| 307 | - <optgroup label="<?php _e( 'Months', 'google-calendar-events' ); ?>"> |
|
| 307 | + <optgroup label="<?php _e('Months', 'google-calendar-events'); ?>"> |
|
| 308 | 308 | <option value="this_month" |
| 309 | 309 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
| 310 | - <?php selected( 'this_month', $calendar_begins, true ); ?>><?php _e( 'This month', 'google-calendar-events' ); ?></option> |
|
| 310 | + <?php selected('this_month', $calendar_begins, true); ?>><?php _e('This month', 'google-calendar-events'); ?></option> |
|
| 311 | 311 | <option value="months_before" |
| 312 | 312 | data-hide-field="_calendar_begins_custom_date" |
| 313 | - data-show-field="_calendar_begins_nth" <?php selected( 'months_before', $calendar_begins, true ); ?>><?php _e( 'Month(s) before current', 'google-calendar-events' ); ?></option> |
|
| 313 | + data-show-field="_calendar_begins_nth" <?php selected('months_before', $calendar_begins, true); ?>><?php _e('Month(s) before current', 'google-calendar-events'); ?></option> |
|
| 314 | 314 | <option value="months_after" |
| 315 | 315 | data-hide-field="_calendar_begins_custom_date" |
| 316 | - data-show-field="_calendar_begins_nth" <?php selected( 'months_after', $calendar_begins, true ); ?>><?php _e( 'Month(s) after current', 'google-calendar-events' ); ?></option> |
|
| 316 | + data-show-field="_calendar_begins_nth" <?php selected('months_after', $calendar_begins, true); ?>><?php _e('Month(s) after current', 'google-calendar-events'); ?></option> |
|
| 317 | 317 | </optgroup> |
| 318 | - <optgroup label="<?php _e( 'Years', 'google-calendar-events' ); ?>"> |
|
| 318 | + <optgroup label="<?php _e('Years', 'google-calendar-events'); ?>"> |
|
| 319 | 319 | <option value="this_year" |
| 320 | 320 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
| 321 | - <?php selected( 'this_year', $calendar_begins, true ); ?>><?php _e( 'This year', 'google-calendar-events' ); ?></option> |
|
| 321 | + <?php selected('this_year', $calendar_begins, true); ?>><?php _e('This year', 'google-calendar-events'); ?></option> |
|
| 322 | 322 | <option value="years_before" |
| 323 | - data-show-field="_calendar_begins_nth" <?php selected( 'years_before', $calendar_begins, true ); ?>><?php _e( 'Year(s) before current', 'google-calendar-events' ); ?></option> |
|
| 323 | + data-show-field="_calendar_begins_nth" <?php selected('years_before', $calendar_begins, true); ?>><?php _e('Year(s) before current', 'google-calendar-events'); ?></option> |
|
| 324 | 324 | <option value="years_after" |
| 325 | 325 | data-hide-field="_calendar_begins_custom_date" |
| 326 | - data-show-field="_calendar_begins_nth" <?php selected( 'years_after', $calendar_begins, true ); ?>><?php _e( 'Year(s) after current', 'google-calendar-events' ); ?></option> |
|
| 326 | + data-show-field="_calendar_begins_nth" <?php selected('years_after', $calendar_begins, true); ?>><?php _e('Year(s) after current', 'google-calendar-events'); ?></option> |
|
| 327 | 327 | </optgroup> |
| 328 | - <optgroup label="<?php _e( 'Other', 'google-calendar-events' ); ?>"> |
|
| 328 | + <optgroup label="<?php _e('Other', 'google-calendar-events'); ?>"> |
|
| 329 | 329 | <option value="custom_date" |
| 330 | 330 | data-hide-field="_calendar_begins_nth" |
| 331 | - data-show-field="_calendar_begins_custom_date" <?php selected( 'custom_date', $calendar_begins, true ); ?>><?php _e( 'Specific date', 'google-calendar-events' ); ?></option> |
|
| 331 | + data-show-field="_calendar_begins_custom_date" <?php selected('custom_date', $calendar_begins, true); ?>><?php _e('Specific date', 'google-calendar-events'); ?></option> |
|
| 332 | 332 | </optgroup> |
| 333 | 333 | </select> |
| 334 | 334 | <?php |
| 335 | 335 | |
| 336 | - simcal_print_field( array( |
|
| 336 | + simcal_print_field(array( |
|
| 337 | 337 | 'type' => 'date-picker', |
| 338 | 338 | 'name' => '_calendar_begins_custom_date', |
| 339 | 339 | 'id' => '_calendar_begins_custom_date', |
| 340 | - 'value' => get_post_meta( $post->ID, '_calendar_begins_custom_date', true ), |
|
| 340 | + 'value' => get_post_meta($post->ID, '_calendar_begins_custom_date', true), |
|
| 341 | 341 | 'class' => array( |
| 342 | 342 | 'simcal-field-inline', |
| 343 | 343 | ), |
| 344 | - 'style' => 'custom_date' != $calendar_begins ? array( 'display' => 'none' ) : '', |
|
| 345 | - ) ); |
|
| 344 | + 'style' => 'custom_date' != $calendar_begins ? array('display' => 'none') : '', |
|
| 345 | + )); |
|
| 346 | 346 | |
| 347 | 347 | ?> |
| 348 | 348 | <i class="simcal-icon-help simcal-help-tip" |
| 349 | - data-tip="<?php _e( 'The calendar default opening date. It will automatically adapt based on the chosen calendar type.', 'google-calendar-events' ); ?>"></i> |
|
| 349 | + data-tip="<?php _e('The calendar default opening date. It will automatically adapt based on the chosen calendar type.', 'google-calendar-events'); ?>"></i> |
|
| 350 | 350 | </td> |
| 351 | 351 | </tr> |
| 352 | 352 | <tr class="simcal-panel-field"> |
| 353 | - <th><label for="_feed_earliest_event_date"><?php _e( 'Earliest Event', 'google-calendar-events' ); ?></label></th> |
|
| 353 | + <th><label for="_feed_earliest_event_date"><?php _e('Earliest Event', 'google-calendar-events'); ?></label></th> |
|
| 354 | 354 | <td> |
| 355 | 355 | <?php |
| 356 | 356 | |
| 357 | - $earliest_event_saved = get_post_meta( $post->ID, '_feed_earliest_event_date', true ); |
|
| 358 | - $earliest_event = false == $earliest_event_saved ? 'months_before' : esc_attr( $earliest_event_saved ); |
|
| 357 | + $earliest_event_saved = get_post_meta($post->ID, '_feed_earliest_event_date', true); |
|
| 358 | + $earliest_event = false == $earliest_event_saved ? 'months_before' : esc_attr($earliest_event_saved); |
|
| 359 | 359 | |
| 360 | - simcal_print_field( array( |
|
| 360 | + simcal_print_field(array( |
|
| 361 | 361 | 'type' => 'standard', |
| 362 | 362 | 'subtype' => 'number', |
| 363 | 363 | 'name' => '_feed_earliest_event_date_range', |
| 364 | 364 | 'id' => '_feed_earliest_event_date_range', |
| 365 | - 'value' => strval( max( absint( get_post_meta( $post->ID, '_feed_earliest_event_date_range', true ) ), 1 ) ), |
|
| 365 | + 'value' => strval(max(absint(get_post_meta($post->ID, '_feed_earliest_event_date_range', true)), 1)), |
|
| 366 | 366 | 'attributes' => array( |
| 367 | 367 | 'min' => '1', |
| 368 | 368 | ), |
@@ -370,37 +370,37 @@ discard block |
||
| 370 | 370 | 'simcal-field-inline', |
| 371 | 371 | 'simcal-field-tiny', |
| 372 | 372 | ), |
| 373 | - 'style' => ( 'now' != $earliest_event ) && ( 'today' != $earliest_event ) ? array( 'display' => 'none' ) : '', |
|
| 374 | - ) ); |
|
| 373 | + 'style' => ('now' != $earliest_event) && ('today' != $earliest_event) ? array('display' => 'none') : '', |
|
| 374 | + )); |
|
| 375 | 375 | |
| 376 | 376 | ?> |
| 377 | 377 | <select name="_feed_earliest_event_date" |
| 378 | 378 | id="_feed_earliest_event_date" |
| 379 | 379 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
| 380 | - <option value="calendar_start" data-hide-field="_feed_earliest_event_date_range" <?php selected( 'calendar_start', $earliest_event, true ); ?>><?php _e( 'Same as start date', 'google-calendar-events' ); ?></option> |
|
| 381 | - <option value="days_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'days_before', $earliest_event, true ); ?>><?php _e( 'Day(s) before start date', 'google-calendar-events' ); ?></option> |
|
| 382 | - <option value="weeks_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'weeks_before', $earliest_event, true ); ?>><?php _e( 'Week(s) before start date', 'google-calendar-events' ); ?></option> |
|
| 383 | - <option value="months_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'months_before', $earliest_event, true ); ?>><?php _e( 'Month(s) before start date', 'google-calendar-events' ); ?></option> |
|
| 384 | - <option value="years_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'years_before', $earliest_event, true ); ?>><?php _e( 'Year(s) before start date', 'google-calendar-events' ); ?></option> |
|
| 380 | + <option value="calendar_start" data-hide-field="_feed_earliest_event_date_range" <?php selected('calendar_start', $earliest_event, true); ?>><?php _e('Same as start date', 'google-calendar-events'); ?></option> |
|
| 381 | + <option value="days_before" data-show-field="_feed_earliest_event_date_range" <?php selected('days_before', $earliest_event, true); ?>><?php _e('Day(s) before start date', 'google-calendar-events'); ?></option> |
|
| 382 | + <option value="weeks_before" data-show-field="_feed_earliest_event_date_range" <?php selected('weeks_before', $earliest_event, true); ?>><?php _e('Week(s) before start date', 'google-calendar-events'); ?></option> |
|
| 383 | + <option value="months_before" data-show-field="_feed_earliest_event_date_range" <?php selected('months_before', $earliest_event, true); ?>><?php _e('Month(s) before start date', 'google-calendar-events'); ?></option> |
|
| 384 | + <option value="years_before" data-show-field="_feed_earliest_event_date_range" <?php selected('years_before', $earliest_event, true); ?>><?php _e('Year(s) before start date', 'google-calendar-events'); ?></option> |
|
| 385 | 385 | </select> |
| 386 | 386 | <i class="simcal-icon-help simcal-help-tip" |
| 387 | - data-tip="<?php _e( 'Set the date for the earliest possible event to show in calendar. There will not be events before this date.', 'google-calendar-events' ); ?>"></i> |
|
| 387 | + data-tip="<?php _e('Set the date for the earliest possible event to show in calendar. There will not be events before this date.', 'google-calendar-events'); ?>"></i> |
|
| 388 | 388 | </td> |
| 389 | 389 | </tr> |
| 390 | 390 | <tr class="simcal-panel-field"> |
| 391 | - <th><label for="_feed_latest_event_date"><?php _e( 'Latest Event', 'google-calendar-events' ); ?></label></th> |
|
| 391 | + <th><label for="_feed_latest_event_date"><?php _e('Latest Event', 'google-calendar-events'); ?></label></th> |
|
| 392 | 392 | <td> |
| 393 | 393 | <?php |
| 394 | 394 | |
| 395 | - $latest_event_saved = get_post_meta( $post->ID, '_feed_latest_event_date', true ); |
|
| 396 | - $latest_event = false == $latest_event_saved ? 'years_after' : esc_attr( $latest_event_saved ); |
|
| 395 | + $latest_event_saved = get_post_meta($post->ID, '_feed_latest_event_date', true); |
|
| 396 | + $latest_event = false == $latest_event_saved ? 'years_after' : esc_attr($latest_event_saved); |
|
| 397 | 397 | |
| 398 | - simcal_print_field( array( |
|
| 398 | + simcal_print_field(array( |
|
| 399 | 399 | 'type' => 'standard', |
| 400 | 400 | 'subtype' => 'number', |
| 401 | 401 | 'name' => '_feed_latest_event_date_range', |
| 402 | 402 | 'id' => '_feed_latest_event_date_range', |
| 403 | - 'value' => strval( max( absint( get_post_meta( $post->ID, '_feed_latest_event_date_range', true ) ), 1 ) ), |
|
| 403 | + 'value' => strval(max(absint(get_post_meta($post->ID, '_feed_latest_event_date_range', true)), 1)), |
|
| 404 | 404 | 'attributes' => array( |
| 405 | 405 | 'min' => '1', |
| 406 | 406 | ), |
@@ -408,21 +408,21 @@ discard block |
||
| 408 | 408 | 'simcal-field-inline', |
| 409 | 409 | 'simcal-field-tiny', |
| 410 | 410 | ), |
| 411 | - 'style' => 'indefinite' != $latest_event ? array( 'display' => 'none' ) : '', |
|
| 412 | - ) ); |
|
| 411 | + 'style' => 'indefinite' != $latest_event ? array('display' => 'none') : '', |
|
| 412 | + )); |
|
| 413 | 413 | |
| 414 | 414 | ?> |
| 415 | 415 | <select name="_feed_latest_event_date" |
| 416 | 416 | id="_feed_latest_event_date" |
| 417 | 417 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
| 418 | - <option value="calendar_start" data-hide-field="_feed_latest_event_date_range" <?php selected( 'calendar_start', $earliest_event, true ); ?>><?php _e( 'Day end of start date', 'google-calendar-events' ); ?></option> |
|
| 419 | - <option value="days_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'days_after', $latest_event, true ); ?>><?php _e( 'Day(s) after start date', 'google-calendar-events' ); ?></option> |
|
| 420 | - <option value="weeks_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'weeks_after', $latest_event, true ); ?>><?php _e( 'Weeks(s) after start date', 'google-calendar-events' ); ?></option> |
|
| 421 | - <option value="months_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'months_after', $latest_event, true ); ?>><?php _e( 'Month(s) after start date', 'google-calendar-events' ); ?></option> |
|
| 422 | - <option value="years_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'years_after', $latest_event, true ); ?>><?php _e( 'Year(s) after start date', 'google-calendar-events' ); ?></option> |
|
| 418 | + <option value="calendar_start" data-hide-field="_feed_latest_event_date_range" <?php selected('calendar_start', $earliest_event, true); ?>><?php _e('Day end of start date', 'google-calendar-events'); ?></option> |
|
| 419 | + <option value="days_after" data-show-field="_feed_latest_event_date_range" <?php selected('days_after', $latest_event, true); ?>><?php _e('Day(s) after start date', 'google-calendar-events'); ?></option> |
|
| 420 | + <option value="weeks_after" data-show-field="_feed_latest_event_date_range" <?php selected('weeks_after', $latest_event, true); ?>><?php _e('Weeks(s) after start date', 'google-calendar-events'); ?></option> |
|
| 421 | + <option value="months_after" data-show-field="_feed_latest_event_date_range" <?php selected('months_after', $latest_event, true); ?>><?php _e('Month(s) after start date', 'google-calendar-events'); ?></option> |
|
| 422 | + <option value="years_after" data-show-field="_feed_latest_event_date_range" <?php selected('years_after', $latest_event, true); ?>><?php _e('Year(s) after start date', 'google-calendar-events'); ?></option> |
|
| 423 | 423 | </select> |
| 424 | 424 | <i class="simcal-icon-help simcal-help-tip" |
| 425 | - data-tip="<?php _e( 'Set the date for the latest possible event to show on calendar. There will not be events after this date.', 'google-calendar-events' ); ?>"></i> |
|
| 425 | + data-tip="<?php _e('Set the date for the latest possible event to show on calendar. There will not be events after this date.', 'google-calendar-events'); ?>"></i> |
|
| 426 | 426 | </td> |
| 427 | 427 | </tr> |
| 428 | 428 | </tbody> |
@@ -439,87 +439,87 @@ discard block |
||
| 439 | 439 | * |
| 440 | 440 | * @param \WP_Post $post |
| 441 | 441 | */ |
| 442 | - private static function calendar_settings_panel( $post ) { |
|
| 442 | + private static function calendar_settings_panel($post) { |
|
| 443 | 443 | |
| 444 | 444 | ?> |
| 445 | 445 | <table> |
| 446 | 446 | <thead> |
| 447 | - <tr><th colspan="2"><?php _e( 'Miscellaneous', 'google-calendar-events' ); ?></th></tr> |
|
| 447 | + <tr><th colspan="2"><?php _e('Miscellaneous', 'google-calendar-events'); ?></th></tr> |
|
| 448 | 448 | </thead> |
| 449 | 449 | <tbody class="simcal-panel-section"> |
| 450 | 450 | <tr class="simcal-panel-field"> |
| 451 | - <th><label for="_calendar_is_static"><?php _e( 'Static Calendar', 'google-calendar-events' ); ?></label></th> |
|
| 451 | + <th><label for="_calendar_is_static"><?php _e('Static Calendar', 'google-calendar-events'); ?></label></th> |
|
| 452 | 452 | <td> |
| 453 | 453 | <?php |
| 454 | 454 | |
| 455 | - $fixed = get_post_meta( $post->ID, '_calendar_is_static', true ); |
|
| 455 | + $fixed = get_post_meta($post->ID, '_calendar_is_static', true); |
|
| 456 | 456 | |
| 457 | - simcal_print_field( array( |
|
| 457 | + simcal_print_field(array( |
|
| 458 | 458 | 'type' => 'checkbox', |
| 459 | 459 | 'name' => '_calendar_is_static', |
| 460 | 460 | 'id' => '_calendar_is_static', |
| 461 | - 'tooltip' => __( 'Remove the navigation arrows and fix the calendar view to its initial state.', 'google-calendar-events' ), |
|
| 461 | + 'tooltip' => __('Remove the navigation arrows and fix the calendar view to its initial state.', 'google-calendar-events'), |
|
| 462 | 462 | 'value' => 'yes' == $fixed ? 'yes' : 'no', |
| 463 | - 'text' => __( 'Yes (hide navigation arrows)', 'google-calendar-events' ), |
|
| 464 | - ) ); |
|
| 463 | + 'text' => __('Yes (hide navigation arrows)', 'google-calendar-events'), |
|
| 464 | + )); |
|
| 465 | 465 | |
| 466 | 466 | ?> |
| 467 | 467 | </td> |
| 468 | 468 | </tr> |
| 469 | 469 | <tr class="simcal-panel-field"> |
| 470 | - <th><label for="_no_events_message"><?php _e( 'No Events Message', 'google-calendar-events' ); ?></label></th> |
|
| 470 | + <th><label for="_no_events_message"><?php _e('No Events Message', 'google-calendar-events'); ?></label></th> |
|
| 471 | 471 | <td> |
| 472 | 472 | <?php |
| 473 | 473 | |
| 474 | - simcal_print_field( array( |
|
| 474 | + simcal_print_field(array( |
|
| 475 | 475 | 'type' => 'textarea', |
| 476 | 476 | 'name' => '_no_events_message', |
| 477 | 477 | 'id' => '_no_events_message', |
| 478 | - 'tooltip' => __( 'Some calendars may display a message when no events are found. You can change the default message here.', 'google-calendar-events' ), |
|
| 479 | - 'value' => get_post_meta( $post->ID, '_no_events_message', true ), |
|
| 480 | - ) ); |
|
| 478 | + 'tooltip' => __('Some calendars may display a message when no events are found. You can change the default message here.', 'google-calendar-events'), |
|
| 479 | + 'value' => get_post_meta($post->ID, '_no_events_message', true), |
|
| 480 | + )); |
|
| 481 | 481 | |
| 482 | 482 | ?> |
| 483 | 483 | </td> |
| 484 | 484 | </tr> |
| 485 | 485 | <tr class="simcal-panel-field"> |
| 486 | - <th><label for="_event_formatting"><?php _e( 'Event Formatting', 'google-calendar-events' ); ?></label></th> |
|
| 486 | + <th><label for="_event_formatting"><?php _e('Event Formatting', 'google-calendar-events'); ?></label></th> |
|
| 487 | 487 | <td> |
| 488 | 488 | <?php |
| 489 | 489 | |
| 490 | - $event_formatting = get_post_meta( $post->ID, '_event_formatting', true ); |
|
| 490 | + $event_formatting = get_post_meta($post->ID, '_event_formatting', true); |
|
| 491 | 491 | |
| 492 | - simcal_print_field( array( |
|
| 492 | + simcal_print_field(array( |
|
| 493 | 493 | 'type' => 'select', |
| 494 | 494 | 'name' => '_event_formatting', |
| 495 | 495 | 'id' => '_event_formatting', |
| 496 | - 'tooltip' => __( 'How to preserve line breaks and paragraphs in the event template builder.', 'google-calendar-events' ), |
|
| 496 | + 'tooltip' => __('How to preserve line breaks and paragraphs in the event template builder.', 'google-calendar-events'), |
|
| 497 | 497 | 'value' => $event_formatting, |
| 498 | 498 | 'default' => 'preserve_linebreaks', |
| 499 | 499 | 'options' => array( |
| 500 | - 'preserve_linebreaks' => __( 'Preserve line breaks, auto paragraphs (default)', 'google-calendar-events' ), |
|
| 501 | - 'no_linebreaks' => __( 'No line breaks, auto paragraphs', 'google-calendar-events' ), |
|
| 502 | - 'none' => __( 'No line breaks, no auto paragraphs', 'google-calendar-events' ), |
|
| 500 | + 'preserve_linebreaks' => __('Preserve line breaks, auto paragraphs (default)', 'google-calendar-events'), |
|
| 501 | + 'no_linebreaks' => __('No line breaks, auto paragraphs', 'google-calendar-events'), |
|
| 502 | + 'none' => __('No line breaks, no auto paragraphs', 'google-calendar-events'), |
|
| 503 | 503 | ), |
| 504 | - ) ); |
|
| 504 | + )); |
|
| 505 | 505 | |
| 506 | 506 | ?> |
| 507 | 507 | </td> |
| 508 | 508 | </tr> |
| 509 | 509 | <tr class="simcal-panel-field"> |
| 510 | - <th><label for="_poweredby"><?php _e( 'Powered By', 'google-calendar-events' ); ?></label></th> |
|
| 510 | + <th><label for="_poweredby"><?php _e('Powered By', 'google-calendar-events'); ?></label></th> |
|
| 511 | 511 | <td> |
| 512 | 512 | <?php |
| 513 | 513 | |
| 514 | - $poweredby = get_post_meta( $post->ID, '_poweredby', true ); |
|
| 514 | + $poweredby = get_post_meta($post->ID, '_poweredby', true); |
|
| 515 | 515 | |
| 516 | - simcal_print_field( array( |
|
| 516 | + simcal_print_field(array( |
|
| 517 | 517 | 'type' => 'checkbox', |
| 518 | 518 | 'name' => '_poweredby', |
| 519 | 519 | 'id' => '_poweredby', |
| 520 | 520 | 'value' => 'yes' == $poweredby ? 'yes' : 'no', |
| 521 | - 'text' => __( 'Yes, Simple Calendar rocks! Show some love with a little link below this calendar.', 'google-calendar-events' ), |
|
| 522 | - ) ); |
|
| 521 | + 'text' => __('Yes, Simple Calendar rocks! Show some love with a little link below this calendar.', 'google-calendar-events'), |
|
| 522 | + )); |
|
| 523 | 523 | |
| 524 | 524 | ?> |
| 525 | 525 | </td> |
@@ -538,28 +538,28 @@ discard block |
||
| 538 | 538 | * |
| 539 | 539 | * @param \WP_Post $post |
| 540 | 540 | */ |
| 541 | - private static function advanced_settings_panel( $post ) { |
|
| 541 | + private static function advanced_settings_panel($post) { |
|
| 542 | 542 | |
| 543 | 543 | ?> |
| 544 | 544 | <table> |
| 545 | 545 | <thead> |
| 546 | - <tr><th colspan="2"><?php _e( 'Date and Time', 'google-calendar-events' ); ?></th></tr> |
|
| 546 | + <tr><th colspan="2"><?php _e('Date and Time', 'google-calendar-events'); ?></th></tr> |
|
| 547 | 547 | </thead> |
| 548 | 548 | <tbody class="simcal-panel-section simcal-panel-datetime-formatting"> |
| 549 | 549 | <tr class="simcal-panel-field"> |
| 550 | - <th><label for="_calendar_timezone_setting"><?php _e( 'Timezone', 'google-calendar-events' ); ?></label></th> |
|
| 550 | + <th><label for="_calendar_timezone_setting"><?php _e('Timezone', 'google-calendar-events'); ?></label></th> |
|
| 551 | 551 | <td> |
| 552 | 552 | <?php |
| 553 | 553 | |
| 554 | 554 | $timezone_wordpress = simcal_get_wp_timezone(); |
| 555 | 555 | $timezone_default = $timezone_wordpress ? $timezone_wordpress : 'UTC'; |
| 556 | - $timezone_setting = esc_attr( get_post_meta( $post->ID, '_feed_timezone_setting', true ) ); |
|
| 557 | - $timezone = esc_attr( get_post_meta( $post->ID, '_feed_timezone', true ) ); |
|
| 556 | + $timezone_setting = esc_attr(get_post_meta($post->ID, '_feed_timezone_setting', true)); |
|
| 557 | + $timezone = esc_attr(get_post_meta($post->ID, '_feed_timezone', true)); |
|
| 558 | 558 | $timezone = $timezone ? $timezone : $timezone_default; |
| 559 | - $show_use_calendar = isset( simcal_get_feed( $post )->type ); |
|
| 559 | + $show_use_calendar = isset(simcal_get_feed($post)->type); |
|
| 560 | 560 | |
| 561 | - if ( $show_use_calendar ) { |
|
| 562 | - $show_use_calendar = ( simcal_get_feed( $post )->type !== 'grouped-calendars' ? 1 : 0 ); |
|
| 561 | + if ($show_use_calendar) { |
|
| 562 | + $show_use_calendar = (simcal_get_feed($post)->type !== 'grouped-calendars' ? 1 : 0); |
|
| 563 | 563 | } else { |
| 564 | 564 | $show_use_calendar = true; |
| 565 | 565 | } |
@@ -569,56 +569,56 @@ discard block |
||
| 569 | 569 | id="_feed_timezone_setting" |
| 570 | 570 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-other" |
| 571 | 571 | data-show-field-on-choice="true"> |
| 572 | - <option value="use_site" <?php selected( 'use_site', $timezone_setting, true ); ?>><?php printf( _x( 'Site default', 'Use this site default setting', 'google-calendar-events' ) . ' (%s)', $timezone_default ); ?></option> |
|
| 573 | - <?php if ( $show_use_calendar ) { ?> |
|
| 574 | - <option id="use_calendar" value="use_calendar" data-show-field="_use_calendar_warning" <?php selected( 'use_calendar', $timezone_setting, true ); ?>><?php _ex( 'Events source default', 'Use the calendar default setting', 'google-calendar-events' ); ?></option> |
|
| 572 | + <option value="use_site" <?php selected('use_site', $timezone_setting, true); ?>><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events').' (%s)', $timezone_default); ?></option> |
|
| 573 | + <?php if ($show_use_calendar) { ?> |
|
| 574 | + <option id="use_calendar" value="use_calendar" data-show-field="_use_calendar_warning" <?php selected('use_calendar', $timezone_setting, true); ?>><?php _ex('Events source default', 'Use the calendar default setting', 'google-calendar-events'); ?></option> |
|
| 575 | 575 | <?php } ?> |
| 576 | - <option value="use_custom" data-show-field="_feed_timezone" <?php selected( 'use_custom', $timezone_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
| 576 | + <option value="use_custom" data-show-field="_feed_timezone" <?php selected('use_custom', $timezone_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
| 577 | 577 | </select> |
| 578 | 578 | <select name="_feed_timezone" |
| 579 | 579 | id="_feed_timezone" |
| 580 | 580 | class="simcal-field simcal-field-select simcal-field-inline" |
| 581 | 581 | <?php echo 'use_custom' != $timezone_setting ? 'style="display: none;"' : ''; ?>> |
| 582 | - <?php echo wp_timezone_choice( $timezone ); ?> |
|
| 582 | + <?php echo wp_timezone_choice($timezone); ?> |
|
| 583 | 583 | </select> |
| 584 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Using a different timezone may alter the date and time display of your calendar events. It is recommended to keep the calendar default timezone.', 'google-calendar-events' ); ?>"></i> |
|
| 584 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Using a different timezone may alter the date and time display of your calendar events. It is recommended to keep the calendar default timezone.', 'google-calendar-events'); ?>"></i> |
|
| 585 | 585 | <p id="_use_calendar_warning" style="display: none;" class="simcal-field"> |
| 586 | - <?php printf( __( '<strong>Warning:</strong> Using this option can return unexpected results if you have specified <a href="%s" target="_blank">event level</a> timezones.', 'google-calendar-events' ), 'http://docs.simplecalendar.io/timezone-settings/' ); ?> |
|
| 586 | + <?php printf(__('<strong>Warning:</strong> Using this option can return unexpected results if you have specified <a href="%s" target="_blank">event level</a> timezones.', 'google-calendar-events'), 'http://docs.simplecalendar.io/timezone-settings/'); ?> |
|
| 587 | 587 | </p> |
| 588 | 588 | </td> |
| 589 | 589 | </tr> |
| 590 | 590 | <tr class="simcal-panel-field"> |
| 591 | - <th><label for="_calendar_date_format_setting"><?php _e( 'Date Format', 'google-calendar-events' ); ?></label></th> |
|
| 591 | + <th><label for="_calendar_date_format_setting"><?php _e('Date Format', 'google-calendar-events'); ?></label></th> |
|
| 592 | 592 | <td> |
| 593 | 593 | <?php |
| 594 | 594 | |
| 595 | - $date_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_setting', true ) ); |
|
| 596 | - $date_format_default = esc_attr( get_option( 'date_format' ) ); |
|
| 597 | - $date_format = esc_attr( get_post_meta( $post->ID, '_calendar_date_format', true ) ); |
|
| 598 | - $date_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_php', true ) ); |
|
| 595 | + $date_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_date_format_setting', true)); |
|
| 596 | + $date_format_default = esc_attr(get_option('date_format')); |
|
| 597 | + $date_format = esc_attr(get_post_meta($post->ID, '_calendar_date_format', true)); |
|
| 598 | + $date_format_php = esc_attr(get_post_meta($post->ID, '_calendar_date_format_php', true)); |
|
| 599 | 599 | $date_format_php = $date_format_php ? $date_format_php : $date_format_default; |
| 600 | 600 | |
| 601 | 601 | ?> |
| 602 | 602 | <select name="_calendar_date_format_setting" |
| 603 | 603 | id="_calendar_date_format_setting" |
| 604 | 604 | class="simcal-field simcal-field-select simcal-field-show-other"> |
| 605 | - <option value="use_site" data-show-field="_calendar_date_format_default" <?php selected( 'use_site', $date_format_setting, true ); ?>><?php _ex( 'Site default', 'Use this site default setting', 'google-calendar-events' ); ?></option> |
|
| 606 | - <option value="use_custom" data-show-field="_calendar_date_format" <?php selected( 'use_custom', $date_format_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
| 607 | - <option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected( 'use_custom_php', $date_format_setting, true ); ?>><?php _e( 'Custom (PHP format)', 'google-calendar-events' ); ?></option> |
|
| 605 | + <option value="use_site" data-show-field="_calendar_date_format_default" <?php selected('use_site', $date_format_setting, true); ?>><?php _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?></option> |
|
| 606 | + <option value="use_custom" data-show-field="_calendar_date_format" <?php selected('use_custom', $date_format_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
| 607 | + <option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected('use_custom_php', $date_format_setting, true); ?>><?php _e('Custom (PHP format)', 'google-calendar-events'); ?></option> |
|
| 608 | 608 | </select> |
| 609 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events' ); ?>"></i> |
|
| 609 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events'); ?>"></i> |
|
| 610 | 610 | <p id="_calendar_date_format_default" style="<?php echo $date_format_setting != 'use_site' ? 'display: none;' : ''; ?>"> |
| 611 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
| 612 | - <code><?php echo date_i18n( $date_format_default, time() ); ?></code> |
|
| 611 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
| 612 | + <code><?php echo date_i18n($date_format_default, time()); ?></code> |
|
| 613 | 613 | </p> |
| 614 | - <?php simcal_print_field( array( |
|
| 614 | + <?php simcal_print_field(array( |
|
| 615 | 615 | 'type' => 'datetime-format', |
| 616 | 616 | 'subtype' => 'date', |
| 617 | 617 | 'name' => '_calendar_date_format', |
| 618 | 618 | 'id' => '_calendar_date_format', |
| 619 | 619 | 'value' => $date_format, |
| 620 | - 'style' => $date_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '', |
|
| 621 | - ) ); ?> |
|
| 620 | + 'style' => $date_format_setting != 'use_custom' ? array('display' => 'none') : '', |
|
| 621 | + )); ?> |
|
| 622 | 622 | <div class="simcal-field-datetime-format-php" id="_calendar_date_format_php_field" style="<?php echo $date_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>"> |
| 623 | 623 | <br> |
| 624 | 624 | <label for="_calendar_date_format_php"> |
@@ -627,70 +627,70 @@ discard block |
||
| 627 | 627 | id="_calendar_date_format_php" |
| 628 | 628 | class="simcal-field simcal-field-text simcal-field-small" |
| 629 | 629 | value="<?php echo $date_format_php; ?>" /> |
| 630 | - <?php printf( __( 'Enter a date format using %s values.', 'google-calendar-events' ), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>' ); ?> |
|
| 630 | + <?php printf(__('Enter a date format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?> |
|
| 631 | 631 | </label> |
| 632 | 632 | <p> |
| 633 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
| 634 | - <code><?php echo date_i18n( $date_format_php, time() ); ?></code> |
|
| 633 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
| 634 | + <code><?php echo date_i18n($date_format_php, time()); ?></code> |
|
| 635 | 635 | </p> |
| 636 | 636 | </div> |
| 637 | 637 | </td> |
| 638 | 638 | </tr> |
| 639 | 639 | <tr class="simcal-panel-field"> |
| 640 | - <th><label for="_calendar_datetime_separator"><?php _e( 'Separator', 'google-calendar-events' ); ?></label></th> |
|
| 640 | + <th><label for="_calendar_datetime_separator"><?php _e('Separator', 'google-calendar-events'); ?></label></th> |
|
| 641 | 641 | <td> |
| 642 | 642 | <?php |
| 643 | 643 | |
| 644 | - $separator = get_post_meta( $post->ID, '_calendar_datetime_separator', true ); |
|
| 644 | + $separator = get_post_meta($post->ID, '_calendar_datetime_separator', true); |
|
| 645 | 645 | $separator = false == $separator ? '@' : $separator; |
| 646 | 646 | |
| 647 | - simcal_print_field( array( |
|
| 647 | + simcal_print_field(array( |
|
| 648 | 648 | 'type' => 'standard', |
| 649 | 649 | 'subtype' => 'text', |
| 650 | 650 | 'name' => '_calendar_datetime_separator', |
| 651 | 651 | 'id' => '_calendar_datetime_separator', |
| 652 | 652 | 'value' => $separator, |
| 653 | - 'tooltip' => __( 'Used to divide date and time when both are shown.', 'google-calendar-events' ), |
|
| 653 | + 'tooltip' => __('Used to divide date and time when both are shown.', 'google-calendar-events'), |
|
| 654 | 654 | 'class' => array( |
| 655 | 655 | 'simcal-field-tiny', |
| 656 | 656 | ), |
| 657 | - ) ); |
|
| 657 | + )); |
|
| 658 | 658 | |
| 659 | 659 | ?> |
| 660 | 660 | </td> |
| 661 | 661 | </tr> |
| 662 | 662 | <tr class="simcal-panel-field"> |
| 663 | - <th><label for="_calendar_time_format_setting"><?php _e( 'Time Format', 'google-calendar-events' ); ?></label></th> |
|
| 663 | + <th><label for="_calendar_time_format_setting"><?php _e('Time Format', 'google-calendar-events'); ?></label></th> |
|
| 664 | 664 | <td> |
| 665 | 665 | <?php |
| 666 | 666 | |
| 667 | - $time_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_setting', true ) ); |
|
| 668 | - $time_format_default = esc_attr( get_option( 'time_format' ) ); |
|
| 669 | - $time_format = esc_attr( get_post_meta( $post->ID, '_calendar_time_format', true ) ); |
|
| 670 | - $time_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_php', true ) ); |
|
| 667 | + $time_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_time_format_setting', true)); |
|
| 668 | + $time_format_default = esc_attr(get_option('time_format')); |
|
| 669 | + $time_format = esc_attr(get_post_meta($post->ID, '_calendar_time_format', true)); |
|
| 670 | + $time_format_php = esc_attr(get_post_meta($post->ID, '_calendar_time_format_php', true)); |
|
| 671 | 671 | $time_format_php = $time_format_php ? $time_format_php : $time_format_default; |
| 672 | 672 | |
| 673 | 673 | ?> |
| 674 | 674 | <select name="_calendar_time_format_setting" |
| 675 | 675 | id="_calendar_time_format_setting" |
| 676 | 676 | class="simcal-field simcal-field-select simcal-field-show-other"> |
| 677 | - <option value="use_site" data-show-field="_calendar_time_format_default" <?php selected( 'use_site', $time_format_setting, true ); ?>><?php _ex( 'Site default', 'Use this site default setting', 'google-calendar-events' ); ?></option> |
|
| 678 | - <option value="use_custom" data-show-field="_calendar_time_format" <?php selected( 'use_custom', $time_format_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
| 679 | - <option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected( 'use_custom_php', $time_format_setting, true ); ?>><?php _e( 'Custom (PHP format)', 'google-calendar-events' ); ?></option> |
|
| 677 | + <option value="use_site" data-show-field="_calendar_time_format_default" <?php selected('use_site', $time_format_setting, true); ?>><?php _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?></option> |
|
| 678 | + <option value="use_custom" data-show-field="_calendar_time_format" <?php selected('use_custom', $time_format_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
| 679 | + <option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected('use_custom_php', $time_format_setting, true); ?>><?php _e('Custom (PHP format)', 'google-calendar-events'); ?></option> |
|
| 680 | 680 | </select> |
| 681 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events' ); ?>"></i> |
|
| 681 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events'); ?>"></i> |
|
| 682 | 682 | <p id="_calendar_time_format_default" style="<?php echo $time_format_setting != 'use_site' ? 'display: none;' : ''; ?>"> |
| 683 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
| 684 | - <code><?php echo date_i18n( $time_format_default, time() ); ?></code> |
|
| 683 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
| 684 | + <code><?php echo date_i18n($time_format_default, time()); ?></code> |
|
| 685 | 685 | </p> |
| 686 | - <?php simcal_print_field( array( |
|
| 686 | + <?php simcal_print_field(array( |
|
| 687 | 687 | 'type' => 'datetime-format', |
| 688 | 688 | 'subtype' => 'time', |
| 689 | 689 | 'name' => '_calendar_time_format', |
| 690 | 690 | 'id' => '_calendar_time_format', |
| 691 | 691 | 'value' => $time_format, |
| 692 | - 'style' => $time_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '', |
|
| 693 | - ) ); ?> |
|
| 692 | + 'style' => $time_format_setting != 'use_custom' ? array('display' => 'none') : '', |
|
| 693 | + )); ?> |
|
| 694 | 694 | <div class="simcal-field-datetime-format-php" id="_calendar_time_format_php_field" style="<?php echo $time_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>"> |
| 695 | 695 | <br> |
| 696 | 696 | <label for="_calendar_date_format_php"> |
@@ -699,24 +699,24 @@ discard block |
||
| 699 | 699 | id="_calendar_time_format_php" |
| 700 | 700 | class="simcal-field simcal-field-text simcal-field-small" |
| 701 | 701 | value="<?php echo $time_format_php; ?>"/> |
| 702 | - <?php printf( __( 'Enter a time format using %s values.', 'google-calendar-events' ), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>' ); ?> |
|
| 702 | + <?php printf(__('Enter a time format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?> |
|
| 703 | 703 | </label> |
| 704 | 704 | <p> |
| 705 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
| 706 | - <code><?php echo date_i18n( $time_format_php, time() ); ?></code> |
|
| 705 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
| 706 | + <code><?php echo date_i18n($time_format_php, time()); ?></code> |
|
| 707 | 707 | </p> |
| 708 | 708 | </div> |
| 709 | 709 | </td> |
| 710 | 710 | </tr> |
| 711 | 711 | <tr class="simcal-panel-field"> |
| 712 | - <th><label for="_calendar_week_starts_on_setting"><?php _e( 'Week Starts On', 'google-calendar-events' ); ?></label></th> |
|
| 712 | + <th><label for="_calendar_week_starts_on_setting"><?php _e('Week Starts On', 'google-calendar-events'); ?></label></th> |
|
| 713 | 713 | <td> |
| 714 | 714 | <?php |
| 715 | 715 | |
| 716 | - $week_starts_setting = esc_attr( get_post_meta( $post->ID, '_calendar_week_starts_on_setting', true ) ); |
|
| 717 | - $week_starts_default = esc_attr( get_option( 'start_of_week' ) ); |
|
| 718 | - $week_starts = intval( get_post_meta( $post->ID, '_calendar_week_starts_on', true ) ); |
|
| 719 | - $week_starts = is_numeric( $week_starts ) ? strval( $week_starts ) : $week_starts_default; |
|
| 716 | + $week_starts_setting = esc_attr(get_post_meta($post->ID, '_calendar_week_starts_on_setting', true)); |
|
| 717 | + $week_starts_default = esc_attr(get_option('start_of_week')); |
|
| 718 | + $week_starts = intval(get_post_meta($post->ID, '_calendar_week_starts_on', true)); |
|
| 719 | + $week_starts = is_numeric($week_starts) ? strval($week_starts) : $week_starts_default; |
|
| 720 | 720 | |
| 721 | 721 | ?> |
| 722 | 722 | <select |
@@ -724,40 +724,40 @@ discard block |
||
| 724 | 724 | id="_calendar_week_starts_on_setting" |
| 725 | 725 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-next" |
| 726 | 726 | data-show-next-if-value="use_custom"> |
| 727 | - <option value="use_site" <?php selected( 'use_site', $week_starts_setting, true ); ?>><?php printf( _x( 'Site default', 'Use this site default setting', 'google-calendar-events' ) . ' (%s)', date_i18n( 'l', strtotime( "Sunday + $week_starts_default Days" ) ) ); ?></option> |
|
| 728 | - <option value="use_custom" <?php selected( 'use_custom', $week_starts_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
| 727 | + <option value="use_site" <?php selected('use_site', $week_starts_setting, true); ?>><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events').' (%s)', date_i18n('l', strtotime("Sunday + $week_starts_default Days"))); ?></option> |
|
| 728 | + <option value="use_custom" <?php selected('use_custom', $week_starts_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
| 729 | 729 | </select> |
| 730 | 730 | <select |
| 731 | 731 | name="_calendar_week_starts_on" |
| 732 | 732 | id="_calendar_week_starts_on" |
| 733 | 733 | class="simcal-field simcal-field-select simcal-field-inline" |
| 734 | 734 | <?php echo 'use_custom' != $week_starts_setting ? 'style="display: none;"' : ''; ?>> |
| 735 | - <?php $day_names = simcal_get_calendar_names_i18n( 'day', 'full' ); ?> |
|
| 736 | - <?php for ( $i = 0; $i <= 6; $i++ ) : ?> |
|
| 737 | - <option value="<?php echo $i; ?>" <?php selected( $i, $week_starts, true ); ?>><?php echo $day_names[ $i ]; ?></option> |
|
| 735 | + <?php $day_names = simcal_get_calendar_names_i18n('day', 'full'); ?> |
|
| 736 | + <?php for ($i = 0; $i <= 6; $i++) : ?> |
|
| 737 | + <option value="<?php echo $i; ?>" <?php selected($i, $week_starts, true); ?>><?php echo $day_names[$i]; ?></option> |
|
| 738 | 738 | <?php endfor; ?> |
| 739 | 739 | </select> |
| 740 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events' ); ?>"></i> |
|
| 740 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events'); ?>"></i> |
|
| 741 | 741 | </td> |
| 742 | 742 | </tr> |
| 743 | 743 | </tbody> |
| 744 | 744 | </table> |
| 745 | 745 | <table> |
| 746 | 746 | <thead> |
| 747 | - <tr><th colspan="2"><?php _e( 'Cache', 'google-calendar-events' ); ?></th></tr> |
|
| 747 | + <tr><th colspan="2"><?php _e('Cache', 'google-calendar-events'); ?></th></tr> |
|
| 748 | 748 | </thead> |
| 749 | 749 | <tbody class="simcal-panel-section simcal-panel-section-cache"> |
| 750 | 750 | <?php |
| 751 | 751 | |
| 752 | - $cache_freq = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_amount', true ) ); |
|
| 753 | - $cache_unit = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_unit', true ) ); |
|
| 752 | + $cache_freq = esc_attr(get_post_meta($post->ID, '_feed_cache_user_amount', true)); |
|
| 753 | + $cache_unit = esc_attr(get_post_meta($post->ID, '_feed_cache_user_unit', true)); |
|
| 754 | 754 | |
| 755 | - $cache_freq = intval( $cache_freq ) && $cache_freq >= 0 ? $cache_freq : 2; |
|
| 755 | + $cache_freq = intval($cache_freq) && $cache_freq >= 0 ? $cache_freq : 2; |
|
| 756 | 756 | $cache_unit = $cache_unit ? $cache_unit : '3600'; |
| 757 | 757 | |
| 758 | 758 | ?> |
| 759 | 759 | <tr class="simcal-panel-field"> |
| 760 | - <th><label for="_feed_cache_user_amount"><?php _ex( 'Refresh Interval', 'Cache maximum interval', 'google-calendar-events' ); ?></label></th> |
|
| 760 | + <th><label for="_feed_cache_user_amount"><?php _ex('Refresh Interval', 'Cache maximum interval', 'google-calendar-events'); ?></label></th> |
|
| 761 | 761 | <td> |
| 762 | 762 | <input type="number" |
| 763 | 763 | name="_feed_cache_user_amount" |
@@ -768,12 +768,12 @@ discard block |
||
| 768 | 768 | <select name="_feed_cache_user_unit" |
| 769 | 769 | id="_feed_cache_user_unit" |
| 770 | 770 | class="simcal-field simcalfield-select simcal-field-inline"> |
| 771 | - <option value="60" <?php selected( '60', $cache_unit, true ); ?>><?php _e( 'Minute(s)', 'google-calendar-events' ); ?></option> |
|
| 772 | - <option value="3600" <?php selected( '3600', $cache_unit, true ); ?>><?php _e( 'Hour(s)', 'google-calendar-events' ); ?></option> |
|
| 773 | - <option value="86400" <?php selected( '86400', $cache_unit, true ); ?>><?php _e( 'Day(s)', 'google-calendar-events' ); ?></option> |
|
| 774 | - <option value="604800" <?php selected( '604800', $cache_unit, true ); ?>><?php _e( 'Week(s)', 'google-calendar-events' ); ?></option> |
|
| 771 | + <option value="60" <?php selected('60', $cache_unit, true); ?>><?php _e('Minute(s)', 'google-calendar-events'); ?></option> |
|
| 772 | + <option value="3600" <?php selected('3600', $cache_unit, true); ?>><?php _e('Hour(s)', 'google-calendar-events'); ?></option> |
|
| 773 | + <option value="86400" <?php selected('86400', $cache_unit, true); ?>><?php _e('Day(s)', 'google-calendar-events'); ?></option> |
|
| 774 | + <option value="604800" <?php selected('604800', $cache_unit, true); ?>><?php _e('Week(s)', 'google-calendar-events'); ?></option> |
|
| 775 | 775 | </select> |
| 776 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events' ); ?>"></i> |
|
| 776 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events'); ?>"></i> |
|
| 777 | 777 | </td> |
| 778 | 778 | </tr> |
| 779 | 779 | </tbody> |
@@ -792,21 +792,21 @@ discard block |
||
| 792 | 792 | * |
| 793 | 793 | * @return void |
| 794 | 794 | */ |
| 795 | - public static function print_panel_fields( $array, $post_id ) { |
|
| 795 | + public static function print_panel_fields($array, $post_id) { |
|
| 796 | 796 | |
| 797 | - foreach ( $array as $section => $fields ) : |
|
| 797 | + foreach ($array as $section => $fields) : |
|
| 798 | 798 | |
| 799 | - if ( $fields && is_array( $fields ) ) : |
|
| 799 | + if ($fields && is_array($fields)) : |
|
| 800 | 800 | |
| 801 | 801 | ?> |
| 802 | - <tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr( $section ); ?>"> |
|
| 803 | - <?php foreach ( $fields as $key => $field ) : |
|
| 802 | + <tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr($section); ?>"> |
|
| 803 | + <?php foreach ($fields as $key => $field) : |
|
| 804 | 804 | |
| 805 | - $value = get_post_meta( $post_id, $key, true ); |
|
| 806 | - $field['value'] = $value ? $value : ( isset( $field['default'] ) ? $field['default'] : '' ); |
|
| 807 | - $the_field = simcal_get_field( $field ); ?> |
|
| 805 | + $value = get_post_meta($post_id, $key, true); |
|
| 806 | + $field['value'] = $value ? $value : (isset($field['default']) ? $field['default'] : ''); |
|
| 807 | + $the_field = simcal_get_field($field); ?> |
|
| 808 | 808 | |
| 809 | - <?php if ( $the_field instanceof Field ) : ?> |
|
| 809 | + <?php if ($the_field instanceof Field) : ?> |
|
| 810 | 810 | <tr class="simcal-panel-field"> |
| 811 | 811 | <th><label for="<?php echo $the_field->id ?>"><?php echo $the_field->title; ?></label></th> |
| 812 | 812 | <td><?php $the_field->html(); ?></td> |
@@ -833,30 +833,30 @@ discard block |
||
| 833 | 833 | * |
| 834 | 834 | * @return void |
| 835 | 835 | */ |
| 836 | - public static function save( $post_id, $post ) { |
|
| 836 | + public static function save($post_id, $post) { |
|
| 837 | 837 | |
| 838 | 838 | /* ====================== * |
| 839 | 839 | * Calendar type and view * |
| 840 | 840 | * ====================== */ |
| 841 | 841 | |
| 842 | 842 | // Unlink existing terms for feed type and calendar type. |
| 843 | - wp_delete_object_term_relationships( $post_id, array( |
|
| 843 | + wp_delete_object_term_relationships($post_id, array( |
|
| 844 | 844 | 'calendar_feed', |
| 845 | 845 | 'calendar_type', |
| 846 | - ) ); |
|
| 846 | + )); |
|
| 847 | 847 | |
| 848 | 848 | // Set the feed type as term. |
| 849 | - $feed_type = isset( $_POST['_feed_type'] ) ? sanitize_title( stripslashes( $_POST['_feed_type'] ) ) : apply_filters( 'simcal_default_feed_type', 'google' ); |
|
| 850 | - wp_set_object_terms( $post_id, $feed_type, 'calendar_feed' ); |
|
| 849 | + $feed_type = isset($_POST['_feed_type']) ? sanitize_title(stripslashes($_POST['_feed_type'])) : apply_filters('simcal_default_feed_type', 'google'); |
|
| 850 | + wp_set_object_terms($post_id, $feed_type, 'calendar_feed'); |
|
| 851 | 851 | |
| 852 | 852 | // Set the calendar type as a term. |
| 853 | - $calendar_type = isset( $_POST['_calendar_type'] ) ? sanitize_title( stripslashes( $_POST['_calendar_type'] ) ) : apply_filters( 'simcal_default_calendar_type', 'default-calendar' ); |
|
| 854 | - wp_set_object_terms( $post_id, $calendar_type, 'calendar_type' ); |
|
| 853 | + $calendar_type = isset($_POST['_calendar_type']) ? sanitize_title(stripslashes($_POST['_calendar_type'])) : apply_filters('simcal_default_calendar_type', 'default-calendar'); |
|
| 854 | + wp_set_object_terms($post_id, $calendar_type, 'calendar_type'); |
|
| 855 | 855 | // Set the calendar type view as post meta. |
| 856 | - $calendar_view = isset( $_POST['_calendar_view'] ) ? $_POST['_calendar_view'] : ''; |
|
| 857 | - if ( $calendar_view && is_array( $calendar_view ) ) { |
|
| 858 | - $views = array_map( 'sanitize_title', $calendar_view ); |
|
| 859 | - update_post_meta( $post_id, '_calendar_view', $views ); |
|
| 856 | + $calendar_view = isset($_POST['_calendar_view']) ? $_POST['_calendar_view'] : ''; |
|
| 857 | + if ($calendar_view && is_array($calendar_view)) { |
|
| 858 | + $views = array_map('sanitize_title', $calendar_view); |
|
| 859 | + update_post_meta($post_id, '_calendar_view', $views); |
|
| 860 | 860 | } |
| 861 | 861 | |
| 862 | 862 | /* ===================== * |
@@ -864,106 +864,106 @@ discard block |
||
| 864 | 864 | * ===================== */ |
| 865 | 865 | |
| 866 | 866 | // Calendar opening. |
| 867 | - $calendar_begins = isset( $_POST['_calendar_begins'] ) ? sanitize_key( $_POST['_calendar_begins'] ) : 'this_month'; |
|
| 868 | - update_post_meta( $post_id, '_calendar_begins', $calendar_begins ); |
|
| 869 | - $calendar_begins_nth = isset( $_POST['_calendar_begins_nth'] ) ? absint( $_POST['_calendar_begins_nth'] ) : 2; |
|
| 870 | - update_post_meta( $post_id, '_calendar_begins_nth', $calendar_begins_nth ); |
|
| 871 | - $calendar_begins_custom_date = isset( $_POST['_calendar_begins_custom_date'] ) ? sanitize_title( $_POST['_calendar_begins_custom_date'] ) : ''; |
|
| 872 | - update_post_meta( $post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date ); |
|
| 867 | + $calendar_begins = isset($_POST['_calendar_begins']) ? sanitize_key($_POST['_calendar_begins']) : 'this_month'; |
|
| 868 | + update_post_meta($post_id, '_calendar_begins', $calendar_begins); |
|
| 869 | + $calendar_begins_nth = isset($_POST['_calendar_begins_nth']) ? absint($_POST['_calendar_begins_nth']) : 2; |
|
| 870 | + update_post_meta($post_id, '_calendar_begins_nth', $calendar_begins_nth); |
|
| 871 | + $calendar_begins_custom_date = isset($_POST['_calendar_begins_custom_date']) ? sanitize_title($_POST['_calendar_begins_custom_date']) : ''; |
|
| 872 | + update_post_meta($post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date); |
|
| 873 | 873 | |
| 874 | 874 | // Feed earliest events date. |
| 875 | - $earliest_events = isset( $_POST['_feed_earliest_event_date'] ) ? sanitize_key( $_POST['_feed_earliest_event_date'] ) : ''; |
|
| 876 | - update_post_meta( $post_id, '_feed_earliest_event_date', $earliest_events ); |
|
| 877 | - $earliest_events_range = isset( $_POST['_feed_earliest_event_date_range'] ) ? max( absint( $_POST['_feed_earliest_event_date_range'] ), 1 ) : 1; |
|
| 878 | - update_post_meta( $post_id, '_feed_earliest_event_date_range', $earliest_events_range ); |
|
| 875 | + $earliest_events = isset($_POST['_feed_earliest_event_date']) ? sanitize_key($_POST['_feed_earliest_event_date']) : ''; |
|
| 876 | + update_post_meta($post_id, '_feed_earliest_event_date', $earliest_events); |
|
| 877 | + $earliest_events_range = isset($_POST['_feed_earliest_event_date_range']) ? max(absint($_POST['_feed_earliest_event_date_range']), 1) : 1; |
|
| 878 | + update_post_meta($post_id, '_feed_earliest_event_date_range', $earliest_events_range); |
|
| 879 | 879 | |
| 880 | 880 | // Feed latest events date. |
| 881 | - $latest_events = isset( $_POST['_feed_latest_event_date'] ) ? sanitize_key( $_POST['_feed_latest_event_date'] ) : ''; |
|
| 882 | - update_post_meta( $post_id, '_feed_latest_event_date', $latest_events ); |
|
| 883 | - $latest_events_range = isset( $_POST['_feed_latest_event_date_range'] ) ? max( absint( $_POST['_feed_latest_event_date_range'] ), 1 ) : 1; |
|
| 884 | - update_post_meta( $post_id, '_feed_latest_event_date_range', $latest_events_range ); |
|
| 881 | + $latest_events = isset($_POST['_feed_latest_event_date']) ? sanitize_key($_POST['_feed_latest_event_date']) : ''; |
|
| 882 | + update_post_meta($post_id, '_feed_latest_event_date', $latest_events); |
|
| 883 | + $latest_events_range = isset($_POST['_feed_latest_event_date_range']) ? max(absint($_POST['_feed_latest_event_date_range']), 1) : 1; |
|
| 884 | + update_post_meta($post_id, '_feed_latest_event_date_range', $latest_events_range); |
|
| 885 | 885 | |
| 886 | 886 | /* ======================= * |
| 887 | 887 | * Calendar settings panel * |
| 888 | 888 | * ======================= */ |
| 889 | 889 | |
| 890 | 890 | // Static calendar. |
| 891 | - $static = isset( $_POST['_calendar_is_static'] ) ? 'yes' : 'no'; |
|
| 892 | - update_post_meta( $post_id, '_calendar_is_static', $static ); |
|
| 891 | + $static = isset($_POST['_calendar_is_static']) ? 'yes' : 'no'; |
|
| 892 | + update_post_meta($post_id, '_calendar_is_static', $static); |
|
| 893 | 893 | |
| 894 | 894 | // No events message. |
| 895 | - $message = isset( $_POST['_no_events_message'] ) ? wp_kses_post( $_POST['_no_events_message'] ) : ''; |
|
| 896 | - update_post_meta( $post_id, '_no_events_message', $message ); |
|
| 895 | + $message = isset($_POST['_no_events_message']) ? wp_kses_post($_POST['_no_events_message']) : ''; |
|
| 896 | + update_post_meta($post_id, '_no_events_message', $message); |
|
| 897 | 897 | |
| 898 | 898 | // _event_formatting |
| 899 | - $event_formatting = isset( $_POST['_event_formatting'] ) ? sanitize_key( $_POST['_event_formatting'] ) : 'preserve_linebreaks'; |
|
| 900 | - update_post_meta( $post_id, '_event_formatting', $event_formatting ); |
|
| 899 | + $event_formatting = isset($_POST['_event_formatting']) ? sanitize_key($_POST['_event_formatting']) : 'preserve_linebreaks'; |
|
| 900 | + update_post_meta($post_id, '_event_formatting', $event_formatting); |
|
| 901 | 901 | |
| 902 | 902 | // Powered by option |
| 903 | - $poweredby = isset( $_POST['_poweredby'] ) ? 'yes' : 'no'; |
|
| 904 | - update_post_meta( $post_id, '_poweredby', $poweredby ); |
|
| 903 | + $poweredby = isset($_POST['_poweredby']) ? 'yes' : 'no'; |
|
| 904 | + update_post_meta($post_id, '_poweredby', $poweredby); |
|
| 905 | 905 | |
| 906 | 906 | /* ======================= * |
| 907 | 907 | * Advanced settings panel * |
| 908 | 908 | * ======================= */ |
| 909 | 909 | |
| 910 | 910 | // Timezone. |
| 911 | - $feed_timezone_setting = isset( $_POST['_feed_timezone_setting'] ) ? sanitize_key( $_POST['_feed_timezone_setting'] ) : 'use_calendar'; |
|
| 912 | - update_post_meta( $post_id, '_feed_timezone_setting', $feed_timezone_setting ); |
|
| 911 | + $feed_timezone_setting = isset($_POST['_feed_timezone_setting']) ? sanitize_key($_POST['_feed_timezone_setting']) : 'use_calendar'; |
|
| 912 | + update_post_meta($post_id, '_feed_timezone_setting', $feed_timezone_setting); |
|
| 913 | 913 | $default_timezone = simcal_get_wp_timezone(); |
| 914 | 914 | $feed_timezone = $default_timezone ? $default_timezone : 'UTC'; |
| 915 | - $feed_timezone = isset( $_POST['_feed_timezone'] ) ? sanitize_text_field( $_POST['_feed_timezone'] ) : $feed_timezone; |
|
| 916 | - update_post_meta( $post_id, '_feed_timezone', $feed_timezone ); |
|
| 915 | + $feed_timezone = isset($_POST['_feed_timezone']) ? sanitize_text_field($_POST['_feed_timezone']) : $feed_timezone; |
|
| 916 | + update_post_meta($post_id, '_feed_timezone', $feed_timezone); |
|
| 917 | 917 | |
| 918 | 918 | // Date format. |
| 919 | - $date_format_setting = isset( $_POST['_calendar_date_format_setting'] ) ? sanitize_key( $_POST['_calendar_date_format_setting'] ) : 'use_site'; |
|
| 920 | - update_post_meta( $post_id, '_calendar_date_format_setting', $date_format_setting ); |
|
| 921 | - $date_format = isset( $_POST['_calendar_date_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format'] ) ) : get_option( 'date_format' ); |
|
| 922 | - update_post_meta( $post_id, '_calendar_date_format', $date_format ); |
|
| 923 | - $date_format_php = isset( $_POST['_calendar_date_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format_php'] ) ) : get_option( 'date_format' ); |
|
| 924 | - update_post_meta( $post_id, '_calendar_date_format_php', $date_format_php ); |
|
| 919 | + $date_format_setting = isset($_POST['_calendar_date_format_setting']) ? sanitize_key($_POST['_calendar_date_format_setting']) : 'use_site'; |
|
| 920 | + update_post_meta($post_id, '_calendar_date_format_setting', $date_format_setting); |
|
| 921 | + $date_format = isset($_POST['_calendar_date_format']) ? sanitize_text_field(trim($_POST['_calendar_date_format'])) : get_option('date_format'); |
|
| 922 | + update_post_meta($post_id, '_calendar_date_format', $date_format); |
|
| 923 | + $date_format_php = isset($_POST['_calendar_date_format_php']) ? sanitize_text_field(trim($_POST['_calendar_date_format_php'])) : get_option('date_format'); |
|
| 924 | + update_post_meta($post_id, '_calendar_date_format_php', $date_format_php); |
|
| 925 | 925 | |
| 926 | 926 | // Time format. |
| 927 | - $time_format_setting = isset( $_POST['_calendar_time_format_setting'] ) ? sanitize_key( $_POST['_calendar_time_format_setting'] ) : 'use_site'; |
|
| 928 | - update_post_meta( $post_id, '_calendar_time_format_setting', $time_format_setting ); |
|
| 929 | - $time_format = isset( $_POST['_calendar_time_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format'] ) ) : get_option( 'time_format' ); |
|
| 930 | - update_post_meta( $post_id, '_calendar_time_format', $time_format ); |
|
| 931 | - $time_format_php = isset( $_POST['_calendar_time_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format_php'] ) ) : get_option( 'time_format' ); |
|
| 932 | - update_post_meta( $post_id, '_calendar_time_format_php', $time_format_php ); |
|
| 927 | + $time_format_setting = isset($_POST['_calendar_time_format_setting']) ? sanitize_key($_POST['_calendar_time_format_setting']) : 'use_site'; |
|
| 928 | + update_post_meta($post_id, '_calendar_time_format_setting', $time_format_setting); |
|
| 929 | + $time_format = isset($_POST['_calendar_time_format']) ? sanitize_text_field(trim($_POST['_calendar_time_format'])) : get_option('time_format'); |
|
| 930 | + update_post_meta($post_id, '_calendar_time_format', $time_format); |
|
| 931 | + $time_format_php = isset($_POST['_calendar_time_format_php']) ? sanitize_text_field(trim($_POST['_calendar_time_format_php'])) : get_option('time_format'); |
|
| 932 | + update_post_meta($post_id, '_calendar_time_format_php', $time_format_php); |
|
| 933 | 933 | |
| 934 | 934 | // Date-time separator. |
| 935 | - $datetime_separator = isset( $_POST['_calendar_datetime_separator'] ) ? sanitize_text_field( $_POST['_calendar_datetime_separator'] ) : ' '; |
|
| 936 | - update_post_meta( $post_id, '_calendar_datetime_separator', $datetime_separator ); |
|
| 935 | + $datetime_separator = isset($_POST['_calendar_datetime_separator']) ? sanitize_text_field($_POST['_calendar_datetime_separator']) : ' '; |
|
| 936 | + update_post_meta($post_id, '_calendar_datetime_separator', $datetime_separator); |
|
| 937 | 937 | |
| 938 | 938 | // Week start. |
| 939 | - $week_start_setting = isset( $_POST['_calendar_week_starts_on_setting'] ) ? sanitize_key( $_POST['_calendar_week_starts_on_setting'] ) : 'use_site'; |
|
| 940 | - update_post_meta( $post_id, '_calendar_week_starts_on_setting', $week_start_setting ); |
|
| 941 | - $week_start = isset( $_POST['_calendar_week_starts_on'] ) ? intval( $_POST['_calendar_week_starts_on'] ) : get_option( 'start_of_week' ); |
|
| 942 | - update_post_meta( $post_id, '_calendar_week_starts_on', $week_start ); |
|
| 939 | + $week_start_setting = isset($_POST['_calendar_week_starts_on_setting']) ? sanitize_key($_POST['_calendar_week_starts_on_setting']) : 'use_site'; |
|
| 940 | + update_post_meta($post_id, '_calendar_week_starts_on_setting', $week_start_setting); |
|
| 941 | + $week_start = isset($_POST['_calendar_week_starts_on']) ? intval($_POST['_calendar_week_starts_on']) : get_option('start_of_week'); |
|
| 942 | + update_post_meta($post_id, '_calendar_week_starts_on', $week_start); |
|
| 943 | 943 | |
| 944 | 944 | // Cache interval. |
| 945 | 945 | $cache = 7200; |
| 946 | - if ( isset( $_POST['_feed_cache_user_amount'] ) && isset( $_POST['_feed_cache_user_unit'] ) ) { |
|
| 947 | - $amount = is_numeric( $_POST['_feed_cache_user_amount'] ) || $_POST['_feed_cache_user_amount'] == 0 ? absint( $_POST['_feed_cache_user_amount'] ) : 1; |
|
| 948 | - $unit = is_numeric( $_POST['_feed_cache_user_unit'] ) ? absint( $_POST['_feed_cache_user_unit'] ) : 3600; |
|
| 949 | - update_post_meta( $post_id, '_feed_cache_user_amount', $amount ); |
|
| 950 | - update_post_meta( $post_id, '_feed_cache_user_unit', $unit ); |
|
| 951 | - $cache = ( ( $amount * $unit ) > 0 ) ? $amount * $unit : 1; |
|
| 946 | + if (isset($_POST['_feed_cache_user_amount']) && isset($_POST['_feed_cache_user_unit'])) { |
|
| 947 | + $amount = is_numeric($_POST['_feed_cache_user_amount']) || $_POST['_feed_cache_user_amount'] == 0 ? absint($_POST['_feed_cache_user_amount']) : 1; |
|
| 948 | + $unit = is_numeric($_POST['_feed_cache_user_unit']) ? absint($_POST['_feed_cache_user_unit']) : 3600; |
|
| 949 | + update_post_meta($post_id, '_feed_cache_user_amount', $amount); |
|
| 950 | + update_post_meta($post_id, '_feed_cache_user_unit', $unit); |
|
| 951 | + $cache = (($amount * $unit) > 0) ? $amount * $unit : 1; |
|
| 952 | 952 | } |
| 953 | - update_post_meta( $post_id, '_feed_cache', $cache ); |
|
| 953 | + update_post_meta($post_id, '_feed_cache', $cache); |
|
| 954 | 954 | |
| 955 | 955 | /* ============= * |
| 956 | 956 | * Miscellaneous * |
| 957 | 957 | * ============= */ |
| 958 | 958 | |
| 959 | 959 | // Update version. |
| 960 | - update_post_meta( $post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION ); |
|
| 960 | + update_post_meta($post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION); |
|
| 961 | 961 | |
| 962 | 962 | // Action hook. |
| 963 | - do_action( 'simcal_process_settings_meta', $post_id ); |
|
| 963 | + do_action('simcal_process_settings_meta', $post_id); |
|
| 964 | 964 | |
| 965 | 965 | // Clear cache. |
| 966 | - simcal_delete_feed_transients( $post_id ); |
|
| 966 | + simcal_delete_feed_transients($post_id); |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | use SimpleCalendar\Events\Event_Builder; |
| 12 | 12 | use SimpleCalendar\Events\Events; |
| 13 | 13 | |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -234,12 +234,12 @@ discard block |
||
| 234 | 234 | * @param int|object|\WP_Post|Calendar $calendar |
| 235 | 235 | * @param string $view |
| 236 | 236 | */ |
| 237 | - public function __construct( $calendar, $view = '' ) { |
|
| 237 | + public function __construct($calendar, $view = '') { |
|
| 238 | 238 | |
| 239 | 239 | // Set the post object. |
| 240 | - $this->set_post_object( $calendar ); |
|
| 240 | + $this->set_post_object($calendar); |
|
| 241 | 241 | |
| 242 | - if ( ! is_null( $this->post ) ) { |
|
| 242 | + if ( ! is_null($this->post)) { |
|
| 243 | 243 | |
| 244 | 244 | // Set calendar type and events source. |
| 245 | 245 | $this->set_taxonomies(); |
@@ -256,23 +256,23 @@ discard block |
||
| 256 | 256 | $this->set_events_template(); |
| 257 | 257 | |
| 258 | 258 | // Get events source data. |
| 259 | - $feed = simcal_get_feed( $this ); |
|
| 260 | - if ( $feed instanceof Feed ) { |
|
| 261 | - if ( ! empty( $feed->events ) ) { |
|
| 262 | - if ( is_array( $feed->events ) ) { |
|
| 263 | - $this->set_events( $feed->events ); |
|
| 264 | - if ( 'use_calendar' == get_post_meta( $this->id, '_feed_timezone_setting', true ) ) { |
|
| 259 | + $feed = simcal_get_feed($this); |
|
| 260 | + if ($feed instanceof Feed) { |
|
| 261 | + if ( ! empty($feed->events)) { |
|
| 262 | + if (is_array($feed->events)) { |
|
| 263 | + $this->set_events($feed->events); |
|
| 264 | + if ('use_calendar' == get_post_meta($this->id, '_feed_timezone_setting', true)) { |
|
| 265 | 265 | $this->timezone = $feed->timezone; |
| 266 | 266 | $this->set_start(); |
| 267 | 267 | } |
| 268 | - } elseif ( is_string( $feed->events ) ) { |
|
| 268 | + } elseif (is_string($feed->events)) { |
|
| 269 | 269 | $this->errors[] = $feed->events; |
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | // Set general purpose timestamps. |
| 275 | - $now = Carbon::now( $this->timezone ); |
|
| 275 | + $now = Carbon::now($this->timezone); |
|
| 276 | 276 | $this->now = $now->getTimestamp(); |
| 277 | 277 | $this->today = $now->startOfDay()->getTimestamp(); |
| 278 | 278 | $this->offset = $now->getOffset(); |
@@ -283,26 +283,26 @@ discard block |
||
| 283 | 283 | $this->set_datetime_separator(); |
| 284 | 284 | |
| 285 | 285 | // Set earliest and latest event timestamps. |
| 286 | - if ( $this->events && is_array( $this->events ) ) { |
|
| 287 | - $this->earliest_event = intval( current( array_keys( $this->events ) ) ); |
|
| 288 | - $this->latest_event = intval( key( array_slice( $this->events, -1, 1, true ) ) ); |
|
| 286 | + if ($this->events && is_array($this->events)) { |
|
| 287 | + $this->earliest_event = intval(current(array_keys($this->events))); |
|
| 288 | + $this->latest_event = intval(key(array_slice($this->events, -1, 1, true))); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | // Set calendar end. |
| 292 | 292 | $this->set_end(); |
| 293 | 293 | |
| 294 | 294 | // Set view. |
| 295 | - if ( ! $view ) { |
|
| 295 | + if ( ! $view) { |
|
| 296 | 296 | |
| 297 | - $calendar_view = get_post_meta( $this->id, '_calendar_view', true ); |
|
| 298 | - $calendar_view = isset( $calendar_view[ $this->type ] ) ? $calendar_view[ $this->type ] : ''; |
|
| 297 | + $calendar_view = get_post_meta($this->id, '_calendar_view', true); |
|
| 298 | + $calendar_view = isset($calendar_view[$this->type]) ? $calendar_view[$this->type] : ''; |
|
| 299 | 299 | |
| 300 | - $view = esc_attr( $calendar_view ); |
|
| 300 | + $view = esc_attr($calendar_view); |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | // Get view. |
| 305 | - $this->view = $this->get_view( $view ); |
|
| 305 | + $this->view = $this->get_view($view); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -314,8 +314,8 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @return bool |
| 316 | 316 | */ |
| 317 | - public function __isset( $key ) { |
|
| 318 | - return metadata_exists( 'post', $this->id, '_' . $key ); |
|
| 317 | + public function __isset($key) { |
|
| 318 | + return metadata_exists('post', $this->id, '_'.$key); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | /** |
@@ -327,9 +327,9 @@ discard block |
||
| 327 | 327 | * |
| 328 | 328 | * @return mixed |
| 329 | 329 | */ |
| 330 | - public function __get( $key ) { |
|
| 331 | - $value = get_post_meta( $this->id, '_' . $key, true ); |
|
| 332 | - if ( ! empty( $value ) ) { |
|
| 330 | + public function __get($key) { |
|
| 331 | + $value = get_post_meta($this->id, '_'.$key, true); |
|
| 332 | + if ( ! empty($value)) { |
|
| 333 | 333 | $this->$key = $value; |
| 334 | 334 | } |
| 335 | 335 | return $value; |
@@ -342,17 +342,17 @@ discard block |
||
| 342 | 342 | * |
| 343 | 343 | * @param int|object|\WP_Post|Calendar $calendar |
| 344 | 344 | */ |
| 345 | - public function set_post_object( $calendar ) { |
|
| 346 | - if ( is_numeric( $calendar ) ) { |
|
| 347 | - $this->id = absint( $calendar ); |
|
| 348 | - $this->post = get_post( $this->id ); |
|
| 349 | - } elseif ( $calendar instanceof Calendar ) { |
|
| 350 | - $this->id = absint( $calendar->id ); |
|
| 345 | + public function set_post_object($calendar) { |
|
| 346 | + if (is_numeric($calendar)) { |
|
| 347 | + $this->id = absint($calendar); |
|
| 348 | + $this->post = get_post($this->id); |
|
| 349 | + } elseif ($calendar instanceof Calendar) { |
|
| 350 | + $this->id = absint($calendar->id); |
|
| 351 | 351 | $this->post = $calendar->post; |
| 352 | - } elseif ( $calendar instanceof \WP_Post ) { |
|
| 353 | - $this->id = absint( $calendar->ID ); |
|
| 352 | + } elseif ($calendar instanceof \WP_Post) { |
|
| 353 | + $this->id = absint($calendar->ID); |
|
| 354 | 354 | $this->post = $calendar; |
| 355 | - } elseif ( isset( $calendar->id ) && isset( $calendar->post ) ) { |
|
| 355 | + } elseif (isset($calendar->id) && isset($calendar->post)) { |
|
| 356 | 356 | $this->id = $calendar->id; |
| 357 | 357 | $this->post = $calendar->post; |
| 358 | 358 | } |
@@ -366,8 +366,8 @@ discard block |
||
| 366 | 366 | * @return string |
| 367 | 367 | */ |
| 368 | 368 | public function get_title() { |
| 369 | - $title = isset( $this->post->post_title ) ? $this->post->post_title : ''; |
|
| 370 | - return apply_filters( 'simcal_calendar_title', $title ); |
|
| 369 | + $title = isset($this->post->post_title) ? $this->post->post_title : ''; |
|
| 370 | + return apply_filters('simcal_calendar_title', $title); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
@@ -389,16 +389,16 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | protected function set_taxonomies() { |
| 391 | 391 | // Set calendar type. |
| 392 | - if ( $type = wp_get_object_terms( $this->id, 'calendar_type' ) ) { |
|
| 393 | - $this->type = sanitize_title( current( $type )->name ); |
|
| 392 | + if ($type = wp_get_object_terms($this->id, 'calendar_type')) { |
|
| 393 | + $this->type = sanitize_title(current($type)->name); |
|
| 394 | 394 | } else { |
| 395 | - $this->type = apply_filters( 'simcal_calendar_default_type', 'default-calendar' ); |
|
| 395 | + $this->type = apply_filters('simcal_calendar_default_type', 'default-calendar'); |
|
| 396 | 396 | } |
| 397 | 397 | // Set feed type. |
| 398 | - if ( $feed_type = wp_get_object_terms( $this->id, 'calendar_feed' ) ) { |
|
| 399 | - $this->feed = sanitize_title( current( $feed_type )->name ); |
|
| 398 | + if ($feed_type = wp_get_object_terms($this->id, 'calendar_feed')) { |
|
| 399 | + $this->feed = sanitize_title(current($feed_type)->name); |
|
| 400 | 400 | } else { |
| 401 | - $this->feed = apply_filters( 'simcal_calendar_default_feed', 'google' ); |
|
| 401 | + $this->feed = apply_filters('simcal_calendar_default_feed', 'google'); |
|
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | * @return Events |
| 411 | 411 | */ |
| 412 | 412 | public function get_events() { |
| 413 | - return new Events( $this->events, $this->timezone ); |
|
| 413 | + return new Events($this->events, $this->timezone); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /** |
@@ -420,14 +420,14 @@ discard block |
||
| 420 | 420 | * |
| 421 | 421 | * @param array $array |
| 422 | 422 | */ |
| 423 | - public function set_events( array $array ) { |
|
| 423 | + public function set_events(array $array) { |
|
| 424 | 424 | |
| 425 | 425 | $events = array(); |
| 426 | 426 | |
| 427 | - if ( ! empty( $array ) ) { |
|
| 428 | - foreach ( $array as $tz => $e ) { |
|
| 429 | - foreach ( $e as $event ) { |
|
| 430 | - $events[ $tz ][] = $event instanceof Event ? $event : new Event( $event ); |
|
| 427 | + if ( ! empty($array)) { |
|
| 428 | + foreach ($array as $tz => $e) { |
|
| 429 | + foreach ($e as $event) { |
|
| 430 | + $events[$tz][] = $event instanceof Event ? $event : new Event($event); |
|
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | 433 | } |
@@ -444,24 +444,24 @@ discard block |
||
| 444 | 444 | * |
| 445 | 445 | * @return string |
| 446 | 446 | */ |
| 447 | - public function set_events_template( $template = '' ) { |
|
| 448 | - if ( empty( $template ) ) { |
|
| 449 | - $template = isset( $this->post->post_content ) ? $this->post->post_content : ''; |
|
| 447 | + public function set_events_template($template = '') { |
|
| 448 | + if (empty($template)) { |
|
| 449 | + $template = isset($this->post->post_content) ? $this->post->post_content : ''; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | // TODO: Removed wpautop() call. |
| 453 | 453 | |
| 454 | - $event_formatting = get_post_meta( $this->id, '_event_formatting', true ); |
|
| 454 | + $event_formatting = get_post_meta($this->id, '_event_formatting', true); |
|
| 455 | 455 | |
| 456 | - switch( $event_formatting ) { |
|
| 456 | + switch ($event_formatting) { |
|
| 457 | 457 | case 'none': |
| 458 | - $this->events_template = wp_kses_post( trim( $template ) ); |
|
| 458 | + $this->events_template = wp_kses_post(trim($template)); |
|
| 459 | 459 | break; |
| 460 | 460 | case 'no_linebreaks': |
| 461 | - $this->events_template = wpautop( wp_kses_post( trim( $template ) ), false ); |
|
| 461 | + $this->events_template = wpautop(wp_kses_post(trim($template)), false); |
|
| 462 | 462 | break; |
| 463 | 463 | default: |
| 464 | - $this->events_template = wpautop( wp_kses_post( trim( $template ) ), true ); |
|
| 464 | + $this->events_template = wpautop(wp_kses_post(trim($template)), true); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | //$this->events_template = wpautop( wp_kses_post( trim( $template ) ), true ); |
@@ -474,37 +474,37 @@ discard block |
||
| 474 | 474 | * |
| 475 | 475 | * @param string $tz Timezone. |
| 476 | 476 | */ |
| 477 | - public function set_timezone( $tz = '' ) { |
|
| 477 | + public function set_timezone($tz = '') { |
|
| 478 | 478 | |
| 479 | - $site_tz = esc_attr( simcal_get_wp_timezone() ); |
|
| 479 | + $site_tz = esc_attr(simcal_get_wp_timezone()); |
|
| 480 | 480 | |
| 481 | - if ( $this->feed === 'grouped-calendars' ) { |
|
| 481 | + if ($this->feed === 'grouped-calendars') { |
|
| 482 | 482 | $this->timezone = $site_tz; |
| 483 | 483 | return; |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | - if ( empty( $tz ) ) { |
|
| 486 | + if (empty($tz)) { |
|
| 487 | 487 | |
| 488 | - $timezone_setting = get_post_meta( $this->id, '_feed_timezone_setting', true ); |
|
| 488 | + $timezone_setting = get_post_meta($this->id, '_feed_timezone_setting', true); |
|
| 489 | 489 | |
| 490 | - if ( 'use_site' == $timezone_setting ) { |
|
| 490 | + if ('use_site' == $timezone_setting) { |
|
| 491 | 491 | $tz = $site_tz; |
| 492 | - } elseif ( 'use_custom' == $timezone_setting ) { |
|
| 493 | - $custom_timezone = esc_attr( get_post_meta( $this->id, '_feed_timezone', true ) ); |
|
| 492 | + } elseif ('use_custom' == $timezone_setting) { |
|
| 493 | + $custom_timezone = esc_attr(get_post_meta($this->id, '_feed_timezone', true)); |
|
| 494 | 494 | // One may be using a non standard timezone in GMT (UTC) offset format. |
| 495 | - if ( ( strpos( $custom_timezone, 'UTC+' ) === 0 ) || ( strpos( $custom_timezone, 'UTC-' ) === 0 ) ) { |
|
| 496 | - $tz = simcal_get_timezone_from_gmt_offset( substr( $custom_timezone, 3 ) ); |
|
| 495 | + if ((strpos($custom_timezone, 'UTC+') === 0) || (strpos($custom_timezone, 'UTC-') === 0)) { |
|
| 496 | + $tz = simcal_get_timezone_from_gmt_offset(substr($custom_timezone, 3)); |
|
| 497 | 497 | } else { |
| 498 | - $tz = ! empty( $custom_timezone ) ? $custom_timezone : 'UTC'; |
|
| 498 | + $tz = ! empty($custom_timezone) ? $custom_timezone : 'UTC'; |
|
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - $this->timezone = empty( $tz ) ? 'UTC' : $tz; |
|
| 502 | + $this->timezone = empty($tz) ? 'UTC' : $tz; |
|
| 503 | 503 | return; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | $this->site_timezone = $site_tz; |
| 507 | - $this->timezone = simcal_esc_timezone( $tz, $this->timezone ); |
|
| 507 | + $this->timezone = simcal_esc_timezone($tz, $this->timezone); |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | /** |
@@ -514,20 +514,20 @@ discard block |
||
| 514 | 514 | * |
| 515 | 515 | * @param string $format PHP datetime format. |
| 516 | 516 | */ |
| 517 | - public function set_date_format( $format = '' ) { |
|
| 517 | + public function set_date_format($format = '') { |
|
| 518 | 518 | |
| 519 | 519 | $date_format_custom = $date_format_default = $format; |
| 520 | 520 | |
| 521 | - if ( empty( $date_format_custom ) ) { |
|
| 521 | + if (empty($date_format_custom)) { |
|
| 522 | 522 | |
| 523 | - $date_format_option = esc_attr( get_post_meta( $this->id, '_calendar_date_format_setting', true ) ); |
|
| 524 | - $date_format_default = esc_attr( get_option( 'date_format' ) ); |
|
| 523 | + $date_format_option = esc_attr(get_post_meta($this->id, '_calendar_date_format_setting', true)); |
|
| 524 | + $date_format_default = esc_attr(get_option('date_format')); |
|
| 525 | 525 | $date_format_custom = ''; |
| 526 | 526 | |
| 527 | - if ( 'use_custom' == $date_format_option ) { |
|
| 528 | - $date_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_date_format', true ) ); |
|
| 529 | - } elseif ( 'use_custom_php' == $date_format_option ) { |
|
| 530 | - $date_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_date_format_php', true ) ); |
|
| 527 | + if ('use_custom' == $date_format_option) { |
|
| 528 | + $date_format_custom = esc_attr(get_post_meta($this->id, '_calendar_date_format', true)); |
|
| 529 | + } elseif ('use_custom_php' == $date_format_option) { |
|
| 530 | + $date_format_custom = esc_attr(get_post_meta($this->id, '_calendar_date_format_php', true)); |
|
| 531 | 531 | } |
| 532 | 532 | } |
| 533 | 533 | |
@@ -541,20 +541,20 @@ discard block |
||
| 541 | 541 | * |
| 542 | 542 | * @param string $format PHP datetime format. |
| 543 | 543 | */ |
| 544 | - public function set_time_format( $format = '' ) { |
|
| 544 | + public function set_time_format($format = '') { |
|
| 545 | 545 | |
| 546 | 546 | $time_format_custom = $time_format_default = $format; |
| 547 | 547 | |
| 548 | - if ( empty( $time_format_custom ) ) { |
|
| 548 | + if (empty($time_format_custom)) { |
|
| 549 | 549 | |
| 550 | - $time_format_option = esc_attr( get_post_meta( $this->id, '_calendar_time_format_setting', true ) ); |
|
| 551 | - $time_format_default = esc_attr( get_option( 'time_format' ) ); |
|
| 550 | + $time_format_option = esc_attr(get_post_meta($this->id, '_calendar_time_format_setting', true)); |
|
| 551 | + $time_format_default = esc_attr(get_option('time_format')); |
|
| 552 | 552 | $time_format_custom = ''; |
| 553 | 553 | |
| 554 | - if ( 'use_custom' == $time_format_option ) { |
|
| 555 | - $time_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_time_format', true ) ); |
|
| 556 | - } elseif ( 'use_custom_php' == $time_format_option ) { |
|
| 557 | - $time_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_time_format_php', true ) ); |
|
| 554 | + if ('use_custom' == $time_format_option) { |
|
| 555 | + $time_format_custom = esc_attr(get_post_meta($this->id, '_calendar_time_format', true)); |
|
| 556 | + } elseif ('use_custom_php' == $time_format_option) { |
|
| 557 | + $time_format_custom = esc_attr(get_post_meta($this->id, '_calendar_time_format_php', true)); |
|
| 558 | 558 | } |
| 559 | 559 | } |
| 560 | 560 | |
@@ -568,13 +568,13 @@ discard block |
||
| 568 | 568 | * |
| 569 | 569 | * @param string $separator A UTF8 character used as separator. |
| 570 | 570 | */ |
| 571 | - public function set_datetime_separator( $separator = '' ) { |
|
| 571 | + public function set_datetime_separator($separator = '') { |
|
| 572 | 572 | |
| 573 | - if ( empty( $separator ) ) { |
|
| 574 | - $separator = get_post_meta( $this->id, '_calendar_datetime_separator', true ); |
|
| 573 | + if (empty($separator)) { |
|
| 574 | + $separator = get_post_meta($this->id, '_calendar_datetime_separator', true); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | - $this->datetime_separator = esc_attr( $separator ); |
|
| 577 | + $this->datetime_separator = esc_attr($separator); |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | /** |
@@ -584,18 +584,18 @@ discard block |
||
| 584 | 584 | * |
| 585 | 585 | * @param int $weekday From 0 (Sunday) to 6 (Friday). |
| 586 | 586 | */ |
| 587 | - public function set_start_of_week( $weekday = -1 ) { |
|
| 587 | + public function set_start_of_week($weekday = -1) { |
|
| 588 | 588 | |
| 589 | - $week_starts = is_int( $weekday ) ? $weekday : -1; |
|
| 589 | + $week_starts = is_int($weekday) ? $weekday : -1; |
|
| 590 | 590 | |
| 591 | - if ( $week_starts < 0 || $week_starts > 6 ) { |
|
| 591 | + if ($week_starts < 0 || $week_starts > 6) { |
|
| 592 | 592 | |
| 593 | - $week_starts_setting = get_post_meta( $this->id, '_calendar_week_starts_on_setting', true ); |
|
| 594 | - $week_starts = intval( get_option( 'start_of_week' ) ); |
|
| 593 | + $week_starts_setting = get_post_meta($this->id, '_calendar_week_starts_on_setting', true); |
|
| 594 | + $week_starts = intval(get_option('start_of_week')); |
|
| 595 | 595 | |
| 596 | - if ( 'use_custom' == $week_starts_setting ) { |
|
| 597 | - $week_starts_on = get_post_meta( $this->id, '_calendar_week_starts_on', true ); |
|
| 598 | - $week_starts = is_numeric( $week_starts_on ) ? intval( $week_starts_on ) : $week_starts; |
|
| 596 | + if ('use_custom' == $week_starts_setting) { |
|
| 597 | + $week_starts_on = get_post_meta($this->id, '_calendar_week_starts_on', true); |
|
| 598 | + $week_starts = is_numeric($week_starts_on) ? intval($week_starts_on) : $week_starts; |
|
| 599 | 599 | } |
| 600 | 600 | } |
| 601 | 601 | |
@@ -609,51 +609,51 @@ discard block |
||
| 609 | 609 | * |
| 610 | 610 | * @param int $timestamp |
| 611 | 611 | */ |
| 612 | - public function set_start( $timestamp = 0 ) { |
|
| 612 | + public function set_start($timestamp = 0) { |
|
| 613 | 613 | |
| 614 | - if ( is_int( $timestamp ) && $timestamp !== 0 ) { |
|
| 614 | + if (is_int($timestamp) && $timestamp !== 0) { |
|
| 615 | 615 | $this->start = $timestamp; |
| 616 | 616 | return; |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | - $this->start = Carbon::now( $this->timezone )->getTimestamp(); |
|
| 619 | + $this->start = Carbon::now($this->timezone)->getTimestamp(); |
|
| 620 | 620 | |
| 621 | - $calendar_begins = esc_attr( get_post_meta( $this->id, '_calendar_begins', true ) ); |
|
| 622 | - $nth = max( absint( get_post_meta( $this->id, '_calendar_begins_nth', true ) ), 1 ); |
|
| 621 | + $calendar_begins = esc_attr(get_post_meta($this->id, '_calendar_begins', true)); |
|
| 622 | + $nth = max(absint(get_post_meta($this->id, '_calendar_begins_nth', true)), 1); |
|
| 623 | 623 | |
| 624 | - if ( 'today' == $calendar_begins ) { |
|
| 625 | - $this->start = Carbon::today( $this->timezone )->getTimestamp(); |
|
| 626 | - } elseif ( 'days_before' == $calendar_begins ) { |
|
| 627 | - $this->start = Carbon::today( $this->timezone )->subDays( $nth )->getTimestamp(); |
|
| 628 | - } elseif ( 'days_after' == $calendar_begins ) { |
|
| 629 | - $this->start = Carbon::today( $this->timezone )->addDays( $nth )->getTimestamp(); |
|
| 630 | - } elseif ( 'this_week' == $calendar_begins ) { |
|
| 631 | - $week = new Carbon( 'now', $this->timezone ); |
|
| 632 | - $week->setWeekStartsAt( $this->week_starts ); |
|
| 624 | + if ('today' == $calendar_begins) { |
|
| 625 | + $this->start = Carbon::today($this->timezone)->getTimestamp(); |
|
| 626 | + } elseif ('days_before' == $calendar_begins) { |
|
| 627 | + $this->start = Carbon::today($this->timezone)->subDays($nth)->getTimestamp(); |
|
| 628 | + } elseif ('days_after' == $calendar_begins) { |
|
| 629 | + $this->start = Carbon::today($this->timezone)->addDays($nth)->getTimestamp(); |
|
| 630 | + } elseif ('this_week' == $calendar_begins) { |
|
| 631 | + $week = new Carbon('now', $this->timezone); |
|
| 632 | + $week->setWeekStartsAt($this->week_starts); |
|
| 633 | 633 | $this->start = $week->startOfWeek()->getTimestamp(); |
| 634 | - } elseif ( 'weeks_before' == $calendar_begins ) { |
|
| 635 | - $week = new Carbon( 'now', $this->timezone ); |
|
| 636 | - $week->setWeekStartsAt( $this->week_starts ); |
|
| 637 | - $this->start = $week->startOfWeek()->subWeeks( $nth )->getTimestamp(); |
|
| 638 | - } elseif ( 'weeks_after' == $calendar_begins ) { |
|
| 639 | - $week = new Carbon( 'now', $this->timezone ); |
|
| 640 | - $week->setWeekStartsAt( $this->week_starts ); |
|
| 641 | - $this->start = $week->startOfWeek()->addWeeks( $nth )->getTimestamp(); |
|
| 642 | - } elseif ( 'this_month' == $calendar_begins ) { |
|
| 643 | - $this->start = Carbon::today( $this->timezone )->startOfMonth()->getTimeStamp(); |
|
| 644 | - } elseif ( 'months_before' == $calendar_begins ) { |
|
| 645 | - $this->start = Carbon::today( $this->timezone )->subMonths( $nth )->startOfMonth()->getTimeStamp(); |
|
| 646 | - } elseif ( 'months_after' == $calendar_begins ) { |
|
| 647 | - $this->start = Carbon::today( $this->timezone )->addMonths( $nth )->startOfMonth()->getTimeStamp(); |
|
| 648 | - } elseif ( 'this_year' == $calendar_begins ) { |
|
| 649 | - $this->start = Carbon::today( $this->timezone )->startOfYear()->getTimestamp(); |
|
| 650 | - } elseif ( 'years_before' == $calendar_begins ) { |
|
| 651 | - $this->start = Carbon::today( $this->timezone )->subYears( $nth )->startOfYear()->getTimeStamp(); |
|
| 652 | - } elseif ( 'years_after' == $calendar_begins ) { |
|
| 653 | - $this->start = Carbon::today( $this->timezone )->addYears( $nth )->startOfYear()->getTimeStamp(); |
|
| 654 | - } elseif ( 'custom_date' == $calendar_begins ) { |
|
| 655 | - if ( $date = get_post_meta( $this->id, '_calendar_begins_custom_date', true ) ) { |
|
| 656 | - $this->start = Carbon::createFromFormat( 'Y-m-d', esc_attr( $date ), $this->timezone )->setTimezone( $this->timezone )->startOfDay()->getTimestamp(); |
|
| 634 | + } elseif ('weeks_before' == $calendar_begins) { |
|
| 635 | + $week = new Carbon('now', $this->timezone); |
|
| 636 | + $week->setWeekStartsAt($this->week_starts); |
|
| 637 | + $this->start = $week->startOfWeek()->subWeeks($nth)->getTimestamp(); |
|
| 638 | + } elseif ('weeks_after' == $calendar_begins) { |
|
| 639 | + $week = new Carbon('now', $this->timezone); |
|
| 640 | + $week->setWeekStartsAt($this->week_starts); |
|
| 641 | + $this->start = $week->startOfWeek()->addWeeks($nth)->getTimestamp(); |
|
| 642 | + } elseif ('this_month' == $calendar_begins) { |
|
| 643 | + $this->start = Carbon::today($this->timezone)->startOfMonth()->getTimeStamp(); |
|
| 644 | + } elseif ('months_before' == $calendar_begins) { |
|
| 645 | + $this->start = Carbon::today($this->timezone)->subMonths($nth)->startOfMonth()->getTimeStamp(); |
|
| 646 | + } elseif ('months_after' == $calendar_begins) { |
|
| 647 | + $this->start = Carbon::today($this->timezone)->addMonths($nth)->startOfMonth()->getTimeStamp(); |
|
| 648 | + } elseif ('this_year' == $calendar_begins) { |
|
| 649 | + $this->start = Carbon::today($this->timezone)->startOfYear()->getTimestamp(); |
|
| 650 | + } elseif ('years_before' == $calendar_begins) { |
|
| 651 | + $this->start = Carbon::today($this->timezone)->subYears($nth)->startOfYear()->getTimeStamp(); |
|
| 652 | + } elseif ('years_after' == $calendar_begins) { |
|
| 653 | + $this->start = Carbon::today($this->timezone)->addYears($nth)->startOfYear()->getTimeStamp(); |
|
| 654 | + } elseif ('custom_date' == $calendar_begins) { |
|
| 655 | + if ($date = get_post_meta($this->id, '_calendar_begins_custom_date', true)) { |
|
| 656 | + $this->start = Carbon::createFromFormat('Y-m-d', esc_attr($date), $this->timezone)->setTimezone($this->timezone)->startOfDay()->getTimestamp(); |
|
| 657 | 657 | } |
| 658 | 658 | } |
| 659 | 659 | } |
@@ -665,8 +665,8 @@ discard block |
||
| 665 | 665 | * |
| 666 | 666 | * @param int $timestamp |
| 667 | 667 | */ |
| 668 | - public function set_end( $timestamp = 0 ) { |
|
| 669 | - $latest = is_int( $timestamp ) && $timestamp !== 0 ? $timestamp : $this->latest_event; |
|
| 668 | + public function set_end($timestamp = 0) { |
|
| 669 | + $latest = is_int($timestamp) && $timestamp !== 0 ? $timestamp : $this->latest_event; |
|
| 670 | 670 | $this->end = $latest > $this->start ? $latest : $this->start; |
| 671 | 671 | } |
| 672 | 672 | |
@@ -677,14 +677,14 @@ discard block |
||
| 677 | 677 | * |
| 678 | 678 | * @param string|bool $static |
| 679 | 679 | */ |
| 680 | - public function set_static( $static = '' ) { |
|
| 680 | + public function set_static($static = '') { |
|
| 681 | 681 | |
| 682 | - if ( ! empty( $static ) && is_bool( $static ) ) { |
|
| 682 | + if ( ! empty($static) && is_bool($static)) { |
|
| 683 | 683 | $this->static = $static; |
| 684 | 684 | return; |
| 685 | 685 | } |
| 686 | 686 | |
| 687 | - if ( 'yes' == get_post_meta( $this->id, '_calendar_is_static', true ) ) { |
|
| 687 | + if ('yes' == get_post_meta($this->id, '_calendar_is_static', true)) { |
|
| 688 | 688 | $this->static = true; |
| 689 | 689 | return; |
| 690 | 690 | } |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | * |
| 713 | 713 | * @return Calendar_View |
| 714 | 714 | */ |
| 715 | - abstract public function get_view( $view = '' ); |
|
| 715 | + abstract public function get_view($view = ''); |
|
| 716 | 716 | |
| 717 | 717 | /** |
| 718 | 718 | * Get event HTML parsed by template. |
@@ -724,11 +724,11 @@ discard block |
||
| 724 | 724 | * |
| 725 | 725 | * @return string |
| 726 | 726 | */ |
| 727 | - public function get_event_html( Event $event, $template = '' ) { |
|
| 728 | - $event_builder = new Event_Builder( $event, $this ); |
|
| 727 | + public function get_event_html(Event $event, $template = '') { |
|
| 728 | + $event_builder = new Event_Builder($event, $this); |
|
| 729 | 729 | // Use the event template to parse tags; if empty, fallback to calendar post content. |
| 730 | - $template = empty( $template ) ? ( empty( $event->template ) ? $this->events_template : $event->template ) : $template; |
|
| 731 | - return $event_builder->parse_event_template_tags( $template ); |
|
| 730 | + $template = empty($template) ? (empty($event->template) ? $this->events_template : $event->template) : $template; |
|
| 731 | + return $event_builder->parse_event_template_tags($template); |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | /** |
@@ -738,58 +738,58 @@ discard block |
||
| 738 | 738 | * |
| 739 | 739 | * @param string $view The calendar view to display. |
| 740 | 740 | */ |
| 741 | - public function html( $view = '' ) { |
|
| 741 | + public function html($view = '') { |
|
| 742 | 742 | |
| 743 | - $view = empty( $view ) ? $this->view : $this->get_view( $view ); |
|
| 743 | + $view = empty($view) ? $this->view : $this->get_view($view); |
|
| 744 | 744 | |
| 745 | - if ( $view instanceof Calendar_View ) { |
|
| 745 | + if ($view instanceof Calendar_View) { |
|
| 746 | 746 | |
| 747 | - if ( ! empty( $this->errors ) ) { |
|
| 747 | + if ( ! empty($this->errors)) { |
|
| 748 | 748 | |
| 749 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 749 | + if (current_user_can('manage_options')) { |
|
| 750 | 750 | echo '<pre><code>'; |
| 751 | - foreach ( $this->errors as $error ) { echo $error; } |
|
| 751 | + foreach ($this->errors as $error) { echo $error; } |
|
| 752 | 752 | echo '</code></pre>'; |
| 753 | 753 | } |
| 754 | 754 | |
| 755 | 755 | } else { |
| 756 | 756 | |
| 757 | 757 | // Get a CSS class from the class name of the calendar view (minus namespace part). |
| 758 | - $view_name = implode( '-', array_map( 'lcfirst', explode( '_', strtolower( get_class( $view ) ) ) ) ); |
|
| 759 | - $view_class = substr( $view_name, strrpos( $view_name, '\\' ) + 1 ); |
|
| 758 | + $view_name = implode('-', array_map('lcfirst', explode('_', strtolower(get_class($view))))); |
|
| 759 | + $view_class = substr($view_name, strrpos($view_name, '\\') + 1); |
|
| 760 | 760 | |
| 761 | - $calendar_class = trim( implode( ' simcal-', apply_filters( 'simcal_calendar_class', array( |
|
| 761 | + $calendar_class = trim(implode(' simcal-', apply_filters('simcal_calendar_class', array( |
|
| 762 | 762 | 'simcal-calendar', |
| 763 | 763 | $this->type, |
| 764 | 764 | $view_class, |
| 765 | - ), $this->id ) ) ); |
|
| 766 | - |
|
| 767 | - echo '<div class="' . $calendar_class . '" ' |
|
| 768 | - . 'data-calendar-id="' . $this->id . '" ' |
|
| 769 | - . 'data-timezone="' . $this->timezone . '" ' |
|
| 770 | - . 'data-offset="' . $this->offset . '" ' |
|
| 771 | - . 'data-week-start="' . $this->week_starts . '" ' |
|
| 772 | - . 'data-calendar-start="' . $this->start .'" ' |
|
| 773 | - . 'data-calendar-end="' . $this->end . '" ' |
|
| 774 | - . 'data-events-first="' . $this->earliest_event .'" ' |
|
| 775 | - . 'data-events-last="' . $this->latest_event . '"' |
|
| 765 | + ), $this->id))); |
|
| 766 | + |
|
| 767 | + echo '<div class="'.$calendar_class.'" ' |
|
| 768 | + . 'data-calendar-id="'.$this->id.'" ' |
|
| 769 | + . 'data-timezone="'.$this->timezone.'" ' |
|
| 770 | + . 'data-offset="'.$this->offset.'" ' |
|
| 771 | + . 'data-week-start="'.$this->week_starts.'" ' |
|
| 772 | + . 'data-calendar-start="'.$this->start.'" ' |
|
| 773 | + . 'data-calendar-end="'.$this->end.'" ' |
|
| 774 | + . 'data-events-first="'.$this->earliest_event.'" ' |
|
| 775 | + . 'data-events-last="'.$this->latest_event.'"' |
|
| 776 | 776 | . '>'; |
| 777 | 777 | |
| 778 | - date_default_timezone_set( $this->timezone ); |
|
| 779 | - do_action( 'simcal_calendar_html_before', $this->id ); |
|
| 778 | + date_default_timezone_set($this->timezone); |
|
| 779 | + do_action('simcal_calendar_html_before', $this->id); |
|
| 780 | 780 | |
| 781 | 781 | $view->html(); |
| 782 | 782 | |
| 783 | - do_action( 'simcal_calendar_html_after', $this->id ); |
|
| 784 | - date_default_timezone_set( $this->site_timezone ); |
|
| 783 | + do_action('simcal_calendar_html_after', $this->id); |
|
| 784 | + date_default_timezone_set($this->site_timezone); |
|
| 785 | 785 | |
| 786 | 786 | //$settings = get_option( 'simple-calendar_settings_calendars' ); |
| 787 | - $poweredby = get_post_meta( $this->id, '_poweredby', true ); |
|
| 787 | + $poweredby = get_post_meta($this->id, '_poweredby', true); |
|
| 788 | 788 | |
| 789 | - if ( 'yes' == $poweredby ) { |
|
| 789 | + if ('yes' == $poweredby) { |
|
| 790 | 790 | $align = is_rtl() ? 'left' : 'right'; |
| 791 | - echo '<small class="simcal-powered simcal-align-' . $align .'">' . |
|
| 792 | - sprintf( __( 'Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events' ), simcal_get_url( 'home' ) ) . |
|
| 791 | + echo '<small class="simcal-powered simcal-align-'.$align.'">'. |
|
| 792 | + sprintf(__('Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events'), simcal_get_url('home')). |
|
| 793 | 793 | '</small>'; |
| 794 | 794 | } |
| 795 | 795 | |