@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | // Exit if accessed directly |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | function gmb_upgrades_screen() { |
| 23 | 23 | |
| 24 | - $action = isset( $_GET['gmb-upgrade'] ) ? sanitize_text_field( $_GET['gmb-upgrade'] ) : ''; |
|
| 25 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
| 26 | - $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; |
|
| 27 | - $custom = isset( $_GET['custom'] ) ? absint( $_GET['custom'] ) : 0; |
|
| 28 | - $number = isset( $_GET['number'] ) ? absint( $_GET['number'] ) : 100; |
|
| 29 | - $steps = round( ( $total / $number ), 0 ); |
|
| 24 | + $action = isset($_GET['gmb-upgrade']) ? sanitize_text_field($_GET['gmb-upgrade']) : ''; |
|
| 25 | + $step = isset($_GET['step']) ? absint($_GET['step']) : 1; |
|
| 26 | + $total = isset($_GET['total']) ? absint($_GET['total']) : false; |
|
| 27 | + $custom = isset($_GET['custom']) ? absint($_GET['custom']) : 0; |
|
| 28 | + $number = isset($_GET['number']) ? absint($_GET['number']) : 100; |
|
| 29 | + $steps = round(($total / $number), 0); |
|
| 30 | 30 | |
| 31 | 31 | $doing_upgrade_args = array( |
| 32 | 32 | 'page' => 'gmb-upgrades', |
@@ -36,23 +36,23 @@ discard block |
||
| 36 | 36 | 'custom' => $custom, |
| 37 | 37 | 'steps' => $steps |
| 38 | 38 | ); |
| 39 | - update_option( 'gmb_doing_upgrade', $doing_upgrade_args ); |
|
| 40 | - if ( $step > $steps ) { |
|
| 39 | + update_option('gmb_doing_upgrade', $doing_upgrade_args); |
|
| 40 | + if ($step > $steps) { |
|
| 41 | 41 | // Prevent a weird case where the estimate was off. Usually only a couple. |
| 42 | 42 | $steps = $step; |
| 43 | 43 | } |
| 44 | 44 | ?> |
| 45 | 45 | <div class="wrap"> |
| 46 | - <h2><?php _e( 'Maps Builder - Upgrade', 'gmb' ); ?></h2> |
|
| 46 | + <h2><?php _e('Maps Builder - Upgrade', 'gmb'); ?></h2> |
|
| 47 | 47 | |
| 48 | - <?php if ( ! empty( $action ) ) : ?> |
|
| 48 | + <?php if ( ! empty($action)) : ?> |
|
| 49 | 49 | |
| 50 | 50 | <div id="gmb-upgrade-status"> |
| 51 | - <p><?php _e( 'The upgrade process has started, please be patient. This could take several minutes. You will be automatically redirected when the upgrade is finished.', 'gmb' ); ?></p> |
|
| 51 | + <p><?php _e('The upgrade process has started, please be patient. This could take several minutes. You will be automatically redirected when the upgrade is finished.', 'gmb'); ?></p> |
|
| 52 | 52 | |
| 53 | - <?php if ( ! empty( $total ) ) : ?> |
|
| 53 | + <?php if ( ! empty($total)) : ?> |
|
| 54 | 54 | <p> |
| 55 | - <strong><?php printf( __( 'Step %d of approximately %d running', 'gmb' ), $step, $steps ); ?></strong> |
|
| 55 | + <strong><?php printf(__('Step %d of approximately %d running', 'gmb'), $step, $steps); ?></strong> |
|
| 56 | 56 | </p> |
| 57 | 57 | <?php endif; ?> |
| 58 | 58 | </div> |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | <div id="gmb-upgrade-status" class="updated" style="margin-top:15px;"> |
| 68 | 68 | <p style="margin-bottom:8px;"> |
| 69 | - <?php _e( 'The upgrade process has started, please do not close your browser or refresh. This could take several minutes. You will be automatically redirected when the upgrade has finished.', 'gmb' ); ?> |
|
| 70 | - <img src="<?php echo GMB_PLUGIN_URL . '/assets/img/loading.gif'; ?>" id="gmb-upgrade-loader" style="position:relative; top:3px;" /> |
|
| 69 | + <?php _e('The upgrade process has started, please do not close your browser or refresh. This could take several minutes. You will be automatically redirected when the upgrade has finished.', 'gmb'); ?> |
|
| 70 | + <img src="<?php echo GMB_PLUGIN_URL.'/assets/img/loading.gif'; ?>" id="gmb-upgrade-loader" style="position:relative; top:3px;" /> |
|
| 71 | 71 | </p> |
| 72 | 72 | </div> |
| 73 | 73 | <script type="text/javascript"> |
@@ -62,11 +62,14 @@ |
||
| 62 | 62 | }, 250 ); |
| 63 | 63 | </script> |
| 64 | 64 | |
| 65 | - <?php else : ?> |
|
| 65 | + <?php else { |
|
| 66 | + : ?> |
|
| 66 | 67 | |
| 67 | 68 | <div id="gmb-upgrade-status" class="updated" style="margin-top:15px;"> |
| 68 | 69 | <p style="margin-bottom:8px;"> |
| 69 | - <?php _e( 'The upgrade process has started, please do not close your browser or refresh. This could take several minutes. You will be automatically redirected when the upgrade has finished.', 'gmb' ); ?> |
|
| 70 | + <?php _e( 'The upgrade process has started, please do not close your browser or refresh. This could take several minutes. You will be automatically redirected when the upgrade has finished.', 'gmb' ); |
|
| 71 | +} |
|
| 72 | +?> |
|
| 70 | 73 | <img src="<?php echo GMB_PLUGIN_URL . '/assets/img/loading.gif'; ?>" id="gmb-upgrade-loader" style="position:relative; top:3px;" /> |
| 71 | 74 | </p> |
| 72 | 75 | </div> |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | 23 | function init_gmb_forms_widget() { |
| 24 | - register_widget( 'Google_Maps_Builder_Widget' ); |
|
| 24 | + register_widget('Google_Maps_Builder_Widget'); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | -add_action( 'widgets_init', 'init_gmb_forms_widget' ); |
|
| 27 | +add_action('widgets_init', 'init_gmb_forms_widget'); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Google Places Reviews |
@@ -56,36 +56,36 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | parent::__construct( |
| 58 | 58 | 'gmb_maps_widget', // Base ID |
| 59 | - __( 'Maps Builder Widget', $this->plugin_slug ), // Name |
|
| 59 | + __('Maps Builder Widget', $this->plugin_slug), // Name |
|
| 60 | 60 | array( |
| 61 | 61 | 'classname' => 'gmb-maps-widget', |
| 62 | - 'description' => __( 'Display a Google Map in your theme\'s widget powered sidebar.', $this->plugin_slug ) |
|
| 62 | + 'description' => __('Display a Google Map in your theme\'s widget powered sidebar.', $this->plugin_slug) |
|
| 63 | 63 | ) //Args |
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | 66 | //Actions |
| 67 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
| 67 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | //Load Widget JS Script ONLY on Widget page |
| 73 | - public function admin_widget_scripts( $hook ) { |
|
| 73 | + public function admin_widget_scripts($hook) { |
|
| 74 | 74 | |
| 75 | 75 | // Use minified libraries if SCRIPT_DEBUG is turned off |
| 76 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 76 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 77 | 77 | |
| 78 | 78 | //Widget Script |
| 79 | - if ( $hook == 'widgets.php' ) { |
|
| 79 | + if ($hook == 'widgets.php') { |
|
| 80 | 80 | |
| 81 | - wp_register_style( $this->plugin_slug . '-admin-styles', GMB_PLUGIN_URL . 'assets/css/gmb-admin' . $suffix . '.css', array(), GMB_VERSION ); |
|
| 82 | - wp_enqueue_style( $this->plugin_slug . '-admin-styles' ); |
|
| 81 | + wp_register_style($this->plugin_slug.'-admin-styles', GMB_PLUGIN_URL.'assets/css/gmb-admin'.$suffix.'.css', array(), GMB_VERSION); |
|
| 82 | + wp_enqueue_style($this->plugin_slug.'-admin-styles'); |
|
| 83 | 83 | |
| 84 | - wp_register_script( 'gmb-qtip', GMB_PLUGIN_URL . 'assets/js/plugins/jquery.qtip' . $suffix . '.js', array( 'jquery' ), GMB_VERSION ); |
|
| 85 | - wp_enqueue_script( 'gmb-qtip' ); |
|
| 84 | + wp_register_script('gmb-qtip', GMB_PLUGIN_URL.'assets/js/plugins/jquery.qtip'.$suffix.'.js', array('jquery'), GMB_VERSION); |
|
| 85 | + wp_enqueue_script('gmb-qtip'); |
|
| 86 | 86 | |
| 87 | - wp_register_script( 'gmb-admin-widgets-scripts', GMB_PLUGIN_URL . 'assets/js/admin/admin-widget' . $suffix . '.js', array( 'jquery' ), GMB_VERSION, false ); |
|
| 88 | - wp_enqueue_script( 'gmb-admin-widgets-scripts' ); |
|
| 87 | + wp_register_script('gmb-admin-widgets-scripts', GMB_PLUGIN_URL.'assets/js/admin/admin-widget'.$suffix.'.js', array('jquery'), GMB_VERSION, false); |
|
| 88 | + wp_enqueue_script('gmb-admin-widgets-scripts'); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | |
@@ -100,35 +100,35 @@ discard block |
||
| 100 | 100 | * @return null |
| 101 | 101 | * @see WP_Widget::form() |
| 102 | 102 | */ |
| 103 | - public function form( $instance ) { |
|
| 103 | + public function form($instance) { |
|
| 104 | 104 | |
| 105 | - $instance = wp_parse_args( (array) $instance, $this->widget_defaults ); ?> |
|
| 105 | + $instance = wp_parse_args((array) $instance, $this->widget_defaults); ?> |
|
| 106 | 106 | |
| 107 | 107 | <!-- Title --> |
| 108 | 108 | <p> |
| 109 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Widget Title', 'gpr' ); ?></label> |
|
| 110 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" |
|
| 111 | - name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
| 109 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title', 'gpr'); ?></label> |
|
| 110 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" |
|
| 111 | + name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
| 112 | 112 | </p> |
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | <?php |
| 116 | 116 | //Query Give Forms |
| 117 | - $args = array( |
|
| 117 | + $args = array( |
|
| 118 | 118 | 'post_type' => 'google_maps', |
| 119 | 119 | 'posts_per_page' => - 1, |
| 120 | 120 | 'post_status' => 'publish', |
| 121 | 121 | ); |
| 122 | - $gmb_forms = get_posts( $args ); |
|
| 122 | + $gmb_forms = get_posts($args); |
|
| 123 | 123 | ?> |
| 124 | 124 | <p> |
| 125 | - <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php _e( 'Select a Map:', $this->plugin_slug ); ?> |
|
| 126 | - <span class="dashicons gmb-tooltip-icon" data-tooltip="<?php _e( 'Select a map that you would like to embed in this widget area.', $this->plugin_slug ); ?>"></span> |
|
| 125 | + <label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php _e('Select a Map:', $this->plugin_slug); ?> |
|
| 126 | + <span class="dashicons gmb-tooltip-icon" data-tooltip="<?php _e('Select a map that you would like to embed in this widget area.', $this->plugin_slug); ?>"></span> |
|
| 127 | 127 | </label> |
| 128 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"> |
|
| 129 | - <option value="current"><?php _e( 'Please select...', $this->plugin_slug ); ?></option> |
|
| 130 | - <?php foreach ( $gmb_forms as $gmb_form ) { ?> |
|
| 131 | - <option <?php selected( absint( $instance['id'] ), $gmb_form->ID ); ?> value="<?php echo esc_attr( $gmb_form->ID ); ?>"><?php echo $gmb_form->post_title; ?></option> |
|
| 128 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>"> |
|
| 129 | + <option value="current"><?php _e('Please select...', $this->plugin_slug); ?></option> |
|
| 130 | + <?php foreach ($gmb_forms as $gmb_form) { ?> |
|
| 131 | + <option <?php selected(absint($instance['id']), $gmb_form->ID); ?> value="<?php echo esc_attr($gmb_form->ID); ?>"><?php echo $gmb_form->post_title; ?></option> |
|
| 132 | 132 | <?php } ?> |
| 133 | 133 | </select> |
| 134 | 134 | </p> |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | <div class="gmb-widget-upgrade clear"> |
| 138 | 138 | <span class="powered-by"></span> |
| 139 | - <a href="https://wordimpress.com/plugins/maps-builder-pro?utm_source=MBF&utm_medium=BANNER&utm_content=WIDGET&utm_campaign=MBF%20Widgets" target="_blank" class="button button-small"><?php _e( 'Upgrade to Pro', $this->plugin_slug ); ?> |
|
| 139 | + <a href="https://wordimpress.com/plugins/maps-builder-pro?utm_source=MBF&utm_medium=BANNER&utm_content=WIDGET&utm_campaign=MBF%20Widgets" target="_blank" class="button button-small"><?php _e('Upgrade to Pro', $this->plugin_slug); ?> |
|
| 140 | 140 | <span class="new-window"></span></a> |
| 141 | 141 | </div> |
| 142 | 142 | |
@@ -152,14 +152,14 @@ discard block |
||
| 152 | 152 | * @param array $args Widget arguments. |
| 153 | 153 | * @param array $instance Saved values from database. |
| 154 | 154 | */ |
| 155 | - public function widget( $args, $instance ) { |
|
| 155 | + public function widget($args, $instance) { |
|
| 156 | 156 | |
| 157 | 157 | echo $args['before_widget']; |
| 158 | 158 | |
| 159 | - do_action( 'gmb_before_forms_widget' ); |
|
| 159 | + do_action('gmb_before_forms_widget'); |
|
| 160 | 160 | |
| 161 | - if ( ! empty( $instance['title'] ) ) { |
|
| 162 | - echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title']; |
|
| 161 | + if ( ! empty($instance['title'])) { |
|
| 162 | + echo $args['before_title'].apply_filters('widget_title', $instance['title']).$args['after_title']; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $atts = array( |
@@ -167,14 +167,14 @@ discard block |
||
| 167 | 167 | ); |
| 168 | 168 | |
| 169 | 169 | //Ensure a map has been set |
| 170 | - if ( $instance['id'] !== 'current' ) { |
|
| 171 | - echo Google_Maps_Builder()->engine->google_maps_shortcode( $atts ); |
|
| 170 | + if ($instance['id'] !== 'current') { |
|
| 171 | + echo Google_Maps_Builder()->engine->google_maps_shortcode($atts); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
| 175 | 175 | echo $args['after_widget']; |
| 176 | 176 | |
| 177 | - do_action( 'gmb_after_forms_widget' ); |
|
| 177 | + do_action('gmb_after_forms_widget'); |
|
| 178 | 178 | |
| 179 | 179 | } |
| 180 | 180 | |
@@ -185,11 +185,11 @@ discard block |
||
| 185 | 185 | * @DESC: Saves the widget options |
| 186 | 186 | * @SEE WP_Widget::update |
| 187 | 187 | */ |
| 188 | - function update( $new_instance, $old_instance ) { |
|
| 188 | + function update($new_instance, $old_instance) { |
|
| 189 | 189 | $instance = $old_instance; |
| 190 | 190 | //loop through options array and save to new instance |
| 191 | - foreach ( $this->widget_defaults as $field => $value ) { |
|
| 192 | - $instance[ $field ] = strip_tags( stripslashes( $new_instance[ $field ] ) ); |
|
| 191 | + foreach ($this->widget_defaults as $field => $value) { |
|
| 192 | + $instance[$field] = strip_tags(stripslashes($new_instance[$field])); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | return $instance; |