@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts as Object; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -31,27 +31,27 @@ discard block |
||
31 | 31 | public function __construct() { |
32 | 32 | |
33 | 33 | // Add default feed type. |
34 | - add_filter( 'simcal_get_feed_types', function( $feed_types ) { |
|
35 | - return array_merge( $feed_types, array( |
|
34 | + add_filter('simcal_get_feed_types', function($feed_types) { |
|
35 | + return array_merge($feed_types, array( |
|
36 | 36 | 'google', |
37 | 37 | 'grouped-calendars', |
38 | - ) ); |
|
39 | - }, 10, 1 ); |
|
38 | + )); |
|
39 | + }, 10, 1); |
|
40 | 40 | |
41 | 41 | // Add default calendar type. |
42 | - add_filter( 'simcal_get_calendar_types', function( $calendar_types ) { |
|
43 | - return array_merge( $calendar_types, array( |
|
42 | + add_filter('simcal_get_calendar_types', function($calendar_types) { |
|
43 | + return array_merge($calendar_types, array( |
|
44 | 44 | 'default-calendar' => array( |
45 | 45 | 'grid', |
46 | 46 | 'list', |
47 | 47 | ), |
48 | - ) ); |
|
49 | - }, 10, 1 ); |
|
48 | + )); |
|
49 | + }, 10, 1); |
|
50 | 50 | |
51 | 51 | // Add default admin objects. |
52 | - if ( $is_admin = is_admin() ) { |
|
53 | - add_filter( 'simcal_get_admin_pages', function( $admin_pages ) { |
|
54 | - return array_merge( $admin_pages, array( |
|
52 | + if ($is_admin = is_admin()) { |
|
53 | + add_filter('simcal_get_admin_pages', function($admin_pages) { |
|
54 | + return array_merge($admin_pages, array( |
|
55 | 55 | 'add-ons' => array( |
56 | 56 | 'add-ons', |
57 | 57 | ), |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | 'tools' => array( |
64 | 64 | 'system-status', |
65 | 65 | ), |
66 | - ) ); |
|
67 | - }, 10, 1 ); |
|
66 | + )); |
|
67 | + }, 10, 1); |
|
68 | 68 | } |
69 | 69 | |
70 | - do_action( 'simcal_load_objects', $is_admin ); |
|
70 | + do_action('simcal_load_objects', $is_admin); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @return array |
79 | 79 | */ |
80 | 80 | public function get_feed_types() { |
81 | - $array = apply_filters( 'simcal_get_feed_types', array() ); |
|
82 | - ksort( $array ); |
|
81 | + $array = apply_filters('simcal_get_feed_types', array()); |
|
82 | + ksort($array); |
|
83 | 83 | return $array; |
84 | 84 | } |
85 | 85 | |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | * @return array |
92 | 92 | */ |
93 | 93 | public function get_calendar_types() { |
94 | - $array = apply_filters( 'simcal_get_calendar_types', array() ); |
|
95 | - ksort( $array ); |
|
94 | + $array = apply_filters('simcal_get_calendar_types', array()); |
|
95 | + ksort($array); |
|
96 | 96 | return $array; |
97 | 97 | } |
98 | 98 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @return array |
105 | 105 | */ |
106 | 106 | public function get_admin_pages() { |
107 | - return apply_filters( 'simcal_get_admin_pages', array() ); |
|
107 | + return apply_filters('simcal_get_admin_pages', array()); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -118,30 +118,30 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return null|Object\Calendar |
120 | 120 | */ |
121 | - public function get_calendar( $object ) { |
|
121 | + public function get_calendar($object) { |
|
122 | 122 | |
123 | - if ( is_string( $object ) ) { |
|
124 | - return ! empty( $object ) ? $this->get_object( $object, 'calendar', '' ) : null; |
|
123 | + if (is_string($object)) { |
|
124 | + return ! empty($object) ? $this->get_object($object, 'calendar', '') : null; |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( is_object( $object ) ) { |
|
128 | - if ( $object instanceof Object\Calendar ) { |
|
129 | - return $this->get_object( $object->type, 'feed', $object ); |
|
130 | - } elseif ( $object instanceof \WP_Post ) { |
|
131 | - if ( $type = wp_get_object_terms( $object->ID, 'calendar_type' ) ) { |
|
132 | - $name = sanitize_title( current( $type )->name ); |
|
133 | - return $this->get_object( $name, 'calendar', $object ); |
|
127 | + if (is_object($object)) { |
|
128 | + if ($object instanceof Object\Calendar) { |
|
129 | + return $this->get_object($object->type, 'feed', $object); |
|
130 | + } elseif ($object instanceof \WP_Post) { |
|
131 | + if ($type = wp_get_object_terms($object->ID, 'calendar_type')) { |
|
132 | + $name = sanitize_title(current($type)->name); |
|
133 | + return $this->get_object($name, 'calendar', $object); |
|
134 | 134 | } |
135 | - } elseif ( isset( $object->type ) && isset( $object->id ) ) { |
|
136 | - return $this->get_object( $object->type, 'calendar', $object->id ); |
|
135 | + } elseif (isset($object->type) && isset($object->id)) { |
|
136 | + return $this->get_object($object->type, 'calendar', $object->id); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - if ( is_int( $object ) ) { |
|
141 | - $post = get_post( $object ); |
|
142 | - if ( $post && ( $type = wp_get_object_terms( $post->ID, 'calendar_type' ) ) ) { |
|
143 | - $name = sanitize_title( current( $type )->name ); |
|
144 | - return $this->get_object( $name, 'calendar', $post ); |
|
140 | + if (is_int($object)) { |
|
141 | + $post = get_post($object); |
|
142 | + if ($post && ($type = wp_get_object_terms($post->ID, 'calendar_type'))) { |
|
143 | + $name = sanitize_title(current($type)->name); |
|
144 | + return $this->get_object($name, 'calendar', $post); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
@@ -158,20 +158,20 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @return null|Object\Calendar_View |
160 | 160 | */ |
161 | - public function get_calendar_view( $id = 0, $name = '' ) { |
|
161 | + public function get_calendar_view($id = 0, $name = '') { |
|
162 | 162 | |
163 | - if ( ! $name && $id > 0 ) { |
|
163 | + if ( ! $name && $id > 0) { |
|
164 | 164 | |
165 | - $calendar_view = get_post_meta( $id, '_calendar_view', true ); |
|
165 | + $calendar_view = get_post_meta($id, '_calendar_view', true); |
|
166 | 166 | |
167 | - if ( $terms = wp_get_object_terms( $id, 'calendar_type' ) ) { |
|
168 | - $calendar_type = sanitize_title( current( $terms )->name ); |
|
169 | - $name = isset( $calendar_view[ $calendar_type ] ) ? $calendar_type . '-' . $calendar_view[ $calendar_type ] : ''; |
|
167 | + if ($terms = wp_get_object_terms($id, 'calendar_type')) { |
|
168 | + $calendar_type = sanitize_title(current($terms)->name); |
|
169 | + $name = isset($calendar_view[$calendar_type]) ? $calendar_type.'-'.$calendar_view[$calendar_type] : ''; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | } |
173 | 173 | |
174 | - return $name ? $this->get_object( $name, 'calendar-view', '' ) : null; |
|
174 | + return $name ? $this->get_object($name, 'calendar-view', '') : null; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -185,34 +185,34 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return null|Object\Feed |
187 | 187 | */ |
188 | - public function get_feed( $object ) { |
|
188 | + public function get_feed($object) { |
|
189 | 189 | |
190 | - if ( is_string( $object ) ) { |
|
191 | - return ! empty( $object ) ? $this->get_object( $object, 'feed', '' ) : null; |
|
190 | + if (is_string($object)) { |
|
191 | + return ! empty($object) ? $this->get_object($object, 'feed', '') : null; |
|
192 | 192 | } |
193 | 193 | |
194 | - if ( is_object( $object ) ) { |
|
195 | - if ( $object instanceof Object\Calendar ) { |
|
194 | + if (is_object($object)) { |
|
195 | + if ($object instanceof Object\Calendar) { |
|
196 | 196 | $feed_name = ''; |
197 | - if ( empty( $object->feed ) ) { |
|
198 | - if ( $feed_type = wp_get_object_terms( $object->id, 'feed_type' ) ) { |
|
199 | - $feed_name = sanitize_title( current( $feed_type )->name ); |
|
197 | + if (empty($object->feed)) { |
|
198 | + if ($feed_type = wp_get_object_terms($object->id, 'feed_type')) { |
|
199 | + $feed_name = sanitize_title(current($feed_type)->name); |
|
200 | 200 | } |
201 | 201 | } else { |
202 | 202 | $feed_name = $object->feed; |
203 | 203 | } |
204 | - return $this->get_object( $feed_name, 'feed', $object ); |
|
205 | - } elseif ( $object instanceof \WP_Post ) { |
|
206 | - $calendar = $this->get_calendar( $object ); |
|
207 | - return $this->get_object( $calendar->feed, 'feed', $calendar ); |
|
208 | - } elseif ( isset( $object->feed ) && isset( $object->id ) ) { |
|
209 | - return $this->get_object( $object->feed, 'feed', $object ); |
|
204 | + return $this->get_object($feed_name, 'feed', $object); |
|
205 | + } elseif ($object instanceof \WP_Post) { |
|
206 | + $calendar = $this->get_calendar($object); |
|
207 | + return $this->get_object($calendar->feed, 'feed', $calendar); |
|
208 | + } elseif (isset($object->feed) && isset($object->id)) { |
|
209 | + return $this->get_object($object->feed, 'feed', $object); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
213 | - if ( is_int( $object ) ) { |
|
214 | - $calendar = $this->get_calendar( $object ); |
|
215 | - return isset( $calendar->feed ) ? $this->get_object( $calendar->feed, 'feed', $calendar ) : null; |
|
213 | + if (is_int($object)) { |
|
214 | + $calendar = $this->get_calendar($object); |
|
215 | + return isset($calendar->feed) ? $this->get_object($calendar->feed, 'feed', $calendar) : null; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | return null; |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @return null|Object\Field |
230 | 230 | */ |
231 | - public function get_field( $args, $name = '' ) { |
|
231 | + public function get_field($args, $name = '') { |
|
232 | 232 | |
233 | - if ( empty( $name ) ) { |
|
234 | - $name = isset( $args['type'] ) ? $args['type'] : false; |
|
233 | + if (empty($name)) { |
|
234 | + $name = isset($args['type']) ? $args['type'] : false; |
|
235 | 235 | } |
236 | 236 | |
237 | - return $name ? $this->get_object( $name, 'field', $args ) : null; |
|
237 | + return $name ? $this->get_object($name, 'field', $args) : null; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @return null|Object\Admin_Page |
248 | 248 | */ |
249 | - public function get_admin_page( $name ) { |
|
250 | - return $name ? $this->get_object( $name, 'admin-page' ) : null; |
|
249 | + public function get_admin_page($name) { |
|
250 | + return $name ? $this->get_object($name, 'admin-page') : null; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * |
263 | 263 | * @return null|Object |
264 | 264 | */ |
265 | - private function get_object( $name, $type, $args = '' ) { |
|
265 | + private function get_object($name, $type, $args = '') { |
|
266 | 266 | |
267 | 267 | $types = array( |
268 | 268 | 'admin-page', |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | 'field', |
273 | 273 | ); |
274 | 274 | |
275 | - if ( in_array( $type, $types ) ) { |
|
275 | + if (in_array($type, $types)) { |
|
276 | 276 | |
277 | - $class_name = $this->make_class_name( $name, $type ); |
|
278 | - $parent = '\\' . __NAMESPACE__ . '\Abstracts\\' . implode( '_', array_map( 'ucfirst', explode( '-', $type ) ) ); |
|
279 | - $class = class_exists( $class_name ) ? new $class_name( $args ) : false; |
|
277 | + $class_name = $this->make_class_name($name, $type); |
|
278 | + $parent = '\\'.__NAMESPACE__.'\Abstracts\\'.implode('_', array_map('ucfirst', explode('-', $type))); |
|
279 | + $class = class_exists($class_name) ? new $class_name($args) : false; |
|
280 | 280 | |
281 | 281 | return $class instanceof $parent ? $class : null; |
282 | 282 | } |
@@ -298,25 +298,25 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @return string The class name complete with its full namespace. |
300 | 300 | */ |
301 | - private function make_class_name( $name, $type ) { |
|
302 | - |
|
303 | - if ( 'calendar' == $type ) { |
|
304 | - $namespace = '\\' . __NAMESPACE__ . '\Calendars\\'; |
|
305 | - } elseif ( 'calendar-view' == $type ) { |
|
306 | - $namespace = '\\' . __NAMESPACE__ . '\Calendars\Views\\'; |
|
307 | - } elseif ( 'feed' == $type ) { |
|
308 | - $namespace = '\\' . __NAMESPACE__ . '\Feeds\\'; |
|
309 | - } elseif ( 'field' == $type ) { |
|
310 | - $namespace = '\\' . __NAMESPACE__ . '\Admin\Fields\\'; |
|
311 | - } elseif ( 'admin-page' == $type ) { |
|
312 | - $namespace = '\\' . __NAMESPACE__ . '\Admin\Pages\\'; |
|
301 | + private function make_class_name($name, $type) { |
|
302 | + |
|
303 | + if ('calendar' == $type) { |
|
304 | + $namespace = '\\'.__NAMESPACE__.'\Calendars\\'; |
|
305 | + } elseif ('calendar-view' == $type) { |
|
306 | + $namespace = '\\'.__NAMESPACE__.'\Calendars\Views\\'; |
|
307 | + } elseif ('feed' == $type) { |
|
308 | + $namespace = '\\'.__NAMESPACE__.'\Feeds\\'; |
|
309 | + } elseif ('field' == $type) { |
|
310 | + $namespace = '\\'.__NAMESPACE__.'\Admin\Fields\\'; |
|
311 | + } elseif ('admin-page' == $type) { |
|
312 | + $namespace = '\\'.__NAMESPACE__.'\Admin\Pages\\'; |
|
313 | 313 | } else { |
314 | 314 | return ''; |
315 | 315 | } |
316 | 316 | |
317 | - $class_name = implode( '_', array_map( 'ucfirst', explode( '-', $name ) ) ); |
|
317 | + $class_name = implode('_', array_map('ucfirst', explode('-', $name))); |
|
318 | 318 | |
319 | - return $namespace . $class_name; |
|
319 | + return $namespace.$class_name; |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function __construct() { |
28 | 28 | // Register custom taxonomies. |
29 | - add_action( 'init', array( __CLASS__, 'register_taxonomies' ), 5 ); |
|
29 | + add_action('init', array(__CLASS__, 'register_taxonomies'), 5); |
|
30 | 30 | // Register custom post types. |
31 | - add_action( 'init', array( __CLASS__, 'register_post_types' ), 5 ); |
|
31 | + add_action('init', array(__CLASS__, 'register_post_types'), 5); |
|
32 | 32 | // Filter the calendar feed post content to display a calendar view. |
33 | - add_filter( 'the_content', array( $this, 'filter_post_content' ), 100 ); |
|
33 | + add_filter('the_content', array($this, 'filter_post_content'), 100); |
|
34 | 34 | // Delete calendar transients and notices upon post deletion. |
35 | - add_action( 'before_delete_post', array( $this, 'upon_deletion' ), 10, 1 ); |
|
35 | + add_action('before_delete_post', array($this, 'upon_deletion'), 10, 1); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -42,32 +42,32 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function register_taxonomies() { |
44 | 44 | |
45 | - do_action( 'simcal_register_taxonomies' ); |
|
45 | + do_action('simcal_register_taxonomies'); |
|
46 | 46 | |
47 | - if ( ! taxonomy_exists( 'calendar_feed' ) ) { |
|
47 | + if ( ! taxonomy_exists('calendar_feed')) { |
|
48 | 48 | |
49 | 49 | // Feed Type. |
50 | 50 | $labels = array( |
51 | - 'name' => __( 'Events Source Types', 'google-calendar-events' ), |
|
52 | - 'singular_name' => __( 'Events Source Type', 'google-calendar-events' ), |
|
53 | - 'menu_name' => __( 'Events Source Type', 'google-calendar-events' ), |
|
54 | - 'all_items' => __( 'All Events Source Types', 'google-calendar-events' ), |
|
55 | - 'parent_item' => __( 'Parent Events Source Type', 'google-calendar-events' ), |
|
56 | - 'parent_item_colon' => __( 'Parent Events Source Type:', 'google-calendar-events' ), |
|
57 | - 'new_item_name' => __( 'New Events Source Type', 'google-calendar-events' ), |
|
58 | - 'add_new_item' => __( 'Add New Events Source Type', 'google-calendar-events' ), |
|
59 | - 'edit_item' => __( 'Edit Events Source Type', 'google-calendar-events' ), |
|
60 | - 'update_item' => __( 'Update Events Source Type', 'google-calendar-events' ), |
|
61 | - 'view_item' => __( 'View Events Source Type', 'google-calendar-events' ), |
|
62 | - 'separate_items_with_commas' => __( 'Separate events source types with commas', 'google-calendar-events' ), |
|
63 | - 'add_or_remove_items' => __( 'Add or remove events source types', 'google-calendar-events' ), |
|
64 | - 'choose_from_most_used' => __( 'Choose from the most used', 'google-calendar-events' ), |
|
65 | - 'popular_items' => __( 'Popular events source types', 'google-calendar-events' ), |
|
66 | - 'search_items' => __( 'Search Events Source Types', 'google-calendar-events' ), |
|
67 | - 'not_found' => __( 'Not Found', 'google-calendar-events' ), |
|
51 | + 'name' => __('Events Source Types', 'google-calendar-events'), |
|
52 | + 'singular_name' => __('Events Source Type', 'google-calendar-events'), |
|
53 | + 'menu_name' => __('Events Source Type', 'google-calendar-events'), |
|
54 | + 'all_items' => __('All Events Source Types', 'google-calendar-events'), |
|
55 | + 'parent_item' => __('Parent Events Source Type', 'google-calendar-events'), |
|
56 | + 'parent_item_colon' => __('Parent Events Source Type:', 'google-calendar-events'), |
|
57 | + 'new_item_name' => __('New Events Source Type', 'google-calendar-events'), |
|
58 | + 'add_new_item' => __('Add New Events Source Type', 'google-calendar-events'), |
|
59 | + 'edit_item' => __('Edit Events Source Type', 'google-calendar-events'), |
|
60 | + 'update_item' => __('Update Events Source Type', 'google-calendar-events'), |
|
61 | + 'view_item' => __('View Events Source Type', 'google-calendar-events'), |
|
62 | + 'separate_items_with_commas' => __('Separate events source types with commas', 'google-calendar-events'), |
|
63 | + 'add_or_remove_items' => __('Add or remove events source types', 'google-calendar-events'), |
|
64 | + 'choose_from_most_used' => __('Choose from the most used', 'google-calendar-events'), |
|
65 | + 'popular_items' => __('Popular events source types', 'google-calendar-events'), |
|
66 | + 'search_items' => __('Search Events Source Types', 'google-calendar-events'), |
|
67 | + 'not_found' => __('Not Found', 'google-calendar-events'), |
|
68 | 68 | ); |
69 | 69 | |
70 | - $args = array( |
|
70 | + $args = array( |
|
71 | 71 | 'hierarchical' => true, |
72 | 72 | 'labels' => $labels, |
73 | 73 | 'public' => false, |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | 'show_tagcloud' => false, |
77 | 77 | 'show_ui' => false, |
78 | 78 | ); |
79 | - register_taxonomy( 'calendar_feed', array( 'calendar' ), $args ); |
|
79 | + register_taxonomy('calendar_feed', array('calendar'), $args); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | |
83 | - if ( ! taxonomy_exists( 'calendar_type' ) ) { |
|
83 | + if ( ! taxonomy_exists('calendar_type')) { |
|
84 | 84 | |
85 | 85 | // Calendar Type. |
86 | 86 | $labels = array( |
87 | - 'name' => __( 'Calendar Types', 'google-calendar-events' ), |
|
88 | - 'singular_name' => __( 'Calendar Type', 'google-calendar-events' ), |
|
89 | - 'menu_name' => __( 'Calendar Type', 'google-calendar-events' ), |
|
90 | - 'all_items' => __( 'All Calendar Types', 'google-calendar-events' ), |
|
91 | - 'parent_item' => __( 'Parent Calendar Type', 'google-calendar-events' ), |
|
92 | - 'parent_item_colon' => __( 'Parent Calendar Type:', 'google-calendar-events' ), |
|
93 | - 'new_item_name' => __( 'New Calendar Type', 'google-calendar-events' ), |
|
94 | - 'add_new_item' => __( 'Add New Calendar Type', 'google-calendar-events' ), |
|
95 | - 'edit_item' => __( 'Edit Calendar Type', 'google-calendar-events' ), |
|
96 | - 'update_item' => __( 'Update Calendar Type', 'google-calendar-events' ), |
|
97 | - 'view_item' => __( 'View Calendar Type', 'google-calendar-events' ), |
|
98 | - 'separate_items_with_commas' => __( 'Separate calendar types with commas', 'google-calendar-events' ), |
|
99 | - 'add_or_remove_items' => __( 'Add or remove calendar types', 'google-calendar-events' ), |
|
100 | - 'choose_from_most_used' => __( 'Choose from the most used', 'google-calendar-events' ), |
|
101 | - 'popular_items' => __( 'Popular calendar types', 'google-calendar-events' ), |
|
102 | - 'search_items' => __( 'Search Calendar Types', 'google-calendar-events' ), |
|
103 | - 'not_found' => __( 'Not Found', 'google-calendar-events' ), |
|
87 | + 'name' => __('Calendar Types', 'google-calendar-events'), |
|
88 | + 'singular_name' => __('Calendar Type', 'google-calendar-events'), |
|
89 | + 'menu_name' => __('Calendar Type', 'google-calendar-events'), |
|
90 | + 'all_items' => __('All Calendar Types', 'google-calendar-events'), |
|
91 | + 'parent_item' => __('Parent Calendar Type', 'google-calendar-events'), |
|
92 | + 'parent_item_colon' => __('Parent Calendar Type:', 'google-calendar-events'), |
|
93 | + 'new_item_name' => __('New Calendar Type', 'google-calendar-events'), |
|
94 | + 'add_new_item' => __('Add New Calendar Type', 'google-calendar-events'), |
|
95 | + 'edit_item' => __('Edit Calendar Type', 'google-calendar-events'), |
|
96 | + 'update_item' => __('Update Calendar Type', 'google-calendar-events'), |
|
97 | + 'view_item' => __('View Calendar Type', 'google-calendar-events'), |
|
98 | + 'separate_items_with_commas' => __('Separate calendar types with commas', 'google-calendar-events'), |
|
99 | + 'add_or_remove_items' => __('Add or remove calendar types', 'google-calendar-events'), |
|
100 | + 'choose_from_most_used' => __('Choose from the most used', 'google-calendar-events'), |
|
101 | + 'popular_items' => __('Popular calendar types', 'google-calendar-events'), |
|
102 | + 'search_items' => __('Search Calendar Types', 'google-calendar-events'), |
|
103 | + 'not_found' => __('Not Found', 'google-calendar-events'), |
|
104 | 104 | ); |
105 | 105 | |
106 | - $args = array( |
|
106 | + $args = array( |
|
107 | 107 | 'hierarchical' => true, |
108 | 108 | 'labels' => $labels, |
109 | 109 | 'public' => false, |
@@ -112,34 +112,34 @@ discard block |
||
112 | 112 | 'show_tagcloud' => false, |
113 | 113 | 'show_ui' => false, |
114 | 114 | ); |
115 | - register_taxonomy( 'calendar_type', array( 'calendar' ), $args ); |
|
115 | + register_taxonomy('calendar_type', array('calendar'), $args); |
|
116 | 116 | |
117 | 117 | } |
118 | 118 | |
119 | - if ( ! taxonomy_exists( 'calendar_category' ) ) { |
|
119 | + if ( ! taxonomy_exists('calendar_category')) { |
|
120 | 120 | |
121 | 121 | // Feed Category. |
122 | 122 | $labels = array( |
123 | - 'name' => __( 'Categories', 'google-calendar-events' ), |
|
124 | - 'singular_name' => __( 'Category', 'google-calendar-events' ), |
|
125 | - 'menu_name' => __( 'Categories', 'google-calendar-events' ), |
|
126 | - 'all_items' => __( 'All Categories', 'google-calendar-events' ), |
|
127 | - 'parent_item' => __( 'Parent Category', 'google-calendar-events' ), |
|
128 | - 'parent_item_colon' => __( 'Parent Category:', 'google-calendar-events' ), |
|
129 | - 'new_item_name' => __( 'New Category', 'google-calendar-events' ), |
|
130 | - 'add_new_item' => __( 'Add New Category', 'google-calendar-events' ), |
|
131 | - 'edit_item' => __( 'Edit Category', 'google-calendar-events' ), |
|
132 | - 'update_item' => __( 'Update Category', 'google-calendar-events' ), |
|
133 | - 'view_item' => __( 'View Category', 'google-calendar-events' ), |
|
134 | - 'separate_items_with_commas' => __( 'Separate categories with commas', 'google-calendar-events' ), |
|
135 | - 'add_or_remove_items' => __( 'Add or remove categories', 'google-calendar-events' ), |
|
136 | - 'choose_from_most_used' => __( 'Choose from the most used', 'google-calendar-events' ), |
|
137 | - 'popular_items' => __( 'Popular Categories', 'google-calendar-events' ), |
|
138 | - 'search_items' => __( 'Search Categories', 'google-calendar-events' ), |
|
139 | - 'not_found' => __( 'Not Found', 'google-calendar-events' ), |
|
123 | + 'name' => __('Categories', 'google-calendar-events'), |
|
124 | + 'singular_name' => __('Category', 'google-calendar-events'), |
|
125 | + 'menu_name' => __('Categories', 'google-calendar-events'), |
|
126 | + 'all_items' => __('All Categories', 'google-calendar-events'), |
|
127 | + 'parent_item' => __('Parent Category', 'google-calendar-events'), |
|
128 | + 'parent_item_colon' => __('Parent Category:', 'google-calendar-events'), |
|
129 | + 'new_item_name' => __('New Category', 'google-calendar-events'), |
|
130 | + 'add_new_item' => __('Add New Category', 'google-calendar-events'), |
|
131 | + 'edit_item' => __('Edit Category', 'google-calendar-events'), |
|
132 | + 'update_item' => __('Update Category', 'google-calendar-events'), |
|
133 | + 'view_item' => __('View Category', 'google-calendar-events'), |
|
134 | + 'separate_items_with_commas' => __('Separate categories with commas', 'google-calendar-events'), |
|
135 | + 'add_or_remove_items' => __('Add or remove categories', 'google-calendar-events'), |
|
136 | + 'choose_from_most_used' => __('Choose from the most used', 'google-calendar-events'), |
|
137 | + 'popular_items' => __('Popular Categories', 'google-calendar-events'), |
|
138 | + 'search_items' => __('Search Categories', 'google-calendar-events'), |
|
139 | + 'not_found' => __('Not Found', 'google-calendar-events'), |
|
140 | 140 | ); |
141 | 141 | |
142 | - $args = array( |
|
142 | + $args = array( |
|
143 | 143 | 'hierarchical' => true, |
144 | 144 | 'labels' => $labels, |
145 | 145 | 'public' => true, |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | 'show_ui' => true, |
150 | 150 | ); |
151 | 151 | |
152 | - register_taxonomy( 'calendar_category', array( 'calendar' ), $args ); |
|
152 | + register_taxonomy('calendar_category', array('calendar'), $args); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | } |
@@ -161,27 +161,27 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public static function register_post_types() { |
163 | 163 | |
164 | - do_action( 'simcal_register_post_types' ); |
|
164 | + do_action('simcal_register_post_types'); |
|
165 | 165 | |
166 | - if ( ! post_type_exists( 'calendar' ) ) { |
|
166 | + if ( ! post_type_exists('calendar')) { |
|
167 | 167 | |
168 | 168 | // Calendar feed post type. |
169 | - $labels = array( |
|
170 | - 'name' => _x( 'Calendars', 'Post Type General Name', 'google-calendar-events' ), |
|
171 | - 'singular_name' => _x( 'Calendar', 'Post Type Singular Name', 'google-calendar-events' ), |
|
172 | - 'menu_name' => __( 'Calendars', 'google-calendar-events' ), |
|
173 | - 'name_admin_bar' => __( 'Calendar', 'google-calendar-events' ), |
|
174 | - 'parent_item_colon' => __( 'Parent Calendar:', 'google-calendar-events' ), |
|
175 | - 'all_items' => __( 'All Calendars', 'google-calendar-events' ), |
|
176 | - 'add_new_item' => __( 'Add New Calendar', 'google-calendar-events' ), |
|
177 | - 'add_new' => __( 'Add New', 'google-calendar-events' ), |
|
178 | - 'new_item' => __( 'New Calendar', 'google-calendar-events' ), |
|
179 | - 'edit_item' => __( 'Edit Calendar', 'google-calendar-events' ), |
|
180 | - 'update_item' => __( 'Update Calendar', 'google-calendar-events' ), |
|
181 | - 'view_item' => __( 'View Calendar', 'google-calendar-events' ), |
|
182 | - 'search_items' => __( 'Search Calendar', 'google-calendar-events' ), |
|
183 | - 'not_found' => __( 'Calendars not found', 'google-calendar-events' ), |
|
184 | - 'not_found_in_trash' => __( 'Calendars not found in Trash', 'google-calendar-events' ), |
|
169 | + $labels = array( |
|
170 | + 'name' => _x('Calendars', 'Post Type General Name', 'google-calendar-events'), |
|
171 | + 'singular_name' => _x('Calendar', 'Post Type Singular Name', 'google-calendar-events'), |
|
172 | + 'menu_name' => __('Calendars', 'google-calendar-events'), |
|
173 | + 'name_admin_bar' => __('Calendar', 'google-calendar-events'), |
|
174 | + 'parent_item_colon' => __('Parent Calendar:', 'google-calendar-events'), |
|
175 | + 'all_items' => __('All Calendars', 'google-calendar-events'), |
|
176 | + 'add_new_item' => __('Add New Calendar', 'google-calendar-events'), |
|
177 | + 'add_new' => __('Add New', 'google-calendar-events'), |
|
178 | + 'new_item' => __('New Calendar', 'google-calendar-events'), |
|
179 | + 'edit_item' => __('Edit Calendar', 'google-calendar-events'), |
|
180 | + 'update_item' => __('Update Calendar', 'google-calendar-events'), |
|
181 | + 'view_item' => __('View Calendar', 'google-calendar-events'), |
|
182 | + 'search_items' => __('Search Calendar', 'google-calendar-events'), |
|
183 | + 'not_found' => __('Calendars not found', 'google-calendar-events'), |
|
184 | + 'not_found_in_trash' => __('Calendars not found in Trash', 'google-calendar-events'), |
|
185 | 185 | ); |
186 | 186 | |
187 | 187 | $rewrite_rules = array( |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | |
194 | 194 | $svg_icon = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iU2hhcGVzX3hBMF9JbWFnZV8xXyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDEwMjQgMTAyNCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIGQ9Ik01MTMuNCwxMDEzLjNjLTE2My44LDAtMzI3LjcsMC00OTEuNSwwYy05LjcsMC04LjgsMC45LTguOC04LjljMC0yNDMuNywwLjItNDg3LjMtMC4zLTczMWMtMC4xLTM5LjYsMjcuNy03Ni40LDY5LjYtODIuM2MzLTAuNCw2LTAuNSw5LTAuNWMzNSwwLDcwLDAuMSwxMDUtMC4xYzUuMSwwLDYuNSwxLjQsNi41LDYuNWMtMC4yLDI2LjgsMC4xLDUzLjctMC4yLDgwLjVjLTAuMiwxNS4yLDMuOSwyOC4yLDE1LjksMzguMmMyLjcsMi4yLDUsNC44LDcuNCw3LjRjOCw4LjYsMTguMSwxMi40LDI5LjYsMTIuNGMzMC43LDAuMiw2MS4zLDAuMiw5MiwwYzExLjItMC4xLDIxLjItMy45LDI5LjEtMTIuMmMzLjQtMy42LDctNy4yLDEwLjYtMTAuNmM5LTguNCwxMi43LTE4LjksMTIuNy0zMWMwLjEtMjguMiwwLTU2LjMsMC04NC41YzAtNi42LDAtNi42LDYuNi02LjZjNzEuNSwwLDE0MywwLDIxNC41LDBjNi42LDAsNi42LDAsNi42LDYuN2MwLDI2LjgsMC4yLDUzLjctMC4xLDgwLjVjLTAuMiwxNSw1LjEsMjYuOCwxNS40LDM4YzEzLjYsMTQuNywyOC45LDIwLjgsNDguNywyMC4xYzI1LjYtMSw1MS4zLTAuNCw3Ny0wLjJjMTMuOSwwLjEsMjQuOC01LjEsMzUuNC0xNC40YzE1LjktMTQsMjIuMS0zMC40LDIxLjEtNTEuM2MtMS4xLTI0LjMtMC4xLTQ4LjctMC40LTczYzAtNS4xLDEuNC02LjUsNi41LTYuNWMzNC43LDAuMiw2OS4zLDAsMTA0LDAuMWM0Mi4zLDAuMiw3OC4zLDM2LDc4LjMsNzguM2MwLjEsMjQ2LDAsNDkyLDAsNzM4YzAsNi40LDAsNi40LTcuMyw2LjRDODQyLDEwMTMuMyw2NzcuNywxMDEzLjMsNTEzLjQsMTAxMy4zeiBNNDM5LjUsNjc4LjljMS42LTEsMi4yLTEuNSwzLTEuOGMxMS44LTUuOCwyMS41LTE0LjIsMjktMjQuOGMyNC4zLTM0LjEsMjQuMy03MC45LDguNi0xMDcuOGMtMTMuMy0zMS4zLTM5LjMtNDkuMy03MS01OS40Yy0yNy42LTguOC01Ni05LjQtODQuNS01LjZjLTIwLjMsMi43LTM5LjIsOS42LTU1LjUsMjIuMmMtMzUuNSwyNy4yLTQ4LjQsNjUuMS01MC40LDEwOGMtMC4yLDMuNywyLjEsMy45LDQuOCwzLjljMjIuMiwwLDQ0LjMtMC4xLDY2LjUsMGMzLjgsMCw1LjQtMS4xLDUuMy01LjFjLTAuMS03LjcsMS0xNS4zLDMtMjIuN2M1LjQtMjAsMTYuNS0zNC43LDM3LjgtMzkuN2M4LjEtMS45LDE2LjMtMi4xLDI0LjQtMS4zYzIxLjQsMi4xLDM2LjMsMTMuMSw0My41LDMzLjdjMy41LDEwLjEsMy45LDIwLjQsMi45LDMxYy0yLjIsMjMuNC0xNi4yLDM5LjctMzkuMSw0NC42Yy0xMy4yLDIuOC0yNi42LDQuMS00MC4yLDRjLTMuNywwLTUsMS4yLTQuOSw0LjljMC4xLDE2LjUsMC4yLDMzLDAsNDkuNWMwLDQsMS41LDUuMiw1LjMsNS4xYzEyLjktMC4zLDI1LjYsMC45LDM4LjMsM2MyNi4zLDQuMiw0My41LDE4LjgsNDkuMiw0MmMzLjMsMTMuNSwzLDI3LjEtMC4yLDQwLjZjLTIuMyw5LjctNi44LDE4LjQtMTMuOCwyNS43Yy0xNS40LDE2LjEtMzQuNSwyMS42LTU2LDE4LjljLTI3LjUtMy40LTQzLjUtMTgtNTAuNS00NC44Yy0xLjktNy4zLTMuMS0xNC43LTIuOC0yMi4yYzAuMi00LTEuMS01LjYtNS40LTUuNmMtMjMuNywwLjItNDcuMywwLjItNzEsMGMtNCwwLTUuNCwxLjItNC45LDUuMmMxLjQsMTMuMiwyLjcsMjYuNSw1LjksMzkuNWMxMS4xLDQ1LjIsMzguMiw3NS42LDgzLjQsODguMmMzNi43LDEwLjMsNzMuOCwxMC4xLDExMC41LDAuMWMyNC41LTYuNiw0NC43LTIwLjEsNjEtMzkuOGMyNC41LTI5LjcsMzQuNC02My45LDMxLjQtMTAxLjljLTIuMi0yNy40LTEyLjUtNTEuMy0zMy42LTY5LjhDNDYwLjcsNjg5LjMsNDUxLjksNjgyLDQzOS41LDY3OC45eiBNNzU1LDY5Mi41YzAtNjguNi0wLjEtMTM3LjMsMC4xLTIwNS45YzAtNS4xLTEuNC02LjUtNi41LTYuNGMtMTguMywwLjMtMzYuNywwLjQtNTUsMGMtNS43LTAuMS03LjIsMS45LTguMiw3Yy01LjksMzIuMS0yNC40LDUzLTU2LjMsNjEuMWMtMTcuNSw0LjUtMzUuNiw1LTUzLjUsNS44Yy0zLjksMC4yLTUuMiwxLjQtNS4yLDUuM2MwLjIsMTUuMywwLjIsMzAuNywwLDQ2Yy0wLjEsNC4zLDEuNiw1LjQsNS42LDUuM2MxNC4yLTAuMiwyOC4zLTAuMSw0Mi41LTAuMWMxNS41LDAsMzEsMC4xLDQ2LjUtMC4xYzQuMSwwLDUuOSwxLjMsNS41LDUuNGMtMC4xLDEuNywwLDMuMywwLDVjMCw5Mi4xLDAsMTg0LjMsMCwyNzYuNGMwLDcuMiwwLDcuMiw3LDcuMmMyMy41LDAsNDcsMCw3MC41LDBjNywwLDcsMCw3LTcuMkM3NTUsODI5LjEsNzU1LDc2MC44LDc1NSw2OTIuNXoiLz48cGF0aCBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgZD0iTTM3Ni43LDE5OS4yYzAsMjQuMiwwLDQ4LjMsMCw3Mi41Yy0wLjEsMjMuMS0xNy40LDQwLjUtNDAuNCw0MC42Yy0yMy4zLDAuMS00Ni42LDAuMS03MCwwYy0yMi44LTAuMS00MC4zLTE3LjQtNDAuMy00MC4xYy0wLjEtNDguNS0wLjEtOTYuOSwwLTE0NS40YzAtMjIuNCwxNy41LTQwLDM5LjktNDAuMWMyMy43LTAuMSw0Ny4zLTAuMSw3MSwwYzIyLjQsMC4xLDM5LjgsMTcuNywzOS44LDQwLjFDMzc2LjgsMTUwLjksMzc2LjcsMTc1LjEsMzc2LjcsMTk5LjJ6Ii8+PHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIGQ9Ik04MDEuNywxOTkuNmMwLDI0LDAsNDgsMCw3MmMwLDIzLjQtMTcuMyw0MC43LTQwLjcsNDAuOGMtMjMuMiwwLjEtNDYuMywwLjEtNjkuNSwwYy0yMy4xLTAuMS00MC41LTE3LjQtNDAuNS00MC41Yy0wLjEtNDguMy0wLjEtOTYuNiwwLTE0NC45YzAtMjIuNywxNy41LTQwLjIsNDAuMi00MC4zYzIzLjMtMC4xLDQ2LjYtMC4xLDcwLDBjMjMuMSwwLjEsNDAuNCwxNy40LDQwLjUsNDAuNUM4MDEuOCwxNTEuMyw4MDEuNywxNzUuNCw4MDEuNywxOTkuNnoiLz48L3N2Zz4='; |
195 | 195 | |
196 | - $args = array( |
|
196 | + $args = array( |
|
197 | 197 | 'capability_type' => 'post', |
198 | 198 | 'exclude_from_search' => false, |
199 | 199 | 'has_archive' => false, |
200 | 200 | 'hierarchical' => false, |
201 | - 'label' => __( 'Calendar', 'google-calendar-events' ), |
|
201 | + 'label' => __('Calendar', 'google-calendar-events'), |
|
202 | 202 | 'labels' => $labels, |
203 | 203 | 'query_var' => true, |
204 | 204 | 'public' => true, |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | 'show_in_menu' => true, |
211 | 211 | 'show_in_nav_menus' => true, |
212 | 212 | 'show_ui' => true, |
213 | - 'supports' => array( 'title', 'editor' ), |
|
213 | + 'supports' => array('title', 'editor'), |
|
214 | 214 | 'taxonomies' => array( |
215 | 215 | 'calendar_category', |
216 | 216 | 'calendar_feed', |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | ), |
219 | 219 | ); |
220 | 220 | |
221 | - register_post_type( 'calendar', $args ); |
|
221 | + register_post_type('calendar', $args); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | } |
@@ -232,49 +232,49 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return string |
234 | 234 | */ |
235 | - public function filter_post_content( $the_content ) { |
|
235 | + public function filter_post_content($the_content) { |
|
236 | 236 | |
237 | - if ( is_singular() ) { |
|
237 | + if (is_singular()) { |
|
238 | 238 | |
239 | 239 | global $post; |
240 | 240 | |
241 | - if ( 'calendar' == $post->post_type ) { |
|
241 | + if ('calendar' == $post->post_type) { |
|
242 | 242 | |
243 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
243 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
244 | 244 | return ''; |
245 | 245 | } else { |
246 | 246 | ob_start(); |
247 | - simcal_print_calendar( $post ); |
|
247 | + simcal_print_calendar($post); |
|
248 | 248 | return ob_get_clean(); |
249 | 249 | } |
250 | 250 | |
251 | 251 | } else { |
252 | 252 | |
253 | 253 | $post_types = array(); |
254 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
255 | - if ( isset( $settings['general']['attach_calendars_posts'] ) ) { |
|
254 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
255 | + if (isset($settings['general']['attach_calendars_posts'])) { |
|
256 | 256 | $post_types = $settings['general']['attach_calendars_posts']; |
257 | 257 | } |
258 | 258 | |
259 | - if ( empty( $post_types ) ) { |
|
259 | + if (empty($post_types)) { |
|
260 | 260 | return $the_content; |
261 | 261 | } |
262 | 262 | |
263 | - if ( in_array( $post->post_type, (array) $post_types ) ) { |
|
263 | + if (in_array($post->post_type, (array) $post_types)) { |
|
264 | 264 | |
265 | - $id = absint( get_post_meta( $post->ID, '_simcal_attach_calendar_id', true ) ); |
|
265 | + $id = absint(get_post_meta($post->ID, '_simcal_attach_calendar_id', true)); |
|
266 | 266 | |
267 | - if ( $id > 0 ) { |
|
267 | + if ($id > 0) { |
|
268 | 268 | |
269 | - $pos = esc_attr( get_post_meta( $post->ID, '_simcal_attach_calendar_position', true ) ); |
|
269 | + $pos = esc_attr(get_post_meta($post->ID, '_simcal_attach_calendar_position', true)); |
|
270 | 270 | |
271 | 271 | ob_start(); |
272 | 272 | |
273 | - if ( 'after' == $pos ) { |
|
273 | + if ('after' == $pos) { |
|
274 | 274 | echo $the_content; |
275 | - simcal_print_calendar( $id ); |
|
276 | - } elseif ( 'before' == $pos ) { |
|
277 | - simcal_print_calendar( $id ); |
|
275 | + simcal_print_calendar($id); |
|
276 | + } elseif ('before' == $pos) { |
|
277 | + simcal_print_calendar($id); |
|
278 | 278 | echo $the_content; |
279 | 279 | } else { |
280 | 280 | echo $the_content; |
@@ -300,20 +300,20 @@ discard block |
||
300 | 300 | * |
301 | 301 | * @param $post_id |
302 | 302 | */ |
303 | - public function upon_deletion( $post_id ) { |
|
303 | + public function upon_deletion($post_id) { |
|
304 | 304 | |
305 | - $post_type = get_post_type( $post_id ); |
|
305 | + $post_type = get_post_type($post_id); |
|
306 | 306 | |
307 | - if ( 'calendar' == $post_type ) { |
|
307 | + if ('calendar' == $post_type) { |
|
308 | 308 | |
309 | - $notices = get_option( 'simple-calendar_admin_notices', array() ); |
|
309 | + $notices = get_option('simple-calendar_admin_notices', array()); |
|
310 | 310 | |
311 | - if ( ! empty( $notices ) && isset( $notices[ 'calendar_' . strval( $post_id ) ] ) ) { |
|
312 | - unset( $notices[ 'calendar_' . strval( $post_id ) ] ); |
|
313 | - update_option( 'simple-calendar_admin_notices', $notices ); |
|
311 | + if ( ! empty($notices) && isset($notices['calendar_'.strval($post_id)])) { |
|
312 | + unset($notices['calendar_'.strval($post_id)]); |
|
313 | + update_option('simple-calendar_admin_notices', $notices); |
|
314 | 314 | } |
315 | 315 | |
316 | - simcal_delete_feed_transients( $post_id ); |
|
316 | + simcal_delete_feed_transients($post_id); |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Calendar; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public function __construct() { |
30 | 30 | |
31 | 31 | // Add shortcodes. |
32 | - add_action( 'init', array( $this, 'register' ) ); |
|
32 | + add_action('init', array($this, 'register')); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function register() { |
41 | 41 | |
42 | - add_shortcode( 'calendar', array( $this, 'print_calendar' ) ); |
|
42 | + add_shortcode('calendar', array($this, 'print_calendar')); |
|
43 | 43 | // @deprecated legacy shortcode |
44 | - add_shortcode( 'gcal', array( $this, 'print_calendar' ) ); |
|
44 | + add_shortcode('gcal', array($this, 'print_calendar')); |
|
45 | 45 | |
46 | - do_action( 'simcal_add_shortcodes' ); |
|
46 | + do_action('simcal_add_shortcodes'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -55,19 +55,19 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return string |
57 | 57 | */ |
58 | - public function print_calendar( $attributes ) { |
|
58 | + public function print_calendar($attributes) { |
|
59 | 59 | |
60 | - $args = shortcode_atts( array( |
|
60 | + $args = shortcode_atts(array( |
|
61 | 61 | 'id' => null, |
62 | - ), $attributes ); |
|
62 | + ), $attributes); |
|
63 | 63 | |
64 | - $id = absint( $args['id'] ); |
|
64 | + $id = absint($args['id']); |
|
65 | 65 | |
66 | - if ( $id > 0 ) { |
|
66 | + if ($id > 0) { |
|
67 | 67 | |
68 | - $calendar = simcal_get_calendar( $id ); |
|
68 | + $calendar = simcal_get_calendar($id); |
|
69 | 69 | |
70 | - if ( $calendar instanceof Calendar ) { |
|
70 | + if ($calendar instanceof Calendar) { |
|
71 | 71 | ob_start(); |
72 | 72 | $calendar->html(); |
73 | 73 | return ob_get_clean(); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar\Updates; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -20,21 +20,21 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param array $posts |
22 | 22 | */ |
23 | - public function __construct( $posts ) { |
|
23 | + public function __construct($posts) { |
|
24 | 24 | |
25 | - if ( ! empty( $posts ) && is_array( $posts ) ) { |
|
25 | + if ( ! empty($posts) && is_array($posts)) { |
|
26 | 26 | |
27 | - foreach ( $posts as $post ) { |
|
27 | + foreach ($posts as $post) { |
|
28 | 28 | |
29 | - $url = get_post_meta( $post->ID, 'gce_feed_url', true ); |
|
29 | + $url = get_post_meta($post->ID, 'gce_feed_url', true); |
|
30 | 30 | |
31 | - if ( $url ) { |
|
31 | + if ($url) { |
|
32 | 32 | |
33 | - $url = str_replace( 'https://www.google.com/calendar/feeds/', '', $url ); |
|
34 | - $url = str_replace( '/public/basic', '', $url ); |
|
35 | - $url = str_replace( '%40', '@', $url ); |
|
33 | + $url = str_replace('https://www.google.com/calendar/feeds/', '', $url); |
|
34 | + $url = str_replace('/public/basic', '', $url); |
|
35 | + $url = str_replace('%40', '@', $url); |
|
36 | 36 | |
37 | - update_post_meta( $post->ID, 'gce_feed_url', $url ); |
|
37 | + update_post_meta($post->ID, 'gce_feed_url', $url); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar\Updates; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -20,28 +20,28 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param array $posts |
22 | 22 | */ |
23 | - public function __construct( $posts ) { |
|
23 | + public function __construct($posts) { |
|
24 | 24 | |
25 | - if ( ! empty( $posts ) && is_array( $posts ) ) { |
|
25 | + if ( ! empty($posts) && is_array($posts)) { |
|
26 | 26 | |
27 | - foreach ( $posts as $post ) { |
|
27 | + foreach ($posts as $post) { |
|
28 | 28 | |
29 | - $gce_list_max_num = get_post_meta( $post->ID, 'gce_list_max_num', true ); |
|
30 | - $gce_list_max_length = get_post_meta( $post->ID, 'gce_list_max_length', true ); |
|
31 | - $gce_feed_start_interval = get_post_meta( $post->ID, 'gce_feed_start_interval', true ); |
|
32 | - $gce_feed_start = get_post_meta( $post->ID, 'gce_feed_start', true ); |
|
33 | - $gce_feed_end_interval = get_post_meta( $post->ID, 'gce_feed_end_interval', true ); |
|
34 | - $gce_feed_end = get_post_meta( $post->ID, 'gce_feed_end', true ); |
|
29 | + $gce_list_max_num = get_post_meta($post->ID, 'gce_list_max_num', true); |
|
30 | + $gce_list_max_length = get_post_meta($post->ID, 'gce_list_max_length', true); |
|
31 | + $gce_feed_start_interval = get_post_meta($post->ID, 'gce_feed_start_interval', true); |
|
32 | + $gce_feed_start = get_post_meta($post->ID, 'gce_feed_start', true); |
|
33 | + $gce_feed_end_interval = get_post_meta($post->ID, 'gce_feed_end_interval', true); |
|
34 | + $gce_feed_end = get_post_meta($post->ID, 'gce_feed_end', true); |
|
35 | 35 | |
36 | - update_post_meta( $post->ID, 'gce_per_page_num', $gce_list_max_num ); |
|
37 | - update_post_meta( $post->ID, 'gce_events_per_page', $gce_list_max_length ); |
|
38 | - update_post_meta( $post->ID, 'gce_feed_start', $gce_feed_start_interval ); |
|
39 | - update_post_meta( $post->ID, 'gce_feed_start_num', $gce_feed_start ); |
|
40 | - update_post_meta( $post->ID, 'gce_feed_end', $gce_feed_end_interval ); |
|
41 | - update_post_meta( $post->ID, 'gce_feed_end_num', $gce_feed_end ); |
|
36 | + update_post_meta($post->ID, 'gce_per_page_num', $gce_list_max_num); |
|
37 | + update_post_meta($post->ID, 'gce_events_per_page', $gce_list_max_length); |
|
38 | + update_post_meta($post->ID, 'gce_feed_start', $gce_feed_start_interval); |
|
39 | + update_post_meta($post->ID, 'gce_feed_start_num', $gce_feed_start); |
|
40 | + update_post_meta($post->ID, 'gce_feed_end', $gce_feed_end_interval); |
|
41 | + update_post_meta($post->ID, 'gce_feed_end_num', $gce_feed_end); |
|
42 | 42 | |
43 | 43 | // Add new show tooltips option checked as default. |
44 | - update_post_meta( $post->ID, 'gce_show_tooltips', 1 ); |
|
44 | + update_post_meta($post->ID, 'gce_show_tooltips', 1); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Carbon\Carbon; |
10 | 10 | use SimpleCalendar\Post_Types; |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param array $posts |
25 | 25 | */ |
26 | - public function __construct( $posts ) { |
|
26 | + public function __construct($posts) { |
|
27 | 27 | |
28 | 28 | Post_Types::register_taxonomies(); |
29 | 29 | Post_Types::register_post_types(); |
30 | 30 | |
31 | - if ( ! empty( $posts ) && is_array( $posts ) ) { |
|
32 | - $this->update_posts( $posts ); |
|
31 | + if ( ! empty($posts) && is_array($posts)) { |
|
32 | + $this->update_posts($posts); |
|
33 | 33 | $this->update_post_type(); |
34 | 34 | $this->update_widgets(); |
35 | 35 | } |
@@ -43,201 +43,201 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @param $posts |
45 | 45 | */ |
46 | - public function update_posts( $posts ) { |
|
46 | + public function update_posts($posts) { |
|
47 | 47 | |
48 | - foreach ( $posts as $post ) { |
|
48 | + foreach ($posts as $post) { |
|
49 | 49 | |
50 | 50 | $post_id = $post->ID; |
51 | 51 | |
52 | 52 | // Assign a feed taxonomy term (feed type) to legacy posts. |
53 | - wp_set_object_terms( $post_id, 'google', 'calendar_feed' ); |
|
53 | + wp_set_object_terms($post_id, 'google', 'calendar_feed'); |
|
54 | 54 | |
55 | 55 | // Assign a calendar taxonomy term (calendar type) to legacy posts. |
56 | - wp_set_object_terms( $post_id, 'default-calendar', 'calendar_type' ); |
|
56 | + wp_set_object_terms($post_id, 'default-calendar', 'calendar_type'); |
|
57 | 57 | |
58 | 58 | // Convert legacy list/grid view to default calendar view. |
59 | - $display = get_post_meta( $post_id, 'gce_display_mode', true ); |
|
59 | + $display = get_post_meta($post_id, 'gce_display_mode', true); |
|
60 | 60 | $views = array(); |
61 | 61 | $range = false; |
62 | - if ( 'list' == $display ) { |
|
62 | + if ('list' == $display) { |
|
63 | 63 | $views['default-calendar'] = 'list'; |
64 | - } elseif ( 'list-grouped' == $display ) { |
|
64 | + } elseif ('list-grouped' == $display) { |
|
65 | 65 | $views['default-calendar'] = 'list'; |
66 | - } elseif ( 'date-range-list' == $display ) { |
|
66 | + } elseif ('date-range-list' == $display) { |
|
67 | 67 | $views['default-calendar'] = 'list'; |
68 | 68 | $range = true; |
69 | - } elseif ( 'date-range-grid' == $display ) { |
|
69 | + } elseif ('date-range-grid' == $display) { |
|
70 | 70 | $views['default-calendar'] = 'grid'; |
71 | 71 | $range = true; |
72 | 72 | } else { |
73 | 73 | $views['default-calendar'] = 'grid'; |
74 | 74 | } |
75 | - update_post_meta( $post_id, '_calendar_view', $views ); |
|
75 | + update_post_meta($post_id, '_calendar_view', $views); |
|
76 | 76 | |
77 | 77 | // List calendar settings. |
78 | - $list_span = get_post_meta( $post_id, 'gce_events_per_page', true ); |
|
79 | - $list_range = max( absint( get_post_meta( $post_id, 'gce_per_page_num', true ) ), 1 ); |
|
80 | - if ( 'days' == $list_span ) { |
|
78 | + $list_span = get_post_meta($post_id, 'gce_events_per_page', true); |
|
79 | + $list_range = max(absint(get_post_meta($post_id, 'gce_per_page_num', true)), 1); |
|
80 | + if ('days' == $list_span) { |
|
81 | 81 | $list_type = 'daily'; |
82 | - } elseif ( 'week' == $list_span ) { |
|
82 | + } elseif ('week' == $list_span) { |
|
83 | 83 | $list_type = 'weekly'; |
84 | 84 | $list_range = 1; |
85 | - } elseif ( 'month' == $list_span ) { |
|
85 | + } elseif ('month' == $list_span) { |
|
86 | 86 | $list_type = 'monthly'; |
87 | 87 | $list_range = 1; |
88 | 88 | } else { |
89 | 89 | $list_type = 'events'; |
90 | 90 | } |
91 | - update_post_meta( $post_id, '_default_calendar_list_range_type', $list_type ); |
|
92 | - update_post_meta( $post_id, '_default_calendar_list_range_span', $list_range ); |
|
91 | + update_post_meta($post_id, '_default_calendar_list_range_type', $list_type); |
|
92 | + update_post_meta($post_id, '_default_calendar_list_range_span', $list_range); |
|
93 | 93 | |
94 | 94 | $calendar_begins = 'today'; |
95 | 95 | |
96 | 96 | // Custom calendar range. |
97 | - if ( $range === true ) { |
|
97 | + if ($range === true) { |
|
98 | 98 | |
99 | - $begins = get_post_meta( $post_id, 'gce_feed_range_start', true ); |
|
100 | - $ends = get_post_meta( $post_id, 'gce_feed_range_end', true ); |
|
99 | + $begins = get_post_meta($post_id, 'gce_feed_range_start', true); |
|
100 | + $ends = get_post_meta($post_id, 'gce_feed_range_end', true); |
|
101 | 101 | |
102 | - if ( $begins && $ends ) { |
|
103 | - update_post_meta( $post_id, '_calendar_begins', 'custom_date' ); |
|
104 | - update_post_meta( $post_id, '_calendar_begins_custom_date', $this->convert_legacy_range( $begins ) ); |
|
102 | + if ($begins && $ends) { |
|
103 | + update_post_meta($post_id, '_calendar_begins', 'custom_date'); |
|
104 | + update_post_meta($post_id, '_calendar_begins_custom_date', $this->convert_legacy_range($begins)); |
|
105 | 105 | } else { |
106 | - update_post_meta( $post_id, '_calendar_begins', $calendar_begins ); |
|
106 | + update_post_meta($post_id, '_calendar_begins', $calendar_begins); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | } else { |
110 | 110 | |
111 | 111 | // Legacy list calendars may have a start offset. |
112 | - $offset = absint( get_post_meta( $post_id, 'gce_list_start_offset_num', true ) ); |
|
113 | - if ( 'list' == $display && $offset > 0 ) { |
|
114 | - $calendar_begins = 'back' == get_post_meta( $post_id, 'gce_list_start_offset_direction', true ) ? 'days_before' : 'days_after'; |
|
115 | - update_post_meta( $post_id, '_calendar_begins_nth', $offset ); |
|
112 | + $offset = absint(get_post_meta($post_id, 'gce_list_start_offset_num', true)); |
|
113 | + if ('list' == $display && $offset > 0) { |
|
114 | + $calendar_begins = 'back' == get_post_meta($post_id, 'gce_list_start_offset_direction', true) ? 'days_before' : 'days_after'; |
|
115 | + update_post_meta($post_id, '_calendar_begins_nth', $offset); |
|
116 | 116 | } |
117 | 117 | |
118 | - update_post_meta( $post_id, '_calendar_begins', $calendar_begins ); |
|
118 | + update_post_meta($post_id, '_calendar_begins', $calendar_begins); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | // Earliest event. |
122 | - $start_before = get_post_meta( $post_id, 'gce_feed_start', true ); |
|
123 | - $start_amt = absint( get_post_meta( $post_id, 'gce_feed_start_num', true ) ); |
|
124 | - if ( $start_amt > 0 ) { |
|
125 | - if ( 'years' == $start_before ) { |
|
122 | + $start_before = get_post_meta($post_id, 'gce_feed_start', true); |
|
123 | + $start_amt = absint(get_post_meta($post_id, 'gce_feed_start_num', true)); |
|
124 | + if ($start_amt > 0) { |
|
125 | + if ('years' == $start_before) { |
|
126 | 126 | $earliest = 'years_before'; |
127 | - } elseif ( 'months' == $start_before ) { |
|
127 | + } elseif ('months' == $start_before) { |
|
128 | 128 | $earliest = 'months_before'; |
129 | 129 | } else { |
130 | 130 | $earliest = 'days_before'; |
131 | 131 | } |
132 | - update_post_meta( $post_id, '_feed_earliest_event_date', $earliest ); |
|
133 | - update_post_meta( $post_id, '_feed_earliest_event_date_range', $start_amt ); |
|
132 | + update_post_meta($post_id, '_feed_earliest_event_date', $earliest); |
|
133 | + update_post_meta($post_id, '_feed_earliest_event_date_range', $start_amt); |
|
134 | 134 | } else { |
135 | - update_post_meta( $post_id, '_feed_earliest_event_date', 'calendar_start' ); |
|
136 | - update_post_meta( $post_id, '_feed_earliest_event_date_range', 1 ); |
|
135 | + update_post_meta($post_id, '_feed_earliest_event_date', 'calendar_start'); |
|
136 | + update_post_meta($post_id, '_feed_earliest_event_date_range', 1); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | // Latest event. |
140 | - $end_after = get_post_meta( $post_id, 'gce_feed_end', true ); |
|
141 | - $end_amt = absint( get_post_meta( $post_id, 'gce_feed_end_num', true ) ); |
|
142 | - if ( $end_amt > 0 ) { |
|
143 | - if ( 'years' == $end_after ) { |
|
140 | + $end_after = get_post_meta($post_id, 'gce_feed_end', true); |
|
141 | + $end_amt = absint(get_post_meta($post_id, 'gce_feed_end_num', true)); |
|
142 | + if ($end_amt > 0) { |
|
143 | + if ('years' == $end_after) { |
|
144 | 144 | $latest = 'years_after'; |
145 | - } elseif ( 'months' == $end_after ) { |
|
145 | + } elseif ('months' == $end_after) { |
|
146 | 146 | $latest = 'months_after'; |
147 | 147 | } else { |
148 | 148 | $latest = 'days_after'; |
149 | 149 | } |
150 | - update_post_meta( $post_id, '_feed_latest_event_date', $latest ); |
|
151 | - update_post_meta( $post_id, '_feed_latest_event_date_range', $end_amt ); |
|
150 | + update_post_meta($post_id, '_feed_latest_event_date', $latest); |
|
151 | + update_post_meta($post_id, '_feed_latest_event_date_range', $end_amt); |
|
152 | 152 | } else { |
153 | - update_post_meta( $post_id, '_feed_latest_event_date', 'calendar_start' ); |
|
154 | - update_post_meta( $post_id, '_feed_latest_event_date_range', 1 ); |
|
153 | + update_post_meta($post_id, '_feed_latest_event_date', 'calendar_start'); |
|
154 | + update_post_meta($post_id, '_feed_latest_event_date_range', 1); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | // Static calendar. |
158 | - if ( false === get_post_meta( $post_id, 'gce_paging', true ) ) { |
|
159 | - update_post_meta( $post_id, '_calendar_is_static', 'yes' ); |
|
158 | + if (false === get_post_meta($post_id, 'gce_paging', true)) { |
|
159 | + update_post_meta($post_id, '_calendar_is_static', 'yes'); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | // Default calendar bubble trigger (click was unavailable before 3.0.0). |
163 | - update_post_meta( $post_id, '_default_calendar_event_bubble_trigger', 'hover' ); |
|
163 | + update_post_meta($post_id, '_default_calendar_event_bubble_trigger', 'hover'); |
|
164 | 164 | |
165 | 165 | // Default calendar multiple day events. |
166 | - if ( get_post_meta( $post_id, 'gce_multi_day_events', true ) ) { |
|
167 | - update_post_meta( $post_id, '_default_calendar_expand_multi_day_events', 'yes' ); |
|
166 | + if (get_post_meta($post_id, 'gce_multi_day_events', true)) { |
|
167 | + update_post_meta($post_id, '_default_calendar_expand_multi_day_events', 'yes'); |
|
168 | 168 | } else { |
169 | - update_post_meta( $post_id, '_default_calendar_expand_multi_day_events', 'no' ); |
|
169 | + update_post_meta($post_id, '_default_calendar_expand_multi_day_events', 'no'); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | // Google Calendar ID. |
173 | - $google_id = get_post_meta( $post_id, 'gce_feed_url', true ); |
|
174 | - update_post_meta( $post_id, '_google_calendar_id', base64_encode( trim( $google_id ) ) ); |
|
173 | + $google_id = get_post_meta($post_id, 'gce_feed_url', true); |
|
174 | + update_post_meta($post_id, '_google_calendar_id', base64_encode(trim($google_id))); |
|
175 | 175 | |
176 | 176 | // Google max results. |
177 | - update_post_meta( $post_id, '_google_events_max_results', 2500 ); |
|
177 | + update_post_meta($post_id, '_google_events_max_results', 2500); |
|
178 | 178 | |
179 | 179 | // Google calendar feed search terms. |
180 | - $google_search = get_post_meta( $post_id, 'gce_search_query', true ); |
|
181 | - if ( ! empty( $google_search ) ) { |
|
182 | - update_post_meta( $post_id, '_google_events_search_query', trim( $google_search ) ); |
|
180 | + $google_search = get_post_meta($post_id, 'gce_search_query', true); |
|
181 | + if ( ! empty($google_search)) { |
|
182 | + update_post_meta($post_id, '_google_events_search_query', trim($google_search)); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | // Google recurring events. |
186 | - if ( get_post_meta( $post_id, 'gce_expand_recurring', true ) ) { |
|
187 | - update_post_meta( $post_id, '_google_events_recurring', 'show' ); |
|
186 | + if (get_post_meta($post_id, 'gce_expand_recurring', true)) { |
|
187 | + update_post_meta($post_id, '_google_events_recurring', 'show'); |
|
188 | 188 | } else { |
189 | - update_post_meta( $post_id, '_google_events_recurring', 'first-only' ); |
|
189 | + update_post_meta($post_id, '_google_events_recurring', 'first-only'); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | // Date and time format. |
193 | - $date_format = get_post_meta( $post_id, 'gce_date_format', true ); |
|
194 | - if ( ! empty( $date_format ) ) { |
|
195 | - update_post_meta( $post_id, '_calendar_date_format_setting', 'use_custom_php' ); |
|
196 | - update_post_meta( $post_id, '_calendar_date_format_php', $date_format ); |
|
193 | + $date_format = get_post_meta($post_id, 'gce_date_format', true); |
|
194 | + if ( ! empty($date_format)) { |
|
195 | + update_post_meta($post_id, '_calendar_date_format_setting', 'use_custom_php'); |
|
196 | + update_post_meta($post_id, '_calendar_date_format_php', $date_format); |
|
197 | 197 | } else { |
198 | - update_post_meta( $post_id, '_calendar_date_format_setting', 'use_site' ); |
|
198 | + update_post_meta($post_id, '_calendar_date_format_setting', 'use_site'); |
|
199 | 199 | } |
200 | - $time_format = get_post_meta( $post_id, 'gce_time_format', true ); |
|
201 | - if ( ! empty( $time_format ) ) { |
|
202 | - update_post_meta( $post_id, '_calendar_time_format_setting', 'use_custom_php' ); |
|
203 | - update_post_meta( $post_id, '_calendar_time_format_php', $time_format ); |
|
200 | + $time_format = get_post_meta($post_id, 'gce_time_format', true); |
|
201 | + if ( ! empty($time_format)) { |
|
202 | + update_post_meta($post_id, '_calendar_time_format_setting', 'use_custom_php'); |
|
203 | + update_post_meta($post_id, '_calendar_time_format_php', $time_format); |
|
204 | 204 | } else { |
205 | - update_post_meta( $post_id, '_calendar_time_format_setting', 'use_site' ); |
|
205 | + update_post_meta($post_id, '_calendar_time_format_setting', 'use_site'); |
|
206 | 206 | } |
207 | - update_post_meta( $post_id, '_calendar_datetime_separator', '@' ); |
|
208 | - update_post_meta( $post_id, '_calendar_week_starts_on_setting', 'use_site' ); |
|
207 | + update_post_meta($post_id, '_calendar_datetime_separator', '@'); |
|
208 | + update_post_meta($post_id, '_calendar_week_starts_on_setting', 'use_site'); |
|
209 | 209 | |
210 | 210 | // Feed transient cache duration. |
211 | - $cache = get_post_meta( $post_id, 'gce_cache', true ); |
|
212 | - if ( is_numeric( $cache ) ) { |
|
213 | - $seconds = absint( $cache ); |
|
214 | - if ( $seconds < 3600 ) { |
|
211 | + $cache = get_post_meta($post_id, 'gce_cache', true); |
|
212 | + if (is_numeric($cache)) { |
|
213 | + $seconds = absint($cache); |
|
214 | + if ($seconds < 3600) { |
|
215 | 215 | $amount = $seconds / 60; |
216 | 216 | $unit = 60; |
217 | - } elseif ( $seconds < 86400 ) { |
|
217 | + } elseif ($seconds < 86400) { |
|
218 | 218 | $amount = $seconds / 3600; |
219 | 219 | $unit = 3600; |
220 | - } elseif ( $seconds < 604800 ) { |
|
220 | + } elseif ($seconds < 604800) { |
|
221 | 221 | $amount = $seconds / 86400; |
222 | 222 | $unit = 86400; |
223 | 223 | } else { |
224 | 224 | $amount = $seconds / 604800; |
225 | 225 | $unit = 604800; |
226 | 226 | } |
227 | - $amount = max( ceil( $amount ), 1 ); |
|
228 | - update_post_meta( $post_id, '_feed_cache_user_unit', $unit ); |
|
229 | - update_post_meta( $post_id, '_feed_cache_user_amount', $amount ); |
|
230 | - update_post_meta( $post_id, '_feed_cache', $unit * $amount ); |
|
227 | + $amount = max(ceil($amount), 1); |
|
228 | + update_post_meta($post_id, '_feed_cache_user_unit', $unit); |
|
229 | + update_post_meta($post_id, '_feed_cache_user_amount', $amount); |
|
230 | + update_post_meta($post_id, '_feed_cache', $unit * $amount); |
|
231 | 231 | } else { |
232 | - update_post_meta( $post_id, '_feed_cache_user_unit', 2 ); |
|
233 | - update_post_meta( $post_id, '_feed_cache_user_amount', 3600 ); |
|
234 | - update_post_meta( $post_id, '_feed_cache', 7200 ); |
|
232 | + update_post_meta($post_id, '_feed_cache_user_unit', 2); |
|
233 | + update_post_meta($post_id, '_feed_cache_user_amount', 3600); |
|
234 | + update_post_meta($post_id, '_feed_cache', 7200); |
|
235 | 235 | } |
236 | 236 | |
237 | - $this->delete_post_meta( $post_id ); |
|
237 | + $this->delete_post_meta($post_id); |
|
238 | 238 | |
239 | 239 | // Post updated. |
240 | - update_post_meta( $post_id, '_calendar_version', '3.0.0' ); |
|
240 | + update_post_meta($post_id, '_calendar_version', '3.0.0'); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @param int $post_id |
249 | 249 | */ |
250 | - public function delete_post_meta( $post_id ) { |
|
250 | + public function delete_post_meta($post_id) { |
|
251 | 251 | |
252 | 252 | $post_meta = array( |
253 | 253 | 'gce_cache', |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | 'gce_time_format', |
296 | 296 | ); |
297 | 297 | |
298 | - foreach ( $post_meta as $meta_key ) { |
|
299 | - delete_post_meta( $post_id, $meta_key ); |
|
298 | + foreach ($post_meta as $meta_key) { |
|
299 | + delete_post_meta($post_id, $meta_key); |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | public function update_post_type() { |
307 | 307 | |
308 | 308 | global $wpdb; |
309 | - $table = $wpdb->prefix . 'posts'; |
|
309 | + $table = $wpdb->prefix.'posts'; |
|
310 | 310 | |
311 | 311 | $wpdb->query( |
312 | 312 | " |
@@ -320,23 +320,23 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public function update_options() { |
322 | 322 | |
323 | - $old_settings = get_option( 'gce_settings_general' ); |
|
324 | - $new_settings_feeds = get_option( 'simple-calendar_settings_feeds' ); |
|
325 | - $new_settings_advanced = get_option( 'simple-calendar_settings_advanced' ); |
|
323 | + $old_settings = get_option('gce_settings_general'); |
|
324 | + $new_settings_feeds = get_option('simple-calendar_settings_feeds'); |
|
325 | + $new_settings_advanced = get_option('simple-calendar_settings_advanced'); |
|
326 | 326 | |
327 | 327 | // If empty probably using a legacy hardcoded key (no longer recommended). |
328 | - $new_settings_feeds['google']['api_key'] = ! empty( $old_settings['api_key'] ) ? $old_settings['api_key'] : ''; |
|
329 | - update_option( 'simple-calendar_settings_feeds', $new_settings_feeds ); |
|
328 | + $new_settings_feeds['google']['api_key'] = ! empty($old_settings['api_key']) ? $old_settings['api_key'] : ''; |
|
329 | + update_option('simple-calendar_settings_feeds', $new_settings_feeds); |
|
330 | 330 | |
331 | - $new_settings_advanced['assets']['disable_css'] = ! empty( $old_settings['disable_css'] ) ? 'yes' : ''; |
|
332 | - update_option( 'simple-calendar_settings_advanced', $new_settings_advanced ); |
|
331 | + $new_settings_advanced['assets']['disable_css'] = ! empty($old_settings['disable_css']) ? 'yes' : ''; |
|
332 | + update_option('simple-calendar_settings_advanced', $new_settings_advanced); |
|
333 | 333 | |
334 | 334 | // Delete legacy options. |
335 | - delete_option( 'gce_version' ); |
|
336 | - delete_option( 'gce_options' ); |
|
337 | - delete_option( 'gce_upgrade_has_run' ); |
|
338 | - delete_option( 'gce_v240_update_notices' ); |
|
339 | - delete_option( 'gce_show_admin_install_notice' ); |
|
335 | + delete_option('gce_version'); |
|
336 | + delete_option('gce_options'); |
|
337 | + delete_option('gce_upgrade_has_run'); |
|
338 | + delete_option('gce_v240_update_notices'); |
|
339 | + delete_option('gce_show_admin_install_notice'); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
@@ -344,26 +344,26 @@ discard block |
||
344 | 344 | */ |
345 | 345 | public function update_widgets() { |
346 | 346 | |
347 | - $old_widgets = get_option( 'widget_gce_widget' ); |
|
347 | + $old_widgets = get_option('widget_gce_widget'); |
|
348 | 348 | |
349 | - if ( ! empty( $old_widgets ) && is_array( $old_widgets ) ) { |
|
349 | + if ( ! empty($old_widgets) && is_array($old_widgets)) { |
|
350 | 350 | |
351 | 351 | $new_widgets = array(); |
352 | 352 | |
353 | - foreach ( $old_widgets as $i => $old_widget ) { |
|
354 | - if ( isset( $old_widget['id'] ) ) { |
|
353 | + foreach ($old_widgets as $i => $old_widget) { |
|
354 | + if (isset($old_widget['id'])) { |
|
355 | 355 | |
356 | - $id = absint( substr( $old_widget['id'], 0, strspn( $old_widget['id'], '0123456789' ) ) ); |
|
356 | + $id = absint(substr($old_widget['id'], 0, strspn($old_widget['id'], '0123456789'))); |
|
357 | 357 | |
358 | - if ( $id > 0 ) { |
|
359 | - $new_widgets[ $i ]['title'] = isset( $old_widget['name'] ) ? $old_widget['name'] : 'Simple Calendar'; |
|
360 | - $new_widgets[ $i ]['calendar_id'] = $id; |
|
358 | + if ($id > 0) { |
|
359 | + $new_widgets[$i]['title'] = isset($old_widget['name']) ? $old_widget['name'] : 'Simple Calendar'; |
|
360 | + $new_widgets[$i]['calendar_id'] = $id; |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
365 | - if ( ! empty( $new_widgets ) ) { |
|
366 | - update_option( 'widget_gce_widget', $new_widgets ); |
|
365 | + if ( ! empty($new_widgets)) { |
|
366 | + update_option('widget_gce_widget', $new_widgets); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | } |
@@ -377,10 +377,10 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @return string |
379 | 379 | */ |
380 | - private function convert_legacy_range( $date ) { |
|
381 | - $date = empty( $date ) ? date( 'm/d/Y', time() ) : $date; |
|
382 | - $timestamp = Carbon::createFromFormat( 'm/d/Y', $date )->getTimestamp(); |
|
383 | - return date( 'Y-m-d', $timestamp ); |
|
380 | + private function convert_legacy_range($date) { |
|
381 | + $date = empty($date) ? date('m/d/Y', time()) : $date; |
|
382 | + $timestamp = Carbon::createFromFormat('m/d/Y', $date)->getTimestamp(); |
|
383 | + return date('Y-m-d', $timestamp); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct() { |
36 | 36 | |
37 | - $this->widgets = apply_filters( 'simcal_get_widgets', array( |
|
37 | + $this->widgets = apply_filters('simcal_get_widgets', array( |
|
38 | 38 | 'SimpleCalendar\Widgets\Calendar' |
39 | - ), array() ); |
|
39 | + ), array()); |
|
40 | 40 | |
41 | - add_action( 'widgets_init', array( $this, 'register' ) ); |
|
41 | + add_action('widgets_init', array($this, 'register')); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | |
51 | 51 | $widgets = $this->widgets; |
52 | 52 | |
53 | - if ( ! empty( $widgets ) && is_array( $widgets ) ) { |
|
54 | - foreach ( $widgets as $widget ) { |
|
55 | - register_widget( $widget ); |
|
53 | + if ( ! empty($widgets) && is_array($widgets)) { |
|
54 | + foreach ($widgets as $widget) { |
|
55 | + register_widget($widget); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | - do_action( 'simcal_register_widgets' ); |
|
59 | + do_action('simcal_register_widgets'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use SimpleCalendar\Abstracts\Calendar_View; |
10 | 10 | use SimpleCalendar\Abstracts\Widget; |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -46,18 +46,18 @@ discard block |
||
46 | 46 | public function __construct() { |
47 | 47 | |
48 | 48 | $id_base = 'gce_widget'; // old id kept for legacy reasons |
49 | - $name = __( 'Simple Calendar', 'google-calendar-events' ); |
|
49 | + $name = __('Simple Calendar', 'google-calendar-events'); |
|
50 | 50 | $widget_options = array( |
51 | - 'description' => __( 'Display a calendar of events from one of your calendar feeds.', 'google-calendar-events' ) |
|
51 | + 'description' => __('Display a calendar of events from one of your calendar feeds.', 'google-calendar-events') |
|
52 | 52 | ); |
53 | 53 | |
54 | - parent::__construct( $id_base, $name, $widget_options ); |
|
54 | + parent::__construct($id_base, $name, $widget_options); |
|
55 | 55 | |
56 | - if ( is_admin() ) { |
|
57 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
56 | + if (is_admin()) { |
|
57 | + if ( ! defined('DOING_AJAX')) { |
|
58 | 58 | $this->calendars = simcal_get_calendars(); |
59 | 59 | } else { |
60 | - $this->calendars = get_transient( '_simple-calendar_feed_ids' ); |
|
60 | + $this->calendars = get_transient('_simple-calendar_feed_ids'); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | } |
@@ -70,18 +70,18 @@ discard block |
||
70 | 70 | * @param array $args Display arguments. |
71 | 71 | * @param array $instance The settings for the particular instance of the widget. |
72 | 72 | */ |
73 | - public function widget( $args, $instance ) { |
|
73 | + public function widget($args, $instance) { |
|
74 | 74 | |
75 | 75 | echo $args['before_widget']; |
76 | 76 | |
77 | - if ( ! empty( $instance['title'] ) ) { |
|
77 | + if ( ! empty($instance['title'])) { |
|
78 | 78 | |
79 | - echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title']; |
|
79 | + echo $args['before_title'].apply_filters('widget_title', $instance['title']).$args['after_title']; |
|
80 | 80 | } |
81 | 81 | |
82 | - $id = isset( $instance['calendar_id'] ) ? absint( $instance['calendar_id'] ) : 0; |
|
83 | - if ( $id > 0 ) { |
|
84 | - simcal_print_calendar( $id ); |
|
82 | + $id = isset($instance['calendar_id']) ? absint($instance['calendar_id']) : 0; |
|
83 | + if ($id > 0) { |
|
84 | + simcal_print_calendar($id); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | echo $args['after_widget']; |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return array Settings to save or bool false to cancel saving. |
103 | 103 | */ |
104 | - public function update( $new_instance, $old_instance ) { |
|
104 | + public function update($new_instance, $old_instance) { |
|
105 | 105 | |
106 | 106 | $instance = array(); |
107 | 107 | |
108 | - $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? sanitize_text_field( $new_instance['title'] ) : ''; |
|
109 | - $instance['calendar_id'] = ( ! empty( $new_instance['calendar_id'] ) ) ? absint( $new_instance['calendar_id'] ) : ''; |
|
108 | + $instance['title'] = ( ! empty($new_instance['title'])) ? sanitize_text_field($new_instance['title']) : ''; |
|
109 | + $instance['calendar_id'] = ( ! empty($new_instance['calendar_id'])) ? absint($new_instance['calendar_id']) : ''; |
|
110 | 110 | |
111 | 111 | return $instance; |
112 | 112 | } |
@@ -120,34 +120,34 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return string |
122 | 122 | */ |
123 | - public function form( $instance ) { |
|
123 | + public function form($instance) { |
|
124 | 124 | |
125 | - $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : __( 'Calendar', 'google-calendar-events' ); |
|
126 | - $calendar_id = isset( $instance['calendar_id'] ) ? esc_attr( $instance['calendar_id'] ) : ''; |
|
125 | + $title = isset($instance['title']) ? esc_attr($instance['title']) : __('Calendar', 'google-calendar-events'); |
|
126 | + $calendar_id = isset($instance['calendar_id']) ? esc_attr($instance['calendar_id']) : ''; |
|
127 | 127 | |
128 | 128 | ?> |
129 | 129 | <div class="simcal-calendar-widget-settings"> |
130 | 130 | |
131 | 131 | <p> |
132 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'google-calendar-events' ); ?></label> |
|
132 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'google-calendar-events'); ?></label> |
|
133 | 133 | <br> |
134 | 134 | <input type="text" |
135 | - name="<?php echo $this->get_field_name( 'title' ); ?>" |
|
136 | - id="<?php echo $this->get_field_id( 'title' ); ?>" |
|
135 | + name="<?php echo $this->get_field_name('title'); ?>" |
|
136 | + id="<?php echo $this->get_field_id('title'); ?>" |
|
137 | 137 | class="widefat simcal-field simcal-field-standard simcal-field-text" |
138 | 138 | value="<?php echo $title; ?>"> |
139 | 139 | </p> |
140 | 140 | |
141 | 141 | <p> |
142 | - <label for="<?php echo $this->get_field_id( 'calendar_id' ); ?>"><?php _e( 'Calendar:', 'google-calendar-events' ); ?></label> |
|
142 | + <label for="<?php echo $this->get_field_id('calendar_id'); ?>"><?php _e('Calendar:', 'google-calendar-events'); ?></label> |
|
143 | 143 | <br> |
144 | - <?php $multiselect = count( $this->calendars ) > 15 ? ' simcal-field-select-enhanced' : ''; ?> |
|
145 | - <select name="<?php echo $this->get_field_name( 'calendar_id' ) ?>" |
|
146 | - id="<?php echo $this->get_field_id( 'calendar_id' ) ?>" |
|
144 | + <?php $multiselect = count($this->calendars) > 15 ? ' simcal-field-select-enhanced' : ''; ?> |
|
145 | + <select name="<?php echo $this->get_field_name('calendar_id') ?>" |
|
146 | + id="<?php echo $this->get_field_id('calendar_id') ?>" |
|
147 | 147 | class="simcal-field simcal-field-select<?php echo $multiselect; ?>" |
148 | - data-noresults="<?php __( 'No calendars found.', 'google-calendar-events' ); ?>"> |
|
149 | - <?php foreach ( $this->calendars as $id => $name ) : ?> |
|
150 | - <option value="<?php echo $id; ?>" <?php selected( $id, $calendar_id, true ); ?>><?php echo $name; ?></option> |
|
148 | + data-noresults="<?php __('No calendars found.', 'google-calendar-events'); ?>"> |
|
149 | + <?php foreach ($this->calendars as $id => $name) : ?> |
|
150 | + <option value="<?php echo $id; ?>" <?php selected($id, $calendar_id, true); ?>><?php echo $name; ?></option> |
|
151 | 151 | <?php endforeach; ?> |
152 | 152 | </select> |
153 | 153 | </p> |
@@ -6,20 +6,20 @@ discard block |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | // Exit if not uninstalling from WordPress. |
9 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
9 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
13 | 13 | // Get user options whether to delete settings and/or data. |
14 | -$settings = get_option( 'simple-calendar_settings_advanced' ); |
|
14 | +$settings = get_option('simple-calendar_settings_advanced'); |
|
15 | 15 | |
16 | -if ( isset( $settings['installation']['delete_settings'] ) ) { |
|
16 | +if (isset($settings['installation']['delete_settings'])) { |
|
17 | 17 | $delete_settings = 'yes' == $settings['installation']['delete_settings'] ? true : false; |
18 | 18 | } else { |
19 | 19 | $delete_settings = false; |
20 | 20 | } |
21 | 21 | |
22 | -if ( isset( $settings['installation']['erase_data'] ) ) { |
|
22 | +if (isset($settings['installation']['erase_data'])) { |
|
23 | 23 | $erase_data = 'yes' == $settings['installation']['erase_data'] ? true : false; |
24 | 24 | } else { |
25 | 25 | $erase_data = false; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | global $wpdb; |
29 | 29 | |
30 | 30 | // Delete settings. |
31 | -if ( ( $delete_settings === true ) || ( $erase_data === true ) ) { |
|
31 | +if (($delete_settings === true) || ($erase_data === true)) { |
|
32 | 32 | $wpdb->query( |
33 | 33 | " |
34 | 34 | DELETE FROM $wpdb->options WHERE option_name LIKE '%simple-calendar%'; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | // Delete calendar data. |
40 | -if ( $erase_data === true ) { |
|
40 | +if ($erase_data === true) { |
|
41 | 41 | |
42 | 42 | // Delete calendar posts. |
43 | 43 | $wpdb->query( |
@@ -47,20 +47,20 @@ discard block |
||
47 | 47 | ); |
48 | 48 | |
49 | 49 | // Delete calendar postmeta. |
50 | - $wpdb->query( " |
|
50 | + $wpdb->query(" |
|
51 | 51 | DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL; |
52 | 52 | " |
53 | 53 | ); |
54 | 54 | |
55 | 55 | // Delete calendar terms. |
56 | - $terms = get_terms( array( |
|
56 | + $terms = get_terms(array( |
|
57 | 57 | 'calendar_category', |
58 | 58 | 'calendar_feed', |
59 | 59 | 'calendar_type', |
60 | - ) ); |
|
61 | - if ( ! empty( $terms ) && is_array( $terms ) ) { |
|
62 | - foreach ( $terms as $term ) { |
|
63 | - wp_delete_term( $term->term_id, $term->taxonomy ); |
|
60 | + )); |
|
61 | + if ( ! empty($terms) && is_array($terms)) { |
|
62 | + foreach ($terms as $term) { |
|
63 | + wp_delete_term($term->term_id, $term->taxonomy); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 |