@@ -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; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | namespace SimpleCalendar\Admin; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | 38 | |
39 | - $this->install = isset( $_GET['simcal_install'] ) ? esc_attr( $_GET['simcal_install'] ) : ''; |
|
39 | + $this->install = isset($_GET['simcal_install']) ? esc_attr($_GET['simcal_install']) : ''; |
|
40 | 40 | |
41 | - add_action( 'admin_menu', array( $this, 'welcome_page_tabs' ) ); |
|
42 | - add_action( 'admin_head', array( $this, 'remove_submenu_pages' ) ); |
|
41 | + add_action('admin_menu', array($this, 'welcome_page_tabs')); |
|
42 | + add_action('admin_head', array($this, 'remove_submenu_pages')); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function welcome_page_tabs() { |
51 | 51 | |
52 | - $welcome_page_name = __( 'About Simple Calendar', 'google-calendar-events' ); |
|
53 | - $welcome_page_title = __( 'Welcome to Simple Calendar', 'google-calendar-events' ); |
|
52 | + $welcome_page_name = __('About Simple Calendar', 'google-calendar-events'); |
|
53 | + $welcome_page_title = __('Welcome to Simple Calendar', 'google-calendar-events'); |
|
54 | 54 | |
55 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : 'simple-calendar_about'; |
|
55 | + $page = isset($_GET['page']) ? $_GET['page'] : 'simple-calendar_about'; |
|
56 | 56 | |
57 | - switch ( $page ) { |
|
57 | + switch ($page) { |
|
58 | 58 | |
59 | 59 | case 'simple-calendar_about' : |
60 | 60 | $page = add_dashboard_page( |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | $welcome_page_name, |
63 | 63 | 'manage_options', |
64 | 64 | 'simple-calendar_about', |
65 | - array( $this, 'about_screen' ) |
|
65 | + array($this, 'about_screen') |
|
66 | 66 | ); |
67 | - add_action( 'admin_print_styles-' . $page, array( $this, 'styles' ) ); |
|
67 | + add_action('admin_print_styles-'.$page, array($this, 'styles')); |
|
68 | 68 | break; |
69 | 69 | |
70 | 70 | case 'simple-calendar_credits' : |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | $welcome_page_name, |
74 | 74 | 'manage_options', |
75 | 75 | 'simple-calendar_credits', |
76 | - array( $this, 'credits_screen' ) |
|
76 | + array($this, 'credits_screen') |
|
77 | 77 | ); |
78 | - add_action( 'admin_print_styles-' . $page, array( $this, 'styles' ) ); |
|
78 | + add_action('admin_print_styles-'.$page, array($this, 'styles')); |
|
79 | 79 | break; |
80 | 80 | |
81 | 81 | case 'simple-calendar_translators' : |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | $welcome_page_name, |
85 | 85 | 'manage_options', |
86 | 86 | 'simple-calendar_translators', |
87 | - array( $this, 'translators_screen' ) |
|
87 | + array($this, 'translators_screen') |
|
88 | 88 | ); |
89 | - add_action( 'admin_print_styles-' . $page, array( $this, 'styles' ) ); |
|
89 | + add_action('admin_print_styles-'.$page, array($this, 'styles')); |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | * @since 3.0.0 |
99 | 99 | */ |
100 | 100 | public function remove_submenu_pages() { |
101 | - remove_submenu_page( 'index.php', 'simple-calendar_about' ); |
|
102 | - remove_submenu_page( 'index.php', 'simple-calendar_credits' ); |
|
103 | - remove_submenu_page( 'index.php', 'simple-calendar_translators' ); |
|
101 | + remove_submenu_page('index.php', 'simple-calendar_about'); |
|
102 | + remove_submenu_page('index.php', 'simple-calendar_credits'); |
|
103 | + remove_submenu_page('index.php', 'simple-calendar_translators'); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | |
130 | 130 | ?> |
131 | 131 | <p> |
132 | - <a href="<?php echo admin_url( 'edit.php?post_type=calendar' ); ?>" |
|
132 | + <a href="<?php echo admin_url('edit.php?post_type=calendar'); ?>" |
|
133 | 133 | class="button button-primary" |
134 | - ><?php _e( 'Calendars', 'google-calendar-events' ); ?></a> |
|
135 | - <a href="<?php echo esc_url( add_query_arg( 'page', 'simple-calendar_settings', admin_url( 'admin.php' ) ) ); ?>" |
|
134 | + ><?php _e('Calendars', 'google-calendar-events'); ?></a> |
|
135 | + <a href="<?php echo esc_url(add_query_arg('page', 'simple-calendar_settings', admin_url('admin.php'))); ?>" |
|
136 | 136 | class="button button-primary" |
137 | - ><?php _e( 'Settings', 'google-calendar-events' ); ?></a> |
|
138 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'welcome-page' ); ?>" |
|
137 | + ><?php _e('Settings', 'google-calendar-events'); ?></a> |
|
138 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'welcome-page'); ?>" |
|
139 | 139 | class="docs button button-primary" target="_blank" |
140 | - ><?php _e( 'Add-ons', 'google-calendar-events' ); ?></a> |
|
141 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'docs' ), 'core-plugin', 'welcome-page' ); ?>" |
|
140 | + ><?php _e('Add-ons', 'google-calendar-events'); ?></a> |
|
141 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('docs'), 'core-plugin', 'welcome-page'); ?>" |
|
142 | 142 | class="docs button button-primary" target="_blank" |
143 | - ><?php _e( 'Documentation', 'google-calendar-events' ); ?></a> |
|
143 | + ><?php _e('Documentation', 'google-calendar-events'); ?></a> |
|
144 | 144 | </p> |
145 | 145 | <?php |
146 | 146 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | <h1> |
158 | 158 | <?php |
159 | 159 | /* translators: %s prints the current version of the plugin. */ |
160 | - printf( __( 'Welcome to Simple Calendar %s', 'google-calendar-events' ), SIMPLE_CALENDAR_VERSION ); |
|
160 | + printf(__('Welcome to Simple Calendar %s', 'google-calendar-events'), SIMPLE_CALENDAR_VERSION); |
|
161 | 161 | ?> |
162 | 162 | </h1> |
163 | 163 | |
@@ -165,21 +165,21 @@ discard block |
||
165 | 165 | <?php |
166 | 166 | |
167 | 167 | // Difference message if updating vs fresh install. |
168 | - if ( 'update' == $this->install ) { |
|
169 | - $message = __( 'Thanks for updating to the latest version!', 'google-calendar-events' ); |
|
168 | + if ('update' == $this->install) { |
|
169 | + $message = __('Thanks for updating to the latest version!', 'google-calendar-events'); |
|
170 | 170 | } else { |
171 | - $message = __( 'Thanks for installing!', 'google-calendar-events' ); |
|
171 | + $message = __('Thanks for installing!', 'google-calendar-events'); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | echo $message; |
175 | 175 | |
176 | 176 | /* translators: %s prints the current version of the plugin. */ |
177 | - printf( ' ' . __( "Simple Calendar %s has a few display options to configure. ", 'google-calendar-events' ), SIMPLE_CALENDAR_VERSION ); |
|
177 | + printf(' '.__("Simple Calendar %s has a few display options to configure. ", 'google-calendar-events'), SIMPLE_CALENDAR_VERSION); |
|
178 | 178 | ?> |
179 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'docs' ), 'core-plugin', 'welcome-page' ); ?>" |
|
179 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('docs'), 'core-plugin', 'welcome-page'); ?>" |
|
180 | 180 | target="_blank" |
181 | - ><?php _e( 'Check out our documentation', 'google-calendar-events' ); ?></a> |
|
182 | - <?php _e( 'to get started now.', 'google-calendar-events' ); ?> |
|
181 | + ><?php _e('Check out our documentation', 'google-calendar-events'); ?></a> |
|
182 | + <?php _e('to get started now.', 'google-calendar-events'); ?> |
|
183 | 183 | </div> |
184 | 184 | |
185 | 185 | <div class="simcal-badge"> </div> |
@@ -187,21 +187,21 @@ discard block |
||
187 | 187 | <?php $this->main_nav_links(); ?> |
188 | 188 | |
189 | 189 | <h2 class="nav-tab-wrapper"> |
190 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_about' ) { |
|
190 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_about') { |
|
191 | 191 | echo 'nav-tab-active'; |
192 | 192 | } ?>" |
193 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_about' ), 'index.php' ) ) ); ?>" |
|
194 | - ><?php _e( "What's New", 'google-calendar-events' ); ?></a> |
|
195 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_credits' ) { |
|
193 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_about'), 'index.php'))); ?>" |
|
194 | + ><?php _e("What's New", 'google-calendar-events'); ?></a> |
|
195 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_credits') { |
|
196 | 196 | echo 'nav-tab-active'; |
197 | 197 | } ?>" |
198 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_credits' ), 'index.php' ) ) ); ?>" |
|
199 | - ><?php _e( 'Credits', 'google-calendar-events' ); ?></a> |
|
200 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_translators' ) { |
|
198 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_credits'), 'index.php'))); ?>" |
|
199 | + ><?php _e('Credits', 'google-calendar-events'); ?></a> |
|
200 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_translators') { |
|
201 | 201 | echo 'nav-tab-active'; |
202 | 202 | } ?>" |
203 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_translators' ), 'index.php' ) ) ); ?>" |
|
204 | - ><?php _e( 'Translators', 'google-calendar-events' ); ?></a> |
|
203 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_translators'), 'index.php'))); ?>" |
|
204 | + ><?php _e('Translators', 'google-calendar-events'); ?></a> |
|
205 | 205 | </h2> |
206 | 206 | <?php |
207 | 207 | |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | * @since 3.0.0 |
214 | 214 | */ |
215 | 215 | public function about_screen() { |
216 | - $welcome_image_about_path = SIMPLE_CALENDAR_ASSETS . '/images/welcome'; |
|
217 | - $welcome_addons_link = simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'welcome-page' ); |
|
216 | + $welcome_image_about_path = SIMPLE_CALENDAR_ASSETS.'/images/welcome'; |
|
217 | + $welcome_addons_link = simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'welcome-page'); |
|
218 | 218 | |
219 | 219 | ?> |
220 | 220 | <div id="simcal-welcome"> |
@@ -222,20 +222,20 @@ discard block |
||
222 | 222 | |
223 | 223 | <?php $this->intro(); ?> |
224 | 224 | |
225 | - <h3><?php _e( 'Configure event colors, number of events to display, grid or list style and more.', 'google-calendar-events' ); ?></h3> |
|
226 | - <img src="<?php echo $welcome_image_about_path . '/grid-view-basic.png'; ?>" /> |
|
225 | + <h3><?php _e('Configure event colors, number of events to display, grid or list style and more.', 'google-calendar-events'); ?></h3> |
|
226 | + <img src="<?php echo $welcome_image_about_path.'/grid-view-basic.png'; ?>" /> |
|
227 | 227 | |
228 | - <h3><?php _e( 'Mobile responsive and widget ready.', 'google-calendar-events' ); ?></h3> |
|
229 | - <img src="<?php echo $welcome_image_about_path . '/list-view-widget.png'; ?>" /> |
|
230 | - <img src="<?php echo $welcome_image_about_path . '/grid-view-widget-dark-theme.png'; ?>" /> |
|
228 | + <h3><?php _e('Mobile responsive and widget ready.', 'google-calendar-events'); ?></h3> |
|
229 | + <img src="<?php echo $welcome_image_about_path.'/list-view-widget.png'; ?>" /> |
|
230 | + <img src="<?php echo $welcome_image_about_path.'/grid-view-widget-dark-theme.png'; ?>" /> |
|
231 | 231 | |
232 | 232 | <h3> |
233 | - <?php _e( 'Add even more display options with add-ons like', 'google-calendar-events' ); ?> |
|
234 | - <a href="<?php echo $welcome_addons_link; ?>" target="_blank"><?php _e( 'FullCalendar and Google Calendar Pro', 'google-calendar-events' ); ?></a>. |
|
233 | + <?php _e('Add even more display options with add-ons like', 'google-calendar-events'); ?> |
|
234 | + <a href="<?php echo $welcome_addons_link; ?>" target="_blank"><?php _e('FullCalendar and Google Calendar Pro', 'google-calendar-events'); ?></a>. |
|
235 | 235 | </h3> |
236 | - <a href="<?php echo $welcome_addons_link; ?>" target="_blank"><img src="<?php echo $welcome_image_about_path . '/fullcalendar-google-calendar-pro-grid-view.png'; ?>" /></a> |
|
236 | + <a href="<?php echo $welcome_addons_link; ?>" target="_blank"><img src="<?php echo $welcome_image_about_path.'/fullcalendar-google-calendar-pro-grid-view.png'; ?>" /></a> |
|
237 | 237 | |
238 | - <h3><a href="<?php echo $welcome_addons_link; ?>" target="_blank"><?php _e( 'View pricing and try demos for all Simple Calendar Pro add-ons.', 'google-calendar-events' ); ?></a></h3> |
|
238 | + <h3><a href="<?php echo $welcome_addons_link; ?>" target="_blank"><?php _e('View pricing and try demos for all Simple Calendar Pro add-ons.', 'google-calendar-events'); ?></a></h3> |
|
239 | 239 | |
240 | 240 | <hr/> |
241 | 241 | |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | <?php |
263 | 263 | |
264 | 264 | printf( |
265 | - __( "Simple Calendar is created by a worldwide team of developers. If you'd like to contribute please visit our <a href='%s' target='_blank'>GitHub repo</a>.", 'google-calendar-events' ), |
|
266 | - simcal_get_url( 'github' ) |
|
265 | + __("Simple Calendar is created by a worldwide team of developers. If you'd like to contribute please visit our <a href='%s' target='_blank'>GitHub repo</a>.", 'google-calendar-events'), |
|
266 | + simcal_get_url('github') |
|
267 | 267 | ); |
268 | 268 | |
269 | 269 | ?> |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | <div class="wrap about-wrap translators-wrap"> |
288 | 288 | <?php $this->intro(); ?> |
289 | 289 | <p class="about-description"> |
290 | - <?php _e( 'Simple Calendar has been kindly translated into several other languages by contributors from all over the world.', 'google-calendar-events' ); ?> |
|
290 | + <?php _e('Simple Calendar has been kindly translated into several other languages by contributors from all over the world.', 'google-calendar-events'); ?> |
|
291 | 291 | </p> |
292 | 292 | <p class="about-description"> |
293 | - <a href="https://translate.wordpress.org/projects/wp-plugins/google-calendar-events" target="_blank"><?php _e( 'Click here to help translate', 'google-calendar-events' ); ?></a> |
|
293 | + <a href="https://translate.wordpress.org/projects/wp-plugins/google-calendar-events" target="_blank"><?php _e('Click here to help translate', 'google-calendar-events'); ?></a> |
|
294 | 294 | </p> |
295 | 295 | <?php |
296 | 296 | |
@@ -319,31 +319,31 @@ discard block |
||
319 | 319 | |
320 | 320 | $contributors = $this->get_contributors(); |
321 | 321 | |
322 | - if ( empty( $contributors ) ) { |
|
322 | + if (empty($contributors)) { |
|
323 | 323 | return ''; |
324 | 324 | } |
325 | 325 | |
326 | 326 | $contributor_list = '<ul class="wp-people-group">'; |
327 | 327 | |
328 | - foreach ( $contributors as $contributor ) { |
|
328 | + foreach ($contributors as $contributor) { |
|
329 | 329 | |
330 | 330 | // Skip contributor bots |
331 | - $contributor_bots = array( 'gitter-badger' ); |
|
332 | - if ( in_array( $contributor->login, $contributor_bots ) ) { |
|
331 | + $contributor_bots = array('gitter-badger'); |
|
332 | + if (in_array($contributor->login, $contributor_bots)) { |
|
333 | 333 | continue; |
334 | 334 | } |
335 | 335 | |
336 | 336 | $contributor_list .= '<li class="wp-person">'; |
337 | 337 | $contributor_list .= sprintf( |
338 | 338 | '<a href="%s" title="%s" target="_blank">%s</a>', |
339 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
340 | - esc_html( sprintf( __( 'View %s', 'google-calendar-events' ), $contributor->login ) ), |
|
341 | - sprintf( '<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url( $contributor->avatar_url ), esc_html( $contributor->login ) ) |
|
339 | + esc_url('https://github.com/'.$contributor->login), |
|
340 | + esc_html(sprintf(__('View %s', 'google-calendar-events'), $contributor->login)), |
|
341 | + sprintf('<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url($contributor->avatar_url), esc_html($contributor->login)) |
|
342 | 342 | ); |
343 | 343 | $contributor_list .= sprintf( |
344 | 344 | '<a class="web" href="%s" target="_blank">%s</a>', |
345 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
346 | - esc_html( $contributor->login ) |
|
345 | + esc_url('https://github.com/'.$contributor->login), |
|
346 | + esc_html($contributor->login) |
|
347 | 347 | ); |
348 | 348 | $contributor_list .= '</li>'; |
349 | 349 | |
@@ -363,24 +363,24 @@ discard block |
||
363 | 363 | */ |
364 | 364 | public function get_contributors() { |
365 | 365 | |
366 | - $contributors = get_transient( '_simple-calendar_contributors' ); |
|
367 | - if ( false !== $contributors ) { |
|
366 | + $contributors = get_transient('_simple-calendar_contributors'); |
|
367 | + if (false !== $contributors) { |
|
368 | 368 | return $contributors; |
369 | 369 | } |
370 | 370 | |
371 | 371 | $response = wp_safe_remote_get( |
372 | 372 | 'https://api.github.com/repos/moonstonemedia/Simple-Calendar/contributors' |
373 | 373 | ); |
374 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
374 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { |
|
375 | 375 | return array(); |
376 | 376 | } |
377 | 377 | |
378 | - $contributors = json_decode( wp_remote_retrieve_body( $response ) ); |
|
379 | - if ( ! is_array( $contributors ) ) { |
|
378 | + $contributors = json_decode(wp_remote_retrieve_body($response)); |
|
379 | + if ( ! is_array($contributors)) { |
|
380 | 380 | return array(); |
381 | 381 | } |
382 | 382 | |
383 | - set_transient( '_simple-calendar_contributors', $contributors, HOUR_IN_SECONDS ); |
|
383 | + set_transient('_simple-calendar_contributors', $contributors, HOUR_IN_SECONDS); |
|
384 | 384 | |
385 | 385 | return $contributors; |
386 | 386 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | use SimpleCalendar\Abstracts\Feed; |
12 | 12 | use SimpleCalendar\Abstracts\Field; |
13 | 13 | |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -31,40 +31,40 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @param \WP_Post $post |
33 | 33 | */ |
34 | - public static function html( $post ) { |
|
34 | + public static function html($post) { |
|
35 | 35 | |
36 | 36 | // @see Meta_Boxes::save_meta_boxes() |
37 | - wp_nonce_field( 'simcal_save_data', 'simcal_meta_nonce' ); |
|
37 | + wp_nonce_field('simcal_save_data', 'simcal_meta_nonce'); |
|
38 | 38 | |
39 | 39 | ?> |
40 | 40 | <div class="simcal-panels-wrap"> |
41 | 41 | |
42 | 42 | <span class="simcal-box-handle"> |
43 | - <?php self::settings_handle( $post ); ?> |
|
43 | + <?php self::settings_handle($post); ?> |
|
44 | 44 | </span> |
45 | 45 | |
46 | 46 | <ul class="simcal-tabs"> |
47 | - <?php self::settings_tabs( $post ); ?> |
|
48 | - <?php do_action( 'simcal_settings_meta_tabs' ); ?> |
|
47 | + <?php self::settings_tabs($post); ?> |
|
48 | + <?php do_action('simcal_settings_meta_tabs'); ?> |
|
49 | 49 | </ul> |
50 | 50 | |
51 | 51 | <div class="simcal-panels"> |
52 | 52 | <div id="events-settings-panel" class="simcal-panel"> |
53 | - <?php self::events_settings_panel( $post ); ?> |
|
54 | - <?php do_action( 'simcal_settings_meta_events_panel', $post->ID ); ?> |
|
53 | + <?php self::events_settings_panel($post); ?> |
|
54 | + <?php do_action('simcal_settings_meta_events_panel', $post->ID); ?> |
|
55 | 55 | </div> |
56 | 56 | <div id="calendar-settings-panel" class="simcal-panel"> |
57 | - <?php do_action( 'simcal_settings_meta_calendar_panel', $post->ID ); ?> |
|
58 | - <?php self::calendar_settings_panel( $post ); ?> |
|
57 | + <?php do_action('simcal_settings_meta_calendar_panel', $post->ID); ?> |
|
58 | + <?php self::calendar_settings_panel($post); ?> |
|
59 | 59 | </div> |
60 | 60 | <?php |
61 | 61 | // Hook for additional settings panels. |
62 | - do_action( 'simcal_settings_meta_panels', $post->ID ); |
|
62 | + do_action('simcal_settings_meta_panels', $post->ID); |
|
63 | 63 | // Thus advanced panel is always the last one: |
64 | 64 | ?> |
65 | 65 | <div id="advanced-settings-panel" class="simcal-panel"> |
66 | - <?php self::advanced_settings_panel( $post ) ?> |
|
67 | - <?php do_action( 'simcal_settings_meta_advanced_panel', $post->ID ); ?> |
|
66 | + <?php self::advanced_settings_panel($post) ?> |
|
67 | + <?php do_action('simcal_settings_meta_advanced_panel', $post->ID); ?> |
|
68 | 68 | </div> |
69 | 69 | </div> |
70 | 70 | |
@@ -84,45 +84,45 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @param \WP_Post $post |
86 | 86 | */ |
87 | - private static function settings_handle( $post ) { |
|
87 | + private static function settings_handle($post) { |
|
88 | 88 | |
89 | 89 | $feed_options = $calendar_options = $calendar_views = array(); |
90 | 90 | |
91 | 91 | $feed_types = simcal_get_feed_types(); |
92 | - foreach ( $feed_types as $feed_type ) { |
|
92 | + foreach ($feed_types as $feed_type) { |
|
93 | 93 | |
94 | - $feed = simcal_get_feed( $feed_type ); |
|
94 | + $feed = simcal_get_feed($feed_type); |
|
95 | 95 | |
96 | - if ( $feed instanceof Feed ) { |
|
97 | - $feed_options[ $feed_type ] = $feed->name; |
|
96 | + if ($feed instanceof Feed) { |
|
97 | + $feed_options[$feed_type] = $feed->name; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | $calendar_types = simcal_get_calendar_types(); |
102 | - foreach ( $calendar_types as $calendar_type => $views ) { |
|
102 | + foreach ($calendar_types as $calendar_type => $views) { |
|
103 | 103 | |
104 | - $calendar = simcal_get_calendar( $calendar_type ); |
|
104 | + $calendar = simcal_get_calendar($calendar_type); |
|
105 | 105 | |
106 | - if ( $calendar instanceof Calendar ) { |
|
107 | - $calendar_options[ $calendar_type ] = $calendar->name; |
|
108 | - $calendar_views[ $calendar_type ] = $calendar->views; |
|
106 | + if ($calendar instanceof Calendar) { |
|
107 | + $calendar_options[$calendar_type] = $calendar->name; |
|
108 | + $calendar_views[$calendar_type] = $calendar->views; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | - if ( $feed_options ) { |
|
112 | + if ($feed_options) { |
|
113 | 113 | |
114 | - if ( $feed_types = wp_get_object_terms( $post->ID, 'calendar_feed' ) ) { |
|
115 | - $feed_type = sanitize_title( current( $feed_types )->name ); |
|
114 | + if ($feed_types = wp_get_object_terms($post->ID, 'calendar_feed')) { |
|
115 | + $feed_type = sanitize_title(current($feed_types)->name); |
|
116 | 116 | } else { |
117 | - $feed_type = apply_filters( 'simcal_default_feed_type', 'google' ); |
|
117 | + $feed_type = apply_filters('simcal_default_feed_type', 'google'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | ?> |
121 | - <label for="_feed_type"><span><?php _e( 'Event Source', 'google-calendar-events' ); ?></span> |
|
121 | + <label for="_feed_type"><span><?php _e('Event Source', 'google-calendar-events'); ?></span> |
|
122 | 122 | <select name="_feed_type" id="_feed_type"> |
123 | - <optgroup label="<?php _ex( 'Get events from', 'From which calendar source to load events from', 'google-calendar-events' ) ?>"> |
|
124 | - <?php foreach ( $feed_options as $feed => $name ) { ?> |
|
125 | - <option value="<?php echo $feed; ?>" <?php selected( $feed, $feed_type, true ); ?>><?php echo $name; ?></option> |
|
123 | + <optgroup label="<?php _ex('Get events from', 'From which calendar source to load events from', 'google-calendar-events') ?>"> |
|
124 | + <?php foreach ($feed_options as $feed => $name) { ?> |
|
125 | + <option value="<?php echo $feed; ?>" <?php selected($feed, $feed_type, true); ?>><?php echo $name; ?></option> |
|
126 | 126 | <?php } ?> |
127 | 127 | </optgroup> |
128 | 128 | </select> |
@@ -131,40 +131,40 @@ discard block |
||
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | - if ( $calendar_options ) { |
|
134 | + if ($calendar_options) { |
|
135 | 135 | |
136 | - if ( $calendar_types = wp_get_object_terms( $post->ID, 'calendar_type' ) ) { |
|
137 | - $calendar_type = sanitize_title( current( $calendar_types )->name ); |
|
136 | + if ($calendar_types = wp_get_object_terms($post->ID, 'calendar_type')) { |
|
137 | + $calendar_type = sanitize_title(current($calendar_types)->name); |
|
138 | 138 | } else { |
139 | - $calendar_type = apply_filters( 'simcal_default_calendar_type', 'default-calendar' ); |
|
139 | + $calendar_type = apply_filters('simcal_default_calendar_type', 'default-calendar'); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | ?> |
143 | - <label for="_calendar_type"><span><?php _e( 'Calendar Type', 'google-calendar-events' ); ?></span> |
|
143 | + <label for="_calendar_type"><span><?php _e('Calendar Type', 'google-calendar-events'); ?></span> |
|
144 | 144 | <select name="_calendar_type" id="_calendar_type"> |
145 | - <optgroup label="<?php _e( 'Calendar to use', 'google-calendar-events' ); ?>"> |
|
146 | - <?php foreach ( $calendar_options as $calendar => $name ) { ?> |
|
147 | - <option value="<?php echo $calendar; ?>" <?php selected( $calendar, $calendar_type, true ); ?>><?php echo $name; ?></option> |
|
145 | + <optgroup label="<?php _e('Calendar to use', 'google-calendar-events'); ?>"> |
|
146 | + <?php foreach ($calendar_options as $calendar => $name) { ?> |
|
147 | + <option value="<?php echo $calendar; ?>" <?php selected($calendar, $calendar_type, true); ?>><?php echo $name; ?></option> |
|
148 | 148 | <?php } ?> |
149 | 149 | </optgroup> |
150 | 150 | </select> |
151 | 151 | </label> |
152 | 152 | <?php |
153 | 153 | |
154 | - if ( $calendar_views ) { |
|
154 | + if ($calendar_views) { |
|
155 | 155 | |
156 | - $calendar_view = get_post_meta( $post->ID, '_calendar_view', true ); |
|
156 | + $calendar_view = get_post_meta($post->ID, '_calendar_view', true); |
|
157 | 157 | |
158 | - foreach ( $calendar_views as $calendar => $views ) { |
|
158 | + foreach ($calendar_views as $calendar => $views) { |
|
159 | 159 | |
160 | - $calendar_type_view = isset( $calendar_view[ $calendar ] ) ? $calendar_view[ $calendar ] : ''; |
|
160 | + $calendar_type_view = isset($calendar_view[$calendar]) ? $calendar_view[$calendar] : ''; |
|
161 | 161 | |
162 | 162 | ?> |
163 | - <label for="_calendar_view_<?php echo $calendar; ?>"><span><?php _e( 'View', 'google-calendar-events' ); ?></span> |
|
163 | + <label for="_calendar_view_<?php echo $calendar; ?>"><span><?php _e('View', 'google-calendar-events'); ?></span> |
|
164 | 164 | <select name="_calendar_view[<?php echo $calendar; ?>]" id="_calendar_view_<?php echo $calendar; ?>"> |
165 | - <optgroup label="<?php _e( 'View to display', 'google-calendar-events' ); ?>"> |
|
166 | - <?php foreach ( $views as $view => $name ) { ?> |
|
167 | - <option value="<?php echo $view; ?>" <?php selected( $view, $calendar_type_view, true ); ?>><?php echo $name; ?></option> |
|
165 | + <optgroup label="<?php _e('View to display', 'google-calendar-events'); ?>"> |
|
166 | + <?php foreach ($views as $view => $name) { ?> |
|
167 | + <option value="<?php echo $view; ?>" <?php selected($view, $calendar_type_view, true); ?>><?php echo $name; ?></option> |
|
168 | 168 | <?php } ?> |
169 | 169 | </optgroup> |
170 | 170 | </select> |
@@ -184,42 +184,42 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @param \WP_Post $post |
186 | 186 | */ |
187 | - private static function settings_tabs( $post ) { |
|
187 | + private static function settings_tabs($post) { |
|
188 | 188 | |
189 | 189 | // Hook to add more tabs. |
190 | - $tabs = apply_filters( 'simcal_settings_meta_tabs_li', array( |
|
190 | + $tabs = apply_filters('simcal_settings_meta_tabs_li', array( |
|
191 | 191 | 'events' => array( |
192 | - 'label' => __( 'Events', 'google-calendar-events' ), |
|
192 | + 'label' => __('Events', 'google-calendar-events'), |
|
193 | 193 | 'target' => 'events-settings-panel', |
194 | - 'class' => array( 'active' ), |
|
194 | + 'class' => array('active'), |
|
195 | 195 | 'icon' => 'simcal-icon-event', |
196 | 196 | ), |
197 | 197 | 'calendar' => array( |
198 | - 'label' => __( 'Appearance', 'google-calendar-events' ), |
|
198 | + 'label' => __('Appearance', 'google-calendar-events'), |
|
199 | 199 | 'target' => 'calendar-settings-panel', |
200 | 200 | 'class' => array(), |
201 | 201 | 'icon' => 'simcal-icon-calendar', |
202 | 202 | ), |
203 | - ), $post->ID ); |
|
203 | + ), $post->ID); |
|
204 | 204 | |
205 | 205 | // Always keep advanced tab as the last one. |
206 | 206 | $tabs['advanced'] = array( |
207 | - 'label' => __( 'Advanced', 'google-calendar-events' ), |
|
207 | + 'label' => __('Advanced', 'google-calendar-events'), |
|
208 | 208 | 'target' => 'advanced-settings-panel', |
209 | 209 | 'class' => array(), |
210 | 210 | 'icon' => 'simcal-icon-settings', |
211 | 211 | ); |
212 | 212 | |
213 | 213 | // Output the tabs as list items. |
214 | - foreach ( $tabs as $key => $tab ) { |
|
214 | + foreach ($tabs as $key => $tab) { |
|
215 | 215 | |
216 | - if ( isset( $tab['target'] ) && isset( $tab['label'] ) ) { |
|
216 | + if (isset($tab['target']) && isset($tab['label'])) { |
|
217 | 217 | |
218 | 218 | $icon = $tab['icon'] ? $tab['icon'] : 'simcal-icon-panel'; |
219 | 219 | $class = $tab['class'] ? $tab['class'] : array(); |
220 | 220 | |
221 | - echo '<li class="' . $key . '-settings ' . $key . '-tab ' . implode( ' ', $class ) . '" data-tab="' . $key . '">'; |
|
222 | - echo '<a href="#' . $tab['target'] . '"><i class="' . $icon . '" ></i> <span>' . esc_html( $tab['label'] ) . '</span></a>'; |
|
221 | + echo '<li class="'.$key.'-settings '.$key.'-tab '.implode(' ', $class).'" data-tab="'.$key.'">'; |
|
222 | + echo '<a href="#'.$tab['target'].'"><i class="'.$icon.'" ></i> <span>'.esc_html($tab['label']).'</span></a>'; |
|
223 | 223 | echo '</li>'; |
224 | 224 | } |
225 | 225 | } |
@@ -233,22 +233,22 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @param \WP_Post $post |
235 | 235 | */ |
236 | - private static function events_settings_panel( $post ) { |
|
236 | + private static function events_settings_panel($post) { |
|
237 | 237 | |
238 | 238 | ?> |
239 | 239 | <table> |
240 | 240 | <thead> |
241 | - <tr><th colspan="2"><?php _e( 'Event Settings', 'google-calendar-events' ); ?></th></tr> |
|
241 | + <tr><th colspan="2"><?php _e('Event Settings', 'google-calendar-events'); ?></th></tr> |
|
242 | 242 | </thead> |
243 | 243 | <tbody class="simcal-panel-section simcal-panel-section-events-range"> |
244 | 244 | <tr class="simcal-panel-field"> |
245 | - <th><label for="_calendar_begins"><?php _e( 'Calendar Start', 'google-calendar-events' ); ?></label></th> |
|
245 | + <th><label for="_calendar_begins"><?php _e('Calendar Start', 'google-calendar-events'); ?></label></th> |
|
246 | 246 | <td> |
247 | 247 | <?php |
248 | 248 | |
249 | - $calendar_begins = esc_attr( get_post_meta( $post->ID, '_calendar_begins', true ) ); |
|
250 | - $calendar_begins_nth = max( absint( get_post_meta( $post->ID, '_calendar_begins_nth', true ) ), 1 ); |
|
251 | - $calendar_begins_nth_show = in_array( $calendar_begins, array( |
|
249 | + $calendar_begins = esc_attr(get_post_meta($post->ID, '_calendar_begins', true)); |
|
250 | + $calendar_begins_nth = max(absint(get_post_meta($post->ID, '_calendar_begins_nth', true)), 1); |
|
251 | + $calendar_begins_nth_show = in_array($calendar_begins, array( |
|
252 | 252 | 'days_before', |
253 | 253 | 'days_after', |
254 | 254 | 'weeks_before', |
@@ -257,14 +257,14 @@ discard block |
||
257 | 257 | 'months_after', |
258 | 258 | 'years_before', |
259 | 259 | 'years_after', |
260 | - ) ); |
|
260 | + )); |
|
261 | 261 | |
262 | - simcal_print_field( array( |
|
262 | + simcal_print_field(array( |
|
263 | 263 | 'type' => 'standard', |
264 | 264 | 'subtype' => 'number', |
265 | 265 | 'name' => '_calendar_begins_nth', |
266 | 266 | 'id' => '_calendar_begins_nth', |
267 | - 'value' => strval( $calendar_begins_nth ), |
|
267 | + 'value' => strval($calendar_begins_nth), |
|
268 | 268 | 'attributes' => array( |
269 | 269 | 'min' => '1', |
270 | 270 | ), |
@@ -272,97 +272,97 @@ discard block |
||
272 | 272 | 'simcal-field-inline', |
273 | 273 | 'simcal-field-tiny', |
274 | 274 | ), |
275 | - 'style' => ! $calendar_begins_nth_show ? array( 'display' => 'none' ) : '', |
|
276 | - ) ); |
|
275 | + 'style' => ! $calendar_begins_nth_show ? array('display' => 'none') : '', |
|
276 | + )); |
|
277 | 277 | |
278 | 278 | ?> |
279 | 279 | <select name="_calendar_begins" |
280 | 280 | id="_calendar_begins" |
281 | 281 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
282 | - <optgroup label="<?php _e( 'Days', 'google-calendar-events' ); ?>"> |
|
282 | + <optgroup label="<?php _e('Days', 'google-calendar-events'); ?>"> |
|
283 | 283 | <option value="today" |
284 | 284 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
285 | - <?php selected( 'today', $calendar_begins, true ); ?>><?php _e( 'Today', 'google-calendar-events' ); ?></option> |
|
285 | + <?php selected('today', $calendar_begins, true); ?>><?php _e('Today', 'google-calendar-events'); ?></option> |
|
286 | 286 | <option value="now" |
287 | 287 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
288 | - <?php selected( 'now', $calendar_begins, true ); ?>><?php _e( 'Now', 'google-calendar-events' ); ?></option> |
|
288 | + <?php selected('now', $calendar_begins, true); ?>><?php _e('Now', 'google-calendar-events'); ?></option> |
|
289 | 289 | <option value="days_before" |
290 | 290 | data-hide-field="_calendar_begins_custom_date" |
291 | - data-show-field="_calendar_begins_nth" <?php selected( 'days_before', $calendar_begins, true ); ?>><?php _e( 'Day(s) before today', 'google-calendar-events' ); ?></option> |
|
291 | + data-show-field="_calendar_begins_nth" <?php selected('days_before', $calendar_begins, true); ?>><?php _e('Day(s) before today', 'google-calendar-events'); ?></option> |
|
292 | 292 | <option value="days_after" |
293 | 293 | data-hide-field="_calendar_begins_custom_date" |
294 | - data-show-field="_calendar_begins_nth" <?php selected( 'days_after', $calendar_begins, true ); ?>><?php _e( 'Day(s) after today', 'google-calendar-events' ); ?></option> |
|
294 | + data-show-field="_calendar_begins_nth" <?php selected('days_after', $calendar_begins, true); ?>><?php _e('Day(s) after today', 'google-calendar-events'); ?></option> |
|
295 | 295 | </optgroup> |
296 | - <optgroup label="<?php _e( 'Weeks', 'google-calendar-events' ); ?>"> |
|
296 | + <optgroup label="<?php _e('Weeks', 'google-calendar-events'); ?>"> |
|
297 | 297 | <option value="this_week" |
298 | 298 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
299 | - <?php selected( 'this_week', $calendar_begins, true ); ?>><?php _e( 'This week', 'google-calendar-events' ); ?></option> |
|
299 | + <?php selected('this_week', $calendar_begins, true); ?>><?php _e('This week', 'google-calendar-events'); ?></option> |
|
300 | 300 | <option value="weeks_before" |
301 | 301 | data-hide-field="_calendar_begins_custom_date" |
302 | - data-show-field="_calendar_begins_nth" <?php selected( 'weeks_before', $calendar_begins, true ); ?>><?php _e( 'Week(s) before current', 'google-calendar-events' ); ?></option> |
|
302 | + data-show-field="_calendar_begins_nth" <?php selected('weeks_before', $calendar_begins, true); ?>><?php _e('Week(s) before current', 'google-calendar-events'); ?></option> |
|
303 | 303 | <option value="weeks_after" |
304 | 304 | data-hide-field="_calendar_begins_custom_date" |
305 | - data-show-field="_calendar_begins_nth" <?php selected( 'weeks_after', $calendar_begins, true ); ?>><?php _e( 'Week(s) after current', 'google-calendar-events' ); ?></option> |
|
305 | + data-show-field="_calendar_begins_nth" <?php selected('weeks_after', $calendar_begins, true); ?>><?php _e('Week(s) after current', 'google-calendar-events'); ?></option> |
|
306 | 306 | </optgroup> |
307 | - <optgroup label="<?php _e( 'Months', 'google-calendar-events' ); ?>"> |
|
307 | + <optgroup label="<?php _e('Months', 'google-calendar-events'); ?>"> |
|
308 | 308 | <option value="this_month" |
309 | 309 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
310 | - <?php selected( 'this_month', $calendar_begins, true ); ?>><?php _e( 'This month', 'google-calendar-events' ); ?></option> |
|
310 | + <?php selected('this_month', $calendar_begins, true); ?>><?php _e('This month', 'google-calendar-events'); ?></option> |
|
311 | 311 | <option value="months_before" |
312 | 312 | data-hide-field="_calendar_begins_custom_date" |
313 | - data-show-field="_calendar_begins_nth" <?php selected( 'months_before', $calendar_begins, true ); ?>><?php _e( 'Month(s) before current', 'google-calendar-events' ); ?></option> |
|
313 | + data-show-field="_calendar_begins_nth" <?php selected('months_before', $calendar_begins, true); ?>><?php _e('Month(s) before current', 'google-calendar-events'); ?></option> |
|
314 | 314 | <option value="months_after" |
315 | 315 | data-hide-field="_calendar_begins_custom_date" |
316 | - data-show-field="_calendar_begins_nth" <?php selected( 'months_after', $calendar_begins, true ); ?>><?php _e( 'Month(s) after current', 'google-calendar-events' ); ?></option> |
|
316 | + data-show-field="_calendar_begins_nth" <?php selected('months_after', $calendar_begins, true); ?>><?php _e('Month(s) after current', 'google-calendar-events'); ?></option> |
|
317 | 317 | </optgroup> |
318 | - <optgroup label="<?php _e( 'Years', 'google-calendar-events' ); ?>"> |
|
318 | + <optgroup label="<?php _e('Years', 'google-calendar-events'); ?>"> |
|
319 | 319 | <option value="this_year" |
320 | 320 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
321 | - <?php selected( 'this_year', $calendar_begins, true ); ?>><?php _e( 'This year', 'google-calendar-events' ); ?></option> |
|
321 | + <?php selected('this_year', $calendar_begins, true); ?>><?php _e('This year', 'google-calendar-events'); ?></option> |
|
322 | 322 | <option value="years_before" |
323 | - data-show-field="_calendar_begins_nth" <?php selected( 'years_before', $calendar_begins, true ); ?>><?php _e( 'Year(s) before current', 'google-calendar-events' ); ?></option> |
|
323 | + data-show-field="_calendar_begins_nth" <?php selected('years_before', $calendar_begins, true); ?>><?php _e('Year(s) before current', 'google-calendar-events'); ?></option> |
|
324 | 324 | <option value="years_after" |
325 | 325 | data-hide-field="_calendar_begins_custom_date" |
326 | - data-show-field="_calendar_begins_nth" <?php selected( 'years_after', $calendar_begins, true ); ?>><?php _e( 'Year(s) after current', 'google-calendar-events' ); ?></option> |
|
326 | + data-show-field="_calendar_begins_nth" <?php selected('years_after', $calendar_begins, true); ?>><?php _e('Year(s) after current', 'google-calendar-events'); ?></option> |
|
327 | 327 | </optgroup> |
328 | - <optgroup label="<?php _e( 'Other', 'google-calendar-events' ); ?>"> |
|
328 | + <optgroup label="<?php _e('Other', 'google-calendar-events'); ?>"> |
|
329 | 329 | <option value="custom_date" |
330 | 330 | data-hide-field="_calendar_begins_nth" |
331 | - data-show-field="_calendar_begins_custom_date" <?php selected( 'custom_date', $calendar_begins, true ); ?>><?php _e( 'Specific date', 'google-calendar-events' ); ?></option> |
|
331 | + data-show-field="_calendar_begins_custom_date" <?php selected('custom_date', $calendar_begins, true); ?>><?php _e('Specific date', 'google-calendar-events'); ?></option> |
|
332 | 332 | </optgroup> |
333 | 333 | </select> |
334 | 334 | <?php |
335 | 335 | |
336 | - simcal_print_field( array( |
|
336 | + simcal_print_field(array( |
|
337 | 337 | 'type' => 'date-picker', |
338 | 338 | 'name' => '_calendar_begins_custom_date', |
339 | 339 | 'id' => '_calendar_begins_custom_date', |
340 | - 'value' => get_post_meta( $post->ID, '_calendar_begins_custom_date', true ), |
|
340 | + 'value' => get_post_meta($post->ID, '_calendar_begins_custom_date', true), |
|
341 | 341 | 'class' => array( |
342 | 342 | 'simcal-field-inline', |
343 | 343 | ), |
344 | - 'style' => 'custom_date' != $calendar_begins ? array( 'display' => 'none' ) : '', |
|
345 | - ) ); |
|
344 | + 'style' => 'custom_date' != $calendar_begins ? array('display' => 'none') : '', |
|
345 | + )); |
|
346 | 346 | |
347 | 347 | ?> |
348 | 348 | <i class="simcal-icon-help simcal-help-tip" |
349 | - data-tip="<?php _e( 'The calendar default opening date. It will automatically adapt based on the chosen calendar type.', 'google-calendar-events' ); ?>"></i> |
|
349 | + data-tip="<?php _e('The calendar default opening date. It will automatically adapt based on the chosen calendar type.', 'google-calendar-events'); ?>"></i> |
|
350 | 350 | </td> |
351 | 351 | </tr> |
352 | 352 | <tr class="simcal-panel-field"> |
353 | - <th><label for="_feed_earliest_event_date"><?php _e( 'Earliest Event', 'google-calendar-events' ); ?></label></th> |
|
353 | + <th><label for="_feed_earliest_event_date"><?php _e('Earliest Event', 'google-calendar-events'); ?></label></th> |
|
354 | 354 | <td> |
355 | 355 | <?php |
356 | 356 | |
357 | - $earliest_event_saved = get_post_meta( $post->ID, '_feed_earliest_event_date', true ); |
|
358 | - $earliest_event = false == $earliest_event_saved ? 'months_before' : esc_attr( $earliest_event_saved ); |
|
357 | + $earliest_event_saved = get_post_meta($post->ID, '_feed_earliest_event_date', true); |
|
358 | + $earliest_event = false == $earliest_event_saved ? 'months_before' : esc_attr($earliest_event_saved); |
|
359 | 359 | |
360 | - simcal_print_field( array( |
|
360 | + simcal_print_field(array( |
|
361 | 361 | 'type' => 'standard', |
362 | 362 | 'subtype' => 'number', |
363 | 363 | 'name' => '_feed_earliest_event_date_range', |
364 | 364 | 'id' => '_feed_earliest_event_date_range', |
365 | - 'value' => strval( max( absint( get_post_meta( $post->ID, '_feed_earliest_event_date_range', true ) ), 1 ) ), |
|
365 | + 'value' => strval(max(absint(get_post_meta($post->ID, '_feed_earliest_event_date_range', true)), 1)), |
|
366 | 366 | 'attributes' => array( |
367 | 367 | 'min' => '1', |
368 | 368 | ), |
@@ -370,37 +370,37 @@ discard block |
||
370 | 370 | 'simcal-field-inline', |
371 | 371 | 'simcal-field-tiny', |
372 | 372 | ), |
373 | - 'style' => ( 'now' != $earliest_event ) && ( 'today' != $earliest_event ) ? array( 'display' => 'none' ) : '', |
|
374 | - ) ); |
|
373 | + 'style' => ('now' != $earliest_event) && ('today' != $earliest_event) ? array('display' => 'none') : '', |
|
374 | + )); |
|
375 | 375 | |
376 | 376 | ?> |
377 | 377 | <select name="_feed_earliest_event_date" |
378 | 378 | id="_feed_earliest_event_date" |
379 | 379 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
380 | - <option value="calendar_start" data-hide-field="_feed_earliest_event_date_range" <?php selected( 'calendar_start', $earliest_event, true ); ?>><?php _e( 'Same as start date', 'google-calendar-events' ); ?></option> |
|
381 | - <option value="days_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'days_before', $earliest_event, true ); ?>><?php _e( 'Day(s) before start date', 'google-calendar-events' ); ?></option> |
|
382 | - <option value="weeks_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'weeks_before', $earliest_event, true ); ?>><?php _e( 'Week(s) before start date', 'google-calendar-events' ); ?></option> |
|
383 | - <option value="months_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'months_before', $earliest_event, true ); ?>><?php _e( 'Month(s) before start date', 'google-calendar-events' ); ?></option> |
|
384 | - <option value="years_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'years_before', $earliest_event, true ); ?>><?php _e( 'Year(s) before start date', 'google-calendar-events' ); ?></option> |
|
380 | + <option value="calendar_start" data-hide-field="_feed_earliest_event_date_range" <?php selected('calendar_start', $earliest_event, true); ?>><?php _e('Same as start date', 'google-calendar-events'); ?></option> |
|
381 | + <option value="days_before" data-show-field="_feed_earliest_event_date_range" <?php selected('days_before', $earliest_event, true); ?>><?php _e('Day(s) before start date', 'google-calendar-events'); ?></option> |
|
382 | + <option value="weeks_before" data-show-field="_feed_earliest_event_date_range" <?php selected('weeks_before', $earliest_event, true); ?>><?php _e('Week(s) before start date', 'google-calendar-events'); ?></option> |
|
383 | + <option value="months_before" data-show-field="_feed_earliest_event_date_range" <?php selected('months_before', $earliest_event, true); ?>><?php _e('Month(s) before start date', 'google-calendar-events'); ?></option> |
|
384 | + <option value="years_before" data-show-field="_feed_earliest_event_date_range" <?php selected('years_before', $earliest_event, true); ?>><?php _e('Year(s) before start date', 'google-calendar-events'); ?></option> |
|
385 | 385 | </select> |
386 | 386 | <i class="simcal-icon-help simcal-help-tip" |
387 | - data-tip="<?php _e( 'Set the date for the earliest possible event to show in calendar. There will not be events before this date.', 'google-calendar-events' ); ?>"></i> |
|
387 | + data-tip="<?php _e('Set the date for the earliest possible event to show in calendar. There will not be events before this date.', 'google-calendar-events'); ?>"></i> |
|
388 | 388 | </td> |
389 | 389 | </tr> |
390 | 390 | <tr class="simcal-panel-field"> |
391 | - <th><label for="_feed_latest_event_date"><?php _e( 'Latest Event', 'google-calendar-events' ); ?></label></th> |
|
391 | + <th><label for="_feed_latest_event_date"><?php _e('Latest Event', 'google-calendar-events'); ?></label></th> |
|
392 | 392 | <td> |
393 | 393 | <?php |
394 | 394 | |
395 | - $latest_event_saved = get_post_meta( $post->ID, '_feed_latest_event_date', true ); |
|
396 | - $latest_event = false == $latest_event_saved ? 'years_after' : esc_attr( $latest_event_saved ); |
|
395 | + $latest_event_saved = get_post_meta($post->ID, '_feed_latest_event_date', true); |
|
396 | + $latest_event = false == $latest_event_saved ? 'years_after' : esc_attr($latest_event_saved); |
|
397 | 397 | |
398 | - simcal_print_field( array( |
|
398 | + simcal_print_field(array( |
|
399 | 399 | 'type' => 'standard', |
400 | 400 | 'subtype' => 'number', |
401 | 401 | 'name' => '_feed_latest_event_date_range', |
402 | 402 | 'id' => '_feed_latest_event_date_range', |
403 | - 'value' => strval( max( absint( get_post_meta( $post->ID, '_feed_latest_event_date_range', true ) ), 1 ) ), |
|
403 | + 'value' => strval(max(absint(get_post_meta($post->ID, '_feed_latest_event_date_range', true)), 1)), |
|
404 | 404 | 'attributes' => array( |
405 | 405 | 'min' => '1', |
406 | 406 | ), |
@@ -408,21 +408,21 @@ discard block |
||
408 | 408 | 'simcal-field-inline', |
409 | 409 | 'simcal-field-tiny', |
410 | 410 | ), |
411 | - 'style' => 'indefinite' != $latest_event ? array( 'display' => 'none' ) : '', |
|
412 | - ) ); |
|
411 | + 'style' => 'indefinite' != $latest_event ? array('display' => 'none') : '', |
|
412 | + )); |
|
413 | 413 | |
414 | 414 | ?> |
415 | 415 | <select name="_feed_latest_event_date" |
416 | 416 | id="_feed_latest_event_date" |
417 | 417 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
418 | - <option value="calendar_start" data-hide-field="_feed_latest_event_date_range" <?php selected( 'calendar_start', $earliest_event, true ); ?>><?php _e( 'Day end of start date', 'google-calendar-events' ); ?></option> |
|
419 | - <option value="days_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'days_after', $latest_event, true ); ?>><?php _e( 'Day(s) after start date', 'google-calendar-events' ); ?></option> |
|
420 | - <option value="weeks_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'weeks_after', $latest_event, true ); ?>><?php _e( 'Weeks(s) after start date', 'google-calendar-events' ); ?></option> |
|
421 | - <option value="months_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'months_after', $latest_event, true ); ?>><?php _e( 'Month(s) after start date', 'google-calendar-events' ); ?></option> |
|
422 | - <option value="years_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'years_after', $latest_event, true ); ?>><?php _e( 'Year(s) after start date', 'google-calendar-events' ); ?></option> |
|
418 | + <option value="calendar_start" data-hide-field="_feed_latest_event_date_range" <?php selected('calendar_start', $earliest_event, true); ?>><?php _e('Day end of start date', 'google-calendar-events'); ?></option> |
|
419 | + <option value="days_after" data-show-field="_feed_latest_event_date_range" <?php selected('days_after', $latest_event, true); ?>><?php _e('Day(s) after start date', 'google-calendar-events'); ?></option> |
|
420 | + <option value="weeks_after" data-show-field="_feed_latest_event_date_range" <?php selected('weeks_after', $latest_event, true); ?>><?php _e('Weeks(s) after start date', 'google-calendar-events'); ?></option> |
|
421 | + <option value="months_after" data-show-field="_feed_latest_event_date_range" <?php selected('months_after', $latest_event, true); ?>><?php _e('Month(s) after start date', 'google-calendar-events'); ?></option> |
|
422 | + <option value="years_after" data-show-field="_feed_latest_event_date_range" <?php selected('years_after', $latest_event, true); ?>><?php _e('Year(s) after start date', 'google-calendar-events'); ?></option> |
|
423 | 423 | </select> |
424 | 424 | <i class="simcal-icon-help simcal-help-tip" |
425 | - data-tip="<?php _e( 'Set the date for the latest possible event to show on calendar. There will not be events after this date.', 'google-calendar-events' ); ?>"></i> |
|
425 | + data-tip="<?php _e('Set the date for the latest possible event to show on calendar. There will not be events after this date.', 'google-calendar-events'); ?>"></i> |
|
426 | 426 | </td> |
427 | 427 | </tr> |
428 | 428 | </tbody> |
@@ -439,69 +439,69 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @param \WP_Post $post |
441 | 441 | */ |
442 | - private static function calendar_settings_panel( $post ) { |
|
442 | + private static function calendar_settings_panel($post) { |
|
443 | 443 | |
444 | 444 | ?> |
445 | 445 | <table> |
446 | 446 | <thead> |
447 | - <tr><th colspan="2"><?php _e( 'Miscellaneous', 'google-calendar-events' ); ?></th></tr> |
|
447 | + <tr><th colspan="2"><?php _e('Miscellaneous', 'google-calendar-events'); ?></th></tr> |
|
448 | 448 | </thead> |
449 | 449 | <tbody class="simcal-panel-section"> |
450 | 450 | <tr class="simcal-panel-field"> |
451 | - <th><label for="_calendar_is_static"><?php _e( 'Static Calendar', 'google-calendar-events' ); ?></label></th> |
|
451 | + <th><label for="_calendar_is_static"><?php _e('Static Calendar', 'google-calendar-events'); ?></label></th> |
|
452 | 452 | <td> |
453 | 453 | <?php |
454 | 454 | |
455 | - $fixed = get_post_meta( $post->ID, '_calendar_is_static', true ); |
|
455 | + $fixed = get_post_meta($post->ID, '_calendar_is_static', true); |
|
456 | 456 | |
457 | - simcal_print_field( array( |
|
457 | + simcal_print_field(array( |
|
458 | 458 | 'type' => 'checkbox', |
459 | 459 | 'name' => '_calendar_is_static', |
460 | 460 | 'id' => '_calendar_is_static', |
461 | - 'tooltip' => __( 'Remove the navigation arrows and fix the calendar view to its initial state.', 'google-calendar-events' ), |
|
461 | + 'tooltip' => __('Remove the navigation arrows and fix the calendar view to its initial state.', 'google-calendar-events'), |
|
462 | 462 | 'value' => 'yes' == $fixed ? 'yes' : 'no', |
463 | - 'text' => __( 'Yes (hide navigation arrows)', 'google-calendar-events' ), |
|
464 | - ) ); |
|
463 | + 'text' => __('Yes (hide navigation arrows)', 'google-calendar-events'), |
|
464 | + )); |
|
465 | 465 | |
466 | 466 | ?> |
467 | 467 | </td> |
468 | 468 | </tr> |
469 | 469 | <tr class="simcal-panel-field"> |
470 | - <th><label for="_no_events_message"><?php _e( 'No Events Message', 'google-calendar-events' ); ?></label></th> |
|
470 | + <th><label for="_no_events_message"><?php _e('No Events Message', 'google-calendar-events'); ?></label></th> |
|
471 | 471 | <td> |
472 | 472 | <?php |
473 | 473 | |
474 | - simcal_print_field( array( |
|
474 | + simcal_print_field(array( |
|
475 | 475 | 'type' => 'textarea', |
476 | 476 | 'name' => '_no_events_message', |
477 | 477 | 'id' => '_no_events_message', |
478 | - 'tooltip' => __( 'Some calendars may display a message when no events are found. You can change the default message here.', 'google-calendar-events' ), |
|
479 | - 'value' => get_post_meta( $post->ID, '_no_events_message', true ), |
|
480 | - ) ); |
|
478 | + 'tooltip' => __('Some calendars may display a message when no events are found. You can change the default message here.', 'google-calendar-events'), |
|
479 | + 'value' => get_post_meta($post->ID, '_no_events_message', true), |
|
480 | + )); |
|
481 | 481 | |
482 | 482 | ?> |
483 | 483 | </td> |
484 | 484 | </tr> |
485 | 485 | <tr class="simcal-panel-field"> |
486 | - <th><label for="_event_formatting"><?php _e( 'Event Formatting', 'google-calendar-events' ); ?></label></th> |
|
486 | + <th><label for="_event_formatting"><?php _e('Event Formatting', 'google-calendar-events'); ?></label></th> |
|
487 | 487 | <td> |
488 | 488 | <?php |
489 | 489 | |
490 | - $event_formatting = get_post_meta( $post->ID, '_event_formatting', true ); |
|
490 | + $event_formatting = get_post_meta($post->ID, '_event_formatting', true); |
|
491 | 491 | |
492 | - simcal_print_field( array( |
|
492 | + simcal_print_field(array( |
|
493 | 493 | 'type' => 'select', |
494 | 494 | 'name' => '_event_formatting', |
495 | 495 | 'id' => '_event_formatting', |
496 | - 'tooltip' => __( 'How to preserve line breaks and paragraphs in the event template builder.', 'google-calendar-events' ), |
|
496 | + 'tooltip' => __('How to preserve line breaks and paragraphs in the event template builder.', 'google-calendar-events'), |
|
497 | 497 | 'value' => $event_formatting, |
498 | 498 | 'default' => 'preserve_linebreaks', |
499 | 499 | 'options' => array( |
500 | - 'preserve_linebreaks' => __( 'Preserve line breaks, auto paragraphs (default)', 'google-calendar-events' ), |
|
501 | - 'no_linebreaks' => __( 'No line breaks, auto paragraphs', 'google-calendar-events' ), |
|
502 | - 'none' => __( 'No line breaks, no auto paragraphs', 'google-calendar-events' ), |
|
500 | + 'preserve_linebreaks' => __('Preserve line breaks, auto paragraphs (default)', 'google-calendar-events'), |
|
501 | + 'no_linebreaks' => __('No line breaks, auto paragraphs', 'google-calendar-events'), |
|
502 | + 'none' => __('No line breaks, no auto paragraphs', 'google-calendar-events'), |
|
503 | 503 | ), |
504 | - ) ); |
|
504 | + )); |
|
505 | 505 | |
506 | 506 | ?> |
507 | 507 | </td> |
@@ -520,28 +520,28 @@ discard block |
||
520 | 520 | * |
521 | 521 | * @param \WP_Post $post |
522 | 522 | */ |
523 | - private static function advanced_settings_panel( $post ) { |
|
523 | + private static function advanced_settings_panel($post) { |
|
524 | 524 | |
525 | 525 | ?> |
526 | 526 | <table> |
527 | 527 | <thead> |
528 | - <tr><th colspan="2"><?php _e( 'Date and Time', 'google-calendar-events' ); ?></th></tr> |
|
528 | + <tr><th colspan="2"><?php _e('Date and Time', 'google-calendar-events'); ?></th></tr> |
|
529 | 529 | </thead> |
530 | 530 | <tbody class="simcal-panel-section simcal-panel-datetime-formatting"> |
531 | 531 | <tr class="simcal-panel-field"> |
532 | - <th><label for="_calendar_timezone_setting"><?php _e( 'Timezone', 'google-calendar-events' ); ?></label></th> |
|
532 | + <th><label for="_calendar_timezone_setting"><?php _e('Timezone', 'google-calendar-events'); ?></label></th> |
|
533 | 533 | <td> |
534 | 534 | <?php |
535 | 535 | |
536 | 536 | $timezone_wordpress = simcal_get_wp_timezone(); |
537 | 537 | $timezone_default = $timezone_wordpress ? $timezone_wordpress : 'UTC'; |
538 | - $timezone_setting = esc_attr( get_post_meta( $post->ID, '_feed_timezone_setting', true ) ); |
|
539 | - $timezone = esc_attr( get_post_meta( $post->ID, '_feed_timezone', true ) ); |
|
538 | + $timezone_setting = esc_attr(get_post_meta($post->ID, '_feed_timezone_setting', true)); |
|
539 | + $timezone = esc_attr(get_post_meta($post->ID, '_feed_timezone', true)); |
|
540 | 540 | $timezone = $timezone ? $timezone : $timezone_default; |
541 | - $show_use_calendar = isset( simcal_get_feed( $post )->type ); |
|
541 | + $show_use_calendar = isset(simcal_get_feed($post)->type); |
|
542 | 542 | |
543 | - if ( $show_use_calendar ) { |
|
544 | - $show_use_calendar = ( simcal_get_feed( $post )->type !== 'grouped-calendars' ? 1 : 0 ); |
|
543 | + if ($show_use_calendar) { |
|
544 | + $show_use_calendar = (simcal_get_feed($post)->type !== 'grouped-calendars' ? 1 : 0); |
|
545 | 545 | } else { |
546 | 546 | $show_use_calendar = true; |
547 | 547 | } |
@@ -551,56 +551,56 @@ discard block |
||
551 | 551 | id="_feed_timezone_setting" |
552 | 552 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-other" |
553 | 553 | data-show-field-on-choice="true"> |
554 | - <option value="use_site" <?php selected( 'use_site', $timezone_setting, true ); ?>><?php printf( _x( 'Site default', 'Use this site default setting', 'google-calendar-events' ) . ' (%s)', $timezone_default ); ?></option> |
|
555 | - <?php if ( $show_use_calendar ) { ?> |
|
556 | - <option id="use_calendar" value="use_calendar" data-show-field="_use_calendar_warning" <?php selected( 'use_calendar', $timezone_setting, true ); ?>><?php _ex( 'Events source default', 'Use the calendar default setting', 'google-calendar-events' ); ?></option> |
|
554 | + <option value="use_site" <?php selected('use_site', $timezone_setting, true); ?>><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events').' (%s)', $timezone_default); ?></option> |
|
555 | + <?php if ($show_use_calendar) { ?> |
|
556 | + <option id="use_calendar" value="use_calendar" data-show-field="_use_calendar_warning" <?php selected('use_calendar', $timezone_setting, true); ?>><?php _ex('Events source default', 'Use the calendar default setting', 'google-calendar-events'); ?></option> |
|
557 | 557 | <?php } ?> |
558 | - <option value="use_custom" data-show-field="_feed_timezone" <?php selected( 'use_custom', $timezone_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
558 | + <option value="use_custom" data-show-field="_feed_timezone" <?php selected('use_custom', $timezone_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
559 | 559 | </select> |
560 | 560 | <select name="_feed_timezone" |
561 | 561 | id="_feed_timezone" |
562 | 562 | class="simcal-field simcal-field-select simcal-field-inline" |
563 | 563 | <?php echo 'use_custom' != $timezone_setting ? 'style="display: none;"' : ''; ?>> |
564 | - <?php echo wp_timezone_choice( $timezone ); ?> |
|
564 | + <?php echo wp_timezone_choice($timezone); ?> |
|
565 | 565 | </select> |
566 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Using a different timezone may alter the date and time display of your calendar events. It is recommended to keep the calendar default timezone.', 'google-calendar-events' ); ?>"></i> |
|
566 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Using a different timezone may alter the date and time display of your calendar events. It is recommended to keep the calendar default timezone.', 'google-calendar-events'); ?>"></i> |
|
567 | 567 | <p id="_use_calendar_warning" style="display: none;" class="simcal-field"> |
568 | - <?php printf( __( '<strong>Warning:</strong> Using this option can return unexpected results if you have specified <a href="%s" target="_blank">event level</a> timezones.', 'google-calendar-events' ), 'http://docs.simplecalendar.io/timezone-settings/' ); ?> |
|
568 | + <?php printf(__('<strong>Warning:</strong> Using this option can return unexpected results if you have specified <a href="%s" target="_blank">event level</a> timezones.', 'google-calendar-events'), 'http://docs.simplecalendar.io/timezone-settings/'); ?> |
|
569 | 569 | </p> |
570 | 570 | </td> |
571 | 571 | </tr> |
572 | 572 | <tr class="simcal-panel-field"> |
573 | - <th><label for="_calendar_date_format_setting"><?php _e( 'Date Format', 'google-calendar-events' ); ?></label></th> |
|
573 | + <th><label for="_calendar_date_format_setting"><?php _e('Date Format', 'google-calendar-events'); ?></label></th> |
|
574 | 574 | <td> |
575 | 575 | <?php |
576 | 576 | |
577 | - $date_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_setting', true ) ); |
|
578 | - $date_format_default = esc_attr( get_option( 'date_format' ) ); |
|
579 | - $date_format = esc_attr( get_post_meta( $post->ID, '_calendar_date_format', true ) ); |
|
580 | - $date_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_php', true ) ); |
|
577 | + $date_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_date_format_setting', true)); |
|
578 | + $date_format_default = esc_attr(get_option('date_format')); |
|
579 | + $date_format = esc_attr(get_post_meta($post->ID, '_calendar_date_format', true)); |
|
580 | + $date_format_php = esc_attr(get_post_meta($post->ID, '_calendar_date_format_php', true)); |
|
581 | 581 | $date_format_php = $date_format_php ? $date_format_php : $date_format_default; |
582 | 582 | |
583 | 583 | ?> |
584 | 584 | <select name="_calendar_date_format_setting" |
585 | 585 | id="_calendar_date_format_setting" |
586 | 586 | class="simcal-field simcal-field-select simcal-field-show-other"> |
587 | - <option value="use_site" data-show-field="_calendar_date_format_default" <?php selected( 'use_site', $date_format_setting, true ); ?>><?php _ex( 'Site default', 'Use this site default setting', 'google-calendar-events' ); ?></option> |
|
588 | - <option value="use_custom" data-show-field="_calendar_date_format" <?php selected( 'use_custom', $date_format_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
589 | - <option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected( 'use_custom_php', $date_format_setting, true ); ?>><?php _e( 'Custom (PHP format)', 'google-calendar-events' ); ?></option> |
|
587 | + <option value="use_site" data-show-field="_calendar_date_format_default" <?php selected('use_site', $date_format_setting, true); ?>><?php _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?></option> |
|
588 | + <option value="use_custom" data-show-field="_calendar_date_format" <?php selected('use_custom', $date_format_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
589 | + <option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected('use_custom_php', $date_format_setting, true); ?>><?php _e('Custom (PHP format)', 'google-calendar-events'); ?></option> |
|
590 | 590 | </select> |
591 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events' ); ?>"></i> |
|
591 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events'); ?>"></i> |
|
592 | 592 | <p id="_calendar_date_format_default" style="<?php echo $date_format_setting != 'use_site' ? 'display: none;' : ''; ?>"> |
593 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
594 | - <code><?php echo date_i18n( $date_format_default, time() ); ?></code> |
|
593 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
594 | + <code><?php echo date_i18n($date_format_default, time()); ?></code> |
|
595 | 595 | </p> |
596 | - <?php simcal_print_field( array( |
|
596 | + <?php simcal_print_field(array( |
|
597 | 597 | 'type' => 'datetime-format', |
598 | 598 | 'subtype' => 'date', |
599 | 599 | 'name' => '_calendar_date_format', |
600 | 600 | 'id' => '_calendar_date_format', |
601 | 601 | 'value' => $date_format, |
602 | - 'style' => $date_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '', |
|
603 | - ) ); ?> |
|
602 | + 'style' => $date_format_setting != 'use_custom' ? array('display' => 'none') : '', |
|
603 | + )); ?> |
|
604 | 604 | <div class="simcal-field-datetime-format-php" id="_calendar_date_format_php_field" style="<?php echo $date_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>"> |
605 | 605 | <br> |
606 | 606 | <label for="_calendar_date_format_php"> |
@@ -609,70 +609,70 @@ discard block |
||
609 | 609 | id="_calendar_date_format_php" |
610 | 610 | class="simcal-field simcal-field-text simcal-field-small" |
611 | 611 | value="<?php echo $date_format_php; ?>" /> |
612 | - <?php printf( __( 'Enter a date format using %s values.', 'google-calendar-events' ), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>' ); ?> |
|
612 | + <?php printf(__('Enter a date format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?> |
|
613 | 613 | </label> |
614 | 614 | <p> |
615 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
616 | - <code><?php echo date_i18n( $date_format_php, time() ); ?></code> |
|
615 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
616 | + <code><?php echo date_i18n($date_format_php, time()); ?></code> |
|
617 | 617 | </p> |
618 | 618 | </div> |
619 | 619 | </td> |
620 | 620 | </tr> |
621 | 621 | <tr class="simcal-panel-field"> |
622 | - <th><label for="_calendar_datetime_separator"><?php _e( 'Separator', 'google-calendar-events' ); ?></label></th> |
|
622 | + <th><label for="_calendar_datetime_separator"><?php _e('Separator', 'google-calendar-events'); ?></label></th> |
|
623 | 623 | <td> |
624 | 624 | <?php |
625 | 625 | |
626 | - $separator = get_post_meta( $post->ID, '_calendar_datetime_separator', true ); |
|
626 | + $separator = get_post_meta($post->ID, '_calendar_datetime_separator', true); |
|
627 | 627 | $separator = false == $separator ? '@' : $separator; |
628 | 628 | |
629 | - simcal_print_field( array( |
|
629 | + simcal_print_field(array( |
|
630 | 630 | 'type' => 'standard', |
631 | 631 | 'subtype' => 'text', |
632 | 632 | 'name' => '_calendar_datetime_separator', |
633 | 633 | 'id' => '_calendar_datetime_separator', |
634 | 634 | 'value' => $separator, |
635 | - 'tooltip' => __( 'Used to divide date and time when both are shown.', 'google-calendar-events' ), |
|
635 | + 'tooltip' => __('Used to divide date and time when both are shown.', 'google-calendar-events'), |
|
636 | 636 | 'class' => array( |
637 | 637 | 'simcal-field-tiny', |
638 | 638 | ), |
639 | - ) ); |
|
639 | + )); |
|
640 | 640 | |
641 | 641 | ?> |
642 | 642 | </td> |
643 | 643 | </tr> |
644 | 644 | <tr class="simcal-panel-field"> |
645 | - <th><label for="_calendar_time_format_setting"><?php _e( 'Time Format', 'google-calendar-events' ); ?></label></th> |
|
645 | + <th><label for="_calendar_time_format_setting"><?php _e('Time Format', 'google-calendar-events'); ?></label></th> |
|
646 | 646 | <td> |
647 | 647 | <?php |
648 | 648 | |
649 | - $time_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_setting', true ) ); |
|
650 | - $time_format_default = esc_attr( get_option( 'time_format' ) ); |
|
651 | - $time_format = esc_attr( get_post_meta( $post->ID, '_calendar_time_format', true ) ); |
|
652 | - $time_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_php', true ) ); |
|
649 | + $time_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_time_format_setting', true)); |
|
650 | + $time_format_default = esc_attr(get_option('time_format')); |
|
651 | + $time_format = esc_attr(get_post_meta($post->ID, '_calendar_time_format', true)); |
|
652 | + $time_format_php = esc_attr(get_post_meta($post->ID, '_calendar_time_format_php', true)); |
|
653 | 653 | $time_format_php = $time_format_php ? $time_format_php : $time_format_default; |
654 | 654 | |
655 | 655 | ?> |
656 | 656 | <select name="_calendar_time_format_setting" |
657 | 657 | id="_calendar_time_format_setting" |
658 | 658 | class="simcal-field simcal-field-select simcal-field-show-other"> |
659 | - <option value="use_site" data-show-field="_calendar_time_format_default" <?php selected( 'use_site', $time_format_setting, true ); ?>><?php _ex( 'Site default', 'Use this site default setting', 'google-calendar-events' ); ?></option> |
|
660 | - <option value="use_custom" data-show-field="_calendar_time_format" <?php selected( 'use_custom', $time_format_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
661 | - <option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected( 'use_custom_php', $time_format_setting, true ); ?>><?php _e( 'Custom (PHP format)', 'google-calendar-events' ); ?></option> |
|
659 | + <option value="use_site" data-show-field="_calendar_time_format_default" <?php selected('use_site', $time_format_setting, true); ?>><?php _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?></option> |
|
660 | + <option value="use_custom" data-show-field="_calendar_time_format" <?php selected('use_custom', $time_format_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
661 | + <option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected('use_custom_php', $time_format_setting, true); ?>><?php _e('Custom (PHP format)', 'google-calendar-events'); ?></option> |
|
662 | 662 | </select> |
663 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events' ); ?>"></i> |
|
663 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events'); ?>"></i> |
|
664 | 664 | <p id="_calendar_time_format_default" style="<?php echo $time_format_setting != 'use_site' ? 'display: none;' : ''; ?>"> |
665 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
666 | - <code><?php echo date_i18n( $time_format_default, time() ); ?></code> |
|
665 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
666 | + <code><?php echo date_i18n($time_format_default, time()); ?></code> |
|
667 | 667 | </p> |
668 | - <?php simcal_print_field( array( |
|
668 | + <?php simcal_print_field(array( |
|
669 | 669 | 'type' => 'datetime-format', |
670 | 670 | 'subtype' => 'time', |
671 | 671 | 'name' => '_calendar_time_format', |
672 | 672 | 'id' => '_calendar_time_format', |
673 | 673 | 'value' => $time_format, |
674 | - 'style' => $time_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '', |
|
675 | - ) ); ?> |
|
674 | + 'style' => $time_format_setting != 'use_custom' ? array('display' => 'none') : '', |
|
675 | + )); ?> |
|
676 | 676 | <div class="simcal-field-datetime-format-php" id="_calendar_time_format_php_field" style="<?php echo $time_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>"> |
677 | 677 | <br> |
678 | 678 | <label for="_calendar_date_format_php"> |
@@ -681,24 +681,24 @@ discard block |
||
681 | 681 | id="_calendar_time_format_php" |
682 | 682 | class="simcal-field simcal-field-text simcal-field-small" |
683 | 683 | value="<?php echo $time_format_php; ?>"/> |
684 | - <?php printf( __( 'Enter a time format using %s values.', 'google-calendar-events' ), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>' ); ?> |
|
684 | + <?php printf(__('Enter a time format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?> |
|
685 | 685 | </label> |
686 | 686 | <p> |
687 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
688 | - <code><?php echo date_i18n( $time_format_php, time() ); ?></code> |
|
687 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
688 | + <code><?php echo date_i18n($time_format_php, time()); ?></code> |
|
689 | 689 | </p> |
690 | 690 | </div> |
691 | 691 | </td> |
692 | 692 | </tr> |
693 | 693 | <tr class="simcal-panel-field"> |
694 | - <th><label for="_calendar_week_starts_on_setting"><?php _e( 'Week Starts On', 'google-calendar-events' ); ?></label></th> |
|
694 | + <th><label for="_calendar_week_starts_on_setting"><?php _e('Week Starts On', 'google-calendar-events'); ?></label></th> |
|
695 | 695 | <td> |
696 | 696 | <?php |
697 | 697 | |
698 | - $week_starts_setting = esc_attr( get_post_meta( $post->ID, '_calendar_week_starts_on_setting', true ) ); |
|
699 | - $week_starts_default = esc_attr( get_option( 'start_of_week' ) ); |
|
700 | - $week_starts = intval( get_post_meta( $post->ID, '_calendar_week_starts_on', true ) ); |
|
701 | - $week_starts = is_numeric( $week_starts ) ? strval( $week_starts ) : $week_starts_default; |
|
698 | + $week_starts_setting = esc_attr(get_post_meta($post->ID, '_calendar_week_starts_on_setting', true)); |
|
699 | + $week_starts_default = esc_attr(get_option('start_of_week')); |
|
700 | + $week_starts = intval(get_post_meta($post->ID, '_calendar_week_starts_on', true)); |
|
701 | + $week_starts = is_numeric($week_starts) ? strval($week_starts) : $week_starts_default; |
|
702 | 702 | |
703 | 703 | ?> |
704 | 704 | <select |
@@ -706,40 +706,40 @@ discard block |
||
706 | 706 | id="_calendar_week_starts_on_setting" |
707 | 707 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-next" |
708 | 708 | data-show-next-if-value="use_custom"> |
709 | - <option value="use_site" <?php selected( 'use_site', $week_starts_setting, true ); ?>><?php printf( _x( 'Site default', 'Use this site default setting', 'google-calendar-events' ) . ' (%s)', date_i18n( 'l', strtotime( "Sunday + $week_starts_default Days" ) ) ); ?></option> |
|
710 | - <option value="use_custom" <?php selected( 'use_custom', $week_starts_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
709 | + <option value="use_site" <?php selected('use_site', $week_starts_setting, true); ?>><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events').' (%s)', date_i18n('l', strtotime("Sunday + $week_starts_default Days"))); ?></option> |
|
710 | + <option value="use_custom" <?php selected('use_custom', $week_starts_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
711 | 711 | </select> |
712 | 712 | <select |
713 | 713 | name="_calendar_week_starts_on" |
714 | 714 | id="_calendar_week_starts_on" |
715 | 715 | class="simcal-field simcal-field-select simcal-field-inline" |
716 | 716 | <?php echo 'use_custom' != $week_starts_setting ? 'style="display: none;"' : ''; ?>> |
717 | - <?php $day_names = simcal_get_calendar_names_i18n( 'day', 'full' ); ?> |
|
718 | - <?php for ( $i = 0; $i <= 6; $i++ ) : ?> |
|
719 | - <option value="<?php echo $i; ?>" <?php selected( $i, $week_starts, true ); ?>><?php echo $day_names[ $i ]; ?></option> |
|
717 | + <?php $day_names = simcal_get_calendar_names_i18n('day', 'full'); ?> |
|
718 | + <?php for ($i = 0; $i <= 6; $i++) : ?> |
|
719 | + <option value="<?php echo $i; ?>" <?php selected($i, $week_starts, true); ?>><?php echo $day_names[$i]; ?></option> |
|
720 | 720 | <?php endfor; ?> |
721 | 721 | </select> |
722 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events' ); ?>"></i> |
|
722 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events'); ?>"></i> |
|
723 | 723 | </td> |
724 | 724 | </tr> |
725 | 725 | </tbody> |
726 | 726 | </table> |
727 | 727 | <table> |
728 | 728 | <thead> |
729 | - <tr><th colspan="2"><?php _e( 'Cache', 'google-calendar-events' ); ?></th></tr> |
|
729 | + <tr><th colspan="2"><?php _e('Cache', 'google-calendar-events'); ?></th></tr> |
|
730 | 730 | </thead> |
731 | 731 | <tbody class="simcal-panel-section simcal-panel-section-cache"> |
732 | 732 | <?php |
733 | 733 | |
734 | - $cache_freq = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_amount', true ) ); |
|
735 | - $cache_unit = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_unit', true ) ); |
|
734 | + $cache_freq = esc_attr(get_post_meta($post->ID, '_feed_cache_user_amount', true)); |
|
735 | + $cache_unit = esc_attr(get_post_meta($post->ID, '_feed_cache_user_unit', true)); |
|
736 | 736 | |
737 | - $cache_freq = intval( $cache_freq ) && $cache_freq >= 0 ? $cache_freq : 2; |
|
737 | + $cache_freq = intval($cache_freq) && $cache_freq >= 0 ? $cache_freq : 2; |
|
738 | 738 | $cache_unit = $cache_unit ? $cache_unit : '3600'; |
739 | 739 | |
740 | 740 | ?> |
741 | 741 | <tr class="simcal-panel-field"> |
742 | - <th><label for="_feed_cache_user_amount"><?php _ex( 'Refresh Interval', 'Cache maximum interval', 'google-calendar-events' ); ?></label></th> |
|
742 | + <th><label for="_feed_cache_user_amount"><?php _ex('Refresh Interval', 'Cache maximum interval', 'google-calendar-events'); ?></label></th> |
|
743 | 743 | <td> |
744 | 744 | <input type="number" |
745 | 745 | name="_feed_cache_user_amount" |
@@ -750,12 +750,12 @@ discard block |
||
750 | 750 | <select name="_feed_cache_user_unit" |
751 | 751 | id="_feed_cache_user_unit" |
752 | 752 | class="simcal-field simcalfield-select simcal-field-inline"> |
753 | - <option value="60" <?php selected( '60', $cache_unit, true ); ?>><?php _e( 'Minute(s)', 'google-calendar-events' ); ?></option> |
|
754 | - <option value="3600" <?php selected( '3600', $cache_unit, true ); ?>><?php _e( 'Hour(s)', 'google-calendar-events' ); ?></option> |
|
755 | - <option value="86400" <?php selected( '86400', $cache_unit, true ); ?>><?php _e( 'Day(s)', 'google-calendar-events' ); ?></option> |
|
756 | - <option value="604800" <?php selected( '604800', $cache_unit, true ); ?>><?php _e( 'Week(s)', 'google-calendar-events' ); ?></option> |
|
753 | + <option value="60" <?php selected('60', $cache_unit, true); ?>><?php _e('Minute(s)', 'google-calendar-events'); ?></option> |
|
754 | + <option value="3600" <?php selected('3600', $cache_unit, true); ?>><?php _e('Hour(s)', 'google-calendar-events'); ?></option> |
|
755 | + <option value="86400" <?php selected('86400', $cache_unit, true); ?>><?php _e('Day(s)', 'google-calendar-events'); ?></option> |
|
756 | + <option value="604800" <?php selected('604800', $cache_unit, true); ?>><?php _e('Week(s)', 'google-calendar-events'); ?></option> |
|
757 | 757 | </select> |
758 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events' ); ?>"></i> |
|
758 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events'); ?>"></i> |
|
759 | 759 | </td> |
760 | 760 | </tr> |
761 | 761 | </tbody> |
@@ -774,21 +774,21 @@ discard block |
||
774 | 774 | * |
775 | 775 | * @return void |
776 | 776 | */ |
777 | - public static function print_panel_fields( $array, $post_id ) { |
|
777 | + public static function print_panel_fields($array, $post_id) { |
|
778 | 778 | |
779 | - foreach ( $array as $section => $fields ) : |
|
779 | + foreach ($array as $section => $fields) : |
|
780 | 780 | |
781 | - if ( $fields && is_array( $fields ) ) : |
|
781 | + if ($fields && is_array($fields)) : |
|
782 | 782 | |
783 | 783 | ?> |
784 | - <tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr( $section ); ?>"> |
|
785 | - <?php foreach ( $fields as $key => $field ) : |
|
784 | + <tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr($section); ?>"> |
|
785 | + <?php foreach ($fields as $key => $field) : |
|
786 | 786 | |
787 | - $value = get_post_meta( $post_id, $key, true ); |
|
788 | - $field['value'] = $value ? $value : ( isset( $field['default'] ) ? $field['default'] : '' ); |
|
789 | - $the_field = simcal_get_field( $field ); ?> |
|
787 | + $value = get_post_meta($post_id, $key, true); |
|
788 | + $field['value'] = $value ? $value : (isset($field['default']) ? $field['default'] : ''); |
|
789 | + $the_field = simcal_get_field($field); ?> |
|
790 | 790 | |
791 | - <?php if ( $the_field instanceof Field ) : ?> |
|
791 | + <?php if ($the_field instanceof Field) : ?> |
|
792 | 792 | <tr class="simcal-panel-field"> |
793 | 793 | <th><label for="<?php echo $the_field->id ?>"><?php echo $the_field->title; ?></label></th> |
794 | 794 | <td><?php $the_field->html(); ?></td> |
@@ -815,30 +815,30 @@ discard block |
||
815 | 815 | * |
816 | 816 | * @return void |
817 | 817 | */ |
818 | - public static function save( $post_id, $post ) { |
|
818 | + public static function save($post_id, $post) { |
|
819 | 819 | |
820 | 820 | /* ====================== * |
821 | 821 | * Calendar type and view * |
822 | 822 | * ====================== */ |
823 | 823 | |
824 | 824 | // Unlink existing terms for feed type and calendar type. |
825 | - wp_delete_object_term_relationships( $post_id, array( |
|
825 | + wp_delete_object_term_relationships($post_id, array( |
|
826 | 826 | 'calendar_feed', |
827 | 827 | 'calendar_type', |
828 | - ) ); |
|
828 | + )); |
|
829 | 829 | |
830 | 830 | // Set the feed type as term. |
831 | - $feed_type = isset( $_POST['_feed_type'] ) ? sanitize_title( stripslashes( $_POST['_feed_type'] ) ) : apply_filters( 'simcal_default_feed_type', 'google' ); |
|
832 | - wp_set_object_terms( $post_id, $feed_type, 'calendar_feed' ); |
|
831 | + $feed_type = isset($_POST['_feed_type']) ? sanitize_title(stripslashes($_POST['_feed_type'])) : apply_filters('simcal_default_feed_type', 'google'); |
|
832 | + wp_set_object_terms($post_id, $feed_type, 'calendar_feed'); |
|
833 | 833 | |
834 | 834 | // Set the calendar type as a term. |
835 | - $calendar_type = isset( $_POST['_calendar_type'] ) ? sanitize_title( stripslashes( $_POST['_calendar_type'] ) ) : apply_filters( 'simcal_default_calendar_type', 'default-calendar' ); |
|
836 | - wp_set_object_terms( $post_id, $calendar_type, 'calendar_type' ); |
|
835 | + $calendar_type = isset($_POST['_calendar_type']) ? sanitize_title(stripslashes($_POST['_calendar_type'])) : apply_filters('simcal_default_calendar_type', 'default-calendar'); |
|
836 | + wp_set_object_terms($post_id, $calendar_type, 'calendar_type'); |
|
837 | 837 | // Set the calendar type view as post meta. |
838 | - $calendar_view = isset( $_POST['_calendar_view'] ) ? $_POST['_calendar_view'] : ''; |
|
839 | - if ( $calendar_view && is_array( $calendar_view ) ) { |
|
840 | - $views = array_map( 'sanitize_title', $calendar_view ); |
|
841 | - update_post_meta( $post_id, '_calendar_view', $views ); |
|
838 | + $calendar_view = isset($_POST['_calendar_view']) ? $_POST['_calendar_view'] : ''; |
|
839 | + if ($calendar_view && is_array($calendar_view)) { |
|
840 | + $views = array_map('sanitize_title', $calendar_view); |
|
841 | + update_post_meta($post_id, '_calendar_view', $views); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | /* ===================== * |
@@ -846,102 +846,102 @@ discard block |
||
846 | 846 | * ===================== */ |
847 | 847 | |
848 | 848 | // Calendar opening. |
849 | - $calendar_begins = isset( $_POST['_calendar_begins'] ) ? sanitize_key( $_POST['_calendar_begins'] ) : 'this_month'; |
|
850 | - update_post_meta( $post_id, '_calendar_begins', $calendar_begins ); |
|
851 | - $calendar_begins_nth = isset( $_POST['_calendar_begins_nth'] ) ? absint( $_POST['_calendar_begins_nth'] ) : 2; |
|
852 | - update_post_meta( $post_id, '_calendar_begins_nth', $calendar_begins_nth ); |
|
853 | - $calendar_begins_custom_date = isset( $_POST['_calendar_begins_custom_date'] ) ? sanitize_title( $_POST['_calendar_begins_custom_date'] ) : ''; |
|
854 | - update_post_meta( $post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date ); |
|
849 | + $calendar_begins = isset($_POST['_calendar_begins']) ? sanitize_key($_POST['_calendar_begins']) : 'this_month'; |
|
850 | + update_post_meta($post_id, '_calendar_begins', $calendar_begins); |
|
851 | + $calendar_begins_nth = isset($_POST['_calendar_begins_nth']) ? absint($_POST['_calendar_begins_nth']) : 2; |
|
852 | + update_post_meta($post_id, '_calendar_begins_nth', $calendar_begins_nth); |
|
853 | + $calendar_begins_custom_date = isset($_POST['_calendar_begins_custom_date']) ? sanitize_title($_POST['_calendar_begins_custom_date']) : ''; |
|
854 | + update_post_meta($post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date); |
|
855 | 855 | |
856 | 856 | // Feed earliest events date. |
857 | - $earliest_events = isset( $_POST['_feed_earliest_event_date'] ) ? sanitize_key( $_POST['_feed_earliest_event_date'] ) : ''; |
|
858 | - update_post_meta( $post_id, '_feed_earliest_event_date', $earliest_events ); |
|
859 | - $earliest_events_range = isset( $_POST['_feed_earliest_event_date_range'] ) ? max( absint( $_POST['_feed_earliest_event_date_range'] ), 1 ) : 1; |
|
860 | - update_post_meta( $post_id, '_feed_earliest_event_date_range', $earliest_events_range ); |
|
857 | + $earliest_events = isset($_POST['_feed_earliest_event_date']) ? sanitize_key($_POST['_feed_earliest_event_date']) : ''; |
|
858 | + update_post_meta($post_id, '_feed_earliest_event_date', $earliest_events); |
|
859 | + $earliest_events_range = isset($_POST['_feed_earliest_event_date_range']) ? max(absint($_POST['_feed_earliest_event_date_range']), 1) : 1; |
|
860 | + update_post_meta($post_id, '_feed_earliest_event_date_range', $earliest_events_range); |
|
861 | 861 | |
862 | 862 | // Feed latest events date. |
863 | - $latest_events = isset( $_POST['_feed_latest_event_date'] ) ? sanitize_key( $_POST['_feed_latest_event_date'] ) : ''; |
|
864 | - update_post_meta( $post_id, '_feed_latest_event_date', $latest_events ); |
|
865 | - $latest_events_range = isset( $_POST['_feed_latest_event_date_range'] ) ? max( absint( $_POST['_feed_latest_event_date_range'] ), 1 ) : 1; |
|
866 | - update_post_meta( $post_id, '_feed_latest_event_date_range', $latest_events_range ); |
|
863 | + $latest_events = isset($_POST['_feed_latest_event_date']) ? sanitize_key($_POST['_feed_latest_event_date']) : ''; |
|
864 | + update_post_meta($post_id, '_feed_latest_event_date', $latest_events); |
|
865 | + $latest_events_range = isset($_POST['_feed_latest_event_date_range']) ? max(absint($_POST['_feed_latest_event_date_range']), 1) : 1; |
|
866 | + update_post_meta($post_id, '_feed_latest_event_date_range', $latest_events_range); |
|
867 | 867 | |
868 | 868 | /* ======================= * |
869 | 869 | * Calendar settings panel * |
870 | 870 | * ======================= */ |
871 | 871 | |
872 | 872 | // Static calendar. |
873 | - $static = isset( $_POST['_calendar_is_static'] ) ? 'yes' : 'no'; |
|
874 | - update_post_meta( $post_id, '_calendar_is_static', $static ); |
|
873 | + $static = isset($_POST['_calendar_is_static']) ? 'yes' : 'no'; |
|
874 | + update_post_meta($post_id, '_calendar_is_static', $static); |
|
875 | 875 | |
876 | 876 | // No events message. |
877 | - $message = isset( $_POST['_no_events_message'] ) ? wp_kses_post( $_POST['_no_events_message'] ) : ''; |
|
878 | - update_post_meta( $post_id, '_no_events_message', $message ); |
|
877 | + $message = isset($_POST['_no_events_message']) ? wp_kses_post($_POST['_no_events_message']) : ''; |
|
878 | + update_post_meta($post_id, '_no_events_message', $message); |
|
879 | 879 | |
880 | 880 | // _event_formatting |
881 | - $event_formatting = isset( $_POST['_event_formatting'] ) ? sanitize_key( $_POST['_event_formatting'] ) : 'preserve_linebreaks'; |
|
882 | - update_post_meta( $post_id, '_event_formatting', $event_formatting ); |
|
881 | + $event_formatting = isset($_POST['_event_formatting']) ? sanitize_key($_POST['_event_formatting']) : 'preserve_linebreaks'; |
|
882 | + update_post_meta($post_id, '_event_formatting', $event_formatting); |
|
883 | 883 | |
884 | 884 | /* ======================= * |
885 | 885 | * Advanced settings panel * |
886 | 886 | * ======================= */ |
887 | 887 | |
888 | 888 | // Timezone. |
889 | - $feed_timezone_setting = isset( $_POST['_feed_timezone_setting'] ) ? sanitize_key( $_POST['_feed_timezone_setting'] ) : 'use_calendar'; |
|
890 | - update_post_meta( $post_id, '_feed_timezone_setting', $feed_timezone_setting ); |
|
889 | + $feed_timezone_setting = isset($_POST['_feed_timezone_setting']) ? sanitize_key($_POST['_feed_timezone_setting']) : 'use_calendar'; |
|
890 | + update_post_meta($post_id, '_feed_timezone_setting', $feed_timezone_setting); |
|
891 | 891 | $default_timezone = simcal_get_wp_timezone(); |
892 | 892 | $feed_timezone = $default_timezone ? $default_timezone : 'UTC'; |
893 | - $feed_timezone = isset( $_POST['_feed_timezone'] ) ? sanitize_text_field( $_POST['_feed_timezone'] ) : $feed_timezone; |
|
894 | - update_post_meta( $post_id, '_feed_timezone', $feed_timezone ); |
|
893 | + $feed_timezone = isset($_POST['_feed_timezone']) ? sanitize_text_field($_POST['_feed_timezone']) : $feed_timezone; |
|
894 | + update_post_meta($post_id, '_feed_timezone', $feed_timezone); |
|
895 | 895 | |
896 | 896 | // Date format. |
897 | - $date_format_setting = isset( $_POST['_calendar_date_format_setting'] ) ? sanitize_key( $_POST['_calendar_date_format_setting'] ) : 'use_site'; |
|
898 | - update_post_meta( $post_id, '_calendar_date_format_setting', $date_format_setting ); |
|
899 | - $date_format = isset( $_POST['_calendar_date_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format'] ) ) : get_option( 'date_format' ); |
|
900 | - update_post_meta( $post_id, '_calendar_date_format', $date_format ); |
|
901 | - $date_format_php = isset( $_POST['_calendar_date_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format_php'] ) ) : get_option( 'date_format' ); |
|
902 | - update_post_meta( $post_id, '_calendar_date_format_php', $date_format_php ); |
|
897 | + $date_format_setting = isset($_POST['_calendar_date_format_setting']) ? sanitize_key($_POST['_calendar_date_format_setting']) : 'use_site'; |
|
898 | + update_post_meta($post_id, '_calendar_date_format_setting', $date_format_setting); |
|
899 | + $date_format = isset($_POST['_calendar_date_format']) ? sanitize_text_field(trim($_POST['_calendar_date_format'])) : get_option('date_format'); |
|
900 | + update_post_meta($post_id, '_calendar_date_format', $date_format); |
|
901 | + $date_format_php = isset($_POST['_calendar_date_format_php']) ? sanitize_text_field(trim($_POST['_calendar_date_format_php'])) : get_option('date_format'); |
|
902 | + update_post_meta($post_id, '_calendar_date_format_php', $date_format_php); |
|
903 | 903 | |
904 | 904 | // Time format. |
905 | - $time_format_setting = isset( $_POST['_calendar_time_format_setting'] ) ? sanitize_key( $_POST['_calendar_time_format_setting'] ) : 'use_site'; |
|
906 | - update_post_meta( $post_id, '_calendar_time_format_setting', $time_format_setting ); |
|
907 | - $time_format = isset( $_POST['_calendar_time_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format'] ) ) : get_option( 'time_format' ); |
|
908 | - update_post_meta( $post_id, '_calendar_time_format', $time_format ); |
|
909 | - $time_format_php = isset( $_POST['_calendar_time_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format_php'] ) ) : get_option( 'time_format' ); |
|
910 | - update_post_meta( $post_id, '_calendar_time_format_php', $time_format_php ); |
|
905 | + $time_format_setting = isset($_POST['_calendar_time_format_setting']) ? sanitize_key($_POST['_calendar_time_format_setting']) : 'use_site'; |
|
906 | + update_post_meta($post_id, '_calendar_time_format_setting', $time_format_setting); |
|
907 | + $time_format = isset($_POST['_calendar_time_format']) ? sanitize_text_field(trim($_POST['_calendar_time_format'])) : get_option('time_format'); |
|
908 | + update_post_meta($post_id, '_calendar_time_format', $time_format); |
|
909 | + $time_format_php = isset($_POST['_calendar_time_format_php']) ? sanitize_text_field(trim($_POST['_calendar_time_format_php'])) : get_option('time_format'); |
|
910 | + update_post_meta($post_id, '_calendar_time_format_php', $time_format_php); |
|
911 | 911 | |
912 | 912 | // Date-time separator. |
913 | - $datetime_separator = isset( $_POST['_calendar_datetime_separator'] ) ? sanitize_text_field( $_POST['_calendar_datetime_separator'] ) : ' '; |
|
914 | - update_post_meta( $post_id, '_calendar_datetime_separator', $datetime_separator ); |
|
913 | + $datetime_separator = isset($_POST['_calendar_datetime_separator']) ? sanitize_text_field($_POST['_calendar_datetime_separator']) : ' '; |
|
914 | + update_post_meta($post_id, '_calendar_datetime_separator', $datetime_separator); |
|
915 | 915 | |
916 | 916 | // Week start. |
917 | - $week_start_setting = isset( $_POST['_calendar_week_starts_on_setting'] ) ? sanitize_key( $_POST['_calendar_week_starts_on_setting'] ) : 'use_site'; |
|
918 | - update_post_meta( $post_id, '_calendar_week_starts_on_setting', $week_start_setting ); |
|
919 | - $week_start = isset( $_POST['_calendar_week_starts_on'] ) ? intval( $_POST['_calendar_week_starts_on'] ) : get_option( 'start_of_week' ); |
|
920 | - update_post_meta( $post_id, '_calendar_week_starts_on', $week_start ); |
|
917 | + $week_start_setting = isset($_POST['_calendar_week_starts_on_setting']) ? sanitize_key($_POST['_calendar_week_starts_on_setting']) : 'use_site'; |
|
918 | + update_post_meta($post_id, '_calendar_week_starts_on_setting', $week_start_setting); |
|
919 | + $week_start = isset($_POST['_calendar_week_starts_on']) ? intval($_POST['_calendar_week_starts_on']) : get_option('start_of_week'); |
|
920 | + update_post_meta($post_id, '_calendar_week_starts_on', $week_start); |
|
921 | 921 | |
922 | 922 | // Cache interval. |
923 | 923 | $cache = 7200; |
924 | - if ( isset( $_POST['_feed_cache_user_amount'] ) && isset( $_POST['_feed_cache_user_unit'] ) ) { |
|
925 | - $amount = is_numeric( $_POST['_feed_cache_user_amount'] ) || $_POST['_feed_cache_user_amount'] == 0 ? absint( $_POST['_feed_cache_user_amount'] ) : 1; |
|
926 | - $unit = is_numeric( $_POST['_feed_cache_user_unit'] ) ? absint( $_POST['_feed_cache_user_unit'] ) : 3600; |
|
927 | - update_post_meta( $post_id, '_feed_cache_user_amount', $amount ); |
|
928 | - update_post_meta( $post_id, '_feed_cache_user_unit', $unit ); |
|
929 | - $cache = ( ( $amount * $unit ) > 0 ) ? $amount * $unit : 1; |
|
924 | + if (isset($_POST['_feed_cache_user_amount']) && isset($_POST['_feed_cache_user_unit'])) { |
|
925 | + $amount = is_numeric($_POST['_feed_cache_user_amount']) || $_POST['_feed_cache_user_amount'] == 0 ? absint($_POST['_feed_cache_user_amount']) : 1; |
|
926 | + $unit = is_numeric($_POST['_feed_cache_user_unit']) ? absint($_POST['_feed_cache_user_unit']) : 3600; |
|
927 | + update_post_meta($post_id, '_feed_cache_user_amount', $amount); |
|
928 | + update_post_meta($post_id, '_feed_cache_user_unit', $unit); |
|
929 | + $cache = (($amount * $unit) > 0) ? $amount * $unit : 1; |
|
930 | 930 | } |
931 | - update_post_meta( $post_id, '_feed_cache', $cache ); |
|
931 | + update_post_meta($post_id, '_feed_cache', $cache); |
|
932 | 932 | |
933 | 933 | /* ============= * |
934 | 934 | * Miscellaneous * |
935 | 935 | * ============= */ |
936 | 936 | |
937 | 937 | // Update version. |
938 | - update_post_meta( $post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION ); |
|
938 | + update_post_meta($post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION); |
|
939 | 939 | |
940 | 940 | // Action hook. |
941 | - do_action( 'simcal_process_settings_meta', $post_id ); |
|
941 | + do_action('simcal_process_settings_meta', $post_id); |
|
942 | 942 | |
943 | 943 | // Clear cache. |
944 | - simcal_delete_feed_transients( $post_id ); |
|
944 | + simcal_delete_feed_transients($post_id); |
|
945 | 945 | } |
946 | 946 | |
947 | 947 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Meta_Box; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -28,38 +28,38 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param \WP_Post $post |
30 | 30 | */ |
31 | - public static function html( $post ) { |
|
31 | + public static function html($post) { |
|
32 | 32 | |
33 | 33 | // @see Meta_Boxes::save_meta_boxes() |
34 | - wp_nonce_field( 'simcal_save_data', 'simcal_meta_nonce' ); |
|
34 | + wp_nonce_field('simcal_save_data', 'simcal_meta_nonce'); |
|
35 | 35 | |
36 | 36 | $calendars = simcal_get_calendars(); |
37 | 37 | |
38 | - simcal_print_field( array( |
|
38 | + simcal_print_field(array( |
|
39 | 39 | 'type' => 'select', |
40 | 40 | 'id' => '_simcal_attach_calendar_id', |
41 | 41 | 'name' => '_simcal_attach_calendar_id', |
42 | - 'enhanced' => count( $calendars ) > 15 ? 'enhanced' : '', |
|
42 | + 'enhanced' => count($calendars) > 15 ? 'enhanced' : '', |
|
43 | 43 | 'allow_void' => 'allow_void', |
44 | - 'value' => absint( get_post_meta( $post->ID, '_simcal_attach_calendar_id', true ) ), |
|
44 | + 'value' => absint(get_post_meta($post->ID, '_simcal_attach_calendar_id', true)), |
|
45 | 45 | 'options' => $calendars, |
46 | 46 | 'attributes' => array( |
47 | 47 | 'data-allowclear' => 'true', |
48 | 48 | ) |
49 | - ) ); |
|
49 | + )); |
|
50 | 50 | |
51 | - $position = get_post_meta( $post->ID, '_simcal_attach_calendar_position', true ); |
|
51 | + $position = get_post_meta($post->ID, '_simcal_attach_calendar_position', true); |
|
52 | 52 | |
53 | - simcal_print_field( array( |
|
53 | + simcal_print_field(array( |
|
54 | 54 | 'type' => 'radio', |
55 | 55 | 'id' => '_simcal_attach_calendar_position', |
56 | 56 | 'name' => '_simcal_attach_calendar_position', |
57 | 57 | 'value' => $position ? $position : 'after', |
58 | 58 | 'options' => array( |
59 | - 'after' => __( 'After Content', 'google-calendar-events' ), |
|
60 | - 'before' => __( 'Before Content', 'google-calendar-events' ), |
|
59 | + 'after' => __('After Content', 'google-calendar-events'), |
|
60 | + 'before' => __('Before Content', 'google-calendar-events'), |
|
61 | 61 | ), |
62 | - ) ); |
|
62 | + )); |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | * @param int $post_id |
72 | 72 | * @param \WP_Post $post |
73 | 73 | */ |
74 | - public static function save( $post_id, $post ) { |
|
74 | + public static function save($post_id, $post) { |
|
75 | 75 | |
76 | - $id = isset( $_POST['_simcal_attach_calendar_id'] ) ? absint( $_POST['_simcal_attach_calendar_id'] ) : ''; |
|
77 | - update_post_meta( $post_id, '_simcal_attach_calendar_id', $id ); |
|
76 | + $id = isset($_POST['_simcal_attach_calendar_id']) ? absint($_POST['_simcal_attach_calendar_id']) : ''; |
|
77 | + update_post_meta($post_id, '_simcal_attach_calendar_id', $id); |
|
78 | 78 | |
79 | - $position = isset( $_POST['_simcal_attach_calendar_position'] ) ? sanitize_title( $_POST['_simcal_attach_calendar_position'] ) : 'after'; |
|
80 | - update_post_meta( $post_id, '_simcal_attach_calendar_position', $position ); |
|
79 | + $position = isset($_POST['_simcal_attach_calendar_position']) ? sanitize_title($_POST['_simcal_attach_calendar_position']) : 'after'; |
|
80 | + update_post_meta($post_id, '_simcal_attach_calendar_position', $position); |
|
81 | 81 | |
82 | 82 | } |
83 | 83 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Calendar_View; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function __construct() { |
62 | 62 | |
63 | - $this->min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG == true ) ? '' : '.min'; |
|
63 | + $this->min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG == true) ? '' : '.min'; |
|
64 | 64 | |
65 | - $settings = get_option( 'simple-calendar_settings_advanced' ); |
|
65 | + $settings = get_option('simple-calendar_settings_advanced'); |
|
66 | 66 | |
67 | - if ( isset( $settings['assets']['disable_css'] ) ) { |
|
67 | + if (isset($settings['assets']['disable_css'])) { |
|
68 | 68 | $this->disable_styles = 'yes' == $settings['assets']['disable_css'] ? true : false; |
69 | 69 | } |
70 | 70 | |
71 | - add_action( 'init', array( $this, 'register' ), 20 ); |
|
72 | - add_action( 'init', array( $this, 'enqueue' ), 40 ); |
|
71 | + add_action('init', array($this, 'register'), 20); |
|
72 | + add_action('init', array($this, 'enqueue'), 40); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @since 3.0.0 |
79 | 79 | */ |
80 | 80 | public function register() { |
81 | - do_action( 'simcal_register_assets', $this->min ); |
|
81 | + do_action('simcal_register_assets', $this->min); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -88,25 +88,25 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function enqueue() { |
90 | 90 | |
91 | - add_action( 'wp_enqueue_scripts', array( $this, 'load' ), 10 ); |
|
91 | + add_action('wp_enqueue_scripts', array($this, 'load'), 10); |
|
92 | 92 | |
93 | - do_action( 'simcal_enqueue_assets', $this->min ); |
|
93 | + do_action('simcal_enqueue_assets', $this->min); |
|
94 | 94 | |
95 | 95 | |
96 | 96 | $min = $this->min; |
97 | 97 | // Improves compatibility with themes and plugins using Isotope and Masonry. |
98 | - add_action( 'wp_enqueue_scripts', |
|
99 | - function () use ( $min ) { |
|
100 | - if ( wp_script_is( 'simcal-qtip', 'enqueued' ) ) { |
|
98 | + add_action('wp_enqueue_scripts', |
|
99 | + function() use ($min) { |
|
100 | + if (wp_script_is('simcal-qtip', 'enqueued')) { |
|
101 | 101 | wp_enqueue_script( |
102 | 102 | 'simplecalendar-imagesloaded', |
103 | - SIMPLE_CALENDAR_ASSETS . 'js/vendor/imagesloaded.pkgd' . $min . '.js', |
|
104 | - array( 'simcal-qtip' ), |
|
103 | + SIMPLE_CALENDAR_ASSETS.'js/vendor/imagesloaded.pkgd'.$min.'.js', |
|
104 | + array('simcal-qtip'), |
|
105 | 105 | '3.1.8', |
106 | 106 | true |
107 | 107 | ); |
108 | 108 | } |
109 | - }, 1000 ); |
|
109 | + }, 1000); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -118,34 +118,34 @@ discard block |
||
118 | 118 | |
119 | 119 | $types = simcal_get_calendar_types(); |
120 | 120 | |
121 | - foreach ( $types as $calendar => $views ) { |
|
122 | - foreach( $views as $key => $view ) { |
|
121 | + foreach ($types as $calendar => $views) { |
|
122 | + foreach ($views as $key => $view) { |
|
123 | 123 | |
124 | - $view = simcal_get_calendar_view( 0, $calendar . '-' . $view ); |
|
124 | + $view = simcal_get_calendar_view(0, $calendar.'-'.$view); |
|
125 | 125 | |
126 | - $scripts[] = $view->scripts( $this->min ); |
|
127 | - $styles[] = $view->styles( $this->min ); |
|
126 | + $scripts[] = $view->scripts($this->min); |
|
127 | + $styles[] = $view->styles($this->min); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | 131 | $this->get_widgets_assets(); |
132 | - $this->scripts = apply_filters( 'simcal_front_end_scripts', $scripts, $this->min ); |
|
132 | + $this->scripts = apply_filters('simcal_front_end_scripts', $scripts, $this->min); |
|
133 | 133 | // First check if there is a multi-dimensional array of scripts |
134 | - if ( isset( $this->scripts[0] ) ) { |
|
135 | - foreach ( $this->scripts as $script ) { |
|
136 | - $this->load_scripts ( $script ); |
|
134 | + if (isset($this->scripts[0])) { |
|
135 | + foreach ($this->scripts as $script) { |
|
136 | + $this->load_scripts($script); |
|
137 | 137 | } |
138 | 138 | } else { |
139 | - $this->load_scripts( $this->scripts ); |
|
139 | + $this->load_scripts($this->scripts); |
|
140 | 140 | } |
141 | - $this->styles = apply_filters( 'simcal_front_end_styles', $styles, $this->min ); |
|
141 | + $this->styles = apply_filters('simcal_front_end_styles', $styles, $this->min); |
|
142 | 142 | // First check if there is a multi-dimensional array of styles |
143 | - if ( isset( $this->styles[0] ) ) { |
|
144 | - foreach( $this->styles as $style ) { |
|
145 | - $this->load_styles( $style ); |
|
143 | + if (isset($this->styles[0])) { |
|
144 | + foreach ($this->styles as $style) { |
|
145 | + $this->load_styles($style); |
|
146 | 146 | } |
147 | 147 | } else { |
148 | - $this->load_styles( $this->styles ); |
|
148 | + $this->load_styles($this->styles); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -156,25 +156,25 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function get_widgets_assets() { |
158 | 158 | |
159 | - $widgets = get_option( 'widget_gce_widget' ); |
|
159 | + $widgets = get_option('widget_gce_widget'); |
|
160 | 160 | |
161 | - if ( ! empty( $widgets ) && is_array( $widgets ) ) { |
|
161 | + if ( ! empty($widgets) && is_array($widgets)) { |
|
162 | 162 | |
163 | - foreach ( $widgets as $settings ) { |
|
163 | + foreach ($widgets as $settings) { |
|
164 | 164 | |
165 | - if ( ! empty( $settings ) && is_array( $settings ) ) { |
|
165 | + if ( ! empty($settings) && is_array($settings)) { |
|
166 | 166 | |
167 | - if ( isset( $settings['calendar_id'] ) ) { |
|
167 | + if (isset($settings['calendar_id'])) { |
|
168 | 168 | |
169 | - $view = simcal_get_calendar_view( absint( $settings['calendar_id'] ) ); |
|
169 | + $view = simcal_get_calendar_view(absint($settings['calendar_id'])); |
|
170 | 170 | |
171 | - if ( $view instanceof Calendar_View ) { |
|
172 | - add_filter( 'simcal_front_end_scripts', function ( $scripts, $min ) use ( $view ) { |
|
173 | - return array_merge( $scripts, $view->scripts( $min ) ); |
|
174 | - }, 100, 2 ); |
|
175 | - add_filter( 'simcal_front_end_styles', function ( $styles, $min ) use ( $view ) { |
|
176 | - return array_merge( $styles, $view->styles( $min ) ); |
|
177 | - }, 100, 2 ); |
|
171 | + if ($view instanceof Calendar_View) { |
|
172 | + add_filter('simcal_front_end_scripts', function($scripts, $min) use ($view) { |
|
173 | + return array_merge($scripts, $view->scripts($min)); |
|
174 | + }, 100, 2); |
|
175 | + add_filter('simcal_front_end_styles', function($styles, $min) use ($view) { |
|
176 | + return array_merge($styles, $view->styles($min)); |
|
177 | + }, 100, 2); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | } |
@@ -192,31 +192,31 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @param array $scripts |
194 | 194 | */ |
195 | - public function load_scripts( $scripts ) { |
|
195 | + public function load_scripts($scripts) { |
|
196 | 196 | |
197 | 197 | // Only load if not disabled in the settings |
198 | - if ( ! empty( $scripts ) && is_array( $scripts ) ) { |
|
198 | + if ( ! empty($scripts) && is_array($scripts)) { |
|
199 | 199 | |
200 | - foreach ( $scripts as $script => $v ) { |
|
200 | + foreach ($scripts as $script => $v) { |
|
201 | 201 | |
202 | - if ( ! empty( $v['src'] ) ) { |
|
202 | + if ( ! empty($v['src'])) { |
|
203 | 203 | |
204 | - $src = esc_url( $v['src'] ); |
|
205 | - $deps = isset( $v['deps'] ) ? $v['deps'] : array(); |
|
206 | - $ver = isset( $v['ver'] ) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
207 | - $in_footer = isset( $v['in_footer'] ) ? $v['in_footer'] : false; |
|
204 | + $src = esc_url($v['src']); |
|
205 | + $deps = isset($v['deps']) ? $v['deps'] : array(); |
|
206 | + $ver = isset($v['ver']) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
207 | + $in_footer = isset($v['in_footer']) ? $v['in_footer'] : false; |
|
208 | 208 | |
209 | - wp_enqueue_script( $script, $src, $deps, $ver, $in_footer ); |
|
209 | + wp_enqueue_script($script, $src, $deps, $ver, $in_footer); |
|
210 | 210 | |
211 | - if ( ! empty( $v['localize'] ) && is_array( $v['localize'] ) ) { |
|
212 | - foreach ( $v['localize'] as $object => $l10n ) { |
|
213 | - wp_localize_script( $script, $object, $l10n ); |
|
211 | + if ( ! empty($v['localize']) && is_array($v['localize'])) { |
|
212 | + foreach ($v['localize'] as $object => $l10n) { |
|
213 | + wp_localize_script($script, $object, $l10n); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | - } elseif ( is_string( $v ) && ! empty( $v ) ) { |
|
217 | + } elseif (is_string($v) && ! empty($v)) { |
|
218 | 218 | |
219 | - wp_enqueue_script( $v ); |
|
219 | + wp_enqueue_script($v); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
@@ -230,25 +230,25 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @param array $styles |
232 | 232 | */ |
233 | - public function load_styles( $styles ) { |
|
233 | + public function load_styles($styles) { |
|
234 | 234 | |
235 | 235 | // Only load if not disabled in the settings |
236 | - if ( ! empty( $styles ) && is_array( $styles ) && false === $this->disable_styles ) { |
|
236 | + if ( ! empty($styles) && is_array($styles) && false === $this->disable_styles) { |
|
237 | 237 | |
238 | - foreach ( $styles as $style => $v ) { |
|
238 | + foreach ($styles as $style => $v) { |
|
239 | 239 | |
240 | - if ( ! empty( $v['src'] ) ) { |
|
240 | + if ( ! empty($v['src'])) { |
|
241 | 241 | |
242 | - $src = esc_url( $v['src'] ); |
|
243 | - $deps = isset( $v['deps'] ) ? $v['deps'] : array(); |
|
244 | - $ver = isset( $v['ver'] ) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
245 | - $media = isset( $v['media'] ) ? $v['media'] : 'all'; |
|
242 | + $src = esc_url($v['src']); |
|
243 | + $deps = isset($v['deps']) ? $v['deps'] : array(); |
|
244 | + $ver = isset($v['ver']) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
245 | + $media = isset($v['media']) ? $v['media'] : 'all'; |
|
246 | 246 | |
247 | - wp_enqueue_style( $style, $src, $deps, $ver, $media ); |
|
247 | + wp_enqueue_style($style, $src, $deps, $ver, $media); |
|
248 | 248 | |
249 | - } elseif ( is_string( $v ) && ! empty( $v ) ) { |
|
249 | + } elseif (is_string($v) && ! empty($v)) { |
|
250 | 250 | |
251 | - wp_enqueue_style( $v ); |
|
251 | + wp_enqueue_style($v); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use Carbon\Carbon; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -239,35 +239,35 @@ discard block |
||
239 | 239 | * |
240 | 240 | * @param array $event |
241 | 241 | */ |
242 | - public function __construct( array $event ) { |
|
242 | + public function __construct(array $event) { |
|
243 | 243 | |
244 | 244 | /* ================= * |
245 | 245 | * Event Identifiers * |
246 | 246 | * ================= */ |
247 | 247 | |
248 | 248 | // Event unique id. |
249 | - if ( ! empty( $event['uid'] ) ) { |
|
250 | - $this->uid = esc_attr( $event['uid'] ); |
|
249 | + if ( ! empty($event['uid'])) { |
|
250 | + $this->uid = esc_attr($event['uid']); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | // iCal ID |
254 | - if ( ! empty( $event['ical_id'] ) ) { |
|
255 | - $this->ical_id = esc_attr( $event['ical_id'] ); |
|
254 | + if ( ! empty($event['ical_id'])) { |
|
255 | + $this->ical_id = esc_attr($event['ical_id']); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | // Event source. |
259 | - if ( ! empty( $event['source'] ) ) { |
|
260 | - $this->source = esc_attr( $event['source'] ); |
|
259 | + if ( ! empty($event['source'])) { |
|
260 | + $this->source = esc_attr($event['source']); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | // Event parent calendar id. |
264 | - if ( ! empty( $event['calendar'] ) ) { |
|
265 | - $this->calendar = max( intval( $event['calendar'] ), 0 ); |
|
264 | + if ( ! empty($event['calendar'])) { |
|
265 | + $this->calendar = max(intval($event['calendar']), 0); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | // Event parent calendar timezone. |
269 | - if ( ! empty( $event['timezone'] ) ) { |
|
270 | - $this->timezone = esc_attr( $event['timezone'] ); |
|
269 | + if ( ! empty($event['timezone'])) { |
|
270 | + $this->timezone = esc_attr($event['timezone']); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /* ============= * |
@@ -275,23 +275,23 @@ discard block |
||
275 | 275 | * ============= */ |
276 | 276 | |
277 | 277 | // Event title. |
278 | - if ( ! empty( $event['title'] ) ) { |
|
279 | - $this->title = esc_html( $event['title'] ); |
|
278 | + if ( ! empty($event['title'])) { |
|
279 | + $this->title = esc_html($event['title']); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | // Event description. |
283 | - if ( ! empty( $event['description'] ) ) { |
|
284 | - $this->description = wp_kses_post( $event['description'] ); |
|
283 | + if ( ! empty($event['description'])) { |
|
284 | + $this->description = wp_kses_post($event['description']); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | // Event link URL. |
288 | - if ( ! empty( $event['link'] ) ) { |
|
289 | - $this->link = esc_url_raw( $event['link'] ); |
|
288 | + if ( ! empty($event['link'])) { |
|
289 | + $this->link = esc_url_raw($event['link']); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | // Event visibility. |
293 | - if ( ! empty( $event['visibility'] ) ) { |
|
294 | - $this->visibility = esc_attr( $event['visibility'] ); |
|
293 | + if ( ! empty($event['visibility'])) { |
|
294 | + $this->visibility = esc_attr($event['visibility']); |
|
295 | 295 | $this->public = $this->visibility == 'public' ? true : false; |
296 | 296 | } |
297 | 297 | |
@@ -299,34 +299,34 @@ discard block |
||
299 | 299 | * Event Start * |
300 | 300 | * =========== */ |
301 | 301 | |
302 | - if ( ! empty( $event['start'] ) ) { |
|
303 | - $this->start = is_numeric( $event['start'] ) ? intval( $event['start'] ) : 0; |
|
304 | - if ( ! empty( $event['start_utc'] ) ) { |
|
305 | - $this->start_utc = is_numeric( $event['start_utc'] ) ? intval( $event['start_utc'] ) : 0; |
|
302 | + if ( ! empty($event['start'])) { |
|
303 | + $this->start = is_numeric($event['start']) ? intval($event['start']) : 0; |
|
304 | + if ( ! empty($event['start_utc'])) { |
|
305 | + $this->start_utc = is_numeric($event['start_utc']) ? intval($event['start_utc']) : 0; |
|
306 | 306 | } |
307 | - if ( ! empty( $event['start_timezone'] ) ) { |
|
308 | - $this->start_timezone = esc_attr( $event['start_timezone'] ); |
|
307 | + if ( ! empty($event['start_timezone'])) { |
|
308 | + $this->start_timezone = esc_attr($event['start_timezone']); |
|
309 | 309 | } |
310 | - $this->start_dt = Carbon::createFromTimestamp( $this->start, $this->start_timezone ); |
|
311 | - $start_location = isset( $event['start_location'] ) ? $event['start_location'] : ''; |
|
312 | - $this->start_location = $this->esc_location( $start_location ); |
|
310 | + $this->start_dt = Carbon::createFromTimestamp($this->start, $this->start_timezone); |
|
311 | + $start_location = isset($event['start_location']) ? $event['start_location'] : ''; |
|
312 | + $this->start_location = $this->esc_location($start_location); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /* ========= * |
316 | 316 | * Event End * |
317 | 317 | * ========= */ |
318 | 318 | |
319 | - if ( ! empty( $event['end'] ) ) { |
|
320 | - $this->end = is_numeric( $event['end'] ) ? intval( $event['end'] ): false; |
|
321 | - if ( ! empty( $event['end_timezone'] ) ) { |
|
322 | - $this->end_timezone = esc_attr( $event['end_timezone'] ); |
|
319 | + if ( ! empty($event['end'])) { |
|
320 | + $this->end = is_numeric($event['end']) ? intval($event['end']) : false; |
|
321 | + if ( ! empty($event['end_timezone'])) { |
|
322 | + $this->end_timezone = esc_attr($event['end_timezone']); |
|
323 | 323 | } |
324 | - if ( ! empty( $event['end_utc'] ) ) { |
|
325 | - $this->end_utc = is_numeric( $event['end_utc'] ) ? intval( $event['end_utc'] ) : false; |
|
326 | - $this->end_dt = Carbon::createFromTimestamp( $this->end, $this->end_timezone ); |
|
324 | + if ( ! empty($event['end_utc'])) { |
|
325 | + $this->end_utc = is_numeric($event['end_utc']) ? intval($event['end_utc']) : false; |
|
326 | + $this->end_dt = Carbon::createFromTimestamp($this->end, $this->end_timezone); |
|
327 | 327 | } |
328 | - $end_location = isset( $event['end_location'] ) ? $event['end_location'] : ''; |
|
329 | - $this->end_location = $this->esc_location( $end_location ); |
|
328 | + $end_location = isset($event['end_location']) ? $event['end_location'] : ''; |
|
329 | + $this->end_location = $this->esc_location($end_location); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /* ================== * |
@@ -334,18 +334,18 @@ discard block |
||
334 | 334 | * ================== */ |
335 | 335 | |
336 | 336 | // Whole day event. |
337 | - if ( ! empty( $event['whole_day'] ) ) { |
|
338 | - $this->whole_day = true === $event['whole_day'] ? true: false; |
|
337 | + if ( ! empty($event['whole_day'])) { |
|
338 | + $this->whole_day = true === $event['whole_day'] ? true : false; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | // Multi day event. |
342 | - if ( ! empty( $event['multiple_days'] ) ) { |
|
343 | - $this->multiple_days = max( absint( $event['multiple_days'] ), 1 ); |
|
342 | + if ( ! empty($event['multiple_days'])) { |
|
343 | + $this->multiple_days = max(absint($event['multiple_days']), 1); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | // Event recurrence. |
347 | - if ( isset( $event['recurrence'] ) ) { |
|
348 | - $this->recurrence = ! empty( $event['recurrence'] ) ? $event['recurrence'] : false; |
|
347 | + if (isset($event['recurrence'])) { |
|
348 | + $this->recurrence = ! empty($event['recurrence']) ? $event['recurrence'] : false; |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | /* ========== * |
@@ -353,18 +353,18 @@ discard block |
||
353 | 353 | * ========== */ |
354 | 354 | |
355 | 355 | // Event has venue(s). |
356 | - if ( $this->start_location['venue'] || $this->end_location['venue'] ) { |
|
356 | + if ($this->start_location['venue'] || $this->end_location['venue']) { |
|
357 | 357 | $this->venue = true; |
358 | 358 | } |
359 | 359 | |
360 | 360 | // Event meta. |
361 | - if ( ! empty( $event['meta'] ) ) { |
|
362 | - $this->meta = is_array( $event['meta'] ) ? $event['meta'] : array(); |
|
361 | + if ( ! empty($event['meta'])) { |
|
362 | + $this->meta = is_array($event['meta']) ? $event['meta'] : array(); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | // Event template. |
366 | - if ( ! empty( $event['template'] ) ) { |
|
367 | - $this->template = wp_kses_post( $event['template'] ); |
|
366 | + if ( ! empty($event['template'])) { |
|
367 | + $this->template = wp_kses_post($event['template']); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | } |
@@ -379,27 +379,27 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @return array |
381 | 381 | */ |
382 | - private function esc_location( $var = '' ) { |
|
382 | + private function esc_location($var = '') { |
|
383 | 383 | |
384 | 384 | $location = array(); |
385 | 385 | |
386 | - if ( is_string( $var ) ) { |
|
386 | + if (is_string($var)) { |
|
387 | 387 | $var = array( |
388 | 388 | 'name' => $var, |
389 | 389 | 'address' => $var, |
390 | 390 | ); |
391 | - } elseif ( is_bool( $var ) || is_null( $var ) ) { |
|
391 | + } elseif (is_bool($var) || is_null($var)) { |
|
392 | 392 | $var = array(); |
393 | 393 | } else { |
394 | 394 | $var = (array) $var; |
395 | 395 | } |
396 | 396 | |
397 | - $location['name'] = isset( $var['name'] ) ? esc_attr( strip_tags( $var['name'] ) ) : ''; |
|
398 | - $location['address'] = isset( $var['address'] ) ? esc_attr( strip_tags( $var['address'] ) ) : ''; |
|
399 | - $location['lat'] = isset( $var['lat'] ) ? $this->esc_coordinate( $var['lat'] ) : 0; |
|
400 | - $location['lng'] = isset( $var['lng'] ) ? $this->esc_coordinate( $var['lng'] ) : 0; |
|
397 | + $location['name'] = isset($var['name']) ? esc_attr(strip_tags($var['name'])) : ''; |
|
398 | + $location['address'] = isset($var['address']) ? esc_attr(strip_tags($var['address'])) : ''; |
|
399 | + $location['lat'] = isset($var['lat']) ? $this->esc_coordinate($var['lat']) : 0; |
|
400 | + $location['lng'] = isset($var['lng']) ? $this->esc_coordinate($var['lng']) : 0; |
|
401 | 401 | |
402 | - if ( ! empty( $location['name'] ) || ! empty( $location['address'] ) ) { |
|
402 | + if ( ! empty($location['name']) || ! empty($location['address'])) { |
|
403 | 403 | $location['venue'] = true; |
404 | 404 | } else { |
405 | 405 | $location['venue'] = false; |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @return int|float |
420 | 420 | */ |
421 | - private function esc_coordinate( $latlng = 0 ) { |
|
422 | - return is_numeric( $latlng ) ? floatval( $latlng ) : 0; |
|
421 | + private function esc_coordinate($latlng = 0) { |
|
422 | + return is_numeric($latlng) ? floatval($latlng) : 0; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -432,8 +432,8 @@ discard block |
||
432 | 432 | * |
433 | 433 | * @return bool |
434 | 434 | */ |
435 | - public function set_timezone( $tz ) { |
|
436 | - if ( in_array( $tz, timezone_identifiers_list() ) ) { |
|
435 | + public function set_timezone($tz) { |
|
436 | + if (in_array($tz, timezone_identifiers_list())) { |
|
437 | 437 | $this->timezone = $tz; |
438 | 438 | return true; |
439 | 439 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | * @return bool |
460 | 460 | */ |
461 | 461 | public function starts_today() { |
462 | - return $this->start_dt->setTimezone( $this->timezone )->isToday(); |
|
462 | + return $this->start_dt->setTimezone($this->timezone)->isToday(); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | /** |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * @return bool |
471 | 471 | */ |
472 | 472 | public function ends_today() { |
473 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isToday() : true; |
|
473 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isToday() : true; |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | * @return bool |
482 | 482 | */ |
483 | 483 | public function starts_tomorrow() { |
484 | - return $this->start_dt->setTimezone( $this->timezone )->isTomorrow(); |
|
484 | + return $this->start_dt->setTimezone($this->timezone)->isTomorrow(); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | * @return bool |
493 | 493 | */ |
494 | 494 | public function ends_tomorrow() { |
495 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isTomorrow() : false; |
|
495 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isTomorrow() : false; |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | * @return bool |
504 | 504 | */ |
505 | 505 | public function started_yesterday() { |
506 | - return $this->start_dt->setTimezone( $this->timezone )->isYesterday(); |
|
506 | + return $this->start_dt->setTimezone($this->timezone)->isYesterday(); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | /** |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | * @return bool |
515 | 515 | */ |
516 | 516 | public function ended_yesterday() { |
517 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isYesterday() : false; |
|
517 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isYesterday() : false; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | * @return bool |
526 | 526 | */ |
527 | 527 | public function starts_future() { |
528 | - return $this->start_dt->setTimezone( $this->timezone )->isFuture(); |
|
528 | + return $this->start_dt->setTimezone($this->timezone)->isFuture(); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | * @return bool |
537 | 537 | */ |
538 | 538 | public function ends_future() { |
539 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isFuture() : false; |
|
539 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isFuture() : false; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | * @return bool |
548 | 548 | */ |
549 | 549 | public function started_past() { |
550 | - return $this->start_dt->setTimezone( $this->timezone )->isPast(); |
|
550 | + return $this->start_dt->setTimezone($this->timezone)->isPast(); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | * @return bool |
559 | 559 | */ |
560 | 560 | public function ended_past() { |
561 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isPast() : false; |
|
561 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isPast() : false; |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | /** |
@@ -570,9 +570,9 @@ discard block |
||
570 | 570 | * |
571 | 571 | * @return string |
572 | 572 | */ |
573 | - public function get_color( $default = '' ) { |
|
574 | - if ( isset( $this->meta['color'] ) ) { |
|
575 | - return ! empty( $this->meta['color'] ) ? esc_attr( $this->meta['color'] ) : $default; |
|
573 | + public function get_color($default = '') { |
|
574 | + if (isset($this->meta['color'])) { |
|
575 | + return ! empty($this->meta['color']) ? esc_attr($this->meta['color']) : $default; |
|
576 | 576 | } |
577 | 577 | return $default; |
578 | 578 | } |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | * @return array |
586 | 586 | */ |
587 | 587 | public function get_attachments() { |
588 | - return isset( $this->meta['attachments'] ) ? $this->meta['attachments'] : array(); |
|
588 | + return isset($this->meta['attachments']) ? $this->meta['attachments'] : array(); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * @return array |
597 | 597 | */ |
598 | 598 | public function get_attendees() { |
599 | - return isset( $this->meta['attendees'] ) ? $this->meta['attendees'] : array(); |
|
599 | + return isset($this->meta['attendees']) ? $this->meta['attendees'] : array(); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | /** |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | * @return array |
608 | 608 | */ |
609 | 609 | public function get_organizer() { |
610 | - return isset( $this->meta['organizer'] ) ? $this->meta['organizer'] : array(); |
|
610 | + return isset($this->meta['organizer']) ? $this->meta['organizer'] : array(); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @package SimpleCalendar/Admin/Functions |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if ( ! defined('ABSPATH')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return null|\SimpleCalendar\Abstracts\Admin_Page |
34 | 34 | */ |
35 | -function simcal_get_admin_page( $page ) { |
|
35 | +function simcal_get_admin_page($page) { |
|
36 | 36 | $objects = \SimpleCalendar\plugin()->objects; |
37 | - return $objects instanceof \SimpleCalendar\Objects ? $objects->get_admin_page( $page ) : null; |
|
37 | + return $objects instanceof \SimpleCalendar\Objects ? $objects->get_admin_page($page) : null; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @return null|\SimpleCalendar\Abstracts\Field |
49 | 49 | */ |
50 | -function simcal_get_field( $args, $name = '' ) { |
|
50 | +function simcal_get_field($args, $name = '') { |
|
51 | 51 | $objects = \SimpleCalendar\plugin()->objects; |
52 | - return $objects instanceof \SimpleCalendar\Objects ? $objects->get_field( $args, $name ) : null; |
|
52 | + return $objects instanceof \SimpleCalendar\Objects ? $objects->get_field($args, $name) : null; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return void |
64 | 64 | */ |
65 | -function simcal_print_field( $args, $name = '' ) { |
|
65 | +function simcal_print_field($args, $name = '') { |
|
66 | 66 | |
67 | - $field = simcal_get_field( $args, $name ); |
|
67 | + $field = simcal_get_field($args, $name); |
|
68 | 68 | |
69 | - if ( $field instanceof \SimpleCalendar\Abstracts\Field ) { |
|
69 | + if ($field instanceof \SimpleCalendar\Abstracts\Field) { |
|
70 | 70 | $field->html(); |
71 | 71 | } |
72 | 72 | } |
@@ -84,33 +84,33 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return array|string Sanitized variable |
86 | 86 | */ |
87 | -function simcal_sanitize_input( $var, $func = 'sanitize_text_field' ) { |
|
87 | +function simcal_sanitize_input($var, $func = 'sanitize_text_field') { |
|
88 | 88 | |
89 | - if ( is_null( $var ) ) { |
|
89 | + if (is_null($var)) { |
|
90 | 90 | return ''; |
91 | 91 | } |
92 | 92 | |
93 | - if ( is_bool( $var ) ) { |
|
94 | - if ( $var === true ) { |
|
93 | + if (is_bool($var)) { |
|
94 | + if ($var === true) { |
|
95 | 95 | return 'yes'; |
96 | 96 | } else { |
97 | 97 | return 'no'; |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - if ( is_string( $var ) || is_numeric( $var ) ) { |
|
102 | - $func = is_string( $func ) && function_exists( $func ) ? $func : 'sanitize_text_field'; |
|
103 | - return call_user_func( $func, trim( strval( $var ) ) ); |
|
101 | + if (is_string($var) || is_numeric($var)) { |
|
102 | + $func = is_string($func) && function_exists($func) ? $func : 'sanitize_text_field'; |
|
103 | + return call_user_func($func, trim(strval($var))); |
|
104 | 104 | } |
105 | 105 | |
106 | - if ( is_object( $var ) ) { |
|
106 | + if (is_object($var)) { |
|
107 | 107 | $var = (array) $var; |
108 | 108 | } |
109 | 109 | |
110 | - if ( is_array( $var ) ) { |
|
110 | + if (is_array($var)) { |
|
111 | 111 | $array = array(); |
112 | - foreach ( $var as $k => $v ) { |
|
113 | - $array[ $k ] = simcal_sanitize_input( $v ); |
|
112 | + foreach ($var as $k => $v) { |
|
113 | + $array[$k] = simcal_sanitize_input($v); |
|
114 | 114 | } |
115 | 115 | return $array; |
116 | 116 | } |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | */ |
129 | 129 | function simcal_is_admin_screen() { |
130 | 130 | |
131 | - $view = function_exists( 'get_current_screen' ) ? get_current_screen() : false; |
|
131 | + $view = function_exists('get_current_screen') ? get_current_screen() : false; |
|
132 | 132 | |
133 | - if ( $view instanceof WP_Screen ) { |
|
133 | + if ($view instanceof WP_Screen) { |
|
134 | 134 | |
135 | 135 | // Screens used by this plugin. |
136 | 136 | $screens = array( |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'dashboard_page_simple-calendar_credits', |
146 | 146 | 'dashboard_page_simple-calendar_translators', |
147 | 147 | ); |
148 | - if ( in_array( $view->id, $screens ) ) { |
|
148 | + if (in_array($view->id, $screens)) { |
|
149 | 149 | return $view->id; |
150 | 150 | } |
151 | 151 | } |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return \SimpleCalendar\Admin\Updater |
166 | 166 | */ |
167 | -function simcal_addon_updater( $_api_url, $_plugin_file, $_api_data = null ) { |
|
168 | - return new \SimpleCalendar\Admin\Updater( $_api_url, $_plugin_file, $_api_data ); |
|
167 | +function simcal_addon_updater($_api_url, $_plugin_file, $_api_data = null) { |
|
168 | + return new \SimpleCalendar\Admin\Updater($_api_url, $_plugin_file, $_api_data); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return null|string |
179 | 179 | */ |
180 | -function simcal_get_license_key( $addon ) { |
|
181 | - $licenses = get_option( 'simple-calendar_settings_licenses', array() ); |
|
182 | - if ( isset( $licenses['keys'][ $addon ] ) ) { |
|
183 | - return empty( $licenses['keys'][ $addon ] ) ? null : $licenses['keys'][ $addon ]; |
|
180 | +function simcal_get_license_key($addon) { |
|
181 | + $licenses = get_option('simple-calendar_settings_licenses', array()); |
|
182 | + if (isset($licenses['keys'][$addon])) { |
|
183 | + return empty($licenses['keys'][$addon]) ? null : $licenses['keys'][$addon]; |
|
184 | 184 | } |
185 | 185 | return null; |
186 | 186 | } |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return array|string |
198 | 198 | */ |
199 | -function simcal_get_license_status( $addon = null ) { |
|
200 | - $licenses = get_option( 'simple-calendar_licenses_status', array() ); |
|
201 | - return isset( $licenses[ $addon ] ) ? $licenses[ $addon ] : $licenses; |
|
199 | +function simcal_get_license_status($addon = null) { |
|
200 | + $licenses = get_option('simple-calendar_licenses_status', array()); |
|
201 | + return isset($licenses[$addon]) ? $licenses[$addon] : $licenses; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @since 3.0.0 |
220 | 220 | */ |
221 | 221 | function simcal_delete_admin_notices() { |
222 | - delete_option( 'simple-calendar_admin_notices' ); |
|
222 | + delete_option('simple-calendar_admin_notices'); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -231,22 +231,22 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return void |
233 | 233 | */ |
234 | -function simcal_print_shortcode_tip( $post_id ) { |
|
234 | +function simcal_print_shortcode_tip($post_id) { |
|
235 | 235 | |
236 | 236 | $browser = new \SimpleCalendar\Browser(); |
237 | - if ( $browser::PLATFORM_APPLE == $browser->getPlatform() ) { |
|
237 | + if ($browser::PLATFORM_APPLE == $browser->getPlatform()) { |
|
238 | 238 | $cmd = '⌘+C'; |
239 | 239 | } else { |
240 | 240 | $cmd = 'Ctrl+C'; |
241 | 241 | } |
242 | 242 | |
243 | - $shortcut = sprintf( __( 'Press %s to copy.', 'google-calendar-events' ), $cmd ); |
|
244 | - $shortcode = sprintf( '[calendar id="%s"]', $post_id ); |
|
243 | + $shortcut = sprintf(__('Press %s to copy.', 'google-calendar-events'), $cmd); |
|
244 | + $shortcode = sprintf('[calendar id="%s"]', $post_id); |
|
245 | 245 | |
246 | - echo "<input readonly='readonly' " . |
|
247 | - "class='simcal-shortcode simcal-calendar-shortcode simcal-shortcode-tip' " . |
|
248 | - "title='" . $shortcut . "' " . |
|
249 | - "onclick='this.select();' value='" . $shortcode . "' />"; |
|
246 | + echo "<input readonly='readonly' ". |
|
247 | + "class='simcal-shortcode simcal-calendar-shortcode simcal-shortcode-tip' ". |
|
248 | + "title='".$shortcut."' ". |
|
249 | + "onclick='this.select();' value='".$shortcode."' />"; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -261,20 +261,20 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return string $url Full Google Analytics campaign URL |
263 | 263 | */ |
264 | -function simcal_ga_campaign_url( $base_url, $campaign, $content, $raw = false ) { |
|
264 | +function simcal_ga_campaign_url($base_url, $campaign, $content, $raw = false) { |
|
265 | 265 | |
266 | - $url = add_query_arg( array( |
|
266 | + $url = add_query_arg(array( |
|
267 | 267 | 'utm_source' => 'inside-plugin', |
268 | 268 | 'utm_medium' => 'link', |
269 | 269 | 'utm_campaign' => $campaign, // i.e. 'core-plugin', 'gcal-pro' |
270 | 270 | 'utm_content' => $content // i.e. 'sidebar-link', 'settings-link' |
271 | - ), $base_url ); |
|
271 | + ), $base_url); |
|
272 | 272 | |
273 | - if ( $raw ) { |
|
274 | - return esc_url_raw( $url ); |
|
273 | + if ($raw) { |
|
274 | + return esc_url_raw($url); |
|
275 | 275 | } |
276 | 276 | |
277 | - return esc_url( $url ); |
|
277 | + return esc_url($url); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | function simcal_newsletter_signup() { |
288 | 288 | |
289 | - if ( $screen = simcal_is_admin_screen() ) { |
|
289 | + if ($screen = simcal_is_admin_screen()) { |
|
290 | 290 | |
291 | 291 | global $current_user; |
292 | 292 | wp_get_current_user(); |
@@ -297,11 +297,11 @@ discard block |
||
297 | 297 | <div id="simcal-drip" class="<?php echo $screen; ?>"> |
298 | 298 | <div class="signup"> |
299 | 299 | <p> |
300 | - <?php _e( "Enter your name and email and we'll send you a coupon code for <strong>20% off</strong> all Pro Add-on purchases.", 'google-calendar-events' ); ?> |
|
300 | + <?php _e("Enter your name and email and we'll send you a coupon code for <strong>20% off</strong> all Pro Add-on purchases.", 'google-calendar-events'); ?> |
|
301 | 301 | </p> |
302 | 302 | |
303 | 303 | <p> |
304 | - <label for="simcal-drip-field-email"><?php _e( 'Your Email', 'google-calendar-events' ); ?></label><br /> |
|
304 | + <label for="simcal-drip-field-email"><?php _e('Your Email', 'google-calendar-events'); ?></label><br /> |
|
305 | 305 | <input type="email" |
306 | 306 | id="simcal-drip-field-email" |
307 | 307 | name="fields[email]" |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | </p> |
310 | 310 | |
311 | 311 | <p> |
312 | - <label for="simcal-drip-field-first_name"><?php _e( 'First Name', 'google-calendar-events' ); ?></label><br /> |
|
312 | + <label for="simcal-drip-field-first_name"><?php _e('First Name', 'google-calendar-events'); ?></label><br /> |
|
313 | 313 | <input type="text" |
314 | 314 | id="simcal-drip-field-first_name" |
315 | 315 | name="fields[first_name]" |
@@ -318,17 +318,17 @@ discard block |
||
318 | 318 | <p class="textright"> |
319 | 319 | <a href="#" |
320 | 320 | id="simcal-drip-signup" |
321 | - class="button button-primary"><?php _e( 'Send me the coupon', 'google-calendar-events' ); ?></a> |
|
321 | + class="button button-primary"><?php _e('Send me the coupon', 'google-calendar-events'); ?></a> |
|
322 | 322 | </p> |
323 | 323 | <div class="textright"> |
324 | - <em><?php _e( 'No spam. Unsubscribe anytime.', 'google-calendar-events' ); ?></em> |
|
324 | + <em><?php _e('No spam. Unsubscribe anytime.', 'google-calendar-events'); ?></em> |
|
325 | 325 | <br/> |
326 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'sidebar-link' ); ?>" |
|
327 | - target="_blank"><?php _e( 'Just take me the add-ons', 'google-calendar-events' ); ?></a> |
|
326 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'sidebar-link'); ?>" |
|
327 | + target="_blank"><?php _e('Just take me the add-ons', 'google-calendar-events'); ?></a> |
|
328 | 328 | </div> |
329 | 329 | </div> |
330 | 330 | <div class="thank-you" style="display: none;"> |
331 | - <?php _e( 'Thank you!', 'google-calendar-events' ); ?> |
|
331 | + <?php _e('Thank you!', 'google-calendar-events'); ?> |
|
332 | 332 | </div> |
333 | 333 | <div class="clear"> |
334 | 334 | </div> |