@@ -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 | 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 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | use Carbon\Carbon; |
| 10 | 10 | use SimpleCalendar\Abstracts\Calendar; |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param Event $event |
| 55 | 55 | * @param Calendar $calendar |
| 56 | 56 | */ |
| 57 | - public function __construct( Event $event, Calendar $calendar ) { |
|
| 57 | + public function __construct(Event $event, Calendar $calendar) { |
|
| 58 | 58 | $this->event = $event; |
| 59 | 59 | $this->calendar = $calendar; |
| 60 | 60 | $this->tags = $this->get_content_tags(); |
@@ -74,85 +74,85 @@ discard block |
||
| 74 | 74 | * Content Tags * |
| 75 | 75 | * ============ */ |
| 76 | 76 | |
| 77 | - 'title', // The event title. |
|
| 78 | - 'event-title', // @deprecated An alias for 'title' tag. |
|
| 79 | - 'description', // The event description. |
|
| 80 | - |
|
| 81 | - 'when', // Date and time of the event. |
|
| 82 | - 'start-time', // Start time of the event. |
|
| 83 | - 'start-date', // Start date of the event. |
|
| 84 | - 'start-custom', // @deprecated Start time in a user defined format (set by tag 'format' attribute). |
|
| 85 | - 'start-human', // Start time in a human friendly format. |
|
| 86 | - 'end-time', // End time of the event. |
|
| 87 | - 'end-date', // End date of the event. |
|
| 88 | - 'end-custom', // @deprecated End date-time in a user defined format (set by tag 'format' attribute). |
|
| 89 | - 'end-human', // End date-time in a human friendly format. |
|
| 90 | - |
|
| 91 | - 'duration', // How long the events lasts, in a human-readable format. |
|
| 92 | - 'length', // @deprecated An alias of 'duration' tag. |
|
| 93 | - |
|
| 94 | - 'location', // Alias of start-location. |
|
| 95 | - 'start-location', // Location name where the event starts. |
|
| 96 | - 'maps-link', // @deprecated An alias for 'start-location-link' tag. |
|
| 97 | - 'start-location-link', // Link to Google Maps querying the event start location address. |
|
| 98 | - 'end-location', // Location name where the event ends. |
|
| 99 | - 'end-location-link', // Link to Google Maps querying the event end location address. |
|
| 100 | - |
|
| 101 | - 'link', // An HTML link to the event URL. |
|
| 102 | - 'url', // A string with the raw event link URL. |
|
| 103 | - |
|
| 104 | - 'calendar', // The title of the source calendar. |
|
| 105 | - 'feed-title', // @deprecated An alias of 'calendar'. |
|
| 106 | - |
|
| 107 | - 'id', // The event unique ID. |
|
| 108 | - 'uid', // An alias of ID. |
|
| 109 | - 'ical-id', // iCal ID. |
|
| 110 | - 'event-id', // @deprecated An alias for 'id' tag. |
|
| 111 | - 'calendar-id', // The calendar ID. |
|
| 112 | - 'feed-id', // @deprecated An alias for 'calendar-id' tag. |
|
| 113 | - 'cal-id', // @deprecated An alias for 'calendar-id' tag. |
|
| 77 | + 'title', // The event title. |
|
| 78 | + 'event-title', // @deprecated An alias for 'title' tag. |
|
| 79 | + 'description', // The event description. |
|
| 80 | + |
|
| 81 | + 'when', // Date and time of the event. |
|
| 82 | + 'start-time', // Start time of the event. |
|
| 83 | + 'start-date', // Start date of the event. |
|
| 84 | + 'start-custom', // @deprecated Start time in a user defined format (set by tag 'format' attribute). |
|
| 85 | + 'start-human', // Start time in a human friendly format. |
|
| 86 | + 'end-time', // End time of the event. |
|
| 87 | + 'end-date', // End date of the event. |
|
| 88 | + 'end-custom', // @deprecated End date-time in a user defined format (set by tag 'format' attribute). |
|
| 89 | + 'end-human', // End date-time in a human friendly format. |
|
| 90 | + |
|
| 91 | + 'duration', // How long the events lasts, in a human-readable format. |
|
| 92 | + 'length', // @deprecated An alias of 'duration' tag. |
|
| 93 | + |
|
| 94 | + 'location', // Alias of start-location. |
|
| 95 | + 'start-location', // Location name where the event starts. |
|
| 96 | + 'maps-link', // @deprecated An alias for 'start-location-link' tag. |
|
| 97 | + 'start-location-link', // Link to Google Maps querying the event start location address. |
|
| 98 | + 'end-location', // Location name where the event ends. |
|
| 99 | + 'end-location-link', // Link to Google Maps querying the event end location address. |
|
| 100 | + |
|
| 101 | + 'link', // An HTML link to the event URL. |
|
| 102 | + 'url', // A string with the raw event link URL. |
|
| 103 | + |
|
| 104 | + 'calendar', // The title of the source calendar. |
|
| 105 | + 'feed-title', // @deprecated An alias of 'calendar'. |
|
| 106 | + |
|
| 107 | + 'id', // The event unique ID. |
|
| 108 | + 'uid', // An alias of ID. |
|
| 109 | + 'ical-id', // iCal ID. |
|
| 110 | + 'event-id', // @deprecated An alias for 'id' tag. |
|
| 111 | + 'calendar-id', // The calendar ID. |
|
| 112 | + 'feed-id', // @deprecated An alias for 'calendar-id' tag. |
|
| 113 | + 'cal-id', // @deprecated An alias for 'calendar-id' tag. |
|
| 114 | 114 | |
| 115 | 115 | /* ========= * |
| 116 | 116 | * Meta Tags * |
| 117 | 117 | * ========= */ |
| 118 | 118 | |
| 119 | - 'attachments', // List of attachments. |
|
| 120 | - 'attendees', // List of attendees. |
|
| 121 | - 'organizer', // Creator info. |
|
| 119 | + 'attachments', // List of attachments. |
|
| 120 | + 'attendees', // List of attendees. |
|
| 121 | + 'organizer', // Creator info. |
|
| 122 | 122 | |
| 123 | 123 | /* ================ * |
| 124 | 124 | * Conditional Tags * |
| 125 | 125 | * ================ */ |
| 126 | 126 | |
| 127 | - 'if-title', // If the event has a title. |
|
| 128 | - 'if-description', // If the event has a description. |
|
| 129 | - |
|
| 130 | - 'if-now', // If the event is taking place now. |
|
| 131 | - 'if-not-now', // If the event is not taking place now (may have ended or just not started yet). |
|
| 132 | - 'if-started', // If the event has started (and may as well as ended). |
|
| 133 | - 'if-not-started', // If the event has NOT started yet (event could be any time in the future). |
|
| 134 | - 'if-ended', // If the event has ended (event could be any time in the past). |
|
| 135 | - 'if-not-ended', // If the event has NOT ended (may as well as not started yet). |
|
| 136 | - |
|
| 137 | - 'if-whole-day', // If the event lasts the whole day. |
|
| 138 | - 'if-all-day', // @deprecated Alias for 'if-whole-day'. |
|
| 139 | - 'if-not-whole-day', // If the event does NOT last the whole day. |
|
| 140 | - 'if-not-all-day', // @deprecated Alias for 'if-not-whole-day'. |
|
| 141 | - 'if-end-time', // If the event has a set end time. |
|
| 142 | - 'if-no-end-time', // If the event has NOT a set end time. |
|
| 143 | - |
|
| 144 | - 'if-multi-day', // If the event spans multiple days. |
|
| 145 | - 'if-single-day', // If the event does not span multiple days. |
|
| 146 | - |
|
| 147 | - 'if-recurring', // If the event is a recurring event. |
|
| 148 | - 'if-not-recurring', // If the event is NOT a recurring event. |
|
| 149 | - |
|
| 150 | - 'if-location', // @deprecated Alias for 'if-start-location'. |
|
| 151 | - 'if-start-location', // Does the event has a start location? |
|
| 152 | - 'if-end-location', // Does the event has an end location? |
|
| 153 | - 'if-not-location', // @deprecated Alias for 'if-not-start-location'. |
|
| 127 | + 'if-title', // If the event has a title. |
|
| 128 | + 'if-description', // If the event has a description. |
|
| 129 | + |
|
| 130 | + 'if-now', // If the event is taking place now. |
|
| 131 | + 'if-not-now', // If the event is not taking place now (may have ended or just not started yet). |
|
| 132 | + 'if-started', // If the event has started (and may as well as ended). |
|
| 133 | + 'if-not-started', // If the event has NOT started yet (event could be any time in the future). |
|
| 134 | + 'if-ended', // If the event has ended (event could be any time in the past). |
|
| 135 | + 'if-not-ended', // If the event has NOT ended (may as well as not started yet). |
|
| 136 | + |
|
| 137 | + 'if-whole-day', // If the event lasts the whole day. |
|
| 138 | + 'if-all-day', // @deprecated Alias for 'if-whole-day'. |
|
| 139 | + 'if-not-whole-day', // If the event does NOT last the whole day. |
|
| 140 | + 'if-not-all-day', // @deprecated Alias for 'if-not-whole-day'. |
|
| 141 | + 'if-end-time', // If the event has a set end time. |
|
| 142 | + 'if-no-end-time', // If the event has NOT a set end time. |
|
| 143 | + |
|
| 144 | + 'if-multi-day', // If the event spans multiple days. |
|
| 145 | + 'if-single-day', // If the event does not span multiple days. |
|
| 146 | + |
|
| 147 | + 'if-recurring', // If the event is a recurring event. |
|
| 148 | + 'if-not-recurring', // If the event is NOT a recurring event. |
|
| 149 | + |
|
| 150 | + 'if-location', // @deprecated Alias for 'if-start-location'. |
|
| 151 | + 'if-start-location', // Does the event has a start location? |
|
| 152 | + 'if-end-location', // Does the event has an end location? |
|
| 153 | + 'if-not-location', // @deprecated Alias for 'if-not-start-location'. |
|
| 154 | 154 | 'if-not-start-location', // Does the event has NOT a start location? |
| 155 | - 'if-not-end-location', // Does the event has NOT an end location? |
|
| 155 | + 'if-not-end-location', // Does the event has NOT an end location? |
|
| 156 | 156 | |
| 157 | 157 | ); |
| 158 | 158 | } |
@@ -166,19 +166,19 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @return string |
| 168 | 168 | */ |
| 169 | - public function parse_event_template_tags( $template_tags = '' ) { |
|
| 169 | + public function parse_event_template_tags($template_tags = '') { |
|
| 170 | 170 | |
| 171 | 171 | // Process tags. |
| 172 | 172 | $result = preg_replace_callback( |
| 173 | 173 | $this->get_regex(), |
| 174 | - array( $this, 'process_event_content' ), |
|
| 174 | + array($this, 'process_event_content'), |
|
| 175 | 175 | $template_tags |
| 176 | 176 | ); |
| 177 | 177 | |
| 178 | 178 | // Removes extra consecutive <br> tags. |
| 179 | 179 | // TODO: Doesn't seem to work but going to remove it to allow multiple <br> tags in the editor |
| 180 | 180 | /*return preg_replace( '#(<br *//*?>\s*)+#i', '<br />', trim( $result ) );*/ |
| 181 | - return do_shortcode( trim( $result ) ); |
|
| 181 | + return do_shortcode(trim($result)); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -190,10 +190,10 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @return string |
| 192 | 192 | */ |
| 193 | - public function process_event_content( $match ) { |
|
| 193 | + public function process_event_content($match) { |
|
| 194 | 194 | |
| 195 | - if ( $match[1] == '[' && $match[6] == ']' ) { |
|
| 196 | - return substr( $match[0], 1, - 1 ); |
|
| 195 | + if ($match[1] == '[' && $match[6] == ']') { |
|
| 196 | + return substr($match[0], 1, - 1); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | $tag = $match[2]; // Tag name without square brackets. |
@@ -205,9 +205,9 @@ discard block |
||
| 205 | 205 | $calendar = $this->calendar; |
| 206 | 206 | $event = $this->event; |
| 207 | 207 | |
| 208 | - if ( ( $calendar instanceof Calendar ) && ( $event instanceof Event ) ) { |
|
| 208 | + if (($calendar instanceof Calendar) && ($event instanceof Event)) { |
|
| 209 | 209 | |
| 210 | - switch ( $tag ) { |
|
| 210 | + switch ($tag) { |
|
| 211 | 211 | |
| 212 | 212 | /* ============ * |
| 213 | 213 | * Content Tags * |
@@ -215,13 +215,13 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | case 'title' : |
| 217 | 217 | case 'event-title' : |
| 218 | - return $this->get_title( $event->title, $attr ); |
|
| 218 | + return $this->get_title($event->title, $attr); |
|
| 219 | 219 | |
| 220 | 220 | case 'description' : |
| 221 | - return $this->get_description( $event->description, $attr ); |
|
| 221 | + return $this->get_description($event->description, $attr); |
|
| 222 | 222 | |
| 223 | 223 | case 'when' : |
| 224 | - return $this->get_when( $event ); |
|
| 224 | + return $this->get_when($event); |
|
| 225 | 225 | |
| 226 | 226 | case 'end-date' : |
| 227 | 227 | case 'end-custom' : |
@@ -231,40 +231,40 @@ discard block |
||
| 231 | 231 | case 'start-date' : |
| 232 | 232 | case 'start-human' : |
| 233 | 233 | case 'start-time' : |
| 234 | - return $this->get_dt( $tag, $event, $attr ); |
|
| 234 | + return $this->get_dt($tag, $event, $attr); |
|
| 235 | 235 | |
| 236 | 236 | case 'length' : |
| 237 | 237 | case 'duration' : |
| 238 | - if ( false !== $event->end ) { |
|
| 238 | + if (false !== $event->end) { |
|
| 239 | 239 | $duration = $event->start - $event->end; |
| 240 | - $value = human_time_diff( $event->start, $event->end ); |
|
| 240 | + $value = human_time_diff($event->start, $event->end); |
|
| 241 | 241 | } else { |
| 242 | 242 | $duration = '-1'; |
| 243 | - $value = __( 'No end time', 'google-calendar-events' ); |
|
| 243 | + $value = __('No end time', 'google-calendar-events'); |
|
| 244 | 244 | } |
| 245 | - return ' <span class="simcal-event-duration" data-event-duration="' . $duration . '">' . $value . '</span>'; |
|
| 245 | + return ' <span class="simcal-event-duration" data-event-duration="'.$duration.'">'.$value.'</span>'; |
|
| 246 | 246 | |
| 247 | 247 | case 'location' : |
| 248 | 248 | case 'start-location' : |
| 249 | 249 | case 'end-location' : |
| 250 | 250 | $location = $tag == 'end-location' ? $event->end_location['address'] : $event->start_location['address']; |
| 251 | 251 | $location_class = $tag == 'end-location' ? 'end' : 'start'; |
| 252 | - return ' <span class="simcal-event-address simcal-event-' . $location_class . '-location" itemprop="location" itemscope itemtype="http://schema.org/Place">' . wp_strip_all_tags( $location ) . '</span>'; |
|
| 252 | + return ' <span class="simcal-event-address simcal-event-'.$location_class.'-location" itemprop="location" itemscope itemtype="http://schema.org/Place">'.wp_strip_all_tags($location).'</span>'; |
|
| 253 | 253 | |
| 254 | 254 | case 'start-location-link': |
| 255 | 255 | case 'end-location-link' : |
| 256 | 256 | case 'maps-link' : |
| 257 | 257 | $location = $tag == 'end-location-link' ? $event->end_location['address'] : $event->start_location['address']; |
| 258 | - if ( ! empty( $location ) ) { |
|
| 259 | - $url = '//maps.google.com?q=' . urlencode( $location ); |
|
| 260 | - return $this->make_link( $tag, $url, $calendar->get_event_html( $event, $partial ), $attr ); |
|
| 258 | + if ( ! empty($location)) { |
|
| 259 | + $url = '//maps.google.com?q='.urlencode($location); |
|
| 260 | + return $this->make_link($tag, $url, $calendar->get_event_html($event, $partial), $attr); |
|
| 261 | 261 | } |
| 262 | 262 | break; |
| 263 | 263 | |
| 264 | 264 | case 'link' : |
| 265 | 265 | case 'url' : |
| 266 | - $content = 'link' == $tag ? $calendar->get_event_html( $event, $partial ) : ''; |
|
| 267 | - return $this->make_link( $tag, $event->link, $content , $attr ); |
|
| 266 | + $content = 'link' == $tag ? $calendar->get_event_html($event, $partial) : ''; |
|
| 267 | + return $this->make_link($tag, $event->link, $content, $attr); |
|
| 268 | 268 | |
| 269 | 269 | case 'calendar' : |
| 270 | 270 | case 'feed-title' : |
@@ -289,22 +289,22 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | case 'attachments' : |
| 291 | 291 | $attachments = $event->get_attachments(); |
| 292 | - if ( ! empty( $attachments ) ) { |
|
| 293 | - return $this->get_attachments( $attachments ); |
|
| 292 | + if ( ! empty($attachments)) { |
|
| 293 | + return $this->get_attachments($attachments); |
|
| 294 | 294 | } |
| 295 | 295 | break; |
| 296 | 296 | |
| 297 | 297 | case 'attendees' : |
| 298 | 298 | $attendees = $event->get_attendees(); |
| 299 | - if ( ! empty( $attendees ) ) { |
|
| 300 | - return $this->get_attendees( $attendees, $attr ); |
|
| 299 | + if ( ! empty($attendees)) { |
|
| 300 | + return $this->get_attendees($attendees, $attr); |
|
| 301 | 301 | } |
| 302 | 302 | break; |
| 303 | 303 | |
| 304 | 304 | case 'organizer' : |
| 305 | 305 | $organizer = $event->get_organizer(); |
| 306 | - if ( ! empty( $organizer ) ) { |
|
| 307 | - return $this->get_organizer( $organizer, $attr ); |
|
| 306 | + if ( ! empty($organizer)) { |
|
| 307 | + return $this->get_organizer($organizer, $attr); |
|
| 308 | 308 | } |
| 309 | 309 | break; |
| 310 | 310 | |
@@ -313,35 +313,35 @@ discard block |
||
| 313 | 313 | * ================ */ |
| 314 | 314 | |
| 315 | 315 | case 'if-title': |
| 316 | - if ( ! empty( $event->title ) ) { |
|
| 317 | - return $calendar->get_event_html( $event, $partial ); |
|
| 316 | + if ( ! empty($event->title)) { |
|
| 317 | + return $calendar->get_event_html($event, $partial); |
|
| 318 | 318 | } |
| 319 | 319 | break; |
| 320 | 320 | |
| 321 | 321 | case 'if-description': |
| 322 | - if ( ! empty( $event->description ) ) { |
|
| 323 | - return $calendar->get_event_html( $event, $partial ); |
|
| 322 | + if ( ! empty($event->description)) { |
|
| 323 | + return $calendar->get_event_html($event, $partial); |
|
| 324 | 324 | } |
| 325 | 325 | break; |
| 326 | 326 | |
| 327 | 327 | case 'if-now' : |
| 328 | 328 | case 'if-not-now' : |
| 329 | 329 | |
| 330 | - $start_dt = $event->start_dt->setTimezone( $calendar->timezone ); |
|
| 330 | + $start_dt = $event->start_dt->setTimezone($calendar->timezone); |
|
| 331 | 331 | $start = $start_dt->getTimestamp(); |
| 332 | 332 | |
| 333 | - if ( $event->end_dt instanceof Carbon ) { |
|
| 334 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
| 333 | + if ($event->end_dt instanceof Carbon) { |
|
| 334 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
| 335 | 335 | } else { |
| 336 | 336 | return ''; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - $now = ( $start <= $calendar->now ) && ( $end >= $calendar->now ); |
|
| 339 | + $now = ($start <= $calendar->now) && ($end >= $calendar->now); |
|
| 340 | 340 | |
| 341 | - if ( ( 'if-now' == $tag ) && $now ) { |
|
| 342 | - return $calendar->get_event_html( $event, $partial ); |
|
| 343 | - } elseif ( ( 'if-not-now' == $tag ) && ( false == $now ) ) { |
|
| 344 | - return $calendar->get_event_html( $event, $partial ); |
|
| 341 | + if (('if-now' == $tag) && $now) { |
|
| 342 | + return $calendar->get_event_html($event, $partial); |
|
| 343 | + } elseif (('if-not-now' == $tag) && (false == $now)) { |
|
| 344 | + return $calendar->get_event_html($event, $partial); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | break; |
@@ -349,15 +349,15 @@ discard block |
||
| 349 | 349 | case 'if-started' : |
| 350 | 350 | case 'if-not-started' : |
| 351 | 351 | |
| 352 | - $start = $event->start_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
| 352 | + $start = $event->start_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
| 353 | 353 | |
| 354 | - if ( 'if-started' == $tag ) { |
|
| 355 | - if ( $start < $calendar->now ) { |
|
| 356 | - return $calendar->get_event_html( $event, $partial ); |
|
| 354 | + if ('if-started' == $tag) { |
|
| 355 | + if ($start < $calendar->now) { |
|
| 356 | + return $calendar->get_event_html($event, $partial); |
|
| 357 | 357 | } |
| 358 | - } elseif ( 'if-not-started' == $tag ) { |
|
| 359 | - if ( $start > $calendar->now ) { |
|
| 360 | - return $calendar->get_event_html( $event, $partial ); |
|
| 358 | + } elseif ('if-not-started' == $tag) { |
|
| 359 | + if ($start > $calendar->now) { |
|
| 360 | + return $calendar->get_event_html($event, $partial); |
|
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | |
@@ -366,17 +366,17 @@ discard block |
||
| 366 | 366 | case 'if-ended' : |
| 367 | 367 | case 'if-not-ended' : |
| 368 | 368 | |
| 369 | - if ( false !== $event->end ) { |
|
| 369 | + if (false !== $event->end) { |
|
| 370 | 370 | |
| 371 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
| 371 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
| 372 | 372 | |
| 373 | - if ( 'if-ended' == $tag ) { |
|
| 374 | - if ( $end < $calendar->now ) { |
|
| 375 | - return $calendar->get_event_html( $event, $partial ); |
|
| 373 | + if ('if-ended' == $tag) { |
|
| 374 | + if ($end < $calendar->now) { |
|
| 375 | + return $calendar->get_event_html($event, $partial); |
|
| 376 | 376 | } |
| 377 | - } elseif ( 'if-not-ended' == $tag ) { |
|
| 378 | - if ( $end > $calendar->now ) { |
|
| 379 | - return $calendar->get_event_html( $event, $partial ); |
|
| 377 | + } elseif ('if-not-ended' == $tag) { |
|
| 378 | + if ($end > $calendar->now) { |
|
| 379 | + return $calendar->get_event_html($event, $partial); |
|
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | |
@@ -385,14 +385,14 @@ discard block |
||
| 385 | 385 | break; |
| 386 | 386 | |
| 387 | 387 | case 'if-end-time' : |
| 388 | - if ( false !== $event->end ) { |
|
| 389 | - return $calendar->get_event_html( $event, $partial ); |
|
| 388 | + if (false !== $event->end) { |
|
| 389 | + return $calendar->get_event_html($event, $partial); |
|
| 390 | 390 | } |
| 391 | 391 | break; |
| 392 | 392 | |
| 393 | 393 | case 'if-no-end-time' : |
| 394 | - if ( false === $event->end ) { |
|
| 395 | - return $calendar->get_event_html( $event, $partial ); |
|
| 394 | + if (false === $event->end) { |
|
| 395 | + return $calendar->get_event_html($event, $partial); |
|
| 396 | 396 | } |
| 397 | 397 | break; |
| 398 | 398 | |
@@ -400,59 +400,59 @@ discard block |
||
| 400 | 400 | case 'if-whole-day' : |
| 401 | 401 | case 'if-not-all-day' : |
| 402 | 402 | case 'if-not-whole-day' : |
| 403 | - $bool = strstr( $tag, 'not' ) ? false : true; |
|
| 404 | - if ( $bool === $event->whole_day ) { |
|
| 405 | - return $calendar->get_event_html( $event, $partial ); |
|
| 403 | + $bool = strstr($tag, 'not') ? false : true; |
|
| 404 | + if ($bool === $event->whole_day) { |
|
| 405 | + return $calendar->get_event_html($event, $partial); |
|
| 406 | 406 | } |
| 407 | 407 | break; |
| 408 | 408 | |
| 409 | 409 | case 'if-recurring' : |
| 410 | - if ( ! empty( $event->recurrence ) ) { |
|
| 411 | - return $calendar->get_event_html( $event, $partial ); |
|
| 410 | + if ( ! empty($event->recurrence)) { |
|
| 411 | + return $calendar->get_event_html($event, $partial); |
|
| 412 | 412 | } |
| 413 | 413 | break; |
| 414 | 414 | |
| 415 | 415 | case 'if-not-recurring' : |
| 416 | - if ( false === $event->recurrence ) { |
|
| 417 | - return $calendar->get_event_html( $event, $partial ); |
|
| 416 | + if (false === $event->recurrence) { |
|
| 417 | + return $calendar->get_event_html($event, $partial); |
|
| 418 | 418 | } |
| 419 | 419 | break; |
| 420 | 420 | |
| 421 | 421 | case 'if-multi-day' : |
| 422 | - if ( false !== $event->multiple_days ) { |
|
| 423 | - return $calendar->get_event_html( $event, $partial ); |
|
| 422 | + if (false !== $event->multiple_days) { |
|
| 423 | + return $calendar->get_event_html($event, $partial); |
|
| 424 | 424 | } |
| 425 | 425 | break; |
| 426 | 426 | |
| 427 | 427 | case 'if-single-day' : |
| 428 | - if ( false === $event->multiple_days ) { |
|
| 429 | - return $calendar->get_event_html( $event, $partial ); |
|
| 428 | + if (false === $event->multiple_days) { |
|
| 429 | + return $calendar->get_event_html($event, $partial); |
|
| 430 | 430 | } |
| 431 | 431 | break; |
| 432 | 432 | |
| 433 | 433 | case 'if-location' : |
| 434 | 434 | case 'if-start-location' : |
| 435 | - if ( ! empty( $event->start_location['address'] ) ) { |
|
| 436 | - return $calendar->get_event_html( $event, $partial ); |
|
| 435 | + if ( ! empty($event->start_location['address'])) { |
|
| 436 | + return $calendar->get_event_html($event, $partial); |
|
| 437 | 437 | } |
| 438 | 438 | return false; |
| 439 | 439 | |
| 440 | 440 | case 'if-not-location' : |
| 441 | 441 | case 'if-not-start-location' : |
| 442 | - if ( empty( $event->start_location['address'] ) ) { |
|
| 443 | - return $calendar->get_event_html( $event, $partial ); |
|
| 442 | + if (empty($event->start_location['address'])) { |
|
| 443 | + return $calendar->get_event_html($event, $partial); |
|
| 444 | 444 | } |
| 445 | 445 | return ''; |
| 446 | 446 | |
| 447 | 447 | case 'if-not-end-location' : |
| 448 | - if ( empty( $event->end_location['address'] ) ) { |
|
| 449 | - return $calendar->get_event_html( $event, $partial ); |
|
| 448 | + if (empty($event->end_location['address'])) { |
|
| 449 | + return $calendar->get_event_html($event, $partial); |
|
| 450 | 450 | } |
| 451 | 451 | return ''; |
| 452 | 452 | |
| 453 | 453 | case 'if-end-location' : |
| 454 | - if ( ! empty( $event->end_location['address'] ) ) { |
|
| 455 | - return $calendar->get_event_html( $event, $partial ); |
|
| 454 | + if ( ! empty($event->end_location['address'])) { |
|
| 455 | + return $calendar->get_event_html($event, $partial); |
|
| 456 | 456 | } |
| 457 | 457 | return ''; |
| 458 | 458 | |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | * ======= */ |
| 462 | 462 | |
| 463 | 463 | default : |
| 464 | - return wp_kses_post( $before . $partial . $after ); |
|
| 464 | + return wp_kses_post($before.$partial.$after); |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
@@ -479,14 +479,14 @@ discard block |
||
| 479 | 479 | * |
| 480 | 480 | * @return string |
| 481 | 481 | */ |
| 482 | - private function limit_words( $text, $limit ) { |
|
| 482 | + private function limit_words($text, $limit) { |
|
| 483 | 483 | |
| 484 | - $limit = max( absint( $limit ), 0 ); |
|
| 484 | + $limit = max(absint($limit), 0); |
|
| 485 | 485 | |
| 486 | - if ( $limit > 0 && ( str_word_count( $text, 0 ) > $limit ) ) { |
|
| 487 | - $words = str_word_count( $text, 2 ); |
|
| 488 | - $pos = array_keys( $words ); |
|
| 489 | - $text = trim( substr( $text, 0, $pos[ $limit ] ) ) . '…'; |
|
| 486 | + if ($limit > 0 && (str_word_count($text, 0) > $limit)) { |
|
| 487 | + $words = str_word_count($text, 2); |
|
| 488 | + $pos = array_keys($words); |
|
| 489 | + $text = trim(substr($text, 0, $pos[$limit])).'…'; |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | return $text; |
@@ -503,26 +503,26 @@ discard block |
||
| 503 | 503 | * |
| 504 | 504 | * @return string |
| 505 | 505 | */ |
| 506 | - private function get_title( $title, $attr ) { |
|
| 506 | + private function get_title($title, $attr) { |
|
| 507 | 507 | |
| 508 | - if ( empty( $title ) ) { |
|
| 508 | + if (empty($title)) { |
|
| 509 | 509 | return ''; |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | - $attr = array_merge( array( |
|
| 513 | - 'html' => '', // Parse HTML |
|
| 514 | - 'limit' => 0, // Trim length to amount of words |
|
| 515 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 512 | + $attr = array_merge(array( |
|
| 513 | + 'html' => '', // Parse HTML |
|
| 514 | + 'limit' => 0, // Trim length to amount of words |
|
| 515 | + ), (array) shortcode_parse_atts($attr)); |
|
| 516 | 516 | |
| 517 | - if ( ! empty( $attr['html'] ) ) { |
|
| 518 | - $title = wp_kses_post( $title ); |
|
| 517 | + if ( ! empty($attr['html'])) { |
|
| 518 | + $title = wp_kses_post($title); |
|
| 519 | 519 | $tag = 'div'; |
| 520 | 520 | } else { |
| 521 | - $title = $this->limit_words( $title, $attr['limit'] ); |
|
| 521 | + $title = $this->limit_words($title, $attr['limit']); |
|
| 522 | 522 | $tag = 'span'; |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | - return '<' . $tag . ' class="simcal-event-title" itemprop="name">' . $title . '</' . $tag . '>'; |
|
| 525 | + return '<'.$tag.' class="simcal-event-title" itemprop="name">'.$title.'</'.$tag.'>'; |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | /** |
@@ -536,42 +536,42 @@ discard block |
||
| 536 | 536 | * |
| 537 | 537 | * @return string |
| 538 | 538 | */ |
| 539 | - private function get_description( $description, $attr ) { |
|
| 539 | + private function get_description($description, $attr) { |
|
| 540 | 540 | |
| 541 | - if ( empty( $description ) ) { |
|
| 541 | + if (empty($description)) { |
|
| 542 | 542 | return ''; |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | - $attr = array_merge( array( |
|
| 546 | - 'limit' => 0, // Trim length to number of words |
|
| 547 | - 'html' => 'no', // Parse HTML content |
|
| 548 | - 'markdown' => 'no', // Parse Markdown content |
|
| 549 | - 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
| 550 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 545 | + $attr = array_merge(array( |
|
| 546 | + 'limit' => 0, // Trim length to number of words |
|
| 547 | + 'html' => 'no', // Parse HTML content |
|
| 548 | + 'markdown' => 'no', // Parse Markdown content |
|
| 549 | + 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
| 550 | + ), (array) shortcode_parse_atts($attr)); |
|
| 551 | 551 | |
| 552 | - $allow_html = 'no' != $attr['html'] ? true : false; |
|
| 552 | + $allow_html = 'no' != $attr['html'] ? true : false; |
|
| 553 | 553 | $allow_md = 'no' != $attr['markdown'] ? true : false; |
| 554 | 554 | |
| 555 | 555 | $html = '<div class="simcal-event-description" itemprop="description">'; |
| 556 | 556 | |
| 557 | 557 | // Markdown and HTML don't play well together, use one or the other in the same tag. |
| 558 | - if ( $allow_html || $allow_md ) { |
|
| 559 | - if ( $allow_html ) { |
|
| 560 | - $description = wp_kses_post( $description ); |
|
| 561 | - } elseif ( $allow_md ) { |
|
| 558 | + if ($allow_html || $allow_md) { |
|
| 559 | + if ($allow_html) { |
|
| 560 | + $description = wp_kses_post($description); |
|
| 561 | + } elseif ($allow_md) { |
|
| 562 | 562 | $markdown = new \Parsedown(); |
| 563 | - $description = $markdown->text( wp_strip_all_tags( $description ) ); |
|
| 563 | + $description = $markdown->text(wp_strip_all_tags($description)); |
|
| 564 | 564 | } |
| 565 | 565 | } else { |
| 566 | - $description = wpautop( $description ); |
|
| 566 | + $description = wpautop($description); |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - $description = $this->limit_words( $description, $attr['limit'] ); |
|
| 569 | + $description = $this->limit_words($description, $attr['limit']); |
|
| 570 | 570 | |
| 571 | - $html .= $description . '</div>'; |
|
| 571 | + $html .= $description.'</div>'; |
|
| 572 | 572 | |
| 573 | - if ( 'no' != $attr['autolink'] ) { |
|
| 574 | - $html = ' ' . make_clickable( $html ); |
|
| 573 | + if ('no' != $attr['autolink']) { |
|
| 574 | + $html = ' '.make_clickable($html); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | return $html; |
@@ -587,74 +587,74 @@ discard block |
||
| 587 | 587 | * |
| 588 | 588 | * @return string |
| 589 | 589 | */ |
| 590 | - private function get_when( Event $event ) { |
|
| 590 | + private function get_when(Event $event) { |
|
| 591 | 591 | |
| 592 | - $start = $event->start_dt->setTimezone( $event->timezone ); |
|
| 593 | - $end = ! is_null( $event->end_dt ) ? $event->end_dt->setTimezone( $event->timezone ) : null; |
|
| 592 | + $start = $event->start_dt->setTimezone($event->timezone); |
|
| 593 | + $end = ! is_null($event->end_dt) ? $event->end_dt->setTimezone($event->timezone) : null; |
|
| 594 | 594 | |
| 595 | 595 | $time_start = ''; |
| 596 | 596 | $time_end = ''; |
| 597 | 597 | |
| 598 | - if ( ! $event->whole_day ) { |
|
| 598 | + if ( ! $event->whole_day) { |
|
| 599 | 599 | |
| 600 | - $time_start = $this->calendar->datetime_separator . |
|
| 601 | - ' <span class="simcal-event-start simcal-event-start-time" ' . |
|
| 602 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
| 603 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
| 604 | - 'itemprop="startDate" data-content="' . $start->toIso8601String() . '">' . |
|
| 605 | - date_i18n( $this->calendar->time_format, $start->getTimestamp() ) . |
|
| 600 | + $time_start = $this->calendar->datetime_separator. |
|
| 601 | + ' <span class="simcal-event-start simcal-event-start-time" '. |
|
| 602 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
| 603 | + 'data-event-format="'.$this->calendar->time_format.'" '. |
|
| 604 | + 'itemprop="startDate" data-content="'.$start->toIso8601String().'">'. |
|
| 605 | + date_i18n($this->calendar->time_format, $start->getTimestamp()). |
|
| 606 | 606 | '</span> '; |
| 607 | 607 | |
| 608 | - if ( $end instanceof Carbon ) { |
|
| 608 | + if ($end instanceof Carbon) { |
|
| 609 | 609 | |
| 610 | - $time_end = ' <span class="simcal-event-end simcal-event-end-time" ' . |
|
| 611 | - 'data-event-end="' . $end->getTimestamp() . '" ' . |
|
| 612 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
| 613 | - 'itemprop="endDate" data-content="' . $end->toIso8601String() . '">' . |
|
| 614 | - date_i18n( $this->calendar->time_format, $end->getTimestamp() ) . |
|
| 610 | + $time_end = ' <span class="simcal-event-end simcal-event-end-time" '. |
|
| 611 | + 'data-event-end="'.$end->getTimestamp().'" '. |
|
| 612 | + 'data-event-format="'.$this->calendar->time_format.'" '. |
|
| 613 | + 'itemprop="endDate" data-content="'.$end->toIso8601String().'">'. |
|
| 614 | + date_i18n($this->calendar->time_format, $end->getTimestamp()). |
|
| 615 | 615 | '</span> '; |
| 616 | 616 | |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | - if ( $event->multiple_days ) { |
|
| 621 | + if ($event->multiple_days) { |
|
| 622 | 622 | |
| 623 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
|
| 624 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
| 625 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
| 626 | - 'itemprop="startDate" data-content="' . $start->toIso8601String() . '">' . |
|
| 627 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
| 628 | - '</span> ' . |
|
| 623 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '. |
|
| 624 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
| 625 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
| 626 | + 'itemprop="startDate" data-content="'.$start->toIso8601String().'">'. |
|
| 627 | + date_i18n($this->calendar->date_format, $start->getTimestamp()). |
|
| 628 | + '</span> '. |
|
| 629 | 629 | $time_start; |
| 630 | 630 | |
| 631 | - if ( $end instanceof Carbon ) { |
|
| 631 | + if ($end instanceof Carbon) { |
|
| 632 | 632 | |
| 633 | - $output .= '-' . |
|
| 634 | - ' <span class="simcal-event-start simcal-event-end-date" ' . |
|
| 635 | - 'data-event-start="' . $end->getTimestamp() . '" ' . |
|
| 636 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
| 637 | - 'itemprop="endDate" data-content="' . $end->toIso8601String() . '">' . |
|
| 638 | - date_i18n( $this->calendar->date_format, $end->getTimestamp() ) . |
|
| 639 | - '</span> ' . |
|
| 633 | + $output .= '-'. |
|
| 634 | + ' <span class="simcal-event-start simcal-event-end-date" '. |
|
| 635 | + 'data-event-start="'.$end->getTimestamp().'" '. |
|
| 636 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
| 637 | + 'itemprop="endDate" data-content="'.$end->toIso8601String().'">'. |
|
| 638 | + date_i18n($this->calendar->date_format, $end->getTimestamp()). |
|
| 639 | + '</span> '. |
|
| 640 | 640 | $time_end; |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | } else { |
| 644 | 644 | |
| 645 | - $time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : ''; |
|
| 645 | + $time_end = ! empty($time_start) && ! empty($time_end) ? ' - '.$time_end : ''; |
|
| 646 | 646 | |
| 647 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
|
| 648 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
| 649 | - 'data-event-format="' . $this->calendar->date_format . '">' . |
|
| 650 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
| 651 | - '</span> ' . |
|
| 652 | - $time_start . |
|
| 647 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '. |
|
| 648 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
| 649 | + 'data-event-format="'.$this->calendar->date_format.'">'. |
|
| 650 | + date_i18n($this->calendar->date_format, $start->getTimestamp()). |
|
| 651 | + '</span> '. |
|
| 652 | + $time_start. |
|
| 653 | 653 | $time_end; |
| 654 | 654 | |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - return trim( $output ); |
|
| 657 | + return trim($output); |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | /** |
@@ -669,50 +669,50 @@ discard block |
||
| 669 | 669 | * |
| 670 | 670 | * @return string |
| 671 | 671 | */ |
| 672 | - private function get_dt( $tag, Event $event, $attr ) { |
|
| 672 | + private function get_dt($tag, Event $event, $attr) { |
|
| 673 | 673 | |
| 674 | - $bound = 0 === strpos( $tag, 'end' ) ? 'end' : 'start'; |
|
| 675 | - if ( ( 'end' == $bound ) && ( false === $event->end ) ) { |
|
| 674 | + $bound = 0 === strpos($tag, 'end') ? 'end' : 'start'; |
|
| 675 | + if (('end' == $bound) && (false === $event->end)) { |
|
| 676 | 676 | return ''; |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - $dt = $bound . '_dt'; |
|
| 680 | - if ( ! $event->$dt instanceof Carbon ) { |
|
| 679 | + $dt = $bound.'_dt'; |
|
| 680 | + if ( ! $event->$dt instanceof Carbon) { |
|
| 681 | 681 | return ''; |
| 682 | 682 | } |
| 683 | - $event_dt = $event->$dt->setTimezone( $event->timezone ); |
|
| 683 | + $event_dt = $event->$dt->setTimezone($event->timezone); |
|
| 684 | 684 | |
| 685 | - $attr = array_merge( array( |
|
| 685 | + $attr = array_merge(array( |
|
| 686 | 686 | 'format' => '', |
| 687 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 687 | + ), (array) shortcode_parse_atts($attr)); |
|
| 688 | 688 | |
| 689 | - $format = ltrim( strstr( $tag, '-' ), '-' ); |
|
| 689 | + $format = ltrim(strstr($tag, '-'), '-'); |
|
| 690 | 690 | $dt_format = ''; |
| 691 | - if ( ! empty( $attr['format'] ) ) { |
|
| 692 | - $dt_format = esc_attr( wp_strip_all_tags( $attr['format'] ) ); |
|
| 693 | - } elseif ( 'date' == $format ) { |
|
| 691 | + if ( ! empty($attr['format'])) { |
|
| 692 | + $dt_format = esc_attr(wp_strip_all_tags($attr['format'])); |
|
| 693 | + } elseif ('date' == $format) { |
|
| 694 | 694 | $dt_format = $this->calendar->date_format; |
| 695 | - } elseif ( 'time' == $format ) { |
|
| 695 | + } elseif ('time' == $format) { |
|
| 696 | 696 | $dt_format = $this->calendar->time_format; |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - if ( 'human' == $format ) { |
|
| 700 | - $value = human_time_diff( $event_dt->getTimestamp(), Carbon::now( $event->timezone )->getTimestamp() ); |
|
| 699 | + if ('human' == $format) { |
|
| 700 | + $value = human_time_diff($event_dt->getTimestamp(), Carbon::now($event->timezone)->getTimestamp()); |
|
| 701 | 701 | |
| 702 | - if ( $event_dt->getTimestamp() < Carbon::now( $event->timezone )->getTimestamp() ) { |
|
| 703 | - $value .= ' ' . _x( 'ago', 'human date event builder code modifier', 'google-calendar-events' ); |
|
| 702 | + if ($event_dt->getTimestamp() < Carbon::now($event->timezone)->getTimestamp()) { |
|
| 703 | + $value .= ' '._x('ago', 'human date event builder code modifier', 'google-calendar-events'); |
|
| 704 | 704 | } else { |
| 705 | - $value .= ' ' . _x( 'from now', 'human date event builder code modifier', 'google-calendar-events' ); |
|
| 705 | + $value .= ' '._x('from now', 'human date event builder code modifier', 'google-calendar-events'); |
|
| 706 | 706 | } |
| 707 | 707 | } else { |
| 708 | - $value = date_i18n( $dt_format, $event_dt->getTimestamp() ); |
|
| 708 | + $value = date_i18n($dt_format, $event_dt->getTimestamp()); |
|
| 709 | 709 | } |
| 710 | 710 | |
| 711 | - return '<span class="simcal-event-' . $bound . ' ' . 'simcal-event-' . $bound . '-' . $format . '" ' . |
|
| 712 | - 'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '" ' . |
|
| 713 | - 'data-event-format="' . $dt_format . '" ' . |
|
| 714 | - 'itemprop="' . $bound . 'Date" data-content="' . $event_dt->toIso8601String() . '">' . |
|
| 715 | - $value . |
|
| 711 | + return '<span class="simcal-event-'.$bound.' '.'simcal-event-'.$bound.'-'.$format.'" '. |
|
| 712 | + 'data-event-'.$bound.'="'.$event_dt->getTimestamp().'" '. |
|
| 713 | + 'data-event-format="'.$dt_format.'" '. |
|
| 714 | + 'itemprop="'.$bound.'Date" data-content="'.$event_dt->toIso8601String().'">'. |
|
| 715 | + $value. |
|
| 716 | 716 | '</span>'; |
| 717 | 717 | } |
| 718 | 718 | |
@@ -729,23 +729,23 @@ discard block |
||
| 729 | 729 | * |
| 730 | 730 | * @return string |
| 731 | 731 | */ |
| 732 | - private function make_link( $tag, $url, $content, $attr ) { |
|
| 732 | + private function make_link($tag, $url, $content, $attr) { |
|
| 733 | 733 | |
| 734 | - if ( empty( $url ) ) { |
|
| 734 | + if (empty($url)) { |
|
| 735 | 735 | return ''; |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | - $text = empty( $content ) ? $url : $content; |
|
| 738 | + $text = empty($content) ? $url : $content; |
|
| 739 | 739 | |
| 740 | - $attr = array_merge( array( |
|
| 741 | - 'autolink' => false, // Convert url to link anchor |
|
| 742 | - 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
| 743 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 740 | + $attr = array_merge(array( |
|
| 741 | + 'autolink' => false, // Convert url to link anchor |
|
| 742 | + 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
| 743 | + ), (array) shortcode_parse_atts($attr)); |
|
| 744 | 744 | |
| 745 | 745 | $anchor = $tag != 'url' ? 'yes' : $attr['autolink']; |
| 746 | 746 | $target = $attr['newwindow'] !== false ? 'target="_blank"' : ''; |
| 747 | 747 | |
| 748 | - return $anchor !== false ? ' <a href="' . esc_url( $url ) . '" ' . $target . '>' . $text . '</a>' : ' ' . $text; |
|
| 748 | + return $anchor !== false ? ' <a href="'.esc_url($url).'" '.$target.'>'.$text.'</a>' : ' '.$text; |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | /** |
@@ -758,20 +758,20 @@ discard block |
||
| 758 | 758 | * |
| 759 | 759 | * @return string |
| 760 | 760 | */ |
| 761 | - private function get_attachments( $attachments ) { |
|
| 761 | + private function get_attachments($attachments) { |
|
| 762 | 762 | |
| 763 | - $html = '<ul class="simcal-attachments">' . "\n\t"; |
|
| 763 | + $html = '<ul class="simcal-attachments">'."\n\t"; |
|
| 764 | 764 | |
| 765 | - foreach ( $attachments as $attachment ) { |
|
| 765 | + foreach ($attachments as $attachment) { |
|
| 766 | 766 | $html .= '<li class="simcal-attachment">'; |
| 767 | - $html .= '<a href="' . $attachment['url'] . '" target="_blank">'; |
|
| 768 | - $html .= ! empty( $attachment['icon'] ) ? '<img src="' . $attachment['icon'] . '" />' : ''; |
|
| 769 | - $html .= '<span>' . $attachment['name'] . '</span>'; |
|
| 767 | + $html .= '<a href="'.$attachment['url'].'" target="_blank">'; |
|
| 768 | + $html .= ! empty($attachment['icon']) ? '<img src="'.$attachment['icon'].'" />' : ''; |
|
| 769 | + $html .= '<span>'.$attachment['name'].'</span>'; |
|
| 770 | 770 | $html .= '</a>'; |
| 771 | - $html .= '</li>' . "\n"; |
|
| 771 | + $html .= '</li>'."\n"; |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - $html .= '</ul>' . "\n"; |
|
| 774 | + $html .= '</ul>'."\n"; |
|
| 775 | 775 | |
| 776 | 776 | return $html; |
| 777 | 777 | } |
@@ -787,41 +787,41 @@ discard block |
||
| 787 | 787 | * |
| 788 | 788 | * @return string |
| 789 | 789 | */ |
| 790 | - private function get_attendees( $attendees, $attr ) { |
|
| 790 | + private function get_attendees($attendees, $attr) { |
|
| 791 | 791 | |
| 792 | - $attr = array_merge( array( |
|
| 793 | - 'photo' => 'show', // show/hide attendee photo |
|
| 794 | - 'email' => 'hide', // show/hide attendee email address |
|
| 795 | - 'rsvp' => 'hide', // show/hide rsvp response status |
|
| 796 | - 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
| 797 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 792 | + $attr = array_merge(array( |
|
| 793 | + 'photo' => 'show', // show/hide attendee photo |
|
| 794 | + 'email' => 'hide', // show/hide attendee email address |
|
| 795 | + 'rsvp' => 'hide', // show/hide rsvp response status |
|
| 796 | + 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
| 797 | + ), (array) shortcode_parse_atts($attr)); |
|
| 798 | 798 | |
| 799 | - $html = '<ul class="simcal-attendees" itemprop="attendees">' . "\n\t"; |
|
| 799 | + $html = '<ul class="simcal-attendees" itemprop="attendees">'."\n\t"; |
|
| 800 | 800 | |
| 801 | 801 | $known = 0; |
| 802 | 802 | $unknown = 0; |
| 803 | 803 | |
| 804 | - foreach ( $attendees as $attendee ) { |
|
| 804 | + foreach ($attendees as $attendee) { |
|
| 805 | 805 | |
| 806 | - if ( 'yes' == $attr['response'] && 'yes' != $attendee['response'] ) { |
|
| 806 | + if ('yes' == $attr['response'] && 'yes' != $attendee['response']) { |
|
| 807 | 807 | continue; |
| 808 | - } elseif ( 'no' == $attr['response'] && 'no' != $attendee['response'] ) { |
|
| 808 | + } elseif ('no' == $attr['response'] && 'no' != $attendee['response']) { |
|
| 809 | 809 | continue; |
| 810 | - } elseif ( 'maybe' == $attr['response'] && ! in_array( $attendee['response'], array( 'yes', 'maybe' ) ) ) { |
|
| 810 | + } elseif ('maybe' == $attr['response'] && ! in_array($attendee['response'], array('yes', 'maybe'))) { |
|
| 811 | 811 | continue; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | - if ( ! empty( $attendee['name'] ) ) { |
|
| 814 | + if ( ! empty($attendee['name'])) { |
|
| 815 | 815 | |
| 816 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $attendee['photo'] . '" itemprop="image" />' : ''; |
|
| 817 | - $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response( $attendee['response'] ) : ''; |
|
| 818 | - $guest = $photo . '<span itemprop="name">' . $attendee['name'] . $response . '</span>'; |
|
| 816 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$attendee['photo'].'" itemprop="image" />' : ''; |
|
| 817 | + $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response($attendee['response']) : ''; |
|
| 818 | + $guest = $photo.'<span itemprop="name">'.$attendee['name'].$response.'</span>'; |
|
| 819 | 819 | |
| 820 | - if ( ! empty( $attendee['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
| 821 | - $guest = sprintf( '<a href="mailto:' . $attendee['email'] . '" itemprop="email">%s</a>', $guest ); |
|
| 820 | + if ( ! empty($attendee['email']) && ('show' == $attr['email'])) { |
|
| 821 | + $guest = sprintf('<a href="mailto:'.$attendee['email'].'" itemprop="email">%s</a>', $guest); |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | - $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">' . $guest . '</li>' . "\n"; |
|
| 824 | + $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">'.$guest.'</li>'."\n"; |
|
| 825 | 825 | |
| 826 | 826 | $known++; |
| 827 | 827 | |
@@ -832,21 +832,21 @@ discard block |
||
| 832 | 832 | } |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - if ( $unknown > 0 ) { |
|
| 836 | - if ( $known > 0 ) { |
|
| 835 | + if ($unknown > 0) { |
|
| 836 | + if ($known > 0) { |
|
| 837 | 837 | /* translators: One more person attending the event. */ |
| 838 | - $others = sprintf( _n( '1 more attendee', '%s more attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
| 838 | + $others = sprintf(_n('1 more attendee', '%s more attendees', $unknown, 'google-calendar-events'), $unknown); |
|
| 839 | 839 | } else { |
| 840 | 840 | /* translators: One or more persons attending the event whose name is unknown. */ |
| 841 | - $others = sprintf( _n( '1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
| 841 | + $others = sprintf(_n('1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events'), $unknown); |
|
| 842 | 842 | } |
| 843 | - $photo = $attr['photo'] !== 'hide' ? get_avatar( '', 128 ) : ''; |
|
| 844 | - $html .= '<li class="simcal-attendee simcal-attendee-anonymous">' . $photo . '<span>' . $others . '</span></li>' . "\n"; |
|
| 845 | - } elseif ( $known === 0 ) { |
|
| 846 | - $html .= '<li class="simcal-attendee">' . _x( 'No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events' ) . '</li>' . "\n"; |
|
| 843 | + $photo = $attr['photo'] !== 'hide' ? get_avatar('', 128) : ''; |
|
| 844 | + $html .= '<li class="simcal-attendee simcal-attendee-anonymous">'.$photo.'<span>'.$others.'</span></li>'."\n"; |
|
| 845 | + } elseif ($known === 0) { |
|
| 846 | + $html .= '<li class="simcal-attendee">'._x('No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events').'</li>'."\n"; |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | - $html .= '</ul>' . "\n"; |
|
| 849 | + $html .= '</ul>'."\n"; |
|
| 850 | 850 | |
| 851 | 851 | return $html; |
| 852 | 852 | } |
@@ -860,23 +860,23 @@ discard block |
||
| 860 | 860 | * |
| 861 | 861 | * @return string |
| 862 | 862 | */ |
| 863 | - private function get_rsvp_response( $response ) { |
|
| 863 | + private function get_rsvp_response($response) { |
|
| 864 | 864 | |
| 865 | - if ( 'yes' == $response ) { |
|
| 865 | + if ('yes' == $response) { |
|
| 866 | 866 | /* translators: Someone replied with 'yes' to a rsvp request. */ |
| 867 | - $rsvp = __( 'Attending', 'google-calendar-events' ); |
|
| 868 | - } elseif ( 'no' == $response ) { |
|
| 867 | + $rsvp = __('Attending', 'google-calendar-events'); |
|
| 868 | + } elseif ('no' == $response) { |
|
| 869 | 869 | /* translators: Someone replied with 'no' to a rsvp request. */ |
| 870 | - $rsvp = __( 'Not attending', 'google-calendar-events' ); |
|
| 871 | - } elseif ( 'maybe' == $response ) { |
|
| 870 | + $rsvp = __('Not attending', 'google-calendar-events'); |
|
| 871 | + } elseif ('maybe' == $response) { |
|
| 872 | 872 | /* translators: Someone replied with 'maybe' to a rsvp request. */ |
| 873 | - $rsvp = __( 'Maybe attending', 'google-calendar-events' ); |
|
| 873 | + $rsvp = __('Maybe attending', 'google-calendar-events'); |
|
| 874 | 874 | } else { |
| 875 | 875 | /* translators: Someone did not send yet a rsvp confirmation to join an event. */ |
| 876 | - $rsvp = __( 'Response pending', 'google-calendar-events' ); |
|
| 876 | + $rsvp = __('Response pending', 'google-calendar-events'); |
|
| 877 | 877 | } |
| 878 | 878 | |
| 879 | - return ' <small>(' . $rsvp . ')</small>'; |
|
| 879 | + return ' <small>('.$rsvp.')</small>'; |
|
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | /** |
@@ -890,21 +890,21 @@ discard block |
||
| 890 | 890 | * |
| 891 | 891 | * @return string |
| 892 | 892 | */ |
| 893 | - private function get_organizer( $organizer, $attr ) { |
|
| 893 | + private function get_organizer($organizer, $attr) { |
|
| 894 | 894 | |
| 895 | - $attr = array_merge( array( |
|
| 896 | - 'photo' => 'show', // show/hide attendee photo |
|
| 897 | - 'email' => 'hide', // show/hide attendee email address |
|
| 898 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 895 | + $attr = array_merge(array( |
|
| 896 | + 'photo' => 'show', // show/hide attendee photo |
|
| 897 | + 'email' => 'hide', // show/hide attendee email address |
|
| 898 | + ), (array) shortcode_parse_atts($attr)); |
|
| 899 | 899 | |
| 900 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $organizer['photo'] . '" itemprop="image" />' : ''; |
|
| 901 | - $organizer_html = $photo . '<span itemprop="name">' . $organizer['name'] . '</span>'; |
|
| 900 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$organizer['photo'].'" itemprop="image" />' : ''; |
|
| 901 | + $organizer_html = $photo.'<span itemprop="name">'.$organizer['name'].'</span>'; |
|
| 902 | 902 | |
| 903 | - if ( ! empty( $organizer['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
| 904 | - $organizer_html = sprintf( '<a href="mailto:' . $organizer['email'] . '" itemprop="email">%s</a>', $organizer_html ); |
|
| 903 | + if ( ! empty($organizer['email']) && ('show' == $attr['email'])) { |
|
| 904 | + $organizer_html = sprintf('<a href="mailto:'.$organizer['email'].'" itemprop="email">%s</a>', $organizer_html); |
|
| 905 | 905 | } |
| 906 | 906 | |
| 907 | - return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">' . $organizer_html . '</div>'; |
|
| 907 | + return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">'.$organizer_html.'</div>'; |
|
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | /** |
@@ -929,7 +929,7 @@ discard block |
||
| 929 | 929 | // This is largely borrowed on get_shortcode_regex() from WordPress Core. |
| 930 | 930 | // @see /wp-includes/shortcodes.php (with some modification) |
| 931 | 931 | |
| 932 | - $tagregexp = implode( '|', array_values( $this->tags ) ); |
|
| 932 | + $tagregexp = implode('|', array_values($this->tags)); |
|
| 933 | 933 | |
| 934 | 934 | return '/' |
| 935 | 935 | . '\\[' // Opening bracket |
@@ -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> |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | */ |
| 7 | 7 | namespace SimpleCalendar\Calendars\Admin; |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if ( ! defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct() { |
| 26 | 26 | |
| 27 | - if ( simcal_is_admin_screen() !== false ) { |
|
| 28 | - add_action( 'simcal_settings_meta_calendar_panel', array( $this, 'add_settings_meta_calendar_panel' ), 10, 1 ); |
|
| 27 | + if (simcal_is_admin_screen() !== false) { |
|
| 28 | + add_action('simcal_settings_meta_calendar_panel', array($this, 'add_settings_meta_calendar_panel'), 10, 1); |
|
| 29 | 29 | } |
| 30 | - add_action( 'simcal_process_settings_meta', array( $this, 'process_meta' ), 10, 1 ); |
|
| 30 | + add_action('simcal_process_settings_meta', array($this, 'process_meta'), 10, 1); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -76,47 +76,47 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @param int $post_id |
| 78 | 78 | */ |
| 79 | - public function add_settings_meta_calendar_panel( $post_id ) { |
|
| 79 | + public function add_settings_meta_calendar_panel($post_id) { |
|
| 80 | 80 | |
| 81 | 81 | ?> |
| 82 | 82 | <table id="default-calendar-settings"> |
| 83 | 83 | <thead> |
| 84 | - <tr><th colspan="2"><?php _e( 'Default Calendar', 'google-calendar-events' ); ?></th></tr> |
|
| 84 | + <tr><th colspan="2"><?php _e('Default Calendar', 'google-calendar-events'); ?></th></tr> |
|
| 85 | 85 | </thead> |
| 86 | 86 | <tbody class="simcal-panel-section"> |
| 87 | 87 | |
| 88 | 88 | <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> |
| 89 | - <th><label for="_default_calendar_event_bubbles_action"><?php _e( 'Event Bubbles', 'google-calendar-events' ); ?></label></th> |
|
| 89 | + <th><label for="_default_calendar_event_bubbles_action"><?php _e('Event Bubbles', 'google-calendar-events'); ?></label></th> |
|
| 90 | 90 | <td> |
| 91 | 91 | <?php |
| 92 | 92 | |
| 93 | - $bubbles = get_post_meta( $post_id, '_default_calendar_event_bubble_trigger', true ); |
|
| 93 | + $bubbles = get_post_meta($post_id, '_default_calendar_event_bubble_trigger', true); |
|
| 94 | 94 | |
| 95 | - simcal_print_field( array( |
|
| 95 | + simcal_print_field(array( |
|
| 96 | 96 | 'type' => 'radio', |
| 97 | 97 | 'inline' => 'inline', |
| 98 | 98 | 'name' => '_default_calendar_event_bubble_trigger', |
| 99 | 99 | 'id' => '_default_calendar_event_bubble_trigger', |
| 100 | - 'tooltip' => __( 'Open event bubbles in calendar grid by clicking or hovering on event titles. On mobile devices it will always default to tapping.', 'google-calendar-events' ), |
|
| 100 | + 'tooltip' => __('Open event bubbles in calendar grid by clicking or hovering on event titles. On mobile devices it will always default to tapping.', 'google-calendar-events'), |
|
| 101 | 101 | 'value' => $bubbles ? $bubbles : 'hover', |
| 102 | 102 | 'default' => 'hover', |
| 103 | 103 | 'options' => array( |
| 104 | - 'click' => __( 'Click', 'google-calendar-events' ), |
|
| 105 | - 'hover' => __( 'Hover', 'google-calendar-events' ), |
|
| 104 | + 'click' => __('Click', 'google-calendar-events'), |
|
| 105 | + 'hover' => __('Hover', 'google-calendar-events'), |
|
| 106 | 106 | ), |
| 107 | - ) ); |
|
| 107 | + )); |
|
| 108 | 108 | |
| 109 | 109 | ?> |
| 110 | 110 | </td> |
| 111 | 111 | </tr> |
| 112 | 112 | <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> |
| 113 | - <th><label for="_default_calendar_trim_titles"><?php _e( 'Trim Event Titles', 'google-calendar-events' ); ?></label></th> |
|
| 113 | + <th><label for="_default_calendar_trim_titles"><?php _e('Trim Event Titles', 'google-calendar-events'); ?></label></th> |
|
| 114 | 114 | <td> |
| 115 | 115 | <?php |
| 116 | 116 | |
| 117 | - $trim = get_post_meta( $post_id, '_default_calendar_trim_titles', true ); |
|
| 117 | + $trim = get_post_meta($post_id, '_default_calendar_trim_titles', true); |
|
| 118 | 118 | |
| 119 | - simcal_print_field( array( |
|
| 119 | + simcal_print_field(array( |
|
| 120 | 120 | 'type' => 'checkbox', |
| 121 | 121 | 'name' => '_default_calendar_trim_titles', |
| 122 | 122 | 'id' => '_default_calendar_trim_titles', |
@@ -127,34 +127,34 @@ discard block |
||
| 127 | 127 | 'attributes' => array( |
| 128 | 128 | 'data-show-next-if-value' => 'yes', |
| 129 | 129 | ), |
| 130 | - ) ); |
|
| 130 | + )); |
|
| 131 | 131 | |
| 132 | - simcal_print_field( array( |
|
| 132 | + simcal_print_field(array( |
|
| 133 | 133 | 'type' => 'standard', |
| 134 | 134 | 'subtype' => 'number', |
| 135 | 135 | 'name' => '_default_calendar_trim_titles_chars', |
| 136 | 136 | 'id' => '_default_calendar_trim_titles_chars', |
| 137 | - 'tooltip' => __( 'Shorten event titles in calendar grid to a specified length in characters.', 'google-calendar-events' ), |
|
| 137 | + 'tooltip' => __('Shorten event titles in calendar grid to a specified length in characters.', 'google-calendar-events'), |
|
| 138 | 138 | 'class' => array( |
| 139 | 139 | 'simcal-field-tiny', |
| 140 | 140 | ), |
| 141 | - 'value' => 'yes' == $trim ? strval( max( absint( get_post_meta( $post_id, '_default_calendar_trim_titles_chars', true ) ), 1 ) ) : '20', |
|
| 141 | + 'value' => 'yes' == $trim ? strval(max(absint(get_post_meta($post_id, '_default_calendar_trim_titles_chars', true)), 1)) : '20', |
|
| 142 | 142 | 'attributes' => array( |
| 143 | 143 | 'min' => '1', |
| 144 | 144 | ), |
| 145 | - ) ); |
|
| 145 | + )); |
|
| 146 | 146 | |
| 147 | 147 | ?> |
| 148 | 148 | </td> |
| 149 | 149 | </tr> |
| 150 | 150 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
| 151 | - <th><label for="_default_calendar_list_grouped_span"><?php _e( 'Span', 'google-calendar-events' ); ?></label></th> |
|
| 151 | + <th><label for="_default_calendar_list_grouped_span"><?php _e('Span', 'google-calendar-events'); ?></label></th> |
|
| 152 | 152 | <td> |
| 153 | 153 | <?php |
| 154 | 154 | |
| 155 | - $list_span = max( absint( get_post_meta( $post_id, '_default_calendar_list_range_span', true ) ), 1 ); |
|
| 155 | + $list_span = max(absint(get_post_meta($post_id, '_default_calendar_list_range_span', true)), 1); |
|
| 156 | 156 | |
| 157 | - simcal_print_field( array( |
|
| 157 | + simcal_print_field(array( |
|
| 158 | 158 | 'type' => 'standard', |
| 159 | 159 | 'subtype' => 'number', |
| 160 | 160 | 'name' => '_default_calendar_list_range_span', |
@@ -163,78 +163,78 @@ discard block |
||
| 163 | 163 | 'simcal-field-tiny', |
| 164 | 164 | 'simcal-field-inline', |
| 165 | 165 | ), |
| 166 | - 'value' => strval( $list_span ), |
|
| 166 | + 'value' => strval($list_span), |
|
| 167 | 167 | 'attributes' => array( |
| 168 | 168 | 'min' => '1', |
| 169 | 169 | ), |
| 170 | - ) ); |
|
| 170 | + )); |
|
| 171 | 171 | |
| 172 | - $list_type = get_post_meta( $post_id, '_default_calendar_list_range_type', true ); |
|
| 172 | + $list_type = get_post_meta($post_id, '_default_calendar_list_range_type', true); |
|
| 173 | 173 | |
| 174 | - simcal_print_field( array( |
|
| 174 | + simcal_print_field(array( |
|
| 175 | 175 | 'type' => 'select', |
| 176 | 176 | 'name' => '_default_calendar_list_range_type', |
| 177 | 177 | 'id' => '_default_calendar_list_range_type', |
| 178 | - 'tooltip' => __( 'Range of events to show on each calendar page.', 'google-calendar-events' ), |
|
| 178 | + 'tooltip' => __('Range of events to show on each calendar page.', 'google-calendar-events'), |
|
| 179 | 179 | 'class' => array( |
| 180 | 180 | 'simcal-field-inline', |
| 181 | 181 | ), |
| 182 | 182 | 'value' => $list_type, |
| 183 | 183 | 'options' => array( |
| 184 | - 'monthly' => __( 'Month(s)', 'google-calendar-events' ), |
|
| 185 | - 'weekly' => __( 'Week(s)', 'google-calendar-events' ), |
|
| 186 | - 'daily' => __( 'Day(s)', 'google-calendar-events' ), |
|
| 187 | - 'events' => __( 'Event(s)', 'google-calendar-events' ), |
|
| 184 | + 'monthly' => __('Month(s)', 'google-calendar-events'), |
|
| 185 | + 'weekly' => __('Week(s)', 'google-calendar-events'), |
|
| 186 | + 'daily' => __('Day(s)', 'google-calendar-events'), |
|
| 187 | + 'events' => __('Event(s)', 'google-calendar-events'), |
|
| 188 | 188 | ), |
| 189 | - ) ); |
|
| 189 | + )); |
|
| 190 | 190 | |
| 191 | 191 | ?> |
| 192 | 192 | </td> |
| 193 | 193 | </tr> |
| 194 | 194 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
| 195 | - <th><label for="_default_calendar_list_header"><?php _e( 'Hide Header', 'google-calendar-events' ); ?></label></th> |
|
| 195 | + <th><label for="_default_calendar_list_header"><?php _e('Hide Header', 'google-calendar-events'); ?></label></th> |
|
| 196 | 196 | <td> |
| 197 | 197 | <?php |
| 198 | 198 | |
| 199 | - $header = get_post_meta( $post_id, '_default_calendar_list_header', true ); |
|
| 199 | + $header = get_post_meta($post_id, '_default_calendar_list_header', true); |
|
| 200 | 200 | |
| 201 | - simcal_print_field( array( |
|
| 201 | + simcal_print_field(array( |
|
| 202 | 202 | 'type' => 'checkbox', |
| 203 | 203 | 'name' => '_default_calendar_list_header', |
| 204 | 204 | 'id' => '_default_calendar_list_header', |
| 205 | - 'tooltip' => __( 'You can use this to hide the month header for this calendar.', 'google-calendar-events' ), |
|
| 205 | + 'tooltip' => __('You can use this to hide the month header for this calendar.', 'google-calendar-events'), |
|
| 206 | 206 | 'value' => 'yes' == $header ? 'yes' : 'no', |
| 207 | - ) ); |
|
| 207 | + )); |
|
| 208 | 208 | |
| 209 | 209 | ?> |
| 210 | 210 | </td> |
| 211 | 211 | </tr> |
| 212 | 212 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
| 213 | - <th><label for="_default_calendar_compact_list"><?php _e( 'Compact List', 'google-calendar-events' ); ?></label></th> |
|
| 213 | + <th><label for="_default_calendar_compact_list"><?php _e('Compact List', 'google-calendar-events'); ?></label></th> |
|
| 214 | 214 | <td> |
| 215 | 215 | <?php |
| 216 | 216 | |
| 217 | - $compact = get_post_meta( $post_id, '_default_calendar_compact_list', true ); |
|
| 217 | + $compact = get_post_meta($post_id, '_default_calendar_compact_list', true); |
|
| 218 | 218 | |
| 219 | - simcal_print_field( array( |
|
| 219 | + simcal_print_field(array( |
|
| 220 | 220 | 'type' => 'checkbox', |
| 221 | 221 | 'name' => '_default_calendar_compact_list', |
| 222 | 222 | 'id' => '_default_calendar_compact_list', |
| 223 | - 'tooltip' => __( 'Make an events list more compact by grouping together events from different days in a single list.', 'google-calendar-events' ), |
|
| 223 | + 'tooltip' => __('Make an events list more compact by grouping together events from different days in a single list.', 'google-calendar-events'), |
|
| 224 | 224 | 'value' => 'yes' == $compact ? 'yes' : 'no', |
| 225 | - ) ); |
|
| 225 | + )); |
|
| 226 | 226 | |
| 227 | 227 | ?> |
| 228 | 228 | </td> |
| 229 | 229 | </tr> |
| 230 | 230 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 231 | - <th><label for="_default_calendar_limit_visible_events"><?php _e( 'Limit Visible Events', 'google-calendar-events' ); ?></label></th> |
|
| 231 | + <th><label for="_default_calendar_limit_visible_events"><?php _e('Limit Visible Events', 'google-calendar-events'); ?></label></th> |
|
| 232 | 232 | <td> |
| 233 | 233 | <?php |
| 234 | 234 | |
| 235 | - $limit = get_post_meta( $post_id, '_default_calendar_limit_visible_events', true ); |
|
| 235 | + $limit = get_post_meta($post_id, '_default_calendar_limit_visible_events', true); |
|
| 236 | 236 | |
| 237 | - simcal_print_field( array( |
|
| 237 | + simcal_print_field(array( |
|
| 238 | 238 | 'type' => 'checkbox', |
| 239 | 239 | 'name' => '_default_calendar_limit_visible_events', |
| 240 | 240 | 'id' => '_default_calendar_limit_visible_events', |
@@ -245,17 +245,17 @@ discard block |
||
| 245 | 245 | 'attributes' => array( |
| 246 | 246 | 'data-show-next-if-value' => 'yes', |
| 247 | 247 | ) |
| 248 | - ) ); |
|
| 248 | + )); |
|
| 249 | 249 | |
| 250 | - $visible_events = absint( get_post_meta( $post_id, '_default_calendar_visible_events', true ) ); |
|
| 250 | + $visible_events = absint(get_post_meta($post_id, '_default_calendar_visible_events', true)); |
|
| 251 | 251 | $visible_events = $visible_events > 0 ? $visible_events : 3; |
| 252 | 252 | |
| 253 | - simcal_print_field( array( |
|
| 253 | + simcal_print_field(array( |
|
| 254 | 254 | 'type' => 'standard', |
| 255 | 255 | 'subtype' => 'number', |
| 256 | 256 | 'name' => '_default_calendar_visible_events', |
| 257 | 257 | 'id' => '_default_calendar_visible_events', |
| 258 | - 'tooltip' => __( 'Limit the number of initial visible events on each day to a set maximum.', 'google-calendar-events' ), |
|
| 258 | + 'tooltip' => __('Limit the number of initial visible events on each day to a set maximum.', 'google-calendar-events'), |
|
| 259 | 259 | 'class' => array( |
| 260 | 260 | 'simcal-field-tiny', |
| 261 | 261 | ), |
@@ -263,39 +263,39 @@ discard block |
||
| 263 | 263 | 'attributes' => array( |
| 264 | 264 | 'min' => '1', |
| 265 | 265 | ) |
| 266 | - ) ); |
|
| 266 | + )); |
|
| 267 | 267 | |
| 268 | 268 | ?> |
| 269 | 269 | </td> |
| 270 | 270 | </tr> |
| 271 | 271 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 272 | - <th><label for="_default_calendar_event_bubbles_action"><?php _e( 'Expand Multi-day Events', 'google-calendar-events' ); ?></label></th> |
|
| 272 | + <th><label for="_default_calendar_event_bubbles_action"><?php _e('Expand Multi-day Events', 'google-calendar-events'); ?></label></th> |
|
| 273 | 273 | <td> |
| 274 | 274 | <?php |
| 275 | 275 | |
| 276 | - $post_meta = get_post_meta( $post_id ); |
|
| 276 | + $post_meta = get_post_meta($post_id); |
|
| 277 | 277 | |
| 278 | - if ( ! is_array( $post_meta ) && ! empty( $post_meta ) ) { |
|
| 278 | + if ( ! is_array($post_meta) && ! empty($post_meta)) { |
|
| 279 | 279 | $multi_day_value = 'current_day_only'; |
| 280 | 280 | } else { |
| 281 | - $multi_day_value = get_post_meta( $post_id, '_default_calendar_expand_multi_day_events', true ); |
|
| 281 | + $multi_day_value = get_post_meta($post_id, '_default_calendar_expand_multi_day_events', true); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - simcal_print_field( array( |
|
| 284 | + simcal_print_field(array( |
|
| 285 | 285 | 'type' => 'select', |
| 286 | 286 | 'name' => '_default_calendar_expand_multi_day_events', |
| 287 | 287 | 'id' => '_default_calendar_expand_multi_day_events', |
| 288 | - 'tooltip' => __( 'For events spanning multiple days, you can display them on each day of the event, ' . |
|
| 289 | - 'only on the first day of the event, or on all days of the event, but only up to the current day. ' . |
|
| 290 | - 'Third option applies to list views only.', 'google-calendar-events' ), |
|
| 288 | + 'tooltip' => __('For events spanning multiple days, you can display them on each day of the event, '. |
|
| 289 | + 'only on the first day of the event, or on all days of the event, but only up to the current day. '. |
|
| 290 | + 'Third option applies to list views only.', 'google-calendar-events'), |
|
| 291 | 291 | 'value' => $multi_day_value, |
| 292 | 292 | 'options' => array( |
| 293 | - 'yes' => __( 'Yes, display on all days of event', 'google-calendar-events' ), |
|
| 294 | - 'no' => __( 'No, display only on first day of event', 'google-calendar-events' ), |
|
| 295 | - 'current_day_only' => __( 'No, display on all days of event up to current day (list view only)', 'google-calendar-events' ), |
|
| 293 | + 'yes' => __('Yes, display on all days of event', 'google-calendar-events'), |
|
| 294 | + 'no' => __('No, display only on first day of event', 'google-calendar-events'), |
|
| 295 | + 'current_day_only' => __('No, display on all days of event up to current day (list view only)', 'google-calendar-events'), |
|
| 296 | 296 | ), |
| 297 | 297 | 'default' => 'current_day_only', |
| 298 | - ) ); |
|
| 298 | + )); |
|
| 299 | 299 | |
| 300 | 300 | ?> |
| 301 | 301 | </td> |
@@ -303,72 +303,72 @@ discard block |
||
| 303 | 303 | </tbody> |
| 304 | 304 | <?php |
| 305 | 305 | |
| 306 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
| 307 | - $default_theme = isset( $settings['default-calendar']['theme'] ) ? $settings['default-calendar']['theme'] : 'light'; |
|
| 306 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
| 307 | + $default_theme = isset($settings['default-calendar']['theme']) ? $settings['default-calendar']['theme'] : 'light'; |
|
| 308 | 308 | $default_today_color = /*isset( $settings['default-calendar']['today_color'] ) ? $settings['default-calendar']['today_color'] :*/ '#1e73be'; |
| 309 | 309 | $default_days_events_color = /*isset( $settings['default-calendar']['days_events_color'] ) ? $settings['default-calendar']['days_events_color'] :*/ '#000000'; |
| 310 | 310 | |
| 311 | 311 | ?> |
| 312 | 312 | <tbody class="simcal-panel-section"> |
| 313 | 313 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 314 | - <th><label for="_default_calendar_style_theme"><?php _e( 'Theme', 'google-calendar-events' ); ?></label></th> |
|
| 314 | + <th><label for="_default_calendar_style_theme"><?php _e('Theme', 'google-calendar-events'); ?></label></th> |
|
| 315 | 315 | <td> |
| 316 | 316 | <?php |
| 317 | 317 | |
| 318 | - $saved = get_post_meta( $post_id, '_default_calendar_style_theme', true ); |
|
| 318 | + $saved = get_post_meta($post_id, '_default_calendar_style_theme', true); |
|
| 319 | 319 | $value = ! $saved ? $default_theme : $saved; |
| 320 | 320 | |
| 321 | - simcal_print_field( array( |
|
| 321 | + simcal_print_field(array( |
|
| 322 | 322 | 'type' => 'select', |
| 323 | 323 | 'name' => '_default_calendar_style_theme', |
| 324 | 324 | 'id' => '_default_calendar_style_theme', |
| 325 | 325 | 'value' => $value, |
| 326 | - 'tooltip' => __( 'Choose a calendar theme to match your site theme.', 'google-calendar-events' ), |
|
| 326 | + 'tooltip' => __('Choose a calendar theme to match your site theme.', 'google-calendar-events'), |
|
| 327 | 327 | 'options' => array( |
| 328 | - 'light' => __( 'Light', 'google-calendar-events' ), |
|
| 329 | - 'dark' => __( 'Dark', 'google-calendar-events' ), |
|
| 328 | + 'light' => __('Light', 'google-calendar-events'), |
|
| 329 | + 'dark' => __('Dark', 'google-calendar-events'), |
|
| 330 | 330 | ), |
| 331 | - ) ); |
|
| 331 | + )); |
|
| 332 | 332 | |
| 333 | 333 | ?> |
| 334 | 334 | </td> |
| 335 | 335 | </tr> |
| 336 | 336 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 337 | - <th><label for="_default_calendar_style_today"><?php _e( 'Today', 'google-calendar-events' ); ?></label></th> |
|
| 337 | + <th><label for="_default_calendar_style_today"><?php _e('Today', 'google-calendar-events'); ?></label></th> |
|
| 338 | 338 | <td> |
| 339 | 339 | <?php |
| 340 | 340 | |
| 341 | - $saved = get_post_meta( $post_id, '_default_calendar_style_today', true ); |
|
| 341 | + $saved = get_post_meta($post_id, '_default_calendar_style_today', true); |
|
| 342 | 342 | $value = ! $saved ? $default_today_color : $saved; |
| 343 | 343 | |
| 344 | - simcal_print_field( array( |
|
| 344 | + simcal_print_field(array( |
|
| 345 | 345 | 'type' => 'standard', |
| 346 | 346 | 'subtype' => 'color-picker', |
| 347 | 347 | 'name' => '_default_calendar_style_today', |
| 348 | 348 | 'id' => '_default_calendar_style_today', |
| 349 | 349 | 'value' => $value, |
| 350 | - 'tooltip' => __( "This option will set the background color for today's date. It will change the day number background and the border around the current day.", 'google-calendar-events' ), |
|
| 351 | - ) ); |
|
| 350 | + 'tooltip' => __("This option will set the background color for today's date. It will change the day number background and the border around the current day.", 'google-calendar-events'), |
|
| 351 | + )); |
|
| 352 | 352 | |
| 353 | 353 | ?> |
| 354 | 354 | </td> |
| 355 | 355 | </tr> |
| 356 | 356 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 357 | - <th><label for="_default_calendar_style_days_events"><?php _e( 'Days with Events', 'google-calendar-events' ); ?></label></th> |
|
| 357 | + <th><label for="_default_calendar_style_days_events"><?php _e('Days with Events', 'google-calendar-events'); ?></label></th> |
|
| 358 | 358 | <td> |
| 359 | 359 | <?php |
| 360 | 360 | |
| 361 | - $saved = get_post_meta( $post_id, '_default_calendar_style_days_events', true ); |
|
| 361 | + $saved = get_post_meta($post_id, '_default_calendar_style_days_events', true); |
|
| 362 | 362 | $value = ! $saved ? $default_days_events_color : $saved; |
| 363 | 363 | |
| 364 | - simcal_print_field( array( |
|
| 364 | + simcal_print_field(array( |
|
| 365 | 365 | 'type' => 'standard', |
| 366 | 366 | 'subtype' => 'color-picker', |
| 367 | 367 | 'name' => '_default_calendar_style_days_events', |
| 368 | 368 | 'id' => '_default_calendar_style_days_events', |
| 369 | 369 | 'value' => $value, |
| 370 | - 'tooltip' => __( 'This setting will modify the day number background for any days that have events on them.', 'google-calendar-events' ), |
|
| 371 | - ) ); |
|
| 370 | + 'tooltip' => __('This setting will modify the day number background for any days that have events on them.', 'google-calendar-events'), |
|
| 371 | + )); |
|
| 372 | 372 | |
| 373 | 373 | ?> |
| 374 | 374 | </td> |
@@ -390,55 +390,55 @@ discard block |
||
| 390 | 390 | * |
| 391 | 391 | * @param int $post_id |
| 392 | 392 | */ |
| 393 | - public function process_meta( $post_id ) { |
|
| 393 | + public function process_meta($post_id) { |
|
| 394 | 394 | |
| 395 | 395 | // Theme. |
| 396 | - $theme = isset( $_POST['_default_calendar_style_theme'] ) ? sanitize_key( $_POST['_default_calendar_style_theme'] ) : 'light'; |
|
| 397 | - update_post_meta( $post_id, '_default_calendar_style_theme', $theme ); |
|
| 396 | + $theme = isset($_POST['_default_calendar_style_theme']) ? sanitize_key($_POST['_default_calendar_style_theme']) : 'light'; |
|
| 397 | + update_post_meta($post_id, '_default_calendar_style_theme', $theme); |
|
| 398 | 398 | |
| 399 | 399 | // Today color. |
| 400 | - $today_color = isset( $_POST['_default_calendar_style_today'] ) ? sanitize_text_field( $_POST['_default_calendar_style_today'] ) : '#FF000'; |
|
| 401 | - update_post_meta( $post_id, '_default_calendar_style_today', $today_color ); |
|
| 400 | + $today_color = isset($_POST['_default_calendar_style_today']) ? sanitize_text_field($_POST['_default_calendar_style_today']) : '#FF000'; |
|
| 401 | + update_post_meta($post_id, '_default_calendar_style_today', $today_color); |
|
| 402 | 402 | |
| 403 | 403 | // Days with events color. |
| 404 | - $days_events_color = isset( $_POST['_default_calendar_style_days_events'] ) ? sanitize_text_field( $_POST['_default_calendar_style_days_events'] ) : '#000000'; |
|
| 405 | - update_post_meta( $post_id, '_default_calendar_style_days_events', $days_events_color ); |
|
| 404 | + $days_events_color = isset($_POST['_default_calendar_style_days_events']) ? sanitize_text_field($_POST['_default_calendar_style_days_events']) : '#000000'; |
|
| 405 | + update_post_meta($post_id, '_default_calendar_style_days_events', $days_events_color); |
|
| 406 | 406 | |
| 407 | 407 | // List range span. |
| 408 | - $span = isset( $_POST['_default_calendar_list_range_span'] ) ? max( absint( $_POST['_default_calendar_list_range_span'] ), 1 ) : 1; |
|
| 409 | - update_post_meta( $post_id, '_default_calendar_list_range_span', $span ); |
|
| 408 | + $span = isset($_POST['_default_calendar_list_range_span']) ? max(absint($_POST['_default_calendar_list_range_span']), 1) : 1; |
|
| 409 | + update_post_meta($post_id, '_default_calendar_list_range_span', $span); |
|
| 410 | 410 | |
| 411 | 411 | // List range type. |
| 412 | - $group = isset( $_POST['_default_calendar_list_range_type'] ) ? sanitize_key( $_POST['_default_calendar_list_range_type'] ) : 'monthly'; |
|
| 413 | - update_post_meta( $post_id, '_default_calendar_list_range_type', $group ); |
|
| 412 | + $group = isset($_POST['_default_calendar_list_range_type']) ? sanitize_key($_POST['_default_calendar_list_range_type']) : 'monthly'; |
|
| 413 | + update_post_meta($post_id, '_default_calendar_list_range_type', $group); |
|
| 414 | 414 | |
| 415 | 415 | // Hide header. |
| 416 | - $header = isset( $_POST['_default_calendar_list_header'] ) ? 'yes' : 'no'; |
|
| 417 | - update_post_meta( $post_id, '_default_calendar_list_header', $header ); |
|
| 416 | + $header = isset($_POST['_default_calendar_list_header']) ? 'yes' : 'no'; |
|
| 417 | + update_post_meta($post_id, '_default_calendar_list_header', $header); |
|
| 418 | 418 | |
| 419 | 419 | // Compact list. |
| 420 | - $compact = isset( $_POST['_default_calendar_compact_list'] ) ? 'yes' : 'no'; |
|
| 421 | - update_post_meta( $post_id, '_default_calendar_compact_list', $compact ); |
|
| 420 | + $compact = isset($_POST['_default_calendar_compact_list']) ? 'yes' : 'no'; |
|
| 421 | + update_post_meta($post_id, '_default_calendar_compact_list', $compact); |
|
| 422 | 422 | |
| 423 | 423 | // Limit number of initially visible daily events. |
| 424 | - $limit = isset( $_POST['_default_calendar_limit_visible_events'] ) ? 'yes' : 'no'; |
|
| 425 | - update_post_meta( $post_id, '_default_calendar_limit_visible_events', $limit ); |
|
| 426 | - $number = isset( $_POST['_default_calendar_visible_events'] ) ? absint( $_POST['_default_calendar_visible_events'] ) : 3; |
|
| 427 | - update_post_meta( $post_id, '_default_calendar_visible_events', $number ); |
|
| 424 | + $limit = isset($_POST['_default_calendar_limit_visible_events']) ? 'yes' : 'no'; |
|
| 425 | + update_post_meta($post_id, '_default_calendar_limit_visible_events', $limit); |
|
| 426 | + $number = isset($_POST['_default_calendar_visible_events']) ? absint($_POST['_default_calendar_visible_events']) : 3; |
|
| 427 | + update_post_meta($post_id, '_default_calendar_visible_events', $number); |
|
| 428 | 428 | |
| 429 | 429 | // Grid event bubbles action. |
| 430 | - $bubbles = isset( $_POST['_default_calendar_event_bubble_trigger'] ) ? esc_attr( $_POST['_default_calendar_event_bubble_trigger'] ) : 'hover'; |
|
| 431 | - update_post_meta( $post_id, '_default_calendar_event_bubble_trigger', $bubbles ); |
|
| 430 | + $bubbles = isset($_POST['_default_calendar_event_bubble_trigger']) ? esc_attr($_POST['_default_calendar_event_bubble_trigger']) : 'hover'; |
|
| 431 | + update_post_meta($post_id, '_default_calendar_event_bubble_trigger', $bubbles); |
|
| 432 | 432 | |
| 433 | 433 | // Trim event titles characters length. |
| 434 | - $trim = isset( $_POST['_default_calendar_trim_titles'] ) ? 'yes' : 'no'; |
|
| 435 | - update_post_meta( $post_id, '_default_calendar_trim_titles', $trim ); |
|
| 436 | - $chars = isset( $_POST['_default_calendar_trim_titles_chars'] ) ? max( absint( $_POST['_default_calendar_trim_titles_chars'] ), 1 ) : 20; |
|
| 437 | - update_post_meta( $post_id, '_default_calendar_trim_titles_chars', $chars ); |
|
| 434 | + $trim = isset($_POST['_default_calendar_trim_titles']) ? 'yes' : 'no'; |
|
| 435 | + update_post_meta($post_id, '_default_calendar_trim_titles', $trim); |
|
| 436 | + $chars = isset($_POST['_default_calendar_trim_titles_chars']) ? max(absint($_POST['_default_calendar_trim_titles_chars']), 1) : 20; |
|
| 437 | + update_post_meta($post_id, '_default_calendar_trim_titles_chars', $chars); |
|
| 438 | 438 | |
| 439 | 439 | // Expand multiple day events on each day. |
| 440 | - $multi_day = isset( $_POST['_default_calendar_expand_multi_day_events'] ) && ! empty( $_POST['_default_calendar_expand_multi_day_events'] ) ? sanitize_key( $_POST['_default_calendar_expand_multi_day_events'] ) : 'current_day_only'; |
|
| 441 | - update_post_meta( $post_id, '_default_calendar_expand_multi_day_events', $multi_day ); |
|
| 440 | + $multi_day = isset($_POST['_default_calendar_expand_multi_day_events']) && ! empty($_POST['_default_calendar_expand_multi_day_events']) ? sanitize_key($_POST['_default_calendar_expand_multi_day_events']) : 'current_day_only'; |
|
| 441 | + update_post_meta($post_id, '_default_calendar_expand_multi_day_events', $multi_day); |
|
| 442 | 442 | |
| 443 | 443 | } |
| 444 | 444 | |
@@ -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 | |
@@ -150,71 +150,71 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @param array $field Field data. |
| 152 | 152 | */ |
| 153 | - public function __construct( $field ) { |
|
| 153 | + public function __construct($field) { |
|
| 154 | 154 | |
| 155 | 155 | // Field properties. |
| 156 | - if ( isset( $field['title'] ) ) { |
|
| 157 | - $this->title = esc_attr( $field['title'] ); |
|
| 156 | + if (isset($field['title'])) { |
|
| 157 | + $this->title = esc_attr($field['title']); |
|
| 158 | 158 | } |
| 159 | - if ( isset( $field['description'] ) ) { |
|
| 160 | - $this->description = wp_kses_post( $field['description'] ); |
|
| 159 | + if (isset($field['description'])) { |
|
| 160 | + $this->description = wp_kses_post($field['description']); |
|
| 161 | 161 | } |
| 162 | - if ( isset( $field['type'] ) ) { |
|
| 163 | - $this->type = esc_attr( $field['type'] ); |
|
| 162 | + if (isset($field['type'])) { |
|
| 163 | + $this->type = esc_attr($field['type']); |
|
| 164 | 164 | } |
| 165 | - if ( isset( $field['name'] ) ) { |
|
| 166 | - $this->name = esc_attr( $field['name'] ); |
|
| 165 | + if (isset($field['name'])) { |
|
| 166 | + $this->name = esc_attr($field['name']); |
|
| 167 | 167 | } |
| 168 | - if ( isset( $field['id'] ) ) { |
|
| 169 | - $this->id = esc_attr( $field['id'] ); |
|
| 168 | + if (isset($field['id'])) { |
|
| 169 | + $this->id = esc_attr($field['id']); |
|
| 170 | 170 | } |
| 171 | - if ( isset( $field['placeholder'] ) ) { |
|
| 172 | - $this->placeholder = esc_attr( $field['placeholder'] ); |
|
| 171 | + if (isset($field['placeholder'])) { |
|
| 172 | + $this->placeholder = esc_attr($field['placeholder']); |
|
| 173 | 173 | } |
| 174 | - if ( isset( $field['options'] ) && is_array( $field['options'] ) ) { |
|
| 175 | - $this->options = array_map( 'esc_attr', $field['options'] ); |
|
| 174 | + if (isset($field['options']) && is_array($field['options'])) { |
|
| 175 | + $this->options = array_map('esc_attr', $field['options']); |
|
| 176 | 176 | } |
| 177 | - if ( isset( $field['text'] ) ) { |
|
| 177 | + if (isset($field['text'])) { |
|
| 178 | 178 | $this->text = $field['text']; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Escaping. |
| 182 | - if ( ! empty( $field['escaping'] ) && ( is_string( $field['escaping'] ) || is_array( $field['escaping'] ) ) ) { |
|
| 183 | - if ( isset( $field['default'] ) ) { |
|
| 184 | - $this->default = $this->escape_callback( $field['escaping'], $field['default'] ); |
|
| 182 | + if ( ! empty($field['escaping']) && (is_string($field['escaping']) || is_array($field['escaping']))) { |
|
| 183 | + if (isset($field['default'])) { |
|
| 184 | + $this->default = $this->escape_callback($field['escaping'], $field['default']); |
|
| 185 | 185 | } |
| 186 | - if ( isset( $field['value'] ) ) { |
|
| 187 | - $this->value = $this->escape_callback( $field['escaping'], $field['value'] ); |
|
| 186 | + if (isset($field['value'])) { |
|
| 187 | + $this->value = $this->escape_callback($field['escaping'], $field['value']); |
|
| 188 | 188 | } |
| 189 | 189 | } else { |
| 190 | - if ( isset( $field['default'] ) ) { |
|
| 191 | - $this->default = $this->escape( $field['default'] ); |
|
| 190 | + if (isset($field['default'])) { |
|
| 191 | + $this->default = $this->escape($field['default']); |
|
| 192 | 192 | } |
| 193 | - if ( isset( $field['value'] ) ) { |
|
| 194 | - $this->value = $this->escape( $field['value'] ); |
|
| 193 | + if (isset($field['value'])) { |
|
| 194 | + $this->value = $this->escape($field['value']); |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // Validation. |
| 199 | - if ( ! empty( $field['validation'] ) ) { |
|
| 200 | - $this->validation = $this->validate( $field['validation'], $this->value ); |
|
| 199 | + if ( ! empty($field['validation'])) { |
|
| 200 | + $this->validation = $this->validate($field['validation'], $this->value); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | // CSS classes and styles. |
| 204 | - $classes = isset( $field['class'] ) ? $field['class'] : ''; |
|
| 205 | - $this->set_class( $classes ); |
|
| 206 | - if ( isset( $field['style'] ) ) { |
|
| 207 | - $this->set_style( $field['style'] ); |
|
| 204 | + $classes = isset($field['class']) ? $field['class'] : ''; |
|
| 205 | + $this->set_class($classes); |
|
| 206 | + if (isset($field['style'])) { |
|
| 207 | + $this->set_style($field['style']); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // Custom attributes. |
| 211 | - if ( isset( $field['attributes'] ) ) { |
|
| 212 | - $this->set_attributes( $field['attributes'] ); |
|
| 211 | + if (isset($field['attributes'])) { |
|
| 212 | + $this->set_attributes($field['attributes']); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | // Tooltip markup. |
| 216 | - if ( isset( $field['tooltip'] ) ) { |
|
| 217 | - $this->tooltip = ' <i class="simcal-icon-help simcal-help-tip" data-tip="' . esc_attr( $field['tooltip'] ) . '"></i> ' ; |
|
| 216 | + if (isset($field['tooltip'])) { |
|
| 217 | + $this->tooltip = ' <i class="simcal-icon-help simcal-help-tip" data-tip="'.esc_attr($field['tooltip']).'"></i> '; |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
@@ -227,13 +227,13 @@ discard block |
||
| 227 | 227 | * |
| 228 | 228 | * @return void |
| 229 | 229 | */ |
| 230 | - public function set_attributes( $attributes ) { |
|
| 230 | + public function set_attributes($attributes) { |
|
| 231 | 231 | |
| 232 | 232 | $attr = ''; |
| 233 | 233 | |
| 234 | - if ( ! empty( $attributes ) && is_array( $attributes ) ) { |
|
| 235 | - foreach ( $attributes as $k => $v ) { |
|
| 236 | - $attr .= esc_attr( $k ) . '="' . esc_attr( $v ) . '" '; |
|
| 234 | + if ( ! empty($attributes) && is_array($attributes)) { |
|
| 235 | + foreach ($attributes as $k => $v) { |
|
| 236 | + $attr .= esc_attr($k).'="'.esc_attr($v).'" '; |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
@@ -249,13 +249,13 @@ discard block |
||
| 249 | 249 | * |
| 250 | 250 | * @return void |
| 251 | 251 | */ |
| 252 | - public function set_style( $css ) { |
|
| 252 | + public function set_style($css) { |
|
| 253 | 253 | |
| 254 | 254 | $styles = ''; |
| 255 | 255 | |
| 256 | - if ( ! empty( $css ) && is_array( $css ) ) { |
|
| 257 | - foreach ( $css as $k => $v ) { |
|
| 258 | - $styles .= esc_attr( $k ) . ': ' . esc_attr( $v ) . '; '; |
|
| 256 | + if ( ! empty($css) && is_array($css)) { |
|
| 257 | + foreach ($css as $k => $v) { |
|
| 258 | + $styles .= esc_attr($k).': '.esc_attr($v).'; '; |
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | |
@@ -271,23 +271,23 @@ discard block |
||
| 271 | 271 | * |
| 272 | 272 | * @return void |
| 273 | 273 | */ |
| 274 | - public function set_class( $class ) { |
|
| 274 | + public function set_class($class) { |
|
| 275 | 275 | |
| 276 | 276 | $classes = ''; |
| 277 | 277 | $type_class = ''; |
| 278 | 278 | $error = ''; |
| 279 | 279 | |
| 280 | - if ( ! empty( $class ) && is_array( $class ) ) { |
|
| 281 | - $classes = implode( ' ', array_map( 'esc_attr', $class ) ); |
|
| 280 | + if ( ! empty($class) && is_array($class)) { |
|
| 281 | + $classes = implode(' ', array_map('esc_attr', $class)); |
|
| 282 | 282 | } |
| 283 | - if ( ! empty( $this->type_class ) ) { |
|
| 284 | - $type_class = esc_attr( $this->type_class ); |
|
| 283 | + if ( ! empty($this->type_class)) { |
|
| 284 | + $type_class = esc_attr($this->type_class); |
|
| 285 | 285 | } |
| 286 | - if ( true !== $this->validation && ! empty( $this->validation ) ) { |
|
| 286 | + if (true !== $this->validation && ! empty($this->validation)) { |
|
| 287 | 287 | $error = 'simcal-field-error '; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - $this->class = trim( $error . 'simcal-field ' . $type_class . ' ' . $classes ); |
|
| 290 | + $this->class = trim($error.'simcal-field '.$type_class.' '.$classes); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
@@ -302,8 +302,8 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @return array|string |
| 304 | 304 | */ |
| 305 | - protected function escape( $value ) { |
|
| 306 | - return ! empty( $value ) ? ( is_array( $value ) ? array_map( 'esc_attr', $value ) : esc_attr( $value ) ) : ''; |
|
| 305 | + protected function escape($value) { |
|
| 306 | + return ! empty($value) ? (is_array($value) ? array_map('esc_attr', $value) : esc_attr($value)) : ''; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -319,11 +319,11 @@ discard block |
||
| 319 | 319 | * |
| 320 | 320 | * @return mixed |
| 321 | 321 | */ |
| 322 | - protected function escape_callback( $callback, $value ) { |
|
| 323 | - if ( $callback && ( is_string( $callback ) || is_array( $callback ) ) ) { |
|
| 324 | - return call_user_func( $callback, $value ); |
|
| 322 | + protected function escape_callback($callback, $value) { |
|
| 323 | + if ($callback && (is_string($callback) || is_array($callback))) { |
|
| 324 | + return call_user_func($callback, $value); |
|
| 325 | 325 | } |
| 326 | - return esc_attr( $value ); |
|
| 326 | + return esc_attr($value); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -339,10 +339,10 @@ discard block |
||
| 339 | 339 | * |
| 340 | 340 | * @return true|string Expected to return bool (true) if passes, message string if not. |
| 341 | 341 | */ |
| 342 | - protected function validate( $callback, $value ) { |
|
| 343 | - if ( $callback && ( is_string( $callback ) || is_array( $callback ) ) ) { |
|
| 344 | - $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : ''; |
|
| 345 | - return call_user_func( $callback, $value, $screen ); |
|
| 342 | + protected function validate($callback, $value) { |
|
| 343 | + if ($callback && (is_string($callback) || is_array($callback))) { |
|
| 344 | + $screen = function_exists('get_current_screen') ? get_current_screen() : ''; |
|
| 345 | + return call_user_func($callback, $value, $screen); |
|
| 346 | 346 | } |
| 347 | 347 | return true; |
| 348 | 348 | } |