@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | */ |
| 7 | 7 | namespace SimpleCalendar\Admin; |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if ( ! defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function __construct() { |
| 36 | 36 | |
| 37 | - $this->min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG == true ) ? '' : '.min'; |
|
| 37 | + $this->min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG == true) ? '' : '.min'; |
|
| 38 | 38 | |
| 39 | - add_action( 'admin_enqueue_scripts', array( $this, 'load' ) ); |
|
| 39 | + add_action('admin_enqueue_scripts', array($this, 'load')); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function load() { |
| 48 | 48 | |
| 49 | - $css_path = SIMPLE_CALENDAR_ASSETS . 'css/'; |
|
| 50 | - $css_path_vendor = $css_path . 'vendor/'; |
|
| 51 | - $js_path = SIMPLE_CALENDAR_ASSETS . 'js/'; |
|
| 52 | - $js_path_vendor = $js_path . 'vendor/'; |
|
| 49 | + $css_path = SIMPLE_CALENDAR_ASSETS.'css/'; |
|
| 50 | + $css_path_vendor = $css_path.'vendor/'; |
|
| 51 | + $js_path = SIMPLE_CALENDAR_ASSETS.'js/'; |
|
| 52 | + $js_path_vendor = $js_path.'vendor/'; |
|
| 53 | 53 | |
| 54 | 54 | /* ====================== * |
| 55 | 55 | * Register Admin Scripts * |
@@ -58,21 +58,21 @@ discard block |
||
| 58 | 58 | // TipTip uses ".minified.js" filename ending. |
| 59 | 59 | wp_register_script( |
| 60 | 60 | 'simcal-tiptip', |
| 61 | - $js_path_vendor . 'jquery.tipTip' . ( ( $this->min !== '' ) ? '.minified' : '' ) . '.js', |
|
| 62 | - array( 'jquery' ), |
|
| 61 | + $js_path_vendor.'jquery.tipTip'.(($this->min !== '') ? '.minified' : '').'.js', |
|
| 62 | + array('jquery'), |
|
| 63 | 63 | '1.3', |
| 64 | 64 | true |
| 65 | 65 | ); |
| 66 | 66 | wp_register_script( |
| 67 | 67 | 'simcal-select2', |
| 68 | - $js_path_vendor . 'select2' . $this->min . '.js', |
|
| 68 | + $js_path_vendor.'select2'.$this->min.'.js', |
|
| 69 | 69 | array(), |
| 70 | 70 | '4.0', |
| 71 | 71 | true |
| 72 | 72 | ); |
| 73 | 73 | wp_register_script( |
| 74 | 74 | 'simcal-admin', |
| 75 | - $js_path . 'admin' . $this->min . '.js', |
|
| 75 | + $js_path.'admin'.$this->min.'.js', |
|
| 76 | 76 | array( |
| 77 | 77 | 'jquery', |
| 78 | 78 | 'jquery-ui-sortable', |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | ); |
| 87 | 87 | wp_register_script( |
| 88 | 88 | 'simcal-admin-add-calendar', |
| 89 | - $js_path . 'admin-add-calendar' . $this->min . '.js', |
|
| 90 | - array( 'simcal-select2' ), |
|
| 89 | + $js_path.'admin-add-calendar'.$this->min.'.js', |
|
| 90 | + array('simcal-select2'), |
|
| 91 | 91 | SIMPLE_CALENDAR_VERSION, |
| 92 | 92 | true |
| 93 | 93 | ); |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | wp_register_style( |
| 100 | 100 | 'simcal-select2', |
| 101 | - $css_path_vendor . 'select2' . $this->min . '.css', |
|
| 101 | + $css_path_vendor.'select2'.$this->min.'.css', |
|
| 102 | 102 | array(), |
| 103 | 103 | '4.0.0' |
| 104 | 104 | ); |
| 105 | 105 | wp_register_style( |
| 106 | 106 | 'simcal-admin', |
| 107 | - $css_path . 'admin' . $this->min . '.css', |
|
| 107 | + $css_path.'admin'.$this->min.'.css', |
|
| 108 | 108 | array( |
| 109 | 109 | 'wp-color-picker', |
| 110 | 110 | 'simcal-select2', |
@@ -113,21 +113,21 @@ discard block |
||
| 113 | 113 | ); |
| 114 | 114 | wp_register_style( |
| 115 | 115 | 'simcal-admin-add-calendar', |
| 116 | - $css_path . 'admin-add-calendar' . $this->min . '.css', |
|
| 117 | - array( 'simcal-select2' ), |
|
| 116 | + $css_path.'admin-add-calendar'.$this->min.'.css', |
|
| 117 | + array('simcal-select2'), |
|
| 118 | 118 | SIMPLE_CALENDAR_VERSION |
| 119 | 119 | ); |
| 120 | 120 | |
| 121 | - if ( simcal_is_admin_screen() !== false ) { |
|
| 121 | + if (simcal_is_admin_screen() !== false) { |
|
| 122 | 122 | |
| 123 | - wp_enqueue_script( 'simcal-admin' ); |
|
| 123 | + wp_enqueue_script('simcal-admin'); |
|
| 124 | 124 | wp_localize_script( |
| 125 | 125 | 'simcal-admin', |
| 126 | 126 | 'simcal_admin', |
| 127 | 127 | simcal_common_scripts_variables() |
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | - wp_enqueue_style( 'simcal-admin' ); |
|
| 130 | + wp_enqueue_style('simcal-admin'); |
|
| 131 | 131 | |
| 132 | 132 | } else { |
| 133 | 133 | |
@@ -135,25 +135,25 @@ discard block |
||
| 135 | 135 | $screen = get_current_screen(); |
| 136 | 136 | |
| 137 | 137 | $post_types = array(); |
| 138 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
| 139 | - if ( isset( $settings['general']['attach_calendars_posts'] ) ) { |
|
| 138 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
| 139 | + if (isset($settings['general']['attach_calendars_posts'])) { |
|
| 140 | 140 | $post_types = $settings['general']['attach_calendars_posts']; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | $conditions = array( |
| 144 | - in_array( $post_type, (array) $post_types ), |
|
| 144 | + in_array($post_type, (array) $post_types), |
|
| 145 | 145 | $screen->id == 'widgets', |
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | - if ( in_array( true, $conditions ) ) { |
|
| 148 | + if (in_array(true, $conditions)) { |
|
| 149 | 149 | |
| 150 | - wp_enqueue_script( 'simcal-admin-add-calendar' ); |
|
| 151 | - wp_localize_script( 'simcal-admin-add-calendar', 'simcal_admin', array( |
|
| 150 | + wp_enqueue_script('simcal-admin-add-calendar'); |
|
| 151 | + wp_localize_script('simcal-admin-add-calendar', 'simcal_admin', array( |
|
| 152 | 152 | 'locale' => get_locale(), |
| 153 | 153 | 'text_dir' => is_rtl() ? 'rtl' : 'ltr', |
| 154 | - ) ); |
|
| 154 | + )); |
|
| 155 | 155 | |
| 156 | - wp_enqueue_style( 'simcal-admin-add-calendar' ); |
|
| 156 | + wp_enqueue_style('simcal-admin-add-calendar'); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Abstracts\Field; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -51,32 +51,32 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @param array $field |
| 53 | 53 | */ |
| 54 | - public function __construct( $field ) { |
|
| 54 | + public function __construct($field) { |
|
| 55 | 55 | |
| 56 | 56 | $class = 'simcal-field-select'; |
| 57 | 57 | |
| 58 | - $enhanced = isset( $field['enhanced'] ) ? $field['enhanced'] : ''; |
|
| 59 | - if ( 'enhanced' == $enhanced ) { |
|
| 58 | + $enhanced = isset($field['enhanced']) ? $field['enhanced'] : ''; |
|
| 59 | + if ('enhanced' == $enhanced) { |
|
| 60 | 60 | $this->enhanced = true; |
| 61 | 61 | $class .= ' simcal-field-select-enhanced'; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $multiselect = isset( $field['multiselect'] ) ? $field['multiselect'] : ''; |
|
| 65 | - if ( 'multiselect' == $multiselect ) { |
|
| 64 | + $multiselect = isset($field['multiselect']) ? $field['multiselect'] : ''; |
|
| 65 | + if ('multiselect' == $multiselect) { |
|
| 66 | 66 | $this->multiselect = true; |
| 67 | 67 | $class .= ' simcal-field-multiselect'; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if ( isset( $field['default'] ) ) { |
|
| 70 | + if (isset($field['default'])) { |
|
| 71 | 71 | $this->default = $field['default']; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $this->type_class = $class; |
| 75 | 75 | |
| 76 | - $allow_void = isset( $field['allow_void'] ) ? $field['allow_void'] : ''; |
|
| 76 | + $allow_void = isset($field['allow_void']) ? $field['allow_void'] : ''; |
|
| 77 | 77 | $this->allow_void = 'allow_void' == $allow_void ? true : false; |
| 78 | 78 | |
| 79 | - parent::__construct( $field ); |
|
| 79 | + parent::__construct($field); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -86,36 +86,36 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function html() { |
| 88 | 88 | |
| 89 | - if ( $this->multiselect === true && ! is_array( $this->value ) ) { |
|
| 90 | - $this->value = explode( ',', $this->value ); |
|
| 89 | + if ($this->multiselect === true && ! is_array($this->value)) { |
|
| 90 | + $this->value = explode(',', $this->value); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if ( $this->default ) { |
|
| 94 | - if ( empty( $this->value ) || $this->value == '' ) { |
|
| 93 | + if ($this->default) { |
|
| 94 | + if (empty($this->value) || $this->value == '') { |
|
| 95 | 95 | $this->value = $this->default; |
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | ?> |
| 100 | - <select name="<?php echo $this->name; ?><?php if ( $this->multiselect === true ) { echo '[]'; } ?>" |
|
| 100 | + <select name="<?php echo $this->name; ?><?php if ($this->multiselect === true) { echo '[]'; } ?>" |
|
| 101 | 101 | id="<?php echo $this->id; ?>" |
| 102 | 102 | style="<?php echo $this->style; ?>" |
| 103 | 103 | class="<?php echo $this->class; ?>" |
| 104 | 104 | <?php echo $this->attributes; ?> |
| 105 | - <?php echo ( $this->multiselect === true ) ? ' multiple="multiple"' : ''; ?>> |
|
| 105 | + <?php echo ($this->multiselect === true) ? ' multiple="multiple"' : ''; ?>> |
|
| 106 | 106 | <?php |
| 107 | 107 | |
| 108 | - if ( $this->allow_void === true ) { |
|
| 109 | - echo '<option value=""' . selected( '', $this->value, false ) . '></option>'; |
|
| 108 | + if ($this->allow_void === true) { |
|
| 109 | + echo '<option value=""'.selected('', $this->value, false).'></option>'; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - foreach ( $this->options as $option => $name ) { |
|
| 113 | - if ( is_array( $this->value ) ) { |
|
| 114 | - $selected = selected( in_array( $option, $this->value ), true, false ); |
|
| 112 | + foreach ($this->options as $option => $name) { |
|
| 113 | + if (is_array($this->value)) { |
|
| 114 | + $selected = selected(in_array($option, $this->value), true, false); |
|
| 115 | 115 | } else { |
| 116 | - $selected = selected( $this->value, trim( strval( $option ) ), false ); |
|
| 116 | + $selected = selected($this->value, trim(strval($option)), false); |
|
| 117 | 117 | } |
| 118 | - echo '<option value="' . $option . '" ' . $selected . '>' . esc_attr( $name ) . '</option>'; |
|
| 118 | + echo '<option value="'.$option.'" '.$selected.'>'.esc_attr($name).'</option>'; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | ?> |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | echo $this->tooltip; |
| 126 | 126 | |
| 127 | - if ( ! empty( $this->description ) ) { |
|
| 128 | - echo '<p class="description">' . wp_kses_post( $this->description ) . '</p>'; |
|
| 127 | + if ( ! empty($this->description)) { |
|
| 128 | + echo '<p class="description">'.wp_kses_post($this->description).'</p>'; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @package SimpleCalendar/Functions |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if ( ! defined('ABSPATH')) { |
|
| 11 | 11 | exit; |
| 12 | 12 | } |
| 13 | 13 | |
@@ -20,17 +20,17 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | function is_simple_calendar() { |
| 22 | 22 | |
| 23 | - if ( is_singular() ) { |
|
| 23 | + if (is_singular()) { |
|
| 24 | 24 | |
| 25 | 25 | global $post, $post_type; |
| 26 | 26 | |
| 27 | - if ( 'calendar' == $post_type ) { |
|
| 27 | + if ('calendar' == $post_type) { |
|
| 28 | 28 | return true; |
| 29 | 29 | } else { |
| 30 | - if ( false !== get_post_meta( $post->ID, '_simcal_attach_calendar_id', true ) ) { |
|
| 30 | + if (false !== get_post_meta($post->ID, '_simcal_attach_calendar_id', true)) { |
|
| 31 | 31 | return true; |
| 32 | 32 | } |
| 33 | - if ( has_shortcode( $post->post_content, 'calendar' ) ) { |
|
| 33 | + if (has_shortcode($post->post_content, 'calendar')) { |
|
| 34 | 34 | return true; |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return string |
| 48 | 48 | */ |
| 49 | -function simcal_get_url( $url ) { |
|
| 50 | - return \SimpleCalendar\plugin()->get_url( $url ); |
|
| 49 | +function simcal_get_url($url) { |
|
| 50 | + return \SimpleCalendar\plugin()->get_url($url); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @return null|\SimpleCalendar\Abstracts\Feed |
| 73 | 73 | */ |
| 74 | -function simcal_get_feed( $object ) { |
|
| 74 | +function simcal_get_feed($object) { |
|
| 75 | 75 | $objects = \SimpleCalendar\plugin()->objects; |
| 76 | - return $objects instanceof \SimpleCalendar\Objects ? $objects->get_feed( $object ) : null; |
|
| 76 | + return $objects instanceof \SimpleCalendar\Objects ? $objects->get_feed($object) : null; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return null|\SimpleCalendar\Abstracts\Calendar |
| 99 | 99 | */ |
| 100 | -function simcal_get_calendar( $object ) { |
|
| 100 | +function simcal_get_calendar($object) { |
|
| 101 | 101 | $objects = \SimpleCalendar\plugin()->objects; |
| 102 | - return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar( $object ) : null; |
|
| 102 | + return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar($object) : null; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return mixed |
| 114 | 114 | */ |
| 115 | -function simcal_get_calendar_view( $id = 0, $name = '' ) { |
|
| 115 | +function simcal_get_calendar_view($id = 0, $name = '') { |
|
| 116 | 116 | $objects = \SimpleCalendar\plugin()->objects; |
| 117 | - return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar_view( $id, $name ) : false; |
|
| 117 | + return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar_view($id, $name) : false; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -126,11 +126,11 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @return void |
| 128 | 128 | */ |
| 129 | -function simcal_print_calendar( $object ) { |
|
| 129 | +function simcal_print_calendar($object) { |
|
| 130 | 130 | |
| 131 | - $calendar = simcal_get_calendar( $object ); |
|
| 131 | + $calendar = simcal_get_calendar($object); |
|
| 132 | 132 | |
| 133 | - if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) { |
|
| 133 | + if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) { |
|
| 134 | 134 | $calendar->html(); |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -148,21 +148,21 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | $vars = array( |
| 150 | 150 | 'ajax_url' => \SimpleCalendar\plugin()->ajax_url(), |
| 151 | - 'nonce' => wp_create_nonce( 'simcal' ), |
|
| 151 | + 'nonce' => wp_create_nonce('simcal'), |
|
| 152 | 152 | 'locale' => \SimpleCalendar\plugin()->locale, |
| 153 | 153 | 'text_dir' => is_rtl() ? 'rtl' : 'ltr', |
| 154 | 154 | 'months' => array( |
| 155 | - 'full' => simcal_get_calendar_names_i18n( 'month', 'full' ), |
|
| 156 | - 'short' => simcal_get_calendar_names_i18n( 'month', 'short' ), |
|
| 155 | + 'full' => simcal_get_calendar_names_i18n('month', 'full'), |
|
| 156 | + 'short' => simcal_get_calendar_names_i18n('month', 'short'), |
|
| 157 | 157 | ), |
| 158 | 158 | 'days' => array( |
| 159 | - 'full' => simcal_get_calendar_names_i18n( 'day', 'full' ), |
|
| 160 | - 'short' => simcal_get_calendar_names_i18n( 'day', 'short' ), |
|
| 159 | + 'full' => simcal_get_calendar_names_i18n('day', 'full'), |
|
| 160 | + 'short' => simcal_get_calendar_names_i18n('day', 'short'), |
|
| 161 | 161 | ), |
| 162 | - 'meridiem' => simcal_get_calendar_names_i18n( 'meridiem' ), |
|
| 162 | + 'meridiem' => simcal_get_calendar_names_i18n('meridiem'), |
|
| 163 | 163 | ); |
| 164 | 164 | |
| 165 | - return array_merge( $vars, apply_filters( 'simcal_common_scripts_variables', array() ) ); |
|
| 165 | + return array_merge($vars, apply_filters('simcal_common_scripts_variables', array())); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -175,31 +175,31 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @return array Associative array with ids as keys and feed titles as values. |
| 177 | 177 | */ |
| 178 | -function simcal_get_calendars( $exclude = '', $cached = true ) { |
|
| 178 | +function simcal_get_calendars($exclude = '', $cached = true) { |
|
| 179 | 179 | |
| 180 | - $calendars = get_transient( '_simple-calendar_feed_ids' ); |
|
| 180 | + $calendars = get_transient('_simple-calendar_feed_ids'); |
|
| 181 | 181 | |
| 182 | - if ( ! $calendars || $cached === false ) { |
|
| 182 | + if ( ! $calendars || $cached === false) { |
|
| 183 | 183 | |
| 184 | - $posts = get_posts( array( |
|
| 184 | + $posts = get_posts(array( |
|
| 185 | 185 | 'post_type' => 'calendar', |
| 186 | 186 | 'nopaging' => true, |
| 187 | - ) ); |
|
| 187 | + )); |
|
| 188 | 188 | |
| 189 | 189 | $calendars = array(); |
| 190 | - foreach ( $posts as $post ) { |
|
| 191 | - $calendars[ $post->ID ] = $post->post_title; |
|
| 190 | + foreach ($posts as $post) { |
|
| 191 | + $calendars[$post->ID] = $post->post_title; |
|
| 192 | 192 | } |
| 193 | - asort( $calendars ); |
|
| 193 | + asort($calendars); |
|
| 194 | 194 | |
| 195 | - set_transient( '_simple-calendar_feed_ids', $calendars, 604800 ); |
|
| 195 | + set_transient('_simple-calendar_feed_ids', $calendars, 604800); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if ( ! empty( $exclude ) ) { |
|
| 199 | - if ( is_numeric( $exclude ) ) { |
|
| 200 | - unset( $calendars[ intval( $exclude ) ] ); |
|
| 201 | - } elseif ( is_array( $exclude ) ) { |
|
| 202 | - array_diff_key( $calendars, array_map( 'intval', array_keys( $exclude ) ) ); |
|
| 198 | + if ( ! empty($exclude)) { |
|
| 199 | + if (is_numeric($exclude)) { |
|
| 200 | + unset($calendars[intval($exclude)]); |
|
| 201 | + } elseif (is_array($exclude)) { |
|
| 202 | + array_diff_key($calendars, array_map('intval', array_keys($exclude))); |
|
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | |
@@ -218,45 +218,45 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @return array |
| 220 | 220 | */ |
| 221 | -function simcal_get_calendar_names_i18n( $group, $style = 'full' ) { |
|
| 221 | +function simcal_get_calendar_names_i18n($group, $style = 'full') { |
|
| 222 | 222 | |
| 223 | 223 | $names = array(); |
| 224 | 224 | |
| 225 | - if ( in_array( $group, array( 'month', 'day', 'meridiem' ) ) ) { |
|
| 225 | + if (in_array($group, array('month', 'day', 'meridiem'))) { |
|
| 226 | 226 | |
| 227 | 227 | $format = ''; |
| 228 | 228 | $length = 0; |
| 229 | 229 | |
| 230 | 230 | $date = Carbon\Carbon::now(); |
| 231 | 231 | |
| 232 | - if ( 'month' == $group ) { |
|
| 233 | - $date->month( 0 )->startOfMonth(); |
|
| 232 | + if ('month' == $group) { |
|
| 233 | + $date->month(0)->startOfMonth(); |
|
| 234 | 234 | $format = 'short' == $style ? 'M' : 'F'; |
| 235 | 235 | $length = 11; |
| 236 | - } elseif ( 'day' == $group ) { |
|
| 237 | - $date->next( 6 ); |
|
| 236 | + } elseif ('day' == $group) { |
|
| 237 | + $date->next(6); |
|
| 238 | 238 | $format = 'short' == $style ? 'D' : 'l'; |
| 239 | 239 | $length = 6; |
| 240 | - } elseif ( 'meridiem' == $group ) { |
|
| 240 | + } elseif ('meridiem' == $group) { |
|
| 241 | 241 | $date->startOfDay(); |
| 242 | - $am = $date->addHour( 1 )->getTimestamp(); |
|
| 243 | - $pm = $date->addHours( 13 )->getTimestamp(); |
|
| 242 | + $am = $date->addHour(1)->getTimestamp(); |
|
| 243 | + $pm = $date->addHours(13)->getTimestamp(); |
|
| 244 | 244 | return array( |
| 245 | - 'AM' => date_i18n( 'A', $am ), |
|
| 246 | - 'am' => date_i18n( 'a', $am ), |
|
| 247 | - 'PM' => date_i18n( 'A', $pm ), |
|
| 248 | - 'pm' => date_i18n( 'a', $pm ), |
|
| 245 | + 'AM' => date_i18n('A', $am), |
|
| 246 | + 'am' => date_i18n('a', $am), |
|
| 247 | + 'PM' => date_i18n('A', $pm), |
|
| 248 | + 'pm' => date_i18n('a', $pm), |
|
| 249 | 249 | ); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | $i = 0; |
| 253 | - while ( $i <= $length ) { |
|
| 254 | - if ( 'month' == $group ) { |
|
| 255 | - $date->addMonths( 1 ); |
|
| 253 | + while ($i <= $length) { |
|
| 254 | + if ('month' == $group) { |
|
| 255 | + $date->addMonths(1); |
|
| 256 | 256 | } else { |
| 257 | - $date->addDays( 1 ); |
|
| 257 | + $date->addDays(1); |
|
| 258 | 258 | } |
| 259 | - $names[ strval( $i ) ] = date_i18n( $format, $date->getTimestamp() ); |
|
| 259 | + $names[strval($i)] = date_i18n($format, $date->getTimestamp()); |
|
| 260 | 260 | $i++; |
| 261 | 261 | } |
| 262 | 262 | |
@@ -274,15 +274,15 @@ discard block |
||
| 274 | 274 | */ |
| 275 | 275 | function simcal_default_event_template() { |
| 276 | 276 | |
| 277 | - $content = '<strong>' . '[title]' . '</strong>'; |
|
| 277 | + $content = '<strong>'.'[title]'.'</strong>'; |
|
| 278 | 278 | $content .= "\n\n"; |
| 279 | - $content .= '[when]' . "\n"; |
|
| 279 | + $content .= '[when]'."\n"; |
|
| 280 | 280 | $content .= '[location]'; |
| 281 | 281 | $content .= "\n"; |
| 282 | - $content .= '<div>' . '[description]' . '</div>'; |
|
| 283 | - $content .= "\n" . '[link newwindow="yes"]' . __( 'See more details', 'google-calendar-events' ) . '[/link]'; |
|
| 282 | + $content .= '<div>'.'[description]'.'</div>'; |
|
| 283 | + $content .= "\n".'[link newwindow="yes"]'.__('See more details', 'google-calendar-events').'[/link]'; |
|
| 284 | 284 | |
| 285 | - return apply_filters( 'simcal_default_event_template', $content ); |
|
| 285 | + return apply_filters('simcal_default_event_template', $content); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
@@ -297,21 +297,21 @@ discard block |
||
| 297 | 297 | * |
| 298 | 298 | * @return array |
| 299 | 299 | */ |
| 300 | -function simcal_get_date_format_order( $date_format ) { |
|
| 300 | +function simcal_get_date_format_order($date_format) { |
|
| 301 | 301 | |
| 302 | 302 | $pos = array( |
| 303 | - 'd' => strpos( $date_format, strpbrk( $date_format, 'Dj' ) ), |
|
| 304 | - 'm' => strpos( $date_format, strpbrk( $date_format, 'FMmn' ) ), |
|
| 305 | - 'y' => strpos( $date_format, strpbrk( $date_format, 'Yy' ) ), |
|
| 303 | + 'd' => strpos($date_format, strpbrk($date_format, 'Dj')), |
|
| 304 | + 'm' => strpos($date_format, strpbrk($date_format, 'FMmn')), |
|
| 305 | + 'y' => strpos($date_format, strpbrk($date_format, 'Yy')), |
|
| 306 | 306 | ); |
| 307 | 307 | |
| 308 | 308 | // @TODO When one date piece is not found, perhaps fallback to ISO standard position. |
| 309 | 309 | |
| 310 | 310 | $order = array(); |
| 311 | - foreach ( $pos as $k => $v ) { |
|
| 312 | - $order[ $k ] = $v; |
|
| 311 | + foreach ($pos as $k => $v) { |
|
| 312 | + $order[$k] = $v; |
|
| 313 | 313 | } |
| 314 | - ksort( $order ); |
|
| 314 | + ksort($order); |
|
| 315 | 315 | |
| 316 | 316 | return $order; |
| 317 | 317 | } |
@@ -327,11 +327,11 @@ discard block |
||
| 327 | 327 | */ |
| 328 | 328 | function simcal_get_wp_timezone() { |
| 329 | 329 | |
| 330 | - $timezone = get_option( 'timezone_string' ); |
|
| 330 | + $timezone = get_option('timezone_string'); |
|
| 331 | 331 | |
| 332 | - if ( empty( $timezone ) ) { |
|
| 333 | - $gmt = get_option( 'gmt_offset' ); |
|
| 334 | - $timezone = simcal_get_timezone_from_gmt_offset( $gmt ); |
|
| 332 | + if (empty($timezone)) { |
|
| 333 | + $gmt = get_option('gmt_offset'); |
|
| 334 | + $timezone = simcal_get_timezone_from_gmt_offset($gmt); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | return $timezone; |
@@ -348,26 +348,26 @@ discard block |
||
| 348 | 348 | * |
| 349 | 349 | * @return null|string |
| 350 | 350 | */ |
| 351 | -function simcal_get_timezone_from_gmt_offset( $offset ) { |
|
| 351 | +function simcal_get_timezone_from_gmt_offset($offset) { |
|
| 352 | 352 | |
| 353 | - if ( is_numeric( $offset ) ) { |
|
| 353 | + if (is_numeric($offset)) { |
|
| 354 | 354 | |
| 355 | - if ( 0 === intval( $offset ) ) { |
|
| 355 | + if (0 === intval($offset)) { |
|
| 356 | 356 | return 'UTC'; |
| 357 | 357 | } else { |
| 358 | - $offset = floatval( $offset ) * 3600; |
|
| 358 | + $offset = floatval($offset) * 3600; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - $timezone = timezone_name_from_abbr( null, $offset, false ); |
|
| 361 | + $timezone = timezone_name_from_abbr(null, $offset, false); |
|
| 362 | 362 | // This is buggy and might return false: |
| 363 | 363 | // @see http://php.net/manual/en/function.timezone-name-from-abbr.php#86928 |
| 364 | 364 | // Therefore: |
| 365 | - if ( false == $timezone ) { |
|
| 365 | + if (false == $timezone) { |
|
| 366 | 366 | |
| 367 | 367 | $list = timezone_abbreviations_list(); |
| 368 | - foreach ( $list as $abbr ) { |
|
| 369 | - foreach ( $abbr as $city ) { |
|
| 370 | - if ( $offset == $city['offset'] ) { |
|
| 368 | + foreach ($list as $abbr) { |
|
| 369 | + foreach ($abbr as $city) { |
|
| 370 | + if ($offset == $city['offset']) { |
|
| 371 | 371 | return $city['timezone_id']; |
| 372 | 372 | } |
| 373 | 373 | } |
@@ -390,8 +390,8 @@ discard block |
||
| 390 | 390 | * |
| 391 | 391 | * @return int Unix time offset |
| 392 | 392 | */ |
| 393 | -function simcal_get_timezone_offset( $timezone ) { |
|
| 394 | - return \Carbon\Carbon::now( $timezone )->offset; |
|
| 393 | +function simcal_get_timezone_offset($timezone) { |
|
| 394 | + return \Carbon\Carbon::now($timezone)->offset; |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | /** |
@@ -404,8 +404,8 @@ discard block |
||
| 404 | 404 | * |
| 405 | 405 | * @return mixed|string |
| 406 | 406 | */ |
| 407 | -function simcal_esc_timezone( $tz, $default = 'UTC' ) { |
|
| 408 | - return in_array( $tz, timezone_identifiers_list() ) ? $tz : $default; |
|
| 407 | +function simcal_esc_timezone($tz, $default = 'UTC') { |
|
| 408 | + return in_array($tz, timezone_identifiers_list()) ? $tz : $default; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
@@ -417,57 +417,57 @@ discard block |
||
| 417 | 417 | * |
| 418 | 418 | * @return bool |
| 419 | 419 | */ |
| 420 | -function simcal_delete_feed_transients( $id = '' ) { |
|
| 420 | +function simcal_delete_feed_transients($id = '') { |
|
| 421 | 421 | |
| 422 | - $grouped_ids = get_post_meta( $id, '_grouped_calendars_ids', true ); |
|
| 422 | + $grouped_ids = get_post_meta($id, '_grouped_calendars_ids', true); |
|
| 423 | 423 | |
| 424 | 424 | // If there are group IDs we need to construct an array to pass along with the grouped IDs + the original $post_id |
| 425 | - if ( is_array( $grouped_ids ) ) { |
|
| 425 | + if (is_array($grouped_ids)) { |
|
| 426 | 426 | $temp_id = $id; |
| 427 | 427 | $id = $grouped_ids; |
| 428 | 428 | $id[] = $temp_id; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - if ( is_numeric( $id ) ) { |
|
| 432 | - $id = intval( $id ) > 0 ? absint( $id ) : simcal_get_calendars(); |
|
| 433 | - } elseif ( $id instanceof WP_Post ) { |
|
| 431 | + if (is_numeric($id)) { |
|
| 432 | + $id = intval($id) > 0 ? absint($id) : simcal_get_calendars(); |
|
| 433 | + } elseif ($id instanceof WP_Post) { |
|
| 434 | 434 | $id = $id->ID; |
| 435 | - } elseif ( is_array( $id ) ) { |
|
| 436 | - $id = array_map( 'absint', $id ); |
|
| 435 | + } elseif (is_array($id)) { |
|
| 436 | + $id = array_map('absint', $id); |
|
| 437 | 437 | } else { |
| 438 | - $id = simcal_get_calendars( '', true ); |
|
| 438 | + $id = simcal_get_calendars('', true); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | $feed_types = simcal_get_feed_types(); |
| 442 | 442 | |
| 443 | - if ( is_array( $id ) ) { |
|
| 443 | + if (is_array($id)) { |
|
| 444 | 444 | |
| 445 | - $posts = get_posts( array( |
|
| 445 | + $posts = get_posts(array( |
|
| 446 | 446 | 'post_type' => 'calendar', |
| 447 | 447 | 'fields' => 'ids', |
| 448 | 448 | 'post__in' => $id, |
| 449 | 449 | 'nopaging' => true, |
| 450 | - ) ); |
|
| 450 | + )); |
|
| 451 | 451 | |
| 452 | - foreach ( $posts as $post ) { |
|
| 453 | - $calendar = simcal_get_calendar( $post ); |
|
| 454 | - if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) { |
|
| 455 | - foreach ( $feed_types as $feed_type ) { |
|
| 456 | - delete_transient( '_simple-calendar_feed_id_' . strval( $calendar->id ) . '_' . $feed_type ); |
|
| 452 | + foreach ($posts as $post) { |
|
| 453 | + $calendar = simcal_get_calendar($post); |
|
| 454 | + if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) { |
|
| 455 | + foreach ($feed_types as $feed_type) { |
|
| 456 | + delete_transient('_simple-calendar_feed_id_'.strval($calendar->id).'_'.$feed_type); |
|
| 457 | 457 | } |
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | } else { |
| 462 | 462 | |
| 463 | - $post = get_post( $id ); |
|
| 464 | - $calendar = simcal_get_calendar( $post ); |
|
| 465 | - if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) { |
|
| 466 | - foreach ( $feed_types as $feed_type ) { |
|
| 467 | - delete_transient( '_simple-calendar_feed_id_' . strval( $calendar->id ) . '_' . $feed_type ); |
|
| 463 | + $post = get_post($id); |
|
| 464 | + $calendar = simcal_get_calendar($post); |
|
| 465 | + if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) { |
|
| 466 | + foreach ($feed_types as $feed_type) { |
|
| 467 | + delete_transient('_simple-calendar_feed_id_'.strval($calendar->id).'_'.$feed_type); |
|
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - return delete_transient( '_simple-calendar_feed_ids' ); |
|
| 472 | + return delete_transient('_simple-calendar_feed_ids'); |
|
| 473 | 473 | } |
| 474 | 474 | \ No newline at end of file |
@@ -14,24 +14,24 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | 16 | // Exit if accessed directly. |
| 17 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 17 | +if ( ! defined('ABSPATH')) { |
|
| 18 | 18 | exit; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | // Plugin constants. |
| 22 | -$this_plugin_path = trailingslashit( dirname( __FILE__ ) ); |
|
| 23 | -$this_plugin_dir = plugin_dir_url( __FILE__ ); |
|
| 22 | +$this_plugin_path = trailingslashit(dirname(__FILE__)); |
|
| 23 | +$this_plugin_dir = plugin_dir_url(__FILE__); |
|
| 24 | 24 | $this_plugin_constants = array( |
| 25 | 25 | 'SIMPLE_CALENDAR_VERSION' => '3.0.15', |
| 26 | 26 | 'SIMPLE_CALENDAR_MAIN_FILE' => __FILE__, |
| 27 | 27 | 'SIMPLE_CALENDAR_URL' => $this_plugin_dir, |
| 28 | - 'SIMPLE_CALENDAR_ASSETS' => $this_plugin_dir . 'assets/', |
|
| 28 | + 'SIMPLE_CALENDAR_ASSETS' => $this_plugin_dir.'assets/', |
|
| 29 | 29 | 'SIMPLE_CALENDAR_PATH' => $this_plugin_path, |
| 30 | - 'SIMPLE_CALENDAR_INC' => $this_plugin_path . 'includes/', |
|
| 30 | + 'SIMPLE_CALENDAR_INC' => $this_plugin_path.'includes/', |
|
| 31 | 31 | ); |
| 32 | -foreach ( $this_plugin_constants as $constant => $value ) { |
|
| 33 | - if ( ! defined( $constant ) ) { |
|
| 34 | - define( $constant, $value ); |
|
| 32 | +foreach ($this_plugin_constants as $constant => $value) { |
|
| 33 | + if ( ! defined($constant)) { |
|
| 34 | + define($constant, $value); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | include_once 'includes/wp-requirements.php'; |
| 41 | 41 | |
| 42 | 42 | // Check plugin requirements before loading plugin. |
| 43 | -$this_plugin_checks = new SimCal_WP_Requirements( 'Simple Calendar', plugin_basename( __FILE__ ), array( |
|
| 43 | +$this_plugin_checks = new SimCal_WP_Requirements('Simple Calendar', plugin_basename(__FILE__), array( |
|
| 44 | 44 | 'PHP' => '5.3.3', |
| 45 | 45 | 'WordPress' => '4.1', |
| 46 | 46 | 'Extensions' => array( |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | 'json', |
| 50 | 50 | 'mbstring', |
| 51 | 51 | ), |
| 52 | - ) ); |
|
| 53 | -if ( $this_plugin_checks->pass() === false ) { |
|
| 52 | + )); |
|
| 53 | +if ($this_plugin_checks->pass() === false) { |
|
| 54 | 54 | $this_plugin_checks->halt(); |
| 55 | 55 | |
| 56 | 56 | return; |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | use SimpleCalendar\Abstracts\Feed; |
| 13 | 13 | use SimpleCalendar\Feeds\Admin\Google_Admin as Admin; |
| 14 | 14 | |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -90,35 +90,35 @@ discard block |
||
| 90 | 90 | * @param string|Calendar $calendar |
| 91 | 91 | * @param bool $load_admin |
| 92 | 92 | */ |
| 93 | - public function __construct( $calendar = '', $load_admin = true ) { |
|
| 93 | + public function __construct($calendar = '', $load_admin = true) { |
|
| 94 | 94 | |
| 95 | - parent::__construct( $calendar ); |
|
| 95 | + parent::__construct($calendar); |
|
| 96 | 96 | |
| 97 | 97 | $this->type = 'google'; |
| 98 | - $this->name = __( 'Google Calendar', 'google-calendar-events' ); |
|
| 98 | + $this->name = __('Google Calendar', 'google-calendar-events'); |
|
| 99 | 99 | |
| 100 | 100 | // Google client config. |
| 101 | - $settings = get_option( 'simple-calendar_settings_feeds' ); |
|
| 102 | - $this->google_api_key = isset( $settings['google']['api_key'] ) ? esc_attr( $settings['google']['api_key'] ) : ''; |
|
| 103 | - $this->google_client_scopes = array( \Google_Service_Calendar::CALENDAR_READONLY ); |
|
| 101 | + $settings = get_option('simple-calendar_settings_feeds'); |
|
| 102 | + $this->google_api_key = isset($settings['google']['api_key']) ? esc_attr($settings['google']['api_key']) : ''; |
|
| 103 | + $this->google_client_scopes = array(\Google_Service_Calendar::CALENDAR_READONLY); |
|
| 104 | 104 | $this->google_client = $this->get_client(); |
| 105 | 105 | |
| 106 | - if ( $this->post_id > 0 ) { |
|
| 106 | + if ($this->post_id > 0) { |
|
| 107 | 107 | |
| 108 | 108 | // Google query args. |
| 109 | - $this->google_calendar_id = $this->esc_google_calendar_id( get_post_meta( $this->post_id, '_google_calendar_id', true ) ); |
|
| 110 | - $this->google_events_recurring = esc_attr( get_post_meta( $this->post_id, '_google_events_recurring', true ) ); |
|
| 109 | + $this->google_calendar_id = $this->esc_google_calendar_id(get_post_meta($this->post_id, '_google_calendar_id', true)); |
|
| 110 | + $this->google_events_recurring = esc_attr(get_post_meta($this->post_id, '_google_events_recurring', true)); |
|
| 111 | 111 | // note that google_search_query is used in a URL param and not as HTML output, so don't use esc_attr() on it |
| 112 | - $this->google_search_query = get_post_meta( $this->post_id, '_google_events_search_query', true ); |
|
| 113 | - $this->google_max_results = max( absint( get_post_meta( $this->post_id, '_google_events_max_results', true ) ), 1 ); |
|
| 112 | + $this->google_search_query = get_post_meta($this->post_id, '_google_events_search_query', true); |
|
| 113 | + $this->google_max_results = max(absint(get_post_meta($this->post_id, '_google_events_max_results', true)), 1); |
|
| 114 | 114 | |
| 115 | - if ( ! is_admin() || defined( 'DOING_AJAX' ) ) { |
|
| 116 | - $this->events = ! empty( $this->google_api_key ) ? $this->get_events() : array(); |
|
| 115 | + if ( ! is_admin() || defined('DOING_AJAX')) { |
|
| 116 | + $this->events = ! empty($this->google_api_key) ? $this->get_events() : array(); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if ( is_admin() && $load_admin ) { |
|
| 121 | - $admin = new Admin( $this, $this->google_api_key, $this->google_calendar_id ); |
|
| 120 | + if (is_admin() && $load_admin) { |
|
| 121 | + $admin = new Admin($this, $this->google_api_key, $this->google_calendar_id); |
|
| 122 | 122 | $this->settings = $admin->settings_fields(); |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | - public function esc_google_calendar_id( $id ) { |
|
| 136 | - return base64_decode( $id ); |
|
| 135 | + public function esc_google_calendar_id($id) { |
|
| 136 | + return base64_decode($id); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -147,85 +147,85 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function get_events() { |
| 149 | 149 | |
| 150 | - $calendar = get_transient( '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type ); |
|
| 150 | + $calendar = get_transient('_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type); |
|
| 151 | 151 | |
| 152 | - if ( empty( $calendar ) && ! empty( $this->google_calendar_id ) ) { |
|
| 152 | + if (empty($calendar) && ! empty($this->google_calendar_id)) { |
|
| 153 | 153 | |
| 154 | 154 | $error = ''; |
| 155 | 155 | |
| 156 | 156 | try { |
| 157 | - $response = $this->make_request( $this->google_calendar_id ); |
|
| 158 | - } catch ( \Exception $e ) { |
|
| 157 | + $response = $this->make_request($this->google_calendar_id); |
|
| 158 | + } catch (\Exception $e) { |
|
| 159 | 159 | $error .= $e->getMessage(); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( empty( $error ) && isset( $response['events'] ) && isset( $response['timezone'] ) ) { |
|
| 162 | + if (empty($error) && isset($response['events']) && isset($response['timezone'])) { |
|
| 163 | 163 | |
| 164 | - $calendar = array_merge( $response, array( 'events' => array() ) ); |
|
| 164 | + $calendar = array_merge($response, array('events' => array())); |
|
| 165 | 165 | |
| 166 | 166 | // If no timezone has been set, use calendar feed. |
| 167 | - if ( 'use_calendar' == $this->timezone_setting ) { |
|
| 167 | + if ('use_calendar' == $this->timezone_setting) { |
|
| 168 | 168 | $this->timezone = $calendar['timezone']; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $source = isset( $response['title'] ) ? sanitize_text_field( $response['title'] ) : ''; |
|
| 171 | + $source = isset($response['title']) ? sanitize_text_field($response['title']) : ''; |
|
| 172 | 172 | |
| 173 | - if ( ! empty( $response['events'] ) && is_array( $response['events'] ) ) { |
|
| 174 | - foreach ( $response['events'] as $event ) { |
|
| 175 | - if ( $event instanceof \Google_Service_Calendar_Event ) { |
|
| 173 | + if ( ! empty($response['events']) && is_array($response['events'])) { |
|
| 174 | + foreach ($response['events'] as $event) { |
|
| 175 | + if ($event instanceof \Google_Service_Calendar_Event) { |
|
| 176 | 176 | |
| 177 | 177 | // Visibility and status. |
| 178 | 178 | // Public calendars may have private events which can't be properly accessed by simple api key method. |
| 179 | 179 | // Also want to skip cancelled events (single occurences deleted from repeating events) |
| 180 | 180 | $visibility = $event->getVisibility(); |
| 181 | 181 | $status = $event->getStatus(); |
| 182 | - if ( $this->type == 'google' && ( $visibility == 'private' || $visibility == 'confidential' || $status == 'cancelled' ) ) { |
|
| 182 | + if ($this->type == 'google' && ($visibility == 'private' || $visibility == 'confidential' || $status == 'cancelled')) { |
|
| 183 | 183 | continue; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | // Event title & description. |
| 187 | - $title = strip_tags( $event->getSummary() ); |
|
| 188 | - $title = sanitize_text_field( iconv( mb_detect_encoding( $title, mb_detect_order(), true ), 'UTF-8', $title ) ); |
|
| 189 | - $description = wp_kses_post( iconv( mb_detect_encoding( $event->getDescription(), mb_detect_order(), true ), 'UTF-8', $event->getDescription() ) ); |
|
| 187 | + $title = strip_tags($event->getSummary()); |
|
| 188 | + $title = sanitize_text_field(iconv(mb_detect_encoding($title, mb_detect_order(), true), 'UTF-8', $title)); |
|
| 189 | + $description = wp_kses_post(iconv(mb_detect_encoding($event->getDescription(), mb_detect_order(), true), 'UTF-8', $event->getDescription())); |
|
| 190 | 190 | |
| 191 | 191 | $whole_day = false; |
| 192 | 192 | |
| 193 | 193 | // Event start properties. |
| 194 | - if( 'use_calendar' == $this->timezone_setting ) { |
|
| 194 | + if ('use_calendar' == $this->timezone_setting) { |
|
| 195 | 195 | $start_timezone = ! $event->getStart()->timeZone ? $calendar['timezone'] : $event->getStart()->timeZone; |
| 196 | 196 | } else { |
| 197 | 197 | $start_timezone = $this->timezone; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if ( is_null( $event->getStart()->dateTime ) ) { |
|
| 200 | + if (is_null($event->getStart()->dateTime)) { |
|
| 201 | 201 | // Whole day event. |
| 202 | - $date = Carbon::parse( $event->getStart()->date ); |
|
| 203 | - $google_start = Carbon::createFromDate( $date->year, $date->month, $date->day, $start_timezone )->startOfDay()->addSeconds( 59 ); |
|
| 204 | - $google_start_utc = Carbon::createFromDate( $date->year, $date->month, $date->day, 'UTC' )->startOfDay()->addSeconds( 59 ); |
|
| 202 | + $date = Carbon::parse($event->getStart()->date); |
|
| 203 | + $google_start = Carbon::createFromDate($date->year, $date->month, $date->day, $start_timezone)->startOfDay()->addSeconds(59); |
|
| 204 | + $google_start_utc = Carbon::createFromDate($date->year, $date->month, $date->day, 'UTC')->startOfDay()->addSeconds(59); |
|
| 205 | 205 | $whole_day = true; |
| 206 | 206 | } else { |
| 207 | - $date = Carbon::parse( $event->getStart()->dateTime ); |
|
| 207 | + $date = Carbon::parse($event->getStart()->dateTime); |
|
| 208 | 208 | |
| 209 | 209 | // Check if there is an event level timezone |
| 210 | - if( $event->getStart()->timeZone && 'use_calendar' == $this->timezone_setting ) { |
|
| 210 | + if ($event->getStart()->timeZone && 'use_calendar' == $this->timezone_setting) { |
|
| 211 | 211 | |
| 212 | 212 | // Get the two different times with the separate timezones so we can check the offsets next |
| 213 | - $google_start1 = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $date->timezone ); |
|
| 214 | - $google_start2 = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $event->getStart()->timeZone ); |
|
| 213 | + $google_start1 = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $date->timezone); |
|
| 214 | + $google_start2 = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $event->getStart()->timeZone); |
|
| 215 | 215 | |
| 216 | 216 | // Get the offset in hours |
| 217 | 217 | $offset1 = $google_start1->offsetHours; |
| 218 | 218 | $offset2 = $google_start2->offsetHours; |
| 219 | 219 | |
| 220 | 220 | // Get the difference between the two timezones |
| 221 | - $total_offset = ( $offset2 - $offset1 ); |
|
| 221 | + $total_offset = ($offset2 - $offset1); |
|
| 222 | 222 | |
| 223 | 223 | // Add the hours offset to the date hour |
| 224 | 224 | $date->hour += $total_offset; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - $google_start = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $start_timezone ); |
|
| 228 | - $google_start_utc = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC' ); |
|
| 227 | + $google_start = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $start_timezone); |
|
| 228 | + $google_start_utc = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC'); |
|
| 229 | 229 | |
| 230 | 230 | $this->timezone = $start_timezone; |
| 231 | 231 | } |
@@ -236,43 +236,43 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | $end = $end_utc = $end_timezone = ''; |
| 238 | 238 | $span = 0; |
| 239 | - if ( false == $event->getEndTimeUnspecified() ) { |
|
| 239 | + if (false == $event->getEndTimeUnspecified()) { |
|
| 240 | 240 | |
| 241 | 241 | // Event end properties. |
| 242 | - if( 'use_calendar' == $this->timezone_setting ) { |
|
| 242 | + if ('use_calendar' == $this->timezone_setting) { |
|
| 243 | 243 | $end_timezone = ! $event->getEnd()->timeZone ? $calendar['timezone'] : $event->getEnd()->timeZone; |
| 244 | 244 | } else { |
| 245 | 245 | $end_timezone = $this->timezone; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - if ( is_null( $event->getEnd()->dateTime ) ) { |
|
| 248 | + if (is_null($event->getEnd()->dateTime)) { |
|
| 249 | 249 | // Whole day event. |
| 250 | - $date = Carbon::parse( $event->getEnd()->date ); |
|
| 251 | - $google_end = Carbon::createFromDate( $date->year, $date->month, $date->day, $end_timezone )->startOfDay()->subSeconds( 59 ); |
|
| 252 | - $google_end_utc = Carbon::createFromDate( $date->year, $date->month, $date->day, 'UTC' )->startOfDay()->subSeconds( 59 ); |
|
| 250 | + $date = Carbon::parse($event->getEnd()->date); |
|
| 251 | + $google_end = Carbon::createFromDate($date->year, $date->month, $date->day, $end_timezone)->startOfDay()->subSeconds(59); |
|
| 252 | + $google_end_utc = Carbon::createFromDate($date->year, $date->month, $date->day, 'UTC')->startOfDay()->subSeconds(59); |
|
| 253 | 253 | } else { |
| 254 | - $date = Carbon::parse( $event->getEnd()->dateTime ); |
|
| 254 | + $date = Carbon::parse($event->getEnd()->dateTime); |
|
| 255 | 255 | |
| 256 | 256 | // Check if there is an event level timezone |
| 257 | - if( $event->getEnd()->timeZone && 'use_calendar' == $this->timezone_setting ) { |
|
| 257 | + if ($event->getEnd()->timeZone && 'use_calendar' == $this->timezone_setting) { |
|
| 258 | 258 | |
| 259 | 259 | // Get the two different times with the separate timezones so we can check the offsets next |
| 260 | - $google_start1 = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $date->timezone ); |
|
| 261 | - $google_start2 = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $event->getEnd()->timeZone ); |
|
| 260 | + $google_start1 = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $date->timezone); |
|
| 261 | + $google_start2 = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $event->getEnd()->timeZone); |
|
| 262 | 262 | |
| 263 | 263 | // Get the offset in hours |
| 264 | 264 | $offset1 = $google_start1->offsetHours; |
| 265 | 265 | $offset2 = $google_start2->offsetHours; |
| 266 | 266 | |
| 267 | 267 | // Get the difference between the two timezones |
| 268 | - $total_offset = ( $offset2 - $offset1 ); |
|
| 268 | + $total_offset = ($offset2 - $offset1); |
|
| 269 | 269 | |
| 270 | 270 | // Add the hours offset to the date hour |
| 271 | 271 | $date->hour += $total_offset; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - $google_end = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $end_timezone ); |
|
| 275 | - $google_end_utc = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC' ); |
|
| 274 | + $google_end = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $end_timezone); |
|
| 275 | + $google_end_utc = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC'); |
|
| 276 | 276 | } |
| 277 | 277 | // End. |
| 278 | 278 | $end = $google_end->getTimestamp(); |
@@ -280,10 +280,10 @@ discard block |
||
| 280 | 280 | $end_utc = $google_end_utc->getTimestamp(); |
| 281 | 281 | |
| 282 | 282 | // Count multiple days. |
| 283 | - $span = $google_start->setTimezone( $calendar['timezone'] )->diffInDays( $google_end->setTimezone( $calendar['timezone'] ) ); |
|
| 283 | + $span = $google_start->setTimezone($calendar['timezone'])->diffInDays($google_end->setTimezone($calendar['timezone'])); |
|
| 284 | 284 | |
| 285 | - if ( $span == 0 ) { |
|
| 286 | - if ( $google_start->toDateString() !== $google_end->toDateString() ) { |
|
| 285 | + if ($span == 0) { |
|
| 286 | + if ($google_start->toDateString() !== $google_end->toDateString()) { |
|
| 287 | 287 | $span = 1; |
| 288 | 288 | } |
| 289 | 289 | } |
@@ -298,19 +298,19 @@ discard block |
||
| 298 | 298 | // Recurring event. |
| 299 | 299 | $recurrence = $event->getRecurrence(); |
| 300 | 300 | $recurring_id = $event->getRecurringEventId(); |
| 301 | - if ( ! $recurrence && $recurring_id ) { |
|
| 301 | + if ( ! $recurrence && $recurring_id) { |
|
| 302 | 302 | $recurrence = true; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | // Event link. |
| 306 | - if ( 'use_calendar' == $this->timezone_setting ) { |
|
| 307 | - $link = add_query_arg( array( 'ctz' => $this->timezone ), $event->getHtmlLink() ); |
|
| 306 | + if ('use_calendar' == $this->timezone_setting) { |
|
| 307 | + $link = add_query_arg(array('ctz' => $this->timezone), $event->getHtmlLink()); |
|
| 308 | 308 | } else { |
| 309 | 309 | $link = $event->getHtmlLink(); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | // Build the event. |
| 313 | - $calendar['events'][ intval( $start ) ][] = array( |
|
| 313 | + $calendar['events'][intval($start)][] = array( |
|
| 314 | 314 | 'type' => 'google-calendar', |
| 315 | 315 | 'source' => $source, |
| 316 | 316 | 'title' => $title, |
@@ -337,24 +337,24 @@ discard block |
||
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if ( ! empty( $calendar['events'] ) ) { |
|
| 340 | + if ( ! empty($calendar['events'])) { |
|
| 341 | 341 | |
| 342 | - ksort( $calendar['events'], SORT_NUMERIC ); |
|
| 342 | + ksort($calendar['events'], SORT_NUMERIC); |
|
| 343 | 343 | |
| 344 | 344 | set_transient( |
| 345 | - '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type, |
|
| 345 | + '_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type, |
|
| 346 | 346 | $calendar, |
| 347 | - max( absint( $this->cache ), 1 ) // Since a value of 0 means forever we set the minimum here to 1 if the user has set it to be 0 |
|
| 347 | + max(absint($this->cache), 1) // Since a value of 0 means forever we set the minimum here to 1 if the user has set it to be 0 |
|
| 348 | 348 | ); |
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | } else { |
| 353 | 353 | |
| 354 | - $message = __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' ); |
|
| 355 | - $message .= '<br><br>' . $error . '<br><br>'; |
|
| 356 | - $message .= __( 'Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events' ) . '<br><br>'; |
|
| 357 | - $message .= __( 'Only you can see this notice.', 'google-calendar-events' ); |
|
| 354 | + $message = __('While trying to retrieve events, Google returned an error:', 'google-calendar-events'); |
|
| 355 | + $message .= '<br><br>'.$error.'<br><br>'; |
|
| 356 | + $message .= __('Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events').'<br><br>'; |
|
| 357 | + $message .= __('Only you can see this notice.', 'google-calendar-events'); |
|
| 358 | 358 | |
| 359 | 359 | return $message; |
| 360 | 360 | } |
@@ -362,11 +362,11 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | // If no timezone has been set, use calendar feed. |
| 365 | - if ( 'use_calendar' == $this->timezone_setting && isset( $calendar['timezone'] ) ) { |
|
| 365 | + if ('use_calendar' == $this->timezone_setting && isset($calendar['timezone'])) { |
|
| 366 | 366 | $this->timezone = $calendar['timezone']; |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - return isset( $calendar['events'] ) ? $calendar['events'] : array(); |
|
| 369 | + return isset($calendar['events']) ? $calendar['events'] : array(); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
@@ -382,67 +382,67 @@ discard block |
||
| 382 | 382 | * |
| 383 | 383 | * @throws \Exception On request failure will throw an exception from Google. |
| 384 | 384 | */ |
| 385 | - public function make_request( $id = '', $time_min = 0, $time_max = 0 ) { |
|
| 385 | + public function make_request($id = '', $time_min = 0, $time_max = 0) { |
|
| 386 | 386 | |
| 387 | 387 | $calendar = array(); |
| 388 | 388 | $google = $this->get_service(); |
| 389 | 389 | |
| 390 | - if ( ! is_null( $google ) && ! empty( $id ) ) { |
|
| 390 | + if ( ! is_null($google) && ! empty($id)) { |
|
| 391 | 391 | |
| 392 | 392 | // Build the request args. |
| 393 | 393 | $args = array(); |
| 394 | 394 | |
| 395 | 395 | // Expand recurring events. |
| 396 | - if ( $this->google_events_recurring == 'show' ) { |
|
| 396 | + if ($this->google_events_recurring == 'show') { |
|
| 397 | 397 | $args['singleEvents'] = true; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | // Query events using search terms. |
| 401 | - if ( ! empty( $this->google_search_query ) ) { |
|
| 402 | - $args['q'] = rawurlencode( $this->google_search_query ); |
|
| 401 | + if ( ! empty($this->google_search_query)) { |
|
| 402 | + $args['q'] = rawurlencode($this->google_search_query); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | // Max results to query. |
| 406 | - $args['maxResults'] = strval( min( absint( $this->google_max_results ), 2500 ) ); |
|
| 406 | + $args['maxResults'] = strval(min(absint($this->google_max_results), 2500)); |
|
| 407 | 407 | |
| 408 | 408 | // Specify a timezone. |
| 409 | 409 | $timezone = ''; |
| 410 | - if ( 'use_calendar' != get_post_meta( $this->post_id, '_feed_timezone_setting', true ) ) { |
|
| 410 | + if ('use_calendar' != get_post_meta($this->post_id, '_feed_timezone_setting', true)) { |
|
| 411 | 411 | $args['timeZone'] = $timezone = $this->timezone; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | // Lower bound (inclusive) for an event's end time to filter by. |
| 415 | - $earliest_event = intval( $this->time_min ); |
|
| 416 | - if ( $earliest_event > 0 ) { |
|
| 415 | + $earliest_event = intval($this->time_min); |
|
| 416 | + if ($earliest_event > 0) { |
|
| 417 | 417 | $timeMin = Carbon::now(); |
| 418 | - if ( ! empty( $timezone ) ) { |
|
| 419 | - $timeMin->setTimezone( $timezone ); |
|
| 418 | + if ( ! empty($timezone)) { |
|
| 419 | + $timeMin->setTimezone($timezone); |
|
| 420 | 420 | } |
| 421 | - $timeMin->setTimestamp( $earliest_event ); |
|
| 421 | + $timeMin->setTimestamp($earliest_event); |
|
| 422 | 422 | $args['timeMin'] = $timeMin->toRfc3339String(); |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Upper bound (exclusive) for an event's start time to filter by. |
| 426 | - $latest_event = intval( $this->time_max ); |
|
| 427 | - if ( $latest_event > 0 ) { |
|
| 426 | + $latest_event = intval($this->time_max); |
|
| 427 | + if ($latest_event > 0) { |
|
| 428 | 428 | $timeMax = Carbon::now(); |
| 429 | - if ( ! empty( $timezone ) ) { |
|
| 430 | - $timeMax->setTimezone( $timezone ); |
|
| 429 | + if ( ! empty($timezone)) { |
|
| 430 | + $timeMax->setTimezone($timezone); |
|
| 431 | 431 | } |
| 432 | - $timeMax->setTimestamp( $latest_event ); |
|
| 432 | + $timeMax->setTimestamp($latest_event); |
|
| 433 | 433 | $args['timeMax'] = $timeMax->toRfc3339String(); |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | // Query events in calendar. |
| 437 | - $response = $google->events->listEvents( $id, $args ); |
|
| 437 | + $response = $google->events->listEvents($id, $args); |
|
| 438 | 438 | |
| 439 | - if ( $response instanceof \Google_Service_Calendar_Events ) { |
|
| 439 | + if ($response instanceof \Google_Service_Calendar_Events) { |
|
| 440 | 440 | $calendar = array( |
| 441 | 441 | 'id' => $id, |
| 442 | 442 | 'title' => $response->getSummary(), |
| 443 | 443 | 'description' => $response->getDescription(), |
| 444 | 444 | 'timezone' => $response->getTimeZone(), |
| 445 | - 'url' => esc_url( '//www.google.com/calendar/embed?src=' . $id ), |
|
| 445 | + 'url' => esc_url('//www.google.com/calendar/embed?src='.$id), |
|
| 446 | 446 | 'events' => $response->getItems(), |
| 447 | 447 | ); |
| 448 | 448 | } |
@@ -462,10 +462,10 @@ discard block |
||
| 462 | 462 | private function get_client() { |
| 463 | 463 | |
| 464 | 464 | $client = new \Google_Client(); |
| 465 | - $client->setApplicationName( 'Simple Calendar' ); |
|
| 466 | - $client->setScopes( $this->google_client_scopes ); |
|
| 467 | - $client->setDeveloperKey( $this->google_api_key ); |
|
| 468 | - $client->setAccessType( 'online' ); |
|
| 465 | + $client->setApplicationName('Simple Calendar'); |
|
| 466 | + $client->setScopes($this->google_client_scopes); |
|
| 467 | + $client->setDeveloperKey($this->google_api_key); |
|
| 468 | + $client->setAccessType('online'); |
|
| 469 | 469 | |
| 470 | 470 | return $client; |
| 471 | 471 | } |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | * @return null|\Google_Service_Calendar |
| 480 | 480 | */ |
| 481 | 481 | protected function get_service() { |
| 482 | - return $this->google_client instanceof \Google_Client ? new \Google_Service_Calendar( $this->google_client ) : null; |
|
| 482 | + return $this->google_client instanceof \Google_Client ? new \Google_Service_Calendar($this->google_client) : null; |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | use SimpleCalendar\Calendars\Default_Calendar; |
| 14 | 14 | use SimpleCalendar\Events\Event; |
| 15 | 15 | |
| 16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 16 | +if ( ! defined('ABSPATH')) { |
|
| 17 | 17 | exit; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @param string|Calendar $calendar |
| 73 | 73 | */ |
| 74 | - public function __construct( $calendar = '' ) { |
|
| 74 | + public function __construct($calendar = '') { |
|
| 75 | 75 | $this->calendar = $calendar; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | 107 | public function get_name() { |
| 108 | - return __( 'List', 'google-calendar-events' ); |
|
| 108 | + return __('List', 'google-calendar-events'); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | * @since 3.0.0 |
| 115 | 115 | */ |
| 116 | 116 | public function add_ajax_actions() { |
| 117 | - add_action( 'wp_ajax_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) ); |
|
| 118 | - add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) ); |
|
| 117 | + add_action('wp_ajax_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax')); |
|
| 118 | + add_action('wp_ajax_nopriv_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax')); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -129,16 +129,16 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return array |
| 131 | 131 | */ |
| 132 | - public function scripts( $min = '' ) { |
|
| 132 | + public function scripts($min = '') { |
|
| 133 | 133 | return array( |
| 134 | 134 | 'simcal-qtip' => array( |
| 135 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js', |
|
| 136 | - 'deps' => array( 'jquery' ), |
|
| 135 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$min.'.js', |
|
| 136 | + 'deps' => array('jquery'), |
|
| 137 | 137 | 'ver' => '2.2.1', |
| 138 | 138 | 'in_footer' => true, |
| 139 | 139 | ), |
| 140 | 140 | 'simcal-default-calendar' => array( |
| 141 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js', |
|
| 141 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js', |
|
| 142 | 142 | 'deps' => array( |
| 143 | 143 | 'jquery', |
| 144 | 144 | 'simcal-qtip', |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @return array |
| 165 | 165 | */ |
| 166 | - public function styles( $min = '' ) { |
|
| 166 | + public function styles($min = '') { |
|
| 167 | 167 | return array( |
| 168 | 168 | 'simcal-default-calendar-list' => array( |
| 169 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-list' . $min . '.css', |
|
| 169 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-list'.$min.'.css', |
|
| 170 | 170 | 'ver' => SIMPLE_CALENDAR_VERSION, |
| 171 | 171 | 'media' => 'all', |
| 172 | 172 | ), |
@@ -182,49 +182,49 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | $calendar = $this->calendar; |
| 184 | 184 | |
| 185 | - if ( $calendar instanceof Default_Calendar ) { |
|
| 185 | + if ($calendar instanceof Default_Calendar) { |
|
| 186 | 186 | |
| 187 | 187 | $disabled = $calendar->static === true ? ' disabled="disabled"' : ''; |
| 188 | 188 | |
| 189 | 189 | |
| 190 | - $hide_header = get_post_meta( $this->calendar->id, '_default_calendar_list_header', true ) == 'yes' ? true : false; |
|
| 191 | - $static_calendar = get_post_meta( $this->calendar->id, '_calendar_is_static', true ) == 'yes' ? true : false; |
|
| 190 | + $hide_header = get_post_meta($this->calendar->id, '_default_calendar_list_header', true) == 'yes' ? true : false; |
|
| 191 | + $static_calendar = get_post_meta($this->calendar->id, '_calendar_is_static', true) == 'yes' ? true : false; |
|
| 192 | 192 | |
| 193 | 193 | $header_class = ''; |
| 194 | 194 | $compact_list_class = $calendar->compact_list ? 'simcal-calendar-list-compact' : ''; |
| 195 | 195 | |
| 196 | - edit_post_link( __( 'Edit Calendar', 'google-calendar-events' ), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id ); |
|
| 196 | + edit_post_link(__('Edit Calendar', 'google-calendar-events'), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id); |
|
| 197 | 197 | |
| 198 | - echo '<div class="simcal-calendar-list ' . $compact_list_class . '">'; |
|
| 198 | + echo '<div class="simcal-calendar-list '.$compact_list_class.'">'; |
|
| 199 | 199 | |
| 200 | - if ( ! $hide_header && ! $static_calendar ) { |
|
| 201 | - echo '<nav class="simcal-calendar-head">' . "\n"; |
|
| 200 | + if ( ! $hide_header && ! $static_calendar) { |
|
| 201 | + echo '<nav class="simcal-calendar-head">'."\n"; |
|
| 202 | 202 | |
| 203 | - echo "\t" . '<div class="simcal-nav">' . "\n"; |
|
| 204 | - echo "\t\t" . '<button class="simcal-nav-button simcal-prev" title="' . __('Previous', 'google-calendar-events') . '"' . $disabled . '>' . "\n"; |
|
| 205 | - echo "\t\t\t" . '<i class="simcal-icon-left"></i>' . "\n"; |
|
| 206 | - echo "\t\t" . '</button>' . "\n"; |
|
| 207 | - echo "\t" . '</div>' . "\n"; |
|
| 203 | + echo "\t".'<div class="simcal-nav">'."\n"; |
|
| 204 | + echo "\t\t".'<button class="simcal-nav-button simcal-prev" title="'.__('Previous', 'google-calendar-events').'"'.$disabled.'>'."\n"; |
|
| 205 | + echo "\t\t\t".'<i class="simcal-icon-left"></i>'."\n"; |
|
| 206 | + echo "\t\t".'</button>'."\n"; |
|
| 207 | + echo "\t".'</div>'."\n"; |
|
| 208 | 208 | |
| 209 | - if ( $hide_header ) { |
|
| 209 | + if ($hide_header) { |
|
| 210 | 210 | $header_class = 'simcal-hide-header'; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | |
| 214 | - echo "\t" . '<div class="simcal-nav simcal-current ' . $header_class . '" data-calendar-current="' . $calendar->start . '">' . "\n"; |
|
| 215 | - echo "\t\t" . '<h3 class="simcal-current-label"> </h3>' . "\n"; |
|
| 216 | - echo "\t" . '</div>' . "\n"; |
|
| 214 | + echo "\t".'<div class="simcal-nav simcal-current '.$header_class.'" data-calendar-current="'.$calendar->start.'">'."\n"; |
|
| 215 | + echo "\t\t".'<h3 class="simcal-current-label"> </h3>'."\n"; |
|
| 216 | + echo "\t".'</div>'."\n"; |
|
| 217 | 217 | |
| 218 | - echo "\t" . '<div class="simcal-nav">'; |
|
| 219 | - echo "\t\t" . '<button class="simcal-nav-button simcal-next" title="' . __('Next', 'google-calendar-events') . '"' . $disabled . '>'; |
|
| 220 | - echo "\t\t\t" . '<i class="simcal-icon-right"></i>' . "\n"; |
|
| 221 | - echo "\t\t" . '</button>' . "\n"; |
|
| 222 | - echo "\t" . '</div>' . "\n"; |
|
| 218 | + echo "\t".'<div class="simcal-nav">'; |
|
| 219 | + echo "\t\t".'<button class="simcal-nav-button simcal-next" title="'.__('Next', 'google-calendar-events').'"'.$disabled.'>'; |
|
| 220 | + echo "\t\t\t".'<i class="simcal-icon-right"></i>'."\n"; |
|
| 221 | + echo "\t\t".'</button>'."\n"; |
|
| 222 | + echo "\t".'</div>'."\n"; |
|
| 223 | 223 | |
| 224 | - echo '</nav>' . "\n"; |
|
| 224 | + echo '</nav>'."\n"; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - echo $this->draw_list( $calendar->start ); |
|
| 227 | + echo $this->draw_list($calendar->start); |
|
| 228 | 228 | |
| 229 | 229 | echo '<div class="simcal-ajax-loader simcal-spinner-top" style="display: none;"><i class="simcal-icon-spinner simcal-icon-spin"></i></div>'; |
| 230 | 230 | |
@@ -244,92 +244,92 @@ discard block |
||
| 244 | 244 | * |
| 245 | 245 | * @return array |
| 246 | 246 | */ |
| 247 | - private function get_events( $timestamp ) { |
|
| 247 | + private function get_events($timestamp) { |
|
| 248 | 248 | |
| 249 | 249 | $calendar = $this->calendar; |
| 250 | 250 | $timezone = $calendar->timezone; |
| 251 | 251 | |
| 252 | - if ( ! $calendar->group_type || ! $calendar->group_span ) { |
|
| 252 | + if ( ! $calendar->group_type || ! $calendar->group_span) { |
|
| 253 | 253 | return array(); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - $current = Carbon::createFromTimestamp( $timestamp, $timezone ); |
|
| 256 | + $current = Carbon::createFromTimestamp($timestamp, $timezone); |
|
| 257 | 257 | $prev = clone $current; |
| 258 | 258 | $next = clone $current; |
| 259 | 259 | |
| 260 | 260 | $this->start = $current->getTimestamp(); |
| 261 | 261 | |
| 262 | - $interval = $span = max( absint( $calendar->group_span ), 1 ); |
|
| 263 | - |
|
| 264 | - if ( 'monthly' == $calendar->group_type ) { |
|
| 265 | - $this->prev = $prev->subMonths( $span )->getTimestamp(); |
|
| 266 | - $this->next = $next->addMonths( $span )->getTimestamp(); |
|
| 267 | - } elseif ( 'weekly' == $calendar->group_type ) { |
|
| 268 | - $week = new Carbon( $calendar->timezone ); |
|
| 269 | - $week->setTimestamp( $timestamp ); |
|
| 270 | - $week->setWeekStartsAt( $calendar->week_starts ); |
|
| 271 | - $this->prev = $prev->subWeeks( $span )->getTimestamp(); |
|
| 272 | - $this->next = $next->addWeeks( $span )->getTimestamp(); |
|
| 273 | - } elseif ( 'daily' == $calendar->group_type ) { |
|
| 274 | - $this->prev = $prev->subDays( $span )->getTimestamp(); |
|
| 275 | - $this->next = $next->addDays( $span )->getTimestamp(); |
|
| 262 | + $interval = $span = max(absint($calendar->group_span), 1); |
|
| 263 | + |
|
| 264 | + if ('monthly' == $calendar->group_type) { |
|
| 265 | + $this->prev = $prev->subMonths($span)->getTimestamp(); |
|
| 266 | + $this->next = $next->addMonths($span)->getTimestamp(); |
|
| 267 | + } elseif ('weekly' == $calendar->group_type) { |
|
| 268 | + $week = new Carbon($calendar->timezone); |
|
| 269 | + $week->setTimestamp($timestamp); |
|
| 270 | + $week->setWeekStartsAt($calendar->week_starts); |
|
| 271 | + $this->prev = $prev->subWeeks($span)->getTimestamp(); |
|
| 272 | + $this->next = $next->addWeeks($span)->getTimestamp(); |
|
| 273 | + } elseif ('daily' == $calendar->group_type) { |
|
| 274 | + $this->prev = $prev->subDays($span)->getTimestamp(); |
|
| 275 | + $this->next = $next->addDays($span)->getTimestamp(); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | $events = $calendar->events; |
| 279 | 279 | $daily_events = $paged_events = $flattened_events = array(); |
| 280 | 280 | |
| 281 | - if ( 'events' != $calendar->group_type ) { |
|
| 281 | + if ('events' != $calendar->group_type) { |
|
| 282 | 282 | |
| 283 | - $this->end = $this->next - 1; |
|
| 283 | + $this->end = $this->next - 1; |
|
| 284 | 284 | |
| 285 | - $timestamps = array_keys( $events ); |
|
| 286 | - $lower_bound = array_filter( $timestamps, array( $this, 'filter_events_before' ) ); |
|
| 287 | - $higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after' ) ); |
|
| 285 | + $timestamps = array_keys($events); |
|
| 286 | + $lower_bound = array_filter($timestamps, array($this, 'filter_events_before')); |
|
| 287 | + $higher_bound = array_filter($lower_bound, array($this, 'filter_events_after')); |
|
| 288 | 288 | |
| 289 | - if ( is_array( $higher_bound ) && !empty( $higher_bound ) ) { |
|
| 290 | - $filtered = array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) ); |
|
| 291 | - foreach ( $filtered as $timestamp => $events ) { |
|
| 292 | - $paged_events[ intval( $timestamp ) ] = $events; |
|
| 289 | + if (is_array($higher_bound) && ! empty($higher_bound)) { |
|
| 290 | + $filtered = array_intersect_key($events, array_combine($higher_bound, $higher_bound)); |
|
| 291 | + foreach ($filtered as $timestamp => $events) { |
|
| 292 | + $paged_events[intval($timestamp)] = $events; |
|
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | } else { |
| 297 | 297 | |
| 298 | - foreach ( $events as $timestamp => $e ) { |
|
| 298 | + foreach ($events as $timestamp => $e) { |
|
| 299 | 299 | $second = 0; |
| 300 | - foreach ( $e as $event ) { |
|
| 301 | - $flattened_events[ intval( $timestamp + $second ) ][] = $event; |
|
| 300 | + foreach ($e as $event) { |
|
| 301 | + $flattened_events[intval($timestamp + $second)][] = $event; |
|
| 302 | 302 | $second++; |
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | - ksort( $flattened_events, SORT_NUMERIC ); |
|
| 305 | + ksort($flattened_events, SORT_NUMERIC); |
|
| 306 | 306 | |
| 307 | - $keys = array_keys( $flattened_events ); |
|
| 307 | + $keys = array_keys($flattened_events); |
|
| 308 | 308 | $current = 0; |
| 309 | - foreach ( $keys as $timestamp ) { |
|
| 310 | - if ( $timestamp <= $this->start ) { |
|
| 309 | + foreach ($keys as $timestamp) { |
|
| 310 | + if ($timestamp <= $this->start) { |
|
| 311 | 311 | $current++; |
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $paged_events = array_slice( $flattened_events, $current, $interval, true ); |
|
| 315 | + $paged_events = array_slice($flattened_events, $current, $interval, true); |
|
| 316 | 316 | |
| 317 | - $events_end = isset( $keys[ $current + $interval ] ) ? $keys[ $current + $interval ] : $calendar->end; |
|
| 317 | + $events_end = isset($keys[$current + $interval]) ? $keys[$current + $interval] : $calendar->end; |
|
| 318 | 318 | $this->end = $events_end > $calendar->end ? $calendar->end : $events_end; |
| 319 | 319 | // -1 adjusts the interval count to index count, which starts at 0. |
| 320 | - $this->prev = isset( $keys[ $current - $interval - 1 ] ) ? $keys[ $current - $interval - 1 ] : $calendar->earliest_event; |
|
| 321 | - $this->next = isset( $keys[ $current + $interval - 1 ] ) ? $keys[ $current + $interval - 1 ] : $this->end; |
|
| 320 | + $this->prev = isset($keys[$current - $interval - 1]) ? $keys[$current - $interval - 1] : $calendar->earliest_event; |
|
| 321 | + $this->next = isset($keys[$current + $interval - 1]) ? $keys[$current + $interval - 1] : $this->end; |
|
| 322 | 322 | |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | // Put resulting events in an associative array, with Ymd date as key for easy retrieval in calendar days loop. |
| 326 | - foreach ( $paged_events as $timestamp => $events ) { |
|
| 327 | - if ( $timestamp <= $this->end ) { |
|
| 328 | - $date = Carbon::createFromTimestamp( $timestamp, $calendar->timezone )->endOfDay()->format( 'Ymd' ); |
|
| 329 | - $daily_events[ intval( $date ) ][] = $events; |
|
| 326 | + foreach ($paged_events as $timestamp => $events) { |
|
| 327 | + if ($timestamp <= $this->end) { |
|
| 328 | + $date = Carbon::createFromTimestamp($timestamp, $calendar->timezone)->endOfDay()->format('Ymd'); |
|
| 329 | + $daily_events[intval($date)][] = $events; |
|
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | - ksort( $daily_events, SORT_NUMERIC ); |
|
| 332 | + ksort($daily_events, SORT_NUMERIC); |
|
| 333 | 333 | |
| 334 | 334 | return $daily_events; |
| 335 | 335 | } |
@@ -347,71 +347,71 @@ discard block |
||
| 347 | 347 | private function get_heading() { |
| 348 | 348 | |
| 349 | 349 | $calendar = $this->calendar; |
| 350 | - $start = Carbon::createFromTimestamp( $this->start, $calendar->timezone ); |
|
| 351 | - $end = Carbon::createFromTimestamp( $this->end, $calendar->timezone ); |
|
| 350 | + $start = Carbon::createFromTimestamp($this->start, $calendar->timezone); |
|
| 351 | + $end = Carbon::createFromTimestamp($this->end, $calendar->timezone); |
|
| 352 | 352 | $date_format = $this->calendar->date_format; |
| 353 | - $date_order = simcal_get_date_format_order( $date_format ); |
|
| 353 | + $date_order = simcal_get_date_format_order($date_format); |
|
| 354 | 354 | |
| 355 | - if ( ( $start->day == $end->day ) && ( $start->month == $end->month ) && ( $start->year == $end->year ) ) { |
|
| 355 | + if (($start->day == $end->day) && ($start->month == $end->month) && ($start->year == $end->year)) { |
|
| 356 | 356 | // Start and end on the same day. |
| 357 | 357 | // e.g. 1 February 2020 |
| 358 | - $large = $small = date_i18n( $calendar->date_format , $this->start ); |
|
| 359 | - if ( ( $date_order['d'] !== false ) && ( $date_order['m'] !== false ) ) { |
|
| 360 | - if ( $date_order['m'] > $date_order['d'] ) { |
|
| 361 | - if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) { |
|
| 362 | - $small = date_i18n( 'Y, d M', $this->start ); |
|
| 358 | + $large = $small = date_i18n($calendar->date_format, $this->start); |
|
| 359 | + if (($date_order['d'] !== false) && ($date_order['m'] !== false)) { |
|
| 360 | + if ($date_order['m'] > $date_order['d']) { |
|
| 361 | + if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) { |
|
| 362 | + $small = date_i18n('Y, d M', $this->start); |
|
| 363 | 363 | } else { |
| 364 | - $small = date_i18n( 'd M Y', $this->start ); |
|
| 364 | + $small = date_i18n('d M Y', $this->start); |
|
| 365 | 365 | } |
| 366 | 366 | } else { |
| 367 | - if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) { |
|
| 368 | - $small = date_i18n( 'Y, M d', $this->start ); |
|
| 367 | + if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) { |
|
| 368 | + $small = date_i18n('Y, M d', $this->start); |
|
| 369 | 369 | } else { |
| 370 | - $small = date_i18n( 'M d Y', $this->start ); |
|
| 370 | + $small = date_i18n('M d Y', $this->start); |
|
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | - } elseif ( ( $start->month == $end->month ) && ( $start->year == $end->year ) ) { |
|
| 374 | + } elseif (($start->month == $end->month) && ($start->year == $end->year)) { |
|
| 375 | 375 | // Start and end days on the same month. |
| 376 | 376 | // e.g. August 2020 |
| 377 | - if ( $date_order['y'] === false ) { |
|
| 377 | + if ($date_order['y'] === false) { |
|
| 378 | 378 | // August. |
| 379 | - $large = $small = date_i18n( 'F', $this->start ); |
|
| 379 | + $large = $small = date_i18n('F', $this->start); |
|
| 380 | 380 | } else { |
| 381 | - if ( $date_order['y'] < $date_order['m'] ) { |
|
| 381 | + if ($date_order['y'] < $date_order['m']) { |
|
| 382 | 382 | // 2020 August. |
| 383 | - $large = date_i18n( 'Y F', $this->start ); |
|
| 384 | - $small = date_i18n( 'Y M', $this->start ); |
|
| 383 | + $large = date_i18n('Y F', $this->start); |
|
| 384 | + $small = date_i18n('Y M', $this->start); |
|
| 385 | 385 | } else { |
| 386 | 386 | // August 2020. |
| 387 | - $large = date_i18n( 'F Y', $this->start ); |
|
| 388 | - $small = date_i18n( 'M Y', $this->start ); |
|
| 387 | + $large = date_i18n('F Y', $this->start); |
|
| 388 | + $small = date_i18n('M Y', $this->start); |
|
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | - } elseif ( $start->year == $end->year ) { |
|
| 391 | + } elseif ($start->year == $end->year) { |
|
| 392 | 392 | // Start and end days on months of the same year. |
| 393 | 393 | // e.g. August - September 2020 |
| 394 | - if ( $date_order['y'] === false ) { |
|
| 394 | + if ($date_order['y'] === false) { |
|
| 395 | 395 | // August - September. |
| 396 | - $large = date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end ); |
|
| 397 | - $small = date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end ); |
|
| 396 | + $large = date_i18n('F', $this->start).' - '.date_i18n('F', $this->end); |
|
| 397 | + $small = date_i18n('M', $this->start).' - '.date_i18n('M', $this->end); |
|
| 398 | 398 | } else { |
| 399 | - if ( $date_order['y'] < $date_order['m'] ) { |
|
| 399 | + if ($date_order['y'] < $date_order['m']) { |
|
| 400 | 400 | // 2020, August - September. |
| 401 | - $large = $small = date( 'Y', $this->start ) . ', '; |
|
| 402 | - $large .= date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end ); |
|
| 403 | - $small .= date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end ); |
|
| 401 | + $large = $small = date('Y', $this->start).', '; |
|
| 402 | + $large .= date_i18n('F', $this->start).' - '.date_i18n('F', $this->end); |
|
| 403 | + $small .= date_i18n('M', $this->start).' - '.date_i18n('M', $this->end); |
|
| 404 | 404 | } else { |
| 405 | 405 | // August - September, 2020. |
| 406 | - $large = date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end ) . ', '; |
|
| 407 | - $small = date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end ) . ' '; |
|
| 408 | - $year = date( 'Y', $this->start ); |
|
| 406 | + $large = date_i18n('F', $this->start).' - '.date_i18n('F', $this->end).', '; |
|
| 407 | + $small = date_i18n('M', $this->start).' - '.date_i18n('M', $this->end).' '; |
|
| 408 | + $year = date('Y', $this->start); |
|
| 409 | 409 | $large .= $year; |
| 410 | 410 | $small .= $year; |
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | } else { |
| 414 | - $large = $small = date( 'Y', $this->start ) . ' - ' . date( 'Y', $this->end ); |
|
| 414 | + $large = $small = date('Y', $this->start).' - '.date('Y', $this->end); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | return array( |
@@ -433,133 +433,133 @@ discard block |
||
| 433 | 433 | * |
| 434 | 434 | * @return string |
| 435 | 435 | */ |
| 436 | - private function draw_list( $timestamp, $id = 0 ) { |
|
| 436 | + private function draw_list($timestamp, $id = 0) { |
|
| 437 | 437 | |
| 438 | 438 | $calendar = $this->calendar; |
| 439 | 439 | |
| 440 | - if ( empty( $calendar ) ) { |
|
| 441 | - $calendar = $this->calendar = simcal_get_calendar( intval( $id ) ); |
|
| 442 | - if ( ! $calendar instanceof Default_Calendar ) { |
|
| 440 | + if (empty($calendar)) { |
|
| 441 | + $calendar = $this->calendar = simcal_get_calendar(intval($id)); |
|
| 442 | + if ( ! $calendar instanceof Default_Calendar) { |
|
| 443 | 443 | return ''; |
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - $feed = simcal_get_feed( $calendar ); |
|
| 448 | - $feed_timezone = get_post_meta( $feed->post_id, '_feed_timezone', true ); |
|
| 447 | + $feed = simcal_get_feed($calendar); |
|
| 448 | + $feed_timezone = get_post_meta($feed->post_id, '_feed_timezone', true); |
|
| 449 | 449 | |
| 450 | 450 | $now = $calendar->now; |
| 451 | - $current_events = $this->get_events( $timestamp ); |
|
| 452 | - $day_format = explode( ' ', $calendar->date_format ); |
|
| 451 | + $current_events = $this->get_events($timestamp); |
|
| 452 | + $day_format = explode(' ', $calendar->date_format); |
|
| 453 | 453 | |
| 454 | 454 | ob_start(); |
| 455 | 455 | |
| 456 | 456 | // Draw the events. |
| 457 | 457 | |
| 458 | - $block_tag = $calendar->compact_list && ! empty( $current_events ) ? 'div' : 'dl'; |
|
| 458 | + $block_tag = $calendar->compact_list && ! empty($current_events) ? 'div' : 'dl'; |
|
| 459 | 459 | |
| 460 | 460 | $data_heading = ''; |
| 461 | 461 | $heading = $this->get_heading(); |
| 462 | - foreach ( $heading as $k => $v ) { |
|
| 463 | - $data_heading .= ' data-heading-' . $k . '="' . $v . '"'; |
|
| 462 | + foreach ($heading as $k => $v) { |
|
| 463 | + $data_heading .= ' data-heading-'.$k.'="'.$v.'"'; |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - echo '<' . $block_tag . ' class="simcal-events-list-container"' . |
|
| 467 | - ' data-prev="' . $this->prev . '"' . |
|
| 468 | - ' data-next="' . $this->next . '"' . |
|
| 469 | - $data_heading . '>'; |
|
| 466 | + echo '<'.$block_tag.' class="simcal-events-list-container"'. |
|
| 467 | + ' data-prev="'.$this->prev.'"'. |
|
| 468 | + ' data-next="'.$this->next.'"'. |
|
| 469 | + $data_heading.'>'; |
|
| 470 | 470 | |
| 471 | - if ( ! empty( $current_events ) && is_array( $current_events ) ) : |
|
| 471 | + if ( ! empty($current_events) && is_array($current_events)) : |
|
| 472 | 472 | |
| 473 | - foreach ( $current_events as $ymd => $events ) : |
|
| 473 | + foreach ($current_events as $ymd => $events) : |
|
| 474 | 474 | |
| 475 | 475 | |
| 476 | 476 | |
| 477 | 477 | // This is where we can find out if an event is a multi-day event and if it needs to be shown. |
| 478 | 478 | // Since this is for list view we are showing the event on the day viewed if it is part of that day even when |
| 479 | 479 | // expand multi-day events are turned off. |
| 480 | - if ( isset( $events[0][0]->multiple_days ) && $events[0][0]->multiple_days > 0 ) { |
|
| 481 | - if ( 'current_day_only' == get_post_meta($calendar->id, '_default_calendar_expand_multi_day_events', true ) ) { |
|
| 480 | + if (isset($events[0][0]->multiple_days) && $events[0][0]->multiple_days > 0) { |
|
| 481 | + if ('current_day_only' == get_post_meta($calendar->id, '_default_calendar_expand_multi_day_events', true)) { |
|
| 482 | 482 | |
| 483 | - $year = substr( $ymd, 0, 4 ); |
|
| 484 | - $month = substr( $ymd, 4, 2 ); |
|
| 485 | - $day = substr( $ymd, 6, 2 ); |
|
| 483 | + $year = substr($ymd, 0, 4); |
|
| 484 | + $month = substr($ymd, 4, 2); |
|
| 485 | + $day = substr($ymd, 6, 2); |
|
| 486 | 486 | |
| 487 | - $temp_date = Carbon::createFromDate( $year, $month, $day ); |
|
| 487 | + $temp_date = Carbon::createFromDate($year, $month, $day); |
|
| 488 | 488 | |
| 489 | - if( ! ( $temp_date < Carbon::now()->endOfDay() ) ) { |
|
| 489 | + if ( ! ($temp_date < Carbon::now()->endOfDay())) { |
|
| 490 | 490 | continue; |
| 491 | 491 | } |
| 492 | 492 | } |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | - $day_ts = Carbon::createFromFormat( 'Ymd', $ymd, $calendar->timezone )->getTimestamp(); |
|
| 495 | + $day_ts = Carbon::createFromFormat('Ymd', $ymd, $calendar->timezone)->getTimestamp(); |
|
| 496 | 496 | |
| 497 | - if ( ! $calendar->compact_list ) : |
|
| 497 | + if ( ! $calendar->compact_list) : |
|
| 498 | 498 | |
| 499 | - $date = new Carbon( 'now', $calendar->timezone ); |
|
| 500 | - $date->setLocale( substr( get_locale(), 0, 2 ) ); |
|
| 501 | - $date->setTimestamp( $day_ts ); |
|
| 499 | + $date = new Carbon('now', $calendar->timezone); |
|
| 500 | + $date->setLocale(substr(get_locale(), 0, 2)); |
|
| 501 | + $date->setTimestamp($day_ts); |
|
| 502 | 502 | |
| 503 | - if ( $date->isToday() ) { |
|
| 504 | - $the_color = new Color( $calendar->today_color ); |
|
| 503 | + if ($date->isToday()) { |
|
| 504 | + $the_color = new Color($calendar->today_color); |
|
| 505 | 505 | } else { |
| 506 | - $the_color = new Color( $calendar->days_events_color ); |
|
| 506 | + $the_color = new Color($calendar->days_events_color); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - $bg_color = '#' . $the_color->getHex(); |
|
| 509 | + $bg_color = '#'.$the_color->getHex(); |
|
| 510 | 510 | $color = $the_color->isDark() ? '#ffffff' : '#000000'; |
| 511 | - $border_style = ' style="border-bottom: 1px solid ' . $bg_color . ';" '; |
|
| 512 | - $bg_style = ' style="background-color: ' . $bg_color . '; color: ' . $color . ';"'; |
|
| 511 | + $border_style = ' style="border-bottom: 1px solid '.$bg_color.';" '; |
|
| 512 | + $bg_style = ' style="background-color: '.$bg_color.'; color: '.$color.';"'; |
|
| 513 | 513 | |
| 514 | - echo "\t" . '<dt class="simcal-day-label"' . $border_style . '>'; |
|
| 515 | - echo '<span' . $bg_style .'>'; |
|
| 516 | - foreach ( $day_format as $format ) { |
|
| 517 | - echo $format ? '<span class="simcal-date-format" data-date-format="' . $format . '">' . date_i18n( $format, $day_ts ) . '</span> ' : ' '; |
|
| 514 | + echo "\t".'<dt class="simcal-day-label"'.$border_style.'>'; |
|
| 515 | + echo '<span'.$bg_style.'>'; |
|
| 516 | + foreach ($day_format as $format) { |
|
| 517 | + echo $format ? '<span class="simcal-date-format" data-date-format="'.$format.'">'.date_i18n($format, $day_ts).'</span> ' : ' '; |
|
| 518 | 518 | } |
| 519 | 519 | echo '</span>'; |
| 520 | - echo '</dt>' . "\n"; |
|
| 520 | + echo '</dt>'."\n"; |
|
| 521 | 521 | |
| 522 | 522 | endif; |
| 523 | 523 | |
| 524 | - $list_events = '<ul class="simcal-events">' . "\n"; |
|
| 524 | + $list_events = '<ul class="simcal-events">'."\n"; |
|
| 525 | 525 | |
| 526 | 526 | $calendar_classes = array(); |
| 527 | - $day_classes = 'simcal-weekday-' . date( 'w', $day_ts ); |
|
| 527 | + $day_classes = 'simcal-weekday-'.date('w', $day_ts); |
|
| 528 | 528 | |
| 529 | 529 | // Is this the present, the past or the future, Doc? |
| 530 | - if ( $timestamp <= $now && $timestamp >= $now ) { |
|
| 530 | + if ($timestamp <= $now && $timestamp >= $now) { |
|
| 531 | 531 | $day_classes .= ' simcal-today simcal-present simcal-day'; |
| 532 | - } elseif ( $timestamp < $now ) { |
|
| 532 | + } elseif ($timestamp < $now) { |
|
| 533 | 533 | $day_classes .= ' simcal-past simcal-day'; |
| 534 | - } elseif ( $this->end > $now ) { |
|
| 534 | + } elseif ($this->end > $now) { |
|
| 535 | 535 | $day_classes .= ' simcal-future simcal-day'; |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | $count = 0; |
| 539 | 539 | |
| 540 | - foreach ( $events as $day_events ) : |
|
| 541 | - foreach ( $day_events as $event ) : |
|
| 540 | + foreach ($events as $day_events) : |
|
| 541 | + foreach ($day_events as $event) : |
|
| 542 | 542 | |
| 543 | - if ( $event instanceof Event ) : |
|
| 543 | + if ($event instanceof Event) : |
|
| 544 | 544 | |
| 545 | - if ( $feed->type == 'grouped-calendars' ) { |
|
| 546 | - date_default_timezone_set( $feed_timezone ); |
|
| 545 | + if ($feed->type == 'grouped-calendars') { |
|
| 546 | + date_default_timezone_set($feed_timezone); |
|
| 547 | 547 | } else { |
| 548 | - date_default_timezone_set( $event->timezone ); |
|
| 548 | + date_default_timezone_set($event->timezone); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | $event_classes = $event_visibility = ''; |
| 552 | 552 | |
| 553 | - $calendar_class = 'simcal-events-calendar-' . strval( $event->calendar ); |
|
| 553 | + $calendar_class = 'simcal-events-calendar-'.strval($event->calendar); |
|
| 554 | 554 | $calendar_classes[] = $calendar_class; |
| 555 | 555 | |
| 556 | 556 | $recurring = $event->recurrence ? 'simcal-event-recurring ' : ''; |
| 557 | 557 | $has_location = $event->venue ? 'simcal-event-has-location ' : ''; |
| 558 | 558 | |
| 559 | - $event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class; |
|
| 559 | + $event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class; |
|
| 560 | 560 | |
| 561 | 561 | // Toggle some events visibility if more than optional limit. |
| 562 | - if ( ( $calendar->events_limit > - 1 ) && ( $count >= $calendar->events_limit ) ) : |
|
| 562 | + if (($calendar->events_limit > - 1) && ($count >= $calendar->events_limit)) : |
|
| 563 | 563 | $event_classes .= ' simcal-event-toggled'; |
| 564 | 564 | $event_visibility = ' style="display: none"'; |
| 565 | 565 | endif; |
@@ -567,75 +567,75 @@ discard block |
||
| 567 | 567 | $event_color = ''; |
| 568 | 568 | $bullet = ''; |
| 569 | 569 | $event_color = $event->get_color(); |
| 570 | - if ( ! empty( $event_color ) ) { |
|
| 570 | + if ( ! empty($event_color)) { |
|
| 571 | 571 | $side = is_rtl() ? 'right' : 'left'; |
| 572 | - $event_color = ' style="border-' . $side . ': 4px solid ' . $event_color . '; padding-' . $side . ': 8px;"'; |
|
| 572 | + $event_color = ' style="border-'.$side.': 4px solid '.$event_color.'; padding-'.$side.': 8px;"'; |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - $list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . $event_color . ' itemscope itemtype="http://schema.org/Event">' . "\n"; |
|
| 576 | - $list_events .= "\t\t" . '<div class="simcal-event-details">' . $calendar->get_event_html( $event ) . '</div>' . "\n"; |
|
| 577 | - $list_events .= "\t" . '</li>' . "\n"; |
|
| 575 | + $list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.$event_color.' itemscope itemtype="http://schema.org/Event">'."\n"; |
|
| 576 | + $list_events .= "\t\t".'<div class="simcal-event-details">'.$calendar->get_event_html($event).'</div>'."\n"; |
|
| 577 | + $list_events .= "\t".'</li>'."\n"; |
|
| 578 | 578 | |
| 579 | - $count ++; |
|
| 579 | + $count++; |
|
| 580 | 580 | |
| 581 | 581 | // Event falls within today. |
| 582 | - if ( ( $this->end <= $now ) && ( $this->start >= $now ) ) : |
|
| 582 | + if (($this->end <= $now) && ($this->start >= $now)) : |
|
| 583 | 583 | $day_classes .= ' simcal-today-has-events'; |
| 584 | 584 | endif; |
| 585 | - $day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events'; |
|
| 585 | + $day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events'; |
|
| 586 | 586 | |
| 587 | - if ( $calendar_classes ) : |
|
| 588 | - $day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) ); |
|
| 587 | + if ($calendar_classes) : |
|
| 588 | + $day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes))); |
|
| 589 | 589 | endif; |
| 590 | 590 | |
| 591 | 591 | endif; |
| 592 | 592 | endforeach; |
| 593 | 593 | endforeach; |
| 594 | 594 | |
| 595 | - $list_events .= '</ul>' . "\n"; |
|
| 595 | + $list_events .= '</ul>'."\n"; |
|
| 596 | 596 | |
| 597 | 597 | // If events visibility is limited, print the button toggle. |
| 598 | - if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) : |
|
| 598 | + if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) : |
|
| 599 | 599 | $list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>'; |
| 600 | 600 | endif; |
| 601 | 601 | |
| 602 | 602 | // Print final list of events for the current day. |
| 603 | 603 | $tag = $calendar->compact_list ? 'div' : 'dd'; |
| 604 | - echo '<' . $tag . ' class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n"; |
|
| 605 | - echo "\t" . $list_events . "\n"; |
|
| 606 | - echo '</' . $tag . '>' . "\n"; |
|
| 604 | + echo '<'.$tag.' class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n"; |
|
| 605 | + echo "\t".$list_events."\n"; |
|
| 606 | + echo '</'.$tag.'>'."\n"; |
|
| 607 | 607 | |
| 608 | 608 | endforeach; |
| 609 | 609 | |
| 610 | 610 | else : |
| 611 | 611 | |
| 612 | - echo "\t" . '<p>'; |
|
| 612 | + echo "\t".'<p>'; |
|
| 613 | 613 | |
| 614 | - $message = get_post_meta( $calendar->id, '_no_events_message', true ); |
|
| 614 | + $message = get_post_meta($calendar->id, '_no_events_message', true); |
|
| 615 | 615 | |
| 616 | - if ( 'events' == $calendar->group_type ) { |
|
| 617 | - echo ! empty( $message ) ? $message : __( 'Nothing to show.', 'google-calendar-events' ); |
|
| 616 | + if ('events' == $calendar->group_type) { |
|
| 617 | + echo ! empty($message) ? $message : __('Nothing to show.', 'google-calendar-events'); |
|
| 618 | 618 | } else { |
| 619 | - if ( ! empty( $message ) ) { |
|
| 619 | + if ( ! empty($message)) { |
|
| 620 | 620 | echo $message; |
| 621 | 621 | } else { |
| 622 | - $from = Carbon::createFromTimestamp( $this->start, $calendar->timezone )->getTimestamp(); |
|
| 623 | - $to = Carbon::createFromTimestamp( $this->end, $calendar->timezone )->getTimestamp(); |
|
| 624 | - echo apply_filters( 'simcal_no_events_message', sprintf( |
|
| 625 | - __( 'Nothing from %1$s to %2$s.', 'google-calendar-events' ), |
|
| 626 | - date_i18n( $calendar->date_format, $from ), |
|
| 627 | - date_i18n( $calendar->date_format, $to ) |
|
| 628 | - ), $calendar->id, $from, $to ); |
|
| 622 | + $from = Carbon::createFromTimestamp($this->start, $calendar->timezone)->getTimestamp(); |
|
| 623 | + $to = Carbon::createFromTimestamp($this->end, $calendar->timezone)->getTimestamp(); |
|
| 624 | + echo apply_filters('simcal_no_events_message', sprintf( |
|
| 625 | + __('Nothing from %1$s to %2$s.', 'google-calendar-events'), |
|
| 626 | + date_i18n($calendar->date_format, $from), |
|
| 627 | + date_i18n($calendar->date_format, $to) |
|
| 628 | + ), $calendar->id, $from, $to); |
|
| 629 | 629 | } |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - echo "\t" . '</p>' . "\n"; |
|
| 632 | + echo "\t".'</p>'."\n"; |
|
| 633 | 633 | |
| 634 | 634 | endif; |
| 635 | 635 | |
| 636 | - echo '</' . $block_tag . '>'; |
|
| 636 | + echo '</'.$block_tag.'>'; |
|
| 637 | 637 | |
| 638 | - date_default_timezone_set( $calendar->site_timezone ); |
|
| 638 | + date_default_timezone_set($calendar->site_timezone); |
|
| 639 | 639 | |
| 640 | 640 | return ob_get_clean(); |
| 641 | 641 | } |
@@ -647,16 +647,16 @@ discard block |
||
| 647 | 647 | */ |
| 648 | 648 | public function draw_list_ajax() { |
| 649 | 649 | |
| 650 | - if ( isset( $_POST['ts'] ) && isset( $_POST['id'] ) ) { |
|
| 650 | + if (isset($_POST['ts']) && isset($_POST['id'])) { |
|
| 651 | 651 | |
| 652 | - $ts = absint( $_POST['ts'] ); |
|
| 653 | - $id = absint( $_POST['id'] ); |
|
| 652 | + $ts = absint($_POST['ts']); |
|
| 653 | + $id = absint($_POST['id']); |
|
| 654 | 654 | |
| 655 | - wp_send_json_success( $this->draw_list( $ts, $id ) ); |
|
| 655 | + wp_send_json_success($this->draw_list($ts, $id)); |
|
| 656 | 656 | |
| 657 | 657 | } else { |
| 658 | 658 | |
| 659 | - wp_send_json_error( 'Missing arguments in default calendar list ajax request.' ); |
|
| 659 | + wp_send_json_error('Missing arguments in default calendar list ajax request.'); |
|
| 660 | 660 | |
| 661 | 661 | } |
| 662 | 662 | } |
@@ -671,8 +671,8 @@ discard block |
||
| 671 | 671 | * |
| 672 | 672 | * @return bool |
| 673 | 673 | */ |
| 674 | - private function filter_events_before( $event ) { |
|
| 675 | - return intval( $event ) >= intval( $this->start ); |
|
| 674 | + private function filter_events_before($event) { |
|
| 675 | + return intval($event) >= intval($this->start); |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | /** |
@@ -685,8 +685,8 @@ discard block |
||
| 685 | 685 | * |
| 686 | 686 | * @return bool |
| 687 | 687 | */ |
| 688 | - private function filter_events_after( $event ) { |
|
| 689 | - return intval( $event ) < intval( $this->end ); |
|
| 688 | + private function filter_events_after($event) { |
|
| 689 | + return intval($event) < intval($this->end); |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | } |
@@ -353,9 +353,9 @@ |
||
| 353 | 353 | */ |
| 354 | 354 | public function __toString() |
| 355 | 355 | { |
| 356 | - return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n" . |
|
| 357 | - "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n" . |
|
| 358 | - "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n" . |
|
| 356 | + return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n". |
|
| 357 | + "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n". |
|
| 358 | + "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n". |
|
| 359 | 359 | "<strong>Platform:</strong> {$this->getPlatform()}<br/>"; |
| 360 | 360 | } |
| 361 | 361 | |
@@ -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 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
| 787 | - $poweredby = isset( $settings['poweredby']['opt_in'] ) ? $settings['poweredby']['opt_in'] : ''; |
|
| 786 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
| 787 | + $poweredby = isset($settings['poweredby']['opt_in']) ? $settings['poweredby']['opt_in'] : ''; |
|
| 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 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | use SimpleCalendar\Abstracts\Feed; |
| 11 | 11 | use SimpleCalendar\Feeds\Admin\Grouped_Calendars_Admin; |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -38,22 +38,22 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param string|Calendar $calendar |
| 40 | 40 | */ |
| 41 | - public function __construct( $calendar = '' ) { |
|
| 41 | + public function __construct($calendar = '') { |
|
| 42 | 42 | |
| 43 | - parent::__construct( $calendar ); |
|
| 43 | + parent::__construct($calendar); |
|
| 44 | 44 | |
| 45 | 45 | $this->type = 'grouped-calendars'; |
| 46 | - $this->name = __( 'Grouped Calendar', 'google-calendar-events' ); |
|
| 46 | + $this->name = __('Grouped Calendar', 'google-calendar-events'); |
|
| 47 | 47 | |
| 48 | - if ( $this->post_id > 0 ) { |
|
| 48 | + if ($this->post_id > 0) { |
|
| 49 | 49 | $this->set_source(); |
| 50 | - if ( ! is_admin() || defined( 'DOING_AJAX' ) ) { |
|
| 50 | + if ( ! is_admin() || defined('DOING_AJAX')) { |
|
| 51 | 51 | $this->events = $this->get_events(); |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 56 | - new Grouped_Calendars_Admin( $this ); |
|
| 55 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
| 56 | + new Grouped_Calendars_Admin($this); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
@@ -64,38 +64,38 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @param array $ids Array of calendar ids. |
| 66 | 66 | */ |
| 67 | - public function set_source( $ids = array() ) { |
|
| 67 | + public function set_source($ids = array()) { |
|
| 68 | 68 | |
| 69 | - $source = get_post_meta( $this->post_id, '_grouped_calendars_source', true ); |
|
| 69 | + $source = get_post_meta($this->post_id, '_grouped_calendars_source', true); |
|
| 70 | 70 | |
| 71 | - if ( 'ids' == $source ) { |
|
| 71 | + if ('ids' == $source) { |
|
| 72 | 72 | |
| 73 | - if ( empty( $ids ) ) { |
|
| 74 | - $ids = get_post_meta( $this->post_id, '_grouped_calendars_ids', true ); |
|
| 73 | + if (empty($ids)) { |
|
| 74 | + $ids = get_post_meta($this->post_id, '_grouped_calendars_ids', true); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $this->calendars_ids = ! empty( $ids ) && is_array( $ids ) ? array_map( 'absint', $ids ) : array(); |
|
| 77 | + $this->calendars_ids = ! empty($ids) && is_array($ids) ? array_map('absint', $ids) : array(); |
|
| 78 | 78 | |
| 79 | - } elseif ( 'category' == $source ) { |
|
| 79 | + } elseif ('category' == $source) { |
|
| 80 | 80 | |
| 81 | - $categories = get_post_meta( $this->post_id, '_grouped_calendars_category', true ); |
|
| 81 | + $categories = get_post_meta($this->post_id, '_grouped_calendars_category', true); |
|
| 82 | 82 | |
| 83 | - if ( $categories && is_array( $categories ) ) { |
|
| 83 | + if ($categories && is_array($categories)) { |
|
| 84 | 84 | |
| 85 | 85 | $tax_query = array( |
| 86 | 86 | 'taxonomy' => 'calendar_category', |
| 87 | 87 | 'field' => 'term_id', |
| 88 | - 'terms' => array_map( 'absint', $categories ), |
|
| 88 | + 'terms' => array_map('absint', $categories), |
|
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | - $calendars = get_posts( array( |
|
| 91 | + $calendars = get_posts(array( |
|
| 92 | 92 | 'post_type' => 'calendar', |
| 93 | - 'tax_query' => array( $tax_query ), |
|
| 93 | + 'tax_query' => array($tax_query), |
|
| 94 | 94 | 'nopaging' => true, |
| 95 | 95 | 'fields' => 'ids', |
| 96 | - ) ); |
|
| 96 | + )); |
|
| 97 | 97 | |
| 98 | - $this->calendars_ids = ! empty( $calendars ) && is_array( $calendars ) ? $calendars : array(); |
|
| 98 | + $this->calendars_ids = ! empty($calendars) && is_array($calendars) ? $calendars : array(); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | } |
@@ -111,57 +111,57 @@ discard block |
||
| 111 | 111 | public function get_events() { |
| 112 | 112 | |
| 113 | 113 | $ids = $this->calendars_ids; |
| 114 | - $events = get_transient( '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type ); |
|
| 114 | + $events = get_transient('_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type); |
|
| 115 | 115 | |
| 116 | - if ( empty( $events ) && ! empty( $ids ) && is_array( $ids ) ) { |
|
| 116 | + if (empty($events) && ! empty($ids) && is_array($ids)) { |
|
| 117 | 117 | |
| 118 | 118 | $events = array(); |
| 119 | 119 | |
| 120 | - foreach ( $ids as $cal_id ) { |
|
| 120 | + foreach ($ids as $cal_id) { |
|
| 121 | 121 | |
| 122 | - $calendar = simcal_get_calendar( intval( $cal_id ) ); |
|
| 122 | + $calendar = simcal_get_calendar(intval($cal_id)); |
|
| 123 | 123 | |
| 124 | - simcal_delete_feed_transients( $cal_id ); |
|
| 124 | + simcal_delete_feed_transients($cal_id); |
|
| 125 | 125 | |
| 126 | - if ( $calendar instanceof Calendar ) { |
|
| 126 | + if ($calendar instanceof Calendar) { |
|
| 127 | 127 | |
| 128 | 128 | // Sometimes the calendars might have events at the same time from different calendars |
| 129 | 129 | // When merging the arrays together some of the events will be lost because the keys are the same and one will overwrite the other |
| 130 | 130 | // This snippet checks if the key already exists in the master events array and if it does it subtracts 1 from it to make the key unique and then unsets the original key. |
| 131 | - foreach( $calendar->events as $k => $v ) { |
|
| 132 | - $calendar->events[ $this->update_array_timestamp( $events, $k ) ] = $v; |
|
| 131 | + foreach ($calendar->events as $k => $v) { |
|
| 132 | + $calendar->events[$this->update_array_timestamp($events, $k)] = $v; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $events = is_array( $calendar->events ) ? $events + $calendar->events : $events; |
|
| 135 | + $events = is_array($calendar->events) ? $events + $calendar->events : $events; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if ( ! empty( $events ) ) { |
|
| 140 | + if ( ! empty($events)) { |
|
| 141 | 141 | |
| 142 | 142 | // Trim events to set the earliest one as specified in feed settings. |
| 143 | - $earliest_event = intval( $this->time_min ); |
|
| 144 | - if ( $earliest_event > 0 ) { |
|
| 145 | - $events = $this->array_filter_key( $events, array( $this, 'filter_events_before' ) ); |
|
| 143 | + $earliest_event = intval($this->time_min); |
|
| 144 | + if ($earliest_event > 0) { |
|
| 145 | + $events = $this->array_filter_key($events, array($this, 'filter_events_before')); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // Trim events to set the latest one as specified in feed settings. |
| 149 | - $latest_event = intval( $this->time_max ); |
|
| 150 | - if ( $latest_event > 0 ) { |
|
| 151 | - $events = $this->array_filter_key( $events, array( $this, 'filter_events_after' ) ); |
|
| 149 | + $latest_event = intval($this->time_max); |
|
| 150 | + if ($latest_event > 0) { |
|
| 151 | + $events = $this->array_filter_key($events, array($this, 'filter_events_after')); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | set_transient( |
| 155 | - '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type, |
|
| 155 | + '_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type, |
|
| 156 | 156 | $events, |
| 157 | - absint( $this->cache ) |
|
| 157 | + absint($this->cache) |
|
| 158 | 158 | ); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // Sort events by start time before returning |
| 164 | - uasort( $events, array( $this, 'sort_by_start_time' ) ); |
|
| 164 | + uasort($events, array($this, 'sort_by_start_time')); |
|
| 165 | 165 | |
| 166 | 166 | return $events; |
| 167 | 167 | } |
@@ -169,10 +169,10 @@ discard block |
||
| 169 | 169 | /* |
| 170 | 170 | * Recursive function to adjust the timestamp array indices that are the same. |
| 171 | 171 | */ |
| 172 | - public function update_array_timestamp( $arr, $i ) { |
|
| 172 | + public function update_array_timestamp($arr, $i) { |
|
| 173 | 173 | |
| 174 | - if ( array_key_exists( $i, $arr ) ) { |
|
| 175 | - $i = $this->update_array_timestamp( $arr, $i - 1 ); |
|
| 174 | + if (array_key_exists($i, $arr)) { |
|
| 175 | + $i = $this->update_array_timestamp($arr, $i - 1); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | return $i; |
@@ -184,12 +184,12 @@ discard block |
||
| 184 | 184 | * @since 3.0.13 |
| 185 | 185 | * @access private |
| 186 | 186 | */ |
| 187 | - private function sort_by_start_time( $a, $b ) { |
|
| 188 | - if ( $a == $b ) { |
|
| 187 | + private function sort_by_start_time($a, $b) { |
|
| 188 | + if ($a == $b) { |
|
| 189 | 189 | return 0; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - return ( $a[0]->start < $b[0]->start ) ? -1 : 1; |
|
| 192 | + return ($a[0]->start < $b[0]->start) ? -1 : 1; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return array |
| 209 | 209 | */ |
| 210 | - private function array_filter_key( array $array, $callback ) { |
|
| 211 | - $matched_keys = array_filter( array_keys( $array ), $callback ); |
|
| 212 | - return array_intersect_key( $array, array_flip( $matched_keys ) ); |
|
| 210 | + private function array_filter_key(array $array, $callback) { |
|
| 211 | + $matched_keys = array_filter(array_keys($array), $callback); |
|
| 212 | + return array_intersect_key($array, array_flip($matched_keys)); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -222,9 +222,9 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @return bool |
| 224 | 224 | */ |
| 225 | - private function filter_events_before( $event ) { |
|
| 226 | - if ( $this->time_min !== 0 ) { |
|
| 227 | - return intval( $event ) > intval( $this->time_min ); |
|
| 225 | + private function filter_events_before($event) { |
|
| 226 | + if ($this->time_min !== 0) { |
|
| 227 | + return intval($event) > intval($this->time_min); |
|
| 228 | 228 | } |
| 229 | 229 | return true; |
| 230 | 230 | } |
@@ -239,9 +239,9 @@ discard block |
||
| 239 | 239 | * |
| 240 | 240 | * @return bool |
| 241 | 241 | */ |
| 242 | - private function filter_events_after( $event ) { |
|
| 243 | - if ( $this->time_max !== 0 ) { |
|
| 244 | - return intval( $event ) < intval( $this->time_max ); |
|
| 242 | + private function filter_events_after($event) { |
|
| 243 | + if ($this->time_max !== 0) { |
|
| 244 | + return intval($event) < intval($this->time_max); |
|
| 245 | 245 | } |
| 246 | 246 | return true; |
| 247 | 247 | } |