@@ -169,7 +169,6 @@ |
||
| 169 | 169 | * |
| 170 | 170 | * @since 1.15.2 |
| 171 | 171 | * |
| 172 | - * @param array $handles Array of meta keys to check for existence of shortcodes |
|
| 173 | 172 | * @param int $post_id The ID being checked by GravityView |
| 174 | 173 | * |
| 175 | 174 | * @return array Meta key array, merged with existing meta keys |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | * @return void |
| 90 | 90 | */ |
| 91 | 91 | private function maybe_add_hooks() { |
| 92 | - $class_exists = ! $this->class_name || ( $this->class_name && class_exists( $this->class_name ) ); |
|
| 93 | - $function_exists = ! $this->function_name || ( $this->function_name && function_exists( $this->function_name ) ); |
|
| 94 | - $constant_defined = ! $this->constant_name || ( $this->constant_name && defined( $this->constant_name ) ); |
|
| 92 | + $class_exists = !$this->class_name || ($this->class_name && class_exists($this->class_name)); |
|
| 93 | + $function_exists = !$this->function_name || ($this->function_name && function_exists($this->function_name)); |
|
| 94 | + $constant_defined = !$this->constant_name || ($this->constant_name && defined($this->constant_name)); |
|
| 95 | 95 | |
| 96 | - if( $class_exists || $function_exists || $constant_defined ) { |
|
| 96 | + if ($class_exists || $function_exists || $constant_defined) { |
|
| 97 | 97 | $this->add_hooks(); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -104,20 +104,20 @@ discard block |
||
| 104 | 104 | * @return void |
| 105 | 105 | */ |
| 106 | 106 | protected function add_hooks() { |
| 107 | - if( $this->content_meta_keys ) { |
|
| 108 | - add_filter( 'gravityview/data/parse/meta_keys', array( $this, 'merge_content_meta_keys' ), 10, 2 ); |
|
| 107 | + if ($this->content_meta_keys) { |
|
| 108 | + add_filter('gravityview/data/parse/meta_keys', array($this, 'merge_content_meta_keys'), 10, 2); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if( $this->script_handles ) { |
|
| 112 | - add_filter( 'gravityview_noconflict_scripts', array( $this, 'merge_noconflict_scripts' ) ); |
|
| 111 | + if ($this->script_handles) { |
|
| 112 | + add_filter('gravityview_noconflict_scripts', array($this, 'merge_noconflict_scripts')); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if( $this->style_handles ) { |
|
| 116 | - add_filter( 'gravityview_noconflict_styles', array( $this, 'merge_noconflict_styles' ) ); |
|
| 115 | + if ($this->style_handles) { |
|
| 116 | + add_filter('gravityview_noconflict_styles', array($this, 'merge_noconflict_styles')); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if( $this->post_type_support ) { |
|
| 120 | - add_filter( 'gravityview_post_type_support', array( $this, 'merge_post_type_support' ), 10, 2 ); |
|
| 119 | + if ($this->post_type_support) { |
|
| 120 | + add_filter('gravityview_post_type_support', array($this, 'merge_post_type_support'), 10, 2); |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | * |
| 132 | 132 | * @return array Array of features associated with a functional area of the edit screen, merged with existing values |
| 133 | 133 | */ |
| 134 | - public function merge_post_type_support( $supports = array(), $is_hierarchical = false ) { |
|
| 135 | - $supports = array_merge( $this->post_type_support, $supports ); |
|
| 134 | + public function merge_post_type_support($supports = array(), $is_hierarchical = false) { |
|
| 135 | + $supports = array_merge($this->post_type_support, $supports); |
|
| 136 | 136 | return $supports; |
| 137 | 137 | } |
| 138 | 138 | |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | * |
| 146 | 146 | * @return array Handles, merged with existing styles |
| 147 | 147 | */ |
| 148 | - public function merge_noconflict_styles( $handles ) { |
|
| 149 | - $handles = array_merge( $this->style_handles, $handles ); |
|
| 148 | + public function merge_noconflict_styles($handles) { |
|
| 149 | + $handles = array_merge($this->style_handles, $handles); |
|
| 150 | 150 | return $handles; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @return array Handles, merged with existing scripts |
| 161 | 161 | */ |
| 162 | - public function merge_noconflict_scripts( $handles ) { |
|
| 163 | - $handles = array_merge( $this->script_handles, $handles ); |
|
| 162 | + public function merge_noconflict_scripts($handles) { |
|
| 163 | + $handles = array_merge($this->script_handles, $handles); |
|
| 164 | 164 | return $handles; |
| 165 | 165 | } |
| 166 | 166 | |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @return array Meta key array, merged with existing meta keys |
| 176 | 176 | */ |
| 177 | - public function merge_content_meta_keys( $meta_keys = array(), $post_id = 0 ) { |
|
| 178 | - return array_merge( $this->content_meta_keys, $meta_keys ); |
|
| 177 | + public function merge_content_meta_keys($meta_keys = array(), $post_id = 0) { |
|
| 178 | + return array_merge($this->content_meta_keys, $meta_keys); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | } |
| 182 | 182 | \ No newline at end of file |
@@ -51,6 +51,9 @@ |
||
| 51 | 51 | // hold widget View options |
| 52 | 52 | private $widget_options; |
| 53 | 53 | |
| 54 | + /** |
|
| 55 | + * @param string $widget_id |
|
| 56 | + */ |
|
| 54 | 57 | function __construct( $widget_label , $widget_id , $defaults = array(), $settings = array() ) { |
| 55 | 58 | |
| 56 | 59 | |
@@ -116,12 +116,12 @@ |
||
| 116 | 116 | return $settings; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * @return string |
|
| 121 | - */ |
|
| 122 | - public function get_widget_id() { |
|
| 123 | - return $this->widget_id; |
|
| 124 | - } |
|
| 119 | + /** |
|
| 120 | + * @return string |
|
| 121 | + */ |
|
| 122 | + public function get_widget_id() { |
|
| 123 | + return $this->widget_id; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * Get the widget settings |
@@ -51,37 +51,37 @@ discard block |
||
| 51 | 51 | // hold widget View options |
| 52 | 52 | private $widget_options; |
| 53 | 53 | |
| 54 | - function __construct( $widget_label , $widget_id , $defaults = array(), $settings = array() ) { |
|
| 54 | + function __construct($widget_label, $widget_id, $defaults = array(), $settings = array()) { |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * The shortcode name is set to the lowercase name of the widget class, unless overridden by the class specifying a different value for $shortcode_name |
| 59 | 59 | * @var string |
| 60 | 60 | */ |
| 61 | - $this->shortcode_name = !isset( $this->shortcode_name ) ? strtolower( get_class($this) ) : $this->shortcode_name; |
|
| 61 | + $this->shortcode_name = !isset($this->shortcode_name) ? strtolower(get_class($this)) : $this->shortcode_name; |
|
| 62 | 62 | |
| 63 | 63 | $this->widget_label = $widget_label; |
| 64 | 64 | $this->widget_id = $widget_id; |
| 65 | - $this->defaults = array_merge( array( 'header' => 0, 'footer' => 0 ), $defaults ); |
|
| 65 | + $this->defaults = array_merge(array('header' => 0, 'footer' => 0), $defaults); |
|
| 66 | 66 | |
| 67 | 67 | // Make sure every widget has a title, even if empty |
| 68 | 68 | $this->settings = $this->get_default_settings(); |
| 69 | - $this->settings = wp_parse_args( $settings, $this->settings ); |
|
| 69 | + $this->settings = wp_parse_args($settings, $this->settings); |
|
| 70 | 70 | |
| 71 | 71 | // register widgets to be listed in the View Configuration |
| 72 | - add_filter( 'gravityview_register_directory_widgets', array( $this, 'register_widget') ); |
|
| 72 | + add_filter('gravityview_register_directory_widgets', array($this, 'register_widget')); |
|
| 73 | 73 | |
| 74 | 74 | // widget options |
| 75 | - add_filter( 'gravityview_template_widget_options', array( $this, 'assign_widget_options' ), 10, 3 ); |
|
| 75 | + add_filter('gravityview_template_widget_options', array($this, 'assign_widget_options'), 10, 3); |
|
| 76 | 76 | |
| 77 | 77 | // frontend logic |
| 78 | - add_action( "gravityview_render_widget_{$widget_id}", array( $this, 'render_frontend' ), 10, 1 ); |
|
| 78 | + add_action("gravityview_render_widget_{$widget_id}", array($this, 'render_frontend'), 10, 1); |
|
| 79 | 79 | |
| 80 | 80 | // register shortcodes |
| 81 | - add_action( 'wp', array( $this, 'add_shortcode') ); |
|
| 81 | + add_action('wp', array($this, 'add_shortcode')); |
|
| 82 | 82 | |
| 83 | 83 | // Use shortcodes in text widgets. |
| 84 | - add_filter('widget_text', array( $this, 'maybe_do_shortcode' ) ); |
|
| 84 | + add_filter('widget_text', array($this, 'maybe_do_shortcode')); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | * @param boolean $enable_custom_class False by default. Return true if you want to enable. |
| 100 | 100 | * @param GravityView_Widget $this Current instance of GravityView_Widget |
| 101 | 101 | */ |
| 102 | - $enable_custom_class = apply_filters('gravityview/widget/enable_custom_class', false, $this ); |
|
| 102 | + $enable_custom_class = apply_filters('gravityview/widget/enable_custom_class', false, $this); |
|
| 103 | 103 | |
| 104 | - if( $enable_custom_class ) { |
|
| 104 | + if ($enable_custom_class) { |
|
| 105 | 105 | |
| 106 | 106 | $settings['custom_class'] = array( |
| 107 | 107 | 'type' => 'text', |
| 108 | - 'label' => __( 'Custom CSS Class:', 'gravityview' ), |
|
| 109 | - 'desc' => __( 'This class will be added to the widget container', 'gravityview'), |
|
| 108 | + 'label' => __('Custom CSS Class:', 'gravityview'), |
|
| 109 | + 'desc' => __('This class will be added to the widget container', 'gravityview'), |
|
| 110 | 110 | 'value' => '', |
| 111 | 111 | 'merge_tags' => true, |
| 112 | 112 | ); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @return array|null Settings array; NULL if not set |
| 129 | 129 | */ |
| 130 | 130 | public function get_settings() { |
| 131 | - return !empty( $this->settings ) ? $this->settings : NULL; |
|
| 131 | + return !empty($this->settings) ? $this->settings : NULL; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | * @param string $key Key for the setting |
| 137 | 137 | * @return mixed|null Value of the setting; NULL if not set |
| 138 | 138 | */ |
| 139 | - public function get_setting( $key ) { |
|
| 139 | + public function get_setting($key) { |
|
| 140 | 140 | $setting = NULL; |
| 141 | 141 | |
| 142 | - if( isset( $this->settings ) && is_array( $this->settings ) ) { |
|
| 143 | - $setting = isset( $this->settings[ $key ] ) ? $this->settings[ $key ] : NULL; |
|
| 142 | + if (isset($this->settings) && is_array($this->settings)) { |
|
| 143 | + $setting = isset($this->settings[$key]) ? $this->settings[$key] : NULL; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | return $setting; |
@@ -152,20 +152,20 @@ discard block |
||
| 152 | 152 | * @param null|WP_Widget Empty if not called by WP_Widget, or a WP_Widget instance |
| 153 | 153 | * @return string Widget text |
| 154 | 154 | */ |
| 155 | - function maybe_do_shortcode( $text, $widget = NULL ) { |
|
| 155 | + function maybe_do_shortcode($text, $widget = NULL) { |
|
| 156 | 156 | |
| 157 | - if( !empty( $this->shortcode_name ) && has_shortcode( $text, $this->shortcode_name ) ) { |
|
| 158 | - return do_shortcode( $text ); |
|
| 157 | + if (!empty($this->shortcode_name) && has_shortcode($text, $this->shortcode_name)) { |
|
| 158 | + return do_shortcode($text); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | return $text; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - function render_shortcode( $atts, $content = '', $context = '' ) { |
|
| 164 | + function render_shortcode($atts, $content = '', $context = '') { |
|
| 165 | 165 | |
| 166 | 166 | ob_start(); |
| 167 | 167 | |
| 168 | - $this->render_frontend( $atts, $content, $context ); |
|
| 168 | + $this->render_frontend($atts, $content, $context); |
|
| 169 | 169 | |
| 170 | 170 | return ob_get_clean(); |
| 171 | 171 | } |
@@ -173,31 +173,31 @@ discard block |
||
| 173 | 173 | /** |
| 174 | 174 | * Add $this->shortcode_name shortcode to output self::render_frontend() |
| 175 | 175 | */ |
| 176 | - function add_shortcode( $run_on_singular = true ) { |
|
| 176 | + function add_shortcode($run_on_singular = true) { |
|
| 177 | 177 | global $post; |
| 178 | 178 | |
| 179 | - if( GravityView_Plugin::is_admin() ) { return; } |
|
| 179 | + if (GravityView_Plugin::is_admin()) { return; } |
|
| 180 | 180 | |
| 181 | - if( empty( $this->shortcode_name ) ) { return; } |
|
| 181 | + if (empty($this->shortcode_name)) { return; } |
|
| 182 | 182 | |
| 183 | 183 | // If the widget shouldn't output on single entries, don't show it |
| 184 | - if( empty( $this->show_on_single ) && class_exists('GravityView_frontend') && GravityView_frontend::is_single_entry() ) { |
|
| 185 | - do_action('gravityview_log_debug', sprintf( '%s[add_shortcode]: Skipping; set to not run on single entry.', get_class($this)) ); |
|
| 184 | + if (empty($this->show_on_single) && class_exists('GravityView_frontend') && GravityView_frontend::is_single_entry()) { |
|
| 185 | + do_action('gravityview_log_debug', sprintf('%s[add_shortcode]: Skipping; set to not run on single entry.', get_class($this))); |
|
| 186 | 186 | |
| 187 | - add_shortcode( $this->shortcode_name, '__return_null' ); |
|
| 187 | + add_shortcode($this->shortcode_name, '__return_null'); |
|
| 188 | 188 | return; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
| 192 | - if( !has_gravityview_shortcode( $post ) ) { |
|
| 192 | + if (!has_gravityview_shortcode($post)) { |
|
| 193 | 193 | |
| 194 | - do_action('gravityview_log_debug', sprintf( '%s[add_shortcode]: No shortcode present; not adding render_frontend shortcode.', get_class($this)) ); |
|
| 194 | + do_action('gravityview_log_debug', sprintf('%s[add_shortcode]: No shortcode present; not adding render_frontend shortcode.', get_class($this))); |
|
| 195 | 195 | |
| 196 | - add_shortcode( $this->shortcode_name, '__return_null' ); |
|
| 196 | + add_shortcode($this->shortcode_name, '__return_null'); |
|
| 197 | 197 | return; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - add_shortcode( $this->shortcode_name, array( $this, 'render_shortcode') ); |
|
| 200 | + add_shortcode($this->shortcode_name, array($this, 'render_shortcode')); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -205,9 +205,9 @@ discard block |
||
| 205 | 205 | * @param array $widgets |
| 206 | 206 | * @return array $widgets |
| 207 | 207 | */ |
| 208 | - function register_widget( $widgets ) { |
|
| 209 | - $widgets[ $this->widget_id ] = array( |
|
| 210 | - 'label' => $this->widget_label , |
|
| 208 | + function register_widget($widgets) { |
|
| 209 | + $widgets[$this->widget_id] = array( |
|
| 210 | + 'label' => $this->widget_label, |
|
| 211 | 211 | 'description' => $this->widget_description, |
| 212 | 212 | 'subtitle' => $this->widget_subtitle, |
| 213 | 213 | ); |
@@ -222,10 +222,10 @@ discard block |
||
| 222 | 222 | * @param string $template (default: '') |
| 223 | 223 | * @return array |
| 224 | 224 | */ |
| 225 | - public function assign_widget_options( $options = array(), $template = '', $widget = '' ) { |
|
| 225 | + public function assign_widget_options($options = array(), $template = '', $widget = '') { |
|
| 226 | 226 | |
| 227 | - if( $this->widget_id === $widget ) { |
|
| 228 | - $options = array_merge( $options, $this->settings ); |
|
| 227 | + if ($this->widget_id === $widget) { |
|
| 228 | + $options = array_merge($options, $this->settings); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | return $options; |
@@ -237,9 +237,9 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @return void |
| 239 | 239 | */ |
| 240 | - public function render_frontend( $widget_args, $content = '', $context = '') { |
|
| 240 | + public function render_frontend($widget_args, $content = '', $context = '') { |
|
| 241 | 241 | // to be defined by child class |
| 242 | - if( !$this->pre_render_frontend() ) { |
|
| 242 | + if (!$this->pre_render_frontend()) { |
|
| 243 | 243 | return; |
| 244 | 244 | } |
| 245 | 245 | } |
@@ -251,8 +251,8 @@ discard block |
||
| 251 | 251 | public function pre_render_frontend() { |
| 252 | 252 | $gravityview_view = GravityView_View::getInstance(); |
| 253 | 253 | |
| 254 | - if( empty( $gravityview_view ) ) { |
|
| 255 | - do_action('gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this)) ); |
|
| 254 | + if (empty($gravityview_view)) { |
|
| 255 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this))); |
|
| 256 | 256 | return false; |
| 257 | 257 | } |
| 258 | 258 | |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | * @param boolean $hide_until_searched Hide until search? |
| 262 | 262 | * @param GravityView_Widget $this Widget instance |
| 263 | 263 | */ |
| 264 | - $hide_until_search = apply_filters( 'gravityview/widget/hide_until_searched', $gravityview_view->hide_until_searched, $this ); |
|
| 264 | + $hide_until_search = apply_filters('gravityview/widget/hide_until_searched', $gravityview_view->hide_until_searched, $this); |
|
| 265 | 265 | |
| 266 | - if( $hide_until_search ) { |
|
| 267 | - do_action('gravityview_log_debug', sprintf( '%s[render_frontend]: Hide View data until search is performed', get_class($this)) ); |
|
| 266 | + if ($hide_until_search) { |
|
| 267 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend]: Hide View data until search is performed', get_class($this))); |
|
| 268 | 268 | return false; |
| 269 | 269 | } |
| 270 | 270 | |
@@ -993,7 +993,7 @@ |
||
| 993 | 993 | /** |
| 994 | 994 | * Modify the array passed to wp_localize_script() |
| 995 | 995 | * |
| 996 | - * @param array $js_localization The data padded to the Javascript file |
|
| 996 | + * @param array $localizations The data padded to the Javascript file |
|
| 997 | 997 | * @param array $view_data View data array with View settings |
| 998 | 998 | * |
| 999 | 999 | * @return array |
@@ -384,16 +384,16 @@ |
||
| 384 | 384 | $curr_start = esc_attr( rgget( 'gv_start' ) ); |
| 385 | 385 | $curr_end = esc_attr( rgget( 'gv_end' ) ); |
| 386 | 386 | |
| 387 | - /** |
|
| 388 | - * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
|
| 389 | - * date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php) |
|
| 390 | - * @since 1.12 |
|
| 391 | - * @param[out,in] boolean $adjust_tz Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true |
|
| 392 | - * @param[in] string $context Where the filter is being called from. `search` in this case. |
|
| 393 | - */ |
|
| 394 | - $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' ); |
|
| 395 | - $search_criteria['start_date'] = ( $adjust_tz && !empty( $curr_start ) ) ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 396 | - $search_criteria['end_date'] = ( $adjust_tz && !empty( $curr_end ) ) ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 387 | + /** |
|
| 388 | + * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
|
| 389 | + * date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php) |
|
| 390 | + * @since 1.12 |
|
| 391 | + * @param[out,in] boolean $adjust_tz Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true |
|
| 392 | + * @param[in] string $context Where the filter is being called from. `search` in this case. |
|
| 393 | + */ |
|
| 394 | + $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' ); |
|
| 395 | + $search_criteria['start_date'] = ( $adjust_tz && !empty( $curr_start ) ) ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 396 | + $search_criteria['end_date'] = ( $adjust_tz && !empty( $curr_end ) ) ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 397 | 397 | |
| 398 | 398 | |
| 399 | 399 | // search for a specific entry ID |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @copyright Copyright 2014, Katz Web Services, Inc. |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'WPINC' ) ) { |
|
| 12 | +if (!defined('WPINC')) { |
|
| 13 | 13 | die; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -22,28 +22,28 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | public function __construct() { |
| 24 | 24 | |
| 25 | - $this->widget_description = esc_html__( 'Search form for searching entries.', 'gravityview' ); |
|
| 25 | + $this->widget_description = esc_html__('Search form for searching entries.', 'gravityview'); |
|
| 26 | 26 | |
| 27 | 27 | self::$instance = &$this; |
| 28 | 28 | |
| 29 | - self::$file = plugin_dir_path( __FILE__ ); |
|
| 29 | + self::$file = plugin_dir_path(__FILE__); |
|
| 30 | 30 | |
| 31 | - $default_values = array( 'header' => 0, 'footer' => 0 ); |
|
| 31 | + $default_values = array('header' => 0, 'footer' => 0); |
|
| 32 | 32 | |
| 33 | 33 | $settings = array( |
| 34 | 34 | 'search_layout' => array( |
| 35 | 35 | 'type' => 'radio', |
| 36 | 36 | 'full_width' => true, |
| 37 | - 'label' => esc_html__( 'Search Layout', 'gravityview' ), |
|
| 37 | + 'label' => esc_html__('Search Layout', 'gravityview'), |
|
| 38 | 38 | 'value' => 'horizontal', |
| 39 | 39 | 'options' => array( |
| 40 | - 'horizontal' => esc_html__( 'Horizontal', 'gravityview' ), |
|
| 41 | - 'vertical' => esc_html__( 'Vertical', 'gravityview' ), |
|
| 40 | + 'horizontal' => esc_html__('Horizontal', 'gravityview'), |
|
| 41 | + 'vertical' => esc_html__('Vertical', 'gravityview'), |
|
| 42 | 42 | ), |
| 43 | 43 | ), |
| 44 | 44 | 'search_clear' => array( |
| 45 | 45 | 'type' => 'checkbox', |
| 46 | - 'label' => __( 'Show Clear button', 'gravityview' ), |
|
| 46 | + 'label' => __('Show Clear button', 'gravityview'), |
|
| 47 | 47 | 'value' => false, |
| 48 | 48 | ), |
| 49 | 49 | 'search_fields' => array( |
@@ -55,33 +55,33 @@ discard block |
||
| 55 | 55 | 'search_mode' => array( |
| 56 | 56 | 'type' => 'radio', |
| 57 | 57 | 'full_width' => true, |
| 58 | - 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
|
| 58 | + 'label' => esc_html__('Search Mode', 'gravityview'), |
|
| 59 | 59 | 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
| 60 | 60 | 'value' => 'any', |
| 61 | 61 | 'class' => 'hide-if-js', |
| 62 | 62 | 'options' => array( |
| 63 | - 'any' => esc_html__( 'Match Any Fields', 'gravityview' ), |
|
| 64 | - 'all' => esc_html__( 'Match All Fields', 'gravityview' ), |
|
| 63 | + 'any' => esc_html__('Match Any Fields', 'gravityview'), |
|
| 64 | + 'all' => esc_html__('Match All Fields', 'gravityview'), |
|
| 65 | 65 | ), |
| 66 | 66 | ), |
| 67 | 67 | ); |
| 68 | - parent::__construct( esc_html__( 'Search Bar', 'gravityview' ), 'search_bar', $default_values, $settings ); |
|
| 68 | + parent::__construct(esc_html__('Search Bar', 'gravityview'), 'search_bar', $default_values, $settings); |
|
| 69 | 69 | |
| 70 | 70 | // frontend - filter entries |
| 71 | - add_filter( 'gravityview_fe_search_criteria', array( $this, 'filter_entries' ), 10, 1 ); |
|
| 71 | + add_filter('gravityview_fe_search_criteria', array($this, 'filter_entries'), 10, 1); |
|
| 72 | 72 | |
| 73 | 73 | // frontend - add template path |
| 74 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
| 74 | + add_filter('gravityview_template_paths', array($this, 'add_template_path')); |
|
| 75 | 75 | |
| 76 | 76 | // Add hidden fields for "Default" permalink structure |
| 77 | - add_filter( 'gravityview_widget_search_filters', array( $this, 'add_no_permalink_fields' ), 10, 3 ); |
|
| 77 | + add_filter('gravityview_widget_search_filters', array($this, 'add_no_permalink_fields'), 10, 3); |
|
| 78 | 78 | |
| 79 | 79 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
| 80 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
|
| 81 | - add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
|
| 80 | + add_action('admin_enqueue_scripts', array($this, 'add_scripts_and_styles'), 1100); |
|
| 81 | + add_filter('gravityview_noconflict_scripts', array($this, 'register_no_conflict')); |
|
| 82 | 82 | |
| 83 | 83 | // ajax - get the searchable fields |
| 84 | - add_action( 'wp_ajax_gv_searchable_fields', array( 'GravityView_Widget_Search', 'get_searchable_fields' ) ); |
|
| 84 | + add_action('wp_ajax_gv_searchable_fields', array('GravityView_Widget_Search', 'get_searchable_fields')); |
|
| 85 | 85 | |
| 86 | 86 | } |
| 87 | 87 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @return GravityView_Widget_Search |
| 90 | 90 | */ |
| 91 | 91 | public static function getInstance() { |
| 92 | - if ( empty( self::$instance ) ) { |
|
| 92 | + if (empty(self::$instance)) { |
|
| 93 | 93 | self::$instance = new GravityView_Widget_Search; |
| 94 | 94 | } |
| 95 | 95 | return self::$instance; |
@@ -100,18 +100,18 @@ discard block |
||
| 100 | 100 | * Add script to Views edit screen (admin) |
| 101 | 101 | * @param mixed $hook |
| 102 | 102 | */ |
| 103 | - public function add_scripts_and_styles( $hook ) { |
|
| 103 | + public function add_scripts_and_styles($hook) { |
|
| 104 | 104 | global $pagenow; |
| 105 | 105 | |
| 106 | 106 | // Don't process any scripts below here if it's not a GravityView page or the widgets screen |
| 107 | - if ( ! gravityview_is_admin_page( $hook ) && ( 'widgets.php' !== $pagenow ) ) { |
|
| 107 | + if (!gravityview_is_admin_page($hook) && ('widgets.php' !== $pagenow)) { |
|
| 108 | 108 | return; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 112 | - $script_source = empty( $script_min ) ? '/source' : ''; |
|
| 111 | + $script_min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 112 | + $script_source = empty($script_min) ? '/source' : ''; |
|
| 113 | 113 | |
| 114 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), GravityView_Plugin::version ); |
|
| 114 | + wp_enqueue_script('gravityview_searchwidget_admin', plugins_url('assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__), array('jquery', 'gravityview_views_scripts'), GravityView_Plugin::version); |
|
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -120,15 +120,15 @@ discard block |
||
| 120 | 120 | * @var array |
| 121 | 121 | */ |
| 122 | 122 | $input_labels = array( |
| 123 | - 'input_text' => esc_html__( 'Text', 'gravityview' ), |
|
| 124 | - 'date' => esc_html__( 'Date', 'gravityview' ), |
|
| 125 | - 'select' => esc_html__( 'Select', 'gravityview' ), |
|
| 126 | - 'multiselect' => esc_html__( 'Select (multiple values)', 'gravityview' ), |
|
| 127 | - 'radio' => esc_html__( 'Radio', 'gravityview' ), |
|
| 128 | - 'checkbox' => esc_html__( 'Checkbox', 'gravityview' ), |
|
| 129 | - 'single_checkbox' => esc_html__( 'Checkbox', 'gravityview' ), |
|
| 130 | - 'link' => esc_html__( 'Links', 'gravityview' ), |
|
| 131 | - 'date_range' => esc_html__( 'Date range', 'gravityview' ), |
|
| 123 | + 'input_text' => esc_html__('Text', 'gravityview'), |
|
| 124 | + 'date' => esc_html__('Date', 'gravityview'), |
|
| 125 | + 'select' => esc_html__('Select', 'gravityview'), |
|
| 126 | + 'multiselect' => esc_html__('Select (multiple values)', 'gravityview'), |
|
| 127 | + 'radio' => esc_html__('Radio', 'gravityview'), |
|
| 128 | + 'checkbox' => esc_html__('Checkbox', 'gravityview'), |
|
| 129 | + 'single_checkbox' => esc_html__('Checkbox', 'gravityview'), |
|
| 130 | + 'link' => esc_html__('Links', 'gravityview'), |
|
| 131 | + 'date_range' => esc_html__('Date range', 'gravityview'), |
|
| 132 | 132 | ); |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -137,32 +137,32 @@ discard block |
||
| 137 | 137 | * @var array |
| 138 | 138 | */ |
| 139 | 139 | $input_types = array( |
| 140 | - 'text' => array( 'input_text' ), |
|
| 141 | - 'address' => array( 'input_text' ), |
|
| 142 | - 'date' => array( 'date', 'date_range' ), |
|
| 143 | - 'boolean' => array( 'single_checkbox' ), |
|
| 144 | - 'select' => array( 'select', 'radio', 'link' ), |
|
| 145 | - 'multi' => array( 'select', 'multiselect', 'radio', 'checkbox', 'link' ), |
|
| 140 | + 'text' => array('input_text'), |
|
| 141 | + 'address' => array('input_text'), |
|
| 142 | + 'date' => array('date', 'date_range'), |
|
| 143 | + 'boolean' => array('single_checkbox'), |
|
| 144 | + 'select' => array('select', 'radio', 'link'), |
|
| 145 | + 'multi' => array('select', 'multiselect', 'radio', 'checkbox', 'link'), |
|
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | - wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
|
| 149 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
|
| 150 | - 'label_nofields' => esc_html__( 'No search fields configured yet.', 'gravityview' ), |
|
| 151 | - 'label_addfield' => esc_html__( 'Add Search Field', 'gravityview' ), |
|
| 152 | - 'label_label' => esc_html__( 'Label', 'gravityview' ), |
|
| 153 | - 'label_searchfield' => esc_html__( 'Search Field', 'gravityview' ), |
|
| 154 | - 'label_inputtype' => esc_html__( 'Input Type', 'gravityview' ), |
|
| 155 | - 'label_ajaxerror' => esc_html__( 'There was an error loading searchable fields. Save the View or refresh the page to fix this issue.', 'gravityview' ), |
|
| 156 | - 'input_labels' => json_encode( $input_labels ), |
|
| 157 | - 'input_types' => json_encode( $input_types ), |
|
| 158 | - ) ); |
|
| 148 | + wp_localize_script('gravityview_searchwidget_admin', 'gvSearchVar', array( |
|
| 149 | + 'nonce' => wp_create_nonce('gravityview_ajaxsearchwidget'), |
|
| 150 | + 'label_nofields' => esc_html__('No search fields configured yet.', 'gravityview'), |
|
| 151 | + 'label_addfield' => esc_html__('Add Search Field', 'gravityview'), |
|
| 152 | + 'label_label' => esc_html__('Label', 'gravityview'), |
|
| 153 | + 'label_searchfield' => esc_html__('Search Field', 'gravityview'), |
|
| 154 | + 'label_inputtype' => esc_html__('Input Type', 'gravityview'), |
|
| 155 | + 'label_ajaxerror' => esc_html__('There was an error loading searchable fields. Save the View or refresh the page to fix this issue.', 'gravityview'), |
|
| 156 | + 'input_labels' => json_encode($input_labels), |
|
| 157 | + 'input_types' => json_encode($input_types), |
|
| 158 | + )); |
|
| 159 | 159 | |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | 163 | * Add admin script to the whitelist |
| 164 | 164 | */ |
| 165 | - public function register_no_conflict( $required ) { |
|
| 165 | + public function register_no_conflict($required) { |
|
| 166 | 166 | $required[] = 'gravityview_searchwidget_admin'; |
| 167 | 167 | return $required; |
| 168 | 168 | } |
@@ -176,31 +176,31 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public static function get_searchable_fields() { |
| 178 | 178 | |
| 179 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 180 | - exit( '0' ); |
|
| 179 | + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxsearchwidget')) { |
|
| 180 | + exit('0'); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | $form = ''; |
| 184 | 184 | |
| 185 | 185 | // Fetch the form for the current View |
| 186 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
| 186 | + if (!empty($_POST['view_id'])) { |
|
| 187 | 187 | |
| 188 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
| 188 | + $form = gravityview_get_form_id($_POST['view_id']); |
|
| 189 | 189 | |
| 190 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
| 190 | + } elseif (!empty($_POST['formid'])) { |
|
| 191 | 191 | |
| 192 | - $form = (int) $_POST['formid']; |
|
| 192 | + $form = (int)$_POST['formid']; |
|
| 193 | 193 | |
| 194 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 194 | + } elseif (!empty($_POST['template_id']) && class_exists('GravityView_Ajax')) { |
|
| 195 | 195 | |
| 196 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 196 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
| 197 | 197 | |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // fetch form id assigned to the view |
| 201 | - $response = self::render_searchable_fields( $form ); |
|
| 201 | + $response = self::render_searchable_fields($form); |
|
| 202 | 202 | |
| 203 | - exit( $response ); |
|
| 203 | + exit($response); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -209,14 +209,14 @@ discard block |
||
| 209 | 209 | * @param string $current (for future use) |
| 210 | 210 | * @return string |
| 211 | 211 | */ |
| 212 | - public static function render_searchable_fields( $form_id = null, $current = '' ) { |
|
| 212 | + public static function render_searchable_fields($form_id = null, $current = '') { |
|
| 213 | 213 | |
| 214 | - if ( is_null( $form_id ) ) { |
|
| 214 | + if (is_null($form_id)) { |
|
| 215 | 215 | return ''; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Get fields with sub-inputs and no parent |
| 219 | - $fields = gravityview_get_form_fields( $form_id, true, true ); |
|
| 219 | + $fields = gravityview_get_form_fields($form_id, true, true); |
|
| 220 | 220 | |
| 221 | 221 | // start building output |
| 222 | 222 | |
@@ -224,40 +224,40 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | $custom_fields = array( |
| 226 | 226 | 'search_all' => array( |
| 227 | - 'text' => esc_html__( 'Search Everything', 'gravityview' ), |
|
| 227 | + 'text' => esc_html__('Search Everything', 'gravityview'), |
|
| 228 | 228 | 'type' => 'text', |
| 229 | 229 | ), |
| 230 | 230 | 'entry_date' => array( |
| 231 | - 'text' => esc_html__( 'Entry Date', 'gravityview' ), |
|
| 231 | + 'text' => esc_html__('Entry Date', 'gravityview'), |
|
| 232 | 232 | 'type' => 'date', |
| 233 | 233 | ), |
| 234 | 234 | 'entry_id' => array( |
| 235 | - 'text' => esc_html__( 'Entry ID', 'gravityview' ), |
|
| 235 | + 'text' => esc_html__('Entry ID', 'gravityview'), |
|
| 236 | 236 | 'type' => 'text', |
| 237 | 237 | ), |
| 238 | 238 | 'created_by' => array( |
| 239 | - 'text' => esc_html__( 'Entry Creator', 'gravityview' ), |
|
| 239 | + 'text' => esc_html__('Entry Creator', 'gravityview'), |
|
| 240 | 240 | 'type' => 'select', |
| 241 | 241 | ) |
| 242 | 242 | ); |
| 243 | 243 | |
| 244 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 245 | - $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] ); |
|
| 244 | + foreach ($custom_fields as $custom_field_key => $custom_field) { |
|
| 245 | + $output .= sprintf('<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected($custom_field_key, $current, false), $custom_field['type'], self::get_field_label(array('field' => $custom_field_key)), $custom_field['text']); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - if ( ! empty( $fields ) ) { |
|
| 248 | + if (!empty($fields)) { |
|
| 249 | 249 | |
| 250 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'fileupload', 'post_image', 'post_id' ), null ); |
|
| 250 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array('fileupload', 'post_image', 'post_id'), null); |
|
| 251 | 251 | |
| 252 | - foreach ( $fields as $id => $field ) { |
|
| 252 | + foreach ($fields as $id => $field) { |
|
| 253 | 253 | |
| 254 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 254 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
| 255 | 255 | continue; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
| 258 | + $types = self::get_search_input_types($id, $field['type']); |
|
| 259 | 259 | |
| 260 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
| 260 | + $output .= '<option value="'.$id.'" '.selected($id, $current, false).'data-inputtypes="'.esc_attr($types).'">'.esc_html($field['label']).'</option>'; |
|
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | |
@@ -276,21 +276,21 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return string GV field search input type ('multi', 'boolean', 'select', 'date', 'text') |
| 278 | 278 | */ |
| 279 | - public static function get_search_input_types( $id = '', $field_type = null ) { |
|
| 279 | + public static function get_search_input_types($id = '', $field_type = null) { |
|
| 280 | 280 | |
| 281 | 281 | // @todo - This needs to be improved - many fields have . including products and addresses |
| 282 | - if ( false !== strpos( (string) $id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
| 282 | + if (false !== strpos((string)$id, '.') && in_array($field_type, array('checkbox')) || in_array($id, array('is_fulfilled'))) { |
|
| 283 | 283 | // on/off checkbox |
| 284 | 284 | $input_type = 'boolean'; |
| 285 | - } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
|
| 285 | + } elseif (in_array($field_type, array('checkbox', 'post_category', 'multiselect'))) { |
|
| 286 | 286 | //multiselect |
| 287 | 287 | $input_type = 'multi'; |
| 288 | 288 | |
| 289 | - } elseif ( in_array( $field_type, array( 'select', 'radio' ) ) ) { |
|
| 289 | + } elseif (in_array($field_type, array('select', 'radio'))) { |
|
| 290 | 290 | //single select |
| 291 | 291 | $input_type = 'select'; |
| 292 | 292 | |
| 293 | - } elseif ( in_array( $field_type, array( 'date' ) ) || in_array( $id, array( 'payment_date' ) ) ) { |
|
| 293 | + } elseif (in_array($field_type, array('date')) || in_array($id, array('payment_date'))) { |
|
| 294 | 294 | // date |
| 295 | 295 | $input_type = 'date'; |
| 296 | 296 | } else { |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | * @param string $field_type Gravity Forms field type |
| 305 | 305 | * @since 1.2 |
| 306 | 306 | */ |
| 307 | - $input_type = apply_filters( 'gravityview/extension/search/input_type', $input_type, $field_type ); |
|
| 307 | + $input_type = apply_filters('gravityview/extension/search/input_type', $input_type, $field_type); |
|
| 308 | 308 | |
| 309 | 309 | return $input_type; |
| 310 | 310 | } |
@@ -315,29 +315,29 @@ discard block |
||
| 315 | 315 | * @since 1.8 |
| 316 | 316 | * @return array Search fields, modified if not using permalinks |
| 317 | 317 | */ |
| 318 | - public function add_no_permalink_fields( $search_fields, $object, $widget_args = array() ) { |
|
| 318 | + public function add_no_permalink_fields($search_fields, $object, $widget_args = array()) { |
|
| 319 | 319 | /** @global WP_Rewrite $wp_rewrite */ |
| 320 | 320 | global $wp_rewrite; |
| 321 | 321 | |
| 322 | 322 | // Support default permalink structure |
| 323 | - if ( false === $wp_rewrite->using_permalinks() ) { |
|
| 323 | + if (false === $wp_rewrite->using_permalinks()) { |
|
| 324 | 324 | |
| 325 | 325 | // By default, use current post. |
| 326 | 326 | $post_id = 0; |
| 327 | 327 | |
| 328 | 328 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
| 329 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
| 330 | - $post_id = absint( $widget_args['post_id'] ); |
|
| 329 | + if (!empty($widget_args['post_id'])) { |
|
| 330 | + $post_id = absint($widget_args['post_id']); |
|
| 331 | 331 | } |
| 332 | 332 | // We're in the WordPress Widget context, and the base View ID should be used |
| 333 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
| 334 | - $post_id = absint( $widget_args['view_id'] ); |
|
| 333 | + else if (!empty($widget_args['view_id'])) { |
|
| 334 | + $post_id = absint($widget_args['view_id']); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - $args = gravityview_get_permalink_query_args( $post_id ); |
|
| 337 | + $args = gravityview_get_permalink_query_args($post_id); |
|
| 338 | 338 | |
| 339 | 339 | // Add hidden fields to the search form |
| 340 | - foreach ( $args as $key => $value ) { |
|
| 340 | + foreach ($args as $key => $value) { |
|
| 341 | 341 | $search_fields[] = array( |
| 342 | 342 | 'name' => $key, |
| 343 | 343 | 'input' => 'hidden', |
@@ -357,23 +357,23 @@ discard block |
||
| 357 | 357 | * @param array $search_criteria |
| 358 | 358 | * @return array |
| 359 | 359 | */ |
| 360 | - public function filter_entries( $search_criteria ) { |
|
| 360 | + public function filter_entries($search_criteria) { |
|
| 361 | 361 | |
| 362 | - do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Requested $_GET: ', get_class( $this ) ), $_GET ); |
|
| 362 | + do_action('gravityview_log_debug', sprintf('%s[filter_entries] Requested $_GET: ', get_class($this)), $_GET); |
|
| 363 | 363 | |
| 364 | - if ( empty( $_GET ) || ! is_array( $_GET ) ) { |
|
| 364 | + if (empty($_GET) || !is_array($_GET)) { |
|
| 365 | 365 | return $search_criteria; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // add free search |
| 369 | - if ( ! empty( $_GET['gv_search'] ) ) { |
|
| 369 | + if (!empty($_GET['gv_search'])) { |
|
| 370 | 370 | |
| 371 | 371 | // Search for a piece |
| 372 | - $words = explode( ' ', stripslashes_deep( urldecode( $_GET['gv_search'] ) ) ); |
|
| 372 | + $words = explode(' ', stripslashes_deep(urldecode($_GET['gv_search']))); |
|
| 373 | 373 | |
| 374 | - $words = array_filter( $words ); |
|
| 374 | + $words = array_filter($words); |
|
| 375 | 375 | |
| 376 | - foreach ( $words as $word ) { |
|
| 376 | + foreach ($words as $word) { |
|
| 377 | 377 | $search_criteria['field_filters'][] = array( |
| 378 | 378 | 'key' => null, // The field ID to search |
| 379 | 379 | 'value' => $word, // The value to search |
@@ -383,8 +383,8 @@ discard block |
||
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | //start date & end date |
| 386 | - $curr_start = esc_attr( rgget( 'gv_start' ) ); |
|
| 387 | - $curr_end = esc_attr( rgget( 'gv_end' ) ); |
|
| 386 | + $curr_start = esc_attr(rgget('gv_start')); |
|
| 387 | + $curr_end = esc_attr(rgget('gv_end')); |
|
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | 390 | * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
@@ -393,51 +393,51 @@ discard block |
||
| 393 | 393 | * @param[out,in] boolean $adjust_tz Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true |
| 394 | 394 | * @param[in] string $context Where the filter is being called from. `search` in this case. |
| 395 | 395 | */ |
| 396 | - $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' ); |
|
| 397 | - $search_criteria['start_date'] = ( $adjust_tz && !empty( $curr_start ) ) ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 398 | - $search_criteria['end_date'] = ( $adjust_tz && !empty( $curr_end ) ) ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 396 | + $adjust_tz = apply_filters('gravityview_date_created_adjust_timezone', true, 'search'); |
|
| 397 | + $search_criteria['start_date'] = ($adjust_tz && !empty($curr_start)) ? get_gmt_from_date($curr_start) : $curr_start; |
|
| 398 | + $search_criteria['end_date'] = ($adjust_tz && !empty($curr_end)) ? get_gmt_from_date($curr_end) : $curr_end; |
|
| 399 | 399 | |
| 400 | 400 | |
| 401 | 401 | // search for a specific entry ID |
| 402 | - if ( ! empty( $_GET[ 'gv_id' ] ) ) { |
|
| 402 | + if (!empty($_GET['gv_id'])) { |
|
| 403 | 403 | $search_criteria['field_filters'][] = array( |
| 404 | 404 | 'key' => 'id', |
| 405 | - 'value' => absint( $_GET[ 'gv_id' ] ), |
|
| 405 | + 'value' => absint($_GET['gv_id']), |
|
| 406 | 406 | 'operator' => '=', |
| 407 | 407 | ); |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | // search for a specific Created_by ID |
| 411 | - if ( ! empty( $_GET[ 'gv_by' ] ) ) { |
|
| 411 | + if (!empty($_GET['gv_by'])) { |
|
| 412 | 412 | $search_criteria['field_filters'][] = array( |
| 413 | 413 | 'key' => 'created_by', |
| 414 | - 'value' => absint( $_GET['gv_by'] ), |
|
| 414 | + 'value' => absint($_GET['gv_by']), |
|
| 415 | 415 | 'operator' => '=', |
| 416 | 416 | ); |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | |
| 420 | 420 | // Get search mode passed in URL |
| 421 | - $mode = in_array( rgget( 'mode' ), array( 'any', 'all' ) ) ? esc_attr( rgget( 'mode' ) ) : 'any'; |
|
| 421 | + $mode = in_array(rgget('mode'), array('any', 'all')) ? esc_attr(rgget('mode')) : 'any'; |
|
| 422 | 422 | |
| 423 | 423 | // get the other search filters |
| 424 | - foreach ( $_GET as $key => $value ) { |
|
| 424 | + foreach ($_GET as $key => $value) { |
|
| 425 | 425 | |
| 426 | - if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[0] ) ) ) { |
|
| 426 | + if (0 !== strpos($key, 'filter_') || empty($value) || (is_array($value) && count($value) === 1 && empty($value[0]))) { |
|
| 427 | 427 | continue; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | // could return simple filter or multiple filters |
| 431 | - $filter = $this->prepare_field_filter( $key, $value ); |
|
| 431 | + $filter = $this->prepare_field_filter($key, $value); |
|
| 432 | 432 | |
| 433 | - if ( isset( $filter[0]['value'] ) ) { |
|
| 434 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
| 433 | + if (isset($filter[0]['value'])) { |
|
| 434 | + $search_criteria['field_filters'] = array_merge($search_criteria['field_filters'], $filter); |
|
| 435 | 435 | |
| 436 | 436 | // if date range type, set search mode to ALL |
| 437 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>', '<' ) ) ) { |
|
| 437 | + if (!empty($filter[0]['operator']) && in_array($filter[0]['operator'], array('>', '<'))) { |
|
| 438 | 438 | $mode = 'all'; |
| 439 | 439 | } |
| 440 | - } elseif( !empty( $filter ) ) { |
|
| 440 | + } elseif (!empty($filter)) { |
|
| 441 | 441 | $search_criteria['field_filters'][] = $filter; |
| 442 | 442 | } |
| 443 | 443 | } |
@@ -447,9 +447,9 @@ discard block |
||
| 447 | 447 | * @since 1.5.1 |
| 448 | 448 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
| 449 | 449 | */ |
| 450 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 450 | + $search_criteria['field_filters']['mode'] = apply_filters('gravityview/search/mode', $mode); |
|
| 451 | 451 | |
| 452 | - do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria ); |
|
| 452 | + do_action('gravityview_log_debug', sprintf('%s[filter_entries] Returned Search Criteria: ', get_class($this)), $search_criteria); |
|
| 453 | 453 | |
| 454 | 454 | return $search_criteria; |
| 455 | 455 | } |
@@ -464,16 +464,16 @@ discard block |
||
| 464 | 464 | * @param string $value $_GET search value |
| 465 | 465 | * @return array 1 or 2 deph levels |
| 466 | 466 | */ |
| 467 | - public function prepare_field_filter( $key, $value ) { |
|
| 467 | + public function prepare_field_filter($key, $value) { |
|
| 468 | 468 | |
| 469 | 469 | $gravityview_view = GravityView_View::getInstance(); |
| 470 | 470 | |
| 471 | 471 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
| 472 | - $field_id = str_replace( '_', '.', str_replace( 'filter_', '', $key ) ); |
|
| 472 | + $field_id = str_replace('_', '.', str_replace('filter_', '', $key)); |
|
| 473 | 473 | |
| 474 | 474 | // get form field array |
| 475 | 475 | $form = $gravityview_view->getForm(); |
| 476 | - $form_field = gravityview_get_field( $form, $field_id ); |
|
| 476 | + $form_field = gravityview_get_field($form, $field_id); |
|
| 477 | 477 | |
| 478 | 478 | // default filter array |
| 479 | 479 | $filter = array( |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | 'value' => $value, |
| 482 | 482 | ); |
| 483 | 483 | |
| 484 | - switch ( $form_field['type'] ) { |
|
| 484 | + switch ($form_field['type']) { |
|
| 485 | 485 | |
| 486 | 486 | case 'select': |
| 487 | 487 | case 'radio': |
@@ -490,18 +490,18 @@ discard block |
||
| 490 | 490 | |
| 491 | 491 | case 'post_category': |
| 492 | 492 | |
| 493 | - if ( ! is_array( $value ) ) { |
|
| 494 | - $value = array( $value ); |
|
| 493 | + if (!is_array($value)) { |
|
| 494 | + $value = array($value); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | // Reset filter variable |
| 498 | 498 | $filter = array(); |
| 499 | 499 | |
| 500 | - foreach ( $value as $val ) { |
|
| 501 | - $cat = get_term( $val, 'category' ); |
|
| 500 | + foreach ($value as $val) { |
|
| 501 | + $cat = get_term($val, 'category'); |
|
| 502 | 502 | $filter[] = array( |
| 503 | 503 | 'key' => $field_id, |
| 504 | - 'value' => esc_attr( $cat->name ) . ':' . $val, |
|
| 504 | + 'value' => esc_attr($cat->name).':'.$val, |
|
| 505 | 505 | 'operator' => 'is', |
| 506 | 506 | ); |
| 507 | 507 | } |
@@ -510,35 +510,35 @@ discard block |
||
| 510 | 510 | |
| 511 | 511 | case 'multiselect': |
| 512 | 512 | |
| 513 | - if ( ! is_array( $value ) ) { |
|
| 513 | + if (!is_array($value)) { |
|
| 514 | 514 | break; |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | // Reset filter variable |
| 518 | 518 | $filter = array(); |
| 519 | 519 | |
| 520 | - foreach ( $value as $val ) { |
|
| 521 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
| 520 | + foreach ($value as $val) { |
|
| 521 | + $filter[] = array('key' => $field_id, 'value' => $val); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | break; |
| 525 | 525 | |
| 526 | 526 | case 'checkbox': |
| 527 | 527 | // convert checkbox on/off into the correct search filter |
| 528 | - if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) { |
|
| 529 | - foreach ( $form_field['inputs'] as $k => $input ) { |
|
| 530 | - if ( $input['id'] == $field_id ) { |
|
| 531 | - $filter['value'] = $form_field['choices'][ $k ]['value']; |
|
| 528 | + if (false !== strpos($field_id, '.') && !empty($form_field['inputs']) && !empty($form_field['choices'])) { |
|
| 529 | + foreach ($form_field['inputs'] as $k => $input) { |
|
| 530 | + if ($input['id'] == $field_id) { |
|
| 531 | + $filter['value'] = $form_field['choices'][$k]['value']; |
|
| 532 | 532 | $filter['operator'] = 'is'; |
| 533 | 533 | break; |
| 534 | 534 | } |
| 535 | 535 | } |
| 536 | - } elseif ( is_array( $value ) ) { |
|
| 536 | + } elseif (is_array($value)) { |
|
| 537 | 537 | |
| 538 | 538 | // Reset filter variable |
| 539 | 539 | $filter = array(); |
| 540 | 540 | |
| 541 | - foreach ( $value as $val ) { |
|
| 541 | + foreach ($value as $val) { |
|
| 542 | 542 | $filter[] = array( |
| 543 | 543 | 'key' => $field_id, |
| 544 | 544 | 'value' => $val, |
@@ -552,13 +552,13 @@ discard block |
||
| 552 | 552 | case 'name': |
| 553 | 553 | case 'address': |
| 554 | 554 | |
| 555 | - if ( false === strpos( $field_id, '.' ) ) { |
|
| 555 | + if (false === strpos($field_id, '.')) { |
|
| 556 | 556 | |
| 557 | - $words = explode( ' ', $value ); |
|
| 557 | + $words = explode(' ', $value); |
|
| 558 | 558 | |
| 559 | 559 | $filters = array(); |
| 560 | - foreach ( $words as $word ) { |
|
| 561 | - if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
|
| 560 | + foreach ($words as $word) { |
|
| 561 | + if (!empty($word) && strlen($word) > 1) { |
|
| 562 | 562 | // Keep the same key for each filter |
| 563 | 563 | $filter['value'] = $word; |
| 564 | 564 | // Add a search for the value |
@@ -573,25 +573,25 @@ discard block |
||
| 573 | 573 | |
| 574 | 574 | case 'date': |
| 575 | 575 | |
| 576 | - if ( is_array( $value ) ) { |
|
| 576 | + if (is_array($value)) { |
|
| 577 | 577 | |
| 578 | 578 | // Reset filter variable |
| 579 | 579 | $filter = array(); |
| 580 | 580 | |
| 581 | - foreach ( $value as $k => $date ) { |
|
| 582 | - if ( empty( $date ) ) { |
|
| 581 | + foreach ($value as $k => $date) { |
|
| 582 | + if (empty($date)) { |
|
| 583 | 583 | continue; |
| 584 | 584 | } |
| 585 | 585 | $operator = 'start' === $k ? '>' : '<'; |
| 586 | 586 | |
| 587 | 587 | $filter[] = array( |
| 588 | 588 | 'key' => $field_id, |
| 589 | - 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
|
| 589 | + 'value' => self::get_formatted_date($date, 'Y-m-d'), |
|
| 590 | 590 | 'operator' => $operator, |
| 591 | 591 | ); |
| 592 | 592 | } |
| 593 | 593 | } else { |
| 594 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 594 | + $filter['value'] = self::get_formatted_date($value, 'Y-m-d'); |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | break; |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | * |
| 611 | 611 | * @return string Format of the date in the database |
| 612 | 612 | */ |
| 613 | - public static function get_date_field_format( GF_Field_Date $field ) { |
|
| 613 | + public static function get_date_field_format(GF_Field_Date $field) { |
|
| 614 | 614 | $format = 'm/d/Y'; |
| 615 | 615 | $datepicker = array( |
| 616 | 616 | 'mdy' => 'm/d/Y', |
@@ -622,8 +622,8 @@ discard block |
||
| 622 | 622 | 'ymd_dot' => 'Y.m.d', |
| 623 | 623 | ); |
| 624 | 624 | |
| 625 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
| 626 | - $format = $datepicker[ $field->dateFormat ]; |
|
| 625 | + if (!empty($field->dateFormat) && isset($datepicker[$field->dateFormat])) { |
|
| 626 | + $format = $datepicker[$field->dateFormat]; |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | return $format; |
@@ -636,13 +636,13 @@ discard block |
||
| 636 | 636 | * @param string $format Wanted formatted date |
| 637 | 637 | * @return string |
| 638 | 638 | */ |
| 639 | - public static function get_formatted_date( $value = '', $format = 'Y-m-d' ) { |
|
| 640 | - $date = date_create( $value ); |
|
| 641 | - if ( empty( $date ) ) { |
|
| 642 | - do_action( 'gravityview_log_debug', sprintf( '%s[get_formatted_date] Date format not valid: ', get_class( self::$instance ) ), $value ); |
|
| 639 | + public static function get_formatted_date($value = '', $format = 'Y-m-d') { |
|
| 640 | + $date = date_create($value); |
|
| 641 | + if (empty($date)) { |
|
| 642 | + do_action('gravityview_log_debug', sprintf('%s[get_formatted_date] Date format not valid: ', get_class(self::$instance)), $value); |
|
| 643 | 643 | return ''; |
| 644 | 644 | } |
| 645 | - return $date->format( $format ); |
|
| 645 | + return $date->format($format); |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | |
@@ -650,10 +650,10 @@ discard block |
||
| 650 | 650 | * Include this extension templates path |
| 651 | 651 | * @param array $file_paths List of template paths ordered |
| 652 | 652 | */ |
| 653 | - public function add_template_path( $file_paths ) { |
|
| 653 | + public function add_template_path($file_paths) { |
|
| 654 | 654 | |
| 655 | 655 | // Index 100 is the default GravityView template path. |
| 656 | - $file_paths[102] = self::$file . 'templates/'; |
|
| 656 | + $file_paths[102] = self::$file.'templates/'; |
|
| 657 | 657 | |
| 658 | 658 | return $file_paths; |
| 659 | 659 | } |
@@ -665,50 +665,50 @@ discard block |
||
| 665 | 665 | * @param type $context |
| 666 | 666 | * @return type |
| 667 | 667 | */ |
| 668 | - public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
| 668 | + public function render_frontend($widget_args, $content = '', $context = '') { |
|
| 669 | 669 | /** @var GravityView_View $gravityview_view */ |
| 670 | 670 | $gravityview_view = GravityView_View::getInstance(); |
| 671 | 671 | |
| 672 | - if ( empty( $gravityview_view ) ) { |
|
| 673 | - do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class( $this ) ) ); |
|
| 672 | + if (empty($gravityview_view)) { |
|
| 673 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this))); |
|
| 674 | 674 | return; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | // get configured search fields |
| 678 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
| 678 | + $search_fields = !empty($widget_args['search_fields']) ? json_decode($widget_args['search_fields'], true) : ''; |
|
| 679 | 679 | |
| 680 | - if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
|
| 681 | - do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args ); |
|
| 680 | + if (empty($search_fields) || !is_array($search_fields)) { |
|
| 681 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend] No search fields configured for widget:', get_class($this)), $widget_args); |
|
| 682 | 682 | return; |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | $has_date = false; |
| 686 | 686 | |
| 687 | 687 | // prepare fields |
| 688 | - foreach ( $search_fields as $k => $field ) { |
|
| 688 | + foreach ($search_fields as $k => $field) { |
|
| 689 | 689 | |
| 690 | 690 | $updated_field = $field; |
| 691 | 691 | |
| 692 | - if ( in_array( $field['input'], array( 'date', 'date_range' ) ) ) { |
|
| 692 | + if (in_array($field['input'], array('date', 'date_range'))) { |
|
| 693 | 693 | $has_date = true; |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | - $updated_field = $this->get_search_filter_details( $updated_field ); |
|
| 696 | + $updated_field = $this->get_search_filter_details($updated_field); |
|
| 697 | 697 | |
| 698 | - switch ( $field['field'] ) { |
|
| 698 | + switch ($field['field']) { |
|
| 699 | 699 | |
| 700 | 700 | case 'search_all': |
| 701 | 701 | $updated_field['key'] = 'search_all'; |
| 702 | 702 | $updated_field['input'] = 'search_all'; |
| 703 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_search' ) ) ); |
|
| 703 | + $updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_search'))); |
|
| 704 | 704 | break; |
| 705 | 705 | |
| 706 | 706 | case 'entry_date': |
| 707 | 707 | $updated_field['key'] = 'entry_date'; |
| 708 | 708 | $updated_field['input'] = 'entry_date'; |
| 709 | 709 | $updated_field['value'] = array( |
| 710 | - 'start' => esc_attr( stripslashes_deep( rgget( 'gv_start' ) ) ), |
|
| 711 | - 'end' => esc_attr( stripslashes_deep( rgget( 'gv_end' ) ) ), |
|
| 710 | + 'start' => esc_attr(stripslashes_deep(rgget('gv_start'))), |
|
| 711 | + 'end' => esc_attr(stripslashes_deep(rgget('gv_end'))), |
|
| 712 | 712 | ); |
| 713 | 713 | $has_date = true; |
| 714 | 714 | break; |
@@ -716,21 +716,21 @@ discard block |
||
| 716 | 716 | case 'entry_id': |
| 717 | 717 | $updated_field['key'] = 'entry_id'; |
| 718 | 718 | $updated_field['input'] = 'entry_id'; |
| 719 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_id' ) ) ); |
|
| 719 | + $updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_id'))); |
|
| 720 | 720 | break; |
| 721 | 721 | |
| 722 | 722 | case 'created_by': |
| 723 | 723 | $updated_field['key'] = 'created_by'; |
| 724 | 724 | $updated_field['name'] = 'gv_by'; |
| 725 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_by' ) ) ); |
|
| 725 | + $updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_by'))); |
|
| 726 | 726 | $updated_field['choices'] = self::get_created_by_choices(); |
| 727 | 727 | break; |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | - $search_fields[ $k ] = $updated_field; |
|
| 730 | + $search_fields[$k] = $updated_field; |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | - do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] Calculated Search Fields: ', get_class( $this ) ), $search_fields ); |
|
| 733 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend] Calculated Search Fields: ', get_class($this)), $search_fields); |
|
| 734 | 734 | |
| 735 | 735 | /** |
| 736 | 736 | * @filter `gravityview_widget_search_filters` Modify what fields are shown. The order of the fields in the $search_filters array controls the order as displayed in the search bar widget. |
@@ -739,25 +739,25 @@ discard block |
||
| 739 | 739 | * @param array $widget_args Args passed to this method. {@since 1.8} |
| 740 | 740 | * @var array |
| 741 | 741 | */ |
| 742 | - $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args ); |
|
| 742 | + $gravityview_view->search_fields = apply_filters('gravityview_widget_search_filters', $search_fields, $this, $widget_args); |
|
| 743 | 743 | |
| 744 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
| 744 | + $gravityview_view->search_layout = !empty($widget_args['search_layout']) ? $widget_args['search_layout'] : 'horizontal'; |
|
| 745 | 745 | |
| 746 | 746 | /** @since 1.14 */ |
| 747 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
| 747 | + $gravityview_view->search_mode = !empty($widget_args['search_mode']) ? $widget_args['search_mode'] : 'any'; |
|
| 748 | 748 | |
| 749 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
| 749 | + $custom_class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : ''; |
|
| 750 | 750 | |
| 751 | - $gravityview_view->search_class = self::get_search_class( $custom_class ); |
|
| 751 | + $gravityview_view->search_class = self::get_search_class($custom_class); |
|
| 752 | 752 | |
| 753 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
| 753 | + $gravityview_view->search_clear = !empty($widget_args['search_clear']) ? $widget_args['search_clear'] : false; |
|
| 754 | 754 | |
| 755 | - if ( $has_date ) { |
|
| 755 | + if ($has_date) { |
|
| 756 | 756 | // enqueue datepicker stuff only if needed! |
| 757 | 757 | $this->enqueue_datepicker(); |
| 758 | 758 | } |
| 759 | 759 | |
| 760 | - $gravityview_view->render( 'widget', 'search', false ); |
|
| 760 | + $gravityview_view->render('widget', 'search', false); |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | /** |
@@ -767,12 +767,12 @@ discard block |
||
| 767 | 767 | * |
| 768 | 768 | * @return string Sanitized CSS class for the search form |
| 769 | 769 | */ |
| 770 | - public static function get_search_class( $custom_class = '' ) { |
|
| 770 | + public static function get_search_class($custom_class = '') { |
|
| 771 | 771 | $gravityview_view = GravityView_View::getInstance(); |
| 772 | 772 | |
| 773 | 773 | $search_class = 'gv-search-'.$gravityview_view->search_layout; |
| 774 | 774 | |
| 775 | - if ( ! empty( $custom_class ) ) { |
|
| 775 | + if (!empty($custom_class)) { |
|
| 776 | 776 | $search_class .= ' '.$custom_class; |
| 777 | 777 | } |
| 778 | 778 | |
@@ -781,12 +781,12 @@ discard block |
||
| 781 | 781 | * |
| 782 | 782 | * @param string $search_class The CSS class for the search form |
| 783 | 783 | */ |
| 784 | - $search_class = apply_filters( 'gravityview_search_class', $search_class ); |
|
| 784 | + $search_class = apply_filters('gravityview_search_class', $search_class); |
|
| 785 | 785 | |
| 786 | 786 | // Is there an active search being performed? Used by fe-views.js |
| 787 | 787 | $search_class .= GravityView_frontend::getInstance()->isSearch() ? ' gv-is-search' : ''; |
| 788 | 788 | |
| 789 | - return gravityview_sanitize_html_class( $search_class ); |
|
| 789 | + return gravityview_sanitize_html_class($search_class); |
|
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | |
@@ -801,9 +801,9 @@ discard block |
||
| 801 | 801 | |
| 802 | 802 | $post_id = $gravityview_view->getPostId() ? $gravityview_view->getPostId() : $gravityview_view->getViewId(); |
| 803 | 803 | |
| 804 | - $url = add_query_arg( array(), get_permalink( $post_id ) ); |
|
| 804 | + $url = add_query_arg(array(), get_permalink($post_id)); |
|
| 805 | 805 | |
| 806 | - return esc_url( $url ); |
|
| 806 | + return esc_url($url); |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | /** |
@@ -812,42 +812,42 @@ discard block |
||
| 812 | 812 | * @param array $form_field Form field data, as fetched by `gravityview_get_field()` |
| 813 | 813 | * @return string Label for the search form |
| 814 | 814 | */ |
| 815 | - private static function get_field_label( $field, $form_field = array() ) { |
|
| 815 | + private static function get_field_label($field, $form_field = array()) { |
|
| 816 | 816 | |
| 817 | - $label = rgget( 'label', $field ); |
|
| 817 | + $label = rgget('label', $field); |
|
| 818 | 818 | |
| 819 | - if( '' === $label ) { |
|
| 819 | + if ('' === $label) { |
|
| 820 | 820 | |
| 821 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
| 821 | + $label = isset($form_field['label']) ? $form_field['label'] : ''; |
|
| 822 | 822 | |
| 823 | - switch( $field['field'] ) { |
|
| 823 | + switch ($field['field']) { |
|
| 824 | 824 | case 'search_all': |
| 825 | - $label = __( 'Search Entries:', 'gravityview' ); |
|
| 825 | + $label = __('Search Entries:', 'gravityview'); |
|
| 826 | 826 | break; |
| 827 | 827 | case 'entry_date': |
| 828 | - $label = __( 'Filter by date:', 'gravityview' ); |
|
| 828 | + $label = __('Filter by date:', 'gravityview'); |
|
| 829 | 829 | break; |
| 830 | 830 | case 'entry_id': |
| 831 | - $label = __( 'Entry ID:', 'gravityview' ); |
|
| 831 | + $label = __('Entry ID:', 'gravityview'); |
|
| 832 | 832 | break; |
| 833 | 833 | case 'created_by': |
| 834 | - $label = __( 'Submitted by:', 'gravityview' ); |
|
| 834 | + $label = __('Submitted by:', 'gravityview'); |
|
| 835 | 835 | break; |
| 836 | 836 | case 'is_fulfilled': |
| 837 | - $label = __( 'Is Fulfilled', 'gravityview' ); |
|
| 837 | + $label = __('Is Fulfilled', 'gravityview'); |
|
| 838 | 838 | break; |
| 839 | 839 | default: |
| 840 | 840 | // If this is a field input, not a field |
| 841 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
| 841 | + if (strpos($field['field'], '.') > 0 && !empty($form_field['inputs'])) { |
|
| 842 | 842 | |
| 843 | 843 | // Get the label for the field in question, which returns an array |
| 844 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
| 844 | + $items = wp_list_filter($form_field['inputs'], array('id' => $field['field'])); |
|
| 845 | 845 | |
| 846 | 846 | // Get the item with the `label` key |
| 847 | - $values = wp_list_pluck( $items, 'label' ); |
|
| 847 | + $values = wp_list_pluck($items, 'label'); |
|
| 848 | 848 | |
| 849 | 849 | // There will only one item in the array, but this is easier |
| 850 | - foreach ( $values as $value ) { |
|
| 850 | + foreach ($values as $value) { |
|
| 851 | 851 | $label = $value; |
| 852 | 852 | break; |
| 853 | 853 | } |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | * @param[in,out] string $label Existing label text, sanitized. |
| 861 | 861 | * @param[in] array $form_field Gravity Forms field array, as returned by `GFFormsModel::get_field()` |
| 862 | 862 | */ |
| 863 | - $label = apply_filters( 'gravityview_search_field_label', esc_attr( $label ), $form_field ); |
|
| 863 | + $label = apply_filters('gravityview_search_field_label', esc_attr($label), $form_field); |
|
| 864 | 864 | |
| 865 | 865 | return $label; |
| 866 | 866 | } |
@@ -871,39 +871,39 @@ discard block |
||
| 871 | 871 | * @param array $field |
| 872 | 872 | * @return array |
| 873 | 873 | */ |
| 874 | - private function get_search_filter_details( $field ) { |
|
| 874 | + private function get_search_filter_details($field) { |
|
| 875 | 875 | |
| 876 | 876 | $gravityview_view = GravityView_View::getInstance(); |
| 877 | 877 | |
| 878 | 878 | $form = $gravityview_view->getForm(); |
| 879 | 879 | |
| 880 | 880 | // for advanced field ids (eg, first name / last name ) |
| 881 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
| 881 | + $name = 'filter_'.str_replace('.', '_', $field['field']); |
|
| 882 | 882 | |
| 883 | 883 | // get searched value from $_GET (string or array) |
| 884 | - $value = rgget( $name ); |
|
| 884 | + $value = rgget($name); |
|
| 885 | 885 | |
| 886 | 886 | // get form field details |
| 887 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
| 887 | + $form_field = gravityview_get_field($form, $field['field']); |
|
| 888 | 888 | |
| 889 | 889 | $filter = array( |
| 890 | 890 | 'key' => $field['field'], |
| 891 | 891 | 'name' => $name, |
| 892 | - 'label' => self::get_field_label( $field, $form_field ), |
|
| 892 | + 'label' => self::get_field_label($field, $form_field), |
|
| 893 | 893 | 'input' => $field['input'], |
| 894 | 894 | 'value' => $value, |
| 895 | 895 | 'type' => $form_field['type'], |
| 896 | 896 | ); |
| 897 | 897 | |
| 898 | 898 | // collect choices |
| 899 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
| 899 | + if ('post_category' === $form_field['type'] && !empty($form_field['displayAllCategories']) && empty($form_field['choices'])) { |
|
| 900 | 900 | $filter['choices'] = gravityview_get_terms_choices(); |
| 901 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
| 901 | + } elseif (!empty($form_field['choices'])) { |
|
| 902 | 902 | $filter['choices'] = $form_field['choices']; |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
| 906 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
| 905 | + if ('date_range' === $field['input'] && empty($value)) { |
|
| 906 | + $filter['value'] = array('start' => '', 'end' => ''); |
|
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | return $filter; |
@@ -923,10 +923,10 @@ discard block |
||
| 923 | 923 | * filter gravityview/get_users/search_widget |
| 924 | 924 | * @see \GVCommon::get_users |
| 925 | 925 | */ |
| 926 | - $users = GVCommon::get_users( 'search_widget', array( 'fields' => array( 'ID', 'display_name' ) ) ); |
|
| 926 | + $users = GVCommon::get_users('search_widget', array('fields' => array('ID', 'display_name'))); |
|
| 927 | 927 | |
| 928 | 928 | $choices = array(); |
| 929 | - foreach ( $users as $user ) { |
|
| 929 | + foreach ($users as $user) { |
|
| 930 | 930 | $choices[] = array( |
| 931 | 931 | 'value' => $user->ID, |
| 932 | 932 | 'text' => $user->display_name, |
@@ -944,11 +944,11 @@ discard block |
||
| 944 | 944 | public static function the_clear_search_button() { |
| 945 | 945 | $gravityview_view = GravityView_View::getInstance(); |
| 946 | 946 | |
| 947 | - if ( $gravityview_view->search_clear ) { |
|
| 947 | + if ($gravityview_view->search_clear) { |
|
| 948 | 948 | |
| 949 | - $url = strtok( add_query_arg( array() ), '?' ); |
|
| 949 | + $url = strtok(add_query_arg(array()), '?'); |
|
| 950 | 950 | |
| 951 | - echo gravityview_get_link( $url, esc_html__( 'Clear', 'gravityview' ), 'class=button gv-search-clear' ); |
|
| 951 | + echo gravityview_get_link($url, esc_html__('Clear', 'gravityview'), 'class=button gv-search-clear'); |
|
| 952 | 952 | |
| 953 | 953 | } |
| 954 | 954 | } |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | * Require the datepicker script for the frontend GV script |
| 960 | 960 | * @param array $js_dependencies Array of existing required scripts for the fe-views.js script |
| 961 | 961 | */ |
| 962 | - public function add_datepicker_js_dependency( $js_dependencies ) { |
|
| 962 | + public function add_datepicker_js_dependency($js_dependencies) { |
|
| 963 | 963 | |
| 964 | 964 | $js_dependencies[] = 'jquery-ui-datepicker'; |
| 965 | 965 | |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | * |
| 975 | 975 | * @return array |
| 976 | 976 | */ |
| 977 | - public function add_datepicker_localization( $localizations = array(), $view_data = array() ) { |
|
| 977 | + public function add_datepicker_localization($localizations = array(), $view_data = array()) { |
|
| 978 | 978 | global $wp_locale; |
| 979 | 979 | |
| 980 | 980 | /** |
@@ -984,26 +984,26 @@ discard block |
||
| 984 | 984 | * @param array $js_localization The data padded to the Javascript file |
| 985 | 985 | * @param array $view_data View data array with View settings |
| 986 | 986 | */ |
| 987 | - $datepicker_settings = apply_filters( 'gravityview_datepicker_settings', array( |
|
| 987 | + $datepicker_settings = apply_filters('gravityview_datepicker_settings', array( |
|
| 988 | 988 | 'yearRange' => '-5:+5', |
| 989 | 989 | 'changeMonth' => true, |
| 990 | 990 | 'changeYear' => true, |
| 991 | - 'closeText' => esc_attr_x( 'Close', 'Close calendar', 'gravityview' ), |
|
| 992 | - 'prevText' => esc_attr_x( 'Prev', 'Previous month in calendar', 'gravityview' ), |
|
| 993 | - 'nextText' => esc_attr_x( 'Next', 'Next month in calendar', 'gravityview' ), |
|
| 994 | - 'currentText' => esc_attr_x( 'Today', 'Today in calendar', 'gravityview' ), |
|
| 995 | - 'weekHeader' => esc_attr_x( 'Week', 'Week in calendar', 'gravityview' ), |
|
| 996 | - 'monthStatus' => __( 'Show a different month', 'gravityview' ), |
|
| 997 | - 'monthNames' => array_values( $wp_locale->month ), |
|
| 998 | - 'monthNamesShort' => array_values( $wp_locale->month_abbrev ), |
|
| 999 | - 'dayNames' => array_values( $wp_locale->weekday ), |
|
| 1000 | - 'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ), |
|
| 1001 | - 'dayNamesMin' => array_values( $wp_locale->weekday_initial ), |
|
| 991 | + 'closeText' => esc_attr_x('Close', 'Close calendar', 'gravityview'), |
|
| 992 | + 'prevText' => esc_attr_x('Prev', 'Previous month in calendar', 'gravityview'), |
|
| 993 | + 'nextText' => esc_attr_x('Next', 'Next month in calendar', 'gravityview'), |
|
| 994 | + 'currentText' => esc_attr_x('Today', 'Today in calendar', 'gravityview'), |
|
| 995 | + 'weekHeader' => esc_attr_x('Week', 'Week in calendar', 'gravityview'), |
|
| 996 | + 'monthStatus' => __('Show a different month', 'gravityview'), |
|
| 997 | + 'monthNames' => array_values($wp_locale->month), |
|
| 998 | + 'monthNamesShort' => array_values($wp_locale->month_abbrev), |
|
| 999 | + 'dayNames' => array_values($wp_locale->weekday), |
|
| 1000 | + 'dayNamesShort' => array_values($wp_locale->weekday_abbrev), |
|
| 1001 | + 'dayNamesMin' => array_values($wp_locale->weekday_initial), |
|
| 1002 | 1002 | // get the start of week from WP general setting |
| 1003 | - 'firstDay' => get_option( 'start_of_week' ), |
|
| 1003 | + 'firstDay' => get_option('start_of_week'), |
|
| 1004 | 1004 | // is Right to left language? default is false |
| 1005 | 1005 | 'isRTL' => is_rtl(), |
| 1006 | - ), $view_data ); |
|
| 1006 | + ), $view_data); |
|
| 1007 | 1007 | |
| 1008 | 1008 | $localizations['datepicker'] = $datepicker_settings; |
| 1009 | 1009 | |
@@ -1022,13 +1022,13 @@ discard block |
||
| 1022 | 1022 | public function enqueue_datepicker() { |
| 1023 | 1023 | $gravityview_view = GravityView_View::getInstance(); |
| 1024 | 1024 | |
| 1025 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 1025 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 1026 | 1026 | |
| 1027 | - add_filter( 'gravityview_js_dependencies', array( $this, 'add_datepicker_js_dependency' ) ); |
|
| 1028 | - add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
|
| 1027 | + add_filter('gravityview_js_dependencies', array($this, 'add_datepicker_js_dependency')); |
|
| 1028 | + add_filter('gravityview_js_localization', array($this, 'add_datepicker_localization'), 10, 2); |
|
| 1029 | 1029 | |
| 1030 | 1030 | $scheme = is_ssl() ? 'https://' : 'http://'; |
| 1031 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1031 | + wp_enqueue_style('jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css'); |
|
| 1032 | 1032 | |
| 1033 | 1033 | /** |
| 1034 | 1034 | * @filter `gravityview_search_datepicker_class` |
@@ -1043,7 +1043,7 @@ discard block |
||
| 1043 | 1043 | * - `ymd_dash` (yyyy-mm-dd) |
| 1044 | 1044 | * - `ymp_dot` (yyyy.mm.dd) |
| 1045 | 1045 | */ |
| 1046 | - $datepicker_class = apply_filters( 'gravityview_search_datepicker_class', 'gv-datepicker datepicker mdy' ); |
|
| 1046 | + $datepicker_class = apply_filters('gravityview_search_datepicker_class', 'gv-datepicker datepicker mdy'); |
|
| 1047 | 1047 | |
| 1048 | 1048 | $gravityview_view->datepicker_class = $datepicker_class; |
| 1049 | 1049 | |
@@ -176,6 +176,7 @@ |
||
| 176 | 176 | * Get the entries that will be shown in the current widget |
| 177 | 177 | * |
| 178 | 178 | * @param array $instance Settings for the current widget |
| 179 | + * @param string $form_id |
|
| 179 | 180 | * |
| 180 | 181 | * @return array $entries Multidimensional array of Gravity Forms entries |
| 181 | 182 | */ |
@@ -15,19 +15,19 @@ discard block |
||
| 15 | 15 | $name = __('GravityView Recent Entries', 'gravityview'); |
| 16 | 16 | |
| 17 | 17 | $widget_options = array( |
| 18 | - 'description' => __( 'Display the most recent entries for a View', 'gravityview' ), |
|
| 18 | + 'description' => __('Display the most recent entries for a View', 'gravityview'), |
|
| 19 | 19 | ); |
| 20 | 20 | |
| 21 | - parent::__construct( 'gv_recent_entries', $name, $widget_options ); |
|
| 21 | + parent::__construct('gv_recent_entries', $name, $widget_options); |
|
| 22 | 22 | |
| 23 | 23 | $this->initialize(); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | private function initialize() { |
| 27 | 27 | |
| 28 | - add_action('admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts') ); |
|
| 28 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
| 29 | 29 | |
| 30 | - add_action( 'wp_ajax_gv_get_view_merge_tag_data', array( $this, 'ajax_get_view_merge_tag_data' ) ); |
|
| 30 | + add_action('wp_ajax_gv_get_view_merge_tag_data', array($this, 'ajax_get_view_merge_tag_data')); |
|
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | function ajax_get_view_merge_tag_data() { |
| 40 | 40 | |
| 41 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajax_widget' ) ) { |
|
| 42 | - exit( false ); |
|
| 41 | + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajax_widget')) { |
|
| 42 | + exit(false); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - $form_id = gravityview_get_form_id( $_POST['view_id'] ); |
|
| 45 | + $form_id = gravityview_get_form_id($_POST['view_id']); |
|
| 46 | 46 | |
| 47 | - $form = RGFormsModel::get_form_meta( $form_id ); |
|
| 47 | + $form = RGFormsModel::get_form_meta($form_id); |
|
| 48 | 48 | |
| 49 | 49 | $output = array( |
| 50 | 50 | 'form' => array( |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | 'title' => $form['title'], |
| 53 | 53 | 'fields' => $form['fields'], |
| 54 | 54 | ), |
| 55 | - 'mergeTags' => GFCommon::get_merge_tags( $form['fields'], '', false ), |
|
| 55 | + 'mergeTags' => GFCommon::get_merge_tags($form['fields'], '', false), |
|
| 56 | 56 | ); |
| 57 | 57 | |
| 58 | - echo json_encode( $output ); |
|
| 58 | + echo json_encode($output); |
|
| 59 | 59 | |
| 60 | 60 | exit; |
| 61 | 61 | } |
@@ -68,19 +68,19 @@ discard block |
||
| 68 | 68 | function admin_enqueue_scripts() { |
| 69 | 69 | global $pagenow; |
| 70 | 70 | |
| 71 | - if( $pagenow === 'widgets.php' ) { |
|
| 71 | + if ($pagenow === 'widgets.php') { |
|
| 72 | 72 | |
| 73 | 73 | $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
| 74 | 74 | |
| 75 | 75 | GravityView_Admin_Views::enqueue_gravity_forms_scripts(); |
| 76 | 76 | |
| 77 | - wp_enqueue_script( 'gravityview_widgets', plugins_url('assets/js/admin-widgets'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery', 'gform_gravityforms' ), GravityView_Plugin::version ); |
|
| 77 | + wp_enqueue_script('gravityview_widgets', plugins_url('assets/js/admin-widgets'.$script_debug.'.js', GRAVITYVIEW_FILE), array('jquery', 'gform_gravityforms'), GravityView_Plugin::version); |
|
| 78 | 78 | |
| 79 | - wp_localize_script( 'gravityview_widgets', 'GVWidgets', array( |
|
| 80 | - 'nonce' => wp_create_nonce( 'gravityview_ajax_widget' ) |
|
| 79 | + wp_localize_script('gravityview_widgets', 'GVWidgets', array( |
|
| 80 | + 'nonce' => wp_create_nonce('gravityview_ajax_widget') |
|
| 81 | 81 | )); |
| 82 | 82 | |
| 83 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url('assets/css/admin-views.css', GRAVITYVIEW_FILE), array('dashicons' ), GravityView_Plugin::version ); |
|
| 83 | + wp_enqueue_style('gravityview_views_styles', plugins_url('assets/css/admin-views.css', GRAVITYVIEW_FILE), array('dashicons'), GravityView_Plugin::version); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | } |
@@ -92,22 +92,22 @@ discard block |
||
| 92 | 92 | * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. |
| 93 | 93 | * @param array $instance The settings for the particular instance of the widget. |
| 94 | 94 | */ |
| 95 | - function widget( $args, $instance ) { |
|
| 95 | + function widget($args, $instance) { |
|
| 96 | 96 | |
| 97 | 97 | // Don't have the Customizer render too soon. |
| 98 | - if( empty( $instance['view_id'] ) ) { |
|
| 98 | + if (empty($instance['view_id'])) { |
|
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $args['id'] = ( isset( $args['id'] ) ) ? $args['id'] : 'gv_recent_entries'; |
|
| 103 | - $instance['title'] = ( isset( $instance['title'] ) ) ? $instance['title'] : ''; |
|
| 102 | + $args['id'] = (isset($args['id'])) ? $args['id'] : 'gv_recent_entries'; |
|
| 103 | + $instance['title'] = (isset($instance['title'])) ? $instance['title'] : ''; |
|
| 104 | 104 | |
| 105 | - $title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $args['id'] ); |
|
| 105 | + $title = apply_filters('widget_title', $instance['title'], $instance, $args['id']); |
|
| 106 | 106 | |
| 107 | 107 | echo $args['before_widget']; |
| 108 | 108 | |
| 109 | - if ( !empty( $title ) ) { |
|
| 110 | - echo $args['before_title'] . $title . $args['after_title']; |
|
| 109 | + if (!empty($title)) { |
|
| 110 | + echo $args['before_title'].$title.$args['after_title']; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -115,17 +115,17 @@ discard block |
||
| 115 | 115 | * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. |
| 116 | 116 | * @param array $instance The settings for the particular instance of the widget. |
| 117 | 117 | */ |
| 118 | - do_action( 'gravityview/widget/recent-entries/before_widget', $args, $instance ); |
|
| 118 | + do_action('gravityview/widget/recent-entries/before_widget', $args, $instance); |
|
| 119 | 119 | |
| 120 | 120 | // Print the entry list |
| 121 | - echo $this->get_output( $instance ); |
|
| 121 | + echo $this->get_output($instance); |
|
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * @action `gravityview/widget/recent-entries/after_widget` After recent entries are displayed in the WordPress widget |
| 125 | 125 | * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. |
| 126 | 126 | * @param array $instance The settings for the particular instance of the widget. |
| 127 | 127 | */ |
| 128 | - do_action( 'gravityview/widget/recent-entries/after_widget', $args, $instance ); |
|
| 128 | + do_action('gravityview/widget/recent-entries/after_widget', $args, $instance); |
|
| 129 | 129 | |
| 130 | 130 | echo $args['after_widget']; |
| 131 | 131 | } |
@@ -139,25 +139,25 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @return string |
| 141 | 141 | */ |
| 142 | - private function get_output( $instance ) { |
|
| 142 | + private function get_output($instance) { |
|
| 143 | 143 | |
| 144 | - $form_id = gravityview_get_form_id( $instance['view_id'] ); |
|
| 144 | + $form_id = gravityview_get_form_id($instance['view_id']); |
|
| 145 | 145 | |
| 146 | - $form = gravityview_get_form( $form_id ); |
|
| 146 | + $form = gravityview_get_form($form_id); |
|
| 147 | 147 | |
| 148 | - $entries = $this->get_entries( $instance, $form_id ); |
|
| 148 | + $entries = $this->get_entries($instance, $form_id); |
|
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | 151 | * @since 1.6.1 |
| 152 | 152 | * @var int $entry_link_post_id The ID to use as the parent post for the entry |
| 153 | 153 | */ |
| 154 | - $entry_link_post_id = ( empty( $instance['error_post_id'] ) && !empty( $instance['post_id'] ) ) ? $instance['post_id'] : $instance['view_id']; |
|
| 154 | + $entry_link_post_id = (empty($instance['error_post_id']) && !empty($instance['post_id'])) ? $instance['post_id'] : $instance['view_id']; |
|
| 155 | 155 | |
| 156 | 156 | /** |
| 157 | 157 | * Generate list output |
| 158 | 158 | * @since 1.7.2 |
| 159 | 159 | */ |
| 160 | - $List = new GravityView_Entry_List( $entries, $entry_link_post_id, $form, $instance['link_format'], $instance['after_link'], 'recent-entries-widget' ); |
|
| 160 | + $List = new GravityView_Entry_List($entries, $entry_link_post_id, $form, $instance['link_format'], $instance['after_link'], 'recent-entries-widget'); |
|
| 161 | 161 | |
| 162 | 162 | $output = $List->get_output(); |
| 163 | 163 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @param string $output HTML to be displayed |
| 167 | 167 | * @param array $instance Widget settings |
| 168 | 168 | */ |
| 169 | - $output = apply_filters( 'gravityview/widget/recent-entries/output', $output, $instance ); |
|
| 169 | + $output = apply_filters('gravityview/widget/recent-entries/output', $output, $instance); |
|
| 170 | 170 | |
| 171 | 171 | return $output; |
| 172 | 172 | } |
@@ -179,15 +179,15 @@ discard block |
||
| 179 | 179 | * |
| 180 | 180 | * @return array $entries Multidimensional array of Gravity Forms entries |
| 181 | 181 | */ |
| 182 | - private function get_entries( $instance, $form_id ) { |
|
| 182 | + private function get_entries($instance, $form_id) { |
|
| 183 | 183 | |
| 184 | 184 | // Get the settings for the View ID |
| 185 | - $view_settings = gravityview_get_template_settings( $instance['view_id'] ); |
|
| 185 | + $view_settings = gravityview_get_template_settings($instance['view_id']); |
|
| 186 | 186 | |
| 187 | 187 | // Set the context view ID to avoid conflicts with the Advanced Filter extension. |
| 188 | 188 | $criteria['context_view_id'] = $instance['view_id']; |
| 189 | 189 | |
| 190 | - $instance['limit'] = isset( $instance['limit'] ) ? $instance['limit'] : 10; |
|
| 190 | + $instance['limit'] = isset($instance['limit']) ? $instance['limit'] : 10; |
|
| 191 | 191 | $view_settings['id'] = $instance['view_id']; |
| 192 | 192 | $view_settings['page_size'] = $instance['limit']; |
| 193 | 193 | |
@@ -198,16 +198,16 @@ discard block |
||
| 198 | 198 | ); |
| 199 | 199 | |
| 200 | 200 | // Prepare Search Criteria |
| 201 | - $criteria['search_criteria'] = array( 'field_filters' => array() ); |
|
| 202 | - $criteria['search_criteria'] = GravityView_frontend::process_search_only_approved( $view_settings, $criteria['search_criteria']); |
|
| 203 | - $criteria['search_criteria']['status'] = apply_filters( 'gravityview_status', 'active', $view_settings ); |
|
| 201 | + $criteria['search_criteria'] = array('field_filters' => array()); |
|
| 202 | + $criteria['search_criteria'] = GravityView_frontend::process_search_only_approved($view_settings, $criteria['search_criteria']); |
|
| 203 | + $criteria['search_criteria']['status'] = apply_filters('gravityview_status', 'active', $view_settings); |
|
| 204 | 204 | |
| 205 | 205 | /** |
| 206 | 206 | * Modify the search parameters before the entries are fetched |
| 207 | 207 | */ |
| 208 | - $criteria = apply_filters('gravityview/widget/recent-entries/criteria', $criteria, $instance, $form_id ); |
|
| 208 | + $criteria = apply_filters('gravityview/widget/recent-entries/criteria', $criteria, $instance, $form_id); |
|
| 209 | 209 | |
| 210 | - $results = GVCommon::get_entries( $form_id, $criteria ); |
|
| 210 | + $results = GVCommon::get_entries($form_id, $criteria); |
|
| 211 | 211 | |
| 212 | 212 | return $results; |
| 213 | 213 | } |
@@ -221,28 +221,28 @@ discard block |
||
| 221 | 221 | * |
| 222 | 222 | * @return array Calculated widget settings after processing |
| 223 | 223 | */ |
| 224 | - public function update( $new_instance, $old_instance ) { |
|
| 224 | + public function update($new_instance, $old_instance) { |
|
| 225 | 225 | |
| 226 | 226 | $instance = $new_instance; |
| 227 | 227 | |
| 228 | 228 | // Force positive number |
| 229 | - $instance['limit'] = empty( $instance['limit'] ) ? 10 : absint( $instance['limit'] ); |
|
| 229 | + $instance['limit'] = empty($instance['limit']) ? 10 : absint($instance['limit']); |
|
| 230 | 230 | |
| 231 | - $instance['view_id'] = intval( $instance['view_id'] ); |
|
| 231 | + $instance['view_id'] = intval($instance['view_id']); |
|
| 232 | 232 | |
| 233 | - $instance['link_format'] = trim( rtrim( $instance['link_format'] ) ); |
|
| 233 | + $instance['link_format'] = trim(rtrim($instance['link_format'])); |
|
| 234 | 234 | |
| 235 | - $instance['link_format'] = empty( $instance['link_format'] ) ? $old_instance['link_format'] : $instance['link_format']; |
|
| 235 | + $instance['link_format'] = empty($instance['link_format']) ? $old_instance['link_format'] : $instance['link_format']; |
|
| 236 | 236 | |
| 237 | - $instance['post_id'] = empty( $instance['post_id'] ) ? '' : intval( $instance['post_id'] ); |
|
| 237 | + $instance['post_id'] = empty($instance['post_id']) ? '' : intval($instance['post_id']); |
|
| 238 | 238 | |
| 239 | - $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance['post_id'], $instance['view_id'] ); |
|
| 239 | + $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id($instance['post_id'], $instance['view_id']); |
|
| 240 | 240 | |
| 241 | 241 | //check if post_id is a valid post with embedded View |
| 242 | - $instance['error_post_id'] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
| 242 | + $instance['error_post_id'] = is_wp_error($is_valid_embed_id) ? $is_valid_embed_id->get_error_message() : NULL; |
|
| 243 | 243 | |
| 244 | 244 | // Share that the widget isn't brand new |
| 245 | - $instance['updated'] = 1; |
|
| 245 | + $instance['updated'] = 1; |
|
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | 248 | * Modify the updated instance. This will allow for validating any added instance settings externally. |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * @param array $new_instance Widget form settings after update |
| 252 | 252 | * @param array $old_instance Widget form settings before update |
| 253 | 253 | */ |
| 254 | - $instance = apply_filters( 'gravityview/widget/update', $instance, $new_instance, $old_instance ); |
|
| 254 | + $instance = apply_filters('gravityview/widget/update', $instance, $new_instance, $old_instance); |
|
| 255 | 255 | |
| 256 | 256 | return $instance; |
| 257 | 257 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | * @since 1.6 |
| 261 | 261 | * @see WP_Widget::form() |
| 262 | 262 | */ |
| 263 | - public function form( $instance ) { |
|
| 263 | + public function form($instance) { |
|
| 264 | 264 | |
| 265 | 265 | // Set up some default widget settings. |
| 266 | 266 | $defaults = array( |
@@ -272,14 +272,14 @@ discard block |
||
| 272 | 272 | 'after_link' => '' |
| 273 | 273 | ); |
| 274 | 274 | |
| 275 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
| 275 | + $instance = wp_parse_args((array)$instance, $defaults); |
|
| 276 | 276 | |
| 277 | 277 | ?> |
| 278 | 278 | |
| 279 | 279 | <!-- Title --> |
| 280 | 280 | <p> |
| 281 | - <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:', 'gravityview' ) ?></label> |
|
| 282 | - <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /> |
|
| 281 | + <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Title:', 'gravityview') ?></label> |
|
| 282 | + <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>" /> |
|
| 283 | 283 | </p> |
| 284 | 284 | |
| 285 | 285 | <!-- Download --> |
@@ -289,11 +289,11 @@ discard block |
||
| 289 | 289 | 'posts_per_page' => -1, |
| 290 | 290 | 'post_status' => 'publish', |
| 291 | 291 | ); |
| 292 | - $views = get_posts( $args ); |
|
| 292 | + $views = get_posts($args); |
|
| 293 | 293 | |
| 294 | 294 | // If there are no views set up yet, we get outta here. |
| 295 | - if( empty( $views ) ) { |
|
| 296 | - echo '<div id="select_gravityview_view"><div class="wrap">'. GravityView_Post_Types::no_views_text() .'</div></div>'; |
|
| 295 | + if (empty($views)) { |
|
| 296 | + echo '<div id="select_gravityview_view"><div class="wrap">'.GravityView_Post_Types::no_views_text().'</div></div>'; |
|
| 297 | 297 | return; |
| 298 | 298 | } |
| 299 | 299 | |
@@ -304,25 +304,25 @@ discard block |
||
| 304 | 304 | * Display errors generated for invalid embed IDs |
| 305 | 305 | * @see GravityView_View_Data::is_valid_embed_id |
| 306 | 306 | */ |
| 307 | - if( isset( $instance['updated'] ) && empty( $instance['view_id'] ) ) { |
|
| 307 | + if (isset($instance['updated']) && empty($instance['view_id'])) { |
|
| 308 | 308 | ?> |
| 309 | 309 | <div class="error inline hide-on-view-change"> |
| 310 | 310 | <p><?php esc_html_e('Please select a View to search.', 'gravityview'); ?></p> |
| 311 | 311 | </div> |
| 312 | 312 | <?php |
| 313 | - unset ( $error ); |
|
| 313 | + unset ($error); |
|
| 314 | 314 | } |
| 315 | 315 | ?> |
| 316 | 316 | |
| 317 | 317 | <p> |
| 318 | - <label for="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"><?php esc_html_e('Select a View', 'gravityview'); ?></label> |
|
| 319 | - <select class="widefat gv-recent-entries-select-view" name="<?php echo esc_attr( $this->get_field_name( 'view_id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"> |
|
| 320 | - <option value=""><?php esc_html_e( '— Select a View as Entries Source —', 'gravityview' ); ?></option> |
|
| 318 | + <label for="<?php echo esc_attr($this->get_field_id('view_id')); ?>"><?php esc_html_e('Select a View', 'gravityview'); ?></label> |
|
| 319 | + <select class="widefat gv-recent-entries-select-view" name="<?php echo esc_attr($this->get_field_name('view_id')); ?>" id="<?php echo esc_attr($this->get_field_id('view_id')); ?>"> |
|
| 320 | + <option value=""><?php esc_html_e('— Select a View as Entries Source —', 'gravityview'); ?></option> |
|
| 321 | 321 | <?php |
| 322 | 322 | |
| 323 | - foreach( $views as $view ) { |
|
| 324 | - $title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title; |
|
| 325 | - echo '<option value="'. $view->ID .'"'.selected( absint( $instance['view_id'] ), $view->ID ).'>'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>'; |
|
| 323 | + foreach ($views as $view) { |
|
| 324 | + $title = empty($view->post_title) ? __('(no title)', 'gravityview') : $view->post_title; |
|
| 325 | + echo '<option value="'.$view->ID.'"'.selected(absint($instance['view_id']), $view->ID).'>'.esc_html(sprintf('%s #%d', $title, $view->ID)).'</option>'; |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | ?> |
@@ -334,44 +334,44 @@ discard block |
||
| 334 | 334 | * Display errors generated for invalid embed IDs |
| 335 | 335 | * @see GravityView_View_Data::is_valid_embed_id |
| 336 | 336 | */ |
| 337 | - if( !empty( $instance['error_post_id'] ) ) { |
|
| 337 | + if (!empty($instance['error_post_id'])) { |
|
| 338 | 338 | ?> |
| 339 | 339 | <div class="error inline"> |
| 340 | 340 | <p><?php echo $instance['error_post_id']; ?></p> |
| 341 | 341 | </div> |
| 342 | 342 | <?php |
| 343 | - unset ( $error ); |
|
| 343 | + unset ($error); |
|
| 344 | 344 | } |
| 345 | 345 | ?> |
| 346 | 346 | |
| 347 | 347 | <p> |
| 348 | - <label for="<?php echo $this->get_field_id('post_id'); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
| 349 | - <input class="code" size="3" id="<?php echo $this->get_field_id('post_id'); ?>" name="<?php echo $this->get_field_name('post_id'); ?>" type="text" value="<?php echo esc_attr( $instance['post_id'] ); ?>" /> |
|
| 348 | + <label for="<?php echo $this->get_field_id('post_id'); ?>"><?php esc_html_e('If Embedded, Page ID:', 'gravityview'); ?></label> |
|
| 349 | + <input class="code" size="3" id="<?php echo $this->get_field_id('post_id'); ?>" name="<?php echo $this->get_field_name('post_id'); ?>" type="text" value="<?php echo esc_attr($instance['post_id']); ?>" /> |
|
| 350 | 350 | <span class="howto"><?php |
| 351 | - esc_html_e('To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' ); |
|
| 352 | - echo ' '.gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview' ), 'target=_blank' ); |
|
| 351 | + esc_html_e('To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview'); |
|
| 352 | + echo ' '.gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview'), 'target=_blank'); |
|
| 353 | 353 | ?></span> |
| 354 | 354 | </p> |
| 355 | 355 | |
| 356 | 356 | <p> |
| 357 | - <label for="<?php echo $this->get_field_id( 'limit' ); ?>"> |
|
| 358 | - <span><?php _e( 'Number of entries to show:', 'gravityview' ); ?></span> |
|
| 357 | + <label for="<?php echo $this->get_field_id('limit'); ?>"> |
|
| 358 | + <span><?php _e('Number of entries to show:', 'gravityview'); ?></span> |
|
| 359 | 359 | </label> |
| 360 | - <input class="code" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" value="<?php echo intval( $instance['limit'] ); ?>" size="3" /> |
|
| 360 | + <input class="code" id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="number" value="<?php echo intval($instance['limit']); ?>" size="3" /> |
|
| 361 | 361 | </p> |
| 362 | 362 | |
| 363 | 363 | <p> |
| 364 | - <label for="<?php echo $this->get_field_id( 'link_format' ); ?>"> |
|
| 365 | - <span><?php _e( 'Entry link text (required)', 'gravityview' ); ?></span> |
|
| 364 | + <label for="<?php echo $this->get_field_id('link_format'); ?>"> |
|
| 365 | + <span><?php _e('Entry link text (required)', 'gravityview'); ?></span> |
|
| 366 | 366 | </label> |
| 367 | - <input id="<?php echo $this->get_field_id( 'link_format' ); ?>" name="<?php echo $this->get_field_name( 'link_format' ); ?>" type="text" value="<?php echo esc_attr( $instance['link_format'] ); ?>" class="widefat merge-tag-support mt-position-right mt-hide_all_fields" /> |
|
| 367 | + <input id="<?php echo $this->get_field_id('link_format'); ?>" name="<?php echo $this->get_field_name('link_format'); ?>" type="text" value="<?php echo esc_attr($instance['link_format']); ?>" class="widefat merge-tag-support mt-position-right mt-hide_all_fields" /> |
|
| 368 | 368 | </p> |
| 369 | 369 | |
| 370 | 370 | <p> |
| 371 | - <label for="<?php echo $this->get_field_id( 'after_link' ); ?>"> |
|
| 372 | - <span><?php _e( 'Text or HTML to display after the link (optional)', 'gravityview' ); ?></span> |
|
| 371 | + <label for="<?php echo $this->get_field_id('after_link'); ?>"> |
|
| 372 | + <span><?php _e('Text or HTML to display after the link (optional)', 'gravityview'); ?></span> |
|
| 373 | 373 | </label> |
| 374 | - <textarea id="<?php echo $this->get_field_id( 'after_link' ); ?>" name="<?php echo $this->get_field_name( 'after_link' ); ?>" rows="5" class="widefat code merge-tag-support mt-position-right mt-hide_all_fields"><?php echo esc_textarea( $instance['after_link'] ); ?></textarea> |
|
| 374 | + <textarea id="<?php echo $this->get_field_id('after_link'); ?>" name="<?php echo $this->get_field_name('after_link'); ?>" rows="5" class="widefat code merge-tag-support mt-position-right mt-hide_all_fields"><?php echo esc_textarea($instance['after_link']); ?></textarea> |
|
| 375 | 375 | </p> |
| 376 | 376 | |
| 377 | 377 | <?php |
@@ -381,14 +381,14 @@ discard block |
||
| 381 | 381 | * @param GravityView_Recent_Entries_Widget $this WP_Widget object |
| 382 | 382 | * @param array $instance Current widget instance |
| 383 | 383 | */ |
| 384 | - do_action( 'gravityview_recent_entries_widget_form' , $this, $instance ); |
|
| 384 | + do_action('gravityview_recent_entries_widget_form', $this, $instance); |
|
| 385 | 385 | |
| 386 | 386 | ?> |
| 387 | 387 | |
| 388 | 388 | <script> |
| 389 | 389 | // When the widget is saved or added, refresh the Merge Tags (here for backward compatibility) |
| 390 | 390 | // WordPress 3.9 added widget-added and widget-updated actions |
| 391 | - jQuery('#<?php echo $this->get_field_id( 'view_id' ); ?>').trigger( 'change' ); |
|
| 391 | + jQuery('#<?php echo $this->get_field_id('view_id'); ?>').trigger( 'change' ); |
|
| 392 | 392 | </script> |
| 393 | 393 | <?php } |
| 394 | 394 | |
@@ -184,8 +184,8 @@ |
||
| 184 | 184 | // Get the settings for the View ID |
| 185 | 185 | $view_settings = gravityview_get_template_settings( $instance['view_id'] ); |
| 186 | 186 | |
| 187 | - // Set the context view ID to avoid conflicts with the Advanced Filter extension. |
|
| 188 | - $criteria['context_view_id'] = $instance['view_id']; |
|
| 187 | + // Set the context view ID to avoid conflicts with the Advanced Filter extension. |
|
| 188 | + $criteria['context_view_id'] = $instance['view_id']; |
|
| 189 | 189 | |
| 190 | 190 | $instance['limit'] = isset( $instance['limit'] ) ? $instance['limit'] : 10; |
| 191 | 191 | $view_settings['id'] = $instance['view_id']; |
@@ -8,10 +8,10 @@ discard block |
||
| 8 | 8 | function __construct() { |
| 9 | 9 | |
| 10 | 10 | // Add Edit link to the entry actions |
| 11 | - add_action( 'gform_entries_first_column_actions', array( $this, 'add_edit_link' ), 10, 5 ); |
|
| 11 | + add_action('gform_entries_first_column_actions', array($this, 'add_edit_link'), 10, 5); |
|
| 12 | 12 | |
| 13 | 13 | // Add script to enable edit link |
| 14 | - add_action( 'admin_head-forms_page_gf_entries', array( $this, 'add_edit_script') ); |
|
| 14 | + add_action('admin_head-forms_page_gf_entries', array($this, 'add_edit_script')); |
|
| 15 | 15 | |
| 16 | 16 | } |
| 17 | 17 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | public function add_edit_script() { |
| 27 | 27 | |
| 28 | 28 | // We're on a single entry page, or at least not the Entries page. |
| 29 | - if( !empty( $_GET['view'] ) && $_GET['view'] !== 'entries' ) { return; } |
|
| 29 | + if (!empty($_GET['view']) && $_GET['view'] !== 'entries') { return; } |
|
| 30 | 30 | ?> |
| 31 | 31 | <script> |
| 32 | 32 | jQuery( document ).ready( function( $ ) { |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @param array $lead The current entry data |
| 51 | 51 | * @param string $query_string URL query string for a link to the current entry. Missing the `?page=` part, which is strange. Example: `gf_entries&view=entry&id=35&lid=5212&filter=&paged=1` |
| 52 | 52 | */ |
| 53 | - function add_edit_link( $form_id = NULL, $field_id = NULL, $value = NULL, $lead = array(), $query_string = NULL ) { |
|
| 53 | + function add_edit_link($form_id = NULL, $field_id = NULL, $value = NULL, $lead = array(), $query_string = NULL) { |
|
| 54 | 54 | |
| 55 | 55 | $params = array( |
| 56 | 56 | 'page' => 'gf_entries', |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | <span class="edit edit_entry"> |
| 65 | 65 | | |
| 66 | - <a title="<?php esc_attr_e( 'Edit this entry', 'gravityview'); ?>" href="<?php echo esc_url( add_query_arg( $params, admin_url( 'admin.php?page='.$query_string ) ) ); ?>"><?php esc_html_e( 'Edit', 'gravityview' ); ?></a> |
|
| 66 | + <a title="<?php esc_attr_e('Edit this entry', 'gravityview'); ?>" href="<?php echo esc_url(add_query_arg($params, admin_url('admin.php?page='.$query_string))); ?>"><?php esc_html_e('Edit', 'gravityview'); ?></a> |
|
| 67 | 67 | </span> |
| 68 | 68 | <?php |
| 69 | 69 | } |
@@ -8,24 +8,24 @@ discard block |
||
| 8 | 8 | ?> |
| 9 | 9 | <label for="<?php echo $this->get_field_id(); ?>" class="<?php echo $this->get_label_class(); ?>"> |
| 10 | 10 | <?php $this->render_input(); ?> |
| 11 | - <?php echo $this->get_field_label() . $this->get_tooltip() . $this->get_field_desc(); ?> |
|
| 11 | + <?php echo $this->get_field_label().$this->get_tooltip().$this->get_field_desc(); ?> |
|
| 12 | 12 | </label> |
| 13 | 13 | <?php |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - function render_setting( $override_input = NULL ) { |
|
| 16 | + function render_setting($override_input = NULL) { |
|
| 17 | 17 | |
| 18 | - if( $this->get_field_left_label() ) { ?> |
|
| 18 | + if ($this->get_field_left_label()) { ?> |
|
| 19 | 19 | |
| 20 | 20 | <td scope="row"> |
| 21 | 21 | <label for="<?php echo $this->get_field_id(); ?>"> |
| 22 | - <?php echo $this->get_field_left_label() . $this->get_tooltip(); ?> |
|
| 22 | + <?php echo $this->get_field_left_label().$this->get_tooltip(); ?> |
|
| 23 | 23 | </label> |
| 24 | 24 | </td> |
| 25 | 25 | <td> |
| 26 | 26 | <label> |
| 27 | - <?php $this->render_input( $override_input ); ?> |
|
| 28 | - <?php echo $this->get_field_label() . $this->get_tooltip() . $this->get_field_desc(); ?> |
|
| 27 | + <?php $this->render_input($override_input); ?> |
|
| 28 | + <?php echo $this->get_field_label().$this->get_tooltip().$this->get_field_desc(); ?> |
|
| 29 | 29 | </label> |
| 30 | 30 | </td> |
| 31 | 31 | |
@@ -33,23 +33,23 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | <td scope="row" colspan="2"> |
| 35 | 35 | <label for="<?php echo $this->get_field_id(); ?>"> |
| 36 | - <?php $this->render_input( $override_input ); ?> |
|
| 37 | - <?php echo $this->get_field_label() . $this->get_tooltip() . $this->get_field_desc(); ?> |
|
| 36 | + <?php $this->render_input($override_input); ?> |
|
| 37 | + <?php echo $this->get_field_label().$this->get_tooltip().$this->get_field_desc(); ?> |
|
| 38 | 38 | </label> |
| 39 | 39 | </td> |
| 40 | 40 | |
| 41 | 41 | <?php } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - function render_input( $override_input = NULL ) { |
|
| 45 | - if( isset( $override_input ) ) { |
|
| 44 | + function render_input($override_input = NULL) { |
|
| 45 | + if (isset($override_input)) { |
|
| 46 | 46 | echo $override_input; |
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | ?> |
| 51 | - <input name="<?php echo esc_attr( $this->name ); ?>" type="hidden" value="0" /> |
|
| 52 | - <input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="checkbox" value="1" <?php checked( $this->value, '1', true ); ?> /> |
|
| 51 | + <input name="<?php echo esc_attr($this->name); ?>" type="hidden" value="0" /> |
|
| 52 | + <input name="<?php echo esc_attr($this->name); ?>" id="<?php echo $this->get_field_id(); ?>" type="checkbox" value="1" <?php checked($this->value, '1', true); ?> /> |
|
| 53 | 53 | <?php |
| 54 | 54 | } |
| 55 | 55 | |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | return; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - $class = !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat'; |
|
| 18 | + $class = !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat'; |
|
| 19 | 19 | |
| 20 | 20 | ?> |
| 21 | 21 | <input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="hidden" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>" /> |
@@ -8,17 +8,17 @@ |
||
| 8 | 8 | $this->render_input(); |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | - function render_input( $override_input = null ) { |
|
| 11 | + function render_input($override_input = null) { |
|
| 12 | 12 | |
| 13 | - if( isset( $override_input ) ) { |
|
| 13 | + if (isset($override_input)) { |
|
| 14 | 14 | echo $override_input; |
| 15 | 15 | return; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - $class = !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat'; |
|
| 18 | + $class = !empty($this->field['class']) ? $this->field['class'] : 'widefat'; |
|
| 19 | 19 | |
| 20 | 20 | ?> |
| 21 | - <input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="hidden" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>" /> |
|
| 21 | + <input name="<?php echo esc_attr($this->name); ?>" id="<?php echo $this->get_field_id(); ?>" type="hidden" value="<?php echo esc_attr($this->value); ?>" class="<?php echo esc_attr($class); ?>" /> |
|
| 22 | 22 | <?php |
| 23 | 23 | } |
| 24 | 24 | |
@@ -3,13 +3,13 @@ discard block |
||
| 3 | 3 | * number input type |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -if( !class_exists('GravityView_FieldType_text') ) { |
|
| 7 | - include_once( GRAVITYVIEW_DIR . 'includes/admin/field-types/type_text.php' ); |
|
| 6 | +if (!class_exists('GravityView_FieldType_text')) { |
|
| 7 | + include_once(GRAVITYVIEW_DIR.'includes/admin/field-types/type_text.php'); |
|
| 8 | 8 | } |
| 9 | 9 | class GravityView_FieldType_number extends GravityView_FieldType_text { |
| 10 | 10 | |
| 11 | - function render_input( $override_input = null ) { |
|
| 12 | - if( isset( $override_input ) ) { |
|
| 11 | + function render_input($override_input = null) { |
|
| 12 | + if (isset($override_input)) { |
|
| 13 | 13 | echo $override_input; |
| 14 | 14 | return; |
| 15 | 15 | } |
@@ -18,13 +18,13 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | $show_mt = $this->show_merge_tags(); |
| 20 | 20 | |
| 21 | - if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
| 21 | + if ($show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force') { |
|
| 22 | 22 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
| 23 | 23 | } |
| 24 | - $class .= !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat'; |
|
| 24 | + $class .= !empty($this->field['class']) ? $this->field['class'] : 'widefat'; |
|
| 25 | 25 | |
| 26 | 26 | ?> |
| 27 | - <input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="number" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>"> |
|
| 27 | + <input name="<?php echo esc_attr($this->name); ?>" id="<?php echo $this->get_field_id(); ?>" type="number" value="<?php echo esc_attr($this->value); ?>" class="<?php echo esc_attr($class); ?>"> |
|
| 28 | 28 | <?php |
| 29 | 29 | } |
| 30 | 30 | |
@@ -28,10 +28,10 @@ |
||
| 28 | 28 | |
| 29 | 29 | $show_mt = $this->show_merge_tags(); |
| 30 | 30 | |
| 31 | - if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
| 32 | - $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
|
| 33 | - } |
|
| 34 | - $class .= !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat'; |
|
| 31 | + if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
| 32 | + $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
|
| 33 | + } |
|
| 34 | + $class .= !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat'; |
|
| 35 | 35 | |
| 36 | 36 | ?> |
| 37 | 37 | <input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="text" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>"> |
@@ -18,15 +18,15 @@ |
||
| 18 | 18 | |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - function render_input( $override_input = null ) { |
|
| 22 | - if( isset( $override_input ) ) { |
|
| 21 | + function render_input($override_input = null) { |
|
| 22 | + if (isset($override_input)) { |
|
| 23 | 23 | echo $override_input; |
| 24 | 24 | return; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - foreach( $this->field['options'] as $value => $label ) : ?> |
|
| 27 | + foreach ($this->field['options'] as $value => $label) : ?> |
|
| 28 | 28 | <label class="<?php echo $this->get_label_class(); ?>"> |
| 29 | - <input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>-<?php echo esc_attr( $value ); ?>" type="radio" value="<?php echo esc_attr( $value ); ?>" <?php checked( $value, $this->value, true ); ?> /> <?php echo esc_html( $label ); ?> |
|
| 29 | + <input name="<?php echo esc_attr($this->name); ?>" id="<?php echo $this->get_field_id(); ?>-<?php echo esc_attr($value); ?>" type="radio" value="<?php echo esc_attr($value); ?>" <?php checked($value, $this->value, true); ?> /> <?php echo esc_html($label); ?> |
|
| 30 | 30 | </label> |
| 31 | 31 | <?php |
| 32 | 32 | endforeach; |