@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar\Abstracts; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return void |
38 | 38 | */ |
39 | - public function widget( $args, $instance ); |
|
39 | + public function widget($args, $instance); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Update a particular instance of the widget. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return array Settings to save or bool false to cancel saving. |
54 | 54 | */ |
55 | - public function update( $new_instance, $old_instance ); |
|
55 | + public function update($new_instance, $old_instance); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Print the settings update form. |
@@ -63,6 +63,6 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return string |
65 | 65 | */ |
66 | - public function form( $instance ); |
|
66 | + public function form($instance); |
|
67 | 67 | |
68 | 68 | } |
@@ -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'] ) ? sanitize_text_field( $_POST['value'] ) : ' '; |
|
75 | - $timestamp = isset( $_POST['timestamp'] ) ? absint( $_POST['timestamp'] ) : time(); |
|
74 | + $value = isset($_POST['value']) ? sanitize_text_field($_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,29 +123,29 @@ discard block |
||
123 | 123 | ); |
124 | 124 | |
125 | 125 | // Update license in db. |
126 | - $keys = get_option( 'simple-calendar_settings_licenses', array() ); |
|
127 | - $new_keys = array_merge( (array) $keys, array( 'keys' => array( $addon => $key ) ) ); |
|
128 | - update_option( 'simple-calendar_settings_licenses', $new_keys ); |
|
126 | + $keys = get_option('simple-calendar_settings_licenses', array()); |
|
127 | + $new_keys = array_merge((array) $keys, array('keys' => array($addon => $key))); |
|
128 | + update_option('simple-calendar_settings_licenses', $new_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 | - if ( 'deactivated' == $license_data->license ) { |
|
139 | - unset( $status[ $addon ] ); |
|
140 | - update_option( 'simple-calendar_licenses_status', $status ); |
|
141 | - wp_send_json_success( $license_data->license ); |
|
142 | - } elseif ( in_array( $license_data->license, array( 'valid', 'invalid' ) ) ) { |
|
143 | - $status[ $addon ] = $license_data->license; |
|
144 | - update_option( 'simple-calendar_licenses_status', $status ); |
|
145 | - $message = 'valid' == $license_data->license ? 'valid' : __( 'License key is invalid.', 'google-calendar-events' ); |
|
146 | - wp_send_json_success( $message ); |
|
138 | + if ('deactivated' == $license_data->license) { |
|
139 | + unset($status[$addon]); |
|
140 | + update_option('simple-calendar_licenses_status', $status); |
|
141 | + wp_send_json_success($license_data->license); |
|
142 | + } elseif (in_array($license_data->license, array('valid', 'invalid'))) { |
|
143 | + $status[$addon] = $license_data->license; |
|
144 | + update_option('simple-calendar_licenses_status', $status); |
|
145 | + $message = 'valid' == $license_data->license ? 'valid' : __('License key is invalid.', 'google-calendar-events'); |
|
146 | + wp_send_json_success($message); |
|
147 | 147 | } else { |
148 | - wp_send_json_error( '' ); |
|
148 | + wp_send_json_error(''); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function reset_licenses() { |
158 | 158 | |
159 | - $nonce = isset( $_POST['nonce'] ) ? esc_attr( $_POST['nonce'] ) : ''; |
|
159 | + $nonce = isset($_POST['nonce']) ? esc_attr($_POST['nonce']) : ''; |
|
160 | 160 | |
161 | 161 | // Verify this request comes from the add-ons licenses activation settings page. |
162 | - if ( empty ( $nonce ) || ! wp_verify_nonce( $nonce, 'simcal_license_manager' ) ) { |
|
163 | - wp_send_json_error( sprintf( __( 'An error occurred: %s', 'google-calendar-events' ), 'Nonce verification failed.' ) ); |
|
162 | + if (empty ($nonce) || ! wp_verify_nonce($nonce, 'simcal_license_manager')) { |
|
163 | + wp_send_json_error(sprintf(__('An error occurred: %s', 'google-calendar-events'), 'Nonce verification failed.')); |
|
164 | 164 | } |
165 | 165 | |
166 | - delete_option( 'simple-calendar_settings_licenses' ); |
|
167 | - delete_option( 'simple-calendar_licenses_status' ); |
|
166 | + delete_option('simple-calendar_settings_licenses'); |
|
167 | + delete_option('simple-calendar_licenses_status'); |
|
168 | 168 | |
169 | - wp_send_json_success( 'success' ); |
|
169 | + wp_send_json_success('success'); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar\Admin; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct() { |
36 | 36 | |
37 | - $this->min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG == true ) ? '' : '.min'; |
|
37 | + $this->min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG == true) ? '' : '.min'; |
|
38 | 38 | |
39 | - add_action( 'admin_enqueue_scripts', array( $this, 'load' ) ); |
|
39 | + add_action('admin_enqueue_scripts', array($this, 'load')); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function load() { |
48 | 48 | |
49 | - $css_path = SIMPLE_CALENDAR_ASSETS . 'css/'; |
|
50 | - $css_path_vendor = $css_path . 'vendor/'; |
|
51 | - $js_path = SIMPLE_CALENDAR_ASSETS . 'js/'; |
|
52 | - $js_path_vendor = $js_path . 'vendor/'; |
|
49 | + $css_path = SIMPLE_CALENDAR_ASSETS.'css/'; |
|
50 | + $css_path_vendor = $css_path.'vendor/'; |
|
51 | + $js_path = SIMPLE_CALENDAR_ASSETS.'js/'; |
|
52 | + $js_path_vendor = $js_path.'vendor/'; |
|
53 | 53 | |
54 | 54 | /* ====================== * |
55 | 55 | * Register Admin Scripts * |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | |
58 | 58 | wp_register_script( |
59 | 59 | 'simcal-tiptip', |
60 | - $js_path_vendor . 'tiptip' . $this->min . '.js', |
|
61 | - array( 'jquery' ), |
|
60 | + $js_path_vendor.'tiptip'.$this->min.'.js', |
|
61 | + array('jquery'), |
|
62 | 62 | '1.3', |
63 | 63 | true |
64 | 64 | ); |
65 | 65 | wp_register_script( |
66 | 66 | 'simcal-select2', |
67 | - $js_path_vendor . 'select2' . $this->min . '.js', |
|
67 | + $js_path_vendor.'select2'.$this->min.'.js', |
|
68 | 68 | array(), |
69 | 69 | '4.0', |
70 | 70 | true |
71 | 71 | ); |
72 | 72 | wp_register_script( |
73 | 73 | 'simcal-admin', |
74 | - $js_path . 'admin' . $this->min . '.js', |
|
74 | + $js_path.'admin'.$this->min.'.js', |
|
75 | 75 | array( |
76 | 76 | 'jquery', |
77 | 77 | 'jquery-ui-sortable', |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | ); |
86 | 86 | wp_register_script( |
87 | 87 | 'simcal-admin-add-calendar', |
88 | - $js_path . 'admin-add-calendar' . $this->min . '.js', |
|
89 | - array( 'simcal-select2' ), |
|
88 | + $js_path.'admin-add-calendar'.$this->min.'.js', |
|
89 | + array('simcal-select2'), |
|
90 | 90 | SIMPLE_CALENDAR_VERSION, |
91 | 91 | true |
92 | 92 | ); |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | |
98 | 98 | wp_register_style( |
99 | 99 | 'simcal-select2', |
100 | - $css_path_vendor . 'select2' . $this->min . '.css', |
|
100 | + $css_path_vendor.'select2'.$this->min.'.css', |
|
101 | 101 | array(), |
102 | 102 | '4.0.0' |
103 | 103 | ); |
104 | 104 | wp_register_style( |
105 | 105 | 'simcal-admin', |
106 | - $css_path . 'admin' . $this->min . '.css', |
|
106 | + $css_path.'admin'.$this->min.'.css', |
|
107 | 107 | array( |
108 | 108 | 'wp-color-picker', |
109 | 109 | 'simcal-select2', |
@@ -112,21 +112,21 @@ discard block |
||
112 | 112 | ); |
113 | 113 | wp_register_style( |
114 | 114 | 'simcal-admin-add-calendar', |
115 | - $css_path . 'admin-add-calendar' . $this->min . '.css', |
|
116 | - array( 'simcal-select2' ), |
|
115 | + $css_path.'admin-add-calendar'.$this->min.'.css', |
|
116 | + array('simcal-select2'), |
|
117 | 117 | SIMPLE_CALENDAR_VERSION |
118 | 118 | ); |
119 | 119 | |
120 | - if ( simcal_is_admin_screen() !== false ) { |
|
120 | + if (simcal_is_admin_screen() !== false) { |
|
121 | 121 | |
122 | - wp_enqueue_script( 'simcal-admin' ); |
|
122 | + wp_enqueue_script('simcal-admin'); |
|
123 | 123 | wp_localize_script( |
124 | 124 | 'simcal-admin', |
125 | 125 | 'simcal_admin', |
126 | 126 | simcal_common_scripts_variables() |
127 | 127 | ); |
128 | 128 | |
129 | - wp_enqueue_style( 'simcal-admin' ); |
|
129 | + wp_enqueue_style('simcal-admin'); |
|
130 | 130 | |
131 | 131 | } else { |
132 | 132 | |
@@ -134,25 +134,25 @@ discard block |
||
134 | 134 | $screen = get_current_screen(); |
135 | 135 | |
136 | 136 | $post_types = array(); |
137 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
138 | - if ( isset( $settings['general']['attach_calendars_posts'] ) ) { |
|
137 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
138 | + if (isset($settings['general']['attach_calendars_posts'])) { |
|
139 | 139 | $post_types = $settings['general']['attach_calendars_posts']; |
140 | 140 | } |
141 | 141 | |
142 | 142 | $conditions = array( |
143 | - in_array( $post_type, (array) $post_types ), |
|
143 | + in_array($post_type, (array) $post_types), |
|
144 | 144 | $screen->id == 'widgets', |
145 | 145 | ); |
146 | 146 | |
147 | - if ( in_array( true, $conditions ) ) { |
|
147 | + if (in_array(true, $conditions)) { |
|
148 | 148 | |
149 | - wp_enqueue_script( 'simcal-admin-add-calendar' ); |
|
150 | - wp_localize_script( 'simcal-admin-add-calendar', 'simcal_admin', array( |
|
149 | + wp_enqueue_script('simcal-admin-add-calendar'); |
|
150 | + wp_localize_script('simcal-admin-add-calendar', 'simcal_admin', array( |
|
151 | 151 | 'locale' => get_locale(), |
152 | 152 | 'text_dir' => is_rtl() ? 'rtl' : 'ltr', |
153 | - ) ); |
|
153 | + )); |
|
154 | 154 | |
155 | - wp_enqueue_style( 'simcal-admin-add-calendar' ); |
|
155 | + wp_enqueue_style('simcal-admin-add-calendar'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | */ |
10 | 10 | namespace SimpleCalendar\Admin; |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @param string $post_type |
43 | 43 | */ |
44 | - public function __construct( $post_type ) { |
|
45 | - $this->bulk_action_post_type = post_type_exists( $post_type ) ? $post_type : ''; |
|
44 | + public function __construct($post_type) { |
|
45 | + $this->bulk_action_post_type = post_type_exists($post_type) ? $post_type : ''; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -53,16 +53,16 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @param array $args |
55 | 55 | */ |
56 | - public function register_bulk_action( $args ) { |
|
56 | + public function register_bulk_action($args) { |
|
57 | 57 | |
58 | 58 | $func = array(); |
59 | - $func['action_name'] = isset( $args['action_name'] ) ? sanitize_key( $args['action_name'] ) : ''; |
|
60 | - $func['callback'] = isset( $args['callback'] ) ? $args['callback'] : ''; |
|
61 | - $func['menu_text'] = isset( $args['menu_text'] ) ? esc_attr( $args['menu_text'] ) : ''; |
|
62 | - $func['admin_notice'] = isset( $args['admin_notice'] ) ? esc_attr( $args['admin_notice'] ) : ''; |
|
59 | + $func['action_name'] = isset($args['action_name']) ? sanitize_key($args['action_name']) : ''; |
|
60 | + $func['callback'] = isset($args['callback']) ? $args['callback'] : ''; |
|
61 | + $func['menu_text'] = isset($args['menu_text']) ? esc_attr($args['menu_text']) : ''; |
|
62 | + $func['admin_notice'] = isset($args['admin_notice']) ? esc_attr($args['admin_notice']) : ''; |
|
63 | 63 | |
64 | - if ( $func['action_name'] && $func['callback'] ) { |
|
65 | - $this->actions[ $func['action_name'] ] = $func; |
|
64 | + if ($func['action_name'] && $func['callback']) { |
|
65 | + $this->actions[$func['action_name']] = $func; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | * @since 3.0.0 |
75 | 75 | */ |
76 | 76 | public function init() { |
77 | - if ( is_admin() ) { |
|
78 | - add_action( 'admin_footer-edit.php', array( $this, 'custom_bulk_admin_footer' ) ); |
|
79 | - add_action( 'load-edit.php', array( $this, 'custom_bulk_action' ) ); |
|
80 | - add_action( 'admin_notices', array( $this, 'custom_bulk_admin_notices' ) ); |
|
77 | + if (is_admin()) { |
|
78 | + add_action('admin_footer-edit.php', array($this, 'custom_bulk_admin_footer')); |
|
79 | + add_action('load-edit.php', array($this, 'custom_bulk_action')); |
|
80 | + add_action('admin_notices', array($this, 'custom_bulk_admin_notices')); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | global $post_type; |
92 | 92 | |
93 | 93 | // Only permit actions with defined post type. |
94 | - if ( $post_type == $this->bulk_action_post_type ) { |
|
94 | + if ($post_type == $this->bulk_action_post_type) { |
|
95 | 95 | |
96 | 96 | ?> |
97 | 97 | <script type="text/javascript"> |
98 | 98 | jQuery( document ).ready( function() { |
99 | - <?php foreach ( $this->actions as $action_name => $action ) : ?> |
|
99 | + <?php foreach ($this->actions as $action_name => $action) : ?> |
|
100 | 100 | jQuery( '<option>' ).val( '<?php echo $action_name ?>' ).text( '<?php echo $action['menu_text'] ?>').appendTo( 'select[name="action"]' ); |
101 | 101 | jQuery( '<option>' ).val( '<?php echo $action_name ?>' ).text( '<?php echo $action['menu_text'] ?>').appendTo( 'select[name="action2"]' ); |
102 | 102 | <?php endforeach; ?> |
@@ -120,65 +120,65 @@ discard block |
||
120 | 120 | global $typenow; |
121 | 121 | $post_type = $typenow; |
122 | 122 | |
123 | - if ( $post_type == $this->bulk_action_post_type ) { |
|
123 | + if ($post_type == $this->bulk_action_post_type) { |
|
124 | 124 | |
125 | 125 | // Get the action. |
126 | 126 | // Depending on your resource type this could be WP_Users_List_Table, WP_Comments_List_Table, etc. |
127 | - $wp_list_table = _get_list_table( 'WP_Posts_List_Table' ); |
|
127 | + $wp_list_table = _get_list_table('WP_Posts_List_Table'); |
|
128 | 128 | $action = $wp_list_table->current_action(); |
129 | 129 | |
130 | 130 | // Allow only defined actions. |
131 | - $allowed_actions = array_keys( $this->actions ); |
|
132 | - if ( ! in_array( $action, $allowed_actions ) ) { |
|
131 | + $allowed_actions = array_keys($this->actions); |
|
132 | + if ( ! in_array($action, $allowed_actions)) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Security check. |
137 | - check_admin_referer( 'bulk-posts' ); |
|
137 | + check_admin_referer('bulk-posts'); |
|
138 | 138 | |
139 | 139 | // Make sure ids are submitted. |
140 | 140 | // Depending on the resource type, this may be 'media' or 'ids'. |
141 | - if ( isset( $_REQUEST['post'] ) ) { |
|
142 | - $post_ids = array_map( 'intval', $_REQUEST['post'] ); |
|
141 | + if (isset($_REQUEST['post'])) { |
|
142 | + $post_ids = array_map('intval', $_REQUEST['post']); |
|
143 | 143 | } |
144 | 144 | |
145 | - if ( empty( $post_ids ) ) { |
|
145 | + if (empty($post_ids)) { |
|
146 | 146 | return; |
147 | 147 | } |
148 | 148 | |
149 | 149 | // This is based on wp-admin/edit.php. |
150 | 150 | $sendback = remove_query_arg( |
151 | - array( 'exported', 'untrashed', 'deleted', 'ids' ), |
|
151 | + array('exported', 'untrashed', 'deleted', 'ids'), |
|
152 | 152 | wp_get_referer() |
153 | 153 | ); |
154 | - if ( ! $sendback ) { |
|
155 | - $sendback = admin_url( "edit.php?post_type=$post_type" ); |
|
154 | + if ( ! $sendback) { |
|
155 | + $sendback = admin_url("edit.php?post_type=$post_type"); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | $pagenum = $wp_list_table->get_pagenum(); |
159 | - $sendback = add_query_arg( 'paged', $pagenum, $sendback ); |
|
159 | + $sendback = add_query_arg('paged', $pagenum, $sendback); |
|
160 | 160 | |
161 | 161 | // Check that we have anonymous function as a callback. |
162 | - $anon_fns = array_filter( $this->actions[ $action ], function( $el ) { |
|
162 | + $anon_fns = array_filter($this->actions[$action], function($el) { |
|
163 | 163 | return $el instanceof \Closure; |
164 | 164 | } ); |
165 | 165 | |
166 | - if ( count( $anon_fns ) > 0 ) { |
|
167 | - $this->actions[ $action ]['callback']( $post_ids ); |
|
166 | + if (count($anon_fns) > 0) { |
|
167 | + $this->actions[$action]['callback']($post_ids); |
|
168 | 168 | } else { |
169 | - call_user_func( $this->actions[ $action ]['callback'], $post_ids ); |
|
169 | + call_user_func($this->actions[$action]['callback'], $post_ids); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | $sendback = add_query_arg( |
173 | - array( 'success_action' => $action, 'ids' => join( ',', $post_ids ) ), |
|
173 | + array('success_action' => $action, 'ids' => join(',', $post_ids)), |
|
174 | 174 | $sendback |
175 | 175 | ); |
176 | 176 | $sendback = remove_query_arg( |
177 | - array( 'action', 'paged', 'mode', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view' ), |
|
177 | + array('action', 'paged', 'mode', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), |
|
178 | 178 | $sendback |
179 | 179 | ); |
180 | 180 | |
181 | - wp_redirect( $sendback ); |
|
181 | + wp_redirect($sendback); |
|
182 | 182 | |
183 | 183 | exit; |
184 | 184 | } |
@@ -193,31 +193,31 @@ discard block |
||
193 | 193 | |
194 | 194 | global $post_type, $pagenow; |
195 | 195 | |
196 | - if ( isset( $_REQUEST['ids'] ) ) { |
|
197 | - $post_ids = explode( ',', $_REQUEST['ids'] ); |
|
196 | + if (isset($_REQUEST['ids'])) { |
|
197 | + $post_ids = explode(',', $_REQUEST['ids']); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | // Make sure ids are submitted. |
201 | 201 | // Depending on the resource type, this may be 'media' or 'ids'. |
202 | - if ( empty( $post_ids ) ) { |
|
202 | + if (empty($post_ids)) { |
|
203 | 203 | return; |
204 | 204 | } |
205 | 205 | |
206 | - $post_ids_count = is_array( $post_ids ) ? count( $post_ids ) : 1; |
|
206 | + $post_ids_count = is_array($post_ids) ? count($post_ids) : 1; |
|
207 | 207 | |
208 | - if ( $pagenow == 'edit.php' && $post_type == $this->bulk_action_post_type ) { |
|
208 | + if ($pagenow == 'edit.php' && $post_type == $this->bulk_action_post_type) { |
|
209 | 209 | |
210 | - if ( isset( $_REQUEST['success_action'] ) ) { |
|
210 | + if (isset($_REQUEST['success_action'])) { |
|
211 | 211 | |
212 | 212 | // Print notice in admin bar. |
213 | - $message = $this->actions[ $_REQUEST['success_action'] ]['admin_notice']; |
|
213 | + $message = $this->actions[$_REQUEST['success_action']]['admin_notice']; |
|
214 | 214 | |
215 | - if ( is_array( $message ) ) { |
|
216 | - $message = sprintf( _n( $message['single'], $message['plural'], $post_ids_count, 'google-calendar-events' ), $post_ids_count ); |
|
215 | + if (is_array($message)) { |
|
216 | + $message = sprintf(_n($message['single'], $message['plural'], $post_ids_count, 'google-calendar-events'), $post_ids_count); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | $class = 'updated notice is-dismissible above-h2'; |
220 | - if ( ! empty( $message ) ) { |
|
220 | + if ( ! empty($message)) { |
|
221 | 221 | echo "<div class=\"{$class}\"><p>{$message}</p></div>"; |
222 | 222 | } |
223 | 223 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Field; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; // Exit if accessed directly. |
13 | 13 | } |
14 | 14 | |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param array $field |
30 | 30 | */ |
31 | - public function __construct( $field ) { |
|
31 | + public function __construct($field) { |
|
32 | 32 | $this->type_class = 'simcal-field-checkboxes'; |
33 | - parent::__construct( $field ); |
|
33 | + parent::__construct($field); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -40,33 +40,33 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function html() { |
42 | 42 | |
43 | - if ( ! empty( $this->options ) && count( (array) $this->options ) > 1 ) { |
|
43 | + if ( ! empty($this->options) && count((array) $this->options) > 1) { |
|
44 | 44 | |
45 | - if ( ! empty( $this->description ) ) { |
|
46 | - echo '<p class="description">' . wp_kses_post( $this->description ) . ' ' . $this->tooltip . '</p>'; |
|
45 | + if ( ! empty($this->description)) { |
|
46 | + echo '<p class="description">'.wp_kses_post($this->description).' '.$this->tooltip.'</p>'; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | ?> |
50 | - <fieldset class="<?php echo $this->class; ?>" <?php echo ! empty( $this->style ) ? 'style="' . $this->style . '"' : ''; ?>> |
|
50 | + <fieldset class="<?php echo $this->class; ?>" <?php echo ! empty($this->style) ? 'style="'.$this->style.'"' : ''; ?>> |
|
51 | 51 | <?php |
52 | 52 | |
53 | - if ( ! empty( $this->title ) ) { |
|
54 | - echo '<legend class="screen-reader-text"><span>' . $this->title . '</span></legend>'; |
|
53 | + if ( ! empty($this->title)) { |
|
54 | + echo '<legend class="screen-reader-text"><span>'.$this->title.'</span></legend>'; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | ?> |
58 | 58 | <ul> |
59 | - <?php foreach ( $this->options as $option => $name ) : ?> |
|
59 | + <?php foreach ($this->options as $option => $name) : ?> |
|
60 | 60 | <li> |
61 | - <label for="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>"> |
|
61 | + <label for="<?php echo $this->id.'-'.trim(strval($option)); ?>"> |
|
62 | 62 | <input name="<?php echo $this->name; ?>" |
63 | - id="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>" |
|
63 | + id="<?php echo $this->id.'-'.trim(strval($option)); ?>" |
|
64 | 64 | class="simcal-field simcal-field-checkbox" |
65 | 65 | type="checkbox" |
66 | - value="<?php echo trim( strval( $option ) ); ?>" |
|
67 | - <?php checked( $this->value, $option, true ); ?> |
|
66 | + value="<?php echo trim(strval($option)); ?>" |
|
67 | + <?php checked($this->value, $option, true); ?> |
|
68 | 68 | <?php echo $this->attributes; ?> |
69 | - /><?php echo esc_attr( $name ); ?> |
|
69 | + /><?php echo esc_attr($name); ?> |
|
70 | 70 | </label> |
71 | 71 | </li> |
72 | 72 | <?php endforeach; ?> |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | } else { |
78 | 78 | |
79 | 79 | ?> |
80 | - <span class="simcal-field-bool" <?php echo $this->style ? 'style="' . $this->style . '"' : ''; ?>> |
|
81 | - <?php if ( ! empty( $this->title ) ) : ?> |
|
80 | + <span class="simcal-field-bool" <?php echo $this->style ? 'style="'.$this->style.'"' : ''; ?>> |
|
81 | + <?php if ( ! empty($this->title)) : ?> |
|
82 | 82 | <span class="screen-reader-text"><?php echo $this->title; ?></span> |
83 | 83 | <?php endif; ?> |
84 | 84 | <input name="<?php echo $this->name; ?>" |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | id="<?php echo $this->id; ?>" |
87 | 87 | class="simcal-field simcal-field-checkbox <?php echo $this->class; ?>" |
88 | 88 | value="yes" |
89 | - <?php checked( $this->value, 'yes', true ); ?> |
|
90 | - <?php echo $this->attributes; ?>/><?php _e( 'Yes', 'google-calendar-events' ); ?> |
|
89 | + <?php checked($this->value, 'yes', true); ?> |
|
90 | + <?php echo $this->attributes; ?>/><?php _e('Yes', 'google-calendar-events'); ?> |
|
91 | 91 | </span> |
92 | 92 | <?php |
93 | 93 | |
94 | 94 | echo $this->tooltip; |
95 | 95 | |
96 | - if ( ! empty( $this->description ) ) { |
|
97 | - echo '<p class="description">' . wp_kses_post( $this->description ) . '</p>'; |
|
96 | + if ( ! empty($this->description)) { |
|
97 | + echo '<p class="description">'.wp_kses_post($this->description).'</p>'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | } |
@@ -95,7 +95,7 @@ |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | } else { |
98 | - // @todo eventually if a date range picker is needed, this can be extended |
|
98 | + // @todo eventually if a date range picker is needed, this can be extended |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | ?> |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Field; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -45,20 +45,20 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @param array $field |
47 | 47 | */ |
48 | - public function __construct( $field ) { |
|
48 | + public function __construct($field) { |
|
49 | 49 | |
50 | - $this->range = isset( $field['range'] ) ? ( $field['range'] === true ? true : false ) : false; |
|
51 | - $this->inline = isset( $field['inline'] ) ? ( $field['inline'] === true ? true : false ) : true; |
|
50 | + $this->range = isset($field['range']) ? ($field['range'] === true ? true : false) : false; |
|
51 | + $this->inline = isset($field['inline']) ? ($field['inline'] === true ? true : false) : true; |
|
52 | 52 | |
53 | 53 | $subtype = $this->range === true ? 'simcal-field-date-picker-range ' : ''; |
54 | - $this->type_class = 'simcal-field-date-picker ' . $subtype; |
|
54 | + $this->type_class = 'simcal-field-date-picker '.$subtype; |
|
55 | 55 | |
56 | 56 | $data = array( |
57 | 57 | 'data-inline' => $this->inline === true ? 'true' : 'false', |
58 | 58 | ); |
59 | - $field['attributes'] = isset( $field['attributes'] ) ? array_merge( $field['attributes'], $data ) : $data; |
|
59 | + $field['attributes'] = isset($field['attributes']) ? array_merge($field['attributes'], $data) : $data; |
|
60 | 60 | |
61 | - parent::__construct( $field ); |
|
61 | + parent::__construct($field); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -68,18 +68,18 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function html() { |
70 | 70 | |
71 | - if ( ! empty( $this->description ) ) { |
|
72 | - echo '<p class="description">' . wp_kses_post( $this->description ) . '</p>'; |
|
71 | + if ( ! empty($this->description)) { |
|
72 | + echo '<p class="description">'.wp_kses_post($this->description).'</p>'; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | ?> |
76 | 76 | <div id="<?php echo $this->id; ?>" |
77 | 77 | class="<?php echo $this->class; ?>" |
78 | - <?php echo $this->style ? 'style="' . $this->style . '"' : ''; ?> |
|
78 | + <?php echo $this->style ? 'style="'.$this->style.'"' : ''; ?> |
|
79 | 79 | <?php echo $this->attributes ?>> |
80 | 80 | <?php |
81 | 81 | |
82 | - if ( false === $this->range ) { |
|
82 | + if (false === $this->range) { |
|
83 | 83 | |
84 | 84 | ?> |
85 | 85 | <i class="simcal-icon-calendar"></i> |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | readonly="readonly" /> |
91 | 91 | <?php |
92 | 92 | |
93 | - if ( true === $this->inline ) { |
|
93 | + if (true === $this->inline) { |
|
94 | 94 | echo $this->tooltip; |
95 | 95 | } |
96 | 96 |
@@ -335,7 +335,7 @@ |
||
335 | 335 | */ |
336 | 336 | private function meridiem() { |
337 | 337 | |
338 | - ?> |
|
338 | + ?> |
|
339 | 339 | <div> |
340 | 340 | <label for="<?php echo $this->id; ?>-meridiem"> |
341 | 341 | <?php _e( 'Meridiem', 'google-calendar-events' ); ?> |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Field; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -42,19 +42,19 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param array $field |
44 | 44 | */ |
45 | - public function __construct( $field ) { |
|
45 | + public function __construct($field) { |
|
46 | 46 | |
47 | - $this->subtype = isset( $field['subtype'] ) ? $field['subtype'] : ''; |
|
48 | - $this->type_class = 'simcal-field-datetime-format simcal-field-' . $this->subtype . '-format-field'; |
|
49 | - $this->timestamp = mktime( 13, 10, 00, 1, 1, intval( date( 'Y', time() ) ) + 1 ); |
|
47 | + $this->subtype = isset($field['subtype']) ? $field['subtype'] : ''; |
|
48 | + $this->type_class = 'simcal-field-datetime-format simcal-field-'.$this->subtype.'-format-field'; |
|
49 | + $this->timestamp = mktime(13, 10, 00, 1, 1, intval(date('Y', time())) + 1); |
|
50 | 50 | |
51 | - parent::__construct( $field ); |
|
51 | + parent::__construct($field); |
|
52 | 52 | |
53 | - if ( empty( $this->value ) ) { |
|
54 | - if ( 'date' == $this->subtype ) { |
|
53 | + if (empty($this->value)) { |
|
54 | + if ('date' == $this->subtype) { |
|
55 | 55 | $this->value = 'l, d F Y'; |
56 | 56 | } |
57 | - if ( 'time' == $this->subtype ) { |
|
57 | + if ('time' == $this->subtype) { |
|
58 | 58 | $this->value = 'G:i a'; |
59 | 59 | } |
60 | 60 | } |
@@ -67,36 +67,36 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function html() { |
69 | 69 | |
70 | - $id = $this->id ? ' id="' . $this->id . '" ' : ''; |
|
71 | - $class = $this->class ? ' class="' . $this->class . '" ' : ''; |
|
72 | - $style = $this->style ? ' style="' . $this->style . '" ' : ''; |
|
70 | + $id = $this->id ? ' id="'.$this->id.'" ' : ''; |
|
71 | + $class = $this->class ? ' class="'.$this->class.'" ' : ''; |
|
72 | + $style = $this->style ? ' style="'.$this->style.'" ' : ''; |
|
73 | 73 | $attr = $this->attributes; |
74 | 74 | |
75 | 75 | ?> |
76 | - <div <?php echo $id . $class . $style . $attr; ?>> |
|
76 | + <div <?php echo $id.$class.$style.$attr; ?>> |
|
77 | 77 | <?php |
78 | 78 | |
79 | - if ( ! empty( $this->description ) ) { |
|
80 | - echo '<p class="description">' . $this->description . '</p>'; |
|
79 | + if ( ! empty($this->description)) { |
|
80 | + echo '<p class="description">'.$this->description.'</p>'; |
|
81 | 81 | } |
82 | 82 | |
83 | - $matches = array_unique( str_split( $this->value ) ); |
|
83 | + $matches = array_unique(str_split($this->value)); |
|
84 | 84 | |
85 | - if ( 'date' == $this->subtype ) { |
|
86 | - $this->print_date( $matches ); |
|
85 | + if ('date' == $this->subtype) { |
|
86 | + $this->print_date($matches); |
|
87 | 87 | } |
88 | 88 | |
89 | - if ( 'time' == $this->subtype ) { |
|
90 | - $this->print_time( $matches ); |
|
89 | + if ('time' == $this->subtype) { |
|
90 | + $this->print_time($matches); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | ?> |
94 | 94 | <input type="hidden" |
95 | 95 | name="<?php echo $this->name; ?>" |
96 | - value="<?php echo trim( $this->value ); ?>" /> |
|
96 | + value="<?php echo trim($this->value); ?>" /> |
|
97 | 97 | <span> |
98 | - <em><?php _e( 'Preview', 'google-calendar-events' ); ?>:</em> |
|
99 | - <code><?php echo date_i18n( $this->value, $this->timestamp ); ?></code> |
|
98 | + <em><?php _e('Preview', 'google-calendar-events'); ?>:</em> |
|
99 | + <code><?php echo date_i18n($this->value, $this->timestamp); ?></code> |
|
100 | 100 | </span> |
101 | 101 | </div> |
102 | 102 | <?php |
@@ -111,30 +111,30 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @param array $matches |
113 | 113 | */ |
114 | - private function print_date( $matches ) { |
|
114 | + private function print_date($matches) { |
|
115 | 115 | |
116 | - $date = array( 'weekday' => '', 'divider' => '', 'day' => '', 'month' => '', 'year' => '' ); |
|
116 | + $date = array('weekday' => '', 'divider' => '', 'day' => '', 'month' => '', 'year' => ''); |
|
117 | 117 | |
118 | - foreach ( $matches as $match ) { |
|
119 | - if ( in_array( $match, array( 'D', 'l' ) ) ) { |
|
118 | + foreach ($matches as $match) { |
|
119 | + if (in_array($match, array('D', 'l'))) { |
|
120 | 120 | $this->weekday(); |
121 | - unset( $date['weekday'] ); |
|
122 | - } elseif ( in_array( $match, array( 'd', 'j' ) ) ) { |
|
121 | + unset($date['weekday']); |
|
122 | + } elseif (in_array($match, array('d', 'j'))) { |
|
123 | 123 | $this->day(); |
124 | - unset( $date['day'] ); |
|
125 | - } elseif ( in_array( $match, array( 'F', 'M', 'm', 'n' ) ) ) { |
|
124 | + unset($date['day']); |
|
125 | + } elseif (in_array($match, array('F', 'M', 'm', 'n'))) { |
|
126 | 126 | $this->month(); |
127 | - unset( $date['month'] ); |
|
128 | - } elseif ( in_array( $match, array( 'y', 'Y' ) ) ) { |
|
127 | + unset($date['month']); |
|
128 | + } elseif (in_array($match, array('y', 'Y'))) { |
|
129 | 129 | $this->year(); |
130 | - unset( $date['year'] ); |
|
131 | - } elseif ( in_array( $match, array( '.', ',', ':', '/', '-' ) ) ) { |
|
130 | + unset($date['year']); |
|
131 | + } elseif (in_array($match, array('.', ',', ':', '/', '-'))) { |
|
132 | 132 | $this->divider(); |
133 | - unset( $date['divider'] ); |
|
133 | + unset($date['divider']); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - $this->print_fields( $date ); |
|
137 | + $this->print_fields($date); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -145,27 +145,27 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param array $matches |
147 | 147 | */ |
148 | - private function print_time( $matches ) { |
|
148 | + private function print_time($matches) { |
|
149 | 149 | |
150 | - $time = array( 'hours' => '', 'divider' => '', 'minutes' => '', 'meridiem' => '' ); |
|
150 | + $time = array('hours' => '', 'divider' => '', 'minutes' => '', 'meridiem' => ''); |
|
151 | 151 | |
152 | - foreach ( $matches as $match ) { |
|
153 | - if ( in_array( $match, array( 'h', 'H', 'g', 'G' ) ) ) { |
|
152 | + foreach ($matches as $match) { |
|
153 | + if (in_array($match, array('h', 'H', 'g', 'G'))) { |
|
154 | 154 | $this->hours(); |
155 | - unset( $time['hours'] ); |
|
156 | - } elseif ( in_array( $match, array( 'i' ) ) ) { |
|
155 | + unset($time['hours']); |
|
156 | + } elseif (in_array($match, array('i'))) { |
|
157 | 157 | $this->minutes(); |
158 | - unset( $time['minutes'] ); |
|
159 | - } elseif ( in_array( $match, array( 'A', 'a' ) ) ) { |
|
158 | + unset($time['minutes']); |
|
159 | + } elseif (in_array($match, array('A', 'a'))) { |
|
160 | 160 | $this->meridiem(); |
161 | - unset( $time['meridiem'] ); |
|
162 | - } elseif ( in_array( $match, array( '.', ',', ':', '/', '-' ) ) ) { |
|
161 | + unset($time['meridiem']); |
|
162 | + } elseif (in_array($match, array('.', ',', ':', '/', '-'))) { |
|
163 | 163 | $this->divider(); |
164 | - unset( $time['divider'] ); |
|
164 | + unset($time['divider']); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | - $this->print_fields( $time ); |
|
168 | + $this->print_fields($time); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @param $fields |
178 | 178 | */ |
179 | - private function print_fields( $fields ) { |
|
180 | - if ( ! empty( $fields ) && is_array( $fields ) ) { |
|
181 | - foreach ( $fields as $func => $v ) { |
|
182 | - if ( method_exists( $this, $func ) ) { |
|
179 | + private function print_fields($fields) { |
|
180 | + if ( ! empty($fields) && is_array($fields)) { |
|
181 | + foreach ($fields as $func => $v) { |
|
182 | + if (method_exists($this, $func)) { |
|
183 | 183 | $this->$func(); |
184 | 184 | }; |
185 | 185 | } |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | ?> |
198 | 198 | <div> |
199 | 199 | <label for="<?php echo $this->id; ?>-weekday"> |
200 | - <?php _e( 'Weekday', 'google-calendar-events' ); ?> |
|
200 | + <?php _e('Weekday', 'google-calendar-events'); ?> |
|
201 | 201 | <select name="" id="<?php echo $this->id; ?>-weekday"> |
202 | 202 | <option value="" data-preview=""></option> |
203 | - <option value="D" <?php selected( 'D', strpbrk( 'D', $this->value ) ) ?> data-preview="<?php echo date_i18n( 'D', $this->timestamp ); ?>"><?php echo date_i18n( 'D', $this->timestamp ); ?></option> |
|
204 | - <option value="l" <?php selected( 'l', strpbrk( 'l', $this->value ) ) ?> data-preview="<?php echo date_i18n( 'l', $this->timestamp ); ?>"><?php echo date_i18n( 'l', $this->timestamp ); ?></option> |
|
203 | + <option value="D" <?php selected('D', strpbrk('D', $this->value)) ?> data-preview="<?php echo date_i18n('D', $this->timestamp); ?>"><?php echo date_i18n('D', $this->timestamp); ?></option> |
|
204 | + <option value="l" <?php selected('l', strpbrk('l', $this->value)) ?> data-preview="<?php echo date_i18n('l', $this->timestamp); ?>"><?php echo date_i18n('l', $this->timestamp); ?></option> |
|
205 | 205 | </select> |
206 | 206 | </label> |
207 | 207 | </div> |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | ?> |
221 | 221 | <div> |
222 | 222 | <label for="<?php echo $this->id; ?>-day"> |
223 | - <?php _e( 'Day', 'google-calendar-events' ); ?> |
|
223 | + <?php _e('Day', 'google-calendar-events'); ?> |
|
224 | 224 | <select name="" id="<?php echo $this->id; ?>-day"> |
225 | 225 | <option value="" data-preview=""></option> |
226 | - <option value="j" <?php selected( 'j', strpbrk( 'j', $this->value ) ) ?> data-preview="<?php echo date( 'j', $this->timestamp ); ?>"><?php echo date( 'j', $this->timestamp ); ?></option> |
|
227 | - <option value="d" <?php selected( 'd', strpbrk( 'd', $this->value ) ) ?> data-preview="<?php echo date( 'd', $this->timestamp ); ?>"><?php echo date( 'd', $this->timestamp ); ?></option> |
|
226 | + <option value="j" <?php selected('j', strpbrk('j', $this->value)) ?> data-preview="<?php echo date('j', $this->timestamp); ?>"><?php echo date('j', $this->timestamp); ?></option> |
|
227 | + <option value="d" <?php selected('d', strpbrk('d', $this->value)) ?> data-preview="<?php echo date('d', $this->timestamp); ?>"><?php echo date('d', $this->timestamp); ?></option> |
|
228 | 228 | </select> |
229 | 229 | </label> |
230 | 230 | </div> |
@@ -243,13 +243,13 @@ discard block |
||
243 | 243 | ?> |
244 | 244 | <div> |
245 | 245 | <label for="<?php echo $this->id; ?>-month"> |
246 | - <?php _e( 'Month', 'google-calendar-events' ); ?> |
|
246 | + <?php _e('Month', 'google-calendar-events'); ?> |
|
247 | 247 | <select name="" id="<?php echo $this->id; ?>-month"> |
248 | 248 | <option value="" data-preview=""></option> |
249 | - <option value="F" <?php selected( 'F', strpbrk( 'F', $this->value ) ) ?> data-preview="<?php echo date_i18n( 'F', $this->timestamp ); ?>"><?php echo date_i18n( 'F', $this->timestamp ); ?></option> |
|
250 | - <option value="M" <?php selected( 'M', strpbrk( 'M', $this->value ) ) ?> data-preview="<?php echo date_i18n( 'M', $this->timestamp ); ?>"><?php echo date_i18n( 'M', $this->timestamp ); ?></option> |
|
251 | - <option value="m" <?php selected( 'm', strpbrk( 'm', $this->value ) ) ?> data-preview="<?php echo date( 'm', $this->timestamp ); ?>"><?php echo date( 'm', $this->timestamp ); ?></option> |
|
252 | - <option value="n" <?php selected( 'n', strpbrk( 'n', $this->value ) ) ?> data-preview="<?php echo date( 'n', $this->timestamp ); ?>"><?php echo date( 'n', $this->timestamp ); ?></option> |
|
249 | + <option value="F" <?php selected('F', strpbrk('F', $this->value)) ?> data-preview="<?php echo date_i18n('F', $this->timestamp); ?>"><?php echo date_i18n('F', $this->timestamp); ?></option> |
|
250 | + <option value="M" <?php selected('M', strpbrk('M', $this->value)) ?> data-preview="<?php echo date_i18n('M', $this->timestamp); ?>"><?php echo date_i18n('M', $this->timestamp); ?></option> |
|
251 | + <option value="m" <?php selected('m', strpbrk('m', $this->value)) ?> data-preview="<?php echo date('m', $this->timestamp); ?>"><?php echo date('m', $this->timestamp); ?></option> |
|
252 | + <option value="n" <?php selected('n', strpbrk('n', $this->value)) ?> data-preview="<?php echo date('n', $this->timestamp); ?>"><?php echo date('n', $this->timestamp); ?></option> |
|
253 | 253 | </select> |
254 | 254 | </label> |
255 | 255 | </div> |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | ?> |
269 | 269 | <div> |
270 | 270 | <label for="<?php echo $this->id; ?>-year"> |
271 | - <?php _e( 'Year', 'google-calendar-events' ); ?> |
|
271 | + <?php _e('Year', 'google-calendar-events'); ?> |
|
272 | 272 | <select name="" id="<?php echo $this->id; ?>-year"> |
273 | 273 | <option value="" data-preview=""></option> |
274 | - <option value="Y" <?php selected( 'Y', strpbrk( 'Y', $this->value ) ) ?> data-preview="<?php echo date( 'Y', $this->timestamp ); ?>"><?php echo date( 'Y', $this->timestamp ); ?></option> |
|
275 | - <option value="y" <?php selected( 'y', strpbrk( 'y', $this->value ) ) ?> data-preview="<?php echo date( 'y', $this->timestamp ); ?>"><?php echo date( 'y', $this->timestamp ); ?></option> |
|
274 | + <option value="Y" <?php selected('Y', strpbrk('Y', $this->value)) ?> data-preview="<?php echo date('Y', $this->timestamp); ?>"><?php echo date('Y', $this->timestamp); ?></option> |
|
275 | + <option value="y" <?php selected('y', strpbrk('y', $this->value)) ?> data-preview="<?php echo date('y', $this->timestamp); ?>"><?php echo date('y', $this->timestamp); ?></option> |
|
276 | 276 | </select> |
277 | 277 | </label> |
278 | 278 | </div> |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | ?> |
292 | 292 | <div> |
293 | 293 | <label for="<?php echo $this->id; ?>-hours"> |
294 | - <?php _e( 'Hours', 'google-calendar-events' ) ?> |
|
294 | + <?php _e('Hours', 'google-calendar-events') ?> |
|
295 | 295 | <select name="" id="<?php echo $this->id; ?>-hours"> |
296 | 296 | <option value="" data-preview=""></option> |
297 | - <option value="g" <?php selected( 'g', strpbrk( 'g', $this->value ) ); ?> data-preview="<?php echo date( 'g', $this->timestamp ); ?>"><?php echo date( 'g', $this->timestamp ) . ' (12h)'; ?></option> |
|
298 | - <option value="G" <?php selected( 'G', strpbrk( 'G', $this->value ) ); ?> data-preview="<?php echo date( 'G', $this->timestamp - 43200 ); ?>"><?php echo date( 'G', $this->timestamp - 43200 ) . ' (24h)'; ?></option> |
|
299 | - <option value="h" <?php selected( 'h', strpbrk( 'h', $this->value ) ); ?> data-preview="<?php echo date( 'h', $this->timestamp ); ?>"><?php echo date( 'h', $this->timestamp ) . ' (12h)'; ?></option> |
|
300 | - <option value="H" <?php selected( 'H', strpbrk( 'H', $this->value ) ); ?> data-preview="<?php echo date( 'H', $this->timestamp - 43200 ); ?>"><?php echo date( 'H', $this->timestamp - 43200 ) . ' (24h)'; ?></option> |
|
297 | + <option value="g" <?php selected('g', strpbrk('g', $this->value)); ?> data-preview="<?php echo date('g', $this->timestamp); ?>"><?php echo date('g', $this->timestamp).' (12h)'; ?></option> |
|
298 | + <option value="G" <?php selected('G', strpbrk('G', $this->value)); ?> data-preview="<?php echo date('G', $this->timestamp - 43200); ?>"><?php echo date('G', $this->timestamp - 43200).' (24h)'; ?></option> |
|
299 | + <option value="h" <?php selected('h', strpbrk('h', $this->value)); ?> data-preview="<?php echo date('h', $this->timestamp); ?>"><?php echo date('h', $this->timestamp).' (12h)'; ?></option> |
|
300 | + <option value="H" <?php selected('H', strpbrk('H', $this->value)); ?> data-preview="<?php echo date('H', $this->timestamp - 43200); ?>"><?php echo date('H', $this->timestamp - 43200).' (24h)'; ?></option> |
|
301 | 301 | </select> |
302 | 302 | </label> |
303 | 303 | </div> |
@@ -316,10 +316,10 @@ discard block |
||
316 | 316 | ?> |
317 | 317 | <div> |
318 | 318 | <label for="<?php echo $this->id; ?>-minutes"> |
319 | - <?php _e( 'Minutes', 'google-calendar-events' ); ?> |
|
319 | + <?php _e('Minutes', 'google-calendar-events'); ?> |
|
320 | 320 | <select name="" id="<?php echo $this->id; ?>-minutes"> |
321 | 321 | <option value="" data-preview=""></option> |
322 | - <option value="i" <?php selected( 'i', strpbrk( 'i', $this->value ) ); ?> data-preview="<?php echo date( 'i', $this->timestamp ); ?>"><?php echo date( 'i', $this->timestamp ); ?></option> |
|
322 | + <option value="i" <?php selected('i', strpbrk('i', $this->value)); ?> data-preview="<?php echo date('i', $this->timestamp); ?>"><?php echo date('i', $this->timestamp); ?></option> |
|
323 | 323 | </select> |
324 | 324 | </label> |
325 | 325 | </div> |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | ?> |
339 | 339 | <div> |
340 | 340 | <label for="<?php echo $this->id; ?>-meridiem"> |
341 | - <?php _e( 'Meridiem', 'google-calendar-events' ); ?> |
|
341 | + <?php _e('Meridiem', 'google-calendar-events'); ?> |
|
342 | 342 | <select name="" id="<?php echo $this->id; ?>-meridiem"> |
343 | 343 | <option value="" data-preview=""></option> |
344 | - <option value="a" <?php selected( 'a', strpbrk( 'a', $this->value ) ); ?> data-preview="<?php echo date( 'a', $this->timestamp ); ?>"><?php echo date( 'a', $this->timestamp ); ?></option> |
|
345 | - <option value="A" <?php selected( 'A', strpbrk( 'A', $this->value ) ); ?> data-preview="<?php echo date( 'A', $this->timestamp ); ?>"><?php echo date( 'A', $this->timestamp ); ?></option> |
|
344 | + <option value="a" <?php selected('a', strpbrk('a', $this->value)); ?> data-preview="<?php echo date('a', $this->timestamp); ?>"><?php echo date('a', $this->timestamp); ?></option> |
|
345 | + <option value="A" <?php selected('A', strpbrk('A', $this->value)); ?> data-preview="<?php echo date('A', $this->timestamp); ?>"><?php echo date('A', $this->timestamp); ?></option> |
|
346 | 346 | </select> |
347 | 347 | </label> |
348 | 348 | </div> |
@@ -361,14 +361,14 @@ discard block |
||
361 | 361 | ?> |
362 | 362 | <div> |
363 | 363 | <label for="<?php echo $this->id; ?>-divider"> |
364 | - <?php _ex( 'Divider', 'A character to separate two elements', 'google-calendar-events' ); ?> |
|
364 | + <?php _ex('Divider', 'A character to separate two elements', 'google-calendar-events'); ?> |
|
365 | 365 | <select name="" id="<?php echo $this->id; ?>-divider"> |
366 | 366 | <option value="" data-preview=""></option> |
367 | - <option value="." <?php selected( '.', strpbrk( '.', $this->value ) ); ?> data-preview="." data-trim="true">.</option> |
|
368 | - <option value=", " <?php selected( ',', strpbrk( ',', $this->value ) ); ?> data-preview=", " data-trim="true">,</option> |
|
369 | - <option value=":" <?php selected( ':', strpbrk( ':', $this->value ) ); ?> data-preview=":" data-trim="true">:</option> |
|
370 | - <option value="-" <?php selected( '-', strpbrk( '-', $this->value ) ); ?> data-preview="-" data-trim="true">-</option> |
|
371 | - <option value="/" <?php selected( '/', strpbrk( '/', $this->value ) ); ?> data-preview="/" data-trim="true">/</option> |
|
367 | + <option value="." <?php selected('.', strpbrk('.', $this->value)); ?> data-preview="." data-trim="true">.</option> |
|
368 | + <option value=", " <?php selected(',', strpbrk(',', $this->value)); ?> data-preview=", " data-trim="true">,</option> |
|
369 | + <option value=":" <?php selected(':', strpbrk(':', $this->value)); ?> data-preview=":" data-trim="true">:</option> |
|
370 | + <option value="-" <?php selected('-', strpbrk('-', $this->value)); ?> data-preview="-" data-trim="true">-</option> |
|
371 | + <option value="/" <?php selected('/', strpbrk('/', $this->value)); ?> data-preview="/" data-trim="true">/</option> |
|
372 | 372 | </select> |
373 | 373 | </label> |
374 | 374 | </div> |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Field; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param array $field |
36 | 36 | */ |
37 | - public function __construct( $field ) { |
|
38 | - $this->addon = isset( $field['addon'] ) ? esc_attr( $field['addon'] ) : ''; |
|
37 | + public function __construct($field) { |
|
38 | + $this->addon = isset($field['addon']) ? esc_attr($field['addon']) : ''; |
|
39 | 39 | $this->type_class = 'simcal-field-license'; |
40 | - parent::__construct( $field ); |
|
40 | + parent::__construct($field); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function html() { |
49 | 49 | |
50 | - if ( ! empty( $this->addon ) ) { |
|
50 | + if ( ! empty($this->addon)) { |
|
51 | 51 | |
52 | - $status = simcal_get_license_status( $this->addon ); |
|
52 | + $status = simcal_get_license_status($this->addon); |
|
53 | 53 | |
54 | - if ( empty( $status ) || in_array( $status, array( 'valid', 'invalid', 'deactivated' ) ) ) { |
|
54 | + if (empty($status) || in_array($status, array('valid', 'invalid', 'deactivated'))) { |
|
55 | 55 | $display_activate = 'display: inline-block'; |
56 | 56 | $display_deactivate = 'display: none'; |
57 | 57 | $active = 'valid' == $status ? 'display: block' : 'display: none'; |
58 | - $disabled = ''; |
|
58 | + $disabled = ''; |
|
59 | 59 | } else { |
60 | 60 | $display_activate = $active = 'display: none'; |
61 | 61 | $display_deactivate = 'display: inline-block'; |
62 | - $disabled = empty( $this->value ) ? '' : 'disabled="disabled"'; |
|
62 | + $disabled = empty($this->value) ? '' : 'disabled="disabled"'; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | ?> |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | <span class="simcal-addon-manage-license-buttons"> |
75 | 75 | |
76 | 76 | <button class="button-secondary simcal-addon-manage-license deactivate" data-add-on="<?php echo $this->addon; ?>" style="<?php echo $display_deactivate; ?>"> |
77 | - <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e( 'Deactivate', 'google-calendar-events' ); ?> |
|
77 | + <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e('Deactivate', 'google-calendar-events'); ?> |
|
78 | 78 | </button> |
79 | 79 | |
80 | 80 | <button class="button-secondary simcal-addon-manage-license activate" data-add-on="<?php echo $this->addon; ?>" style="<?php echo $display_activate; ?>"> |
81 | - <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e( 'Activate', 'google-calendar-events' ); ?> |
|
81 | + <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e('Activate', 'google-calendar-events'); ?> |
|
82 | 82 | </button> |
83 | 83 | |
84 | 84 | <span class="error" style="color: red; display: none"> </span> |
85 | 85 | |
86 | - <strong class="label" style="color:green; <?php echo $active; ?>"> <?php _e( '(active)', 'google-calendar-events' ); ?></strong> |
|
86 | + <strong class="label" style="color:green; <?php echo $active; ?>"> <?php _e('(active)', 'google-calendar-events'); ?></strong> |
|
87 | 87 | |
88 | 88 | </span> |
89 | 89 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Field; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @param array $field |
28 | 28 | */ |
29 | - public function __construct( $field ) { |
|
30 | - parent::__construct( $field ); |
|
29 | + public function __construct($field) { |
|
30 | + parent::__construct($field); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @since 3.0.0 |
37 | 37 | */ |
38 | 38 | public function html() { |
39 | - wp_nonce_field( $this->name, $this->value ); |
|
39 | + wp_nonce_field($this->name, $this->value); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | } |