@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | use SimpleCalendar\Admin\Notice; |
| 11 | 11 | use SimpleCalendar\Feeds\Google; |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param string $google_api_key |
| 55 | 55 | * @param string $google_calendar_id |
| 56 | 56 | */ |
| 57 | - public function __construct( Google $feed, $google_api_key, $google_calendar_id ) { |
|
| 57 | + public function __construct(Google $feed, $google_api_key, $google_calendar_id) { |
|
| 58 | 58 | |
| 59 | 59 | $this->feed = $feed; |
| 60 | 60 | $this->google_api_key = $google_api_key; |
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $screen = simcal_is_admin_screen(); |
| 64 | 64 | |
| 65 | - if ( 'calendar' == $screen ) { |
|
| 66 | - $this->test_api_key_connection( $this->google_calendar_id ); |
|
| 67 | - add_filter( 'simcal_settings_meta_tabs_li', array( $this, 'add_settings_meta_tab_li' ), 10, 1 ); |
|
| 68 | - add_action( 'simcal_settings_meta_panels', array( $this, 'add_settings_meta_panel' ), 10, 1 ); |
|
| 65 | + if ('calendar' == $screen) { |
|
| 66 | + $this->test_api_key_connection($this->google_calendar_id); |
|
| 67 | + add_filter('simcal_settings_meta_tabs_li', array($this, 'add_settings_meta_tab_li'), 10, 1); |
|
| 68 | + add_action('simcal_settings_meta_panels', array($this, 'add_settings_meta_panel'), 10, 1); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - add_action( 'simcal_process_settings_meta', array( $this, 'process_meta' ), 10, 1 ); |
|
| 71 | + add_action('simcal_process_settings_meta', array($this, 'process_meta'), 10, 1); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -81,20 +81,20 @@ discard block |
||
| 81 | 81 | public function settings_fields() { |
| 82 | 82 | return array( |
| 83 | 83 | 'name' => $this->feed->name, |
| 84 | - 'description' => __( "To read events from your public Google Calendars you'll need create a Google API key and save it here.", 'google-calendar-events' ) . |
|
| 85 | - '<br/><br/>' . |
|
| 86 | - '<em style="font-size: 14px;">' . |
|
| 87 | - sprintf( __( '<strong>Note:</strong> Calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong> use a different method of authorization.', 'google-calendar-events' ), |
|
| 88 | - simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'settings-link' ) |
|
| 89 | - ) . |
|
| 84 | + 'description' => __("To read events from your public Google Calendars you'll need create a Google API key and save it here.", 'google-calendar-events'). |
|
| 85 | + '<br/><br/>'. |
|
| 86 | + '<em style="font-size: 14px;">'. |
|
| 87 | + sprintf(__('<strong>Note:</strong> Calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong> use a different method of authorization.', 'google-calendar-events'), |
|
| 88 | + simcal_ga_campaign_url(simcal_get_url('gcal-pro'), 'core-plugin', 'settings-link') |
|
| 89 | + ). |
|
| 90 | 90 | '</em>', |
| 91 | 91 | 'fields' => array( |
| 92 | 92 | 'api_key' => array( |
| 93 | 93 | 'type' => 'standard', |
| 94 | 94 | 'subtype' => 'text', |
| 95 | - 'class' => array( 'simcal-wide-text regular-text', 'ltr' ), |
|
| 96 | - 'title' => __( 'Google API Key', 'google-calendar-events' ), |
|
| 97 | - 'validation' => array( $this, 'check_google_api_key' ), |
|
| 95 | + 'class' => array('simcal-wide-text regular-text', 'ltr'), |
|
| 96 | + 'title' => __('Google API Key', 'google-calendar-events'), |
|
| 97 | + 'validation' => array($this, 'check_google_api_key'), |
|
| 98 | 98 | ), |
| 99 | 99 | ), |
| 100 | 100 | ); |
@@ -113,27 +113,27 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return true|string |
| 115 | 115 | */ |
| 116 | - public function check_google_api_key( $api_key = '' ) { |
|
| 116 | + public function check_google_api_key($api_key = '') { |
|
| 117 | 117 | |
| 118 | 118 | $message = ''; |
| 119 | 119 | $has_errors = false; |
| 120 | 120 | |
| 121 | - if ( empty( $api_key ) ){ |
|
| 121 | + if (empty($api_key)) { |
|
| 122 | 122 | $api_key = $this->google_api_key; |
| 123 | - if ( empty( $api_key ) ) { |
|
| 124 | - $settings = get_option( 'simple-calendar_settings_feeds' ); |
|
| 125 | - $api_key = isset( $settings['google']['api_key'] ) ? esc_attr( $settings['google']['api_key'] ) : ''; |
|
| 123 | + if (empty($api_key)) { |
|
| 124 | + $settings = get_option('simple-calendar_settings_feeds'); |
|
| 125 | + $api_key = isset($settings['google']['api_key']) ? esc_attr($settings['google']['api_key']) : ''; |
|
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - $message = '<p class="description">' . |
|
| 130 | - sprintf( __( '<a href="%s" target="_blank">Step-by-step instructions</a> ', 'google-calendar-events' ), |
|
| 131 | - simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/google-api-key/', 'core-plugin', 'settings-link' ) |
|
| 132 | - ) . |
|
| 133 | - '<br/>' . |
|
| 134 | - sprintf( __( '<a href="%s" target="_blank">Google Developers Console</a> ', 'google-calendar-events' ), |
|
| 135 | - simcal_get_url( 'gdev-console' ) |
|
| 136 | - ) . |
|
| 129 | + $message = '<p class="description">'. |
|
| 130 | + sprintf(__('<a href="%s" target="_blank">Step-by-step instructions</a> ', 'google-calendar-events'), |
|
| 131 | + simcal_ga_campaign_url(simcal_get_url('docs').'/google-api-key/', 'core-plugin', 'settings-link') |
|
| 132 | + ). |
|
| 133 | + '<br/>'. |
|
| 134 | + sprintf(__('<a href="%s" target="_blank">Google Developers Console</a> ', 'google-calendar-events'), |
|
| 135 | + simcal_get_url('gdev-console') |
|
| 136 | + ). |
|
| 137 | 137 | '</p>'; |
| 138 | 138 | |
| 139 | 139 | return $message; |
@@ -148,15 +148,15 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @return array |
| 150 | 150 | */ |
| 151 | - public function add_settings_meta_tab_li( $tabs ) { |
|
| 152 | - return array_merge( $tabs, array( |
|
| 151 | + public function add_settings_meta_tab_li($tabs) { |
|
| 152 | + return array_merge($tabs, array( |
|
| 153 | 153 | 'google' => array( |
| 154 | 154 | 'label' => $this->feed->name, |
| 155 | 155 | 'target' => 'google-settings-panel', |
| 156 | - 'class' => array( 'simcal-feed-type', 'simcal-feed-type-google' ), |
|
| 156 | + 'class' => array('simcal-feed-type', 'simcal-feed-type-google'), |
|
| 157 | 157 | 'icon' => 'simcal-icon-google', |
| 158 | 158 | ), |
| 159 | - ) ); |
|
| 159 | + )); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @param int $post_id |
| 168 | 168 | */ |
| 169 | - public function add_settings_meta_panel( $post_id ) { |
|
| 169 | + public function add_settings_meta_panel($post_id) { |
|
| 170 | 170 | |
| 171 | 171 | $inputs = array( |
| 172 | 172 | $this->feed->type => array( |
@@ -175,30 +175,30 @@ discard block |
||
| 175 | 175 | 'subtype' => 'text', |
| 176 | 176 | 'name' => '_google_calendar_id', |
| 177 | 177 | 'id' => '_google_calendar_id', |
| 178 | - 'title' => __( 'Calendar ID', 'google-calendar-events' ), |
|
| 179 | - 'tooltip' => __( 'Visit your Google Calendar account, copy your public calendar ID, then paste it here.', 'google-calendar-events' ), |
|
| 180 | - 'placeholder' => __( 'Enter a valid Google Calendar ID from a public calendar', 'google-calendar-events' ), |
|
| 181 | - 'escaping' => array( $this->feed, 'esc_google_calendar_id' ), |
|
| 182 | - 'validation' => array( $this, 'test_api_key_connection' ), |
|
| 178 | + 'title' => __('Calendar ID', 'google-calendar-events'), |
|
| 179 | + 'tooltip' => __('Visit your Google Calendar account, copy your public calendar ID, then paste it here.', 'google-calendar-events'), |
|
| 180 | + 'placeholder' => __('Enter a valid Google Calendar ID from a public calendar', 'google-calendar-events'), |
|
| 181 | + 'escaping' => array($this->feed, 'esc_google_calendar_id'), |
|
| 182 | + 'validation' => array($this, 'test_api_key_connection'), |
|
| 183 | 183 | ), |
| 184 | 184 | '_google_events_search_query' => array( |
| 185 | 185 | 'type' => 'standard', |
| 186 | 186 | 'subtype' => 'text', |
| 187 | 187 | 'name' => '_google_events_search_query', |
| 188 | 188 | 'id' => '_google_events_search_query', |
| 189 | - 'title' => __( 'Search Query', 'google-calendar-events' ), |
|
| 190 | - 'tooltip' => __( 'Type in keywords if you only want display events that match these terms. You can use basic boolean search operators too.', 'google-calendar-events' ), |
|
| 191 | - 'placeholder' => __( 'Filter events to display by search terms...', 'google-calendar-events' ), |
|
| 189 | + 'title' => __('Search Query', 'google-calendar-events'), |
|
| 190 | + 'tooltip' => __('Type in keywords if you only want display events that match these terms. You can use basic boolean search operators too.', 'google-calendar-events'), |
|
| 191 | + 'placeholder' => __('Filter events to display by search terms...', 'google-calendar-events'), |
|
| 192 | 192 | ), |
| 193 | 193 | '_google_events_recurring' => array( |
| 194 | 194 | 'type' => 'select', |
| 195 | 195 | 'name' => '_google_events_recurring', |
| 196 | 196 | 'id' => '_google_events_recurring', |
| 197 | - 'title' => __( 'Recurring Events', 'google-calendar-events' ), |
|
| 198 | - 'tooltip' => __( 'Events that are programmed to repeat themselves periodically.', 'google-calendar-events' ), |
|
| 197 | + 'title' => __('Recurring Events', 'google-calendar-events'), |
|
| 198 | + 'tooltip' => __('Events that are programmed to repeat themselves periodically.', 'google-calendar-events'), |
|
| 199 | 199 | 'options' => array( |
| 200 | - 'show' => __( 'Show all', 'google-calendar-events' ), |
|
| 201 | - 'first-only' => __( 'Only show first occurrence', 'google-calendar-events' ), |
|
| 200 | + 'show' => __('Show all', 'google-calendar-events'), |
|
| 201 | + 'first-only' => __('Only show first occurrence', 'google-calendar-events'), |
|
| 202 | 202 | ), |
| 203 | 203 | ), |
| 204 | 204 | '_google_events_max_results' => array( |
@@ -206,8 +206,8 @@ discard block |
||
| 206 | 206 | 'subtype' => 'number', |
| 207 | 207 | 'name' => '_google_events_max_results', |
| 208 | 208 | 'id' => '_google_events_max_results', |
| 209 | - 'title' => __( 'Maximum Events', 'google-calendar-events' ), |
|
| 210 | - 'tooltip' => __( 'Google Calendar only allows to query for a maximum amount of 2500 events from a calendar each time.', 'google-calendar-events' ), |
|
| 209 | + 'title' => __('Maximum Events', 'google-calendar-events'), |
|
| 210 | + 'tooltip' => __('Google Calendar only allows to query for a maximum amount of 2500 events from a calendar each time.', 'google-calendar-events'), |
|
| 211 | 211 | 'class' => array( |
| 212 | 212 | 'simcal-field-small', |
| 213 | 213 | ), |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | <div id="google-settings-panel" class="simcal-panel"> |
| 225 | 225 | <table> |
| 226 | 226 | <thead> |
| 227 | - <tr><th colspan="2"><?php _e( 'Google Calendar Settings', 'google-calendar-events' ); ?></th></tr> |
|
| 227 | + <tr><th colspan="2"><?php _e('Google Calendar Settings', 'google-calendar-events'); ?></th></tr> |
|
| 228 | 228 | </thead> |
| 229 | - <?php Settings::print_panel_fields( $inputs, $post_id ); ?> |
|
| 229 | + <?php Settings::print_panel_fields($inputs, $post_id); ?> |
|
| 230 | 230 | </table> |
| 231 | 231 | </div> |
| 232 | 232 | <?php |
@@ -242,47 +242,47 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @return true|string |
| 244 | 244 | */ |
| 245 | - public function test_api_key_connection( $google_calendar_id ) { |
|
| 245 | + public function test_api_key_connection($google_calendar_id) { |
|
| 246 | 246 | |
| 247 | 247 | global $post; |
| 248 | 248 | |
| 249 | - $post_id = isset( $post->ID ) ? $post->ID : 0; |
|
| 249 | + $post_id = isset($post->ID) ? $post->ID : 0; |
|
| 250 | 250 | $feed = null; |
| 251 | - if ( $feed_type = wp_get_object_terms( $post_id, 'calendar_feed' ) ) { |
|
| 252 | - $feed = sanitize_title( current( $feed_type )->name ); |
|
| 251 | + if ($feed_type = wp_get_object_terms($post_id, 'calendar_feed')) { |
|
| 252 | + $feed = sanitize_title(current($feed_type)->name); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | $message = ''; |
| 256 | 256 | $error = ''; |
| 257 | 257 | $has_errors = false; |
| 258 | 258 | |
| 259 | - $message .= '<p class="description">' . |
|
| 259 | + $message .= '<p class="description">'. |
|
| 260 | 260 | sprintf( |
| 261 | - __( 'Step 1: Set the Google Calendar you want to use as <strong>"public."</strong> <a href="%1s" target="_blank">Detailed instructions</a>', 'google-calendar-events' ) . '<br />' . |
|
| 262 | - __( 'Step 2: Copy and paste your Google Calendar ID here. <a href="%2s" target="_blank">Detailed instructions</a>', 'google-calendar-events' ), |
|
| 263 | - simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/make-google-calendar-public/', 'core-plugin', 'settings-link' ), |
|
| 264 | - simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/find-google-calendar-id/', 'core-plugin', 'settings-link' ) |
|
| 265 | - ) . '</p>'; |
|
| 261 | + __('Step 1: Set the Google Calendar you want to use as <strong>"public."</strong> <a href="%1s" target="_blank">Detailed instructions</a>', 'google-calendar-events').'<br />'. |
|
| 262 | + __('Step 2: Copy and paste your Google Calendar ID here. <a href="%2s" target="_blank">Detailed instructions</a>', 'google-calendar-events'), |
|
| 263 | + simcal_ga_campaign_url(simcal_get_url('docs').'/make-google-calendar-public/', 'core-plugin', 'settings-link'), |
|
| 264 | + simcal_ga_campaign_url(simcal_get_url('docs').'/find-google-calendar-id/', 'core-plugin', 'settings-link') |
|
| 265 | + ).'</p>'; |
|
| 266 | 266 | |
| 267 | - if ( $post_id > 0 && ! is_null( $feed ) && ! empty( $this->feed->type ) ) { |
|
| 267 | + if ($post_id > 0 && ! is_null($feed) && ! empty($this->feed->type)) { |
|
| 268 | 268 | |
| 269 | - $no_key_notice = new Notice( array( |
|
| 270 | - 'id' => array( 'calendar_' . $post_id => 'google-no-api-key' ), |
|
| 269 | + $no_key_notice = new Notice(array( |
|
| 270 | + 'id' => array('calendar_'.$post_id => 'google-no-api-key'), |
|
| 271 | 271 | 'type' => 'error', |
| 272 | 272 | 'screen' => 'calendar', |
| 273 | 273 | 'post' => $post_id, |
| 274 | 274 | 'dismissable' => false, |
| 275 | - 'content' => '<p>' . |
|
| 276 | - '<i class="simcal-icon-warning"></i> ' . |
|
| 275 | + 'content' => '<p>'. |
|
| 276 | + '<i class="simcal-icon-warning"></i> '. |
|
| 277 | 277 | sprintf( |
| 278 | - __( 'Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events' ), |
|
| 279 | - admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds' ) |
|
| 280 | - ) . |
|
| 278 | + __('Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events'), |
|
| 279 | + admin_url('edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds') |
|
| 280 | + ). |
|
| 281 | 281 | '</p>', |
| 282 | 282 | ) |
| 283 | 283 | ); |
| 284 | 284 | |
| 285 | - if ( empty( $this->google_api_key ) && ( $feed == $this->feed->type ) ) { |
|
| 285 | + if (empty($this->google_api_key) && ($feed == $this->feed->type)) { |
|
| 286 | 286 | |
| 287 | 287 | $has_errors = true; |
| 288 | 288 | $no_key_notice->add(); |
@@ -292,28 +292,28 @@ discard block |
||
| 292 | 292 | $no_key_notice->remove(); |
| 293 | 293 | |
| 294 | 294 | try { |
| 295 | - $this->feed->make_request( $google_calendar_id ); |
|
| 296 | - } catch ( \Exception $e ) { |
|
| 295 | + $this->feed->make_request($google_calendar_id); |
|
| 296 | + } catch (\Exception $e) { |
|
| 297 | 297 | $error = $e->getMessage(); |
| 298 | - $message = ! empty( $error ) ? '<blockquote>' . $error . '</blockquote>' : ''; |
|
| 298 | + $message = ! empty($error) ? '<blockquote>'.$error.'</blockquote>' : ''; |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - $error_notice = new Notice( array( |
|
| 302 | - 'id' => array( 'calendar_' . $post_id => 'google-error-response' ), |
|
| 301 | + $error_notice = new Notice(array( |
|
| 302 | + 'id' => array('calendar_'.$post_id => 'google-error-response'), |
|
| 303 | 303 | 'type' => 'error', |
| 304 | 304 | 'screen' => 'calendar', |
| 305 | 305 | 'post' => $post_id, |
| 306 | 306 | 'dismissable' => false, |
| 307 | - 'content' => '<p>' . |
|
| 308 | - '<i class="simcal-icon-warning"></i> ' . |
|
| 309 | - __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' ) . |
|
| 310 | - '<br>' . $message . '<br>' . |
|
| 311 | - __( 'Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events' ) . |
|
| 307 | + 'content' => '<p>'. |
|
| 308 | + '<i class="simcal-icon-warning"></i> '. |
|
| 309 | + __('While trying to retrieve events, Google returned an error:', 'google-calendar-events'). |
|
| 310 | + '<br>'.$message.'<br>'. |
|
| 311 | + __('Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events'). |
|
| 312 | 312 | '</p>', |
| 313 | 313 | ) |
| 314 | 314 | ); |
| 315 | 315 | |
| 316 | - if ( ! empty( $error ) && ( $feed == $this->feed->type ) ) { |
|
| 316 | + if ( ! empty($error) && ($feed == $this->feed->type)) { |
|
| 317 | 317 | $error_notice->add(); |
| 318 | 318 | $has_errors = true; |
| 319 | 319 | } else { |
@@ -335,21 +335,21 @@ discard block |
||
| 335 | 335 | * |
| 336 | 336 | * @param int $post_id |
| 337 | 337 | */ |
| 338 | - public function process_meta( $post_id ) { |
|
| 338 | + public function process_meta($post_id) { |
|
| 339 | 339 | |
| 340 | - $calendar_id = isset( $_POST['_google_calendar_id'] ) ? base64_encode( trim( $_POST['_google_calendar_id'] ) ): ''; |
|
| 341 | - update_post_meta( $post_id, '_google_calendar_id', $calendar_id ); |
|
| 340 | + $calendar_id = isset($_POST['_google_calendar_id']) ? base64_encode(trim($_POST['_google_calendar_id'])) : ''; |
|
| 341 | + update_post_meta($post_id, '_google_calendar_id', $calendar_id); |
|
| 342 | 342 | |
| 343 | - $search_query = isset( $_POST['_google_events_search_query'] ) ? sanitize_text_field( $_POST['_google_events_search_query'] ) : ''; |
|
| 344 | - update_post_meta( $post_id, '_google_events_search_query', $search_query ); |
|
| 343 | + $search_query = isset($_POST['_google_events_search_query']) ? sanitize_text_field($_POST['_google_events_search_query']) : ''; |
|
| 344 | + update_post_meta($post_id, '_google_events_search_query', $search_query); |
|
| 345 | 345 | |
| 346 | - $recurring = isset( $_POST['_google_events_recurring'] ) ? sanitize_key( $_POST['_google_events_recurring'] ) : 'show'; |
|
| 347 | - update_post_meta( $post_id, '_google_events_recurring', $recurring ); |
|
| 346 | + $recurring = isset($_POST['_google_events_recurring']) ? sanitize_key($_POST['_google_events_recurring']) : 'show'; |
|
| 347 | + update_post_meta($post_id, '_google_events_recurring', $recurring); |
|
| 348 | 348 | |
| 349 | - $max_results = isset( $_POST['_google_events_max_results'] ) ? absint( $_POST['_google_events_max_results'] ) : '2500'; |
|
| 350 | - update_post_meta( $post_id, '_google_events_max_results', $max_results ); |
|
| 349 | + $max_results = isset($_POST['_google_events_max_results']) ? absint($_POST['_google_events_max_results']) : '2500'; |
|
| 350 | + update_post_meta($post_id, '_google_events_max_results', $max_results); |
|
| 351 | 351 | |
| 352 | - $this->test_api_key_connection( $calendar_id ); |
|
| 352 | + $this->test_api_key_connection($calendar_id); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Feeds\Grouped_Calendars; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -34,15 +34,15 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @param Grouped_Calendars $feed |
| 36 | 36 | */ |
| 37 | - public function __construct( Grouped_Calendars $feed ) { |
|
| 37 | + public function __construct(Grouped_Calendars $feed) { |
|
| 38 | 38 | |
| 39 | 39 | $this->feed = $feed; |
| 40 | 40 | |
| 41 | - if ( 'calendar' == simcal_is_admin_screen() ) { |
|
| 42 | - add_filter( 'simcal_settings_meta_tabs_li', array( $this, 'add_settings_meta_tab_li' ), 10, 1 ); |
|
| 43 | - add_action( 'simcal_settings_meta_panels', array( $this, 'add_settings_meta_panel' ), 10, 1 ); |
|
| 41 | + if ('calendar' == simcal_is_admin_screen()) { |
|
| 42 | + add_filter('simcal_settings_meta_tabs_li', array($this, 'add_settings_meta_tab_li'), 10, 1); |
|
| 43 | + add_action('simcal_settings_meta_panels', array($this, 'add_settings_meta_panel'), 10, 1); |
|
| 44 | 44 | } |
| 45 | - add_action( 'simcal_process_settings_meta', array( $this, 'process_meta' ), 10, 1 ); |
|
| 45 | + add_action('simcal_process_settings_meta', array($this, 'process_meta'), 10, 1); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @return array |
| 56 | 56 | */ |
| 57 | - public function add_settings_meta_tab_li( $tabs ) { |
|
| 58 | - return array_merge( $tabs, array( |
|
| 57 | + public function add_settings_meta_tab_li($tabs) { |
|
| 58 | + return array_merge($tabs, array( |
|
| 59 | 59 | 'grouped-calendars' => array( |
| 60 | 60 | 'label' => $this->feed->name, |
| 61 | 61 | 'target' => 'grouped-calendars-settings-panel', |
@@ -75,40 +75,40 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @param int $post_id |
| 77 | 77 | */ |
| 78 | - public function add_settings_meta_panel( $post_id ) { |
|
| 78 | + public function add_settings_meta_panel($post_id) { |
|
| 79 | 79 | |
| 80 | 80 | ?> |
| 81 | 81 | <div id="grouped-calendars-settings-panel" class="simcal-panel"> |
| 82 | 82 | <table> |
| 83 | 83 | <thead> |
| 84 | - <tr><th colspan="2"><?php _e( 'Grouped Calendar Settings', 'google-calendar-events' ); ?></th></tr> |
|
| 84 | + <tr><th colspan="2"><?php _e('Grouped Calendar Settings', 'google-calendar-events'); ?></th></tr> |
|
| 85 | 85 | </thead> |
| 86 | 86 | <tbody class="simcal-panel-section"> |
| 87 | 87 | <tr class="simcal-panel-field"> |
| 88 | - <th><label for="_grouped_calendars_source"><?php _e( 'Get Calendars From', 'google-calendar-events' ); ?></label></th> |
|
| 88 | + <th><label for="_grouped_calendars_source"><?php _e('Get Calendars From', 'google-calendar-events'); ?></label></th> |
|
| 89 | 89 | <td> |
| 90 | 90 | <?php |
| 91 | 91 | |
| 92 | - $source = esc_attr( get_post_meta( $post_id, '_grouped_calendars_source', true ) ); |
|
| 93 | - $source = empty( $source ) ? 'ids' : $source; |
|
| 92 | + $source = esc_attr(get_post_meta($post_id, '_grouped_calendars_source', true)); |
|
| 93 | + $source = empty($source) ? 'ids' : $source; |
|
| 94 | 94 | |
| 95 | 95 | ?> |
| 96 | 96 | <select name="_grouped_calendars_source" |
| 97 | 97 | id="_grouped_calendars_source" |
| 98 | 98 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-other" |
| 99 | 99 | data-show-field-on-choice="true"> |
| 100 | - <option value="ids" data-show-field="_grouped_calendars_ids" <?php selected( 'ids', $source, true ); ?>><?php _e( 'Manual selection', 'google-calendar-events' ); ?></option> |
|
| 101 | - <option value="category" data-show-field="_grouped_calendars_category" <?php selected( 'category', $source, true ); ?>><?php _e( 'Category', 'google-calendar-events' ); ?></option> |
|
| 100 | + <option value="ids" data-show-field="_grouped_calendars_ids" <?php selected('ids', $source, true); ?>><?php _e('Manual selection', 'google-calendar-events'); ?></option> |
|
| 101 | + <option value="category" data-show-field="_grouped_calendars_category" <?php selected('category', $source, true); ?>><?php _e('Category', 'google-calendar-events'); ?></option> |
|
| 102 | 102 | </select> |
| 103 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Choose from which calendar feeds you want to get events from. Choose them individually or select all those belonging to calendar feed categories.', 'google-calendar-events' ); ?>"></i> |
|
| 103 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Choose from which calendar feeds you want to get events from. Choose them individually or select all those belonging to calendar feed categories.', 'google-calendar-events'); ?>"></i> |
|
| 104 | 104 | <br><br> |
| 105 | 105 | <?php |
| 106 | 106 | |
| 107 | - $cals = simcal_get_calendars( $post_id ); |
|
| 108 | - $meta = get_post_meta( $post_id, '_grouped_calendars_ids', true ); |
|
| 109 | - $ids = $meta && is_array( $meta ) ? implode( ',', array_map( 'absint', $meta ) ) : absint( $meta ); |
|
| 107 | + $cals = simcal_get_calendars($post_id); |
|
| 108 | + $meta = get_post_meta($post_id, '_grouped_calendars_ids', true); |
|
| 109 | + $ids = $meta && is_array($meta) ? implode(',', array_map('absint', $meta)) : absint($meta); |
|
| 110 | 110 | |
| 111 | - simcal_print_field( array( |
|
| 111 | + simcal_print_field(array( |
|
| 112 | 112 | 'type' => 'select', |
| 113 | 113 | 'multiselect' => 'multiselect', |
| 114 | 114 | 'name' => '_grouped_calendars_ids', |
@@ -116,25 +116,25 @@ discard block |
||
| 116 | 116 | 'value' => $ids !== 0 ? $ids : '', |
| 117 | 117 | 'options' => $cals, |
| 118 | 118 | 'enhanced' => 'enhanced', |
| 119 | - 'style' => 'ids' == $source ? '' : array( 'display' => 'none' ), |
|
| 119 | + 'style' => 'ids' == $source ? '' : array('display' => 'none'), |
|
| 120 | 120 | 'attributes' => array( |
| 121 | - 'data-noresults' => __( 'No results found.', 'google-calendar-events' ), |
|
| 121 | + 'data-noresults' => __('No results found.', 'google-calendar-events'), |
|
| 122 | 122 | ), |
| 123 | 123 | )); |
| 124 | 124 | |
| 125 | - $meta = get_post_meta( $post_id, '_grouped_calendars_category', true ); |
|
| 126 | - $category = $meta && is_array( $meta ) ? implode( ',', array_map( 'absint', $meta ) ): ''; |
|
| 125 | + $meta = get_post_meta($post_id, '_grouped_calendars_category', true); |
|
| 126 | + $category = $meta && is_array($meta) ? implode(',', array_map('absint', $meta)) : ''; |
|
| 127 | 127 | |
| 128 | - $terms = get_terms( 'calendar_category' ); |
|
| 128 | + $terms = get_terms('calendar_category'); |
|
| 129 | 129 | |
| 130 | - if ( ! empty( $terms ) ) { |
|
| 130 | + if ( ! empty($terms)) { |
|
| 131 | 131 | |
| 132 | 132 | $categories = array(); |
| 133 | - foreach ( $terms as $term ) { |
|
| 134 | - $categories[ $term->term_id ] = $term->name; |
|
| 133 | + foreach ($terms as $term) { |
|
| 134 | + $categories[$term->term_id] = $term->name; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - simcal_print_field( array( |
|
| 137 | + simcal_print_field(array( |
|
| 138 | 138 | 'type' => 'select', |
| 139 | 139 | 'multiselect' => 'multiselect', |
| 140 | 140 | 'name' => '_grouped_calendars_category', |
@@ -142,17 +142,17 @@ discard block |
||
| 142 | 142 | 'value' => $category, |
| 143 | 143 | 'options' => $categories, |
| 144 | 144 | 'enhanced' => 'enhanced', |
| 145 | - 'style' => 'category' == $source ? '' : array( 'display' => 'none' ), |
|
| 145 | + 'style' => 'category' == $source ? '' : array('display' => 'none'), |
|
| 146 | 146 | 'attributes' => array( |
| 147 | - 'data-noresults' => __( 'No results found.', 'google-calendar-events' ), |
|
| 147 | + 'data-noresults' => __('No results found.', 'google-calendar-events'), |
|
| 148 | 148 | ), |
| 149 | - ) ); |
|
| 149 | + )); |
|
| 150 | 150 | |
| 151 | 151 | } else { |
| 152 | 152 | |
| 153 | 153 | $style = 'category' == $source ? '' : 'display: none;'; |
| 154 | 154 | $style .= ' width: 100%; max-width: 500px'; |
| 155 | - echo '<input type="text" disabled="disabled" name="_grouped_calendars_category" id="_grouped_calendars_category" style="' . $style . '" placeholder="' . __( 'There are no calendar categories yet.', 'google-calendar-events' ) . '" />'; |
|
| 155 | + echo '<input type="text" disabled="disabled" name="_grouped_calendars_category" id="_grouped_calendars_category" style="'.$style.'" placeholder="'.__('There are no calendar categories yet.', 'google-calendar-events').'" />'; |
|
| 156 | 156 | |
| 157 | 157 | } |
| 158 | 158 | |
@@ -173,16 +173,16 @@ discard block |
||
| 173 | 173 | * |
| 174 | 174 | * @param int $post_id |
| 175 | 175 | */ |
| 176 | - public function process_meta( $post_id ) { |
|
| 176 | + public function process_meta($post_id) { |
|
| 177 | 177 | |
| 178 | - $source = isset( $_POST['_grouped_calendars_source'] ) ? sanitize_key( $_POST['_grouped_calendars_source'] ) : 'ids'; |
|
| 179 | - update_post_meta( $post_id, '_grouped_calendars_source', $source ); |
|
| 178 | + $source = isset($_POST['_grouped_calendars_source']) ? sanitize_key($_POST['_grouped_calendars_source']) : 'ids'; |
|
| 179 | + update_post_meta($post_id, '_grouped_calendars_source', $source); |
|
| 180 | 180 | |
| 181 | - $ids = isset( $_POST['_grouped_calendars_ids'] ) ? array_map( 'absint', $_POST['_grouped_calendars_ids'] ) : ''; |
|
| 182 | - update_post_meta( $post_id, '_grouped_calendars_ids', $ids ); |
|
| 181 | + $ids = isset($_POST['_grouped_calendars_ids']) ? array_map('absint', $_POST['_grouped_calendars_ids']) : ''; |
|
| 182 | + update_post_meta($post_id, '_grouped_calendars_ids', $ids); |
|
| 183 | 183 | |
| 184 | - $category = isset( $_POST['_grouped_calendars_category'] ) ? array_map( 'absint', $_POST['_grouped_calendars_category'] ) : ''; |
|
| 185 | - update_post_meta( $post_id, '_grouped_calendars_category', $category ); |
|
| 184 | + $category = isset($_POST['_grouped_calendars_category']) ? array_map('absint', $_POST['_grouped_calendars_category']) : ''; |
|
| 185 | + update_post_meta($post_id, '_grouped_calendars_category', $category); |
|
| 186 | 186 | |
| 187 | 187 | } |
| 188 | 188 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Admin\Metaboxes as Metabox; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function __construct() { |
| 46 | 46 | |
| 47 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
| 48 | - if ( isset( $settings['general']['attach_calendars_posts'] ) ) { |
|
| 47 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
| 48 | + if (isset($settings['general']['attach_calendars_posts'])) { |
|
| 49 | 49 | $this->post_types = $settings['general']['attach_calendars_posts']; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -53,17 +53,17 @@ discard block |
||
| 53 | 53 | new Metabox\Settings(); |
| 54 | 54 | new Metabox\Attach_Calendar(); |
| 55 | 55 | new Metabox\Newsletter(); |
| 56 | - do_action( 'simcal_load_meta_boxes' ); |
|
| 56 | + do_action('simcal_load_meta_boxes'); |
|
| 57 | 57 | |
| 58 | 58 | // Add meta boxes. |
| 59 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 30 ); |
|
| 59 | + add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 30); |
|
| 60 | 60 | |
| 61 | 61 | // Process meta boxes. |
| 62 | - add_action( 'simcal_save_settings_meta','\SimpleCalendar\Admin\Metaboxes\Settings::save', 10, 2 ); |
|
| 63 | - add_action( 'simcal_save_attach_calendar_meta','\SimpleCalendar\Admin\Metaboxes\Attach_Calendar::save', 10, 2 ); |
|
| 62 | + add_action('simcal_save_settings_meta', '\SimpleCalendar\Admin\Metaboxes\Settings::save', 10, 2); |
|
| 63 | + add_action('simcal_save_attach_calendar_meta', '\SimpleCalendar\Admin\Metaboxes\Attach_Calendar::save', 10, 2); |
|
| 64 | 64 | |
| 65 | 65 | // Save meta boxes data. |
| 66 | - add_action( 'save_post', array( $this, 'save_meta_boxes' ), 1, 2 ); |
|
| 66 | + add_action('save_post', array($this, 'save_meta_boxes'), 1, 2); |
|
| 67 | 67 | |
| 68 | 68 | // Uncomment this for debugging $_POST while saving a meta box. |
| 69 | 69 | // add_action( 'save_post', function() { echo '<pre>'; print_r( $_POST ); echo '</pre>'; die(); } ); |
@@ -78,19 +78,19 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | add_meta_box( |
| 80 | 80 | 'simcal-calendar-settings', |
| 81 | - __( 'Calendar Settings', 'google-calendar-events' ), |
|
| 81 | + __('Calendar Settings', 'google-calendar-events'), |
|
| 82 | 82 | '\SimpleCalendar\Admin\Metaboxes\Settings::html', |
| 83 | 83 | 'calendar', |
| 84 | 84 | 'normal', |
| 85 | 85 | 'core' |
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | - $addons = apply_filters( 'simcal_installed_addons', array() ); |
|
| 89 | - if ( empty( $addons ) ) { |
|
| 88 | + $addons = apply_filters('simcal_installed_addons', array()); |
|
| 89 | + if (empty($addons)) { |
|
| 90 | 90 | |
| 91 | 91 | add_meta_box( |
| 92 | 92 | 'simcal-newsletter', |
| 93 | - __( 'Get 20% off all Pro Add-ons', 'google-calendar-events' ), |
|
| 93 | + __('Get 20% off all Pro Add-ons', 'google-calendar-events'), |
|
| 94 | 94 | '\SimpleCalendar\Admin\Metaboxes\Newsletter::html', |
| 95 | 95 | 'calendar', |
| 96 | 96 | 'side', |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | add_meta_box( |
| 103 | 103 | 'simcal-get-shortcode', |
| 104 | - __( 'Calendar Shortcode', 'google-calendar-events' ), |
|
| 104 | + __('Calendar Shortcode', 'google-calendar-events'), |
|
| 105 | 105 | '\SimpleCalendar\Admin\Metaboxes\Get_Shortcode::html', |
| 106 | 106 | 'calendar', |
| 107 | 107 | 'side', |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | ); |
| 110 | 110 | |
| 111 | 111 | // Add meta box if there are calendars. |
| 112 | - if ( ( true == simcal_get_calendars() ) && ! empty( $this->post_types ) ) { |
|
| 113 | - foreach ( $this->post_types as $post_type ) { |
|
| 112 | + if ((true == simcal_get_calendars()) && ! empty($this->post_types)) { |
|
| 113 | + foreach ($this->post_types as $post_type) { |
|
| 114 | 114 | add_meta_box( |
| 115 | 115 | 'simcal-attach-calendar', |
| 116 | - __( 'Attach Calendar', 'google-calendar-events' ), |
|
| 116 | + __('Attach Calendar', 'google-calendar-events'), |
|
| 117 | 117 | '\SimpleCalendar\Admin\Metaboxes\Attach_Calendar::html', |
| 118 | 118 | $post_type, |
| 119 | 119 | 'side', |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - do_action( 'simcal_add_meta_boxes' ); |
|
| 125 | + do_action('simcal_add_meta_boxes'); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -135,30 +135,30 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return void |
| 137 | 137 | */ |
| 138 | - public function save_meta_boxes( $post_id, $post ) { |
|
| 138 | + public function save_meta_boxes($post_id, $post) { |
|
| 139 | 139 | |
| 140 | 140 | // $post_id and $post are required. |
| 141 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
| 141 | + if (empty($post_id) || empty($post) || self::$saved_meta_boxes) { |
|
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // Don't save meta boxes for revisions or autosaves. |
| 146 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
| 146 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
| 147 | 147 | return; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // Check the nonce. |
| 151 | - if ( empty( $_POST['simcal_meta_nonce'] ) || ! wp_verify_nonce( $_POST['simcal_meta_nonce'], 'simcal_save_data' ) ) { |
|
| 151 | + if (empty($_POST['simcal_meta_nonce']) || ! wp_verify_nonce($_POST['simcal_meta_nonce'], 'simcal_save_data')) { |
|
| 152 | 152 | return; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
| 156 | - if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { |
|
| 156 | + if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) { |
|
| 157 | 157 | return; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Check user has permission to edit |
| 161 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 161 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
| 162 | 162 | return; |
| 163 | 163 | } |
| 164 | 164 | |
@@ -171,13 +171,13 @@ discard block |
||
| 171 | 171 | self::$saved_meta_boxes = true; |
| 172 | 172 | |
| 173 | 173 | // Check the post type. |
| 174 | - if ( 'calendar' == $post->post_type ) { |
|
| 175 | - do_action( 'simcal_save_settings_meta', $post_id, $post ); |
|
| 176 | - } elseif ( in_array( $post->post_type, $this->post_types ) ) { |
|
| 177 | - do_action( 'simcal_save_attach_calendar_meta', $post_id, $post ); |
|
| 174 | + if ('calendar' == $post->post_type) { |
|
| 175 | + do_action('simcal_save_settings_meta', $post_id, $post); |
|
| 176 | + } elseif (in_array($post->post_type, $this->post_types)) { |
|
| 177 | + do_action('simcal_save_attach_calendar_meta', $post_id, $post); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - do_action( 'simcal_save_meta_boxes', $post_id, $post ); |
|
| 180 | + do_action('simcal_save_meta_boxes', $post_id, $post); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | } |
@@ -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 | |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @param array $field |
| 36 | 36 | */ |
| 37 | - public function __construct( $field ) { |
|
| 38 | - $this->addon = isset( $field['addon'] ) ? esc_attr( $field['addon'] ) : ''; |
|
| 37 | + public function __construct($field) { |
|
| 38 | + $this->addon = isset($field['addon']) ? esc_attr($field['addon']) : ''; |
|
| 39 | 39 | $this->type_class = 'simcal-field-license'; |
| 40 | - parent::__construct( $field ); |
|
| 40 | + parent::__construct($field); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function html() { |
| 49 | 49 | |
| 50 | - if ( ! empty( $this->addon ) ) { |
|
| 50 | + if ( ! empty($this->addon)) { |
|
| 51 | 51 | |
| 52 | - $status = apply_filters( 'simcal_addon_status_' . $this->addon, simcal_get_license_status( $this->addon ) ); |
|
| 52 | + $status = apply_filters('simcal_addon_status_'.$this->addon, simcal_get_license_status($this->addon)); |
|
| 53 | 53 | |
| 54 | - if ( $status !== 'valid' ) { |
|
| 54 | + if ($status !== 'valid') { |
|
| 55 | 55 | $display_activate = 'display: inline-block'; |
| 56 | 56 | $display_deactivate = 'display: none'; |
| 57 | 57 | $active = 'valid' == $status ? 'display: block' : 'display: none'; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | } else { |
| 60 | 60 | $display_activate = $active = 'display: none'; |
| 61 | 61 | $display_deactivate = 'display: inline-block'; |
| 62 | - $disabled = empty( $this->value ) ? '' : 'disabled="disabled"'; |
|
| 62 | + $disabled = empty($this->value) ? '' : 'disabled="disabled"'; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | ?> |
@@ -74,16 +74,16 @@ discard block |
||
| 74 | 74 | <span class="simcal-addon-manage-license-buttons"> |
| 75 | 75 | |
| 76 | 76 | <button class="button-secondary simcal-addon-manage-license deactivate" data-add-on="<?php echo $this->addon; ?>" style="<?php echo $display_deactivate; ?>"> |
| 77 | - <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e( 'Deactivate', 'google-calendar-events' ); ?> |
|
| 77 | + <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e('Deactivate', 'google-calendar-events'); ?> |
|
| 78 | 78 | </button> |
| 79 | 79 | |
| 80 | 80 | <button class="button-secondary simcal-addon-manage-license activate" data-add-on="<?php echo $this->addon; ?>" style="<?php echo $display_activate; ?>"> |
| 81 | - <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e( 'Activate', 'google-calendar-events' ); ?> |
|
| 81 | + <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e('Activate', 'google-calendar-events'); ?> |
|
| 82 | 82 | </button> |
| 83 | 83 | |
| 84 | 84 | <span class="error" style="color: red; display: none"> </span> |
| 85 | 85 | |
| 86 | - <strong class="label" style="color:green; <?php echo $active; ?>"> <?php _e( '(active)', 'google-calendar-events' ); ?></strong> |
|
| 86 | + <strong class="label" style="color:green; <?php echo $active; ?>"> <?php _e('(active)', 'google-calendar-events'); ?></strong> |
|
| 87 | 87 | |
| 88 | 88 | </span> |
| 89 | 89 | |
@@ -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; // Exit if accessed directly. |
| 13 | 13 | } |
| 14 | 14 | |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @param array $field |
| 30 | 30 | */ |
| 31 | - public function __construct( $field ) { |
|
| 31 | + public function __construct($field) { |
|
| 32 | 32 | $this->type_class = 'simcal-field-checkboxes'; |
| 33 | - parent::__construct( $field ); |
|
| 33 | + parent::__construct($field); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -40,33 +40,33 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function html() { |
| 42 | 42 | |
| 43 | - if ( ! empty( $this->options ) && count( (array) $this->options ) > 1 ) { |
|
| 43 | + if ( ! empty($this->options) && count((array) $this->options) > 1) { |
|
| 44 | 44 | |
| 45 | - if ( ! empty( $this->description ) ) { |
|
| 46 | - echo '<p class="description">' . wp_kses_post( $this->description ) . ' ' . $this->tooltip . '</p>'; |
|
| 45 | + if ( ! empty($this->description)) { |
|
| 46 | + echo '<p class="description">'.wp_kses_post($this->description).' '.$this->tooltip.'</p>'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | ?> |
| 50 | - <fieldset class="<?php echo $this->class; ?>" <?php echo ! empty( $this->style ) ? 'style="' . $this->style . '"' : ''; ?>> |
|
| 50 | + <fieldset class="<?php echo $this->class; ?>" <?php echo ! empty($this->style) ? 'style="'.$this->style.'"' : ''; ?>> |
|
| 51 | 51 | <?php |
| 52 | 52 | |
| 53 | - if ( ! empty( $this->title ) ) { |
|
| 54 | - echo '<legend class="screen-reader-text"><span>' . $this->title . '</span></legend>'; |
|
| 53 | + if ( ! empty($this->title)) { |
|
| 54 | + echo '<legend class="screen-reader-text"><span>'.$this->title.'</span></legend>'; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | ?> |
| 58 | 58 | <ul> |
| 59 | - <?php foreach ( $this->options as $option => $name ) : ?> |
|
| 59 | + <?php foreach ($this->options as $option => $name) : ?> |
|
| 60 | 60 | <li> |
| 61 | - <label for="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>"> |
|
| 61 | + <label for="<?php echo $this->id.'-'.trim(strval($option)); ?>"> |
|
| 62 | 62 | <input name="<?php echo $this->name; ?>" |
| 63 | - id="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>" |
|
| 63 | + id="<?php echo $this->id.'-'.trim(strval($option)); ?>" |
|
| 64 | 64 | class="simcal-field simcal-field-checkbox" |
| 65 | 65 | type="checkbox" |
| 66 | - value="<?php echo trim( strval( $option ) ); ?>" |
|
| 67 | - <?php checked( $this->value, 'yes', true ); ?> |
|
| 66 | + value="<?php echo trim(strval($option)); ?>" |
|
| 67 | + <?php checked($this->value, 'yes', true); ?> |
|
| 68 | 68 | <?php echo $this->attributes; ?> |
| 69 | - /><?php echo esc_attr( $name ); ?> |
|
| 69 | + /><?php echo esc_attr($name); ?> |
|
| 70 | 70 | </label> |
| 71 | 71 | </li> |
| 72 | 72 | <?php endforeach; ?> |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | } else { |
| 78 | 78 | |
| 79 | 79 | ?> |
| 80 | - <span class="simcal-field-bool" <?php echo $this->style ? 'style="' . $this->style . '"' : ''; ?>> |
|
| 81 | - <?php if ( ! empty( $this->title ) ) : ?> |
|
| 80 | + <span class="simcal-field-bool" <?php echo $this->style ? 'style="'.$this->style.'"' : ''; ?>> |
|
| 81 | + <?php if ( ! empty($this->title)) : ?> |
|
| 82 | 82 | <span class="screen-reader-text"><?php echo $this->title; ?></span> |
| 83 | 83 | <?php endif; ?> |
| 84 | 84 | <input name="<?php echo $this->name; ?>" |
@@ -86,15 +86,15 @@ discard block |
||
| 86 | 86 | id="<?php echo $this->id; ?>" |
| 87 | 87 | class="simcal-field simcal-field-checkbox <?php echo $this->class; ?>" |
| 88 | 88 | value="yes" |
| 89 | - <?php checked( $this->value, 'yes', true ); ?> |
|
| 90 | - <?php echo $this->attributes; ?>/><?php echo ( ! empty( $this->text ) ? $this->text : __( 'Yes', 'google-calendar-events' ) ); ?> |
|
| 89 | + <?php checked($this->value, 'yes', true); ?> |
|
| 90 | + <?php echo $this->attributes; ?>/><?php echo ( ! empty($this->text) ? $this->text : __('Yes', 'google-calendar-events')); ?> |
|
| 91 | 91 | </span> |
| 92 | 92 | <?php |
| 93 | 93 | |
| 94 | 94 | echo $this->tooltip; |
| 95 | 95 | |
| 96 | - if ( ! empty( $this->description ) ) { |
|
| 97 | - echo '<p class="description">' . wp_kses_post( $this->description ) . '</p>'; |
|
| 96 | + if ( ! empty($this->description)) { |
|
| 97 | + echo '<p class="description">'.wp_kses_post($this->description).'</p>'; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | } |
@@ -143,7 +143,7 @@ |
||
| 143 | 143 | |
| 144 | 144 | $links = array(); |
| 145 | 145 | $links['add-ons'] = '<a href="' . simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'plugin-listing' ) . '" target="_blank" >' . |
| 146 | - __( 'Add-ons', 'google-calendar-events' ) . '</a>'; |
|
| 146 | + __( 'Add-ons', 'google-calendar-events' ) . '</a>'; |
|
| 147 | 147 | |
| 148 | 148 | return apply_filters( 'simcal_plugin_action_links', array_merge( $meta_links, $links ) ); |
| 149 | 149 | } |
@@ -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 | |
@@ -44,17 +44,17 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | self::$main_menu = 'edit.php?post_type=calendar'; |
| 46 | 46 | |
| 47 | - add_action( 'admin_menu', array( __CLASS__, 'add_menu_items' ) ); |
|
| 47 | + add_action('admin_menu', array(__CLASS__, 'add_menu_items')); |
|
| 48 | 48 | |
| 49 | - self::$plugin = plugin_basename( SIMPLE_CALENDAR_MAIN_FILE ); |
|
| 49 | + self::$plugin = plugin_basename(SIMPLE_CALENDAR_MAIN_FILE); |
|
| 50 | 50 | |
| 51 | 51 | new Welcome(); |
| 52 | 52 | |
| 53 | 53 | // Links and meta content in plugins page. |
| 54 | - add_filter( 'plugin_action_links_' . self::$plugin, array( __CLASS__, 'plugin_action_links' ), 10, 5 ); |
|
| 55 | - add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 ); |
|
| 54 | + add_filter('plugin_action_links_'.self::$plugin, array(__CLASS__, 'plugin_action_links'), 10, 5); |
|
| 55 | + add_filter('plugin_row_meta', array(__CLASS__, 'plugin_row_meta'), 10, 2); |
|
| 56 | 56 | // Custom text in admin footer. |
| 57 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 ); |
|
| 57 | + add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -66,41 +66,41 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | add_submenu_page( |
| 68 | 68 | self::$main_menu, |
| 69 | - __( 'Settings', 'google-calendar-events' ), |
|
| 70 | - __( 'Settings', 'google-calendar-events' ), |
|
| 69 | + __('Settings', 'google-calendar-events'), |
|
| 70 | + __('Settings', 'google-calendar-events'), |
|
| 71 | 71 | 'manage_options', |
| 72 | 72 | 'simple-calendar_settings', |
| 73 | - function () { |
|
| 74 | - $page = new Pages( 'settings' ); |
|
| 73 | + function() { |
|
| 74 | + $page = new Pages('settings'); |
|
| 75 | 75 | $page->html(); |
| 76 | 76 | } |
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | 79 | add_submenu_page( |
| 80 | 80 | self::$main_menu, |
| 81 | - __( 'Add-ons', 'google-calendar-events' ), |
|
| 82 | - __( 'Add-ons', 'google-calendar-events' ), |
|
| 81 | + __('Add-ons', 'google-calendar-events'), |
|
| 82 | + __('Add-ons', 'google-calendar-events'), |
|
| 83 | 83 | 'manage_options', |
| 84 | 84 | 'simple-calendar_add_ons', |
| 85 | 85 | function() { |
| 86 | - $page = new Pages( 'add-ons' ); |
|
| 86 | + $page = new Pages('add-ons'); |
|
| 87 | 87 | $page->html(); |
| 88 | 88 | } |
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | 91 | add_submenu_page( |
| 92 | 92 | self::$main_menu, |
| 93 | - __( 'Tools', 'google-calendar-events' ), |
|
| 94 | - __( 'Tools', 'google-calendar-events' ), |
|
| 93 | + __('Tools', 'google-calendar-events'), |
|
| 94 | + __('Tools', 'google-calendar-events'), |
|
| 95 | 95 | 'manage_options', |
| 96 | 96 | 'simple-calendar_tools', |
| 97 | - function () { |
|
| 98 | - $page = new Pages( 'tools' ); |
|
| 97 | + function() { |
|
| 98 | + $page = new Pages('tools'); |
|
| 99 | 99 | $page->html(); |
| 100 | 100 | } |
| 101 | 101 | ); |
| 102 | 102 | |
| 103 | - do_action( 'simcal_admin_add_menu_items' ); |
|
| 103 | + do_action('simcal_admin_add_menu_items'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return array |
| 115 | 115 | */ |
| 116 | - public static function plugin_action_links( $action_links, $file ) { |
|
| 116 | + public static function plugin_action_links($action_links, $file) { |
|
| 117 | 117 | |
| 118 | - if ( self::$plugin == $file ) { |
|
| 118 | + if (self::$plugin == $file) { |
|
| 119 | 119 | |
| 120 | 120 | $links = array(); |
| 121 | - $links['settings'] = '<a href="' . admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings' ) . '">' . __( 'Settings', 'google-calendar-events' ) . '</a>'; |
|
| 122 | - $links['feeds'] = '<a href="' . admin_url( 'edit.php?post_type=calendar' ) . '">' . __( 'Calendars', 'google-calendar-events' ) . '</a>'; |
|
| 121 | + $links['settings'] = '<a href="'.admin_url('edit.php?post_type=calendar&page=simple-calendar_settings').'">'.__('Settings', 'google-calendar-events').'</a>'; |
|
| 122 | + $links['feeds'] = '<a href="'.admin_url('edit.php?post_type=calendar').'">'.__('Calendars', 'google-calendar-events').'</a>'; |
|
| 123 | 123 | |
| 124 | - return apply_filters( 'simcal_plugin_action_links', array_merge( $links, $action_links ) ); |
|
| 124 | + return apply_filters('simcal_plugin_action_links', array_merge($links, $action_links)); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | return $action_links; |
@@ -137,15 +137,15 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | * @return array |
| 139 | 139 | */ |
| 140 | - public static function plugin_row_meta( $meta_links, $file ) { |
|
| 140 | + public static function plugin_row_meta($meta_links, $file) { |
|
| 141 | 141 | |
| 142 | - if ( self::$plugin == $file ) { |
|
| 142 | + if (self::$plugin == $file) { |
|
| 143 | 143 | |
| 144 | 144 | $links = array(); |
| 145 | - $links['add-ons'] = '<a href="' . simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'plugin-listing' ) . '" target="_blank" >' . |
|
| 146 | - __( 'Add-ons', 'google-calendar-events' ) . '</a>'; |
|
| 145 | + $links['add-ons'] = '<a href="'.simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'plugin-listing').'" target="_blank" >'. |
|
| 146 | + __('Add-ons', 'google-calendar-events').'</a>'; |
|
| 147 | 147 | |
| 148 | - return apply_filters( 'simcal_plugin_action_links', array_merge( $meta_links, $links ) ); |
|
| 148 | + return apply_filters('simcal_plugin_action_links', array_merge($meta_links, $links)); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | return $meta_links; |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @return string|void |
| 164 | 164 | */ |
| 165 | - public function admin_footer_text( $footer_text ) { |
|
| 165 | + public function admin_footer_text($footer_text) { |
|
| 166 | 166 | |
| 167 | 167 | // Check to make sure we're on a SimpleCal admin page |
| 168 | 168 | $screen = simcal_is_admin_screen(); |
| 169 | - if ( $screen !== false ) { |
|
| 169 | + if ($screen !== false) { |
|
| 170 | 170 | |
| 171 | - if ( 'calendar' == $screen ) { |
|
| 171 | + if ('calendar' == $screen) { |
|
| 172 | 172 | |
| 173 | 173 | // Add Drip promo signup form (@see Newsletter meta box). |
| 174 | 174 | |
@@ -196,23 +196,23 @@ discard block |
||
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // Change the footer text |
| 199 | - if ( ! get_option( 'simple-calendar_admin_footer_text_rated' ) ) { |
|
| 199 | + if ( ! get_option('simple-calendar_admin_footer_text_rated')) { |
|
| 200 | 200 | |
| 201 | 201 | $footer_text = sprintf( |
| 202 | - __( 'If you like <strong>Simple Calendar</strong> please leave us a %s★★★★★ rating on WordPress.org%s. A huge thank you in advance!', 'google-calendar-events' ), |
|
| 203 | - '<a href="https://wordpress.org/support/view/plugin-reviews/google-calendar-events?filter=5#postform" target="_blank" class="simcal-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'google-calendar-events' ) . '">', '</a>' |
|
| 202 | + __('If you like <strong>Simple Calendar</strong> please leave us a %s★★★★★ rating on WordPress.org%s. A huge thank you in advance!', 'google-calendar-events'), |
|
| 203 | + '<a href="https://wordpress.org/support/view/plugin-reviews/google-calendar-events?filter=5#postform" target="_blank" class="simcal-rating-link" data-rated="'.esc_attr__('Thanks :)', 'google-calendar-events').'">', '</a>' |
|
| 204 | 204 | ); |
| 205 | 205 | |
| 206 | 206 | $footer_text .= '<script type="text/javascript">'; |
| 207 | 207 | $footer_text .= "jQuery( 'a.simcal-rating-link' ).click( function() { |
| 208 | - jQuery.post( '" . \SimpleCalendar\plugin()->ajax_url() . "', { action: 'simcal_rated' } ); |
|
| 208 | + jQuery.post( '" . \SimpleCalendar\plugin()->ajax_url()."', { action: 'simcal_rated' } ); |
|
| 209 | 209 | jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) ); |
| 210 | 210 | });"; |
| 211 | 211 | $footer_text .= '</script>'; |
| 212 | 212 | |
| 213 | 213 | } else { |
| 214 | 214 | |
| 215 | - $footer_text = __( 'Thanks for using Simple Calendar!', 'google-calendar-events' ); |
|
| 215 | + $footer_text = __('Thanks for using Simple Calendar!', 'google-calendar-events'); |
|
| 216 | 216 | |
| 217 | 217 | } |
| 218 | 218 | |
@@ -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 | |
@@ -25,19 +25,19 @@ discard block |
||
| 25 | 25 | public function __construct() { |
| 26 | 26 | |
| 27 | 27 | // Set an option if the user rated the plugin. |
| 28 | - add_action( 'wp_ajax_simcal_rated', array( $this, 'rate_plugin' ) ); |
|
| 28 | + add_action('wp_ajax_simcal_rated', array($this, 'rate_plugin')); |
|
| 29 | 29 | |
| 30 | 30 | // Set an option if the user rated the plugin. |
| 31 | - add_action( 'wp_ajax_simcal_clear_cache', array( $this, 'clear_cache' ) ); |
|
| 31 | + add_action('wp_ajax_simcal_clear_cache', array($this, 'clear_cache')); |
|
| 32 | 32 | |
| 33 | 33 | // Convert a datetime format. |
| 34 | - add_action( 'wp_ajax_simcal_date_i18n_input_preview', array( $this, 'date_i18n' ) ); |
|
| 34 | + add_action('wp_ajax_simcal_date_i18n_input_preview', array($this, 'date_i18n')); |
|
| 35 | 35 | |
| 36 | 36 | // Manage an add-on license activation or deactivation. |
| 37 | - add_action( 'wp_ajax_simcal_manage_add_on_license', array( $this, 'manage_add_on_license' ) ); |
|
| 37 | + add_action('wp_ajax_simcal_manage_add_on_license', array($this, 'manage_add_on_license')); |
|
| 38 | 38 | |
| 39 | 39 | // Reset add-ons licenses. |
| 40 | - add_action( 'wp_ajax_simcal_reset_add_ons_licenses', array( $this, 'reset_licenses' ) ); |
|
| 40 | + add_action('wp_ajax_simcal_reset_add_ons_licenses', array($this, 'reset_licenses')); |
|
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function clear_cache() { |
| 50 | 50 | |
| 51 | - $id = isset( $_POST['id'] ) ? ( is_array( $_POST['id'] ) ? array_map( 'intval', $_POST['id'] ) : intval( $_POST['id'] ) ) : ''; |
|
| 51 | + $id = isset($_POST['id']) ? (is_array($_POST['id']) ? array_map('intval', $_POST['id']) : intval($_POST['id'])) : ''; |
|
| 52 | 52 | |
| 53 | - if ( ! empty( $id ) ) { |
|
| 54 | - simcal_delete_feed_transients( $id ); |
|
| 53 | + if ( ! empty($id)) { |
|
| 54 | + simcal_delete_feed_transients($id); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @since 3.0.0 |
| 62 | 62 | */ |
| 63 | 63 | public function rate_plugin() { |
| 64 | - update_option( 'simple-calendar_admin_footer_text_rated', date( 'Y-m-d', time() ) ); |
|
| 64 | + update_option('simple-calendar_admin_footer_text_rated', date('Y-m-d', time())); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function date_i18n() { |
| 73 | 73 | |
| 74 | - $value = isset( $_POST['value'] ) ? esc_attr( $_POST['value'] ) : ' '; |
|
| 75 | - $timestamp = isset( $_POST['timestamp'] ) ? absint( $_POST['timestamp'] ) : time(); |
|
| 74 | + $value = isset($_POST['value']) ? esc_attr($_POST['value']) : ' '; |
|
| 75 | + $timestamp = isset($_POST['timestamp']) ? absint($_POST['timestamp']) : time(); |
|
| 76 | 76 | |
| 77 | - wp_send_json_success( date_i18n( $value, $timestamp ) ); |
|
| 77 | + wp_send_json_success(date_i18n($value, $timestamp)); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -86,35 +86,35 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function manage_add_on_license() { |
| 88 | 88 | |
| 89 | - $addon = isset( $_POST['add_on'] ) ? sanitize_key( $_POST['add_on'] ) : false; |
|
| 90 | - $action = isset( $_POST['license_action'] ) ? esc_attr( $_POST['license_action'] ) : false; |
|
| 91 | - $key = isset( $_POST['license_key'] ) ? esc_attr( $_POST['license_key'] ) : ''; |
|
| 92 | - $nonce = isset( $_POST['nonce'] ) ? esc_attr( $_POST['nonce'] ) : ''; |
|
| 89 | + $addon = isset($_POST['add_on']) ? sanitize_key($_POST['add_on']) : false; |
|
| 90 | + $action = isset($_POST['license_action']) ? esc_attr($_POST['license_action']) : false; |
|
| 91 | + $key = isset($_POST['license_key']) ? esc_attr($_POST['license_key']) : ''; |
|
| 92 | + $nonce = isset($_POST['nonce']) ? esc_attr($_POST['nonce']) : ''; |
|
| 93 | 93 | |
| 94 | 94 | // Verify that there are valid variables to process. |
| 95 | - if ( false === $addon || ! in_array( $action, array( 'activate_license', 'deactivate_license' ) ) ) { |
|
| 96 | - wp_send_json_error( __( 'Add-on unspecified or invalid action.', 'google-calendar-events' ) ); |
|
| 95 | + if (false === $addon || ! in_array($action, array('activate_license', 'deactivate_license'))) { |
|
| 96 | + wp_send_json_error(__('Add-on unspecified or invalid action.', 'google-calendar-events')); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Verify this request comes from the add-ons licenses activation settings page. |
| 100 | - if ( ! wp_verify_nonce( $nonce, 'simcal_license_manager' ) ) { |
|
| 101 | - wp_send_json_error( sprintf( __( 'An error occurred: %s', 'google-calendar-events' ), 'Nonce verification failed.' ) ); |
|
| 100 | + if ( ! wp_verify_nonce($nonce, 'simcal_license_manager')) { |
|
| 101 | + wp_send_json_error(sprintf(__('An error occurred: %s', 'google-calendar-events'), 'Nonce verification failed.')); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | // Removes the prefix and converts simcal_{id_no} to {id_no}. |
| 105 | - $id = intval( substr( $addon, 7 ) ); |
|
| 105 | + $id = intval(substr($addon, 7)); |
|
| 106 | 106 | |
| 107 | 107 | // Data to send in API request. |
| 108 | 108 | $api_request = array( |
| 109 | 109 | 'edd_action' => $action, |
| 110 | 110 | 'license' => $key, |
| 111 | - 'item_id' => urlencode( $id ), |
|
| 111 | + 'item_id' => urlencode($id), |
|
| 112 | 112 | 'url' => home_url() |
| 113 | 113 | ); |
| 114 | 114 | |
| 115 | 115 | // Call the custom API. |
| 116 | 116 | $response = wp_remote_post( |
| 117 | - defined( 'SIMPLE_CALENDAR_STORE_URL' ) ? SIMPLE_CALENDAR_STORE_URL : simcal_get_url( 'home' ), |
|
| 117 | + defined('SIMPLE_CALENDAR_STORE_URL') ? SIMPLE_CALENDAR_STORE_URL : simcal_get_url('home'), |
|
| 118 | 118 | array( |
| 119 | 119 | 'timeout' => 15, |
| 120 | 120 | 'sslverify' => false, |
@@ -123,20 +123,20 @@ discard block |
||
| 123 | 123 | ); |
| 124 | 124 | |
| 125 | 125 | // Update license in db. |
| 126 | - $keys = get_option( 'simple-calendar_settings_licenses', array() ); |
|
| 127 | - $keys['keys'][ $addon ] = $key; |
|
| 128 | - update_option( 'simple-calendar_settings_licenses', $keys ); |
|
| 126 | + $keys = get_option('simple-calendar_settings_licenses', array()); |
|
| 127 | + $keys['keys'][$addon] = $key; |
|
| 128 | + update_option('simple-calendar_settings_licenses', $keys); |
|
| 129 | 129 | |
| 130 | 130 | // Make sure there is a response. |
| 131 | - if ( is_wp_error( $response ) ) { |
|
| 132 | - wp_send_json_error( sprintf( __( 'There was an error processing your request: %s', 'google-calendar-events' ), $response->get_error_message() ) ); |
|
| 131 | + if (is_wp_error($response)) { |
|
| 132 | + wp_send_json_error(sprintf(__('There was an error processing your request: %s', 'google-calendar-events'), $response->get_error_message())); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // Decode the license data and save. |
| 136 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 136 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 137 | 137 | $status = simcal_get_license_status(); |
| 138 | 138 | |
| 139 | - if ( ! empty( $license_data ) ) { |
|
| 139 | + if ( ! empty($license_data)) { |
|
| 140 | 140 | if ('deactivated' == $license_data->license) { |
| 141 | 141 | unset($status[$addon]); |
| 142 | 142 | update_option('simple-calendar_licenses_status', $status); |
@@ -147,10 +147,10 @@ discard block |
||
| 147 | 147 | $message = 'valid' == $license_data->license ? 'valid' : __('License key is invalid.', 'google-calendar-events'); |
| 148 | 148 | wp_send_json_success($message); |
| 149 | 149 | } else { |
| 150 | - wp_send_json_error( '' ); |
|
| 150 | + wp_send_json_error(''); |
|
| 151 | 151 | } |
| 152 | 152 | } else { |
| 153 | - wp_send_json_error( __( 'An error has occurred, please try again.', 'google-calendar-events' ) ); |
|
| 153 | + wp_send_json_error(__('An error has occurred, please try again.', 'google-calendar-events')); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
@@ -161,17 +161,17 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function reset_licenses() { |
| 163 | 163 | |
| 164 | - $nonce = isset( $_POST['nonce'] ) ? esc_attr( $_POST['nonce'] ) : ''; |
|
| 164 | + $nonce = isset($_POST['nonce']) ? esc_attr($_POST['nonce']) : ''; |
|
| 165 | 165 | |
| 166 | 166 | // Verify this request comes from the add-ons licenses activation settings page. |
| 167 | - if ( empty ( $nonce ) || ! wp_verify_nonce( $nonce, 'simcal_license_manager' ) ) { |
|
| 168 | - wp_send_json_error( sprintf( __( 'An error occurred: %s', 'google-calendar-events' ), 'Nonce verification failed.' ) ); |
|
| 167 | + if (empty ($nonce) || ! wp_verify_nonce($nonce, 'simcal_license_manager')) { |
|
| 168 | + wp_send_json_error(sprintf(__('An error occurred: %s', 'google-calendar-events'), 'Nonce verification failed.')); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - delete_option( 'simple-calendar_settings_licenses' ); |
|
| 172 | - delete_option( 'simple-calendar_licenses_status' ); |
|
| 171 | + delete_option('simple-calendar_settings_licenses'); |
|
| 172 | + delete_option('simple-calendar_licenses_status'); |
|
| 173 | 173 | |
| 174 | - wp_send_json_success( 'success' ); |
|
| 174 | + wp_send_json_success('success'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Abstracts\Admin_Page; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function __construct() { |
| 30 | 30 | $this->id = 'advanced'; |
| 31 | 31 | $this->option_group = 'settings'; |
| 32 | - $this->label = __( 'Advanced', 'google-calendar-events' ); |
|
| 32 | + $this->label = __('Advanced', 'google-calendar-events'); |
|
| 33 | 33 | //$this->description = __( 'Advanced settings.', 'google-calendar-events' ); |
| 34 | 34 | $this->sections = $this->add_sections(); |
| 35 | 35 | $this->fields = $this->add_fields(); |
@@ -43,16 +43,16 @@ discard block |
||
| 43 | 43 | * @return array |
| 44 | 44 | */ |
| 45 | 45 | public function add_sections() { |
| 46 | - return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id .'_sections', array( |
|
| 46 | + return apply_filters('simcal_add_'.$this->option_group.'_'.$this->id.'_sections', array( |
|
| 47 | 47 | 'assets' => array( |
| 48 | - 'title' => __( 'Styles', 'google-calendar-events' ), |
|
| 49 | - 'description' => __( 'Manage front end assets that handle the calendars appearance.', 'google-calendar-events' ) |
|
| 48 | + 'title' => __('Styles', 'google-calendar-events'), |
|
| 49 | + 'description' => __('Manage front end assets that handle the calendars appearance.', 'google-calendar-events') |
|
| 50 | 50 | ), |
| 51 | 51 | 'installation' => array( |
| 52 | - 'title' => __( 'Installation', 'google-calendar-events' ), |
|
| 53 | - 'description' => __( 'Manage your data (plugin settings and saved calendars).', 'google-calendar-events' ) |
|
| 52 | + 'title' => __('Installation', 'google-calendar-events'), |
|
| 53 | + 'description' => __('Manage your data (plugin settings and saved calendars).', 'google-calendar-events') |
|
| 54 | 54 | ) |
| 55 | - ) ); |
|
| 55 | + )); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -65,41 +65,41 @@ discard block |
||
| 65 | 65 | public function add_fields() { |
| 66 | 66 | |
| 67 | 67 | $fields = array(); |
| 68 | - $this->values = get_option( 'simple-calendar_' . $this->option_group . '_' . $this->id ); |
|
| 68 | + $this->values = get_option('simple-calendar_'.$this->option_group.'_'.$this->id); |
|
| 69 | 69 | |
| 70 | - foreach ( $this->sections as $section => $a ) : |
|
| 70 | + foreach ($this->sections as $section => $a) : |
|
| 71 | 71 | |
| 72 | - if ( 'assets' == $section ) { |
|
| 72 | + if ('assets' == $section) { |
|
| 73 | 73 | |
| 74 | - $fields[ $section ] = array( |
|
| 74 | + $fields[$section] = array( |
|
| 75 | 75 | 'disable_css' => array( |
| 76 | - 'title' => __( 'Disable CSS', 'google-calendar-events' ), |
|
| 77 | - 'tooltip' => __( 'If ticked, this option will prevent all front end stylesheets to load. This also includes all add-on stylesheets.', 'google-calendar-events' ), |
|
| 76 | + 'title' => __('Disable CSS', 'google-calendar-events'), |
|
| 77 | + 'tooltip' => __('If ticked, this option will prevent all front end stylesheets to load. This also includes all add-on stylesheets.', 'google-calendar-events'), |
|
| 78 | 78 | 'type' => 'checkbox', |
| 79 | - 'name' => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][disable_css]', |
|
| 80 | - 'id' => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $section . '-disable-css', |
|
| 81 | - 'value' => $this->get_option_value( $section, 'disable_css' ) |
|
| 79 | + 'name' => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][disable_css]', |
|
| 80 | + 'id' => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-'.$section.'-disable-css', |
|
| 81 | + 'value' => $this->get_option_value($section, 'disable_css') |
|
| 82 | 82 | ), |
| 83 | 83 | ); |
| 84 | 84 | |
| 85 | - } elseif ( 'installation' == $section ) { |
|
| 85 | + } elseif ('installation' == $section) { |
|
| 86 | 86 | |
| 87 | - $fields[ $section ] = array( |
|
| 87 | + $fields[$section] = array( |
|
| 88 | 88 | 'delete_settings' => array( |
| 89 | - 'title' => __( 'Delete settings', 'google-calendar-events' ), |
|
| 90 | - 'tooltip' => __( 'Tick this option if you want to wipe this plugin settings from database when uninstalling.', 'google-calendar-events' ), |
|
| 89 | + 'title' => __('Delete settings', 'google-calendar-events'), |
|
| 90 | + 'tooltip' => __('Tick this option if you want to wipe this plugin settings from database when uninstalling.', 'google-calendar-events'), |
|
| 91 | 91 | 'type' => 'checkbox', |
| 92 | - 'name' => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][delete_settings]', |
|
| 93 | - 'id' => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $section . '-delete-settings', |
|
| 94 | - 'value' => $this->get_option_value( $section, 'delete_settings' ), |
|
| 92 | + 'name' => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][delete_settings]', |
|
| 93 | + 'id' => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-'.$section.'-delete-settings', |
|
| 94 | + 'value' => $this->get_option_value($section, 'delete_settings'), |
|
| 95 | 95 | ), |
| 96 | 96 | 'erase_data' => array( |
| 97 | - 'title' => __( 'Erase calendar data', 'google-calendar-events' ), |
|
| 98 | - 'tooltip' => __( 'By default your data will be retained in database even after uninstall. Tick this option if you want to delete all your calendar data when uninstalling.', 'google-calendar-events' ), |
|
| 97 | + 'title' => __('Erase calendar data', 'google-calendar-events'), |
|
| 98 | + 'tooltip' => __('By default your data will be retained in database even after uninstall. Tick this option if you want to delete all your calendar data when uninstalling.', 'google-calendar-events'), |
|
| 99 | 99 | 'type' => 'checkbox', |
| 100 | - 'name' => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][erase_data]', |
|
| 101 | - 'id' => 'simple-calendar_' . $this->option_group . '_' . $this->id . '-delete-data', |
|
| 102 | - 'value' => $this->get_option_value( $section, 'erase_data' ), |
|
| 100 | + 'name' => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][erase_data]', |
|
| 101 | + 'id' => 'simple-calendar_'.$this->option_group.'_'.$this->id.'-delete-data', |
|
| 102 | + 'value' => $this->get_option_value($section, 'erase_data'), |
|
| 103 | 103 | ) |
| 104 | 104 | ); |
| 105 | 105 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | endforeach; |
| 109 | 109 | |
| 110 | - return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id . '_fields', $fields ); |
|
| 110 | + return apply_filters('simcal_add_'.$this->option_group.'_'.$this->id.'_fields', $fields); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Abstracts\Admin_Page; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -28,16 +28,16 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | $this->id = $tab = 'add-ons'; |
| 30 | 30 | $this->option_group = $page = 'add-ons'; |
| 31 | - $this->label = __( 'Add-ons', 'google-calendar-events' ); |
|
| 31 | + $this->label = __('Add-ons', 'google-calendar-events'); |
|
| 32 | 32 | $this->description = ''; |
| 33 | 33 | $this->sections = $this->add_sections(); |
| 34 | 34 | $this->fields = $this->add_fields(); |
| 35 | 35 | |
| 36 | 36 | // Disable the submit button for this page. |
| 37 | - add_filter( 'simcal_admin_page_' . $page . '_' . $tab . '_submit', function() { return false; } ); |
|
| 37 | + add_filter('simcal_admin_page_'.$page.'_'.$tab.'_submit', function() { return false; } ); |
|
| 38 | 38 | |
| 39 | 39 | // Add html. |
| 40 | - add_action( 'simcal_admin_page_' . $page . '_' . $tab . '_end', array( $this, 'html' ) ); |
|
| 40 | + add_action('simcal_admin_page_'.$page.'_'.$tab.'_end', array($this, 'html')); |
|
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | // @todo pull data from simplecalendar.io to showcase add-ons |
| 52 | 52 | $js_redirect = '<script type="text/javascript">'; |
| 53 | - $js_redirect .= 'window.location = "' . simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'plugin-submenu-link', true ) . '"'; |
|
| 53 | + $js_redirect .= 'window.location = "'.simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'plugin-submenu-link', true).'"'; |
|
| 54 | 54 | $js_redirect .= '</script>'; |
| 55 | 55 | |
| 56 | 56 | echo $js_redirect; |