@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Admin\Metaboxes as Metabox; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function __construct() { |
| 46 | 46 | |
| 47 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
| 48 | - if ( isset( $settings['general']['attach_calendars_posts'] ) ) { |
|
| 47 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
| 48 | + if (isset($settings['general']['attach_calendars_posts'])) { |
|
| 49 | 49 | $this->post_types = $settings['general']['attach_calendars_posts']; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -55,17 +55,17 @@ discard block |
||
| 55 | 55 | new Metabox\Upgrade_To_Premium(); |
| 56 | 56 | //new Metabox\Newsletter(); |
| 57 | 57 | |
| 58 | - do_action( 'simcal_load_meta_boxes' ); |
|
| 58 | + do_action('simcal_load_meta_boxes'); |
|
| 59 | 59 | |
| 60 | 60 | // Add meta boxes. |
| 61 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 30 ); |
|
| 61 | + add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 30); |
|
| 62 | 62 | |
| 63 | 63 | // Process meta boxes. |
| 64 | - add_action( 'simcal_save_settings_meta','\SimpleCalendar\Admin\Metaboxes\Settings::save', 10, 2 ); |
|
| 65 | - add_action( 'simcal_save_attach_calendar_meta','\SimpleCalendar\Admin\Metaboxes\Attach_Calendar::save', 10, 2 ); |
|
| 64 | + add_action('simcal_save_settings_meta', '\SimpleCalendar\Admin\Metaboxes\Settings::save', 10, 2); |
|
| 65 | + add_action('simcal_save_attach_calendar_meta', '\SimpleCalendar\Admin\Metaboxes\Attach_Calendar::save', 10, 2); |
|
| 66 | 66 | |
| 67 | 67 | // Save meta boxes data. |
| 68 | - add_action( 'save_post', array( $this, 'save_meta_boxes' ), 1, 2 ); |
|
| 68 | + add_action('save_post', array($this, 'save_meta_boxes'), 1, 2); |
|
| 69 | 69 | |
| 70 | 70 | // Uncomment this for debugging $_POST while saving a meta box. |
| 71 | 71 | // add_action( 'save_post', function() { echo '<pre>'; print_r( $_POST ); echo '</pre>'; die(); } ); |
@@ -80,20 +80,20 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | add_meta_box( |
| 82 | 82 | 'simcal-calendar-settings', |
| 83 | - __( 'Calendar Settings', 'google-calendar-events' ), |
|
| 83 | + __('Calendar Settings', 'google-calendar-events'), |
|
| 84 | 84 | '\SimpleCalendar\Admin\Metaboxes\Settings::html', |
| 85 | 85 | 'calendar', |
| 86 | 86 | 'normal', |
| 87 | 87 | 'core' |
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | - $addons = apply_filters( 'simcal_installed_addons', array() ); |
|
| 91 | - if ( empty( $addons ) ) { |
|
| 90 | + $addons = apply_filters('simcal_installed_addons', array()); |
|
| 91 | + if (empty($addons)) { |
|
| 92 | 92 | |
| 93 | 93 | // Premium add-on feature list and upsell. |
| 94 | 94 | add_meta_box( |
| 95 | 95 | 'simcal-upgrade', |
| 96 | - __( 'Looking for more?', 'google-calendar-events' ), |
|
| 96 | + __('Looking for more?', 'google-calendar-events'), |
|
| 97 | 97 | '\SimpleCalendar\Admin\Metaboxes\Upgrade_To_Premium::html', |
| 98 | 98 | 'calendar', |
| 99 | 99 | 'side', |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | add_meta_box( |
| 117 | 117 | 'simcal-get-shortcode', |
| 118 | - __( 'Calendar Shortcode', 'google-calendar-events' ), |
|
| 118 | + __('Calendar Shortcode', 'google-calendar-events'), |
|
| 119 | 119 | '\SimpleCalendar\Admin\Metaboxes\Get_Shortcode::html', |
| 120 | 120 | 'calendar', |
| 121 | 121 | 'side', |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | ); |
| 124 | 124 | |
| 125 | 125 | // Add meta box if there are calendars. |
| 126 | - if ( ( true == simcal_get_calendars() ) && ! empty( $this->post_types ) ) { |
|
| 127 | - foreach ( $this->post_types as $post_type ) { |
|
| 126 | + if ((true == simcal_get_calendars()) && ! empty($this->post_types)) { |
|
| 127 | + foreach ($this->post_types as $post_type) { |
|
| 128 | 128 | add_meta_box( |
| 129 | 129 | 'simcal-attach-calendar', |
| 130 | - __( 'Attach Calendar', 'google-calendar-events' ), |
|
| 130 | + __('Attach Calendar', 'google-calendar-events'), |
|
| 131 | 131 | '\SimpleCalendar\Admin\Metaboxes\Attach_Calendar::html', |
| 132 | 132 | $post_type, |
| 133 | 133 | 'side', |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - do_action( 'simcal_add_meta_boxes' ); |
|
| 139 | + do_action('simcal_add_meta_boxes'); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -149,30 +149,30 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @return void |
| 151 | 151 | */ |
| 152 | - public function save_meta_boxes( $post_id, $post ) { |
|
| 152 | + public function save_meta_boxes($post_id, $post) { |
|
| 153 | 153 | |
| 154 | 154 | // $post_id and $post are required. |
| 155 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
| 155 | + if (empty($post_id) || empty($post) || self::$saved_meta_boxes) { |
|
| 156 | 156 | return; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // Don't save meta boxes for revisions or autosaves. |
| 160 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
| 160 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
| 161 | 161 | return; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // Check the nonce. |
| 165 | - if ( empty( $_POST['simcal_meta_nonce'] ) || ! wp_verify_nonce( $_POST['simcal_meta_nonce'], 'simcal_save_data' ) ) { |
|
| 165 | + if (empty($_POST['simcal_meta_nonce']) || ! wp_verify_nonce($_POST['simcal_meta_nonce'], 'simcal_save_data')) { |
|
| 166 | 166 | return; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
| 170 | - if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { |
|
| 170 | + if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) { |
|
| 171 | 171 | return; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Check user has permission to edit |
| 175 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 175 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
| 176 | 176 | return; |
| 177 | 177 | } |
| 178 | 178 | |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | self::$saved_meta_boxes = true; |
| 186 | 186 | |
| 187 | 187 | // Check the post type. |
| 188 | - if ( 'calendar' == $post->post_type ) { |
|
| 189 | - do_action( 'simcal_save_settings_meta', $post_id, $post ); |
|
| 190 | - } elseif ( in_array( $post->post_type, $this->post_types ) ) { |
|
| 191 | - do_action( 'simcal_save_attach_calendar_meta', $post_id, $post ); |
|
| 188 | + if ('calendar' == $post->post_type) { |
|
| 189 | + do_action('simcal_save_settings_meta', $post_id, $post); |
|
| 190 | + } elseif (in_array($post->post_type, $this->post_types)) { |
|
| 191 | + do_action('simcal_save_attach_calendar_meta', $post_id, $post); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - do_action( 'simcal_save_meta_boxes', $post_id, $post ); |
|
| 194 | + do_action('simcal_save_meta_boxes', $post_id, $post); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | } |
@@ -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 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @param \WP_Post $post |
| 28 | 28 | */ |
| 29 | - public static function html( $post ) { |
|
| 29 | + public static function html($post) { |
|
| 30 | 30 | simcal_newsletter_signup(); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @param int $post_id |
| 39 | 39 | * @param \WP_Post $post |
| 40 | 40 | */ |
| 41 | - public static function save( $post_id, $post ) { |
|
| 41 | + public static function save($post_id, $post) { |
|
| 42 | 42 | // This meta box has no persistent settings. |
| 43 | 43 | } |
| 44 | 44 | |
@@ -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> |
@@ -347,29 +347,29 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | function simcal_upgrade_to_premium() { |
| 349 | 349 | |
| 350 | - if ( $screen = simcal_is_admin_screen() ) { |
|
| 350 | + if ($screen = simcal_is_admin_screen()) { |
|
| 351 | 351 | ?> |
| 352 | 352 | <div class="main"> |
| 353 | 353 | <p class="heading centered"> |
| 354 | - <?php _e( 'Some of the features included with our premium add-ons', 'google-calendar-events' ); ?> |
|
| 354 | + <?php _e('Some of the features included with our premium add-ons', 'google-calendar-events'); ?> |
|
| 355 | 355 | </p> |
| 356 | 356 | |
| 357 | 357 | <ul> |
| 358 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Display color coded events', 'google-calendar-events' ); ?></li> |
|
| 359 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Show week & day views', 'google-calendar-events' ); ?></li> |
|
| 360 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Fast view switching', 'google-calendar-events' ); ?></li> |
|
| 361 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Event titles & start times in grid', 'google-calendar-events' ); ?></li> |
|
| 362 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Limit event display times', 'google-calendar-events' ); ?></li> |
|
| 363 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Display private calendar events', 'google-calendar-events' ); ?></li> |
|
| 364 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Show attendees & RSVP status', 'google-calendar-events' ); ?></li> |
|
| 365 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Display attachments', 'google-calendar-events' ); ?></li> |
|
| 366 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Priority email support', 'google-calendar-events' ); ?></li> |
|
| 358 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Display color coded events', 'google-calendar-events'); ?></li> |
|
| 359 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Show week & day views', 'google-calendar-events'); ?></li> |
|
| 360 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Fast view switching', 'google-calendar-events'); ?></li> |
|
| 361 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Event titles & start times in grid', 'google-calendar-events'); ?></li> |
|
| 362 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Limit event display times', 'google-calendar-events'); ?></li> |
|
| 363 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Display private calendar events', 'google-calendar-events'); ?></li> |
|
| 364 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Show attendees & RSVP status', 'google-calendar-events'); ?></li> |
|
| 365 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Display attachments', 'google-calendar-events'); ?></li> |
|
| 366 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Priority email support', 'google-calendar-events'); ?></li> |
|
| 367 | 367 | </ul> |
| 368 | 368 | |
| 369 | 369 | <div class="centered"> |
| 370 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'sidebar-link' ); ?>" |
|
| 370 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'sidebar-link'); ?>" |
|
| 371 | 371 | class="button-primary button-large" target="_blank"> |
| 372 | - <?php _e( 'Upgrade to Premium Now', 'google-calendar-events' ); ?></a> |
|
| 372 | + <?php _e('Upgrade to Premium Now', 'google-calendar-events'); ?></a> |
|
| 373 | 373 | </div> |
| 374 | 374 | </div> |
| 375 | 375 | <?php |
@@ -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(); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return array |
| 69 | 69 | */ |
| 70 | 70 | public function get_content_tags() { |
| 71 | - return array_merge( array( |
|
| 71 | + return array_merge(array( |
|
| 72 | 72 | |
| 73 | 73 | /* ============ * |
| 74 | 74 | * Content Tags * |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | 'if-not-end-location', |
| 215 | 215 | // Does the event has NOT an end location? |
| 216 | 216 | |
| 217 | - ), (array) $this->add_custom_event_tags() ); |
|
| 217 | + ), (array) $this->add_custom_event_tags()); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -226,16 +226,16 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @return string |
| 228 | 228 | */ |
| 229 | - public function parse_event_template_tags( $template_tags = '' ) { |
|
| 229 | + public function parse_event_template_tags($template_tags = '') { |
|
| 230 | 230 | |
| 231 | 231 | // Process tags. |
| 232 | - $result = preg_replace_callback( $this->get_regex(), array( $this, 'process_event_content' ), $template_tags ); |
|
| 232 | + $result = preg_replace_callback($this->get_regex(), array($this, 'process_event_content'), $template_tags); |
|
| 233 | 233 | |
| 234 | 234 | // Removes extra consecutive <br> tags. |
| 235 | 235 | // TODO: Doesn't seem to work but going to remove it to allow multiple <br> tags in the editor |
| 236 | 236 | /*return preg_replace( '#(<br *//*?>\s*)+#i', '<br />', trim( $result ) );*/ |
| 237 | 237 | |
| 238 | - return do_shortcode( trim( $result ) ); |
|
| 238 | + return do_shortcode(trim($result)); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
@@ -247,10 +247,10 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @return string |
| 249 | 249 | */ |
| 250 | - public function process_event_content( $match ) { |
|
| 250 | + public function process_event_content($match) { |
|
| 251 | 251 | |
| 252 | - if ( $match[1] == '[' && $match[6] == ']' ) { |
|
| 253 | - return substr( $match[0], 1, -1 ); |
|
| 252 | + if ($match[1] == '[' && $match[6] == ']') { |
|
| 253 | + return substr($match[0], 1, -1); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | $tag = $match[2]; // Tag name without square brackets. |
@@ -262,9 +262,9 @@ discard block |
||
| 262 | 262 | $calendar = $this->calendar; |
| 263 | 263 | $event = $this->event; |
| 264 | 264 | |
| 265 | - if ( ( $calendar instanceof Calendar ) && ( $event instanceof Event ) ) { |
|
| 265 | + if (($calendar instanceof Calendar) && ($event instanceof Event)) { |
|
| 266 | 266 | |
| 267 | - switch ( $tag ) { |
|
| 267 | + switch ($tag) { |
|
| 268 | 268 | |
| 269 | 269 | /* ============ * |
| 270 | 270 | * Content Tags * |
@@ -272,13 +272,13 @@ discard block |
||
| 272 | 272 | |
| 273 | 273 | case 'title' : |
| 274 | 274 | case 'event-title' : |
| 275 | - return $this->get_title( $event->title, $attr ); |
|
| 275 | + return $this->get_title($event->title, $attr); |
|
| 276 | 276 | |
| 277 | 277 | case 'description' : |
| 278 | - return $this->get_description( $event->description, $attr ); |
|
| 278 | + return $this->get_description($event->description, $attr); |
|
| 279 | 279 | |
| 280 | 280 | case 'when' : |
| 281 | - return $this->get_when( $event ); |
|
| 281 | + return $this->get_when($event); |
|
| 282 | 282 | |
| 283 | 283 | case 'end-date' : |
| 284 | 284 | case 'end-custom' : |
@@ -288,58 +288,58 @@ discard block |
||
| 288 | 288 | case 'start-date' : |
| 289 | 289 | case 'start-human' : |
| 290 | 290 | case 'start-time' : |
| 291 | - return $this->get_dt( $tag, $event, $attr ); |
|
| 291 | + return $this->get_dt($tag, $event, $attr); |
|
| 292 | 292 | |
| 293 | 293 | case 'length' : |
| 294 | 294 | case 'duration' : |
| 295 | - if ( false !== $event->end ) { |
|
| 295 | + if (false !== $event->end) { |
|
| 296 | 296 | $duration = $event->start - $event->end; |
| 297 | - $value = human_time_diff( $event->start, $event->end ); |
|
| 297 | + $value = human_time_diff($event->start, $event->end); |
|
| 298 | 298 | } else { |
| 299 | 299 | $duration = '-1'; |
| 300 | - $value = __( 'No end time', 'google-calendar-events' ); |
|
| 300 | + $value = __('No end time', 'google-calendar-events'); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - return ' <span class="simcal-event-duration" data-event-duration="' . $duration . '">' . $value . '</span>'; |
|
| 303 | + return ' <span class="simcal-event-duration" data-event-duration="'.$duration.'">'.$value.'</span>'; |
|
| 304 | 304 | |
| 305 | 305 | case 'location' : |
| 306 | 306 | case 'start-location' : |
| 307 | 307 | case 'end-location' : |
| 308 | - $location = ( 'end-location' == $tag ) ? $event->end_location['address'] : $event->start_location['address']; |
|
| 309 | - $location_class = ( 'end-location' == $tag ) ? 'end' : 'start'; |
|
| 308 | + $location = ('end-location' == $tag) ? $event->end_location['address'] : $event->start_location['address']; |
|
| 309 | + $location_class = ('end-location' == $tag) ? 'end' : 'start'; |
|
| 310 | 310 | |
| 311 | 311 | // location, location.name, location.address (type PostalAddress) all required for schema data. |
| 312 | 312 | // Need to use event name where location data doesn't exist. |
| 313 | 313 | // Since we have 1 location field, use it as the name and address. |
| 314 | 314 | // If the location is blank, use the event title as the name and address. |
| 315 | 315 | // Wrap with wp_strip_all_tags(). |
| 316 | - $meta_location_name_and_address = empty( $location ) ? wp_strip_all_tags( $event->title ) : wp_strip_all_tags( $location ); |
|
| 316 | + $meta_location_name_and_address = empty($location) ? wp_strip_all_tags($event->title) : wp_strip_all_tags($location); |
|
| 317 | 317 | |
| 318 | - return ' <span class="simcal-event-address simcal-event-' . $location_class . '-location" itemprop="location" itemscope itemtype="http://schema.org/Place">' . '<meta itemprop="name" content="' . $meta_location_name_and_address . '" />' . '<meta itemprop="address" content="' . $meta_location_name_and_address . '" />' . wp_strip_all_tags( $location ) . '</span>'; |
|
| 318 | + return ' <span class="simcal-event-address simcal-event-'.$location_class.'-location" itemprop="location" itemscope itemtype="http://schema.org/Place">'.'<meta itemprop="name" content="'.$meta_location_name_and_address.'" />'.'<meta itemprop="address" content="'.$meta_location_name_and_address.'" />'.wp_strip_all_tags($location).'</span>'; |
|
| 319 | 319 | |
| 320 | 320 | case 'start-location-link': |
| 321 | 321 | case 'end-location-link' : |
| 322 | 322 | case 'maps-link' : |
| 323 | - $location = ( 'end-location-link' == $tag ) ? $event->end_location['address'] : $event->start_location['address']; |
|
| 324 | - if ( ! empty( $location ) ) { |
|
| 325 | - $url = '//maps.google.com?q=' . urlencode( $location ); |
|
| 323 | + $location = ('end-location-link' == $tag) ? $event->end_location['address'] : $event->start_location['address']; |
|
| 324 | + if ( ! empty($location)) { |
|
| 325 | + $url = '//maps.google.com?q='.urlencode($location); |
|
| 326 | 326 | |
| 327 | - return $this->make_link( $tag, $url, $calendar->get_event_html( $event, $partial ), $attr ); |
|
| 327 | + return $this->make_link($tag, $url, $calendar->get_event_html($event, $partial), $attr); |
|
| 328 | 328 | } |
| 329 | 329 | break; |
| 330 | 330 | |
| 331 | 331 | case 'link' : |
| 332 | 332 | case 'url' : |
| 333 | - $content = ( 'link' == $tag ) ? $calendar->get_event_html( $event, $partial ) : ''; |
|
| 333 | + $content = ('link' == $tag) ? $calendar->get_event_html($event, $partial) : ''; |
|
| 334 | 334 | |
| 335 | - return $this->make_link( $tag, $event->link, $content, $attr ); |
|
| 335 | + return $this->make_link($tag, $event->link, $content, $attr); |
|
| 336 | 336 | |
| 337 | 337 | case 'add-to-gcal-link'; |
| 338 | - $content = ( 'add-to-gcal-link' == $tag ) ? $calendar->get_event_html( $event, $partial ) : ''; |
|
| 339 | - if ( ! empty( $content ) ) { |
|
| 340 | - $url = $calendar->get_add_to_gcal_url( $event ); |
|
| 338 | + $content = ('add-to-gcal-link' == $tag) ? $calendar->get_event_html($event, $partial) : ''; |
|
| 339 | + if ( ! empty($content)) { |
|
| 340 | + $url = $calendar->get_add_to_gcal_url($event); |
|
| 341 | 341 | |
| 342 | - return $this->make_link( $tag, $url, $content, $attr ); |
|
| 342 | + return $this->make_link($tag, $url, $content, $attr); |
|
| 343 | 343 | } |
| 344 | 344 | break; |
| 345 | 345 | |
@@ -366,22 +366,22 @@ discard block |
||
| 366 | 366 | |
| 367 | 367 | case 'attachments' : |
| 368 | 368 | $attachments = $event->get_attachments(); |
| 369 | - if ( ! empty( $attachments ) ) { |
|
| 370 | - return $this->get_attachments( $attachments ); |
|
| 369 | + if ( ! empty($attachments)) { |
|
| 370 | + return $this->get_attachments($attachments); |
|
| 371 | 371 | } |
| 372 | 372 | break; |
| 373 | 373 | |
| 374 | 374 | case 'attendees' : |
| 375 | 375 | $attendees = $event->get_attendees(); |
| 376 | - if ( ! empty( $attendees ) ) { |
|
| 377 | - return $this->get_attendees( $attendees, $attr ); |
|
| 376 | + if ( ! empty($attendees)) { |
|
| 377 | + return $this->get_attendees($attendees, $attr); |
|
| 378 | 378 | } |
| 379 | 379 | break; |
| 380 | 380 | |
| 381 | 381 | case 'organizer' : |
| 382 | 382 | $organizer = $event->get_organizer(); |
| 383 | - if ( ! empty( $organizer ) ) { |
|
| 384 | - return $this->get_organizer( $organizer, $attr ); |
|
| 383 | + if ( ! empty($organizer)) { |
|
| 384 | + return $this->get_organizer($organizer, $attr); |
|
| 385 | 385 | } |
| 386 | 386 | break; |
| 387 | 387 | |
@@ -390,35 +390,35 @@ discard block |
||
| 390 | 390 | * ================ */ |
| 391 | 391 | |
| 392 | 392 | case 'if-title': |
| 393 | - if ( ! empty( $event->title ) ) { |
|
| 394 | - return $calendar->get_event_html( $event, $partial ); |
|
| 393 | + if ( ! empty($event->title)) { |
|
| 394 | + return $calendar->get_event_html($event, $partial); |
|
| 395 | 395 | } |
| 396 | 396 | break; |
| 397 | 397 | |
| 398 | 398 | case 'if-description': |
| 399 | - if ( ! empty( $event->description ) ) { |
|
| 400 | - return $calendar->get_event_html( $event, $partial ); |
|
| 399 | + if ( ! empty($event->description)) { |
|
| 400 | + return $calendar->get_event_html($event, $partial); |
|
| 401 | 401 | } |
| 402 | 402 | break; |
| 403 | 403 | |
| 404 | 404 | case 'if-now' : |
| 405 | 405 | case 'if-not-now' : |
| 406 | 406 | |
| 407 | - $start_dt = $event->start_dt->setTimezone( $calendar->timezone ); |
|
| 407 | + $start_dt = $event->start_dt->setTimezone($calendar->timezone); |
|
| 408 | 408 | $start = $start_dt->getTimestamp(); |
| 409 | 409 | |
| 410 | - if ( $event->end_dt instanceof Carbon ) { |
|
| 411 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
| 410 | + if ($event->end_dt instanceof Carbon) { |
|
| 411 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
| 412 | 412 | } else { |
| 413 | 413 | return ''; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - $now = ( $start <= $calendar->now ) && ( $end >= $calendar->now ); |
|
| 416 | + $now = ($start <= $calendar->now) && ($end >= $calendar->now); |
|
| 417 | 417 | |
| 418 | - if ( ( 'if-now' == $tag ) && $now ) { |
|
| 419 | - return $calendar->get_event_html( $event, $partial ); |
|
| 420 | - } elseif ( ( 'if-not-now' == $tag ) && ( false == $now ) ) { |
|
| 421 | - return $calendar->get_event_html( $event, $partial ); |
|
| 418 | + if (('if-now' == $tag) && $now) { |
|
| 419 | + return $calendar->get_event_html($event, $partial); |
|
| 420 | + } elseif (('if-not-now' == $tag) && (false == $now)) { |
|
| 421 | + return $calendar->get_event_html($event, $partial); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | break; |
@@ -426,15 +426,15 @@ discard block |
||
| 426 | 426 | case 'if-started' : |
| 427 | 427 | case 'if-not-started' : |
| 428 | 428 | |
| 429 | - $start = $event->start_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
| 429 | + $start = $event->start_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
| 430 | 430 | |
| 431 | - if ( 'if-started' == $tag ) { |
|
| 432 | - if ( $start < $calendar->now ) { |
|
| 433 | - return $calendar->get_event_html( $event, $partial ); |
|
| 431 | + if ('if-started' == $tag) { |
|
| 432 | + if ($start < $calendar->now) { |
|
| 433 | + return $calendar->get_event_html($event, $partial); |
|
| 434 | 434 | } |
| 435 | - } elseif ( 'if-not-started' == $tag ) { |
|
| 436 | - if ( $start > $calendar->now ) { |
|
| 437 | - return $calendar->get_event_html( $event, $partial ); |
|
| 435 | + } elseif ('if-not-started' == $tag) { |
|
| 436 | + if ($start > $calendar->now) { |
|
| 437 | + return $calendar->get_event_html($event, $partial); |
|
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | |
@@ -443,17 +443,17 @@ discard block |
||
| 443 | 443 | case 'if-ended' : |
| 444 | 444 | case 'if-not-ended' : |
| 445 | 445 | |
| 446 | - if ( false !== $event->end ) { |
|
| 446 | + if (false !== $event->end) { |
|
| 447 | 447 | |
| 448 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
| 448 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
| 449 | 449 | |
| 450 | - if ( 'if-ended' == $tag ) { |
|
| 451 | - if ( $end < $calendar->now ) { |
|
| 452 | - return $calendar->get_event_html( $event, $partial ); |
|
| 450 | + if ('if-ended' == $tag) { |
|
| 451 | + if ($end < $calendar->now) { |
|
| 452 | + return $calendar->get_event_html($event, $partial); |
|
| 453 | 453 | } |
| 454 | - } elseif ( 'if-not-ended' == $tag ) { |
|
| 455 | - if ( $end > $calendar->now ) { |
|
| 456 | - return $calendar->get_event_html( $event, $partial ); |
|
| 454 | + } elseif ('if-not-ended' == $tag) { |
|
| 455 | + if ($end > $calendar->now) { |
|
| 456 | + return $calendar->get_event_html($event, $partial); |
|
| 457 | 457 | } |
| 458 | 458 | } |
| 459 | 459 | |
@@ -462,14 +462,14 @@ discard block |
||
| 462 | 462 | break; |
| 463 | 463 | |
| 464 | 464 | case 'if-end-time' : |
| 465 | - if ( false !== $event->end ) { |
|
| 466 | - return $calendar->get_event_html( $event, $partial ); |
|
| 465 | + if (false !== $event->end) { |
|
| 466 | + return $calendar->get_event_html($event, $partial); |
|
| 467 | 467 | } |
| 468 | 468 | break; |
| 469 | 469 | |
| 470 | 470 | case 'if-no-end-time' : |
| 471 | - if ( false === $event->end ) { |
|
| 472 | - return $calendar->get_event_html( $event, $partial ); |
|
| 471 | + if (false === $event->end) { |
|
| 472 | + return $calendar->get_event_html($event, $partial); |
|
| 473 | 473 | } |
| 474 | 474 | break; |
| 475 | 475 | |
@@ -477,62 +477,62 @@ discard block |
||
| 477 | 477 | case 'if-whole-day' : |
| 478 | 478 | case 'if-not-all-day' : |
| 479 | 479 | case 'if-not-whole-day' : |
| 480 | - $bool = strstr( $tag, 'not' ) ? false : true; |
|
| 481 | - if ( $bool === $event->whole_day ) { |
|
| 482 | - return $calendar->get_event_html( $event, $partial ); |
|
| 480 | + $bool = strstr($tag, 'not') ? false : true; |
|
| 481 | + if ($bool === $event->whole_day) { |
|
| 482 | + return $calendar->get_event_html($event, $partial); |
|
| 483 | 483 | } |
| 484 | 484 | break; |
| 485 | 485 | |
| 486 | 486 | case 'if-recurring' : |
| 487 | - if ( ! empty( $event->recurrence ) ) { |
|
| 488 | - return $calendar->get_event_html( $event, $partial ); |
|
| 487 | + if ( ! empty($event->recurrence)) { |
|
| 488 | + return $calendar->get_event_html($event, $partial); |
|
| 489 | 489 | } |
| 490 | 490 | break; |
| 491 | 491 | |
| 492 | 492 | case 'if-not-recurring' : |
| 493 | - if ( false === $event->recurrence ) { |
|
| 494 | - return $calendar->get_event_html( $event, $partial ); |
|
| 493 | + if (false === $event->recurrence) { |
|
| 494 | + return $calendar->get_event_html($event, $partial); |
|
| 495 | 495 | } |
| 496 | 496 | break; |
| 497 | 497 | |
| 498 | 498 | case 'if-multi-day' : |
| 499 | - if ( false !== $event->multiple_days ) { |
|
| 500 | - return $calendar->get_event_html( $event, $partial ); |
|
| 499 | + if (false !== $event->multiple_days) { |
|
| 500 | + return $calendar->get_event_html($event, $partial); |
|
| 501 | 501 | } |
| 502 | 502 | break; |
| 503 | 503 | |
| 504 | 504 | case 'if-single-day' : |
| 505 | - if ( false === $event->multiple_days ) { |
|
| 506 | - return $calendar->get_event_html( $event, $partial ); |
|
| 505 | + if (false === $event->multiple_days) { |
|
| 506 | + return $calendar->get_event_html($event, $partial); |
|
| 507 | 507 | } |
| 508 | 508 | break; |
| 509 | 509 | |
| 510 | 510 | case 'if-location' : |
| 511 | 511 | case 'if-start-location' : |
| 512 | - if ( ! empty( $event->start_location['address'] ) ) { |
|
| 513 | - return $calendar->get_event_html( $event, $partial ); |
|
| 512 | + if ( ! empty($event->start_location['address'])) { |
|
| 513 | + return $calendar->get_event_html($event, $partial); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | return false; |
| 517 | 517 | |
| 518 | 518 | case 'if-not-location' : |
| 519 | 519 | case 'if-not-start-location' : |
| 520 | - if ( empty( $event->start_location['address'] ) ) { |
|
| 521 | - return $calendar->get_event_html( $event, $partial ); |
|
| 520 | + if (empty($event->start_location['address'])) { |
|
| 521 | + return $calendar->get_event_html($event, $partial); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | return ''; |
| 525 | 525 | |
| 526 | 526 | case 'if-not-end-location' : |
| 527 | - if ( empty( $event->end_location['address'] ) ) { |
|
| 528 | - return $calendar->get_event_html( $event, $partial ); |
|
| 527 | + if (empty($event->end_location['address'])) { |
|
| 528 | + return $calendar->get_event_html($event, $partial); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | return ''; |
| 532 | 532 | |
| 533 | 533 | case 'if-end-location' : |
| 534 | - if ( ! empty( $event->end_location['address'] ) ) { |
|
| 535 | - return $calendar->get_event_html( $event, $partial ); |
|
| 534 | + if ( ! empty($event->end_location['address'])) { |
|
| 535 | + return $calendar->get_event_html($event, $partial); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | return ''; |
@@ -542,12 +542,12 @@ discard block |
||
| 542 | 542 | * ======= */ |
| 543 | 543 | |
| 544 | 544 | default : |
| 545 | - $resultCustom = $this->do_custom_event_tag( $tag, $partial, $attr, $event ); |
|
| 546 | - if ( $resultCustom != "" ) { |
|
| 545 | + $resultCustom = $this->do_custom_event_tag($tag, $partial, $attr, $event); |
|
| 546 | + if ($resultCustom != "") { |
|
| 547 | 547 | return $resultCustom; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - return wp_kses_post( $before . $partial . $after ); |
|
| 550 | + return wp_kses_post($before.$partial.$after); |
|
| 551 | 551 | } |
| 552 | 552 | } |
| 553 | 553 | |
@@ -565,14 +565,14 @@ discard block |
||
| 565 | 565 | * |
| 566 | 566 | * @return string |
| 567 | 567 | */ |
| 568 | - private function limit_words( $text, $limit ) { |
|
| 568 | + private function limit_words($text, $limit) { |
|
| 569 | 569 | |
| 570 | - $limit = max( absint( $limit ), 0 ); |
|
| 570 | + $limit = max(absint($limit), 0); |
|
| 571 | 571 | |
| 572 | - if ( $limit > 0 && ( str_word_count( $text, 0 ) > $limit ) ) { |
|
| 573 | - $words = str_word_count( $text, 2 ); |
|
| 574 | - $pos = array_keys( $words ); |
|
| 575 | - $text = trim( substr( $text, 0, $pos[ $limit ] ) ) . '…'; |
|
| 572 | + if ($limit > 0 && (str_word_count($text, 0) > $limit)) { |
|
| 573 | + $words = str_word_count($text, 2); |
|
| 574 | + $pos = array_keys($words); |
|
| 575 | + $text = trim(substr($text, 0, $pos[$limit])).'…'; |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | return $text; |
@@ -589,26 +589,26 @@ discard block |
||
| 589 | 589 | * |
| 590 | 590 | * @return string |
| 591 | 591 | */ |
| 592 | - private function get_title( $title, $attr ) { |
|
| 592 | + private function get_title($title, $attr) { |
|
| 593 | 593 | |
| 594 | - if ( empty( $title ) ) { |
|
| 594 | + if (empty($title)) { |
|
| 595 | 595 | return ''; |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - $attr = array_merge( array( |
|
| 599 | - 'html' => '', // Parse HTML |
|
| 600 | - 'limit' => 0, // Trim length to amount of words |
|
| 601 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 598 | + $attr = array_merge(array( |
|
| 599 | + 'html' => '', // Parse HTML |
|
| 600 | + 'limit' => 0, // Trim length to amount of words |
|
| 601 | + ), (array) shortcode_parse_atts($attr)); |
|
| 602 | 602 | |
| 603 | - if ( ! empty( $attr['html'] ) ) { |
|
| 604 | - $title = wp_kses_post( $title ); |
|
| 603 | + if ( ! empty($attr['html'])) { |
|
| 604 | + $title = wp_kses_post($title); |
|
| 605 | 605 | $tag = 'div'; |
| 606 | 606 | } else { |
| 607 | - $title = $this->limit_words( $title, $attr['limit'] ); |
|
| 607 | + $title = $this->limit_words($title, $attr['limit']); |
|
| 608 | 608 | $tag = 'span'; |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - return '<' . $tag . ' class="simcal-event-title" itemprop="name">' . $title . '</' . $tag . '>'; |
|
| 611 | + return '<'.$tag.' class="simcal-event-title" itemprop="name">'.$title.'</'.$tag.'>'; |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | /** |
@@ -622,18 +622,18 @@ discard block |
||
| 622 | 622 | * |
| 623 | 623 | * @return string |
| 624 | 624 | */ |
| 625 | - private function get_description( $description, $attr ) { |
|
| 625 | + private function get_description($description, $attr) { |
|
| 626 | 626 | |
| 627 | - if ( empty( $description ) ) { |
|
| 627 | + if (empty($description)) { |
|
| 628 | 628 | return ''; |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | - $attr = array_merge( array( |
|
| 632 | - 'limit' => 0, // Trim length to number of words |
|
| 633 | - 'html' => 'no', // Parse HTML content |
|
| 634 | - 'markdown' => 'no', // Parse Markdown content |
|
| 635 | - 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
| 636 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 631 | + $attr = array_merge(array( |
|
| 632 | + 'limit' => 0, // Trim length to number of words |
|
| 633 | + 'html' => 'no', // Parse HTML content |
|
| 634 | + 'markdown' => 'no', // Parse Markdown content |
|
| 635 | + 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
| 636 | + ), (array) shortcode_parse_atts($attr)); |
|
| 637 | 637 | |
| 638 | 638 | $allow_html = 'no' != $attr['html'] ? true : false; |
| 639 | 639 | $allow_md = 'no' != $attr['markdown'] ? true : false; |
@@ -641,23 +641,23 @@ discard block |
||
| 641 | 641 | $html = '<div class="simcal-event-description" itemprop="description">'; |
| 642 | 642 | |
| 643 | 643 | // Markdown and HTML don't play well together, use one or the other in the same tag. |
| 644 | - if ( $allow_html || $allow_md ) { |
|
| 645 | - if ( $allow_html ) { |
|
| 646 | - $description = wp_kses_post( $description ); |
|
| 647 | - } elseif ( $allow_md ) { |
|
| 644 | + if ($allow_html || $allow_md) { |
|
| 645 | + if ($allow_html) { |
|
| 646 | + $description = wp_kses_post($description); |
|
| 647 | + } elseif ($allow_md) { |
|
| 648 | 648 | $markdown = new \Parsedown(); |
| 649 | - $description = $markdown->text( wp_strip_all_tags( $description ) ); |
|
| 649 | + $description = $markdown->text(wp_strip_all_tags($description)); |
|
| 650 | 650 | } |
| 651 | 651 | } else { |
| 652 | - $description = wpautop( $description ); |
|
| 652 | + $description = wpautop($description); |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | - $description = $this->limit_words( $description, $attr['limit'] ); |
|
| 655 | + $description = $this->limit_words($description, $attr['limit']); |
|
| 656 | 656 | |
| 657 | - $html .= $description . '</div>'; |
|
| 657 | + $html .= $description.'</div>'; |
|
| 658 | 658 | |
| 659 | - if ( 'no' != $attr['autolink'] ) { |
|
| 660 | - $html = ' ' . make_clickable( $html ); |
|
| 659 | + if ('no' != $attr['autolink']) { |
|
| 660 | + $html = ' '.make_clickable($html); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | return $html; |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | * |
| 674 | 674 | * @return string |
| 675 | 675 | */ |
| 676 | - private function get_when( Event $event ) { |
|
| 676 | + private function get_when(Event $event) { |
|
| 677 | 677 | |
| 678 | 678 | //$start = $event->start_dt->setTimezone( $event->timezone ); |
| 679 | 679 | //$end = ! is_null( $event->end_dt ) ? $event->end_dt->setTimezone( $event->timezone ) : null; |
@@ -683,41 +683,41 @@ discard block |
||
| 683 | 683 | $time_start = ''; |
| 684 | 684 | $time_end = ''; |
| 685 | 685 | $start_ts = $start->timestamp; |
| 686 | - $end_ts = ! is_null( $end ) ? $end->timestamp : null; |
|
| 686 | + $end_ts = ! is_null($end) ? $end->timestamp : null; |
|
| 687 | 687 | $start_iso = $start->toIso8601String(); |
| 688 | - $end_iso = ! is_null( $end ) ? $end->toIso8601String() : null;; |
|
| 688 | + $end_iso = ! is_null($end) ? $end->toIso8601String() : null; ; |
|
| 689 | 689 | |
| 690 | - if ( ! $event->whole_day ) { |
|
| 690 | + if ( ! $event->whole_day) { |
|
| 691 | 691 | |
| 692 | - $time_start = $this->calendar->datetime_separator . ' <span class="simcal-event-start simcal-event-start-time" ' . 'data-event-start="' . $start_ts . '" ' . 'data-event-format="' . $this->calendar->time_format . '" ' . 'itemprop="startDate" content="' . $start_iso . '">' . $start->format( $this->calendar->time_format ) . '</span> '; |
|
| 692 | + $time_start = $this->calendar->datetime_separator.' <span class="simcal-event-start simcal-event-start-time" '.'data-event-start="'.$start_ts.'" '.'data-event-format="'.$this->calendar->time_format.'" '.'itemprop="startDate" content="'.$start_iso.'">'.$start->format($this->calendar->time_format).'</span> '; |
|
| 693 | 693 | |
| 694 | - if ( $end instanceof Carbon ) { |
|
| 694 | + if ($end instanceof Carbon) { |
|
| 695 | 695 | |
| 696 | - $time_end = ' <span class="simcal-event-end simcal-event-end-time" ' . 'data-event-end="' . $end_ts . '" ' . 'data-event-format="' . $this->calendar->time_format . '" ' . 'itemprop="endDate" content="' . $end_iso . '">' . $end->format( $this->calendar->time_format ) . '</span> '; |
|
| 696 | + $time_end = ' <span class="simcal-event-end simcal-event-end-time" '.'data-event-end="'.$end_ts.'" '.'data-event-format="'.$this->calendar->time_format.'" '.'itemprop="endDate" content="'.$end_iso.'">'.$end->format($this->calendar->time_format).'</span> '; |
|
| 697 | 697 | |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | - if ( $event->multiple_days ) { |
|
| 702 | + if ($event->multiple_days) { |
|
| 703 | 703 | |
| 704 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . 'data-event-start="' . $start_ts . '" ' . 'data-event-format="' . $this->calendar->date_format . '" ' . 'itemprop="startDate" content="' . $start_iso . '">' . $start->format( $this->calendar->date_format ) . '</span> ' . $time_start; |
|
| 704 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '.'data-event-start="'.$start_ts.'" '.'data-event-format="'.$this->calendar->date_format.'" '.'itemprop="startDate" content="'.$start_iso.'">'.$start->format($this->calendar->date_format).'</span> '.$time_start; |
|
| 705 | 705 | |
| 706 | - if ( $end instanceof Carbon ) { |
|
| 706 | + if ($end instanceof Carbon) { |
|
| 707 | 707 | |
| 708 | - $output .= '-' . ' <span class="simcal-event-start simcal-event-end-date" ' . 'data-event-start="' . $end_ts . '" ' . 'data-event-format="' . $this->calendar->date_format . '" ' . 'itemprop="endDate" content="' . $end_iso . '">' . $end->format( $this->calendar->date_format ) . '</span> ' . $time_end; |
|
| 708 | + $output .= '-'.' <span class="simcal-event-start simcal-event-end-date" '.'data-event-start="'.$end_ts.'" '.'data-event-format="'.$this->calendar->date_format.'" '.'itemprop="endDate" content="'.$end_iso.'">'.$end->format($this->calendar->date_format).'</span> '.$time_end; |
|
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | } else { |
| 712 | 712 | |
| 713 | - $time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : ''; |
|
| 713 | + $time_end = ! empty($time_start) && ! empty($time_end) ? ' - '.$time_end : ''; |
|
| 714 | 714 | |
| 715 | 715 | // All-day events also need startDate for schema data. |
| 716 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . 'data-event-start="' . $start_ts . '" ' . 'data-event-format="' . $this->calendar->date_format . '" ' . 'itemprop="startDate" content="' . $start_iso . '">' . $start->format( $this->calendar->date_format ) . '</span> ' . $time_start . $time_end; |
|
| 716 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '.'data-event-start="'.$start_ts.'" '.'data-event-format="'.$this->calendar->date_format.'" '.'itemprop="startDate" content="'.$start_iso.'">'.$start->format($this->calendar->date_format).'</span> '.$time_start.$time_end; |
|
| 717 | 717 | |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - return trim( $output ); |
|
| 720 | + return trim($output); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | /** |
@@ -732,52 +732,52 @@ discard block |
||
| 732 | 732 | * |
| 733 | 733 | * @return string |
| 734 | 734 | */ |
| 735 | - private function get_dt( $tag, Event $event, $attr ) { |
|
| 735 | + private function get_dt($tag, Event $event, $attr) { |
|
| 736 | 736 | |
| 737 | - $bound = 0 === strpos( $tag, 'end' ) ? 'end' : 'start'; |
|
| 737 | + $bound = 0 === strpos($tag, 'end') ? 'end' : 'start'; |
|
| 738 | 738 | |
| 739 | - if ( ( 'end' == $bound ) && ( false === $event->end ) ) { |
|
| 739 | + if (('end' == $bound) && (false === $event->end)) { |
|
| 740 | 740 | return ''; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - $dt = $bound . '_dt'; |
|
| 743 | + $dt = $bound.'_dt'; |
|
| 744 | 744 | |
| 745 | - if ( ! $event->$dt instanceof Carbon ) { |
|
| 745 | + if ( ! $event->$dt instanceof Carbon) { |
|
| 746 | 746 | return ''; |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | $event_dt = $event->$dt; |
| 750 | 750 | |
| 751 | - $attr = array_merge( array( |
|
| 751 | + $attr = array_merge(array( |
|
| 752 | 752 | 'format' => '', |
| 753 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 753 | + ), (array) shortcode_parse_atts($attr)); |
|
| 754 | 754 | |
| 755 | - $format = ltrim( strstr( $tag, '-' ), '-' ); |
|
| 755 | + $format = ltrim(strstr($tag, '-'), '-'); |
|
| 756 | 756 | $dt_format = ''; |
| 757 | 757 | |
| 758 | - if ( ! empty( $attr['format'] ) ) { |
|
| 759 | - $dt_format = esc_attr( wp_strip_all_tags( $attr['format'] ) ); |
|
| 760 | - } elseif ( 'date' == $format ) { |
|
| 758 | + if ( ! empty($attr['format'])) { |
|
| 759 | + $dt_format = esc_attr(wp_strip_all_tags($attr['format'])); |
|
| 760 | + } elseif ('date' == $format) { |
|
| 761 | 761 | $dt_format = $this->calendar->date_format; |
| 762 | - } elseif ( 'time' == $format ) { |
|
| 762 | + } elseif ('time' == $format) { |
|
| 763 | 763 | $dt_format = $this->calendar->time_format; |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | $dt_ts = $event_dt->timestamp; |
| 767 | 767 | |
| 768 | - if ( 'human' == $format ) { |
|
| 769 | - $value = human_time_diff( $dt_ts, Carbon::now( $event->timezone )->getTimestamp() ); |
|
| 768 | + if ('human' == $format) { |
|
| 769 | + $value = human_time_diff($dt_ts, Carbon::now($event->timezone)->getTimestamp()); |
|
| 770 | 770 | |
| 771 | - if ( $dt_ts < Carbon::now( $event->timezone )->getTimestamp() ) { |
|
| 772 | - $value .= ' ' . _x( 'ago', 'human date event builder code modifier', 'google-calendar-events' ); |
|
| 771 | + if ($dt_ts < Carbon::now($event->timezone)->getTimestamp()) { |
|
| 772 | + $value .= ' '._x('ago', 'human date event builder code modifier', 'google-calendar-events'); |
|
| 773 | 773 | } else { |
| 774 | - $value .= ' ' . _x( 'from now', 'human date event builder code modifier', 'google-calendar-events' ); |
|
| 774 | + $value .= ' '._x('from now', 'human date event builder code modifier', 'google-calendar-events'); |
|
| 775 | 775 | } |
| 776 | 776 | } else { |
| 777 | - $value = $event->$dt->format( $dt_format ); |
|
| 777 | + $value = $event->$dt->format($dt_format); |
|
| 778 | 778 | } |
| 779 | 779 | |
| 780 | - return '<span class="simcal-event-' . $bound . ' ' . 'simcal-event-' . $bound . '-' . $format . '" ' . 'data-event-' . $bound . '="' . $dt_ts . '" ' . 'data-event-format="' . $dt_format . '" ' . 'itemprop="' . $bound . 'Date" content="' . $event_dt->toIso8601String() . '">' . $value . '</span>'; |
|
| 780 | + return '<span class="simcal-event-'.$bound.' '.'simcal-event-'.$bound.'-'.$format.'" '.'data-event-'.$bound.'="'.$dt_ts.'" '.'data-event-format="'.$dt_format.'" '.'itemprop="'.$bound.'Date" content="'.$event_dt->toIso8601String().'">'.$value.'</span>'; |
|
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | /** |
@@ -793,23 +793,23 @@ discard block |
||
| 793 | 793 | * |
| 794 | 794 | * @return string |
| 795 | 795 | */ |
| 796 | - private function make_link( $tag, $url, $content, $attr ) { |
|
| 796 | + private function make_link($tag, $url, $content, $attr) { |
|
| 797 | 797 | |
| 798 | - if ( empty( $url ) ) { |
|
| 798 | + if (empty($url)) { |
|
| 799 | 799 | return ''; |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - $text = empty( $content ) ? $url : $content; |
|
| 802 | + $text = empty($content) ? $url : $content; |
|
| 803 | 803 | |
| 804 | - $attr = array_merge( array( |
|
| 805 | - 'autolink' => false, // Convert url to link anchor |
|
| 806 | - 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
| 807 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 804 | + $attr = array_merge(array( |
|
| 805 | + 'autolink' => false, // Convert url to link anchor |
|
| 806 | + 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
| 807 | + ), (array) shortcode_parse_atts($attr)); |
|
| 808 | 808 | |
| 809 | 809 | $anchor = $tag != 'url' ? 'yes' : $attr['autolink']; |
| 810 | 810 | $target = $attr['newwindow'] !== false ? 'target="_blank"' : ''; |
| 811 | 811 | |
| 812 | - return $anchor !== false ? ' <a href="' . esc_url( $url ) . '" ' . $target . '>' . $text . '</a>' : ' ' . $text; |
|
| 812 | + return $anchor !== false ? ' <a href="'.esc_url($url).'" '.$target.'>'.$text.'</a>' : ' '.$text; |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
@@ -822,20 +822,20 @@ discard block |
||
| 822 | 822 | * |
| 823 | 823 | * @return string |
| 824 | 824 | */ |
| 825 | - private function get_attachments( $attachments ) { |
|
| 825 | + private function get_attachments($attachments) { |
|
| 826 | 826 | |
| 827 | - $html = '<ul class="simcal-attachments">' . "\n\t"; |
|
| 827 | + $html = '<ul class="simcal-attachments">'."\n\t"; |
|
| 828 | 828 | |
| 829 | - foreach ( $attachments as $attachment ) { |
|
| 829 | + foreach ($attachments as $attachment) { |
|
| 830 | 830 | $html .= '<li class="simcal-attachment">'; |
| 831 | - $html .= '<a href="' . $attachment['url'] . '" target="_blank">'; |
|
| 832 | - $html .= ! empty( $attachment['icon'] ) ? '<img src="' . $attachment['icon'] . '" />' : ''; |
|
| 833 | - $html .= '<span>' . $attachment['name'] . '</span>'; |
|
| 831 | + $html .= '<a href="'.$attachment['url'].'" target="_blank">'; |
|
| 832 | + $html .= ! empty($attachment['icon']) ? '<img src="'.$attachment['icon'].'" />' : ''; |
|
| 833 | + $html .= '<span>'.$attachment['name'].'</span>'; |
|
| 834 | 834 | $html .= '</a>'; |
| 835 | - $html .= '</li>' . "\n"; |
|
| 835 | + $html .= '</li>'."\n"; |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | - $html .= '</ul>' . "\n"; |
|
| 838 | + $html .= '</ul>'."\n"; |
|
| 839 | 839 | |
| 840 | 840 | return $html; |
| 841 | 841 | } |
@@ -851,41 +851,41 @@ discard block |
||
| 851 | 851 | * |
| 852 | 852 | * @return string |
| 853 | 853 | */ |
| 854 | - private function get_attendees( $attendees, $attr ) { |
|
| 854 | + private function get_attendees($attendees, $attr) { |
|
| 855 | 855 | |
| 856 | - $attr = array_merge( array( |
|
| 857 | - 'photo' => 'show', // show/hide attendee photo |
|
| 858 | - 'email' => 'hide', // show/hide attendee email address |
|
| 859 | - 'rsvp' => 'hide', // show/hide rsvp response status |
|
| 860 | - 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
| 861 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 856 | + $attr = array_merge(array( |
|
| 857 | + 'photo' => 'show', // show/hide attendee photo |
|
| 858 | + 'email' => 'hide', // show/hide attendee email address |
|
| 859 | + 'rsvp' => 'hide', // show/hide rsvp response status |
|
| 860 | + 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
| 861 | + ), (array) shortcode_parse_atts($attr)); |
|
| 862 | 862 | |
| 863 | - $html = '<ul class="simcal-attendees" itemprop="attendees">' . "\n\t"; |
|
| 863 | + $html = '<ul class="simcal-attendees" itemprop="attendees">'."\n\t"; |
|
| 864 | 864 | |
| 865 | 865 | $known = 0; |
| 866 | 866 | $unknown = 0; |
| 867 | 867 | |
| 868 | - foreach ( $attendees as $attendee ) { |
|
| 868 | + foreach ($attendees as $attendee) { |
|
| 869 | 869 | |
| 870 | - if ( 'yes' == $attr['response'] && 'yes' != $attendee['response'] ) { |
|
| 870 | + if ('yes' == $attr['response'] && 'yes' != $attendee['response']) { |
|
| 871 | 871 | continue; |
| 872 | - } elseif ( 'no' == $attr['response'] && 'no' != $attendee['response'] ) { |
|
| 872 | + } elseif ('no' == $attr['response'] && 'no' != $attendee['response']) { |
|
| 873 | 873 | continue; |
| 874 | - } elseif ( 'maybe' == $attr['response'] && ! in_array( $attendee['response'], array( 'yes', 'maybe' ) ) ) { |
|
| 874 | + } elseif ('maybe' == $attr['response'] && ! in_array($attendee['response'], array('yes', 'maybe'))) { |
|
| 875 | 875 | continue; |
| 876 | 876 | } |
| 877 | 877 | |
| 878 | - if ( ! empty( $attendee['name'] ) ) { |
|
| 878 | + if ( ! empty($attendee['name'])) { |
|
| 879 | 879 | |
| 880 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $attendee['photo'] . '" itemprop="image" />' : ''; |
|
| 881 | - $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response( $attendee['response'] ) : ''; |
|
| 882 | - $guest = $photo . '<span itemprop="name">' . $attendee['name'] . $response . '</span>'; |
|
| 880 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$attendee['photo'].'" itemprop="image" />' : ''; |
|
| 881 | + $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response($attendee['response']) : ''; |
|
| 882 | + $guest = $photo.'<span itemprop="name">'.$attendee['name'].$response.'</span>'; |
|
| 883 | 883 | |
| 884 | - if ( ! empty( $attendee['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
| 885 | - $guest = sprintf( '<a href="mailto:' . $attendee['email'] . '" itemprop="email">%s</a>', $guest ); |
|
| 884 | + if ( ! empty($attendee['email']) && ('show' == $attr['email'])) { |
|
| 885 | + $guest = sprintf('<a href="mailto:'.$attendee['email'].'" itemprop="email">%s</a>', $guest); |
|
| 886 | 886 | } |
| 887 | 887 | |
| 888 | - $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">' . $guest . '</li>' . "\n"; |
|
| 888 | + $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">'.$guest.'</li>'."\n"; |
|
| 889 | 889 | |
| 890 | 890 | $known++; |
| 891 | 891 | |
@@ -896,21 +896,21 @@ discard block |
||
| 896 | 896 | } |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | - if ( $unknown > 0 ) { |
|
| 900 | - if ( $known > 0 ) { |
|
| 899 | + if ($unknown > 0) { |
|
| 900 | + if ($known > 0) { |
|
| 901 | 901 | /* translators: One more person attending the event. */ |
| 902 | - $others = sprintf( _n( '1 more attendee', '%s more attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
| 902 | + $others = sprintf(_n('1 more attendee', '%s more attendees', $unknown, 'google-calendar-events'), $unknown); |
|
| 903 | 903 | } else { |
| 904 | 904 | /* translators: One or more persons attending the event whose name is unknown. */ |
| 905 | - $others = sprintf( _n( '1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
| 905 | + $others = sprintf(_n('1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events'), $unknown); |
|
| 906 | 906 | } |
| 907 | - $photo = $attr['photo'] !== 'hide' ? get_avatar( '', 128 ) : ''; |
|
| 908 | - $html .= '<li class="simcal-attendee simcal-attendee-anonymous">' . $photo . '<span>' . $others . '</span></li>' . "\n"; |
|
| 909 | - } elseif ( $known === 0 ) { |
|
| 910 | - $html .= '<li class="simcal-attendee">' . _x( 'No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events' ) . '</li>' . "\n"; |
|
| 907 | + $photo = $attr['photo'] !== 'hide' ? get_avatar('', 128) : ''; |
|
| 908 | + $html .= '<li class="simcal-attendee simcal-attendee-anonymous">'.$photo.'<span>'.$others.'</span></li>'."\n"; |
|
| 909 | + } elseif ($known === 0) { |
|
| 910 | + $html .= '<li class="simcal-attendee">'._x('No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events').'</li>'."\n"; |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | - $html .= '</ul>' . "\n"; |
|
| 913 | + $html .= '</ul>'."\n"; |
|
| 914 | 914 | |
| 915 | 915 | return $html; |
| 916 | 916 | } |
@@ -924,23 +924,23 @@ discard block |
||
| 924 | 924 | * |
| 925 | 925 | * @return string |
| 926 | 926 | */ |
| 927 | - private function get_rsvp_response( $response ) { |
|
| 927 | + private function get_rsvp_response($response) { |
|
| 928 | 928 | |
| 929 | - if ( 'yes' == $response ) { |
|
| 929 | + if ('yes' == $response) { |
|
| 930 | 930 | /* translators: Someone replied with 'yes' to a rsvp request. */ |
| 931 | - $rsvp = __( 'Attending', 'google-calendar-events' ); |
|
| 932 | - } elseif ( 'no' == $response ) { |
|
| 931 | + $rsvp = __('Attending', 'google-calendar-events'); |
|
| 932 | + } elseif ('no' == $response) { |
|
| 933 | 933 | /* translators: Someone replied with 'no' to a rsvp request. */ |
| 934 | - $rsvp = __( 'Not attending', 'google-calendar-events' ); |
|
| 935 | - } elseif ( 'maybe' == $response ) { |
|
| 934 | + $rsvp = __('Not attending', 'google-calendar-events'); |
|
| 935 | + } elseif ('maybe' == $response) { |
|
| 936 | 936 | /* translators: Someone replied with 'maybe' to a rsvp request. */ |
| 937 | - $rsvp = __( 'Maybe attending', 'google-calendar-events' ); |
|
| 937 | + $rsvp = __('Maybe attending', 'google-calendar-events'); |
|
| 938 | 938 | } else { |
| 939 | 939 | /* translators: Someone did not send yet a rsvp confirmation to join an event. */ |
| 940 | - $rsvp = __( 'Response pending', 'google-calendar-events' ); |
|
| 940 | + $rsvp = __('Response pending', 'google-calendar-events'); |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | - return ' <small>(' . $rsvp . ')</small>'; |
|
| 943 | + return ' <small>('.$rsvp.')</small>'; |
|
| 944 | 944 | } |
| 945 | 945 | |
| 946 | 946 | /** |
@@ -954,21 +954,21 @@ discard block |
||
| 954 | 954 | * |
| 955 | 955 | * @return string |
| 956 | 956 | */ |
| 957 | - private function get_organizer( $organizer, $attr ) { |
|
| 957 | + private function get_organizer($organizer, $attr) { |
|
| 958 | 958 | |
| 959 | - $attr = array_merge( array( |
|
| 960 | - 'photo' => 'show', // show/hide attendee photo |
|
| 961 | - 'email' => 'hide', // show/hide attendee email address |
|
| 962 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
| 959 | + $attr = array_merge(array( |
|
| 960 | + 'photo' => 'show', // show/hide attendee photo |
|
| 961 | + 'email' => 'hide', // show/hide attendee email address |
|
| 962 | + ), (array) shortcode_parse_atts($attr)); |
|
| 963 | 963 | |
| 964 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $organizer['photo'] . '" itemprop="image" />' : ''; |
|
| 965 | - $organizer_html = $photo . '<span itemprop="name">' . $organizer['name'] . '</span>'; |
|
| 964 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$organizer['photo'].'" itemprop="image" />' : ''; |
|
| 965 | + $organizer_html = $photo.'<span itemprop="name">'.$organizer['name'].'</span>'; |
|
| 966 | 966 | |
| 967 | - if ( ! empty( $organizer['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
| 968 | - $organizer_html = sprintf( '<a href="mailto:' . $organizer['email'] . '" itemprop="email">%s</a>', $organizer_html ); |
|
| 967 | + if ( ! empty($organizer['email']) && ('show' == $attr['email'])) { |
|
| 968 | + $organizer_html = sprintf('<a href="mailto:'.$organizer['email'].'" itemprop="email">%s</a>', $organizer_html); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | - return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">' . $organizer_html . '</div>'; |
|
| 971 | + return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">'.$organizer_html.'</div>'; |
|
| 972 | 972 | } |
| 973 | 973 | |
| 974 | 974 | /** |
@@ -993,38 +993,38 @@ discard block |
||
| 993 | 993 | // This is largely borrowed on get_shortcode_regex() from WordPress Core. |
| 994 | 994 | // @see /wp-includes/shortcodes.php (with some modification) |
| 995 | 995 | |
| 996 | - $tagregexp = implode( '|', array_values( $this->tags ) ); |
|
| 996 | + $tagregexp = implode('|', array_values($this->tags)); |
|
| 997 | 997 | |
| 998 | - return '/' . '\\[' // Opening bracket |
|
| 998 | + return '/'.'\\[' // Opening bracket |
|
| 999 | 999 | . '(\\[?)' // 1: Optional second opening bracket for escaping tags: [[tag]] |
| 1000 | 1000 | . "($tagregexp)" // 2: Tag name |
| 1001 | 1001 | . '(?![\\w-])' // Not followed by word character or hyphen |
| 1002 | 1002 | . '(' // 3: Unroll the loop: Inside the opening tag |
| 1003 | 1003 | . '[^\\]\\/]*' // Not a closing bracket or forward slash |
| 1004 | - . '(?:' . '\\/(?!\\])' // A forward slash not followed by a closing bracket |
|
| 1004 | + . '(?:'.'\\/(?!\\])' // A forward slash not followed by a closing bracket |
|
| 1005 | 1005 | . '[^\\]\\/]*' // Not a closing bracket or forward slash |
| 1006 | - . ')*?' . ')' . '(?:' . '(\\/)' // 4: Self closing tag ... |
|
| 1006 | + . ')*?'.')'.'(?:'.'(\\/)' // 4: Self closing tag ... |
|
| 1007 | 1007 | . '\\]' // ... and closing bracket |
| 1008 | - . '|' . '\\]' // Closing bracket |
|
| 1009 | - . '(?:' . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing tags |
|
| 1008 | + . '|'.'\\]' // Closing bracket |
|
| 1009 | + . '(?:'.'(' // 5: Unroll the loop: Optionally, anything between the opening and closing tags |
|
| 1010 | 1010 | . '[^\\[]*+' // Not an opening bracket |
| 1011 | - . '(?:' . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag |
|
| 1011 | + . '(?:'.'\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag |
|
| 1012 | 1012 | . '[^\\[]*+' // Not an opening bracket |
| 1013 | - . ')*+' . ')' . '\\[\\/\\2\\]' // Closing tag |
|
| 1014 | - . ')?' . ')' . '(\\]?)' // 6: Optional second closing bracket for escaping tags: [[tag]] |
|
| 1013 | + . ')*+'.')'.'\\[\\/\\2\\]' // Closing tag |
|
| 1014 | + . ')?'.')'.'(\\]?)' // 6: Optional second closing bracket for escaping tags: [[tag]] |
|
| 1015 | 1015 | . '/s'; |
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | 1018 | //allow other plugins to register own event tags |
| 1019 | 1019 | private function add_custom_event_tags() { |
| 1020 | - $array = apply_filters( 'simcal_event_tags_add_custom', array() ); |
|
| 1020 | + $array = apply_filters('simcal_event_tags_add_custom', array()); |
|
| 1021 | 1021 | |
| 1022 | 1022 | return $array; |
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | //allow other plugins to replace own (registered) event tags with their value |
| 1026 | - private function do_custom_event_tag( $tag, $partial, $attr, $event ) { |
|
| 1027 | - $returnvalue = apply_filters( 'simcal_event_tags_do_custom', "", $tag, $partial, $attr, $event ); |
|
| 1026 | + private function do_custom_event_tag($tag, $partial, $attr, $event) { |
|
| 1027 | + $returnvalue = apply_filters('simcal_event_tags_do_custom', "", $tag, $partial, $attr, $event); |
|
| 1028 | 1028 | |
| 1029 | 1029 | return $returnvalue; |
| 1030 | 1030 | } |