@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Abstracts\Field; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @param array $field |
| 36 | 36 | */ |
| 37 | - public function __construct( $field ) { |
|
| 38 | - $this->addon = isset( $field['addon'] ) ? esc_attr( $field['addon'] ) : ''; |
|
| 37 | + public function __construct($field) { |
|
| 38 | + $this->addon = isset($field['addon']) ? esc_attr($field['addon']) : ''; |
|
| 39 | 39 | $this->type_class = 'simcal-field-license'; |
| 40 | - parent::__construct( $field ); |
|
| 40 | + parent::__construct($field); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function html() { |
| 49 | 49 | |
| 50 | - if ( ! empty( $this->addon ) ) { |
|
| 50 | + if ( ! empty($this->addon)) { |
|
| 51 | 51 | |
| 52 | - $status = apply_filters( 'simcal_addon_status_' . $this->addon, simcal_get_license_status( $this->addon ) ); |
|
| 52 | + $status = apply_filters('simcal_addon_status_'.$this->addon, simcal_get_license_status($this->addon)); |
|
| 53 | 53 | |
| 54 | - if ( $status !== 'valid' ) { |
|
| 54 | + if ($status !== 'valid') { |
|
| 55 | 55 | $display_activate = 'display: inline-block'; |
| 56 | 56 | $display_deactivate = 'display: none'; |
| 57 | 57 | $active = 'valid' == $status ? 'display: block' : 'display: none'; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | } else { |
| 60 | 60 | $display_activate = $active = 'display: none'; |
| 61 | 61 | $display_deactivate = 'display: inline-block'; |
| 62 | - $disabled = empty( $this->value ) ? '' : 'disabled="disabled"'; |
|
| 62 | + $disabled = empty($this->value) ? '' : 'disabled="disabled"'; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | ?> |
@@ -74,16 +74,16 @@ discard block |
||
| 74 | 74 | <span class="simcal-addon-manage-license-buttons"> |
| 75 | 75 | |
| 76 | 76 | <button class="button-secondary simcal-addon-manage-license deactivate" data-add-on="<?php echo $this->addon; ?>" style="<?php echo $display_deactivate; ?>"> |
| 77 | - <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e( 'Deactivate', 'google-calendar-events' ); ?> |
|
| 77 | + <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e('Deactivate', 'google-calendar-events'); ?> |
|
| 78 | 78 | </button> |
| 79 | 79 | |
| 80 | 80 | <button class="button-secondary simcal-addon-manage-license activate" data-add-on="<?php echo $this->addon; ?>" style="<?php echo $display_activate; ?>"> |
| 81 | - <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e( 'Activate', 'google-calendar-events' ); ?> |
|
| 81 | + <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e('Activate', 'google-calendar-events'); ?> |
|
| 82 | 82 | </button> |
| 83 | 83 | |
| 84 | 84 | <span class="error" style="color: red; display: none"> </span> |
| 85 | 85 | |
| 86 | - <strong class="label" style="color:green; <?php echo $active; ?>"> <?php _e( '(active)', 'google-calendar-events' ); ?></strong> |
|
| 86 | + <strong class="label" style="color:green; <?php echo $active; ?>"> <?php _e('(active)', 'google-calendar-events'); ?></strong> |
|
| 87 | 87 | |
| 88 | 88 | </span> |
| 89 | 89 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Abstracts\Field; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; // Exit if accessed directly. |
| 13 | 13 | } |
| 14 | 14 | |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @param array $field |
| 30 | 30 | */ |
| 31 | - public function __construct( $field ) { |
|
| 31 | + public function __construct($field) { |
|
| 32 | 32 | $this->type_class = 'simcal-field-checkboxes'; |
| 33 | - parent::__construct( $field ); |
|
| 33 | + parent::__construct($field); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -40,33 +40,33 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function html() { |
| 42 | 42 | |
| 43 | - if ( ! empty( $this->options ) && count( (array) $this->options ) > 1 ) { |
|
| 43 | + if ( ! empty($this->options) && count((array) $this->options) > 1) { |
|
| 44 | 44 | |
| 45 | - if ( ! empty( $this->description ) ) { |
|
| 46 | - echo '<p class="description">' . wp_kses_post( $this->description ) . ' ' . $this->tooltip . '</p>'; |
|
| 45 | + if ( ! empty($this->description)) { |
|
| 46 | + echo '<p class="description">'.wp_kses_post($this->description).' '.$this->tooltip.'</p>'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | ?> |
| 50 | - <fieldset class="<?php echo $this->class; ?>" <?php echo ! empty( $this->style ) ? 'style="' . $this->style . '"' : ''; ?>> |
|
| 50 | + <fieldset class="<?php echo $this->class; ?>" <?php echo ! empty($this->style) ? 'style="'.$this->style.'"' : ''; ?>> |
|
| 51 | 51 | <?php |
| 52 | 52 | |
| 53 | - if ( ! empty( $this->title ) ) { |
|
| 54 | - echo '<legend class="screen-reader-text"><span>' . $this->title . '</span></legend>'; |
|
| 53 | + if ( ! empty($this->title)) { |
|
| 54 | + echo '<legend class="screen-reader-text"><span>'.$this->title.'</span></legend>'; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | ?> |
| 58 | 58 | <ul> |
| 59 | - <?php foreach ( $this->options as $option => $name ) : ?> |
|
| 59 | + <?php foreach ($this->options as $option => $name) : ?> |
|
| 60 | 60 | <li> |
| 61 | - <label for="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>"> |
|
| 61 | + <label for="<?php echo $this->id.'-'.trim(strval($option)); ?>"> |
|
| 62 | 62 | <input name="<?php echo $this->name; ?>" |
| 63 | - id="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>" |
|
| 63 | + id="<?php echo $this->id.'-'.trim(strval($option)); ?>" |
|
| 64 | 64 | class="simcal-field simcal-field-checkbox" |
| 65 | 65 | type="checkbox" |
| 66 | - value="<?php echo trim( strval( $option ) ); ?>" |
|
| 67 | - <?php checked( $this->value, 'yes', true ); ?> |
|
| 66 | + value="<?php echo trim(strval($option)); ?>" |
|
| 67 | + <?php checked($this->value, 'yes', true); ?> |
|
| 68 | 68 | <?php echo $this->attributes; ?> |
| 69 | - /><?php echo esc_attr( $name ); ?> |
|
| 69 | + /><?php echo esc_attr($name); ?> |
|
| 70 | 70 | </label> |
| 71 | 71 | </li> |
| 72 | 72 | <?php endforeach; ?> |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | } else { |
| 78 | 78 | |
| 79 | 79 | ?> |
| 80 | - <span class="simcal-field-bool" <?php echo $this->style ? 'style="' . $this->style . '"' : ''; ?>> |
|
| 81 | - <?php if ( ! empty( $this->title ) ) : ?> |
|
| 80 | + <span class="simcal-field-bool" <?php echo $this->style ? 'style="'.$this->style.'"' : ''; ?>> |
|
| 81 | + <?php if ( ! empty($this->title)) : ?> |
|
| 82 | 82 | <span class="screen-reader-text"><?php echo $this->title; ?></span> |
| 83 | 83 | <?php endif; ?> |
| 84 | 84 | <input name="<?php echo $this->name; ?>" |
@@ -86,15 +86,15 @@ discard block |
||
| 86 | 86 | id="<?php echo $this->id; ?>" |
| 87 | 87 | class="simcal-field simcal-field-checkbox <?php echo $this->class; ?>" |
| 88 | 88 | value="yes" |
| 89 | - <?php checked( $this->value, 'yes', true ); ?> |
|
| 90 | - <?php echo $this->attributes; ?>/><?php echo ( ! empty( $this->text ) ? $this->text : __( 'Yes', 'google-calendar-events' ) ); ?> |
|
| 89 | + <?php checked($this->value, 'yes', true); ?> |
|
| 90 | + <?php echo $this->attributes; ?>/><?php echo ( ! empty($this->text) ? $this->text : __('Yes', 'google-calendar-events')); ?> |
|
| 91 | 91 | </span> |
| 92 | 92 | <?php |
| 93 | 93 | |
| 94 | 94 | echo $this->tooltip; |
| 95 | 95 | |
| 96 | - if ( ! empty( $this->description ) ) { |
|
| 97 | - echo '<p class="description">' . wp_kses_post( $this->description ) . '</p>'; |
|
| 96 | + if ( ! empty($this->description)) { |
|
| 97 | + echo '<p class="description">'.wp_kses_post($this->description).'</p>'; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | } |
@@ -143,7 +143,7 @@ |
||
| 143 | 143 | |
| 144 | 144 | $links = array(); |
| 145 | 145 | $links['add-ons'] = '<a href="' . simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'plugin-listing' ) . '" target="_blank" >' . |
| 146 | - __( 'Add-ons', 'google-calendar-events' ) . '</a>'; |
|
| 146 | + __( 'Add-ons', 'google-calendar-events' ) . '</a>'; |
|
| 147 | 147 | |
| 148 | 148 | return apply_filters( 'simcal_plugin_action_links', array_merge( $meta_links, $links ) ); |
| 149 | 149 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | */ |
| 7 | 7 | namespace SimpleCalendar\Admin; |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if ( ! defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -44,17 +44,17 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | self::$main_menu = 'edit.php?post_type=calendar'; |
| 46 | 46 | |
| 47 | - add_action( 'admin_menu', array( __CLASS__, 'add_menu_items' ) ); |
|
| 47 | + add_action('admin_menu', array(__CLASS__, 'add_menu_items')); |
|
| 48 | 48 | |
| 49 | - self::$plugin = plugin_basename( SIMPLE_CALENDAR_MAIN_FILE ); |
|
| 49 | + self::$plugin = plugin_basename(SIMPLE_CALENDAR_MAIN_FILE); |
|
| 50 | 50 | |
| 51 | 51 | new Welcome(); |
| 52 | 52 | |
| 53 | 53 | // Links and meta content in plugins page. |
| 54 | - add_filter( 'plugin_action_links_' . self::$plugin, array( __CLASS__, 'plugin_action_links' ), 10, 5 ); |
|
| 55 | - add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 ); |
|
| 54 | + add_filter('plugin_action_links_'.self::$plugin, array(__CLASS__, 'plugin_action_links'), 10, 5); |
|
| 55 | + add_filter('plugin_row_meta', array(__CLASS__, 'plugin_row_meta'), 10, 2); |
|
| 56 | 56 | // Custom text in admin footer. |
| 57 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 ); |
|
| 57 | + add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -66,41 +66,41 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | add_submenu_page( |
| 68 | 68 | self::$main_menu, |
| 69 | - __( 'Settings', 'google-calendar-events' ), |
|
| 70 | - __( 'Settings', 'google-calendar-events' ), |
|
| 69 | + __('Settings', 'google-calendar-events'), |
|
| 70 | + __('Settings', 'google-calendar-events'), |
|
| 71 | 71 | 'manage_options', |
| 72 | 72 | 'simple-calendar_settings', |
| 73 | - function () { |
|
| 74 | - $page = new Pages( 'settings' ); |
|
| 73 | + function() { |
|
| 74 | + $page = new Pages('settings'); |
|
| 75 | 75 | $page->html(); |
| 76 | 76 | } |
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | 79 | add_submenu_page( |
| 80 | 80 | self::$main_menu, |
| 81 | - __( 'Add-ons', 'google-calendar-events' ), |
|
| 82 | - __( 'Add-ons', 'google-calendar-events' ), |
|
| 81 | + __('Add-ons', 'google-calendar-events'), |
|
| 82 | + __('Add-ons', 'google-calendar-events'), |
|
| 83 | 83 | 'manage_options', |
| 84 | 84 | 'simple-calendar_add_ons', |
| 85 | 85 | function() { |
| 86 | - $page = new Pages( 'add-ons' ); |
|
| 86 | + $page = new Pages('add-ons'); |
|
| 87 | 87 | $page->html(); |
| 88 | 88 | } |
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | 91 | add_submenu_page( |
| 92 | 92 | self::$main_menu, |
| 93 | - __( 'Tools', 'google-calendar-events' ), |
|
| 94 | - __( 'Tools', 'google-calendar-events' ), |
|
| 93 | + __('Tools', 'google-calendar-events'), |
|
| 94 | + __('Tools', 'google-calendar-events'), |
|
| 95 | 95 | 'manage_options', |
| 96 | 96 | 'simple-calendar_tools', |
| 97 | - function () { |
|
| 98 | - $page = new Pages( 'tools' ); |
|
| 97 | + function() { |
|
| 98 | + $page = new Pages('tools'); |
|
| 99 | 99 | $page->html(); |
| 100 | 100 | } |
| 101 | 101 | ); |
| 102 | 102 | |
| 103 | - do_action( 'simcal_admin_add_menu_items' ); |
|
| 103 | + do_action('simcal_admin_add_menu_items'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return array |
| 115 | 115 | */ |
| 116 | - public static function plugin_action_links( $action_links, $file ) { |
|
| 116 | + public static function plugin_action_links($action_links, $file) { |
|
| 117 | 117 | |
| 118 | - if ( self::$plugin == $file ) { |
|
| 118 | + if (self::$plugin == $file) { |
|
| 119 | 119 | |
| 120 | 120 | $links = array(); |
| 121 | - $links['settings'] = '<a href="' . admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings' ) . '">' . __( 'Settings', 'google-calendar-events' ) . '</a>'; |
|
| 122 | - $links['feeds'] = '<a href="' . admin_url( 'edit.php?post_type=calendar' ) . '">' . __( 'Calendars', 'google-calendar-events' ) . '</a>'; |
|
| 121 | + $links['settings'] = '<a href="'.admin_url('edit.php?post_type=calendar&page=simple-calendar_settings').'">'.__('Settings', 'google-calendar-events').'</a>'; |
|
| 122 | + $links['feeds'] = '<a href="'.admin_url('edit.php?post_type=calendar').'">'.__('Calendars', 'google-calendar-events').'</a>'; |
|
| 123 | 123 | |
| 124 | - return apply_filters( 'simcal_plugin_action_links', array_merge( $links, $action_links ) ); |
|
| 124 | + return apply_filters('simcal_plugin_action_links', array_merge($links, $action_links)); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | return $action_links; |
@@ -137,15 +137,15 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | * @return array |
| 139 | 139 | */ |
| 140 | - public static function plugin_row_meta( $meta_links, $file ) { |
|
| 140 | + public static function plugin_row_meta($meta_links, $file) { |
|
| 141 | 141 | |
| 142 | - if ( self::$plugin == $file ) { |
|
| 142 | + if (self::$plugin == $file) { |
|
| 143 | 143 | |
| 144 | 144 | $links = array(); |
| 145 | - $links['add-ons'] = '<a href="' . simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'plugin-listing' ) . '" target="_blank" >' . |
|
| 146 | - __( 'Add-ons', 'google-calendar-events' ) . '</a>'; |
|
| 145 | + $links['add-ons'] = '<a href="'.simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'plugin-listing').'" target="_blank" >'. |
|
| 146 | + __('Add-ons', 'google-calendar-events').'</a>'; |
|
| 147 | 147 | |
| 148 | - return apply_filters( 'simcal_plugin_action_links', array_merge( $meta_links, $links ) ); |
|
| 148 | + return apply_filters('simcal_plugin_action_links', array_merge($meta_links, $links)); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | return $meta_links; |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @return string|void |
| 164 | 164 | */ |
| 165 | - public function admin_footer_text( $footer_text ) { |
|
| 165 | + public function admin_footer_text($footer_text) { |
|
| 166 | 166 | |
| 167 | 167 | // Check to make sure we're on a SimpleCal admin page |
| 168 | 168 | $screen = simcal_is_admin_screen(); |
| 169 | - if ( $screen !== false ) { |
|
| 169 | + if ($screen !== false) { |
|
| 170 | 170 | |
| 171 | - if ( 'calendar' == $screen ) { |
|
| 171 | + if ('calendar' == $screen) { |
|
| 172 | 172 | |
| 173 | 173 | // Add Drip promo signup form (@see Newsletter meta box). |
| 174 | 174 | |
@@ -196,23 +196,23 @@ discard block |
||
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // Change the footer text |
| 199 | - if ( ! get_option( 'simple-calendar_admin_footer_text_rated' ) ) { |
|
| 199 | + if ( ! get_option('simple-calendar_admin_footer_text_rated')) { |
|
| 200 | 200 | |
| 201 | 201 | $footer_text = sprintf( |
| 202 | - __( 'If you like <strong>Simple Calendar</strong> please leave us a %s★★★★★ rating on WordPress.org%s. A huge thank you in advance!', 'google-calendar-events' ), |
|
| 203 | - '<a href="https://wordpress.org/support/view/plugin-reviews/google-calendar-events?filter=5#postform" target="_blank" class="simcal-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'google-calendar-events' ) . '">', '</a>' |
|
| 202 | + __('If you like <strong>Simple Calendar</strong> please leave us a %s★★★★★ rating on WordPress.org%s. A huge thank you in advance!', 'google-calendar-events'), |
|
| 203 | + '<a href="https://wordpress.org/support/view/plugin-reviews/google-calendar-events?filter=5#postform" target="_blank" class="simcal-rating-link" data-rated="'.esc_attr__('Thanks :)', 'google-calendar-events').'">', '</a>' |
|
| 204 | 204 | ); |
| 205 | 205 | |
| 206 | 206 | $footer_text .= '<script type="text/javascript">'; |
| 207 | 207 | $footer_text .= "jQuery( 'a.simcal-rating-link' ).click( function() { |
| 208 | - jQuery.post( '" . \SimpleCalendar\plugin()->ajax_url() . "', { action: 'simcal_rated' } ); |
|
| 208 | + jQuery.post( '" . \SimpleCalendar\plugin()->ajax_url()."', { action: 'simcal_rated' } ); |
|
| 209 | 209 | jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) ); |
| 210 | 210 | });"; |
| 211 | 211 | $footer_text .= '</script>'; |
| 212 | 212 | |
| 213 | 213 | } else { |
| 214 | 214 | |
| 215 | - $footer_text = __( 'Thanks for using Simple Calendar!', 'google-calendar-events' ); |
|
| 215 | + $footer_text = __('Thanks for using Simple Calendar!', 'google-calendar-events'); |
|
| 216 | 216 | |
| 217 | 217 | } |
| 218 | 218 | |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | */ |
| 7 | 7 | namespace SimpleCalendar\Admin; |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if ( ! defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -25,19 +25,19 @@ discard block |
||
| 25 | 25 | public function __construct() { |
| 26 | 26 | |
| 27 | 27 | // Set an option if the user rated the plugin. |
| 28 | - add_action( 'wp_ajax_simcal_rated', array( $this, 'rate_plugin' ) ); |
|
| 28 | + add_action('wp_ajax_simcal_rated', array($this, 'rate_plugin')); |
|
| 29 | 29 | |
| 30 | 30 | // Set an option if the user rated the plugin. |
| 31 | - add_action( 'wp_ajax_simcal_clear_cache', array( $this, 'clear_cache' ) ); |
|
| 31 | + add_action('wp_ajax_simcal_clear_cache', array($this, 'clear_cache')); |
|
| 32 | 32 | |
| 33 | 33 | // Convert a datetime format. |
| 34 | - add_action( 'wp_ajax_simcal_date_i18n_input_preview', array( $this, 'date_i18n' ) ); |
|
| 34 | + add_action('wp_ajax_simcal_date_i18n_input_preview', array($this, 'date_i18n')); |
|
| 35 | 35 | |
| 36 | 36 | // Manage an add-on license activation or deactivation. |
| 37 | - add_action( 'wp_ajax_simcal_manage_add_on_license', array( $this, 'manage_add_on_license' ) ); |
|
| 37 | + add_action('wp_ajax_simcal_manage_add_on_license', array($this, 'manage_add_on_license')); |
|
| 38 | 38 | |
| 39 | 39 | // Reset add-ons licenses. |
| 40 | - add_action( 'wp_ajax_simcal_reset_add_ons_licenses', array( $this, 'reset_licenses' ) ); |
|
| 40 | + add_action('wp_ajax_simcal_reset_add_ons_licenses', array($this, 'reset_licenses')); |
|
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function clear_cache() { |
| 50 | 50 | |
| 51 | - $id = isset( $_POST['id'] ) ? ( is_array( $_POST['id'] ) ? array_map( 'intval', $_POST['id'] ) : intval( $_POST['id'] ) ) : ''; |
|
| 51 | + $id = isset($_POST['id']) ? (is_array($_POST['id']) ? array_map('intval', $_POST['id']) : intval($_POST['id'])) : ''; |
|
| 52 | 52 | |
| 53 | - if ( ! empty( $id ) ) { |
|
| 54 | - simcal_delete_feed_transients( $id ); |
|
| 53 | + if ( ! empty($id)) { |
|
| 54 | + simcal_delete_feed_transients($id); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @since 3.0.0 |
| 62 | 62 | */ |
| 63 | 63 | public function rate_plugin() { |
| 64 | - update_option( 'simple-calendar_admin_footer_text_rated', date( 'Y-m-d', time() ) ); |
|
| 64 | + update_option('simple-calendar_admin_footer_text_rated', date('Y-m-d', time())); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function date_i18n() { |
| 73 | 73 | |
| 74 | - $value = isset( $_POST['value'] ) ? esc_attr( $_POST['value'] ) : ' '; |
|
| 75 | - $timestamp = isset( $_POST['timestamp'] ) ? absint( $_POST['timestamp'] ) : time(); |
|
| 74 | + $value = isset($_POST['value']) ? esc_attr($_POST['value']) : ' '; |
|
| 75 | + $timestamp = isset($_POST['timestamp']) ? absint($_POST['timestamp']) : time(); |
|
| 76 | 76 | |
| 77 | - wp_send_json_success( date_i18n( $value, $timestamp ) ); |
|
| 77 | + wp_send_json_success(date_i18n($value, $timestamp)); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -86,35 +86,35 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function manage_add_on_license() { |
| 88 | 88 | |
| 89 | - $addon = isset( $_POST['add_on'] ) ? sanitize_key( $_POST['add_on'] ) : false; |
|
| 90 | - $action = isset( $_POST['license_action'] ) ? esc_attr( $_POST['license_action'] ) : false; |
|
| 91 | - $key = isset( $_POST['license_key'] ) ? esc_attr( $_POST['license_key'] ) : ''; |
|
| 92 | - $nonce = isset( $_POST['nonce'] ) ? esc_attr( $_POST['nonce'] ) : ''; |
|
| 89 | + $addon = isset($_POST['add_on']) ? sanitize_key($_POST['add_on']) : false; |
|
| 90 | + $action = isset($_POST['license_action']) ? esc_attr($_POST['license_action']) : false; |
|
| 91 | + $key = isset($_POST['license_key']) ? esc_attr($_POST['license_key']) : ''; |
|
| 92 | + $nonce = isset($_POST['nonce']) ? esc_attr($_POST['nonce']) : ''; |
|
| 93 | 93 | |
| 94 | 94 | // Verify that there are valid variables to process. |
| 95 | - if ( false === $addon || ! in_array( $action, array( 'activate_license', 'deactivate_license' ) ) ) { |
|
| 96 | - wp_send_json_error( __( 'Add-on unspecified or invalid action.', 'google-calendar-events' ) ); |
|
| 95 | + if (false === $addon || ! in_array($action, array('activate_license', 'deactivate_license'))) { |
|
| 96 | + wp_send_json_error(__('Add-on unspecified or invalid action.', 'google-calendar-events')); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Verify this request comes from the add-ons licenses activation settings page. |
| 100 | - if ( ! wp_verify_nonce( $nonce, 'simcal_license_manager' ) ) { |
|
| 101 | - wp_send_json_error( sprintf( __( 'An error occurred: %s', 'google-calendar-events' ), 'Nonce verification failed.' ) ); |
|
| 100 | + if ( ! wp_verify_nonce($nonce, 'simcal_license_manager')) { |
|
| 101 | + wp_send_json_error(sprintf(__('An error occurred: %s', 'google-calendar-events'), 'Nonce verification failed.')); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | // Removes the prefix and converts simcal_{id_no} to {id_no}. |
| 105 | - $id = intval( substr( $addon, 7 ) ); |
|
| 105 | + $id = intval(substr($addon, 7)); |
|
| 106 | 106 | |
| 107 | 107 | // Data to send in API request. |
| 108 | 108 | $api_request = array( |
| 109 | 109 | 'edd_action' => $action, |
| 110 | 110 | 'license' => $key, |
| 111 | - 'item_id' => urlencode( $id ), |
|
| 111 | + 'item_id' => urlencode($id), |
|
| 112 | 112 | 'url' => home_url() |
| 113 | 113 | ); |
| 114 | 114 | |
| 115 | 115 | // Call the custom API. |
| 116 | 116 | $response = wp_remote_post( |
| 117 | - defined( 'SIMPLE_CALENDAR_STORE_URL' ) ? SIMPLE_CALENDAR_STORE_URL : simcal_get_url( 'home' ), |
|
| 117 | + defined('SIMPLE_CALENDAR_STORE_URL') ? SIMPLE_CALENDAR_STORE_URL : simcal_get_url('home'), |
|
| 118 | 118 | array( |
| 119 | 119 | 'timeout' => 15, |
| 120 | 120 | 'sslverify' => false, |
@@ -123,20 +123,20 @@ discard block |
||
| 123 | 123 | ); |
| 124 | 124 | |
| 125 | 125 | // Update license in db. |
| 126 | - $keys = get_option( 'simple-calendar_settings_licenses', array() ); |
|
| 127 | - $keys['keys'][ $addon ] = $key; |
|
| 128 | - update_option( 'simple-calendar_settings_licenses', $keys ); |
|
| 126 | + $keys = get_option('simple-calendar_settings_licenses', array()); |
|
| 127 | + $keys['keys'][$addon] = $key; |
|
| 128 | + update_option('simple-calendar_settings_licenses', $keys); |
|
| 129 | 129 | |
| 130 | 130 | // Make sure there is a response. |
| 131 | - if ( is_wp_error( $response ) ) { |
|
| 132 | - wp_send_json_error( sprintf( __( 'There was an error processing your request: %s', 'google-calendar-events' ), $response->get_error_message() ) ); |
|
| 131 | + if (is_wp_error($response)) { |
|
| 132 | + wp_send_json_error(sprintf(__('There was an error processing your request: %s', 'google-calendar-events'), $response->get_error_message())); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // Decode the license data and save. |
| 136 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 136 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 137 | 137 | $status = simcal_get_license_status(); |
| 138 | 138 | |
| 139 | - if ( ! empty( $license_data ) ) { |
|
| 139 | + if ( ! empty($license_data)) { |
|
| 140 | 140 | if ('deactivated' == $license_data->license) { |
| 141 | 141 | unset($status[$addon]); |
| 142 | 142 | update_option('simple-calendar_licenses_status', $status); |
@@ -147,10 +147,10 @@ discard block |
||
| 147 | 147 | $message = 'valid' == $license_data->license ? 'valid' : __('License key is invalid.', 'google-calendar-events'); |
| 148 | 148 | wp_send_json_success($message); |
| 149 | 149 | } else { |
| 150 | - wp_send_json_error( '' ); |
|
| 150 | + wp_send_json_error(''); |
|
| 151 | 151 | } |
| 152 | 152 | } else { |
| 153 | - wp_send_json_error( __( 'An error has occurred, please try again.', 'google-calendar-events' ) ); |
|
| 153 | + wp_send_json_error(__('An error has occurred, please try again.', 'google-calendar-events')); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
@@ -161,17 +161,17 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function reset_licenses() { |
| 163 | 163 | |
| 164 | - $nonce = isset( $_POST['nonce'] ) ? esc_attr( $_POST['nonce'] ) : ''; |
|
| 164 | + $nonce = isset($_POST['nonce']) ? esc_attr($_POST['nonce']) : ''; |
|
| 165 | 165 | |
| 166 | 166 | // Verify this request comes from the add-ons licenses activation settings page. |
| 167 | - if ( empty ( $nonce ) || ! wp_verify_nonce( $nonce, 'simcal_license_manager' ) ) { |
|
| 168 | - wp_send_json_error( sprintf( __( 'An error occurred: %s', 'google-calendar-events' ), 'Nonce verification failed.' ) ); |
|
| 167 | + if (empty ($nonce) || ! wp_verify_nonce($nonce, 'simcal_license_manager')) { |
|
| 168 | + wp_send_json_error(sprintf(__('An error occurred: %s', 'google-calendar-events'), 'Nonce verification failed.')); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - delete_option( 'simple-calendar_settings_licenses' ); |
|
| 172 | - delete_option( 'simple-calendar_licenses_status' ); |
|
| 171 | + delete_option('simple-calendar_settings_licenses'); |
|
| 172 | + delete_option('simple-calendar_licenses_status'); |
|
| 173 | 173 | |
| 174 | - wp_send_json_success( 'success' ); |
|
| 174 | + wp_send_json_success('success'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Abstracts\Admin_Page; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function __construct() { |
| 30 | 30 | $this->id = 'advanced'; |
| 31 | 31 | $this->option_group = 'settings'; |
| 32 | - $this->label = __( 'Advanced', 'google-calendar-events' ); |
|
| 32 | + $this->label = __('Advanced', 'google-calendar-events'); |
|
| 33 | 33 | //$this->description = __( 'Advanced settings.', 'google-calendar-events' ); |
| 34 | 34 | $this->sections = $this->add_sections(); |
| 35 | 35 | $this->fields = $this->add_fields(); |
@@ -43,16 +43,16 @@ discard block |
||
| 43 | 43 | * @return array |
| 44 | 44 | */ |
| 45 | 45 | public function add_sections() { |
| 46 | - return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id .'_sections', array( |
|
| 46 | + return apply_filters('simcal_add_'.$this->option_group.'_'.$this->id.'_sections', array( |
|
| 47 | 47 | 'assets' => array( |
| 48 | - 'title' => __( 'Styles', 'google-calendar-events' ), |
|
| 49 | - 'description' => __( 'Manage front end assets that handle the calendars appearance.', 'google-calendar-events' ) |
|
| 48 | + 'title' => __('Styles', 'google-calendar-events'), |
|
| 49 | + 'description' => __('Manage front end assets that handle the calendars appearance.', 'google-calendar-events') |
|
| 50 | 50 | ), |
| 51 | 51 | 'installation' => array( |
| 52 | - 'title' => __( 'Installation', 'google-calendar-events' ), |
|
| 53 | - 'description' => __( 'Manage your data (plugin settings and saved calendars).', 'google-calendar-events' ) |
|
| 52 | + 'title' => __('Installation', 'google-calendar-events'), |
|
| 53 | + 'description' => __('Manage your data (plugin settings and saved calendars).', 'google-calendar-events') |
|
| 54 | 54 | ) |
| 55 | - ) ); |
|
| 55 | + )); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -65,41 +65,41 @@ discard block |
||
| 65 | 65 | public function add_fields() { |
| 66 | 66 | |
| 67 | 67 | $fields = array(); |
| 68 | - $this->values = get_option( 'simple-calendar_' . $this->option_group . '_' . $this->id ); |
|
| 68 | + $this->values = get_option('simple-calendar_'.$this->option_group.'_'.$this->id); |
|
| 69 | 69 | |
| 70 | - foreach ( $this->sections as $section => $a ) : |
|
| 70 | + foreach ($this->sections as $section => $a) : |
|
| 71 | 71 | |
| 72 | - if ( 'assets' == $section ) { |
|
| 72 | + if ('assets' == $section) { |
|
| 73 | 73 | |
| 74 | - $fields[ $section ] = array( |
|
| 74 | + $fields[$section] = array( |
|
| 75 | 75 | 'disable_css' => array( |
| 76 | - 'title' => __( 'Disable CSS', 'google-calendar-events' ), |
|
| 77 | - 'tooltip' => __( 'If ticked, this option will prevent all front end stylesheets to load. This also includes all add-on stylesheets.', 'google-calendar-events' ), |
|
| 76 | + 'title' => __('Disable CSS', 'google-calendar-events'), |
|
| 77 | + 'tooltip' => __('If ticked, this option will prevent all front end stylesheets to load. This also includes all add-on stylesheets.', 'google-calendar-events'), |
|
| 78 | 78 | 'type' => 'checkbox', |
| 79 | - 'name' => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][disable_css]', |
|
| 80 | - 'id' => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $section . '-disable-css', |
|
| 81 | - 'value' => $this->get_option_value( $section, 'disable_css' ) |
|
| 79 | + 'name' => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][disable_css]', |
|
| 80 | + 'id' => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-'.$section.'-disable-css', |
|
| 81 | + 'value' => $this->get_option_value($section, 'disable_css') |
|
| 82 | 82 | ), |
| 83 | 83 | ); |
| 84 | 84 | |
| 85 | - } elseif ( 'installation' == $section ) { |
|
| 85 | + } elseif ('installation' == $section) { |
|
| 86 | 86 | |
| 87 | - $fields[ $section ] = array( |
|
| 87 | + $fields[$section] = array( |
|
| 88 | 88 | 'delete_settings' => array( |
| 89 | - 'title' => __( 'Delete settings', 'google-calendar-events' ), |
|
| 90 | - 'tooltip' => __( 'Tick this option if you want to wipe this plugin settings from database when uninstalling.', 'google-calendar-events' ), |
|
| 89 | + 'title' => __('Delete settings', 'google-calendar-events'), |
|
| 90 | + 'tooltip' => __('Tick this option if you want to wipe this plugin settings from database when uninstalling.', 'google-calendar-events'), |
|
| 91 | 91 | 'type' => 'checkbox', |
| 92 | - 'name' => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][delete_settings]', |
|
| 93 | - 'id' => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $section . '-delete-settings', |
|
| 94 | - 'value' => $this->get_option_value( $section, 'delete_settings' ), |
|
| 92 | + 'name' => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][delete_settings]', |
|
| 93 | + 'id' => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-'.$section.'-delete-settings', |
|
| 94 | + 'value' => $this->get_option_value($section, 'delete_settings'), |
|
| 95 | 95 | ), |
| 96 | 96 | 'erase_data' => array( |
| 97 | - 'title' => __( 'Erase calendar data', 'google-calendar-events' ), |
|
| 98 | - 'tooltip' => __( 'By default your data will be retained in database even after uninstall. Tick this option if you want to delete all your calendar data when uninstalling.', 'google-calendar-events' ), |
|
| 97 | + 'title' => __('Erase calendar data', 'google-calendar-events'), |
|
| 98 | + 'tooltip' => __('By default your data will be retained in database even after uninstall. Tick this option if you want to delete all your calendar data when uninstalling.', 'google-calendar-events'), |
|
| 99 | 99 | 'type' => 'checkbox', |
| 100 | - 'name' => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][erase_data]', |
|
| 101 | - 'id' => 'simple-calendar_' . $this->option_group . '_' . $this->id . '-delete-data', |
|
| 102 | - 'value' => $this->get_option_value( $section, 'erase_data' ), |
|
| 100 | + 'name' => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][erase_data]', |
|
| 101 | + 'id' => 'simple-calendar_'.$this->option_group.'_'.$this->id.'-delete-data', |
|
| 102 | + 'value' => $this->get_option_value($section, 'erase_data'), |
|
| 103 | 103 | ) |
| 104 | 104 | ); |
| 105 | 105 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | endforeach; |
| 109 | 109 | |
| 110 | - return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id . '_fields', $fields ); |
|
| 110 | + return apply_filters('simcal_add_'.$this->option_group.'_'.$this->id.'_fields', $fields); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Abstracts\Admin_Page; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -28,16 +28,16 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | $this->id = $tab = 'add-ons'; |
| 30 | 30 | $this->option_group = $page = 'add-ons'; |
| 31 | - $this->label = __( 'Add-ons', 'google-calendar-events' ); |
|
| 31 | + $this->label = __('Add-ons', 'google-calendar-events'); |
|
| 32 | 32 | $this->description = ''; |
| 33 | 33 | $this->sections = $this->add_sections(); |
| 34 | 34 | $this->fields = $this->add_fields(); |
| 35 | 35 | |
| 36 | 36 | // Disable the submit button for this page. |
| 37 | - add_filter( 'simcal_admin_page_' . $page . '_' . $tab . '_submit', function() { return false; } ); |
|
| 37 | + add_filter('simcal_admin_page_'.$page.'_'.$tab.'_submit', function() { return false; } ); |
|
| 38 | 38 | |
| 39 | 39 | // Add html. |
| 40 | - add_action( 'simcal_admin_page_' . $page . '_' . $tab . '_end', array( $this, 'html' ) ); |
|
| 40 | + add_action('simcal_admin_page_'.$page.'_'.$tab.'_end', array($this, 'html')); |
|
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | // @todo pull data from simplecalendar.io to showcase add-ons |
| 52 | 52 | $js_redirect = '<script type="text/javascript">'; |
| 53 | - $js_redirect .= 'window.location = "' . simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'plugin-submenu-link', true ) . '"'; |
|
| 53 | + $js_redirect .= 'window.location = "'.simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'plugin-submenu-link', true).'"'; |
|
| 54 | 54 | $js_redirect .= '</script>'; |
| 55 | 55 | |
| 56 | 56 | echo $js_redirect; |
@@ -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 | |
@@ -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 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | use SimpleCalendar\Abstracts\Calendar; |
| 10 | 10 | use SimpleCalendar\Abstracts\Admin_Page; |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -39,20 +39,20 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $this->id = 'calendars'; |
| 41 | 41 | $this->option_group = 'settings'; |
| 42 | - $this->label = __( 'Calendars', 'google-calendar-events' ); |
|
| 42 | + $this->label = __('Calendars', 'google-calendar-events'); |
|
| 43 | 43 | //$this->description = __( 'Manage calendar preferences and calendar types settings and options.', 'google-calendar-events' ); |
| 44 | 44 | |
| 45 | 45 | $calendars = simcal_get_calendar_types(); |
| 46 | 46 | $calendar_settings = array(); |
| 47 | - if ( ! empty( $calendars ) && is_array( $calendars ) ) { |
|
| 48 | - foreach ( $calendars as $calendar => $views ) { |
|
| 47 | + if ( ! empty($calendars) && is_array($calendars)) { |
|
| 48 | + foreach ($calendars as $calendar => $views) { |
|
| 49 | 49 | |
| 50 | - $calendar_type = simcal_get_calendar( $calendar ); |
|
| 50 | + $calendar_type = simcal_get_calendar($calendar); |
|
| 51 | 51 | |
| 52 | - if ( $calendar_type instanceof Calendar ) { |
|
| 52 | + if ($calendar_type instanceof Calendar) { |
|
| 53 | 53 | $settings = $calendar_type->settings_fields(); |
| 54 | - if ( ! empty( $settings ) ) { |
|
| 55 | - $calendar_settings[ $calendar ] = $settings; |
|
| 54 | + if ( ! empty($settings)) { |
|
| 55 | + $calendar_settings[$calendar] = $settings; |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -74,17 +74,17 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | $sections = array( |
| 76 | 76 | 'general' => array( |
| 77 | - 'title' => __( 'General', 'google-calendar-events' ), |
|
| 77 | + 'title' => __('General', 'google-calendar-events'), |
|
| 78 | 78 | 'description' => '', |
| 79 | 79 | ), |
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | 82 | $calendar_types = $this->calendar_types; |
| 83 | 83 | |
| 84 | - if ( ! empty( $calendar_types ) && is_array( $calendar_types ) ) { |
|
| 85 | - foreach ( $calendar_types as $calendar_type => $type ) { |
|
| 84 | + if ( ! empty($calendar_types) && is_array($calendar_types)) { |
|
| 85 | + foreach ($calendar_types as $calendar_type => $type) { |
|
| 86 | 86 | |
| 87 | - $sections[ $calendar_type ] = array( |
|
| 87 | + $sections[$calendar_type] = array( |
|
| 88 | 88 | 'title' => $type['name'], |
| 89 | 89 | 'description' => $type['description'], |
| 90 | 90 | ); |
@@ -92,9 +92,9 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - arsort( $calendar_types ); |
|
| 95 | + arsort($calendar_types); |
|
| 96 | 96 | |
| 97 | - return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id .'_sections', $sections ); |
|
| 97 | + return apply_filters('simcal_add_'.$this->option_group.'_'.$this->id.'_sections', $sections); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $fields = array(); |
| 110 | 110 | $feed_types = $this->calendar_types; |
| 111 | - $this->values = get_option( 'simple-calendar_' . $this->option_group . '_' . $this->id ); |
|
| 111 | + $this->values = get_option('simple-calendar_'.$this->option_group.'_'.$this->id); |
|
| 112 | 112 | |
| 113 | - foreach ( $this->sections as $section => $contents ) : |
|
| 113 | + foreach ($this->sections as $section => $contents) : |
|
| 114 | 114 | |
| 115 | - if ( 'general' == $section ) { |
|
| 115 | + if ('general' == $section) { |
|
| 116 | 116 | |
| 117 | 117 | $options = array(); |
| 118 | 118 | $post_types = get_post_types( |
@@ -124,36 +124,36 @@ discard block |
||
| 124 | 124 | 'objects', |
| 125 | 125 | 'not' |
| 126 | 126 | ); |
| 127 | - unset( $post_types['attachment'] ); |
|
| 128 | - unset( $post_types['calendar'] ); |
|
| 129 | - unset( $post_types['gce_feed'] ); |
|
| 130 | - foreach ( $post_types as $slug => $post_type ) { |
|
| 131 | - $options[ $slug ] = $post_type->label; |
|
| 127 | + unset($post_types['attachment']); |
|
| 128 | + unset($post_types['calendar']); |
|
| 129 | + unset($post_types['gce_feed']); |
|
| 130 | + foreach ($post_types as $slug => $post_type) { |
|
| 131 | + $options[$slug] = $post_type->label; |
|
| 132 | 132 | } |
| 133 | - asort( $options ); |
|
| 133 | + asort($options); |
|
| 134 | 134 | |
| 135 | - $fields[ $section ][] = array( |
|
| 135 | + $fields[$section][] = array( |
|
| 136 | 136 | 'type' => 'select', |
| 137 | 137 | 'multiselect' => 'multiselect', |
| 138 | 138 | 'enhanced' => 'enhanced', |
| 139 | - 'title' => __( 'Attach Calendars', 'google-calendar-events' ), |
|
| 140 | - 'tooltip' => __( 'You can choose on which content types to add the ability to attach calendars.', 'google-calendar-events' ), |
|
| 141 | - 'name' => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][attach_calendars_posts]', |
|
| 142 | - 'id' => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-attach-calendars-posts', |
|
| 143 | - 'value' => $this->get_option_value( $section, 'attach_calendars_posts' ), |
|
| 139 | + 'title' => __('Attach Calendars', 'google-calendar-events'), |
|
| 140 | + 'tooltip' => __('You can choose on which content types to add the ability to attach calendars.', 'google-calendar-events'), |
|
| 141 | + 'name' => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][attach_calendars_posts]', |
|
| 142 | + 'id' => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-attach-calendars-posts', |
|
| 143 | + 'value' => $this->get_option_value($section, 'attach_calendars_posts'), |
|
| 144 | 144 | 'default' => 'post,page', |
| 145 | 145 | 'options' => $options, |
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | - } elseif ( isset( $feed_types[ $section ]['fields'] ) ) { |
|
| 148 | + } elseif (isset($feed_types[$section]['fields'])) { |
|
| 149 | 149 | |
| 150 | - foreach ( $feed_types[ $section ]['fields'] as $key => $args ) { |
|
| 150 | + foreach ($feed_types[$section]['fields'] as $key => $args) { |
|
| 151 | 151 | |
| 152 | - $fields[ $section ][] = array_merge( $args, array( |
|
| 153 | - 'name' => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][' . $key . ']', |
|
| 154 | - 'id' => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $key, |
|
| 155 | - 'value' => $this->get_option_value( $section, $key ) |
|
| 156 | - ) ); |
|
| 152 | + $fields[$section][] = array_merge($args, array( |
|
| 153 | + 'name' => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.']['.$key.']', |
|
| 154 | + 'id' => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-'.$key, |
|
| 155 | + 'value' => $this->get_option_value($section, $key) |
|
| 156 | + )); |
|
| 157 | 157 | |
| 158 | 158 | } |
| 159 | 159 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | endforeach; |
| 163 | 163 | |
| 164 | - return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id . '_fields', $fields ); |
|
| 164 | + return apply_filters('simcal_add_'.$this->option_group.'_'.$this->id.'_fields', $fields); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | } |