@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | */ |
22 | 22 | function __construct() { |
23 | 23 | |
24 | - $this->widget_description = __('Displays the results of Poll Fields that exist in the form.', 'gravityview' ); |
|
24 | + $this->widget_description = __('Displays the results of Poll Fields that exist in the form.', 'gravityview'); |
|
25 | 25 | |
26 | - $this->widget_subtitle = sprintf( _x('Note: this will display poll results for %sall form entries%s, not only the entries displayed in the View.', 'The string placeholders are for emphasis HTML', 'gravityview' ), '<em>', '</em>' ); |
|
26 | + $this->widget_subtitle = sprintf(_x('Note: this will display poll results for %sall form entries%s, not only the entries displayed in the View.', 'The string placeholders are for emphasis HTML', 'gravityview'), '<em>', '</em>'); |
|
27 | 27 | |
28 | 28 | $default_values = array( |
29 | 29 | 'header' => 1, |
@@ -35,18 +35,18 @@ discard block |
||
35 | 35 | 'label' => __('Display Percentages', 'gravityview'), |
36 | 36 | 'type' => 'checkbox', |
37 | 37 | 'value' => true, |
38 | - 'tooltip' => __( 'Display results percentages as part of results? Supported values are: true, false. Defaults to "true".', 'gravityview' ), |
|
38 | + 'tooltip' => __('Display results percentages as part of results? Supported values are: true, false. Defaults to "true".', 'gravityview'), |
|
39 | 39 | ), |
40 | 40 | 'counts' => array( |
41 | 41 | 'label' => __('Display Counts', 'gravityview'), |
42 | 42 | 'type' => 'checkbox', |
43 | 43 | 'value' => true, |
44 | - 'tooltip' => __( 'Display number of times each choice has been selected when displaying results? Supported values are: true, false. Defaults to "true".', 'gravityview' ), |
|
44 | + 'tooltip' => __('Display number of times each choice has been selected when displaying results? Supported values are: true, false. Defaults to "true".', 'gravityview'), |
|
45 | 45 | ), |
46 | 46 | 'style' => array( |
47 | 47 | 'type' => 'select', |
48 | 48 | 'label' => __('Style', 'gravityview'), |
49 | - 'tooltip' => __( 'The Polls Add-On currently supports 4 built in styles: red, green, orange, blue. Defaults to "green".', 'gravityview' ), |
|
49 | + 'tooltip' => __('The Polls Add-On currently supports 4 built in styles: red, green, orange, blue. Defaults to "green".', 'gravityview'), |
|
50 | 50 | 'value' => 'green', |
51 | 51 | 'choices' => array( |
52 | 52 | 'green' => __('Green', 'gravityview'), |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | ) |
58 | 58 | ); |
59 | 59 | |
60 | - parent::__construct( __( 'Poll Results', 'gravityview' ) , 'poll', $default_values, $settings ); |
|
60 | + parent::__construct(__('Poll Results', 'gravityview'), 'poll', $default_values, $settings); |
|
61 | 61 | |
62 | 62 | // frontend - add template path |
63 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
63 | + add_filter('gravityview_template_paths', array($this, 'add_template_path')); |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | * @since 1.8 |
70 | 70 | * @param array $file_paths List of template paths ordered |
71 | 71 | */ |
72 | - function add_template_path( $file_paths ) { |
|
72 | + function add_template_path($file_paths) { |
|
73 | 73 | |
74 | 74 | $index = 126; |
75 | 75 | |
76 | 76 | // Index 100 is the default GravityView template path. |
77 | - $file_paths[ $index ] = plugin_dir_path( __FILE__ ) . 'templates/'; |
|
77 | + $file_paths[$index] = plugin_dir_path(__FILE__).'templates/'; |
|
78 | 78 | |
79 | 79 | return $file_paths; |
80 | 80 | } |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | |
89 | 89 | $GFPolls = GFPolls::get_instance(); |
90 | 90 | |
91 | - wp_enqueue_script('gpoll_js', $GFPolls->get_base_url() . '/js/gpoll.js', array('jquery'), $GFPolls->_version); |
|
91 | + wp_enqueue_script('gpoll_js', $GFPolls->get_base_url().'/js/gpoll.js', array('jquery'), $GFPolls->_version); |
|
92 | 92 | |
93 | 93 | $GFPolls->localize_scripts(); |
94 | 94 | |
95 | - wp_enqueue_style('gpoll_css', $GFPolls->get_base_url() . '/css/gpoll.css', null, $GFPolls->_version); |
|
95 | + wp_enqueue_style('gpoll_css', $GFPolls->get_base_url().'/css/gpoll.css', null, $GFPolls->_version); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -102,20 +102,20 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function pre_render_frontend() { |
104 | 104 | |
105 | - if( !class_exists('GFPolls') ) { |
|
105 | + if (!class_exists('GFPolls')) { |
|
106 | 106 | |
107 | 107 | $return = false; |
108 | 108 | |
109 | - do_action( 'gravityview_log_error', 'Poll Widget not displayed; the Poll Addon is not loaded' ); |
|
109 | + do_action('gravityview_log_error', 'Poll Widget not displayed; the Poll Addon is not loaded'); |
|
110 | 110 | |
111 | 111 | } else { |
112 | 112 | |
113 | 113 | $return = parent::pre_render_frontend(); |
114 | 114 | |
115 | - $poll_fields = GFCommon::get_fields_by_type( GravityView_View::getInstance()->getForm(), array( 'poll' ) ); |
|
115 | + $poll_fields = GFCommon::get_fields_by_type(GravityView_View::getInstance()->getForm(), array('poll')); |
|
116 | 116 | |
117 | - if ( empty ( $poll_fields ) ) { |
|
118 | - do_action( 'gravityview_log_error', 'Poll Widget not displayed; there are no poll fields for the form' ); |
|
117 | + if (empty ($poll_fields)) { |
|
118 | + do_action('gravityview_log_error', 'Poll Widget not displayed; there are no poll fields for the form'); |
|
119 | 119 | $return = false; |
120 | 120 | } |
121 | 121 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @return array Final poll widget settings |
132 | 132 | */ |
133 | - function get_frontend_settings( $widget_settings ) { |
|
133 | + function get_frontend_settings($widget_settings) { |
|
134 | 134 | |
135 | 135 | $default_settings = array( |
136 | 136 | 'field' => 0, |
@@ -139,14 +139,14 @@ discard block |
||
139 | 139 | 'counts' => true, |
140 | 140 | ); |
141 | 141 | |
142 | - $settings = wp_parse_args( $widget_settings, $default_settings ); |
|
142 | + $settings = wp_parse_args($widget_settings, $default_settings); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * @filter `gravityview/widget/poll/settings` Modify display settings for the poll widget |
146 | 146 | * @since 1.8 |
147 | 147 | * @param array $settings Settings with `field`, `style`, `percentages` and `counts` keys |
148 | 148 | */ |
149 | - $settings = apply_filters( 'gravityview/widget/poll/settings', $settings ); |
|
149 | + $settings = apply_filters('gravityview/widget/poll/settings', $settings); |
|
150 | 150 | |
151 | 151 | return $settings; |
152 | 152 | } |
@@ -158,29 +158,29 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @since 1.8 |
160 | 160 | */ |
161 | - public function render_frontend( $widget_args, $content = '', $context = '') { |
|
161 | + public function render_frontend($widget_args, $content = '', $context = '') { |
|
162 | 162 | |
163 | - if( !$this->pre_render_frontend() ) { |
|
163 | + if (!$this->pre_render_frontend()) { |
|
164 | 164 | return; |
165 | 165 | } |
166 | 166 | |
167 | 167 | // Make sure the class is loaded in DataTables |
168 | - if( !class_exists( 'GFFormDisplay' ) ) { |
|
169 | - include_once( GFCommon::get_base_path() . '/form_display.php' ); |
|
168 | + if (!class_exists('GFFormDisplay')) { |
|
169 | + include_once(GFCommon::get_base_path().'/form_display.php'); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | $this->enqueue_scripts_and_styles(); |
173 | 173 | |
174 | - $settings = $this->get_frontend_settings( $widget_args ); |
|
174 | + $settings = $this->get_frontend_settings($widget_args); |
|
175 | 175 | |
176 | - $percentages = empty( $settings['percentages'] ) ? 'false' : 'true'; |
|
176 | + $percentages = empty($settings['percentages']) ? 'false' : 'true'; |
|
177 | 177 | |
178 | - $counts = empty( $settings['counts'] ) ? 'false' : 'true'; |
|
178 | + $counts = empty($settings['counts']) ? 'false' : 'true'; |
|
179 | 179 | |
180 | - if( !empty( $settings['field'] ) ) { |
|
181 | - $merge_tag = sprintf( '{gpoll: field="%d" style="%s" percentages="%s" counts="%s"}', $settings['field'], $settings['style'], $percentages, $counts ); |
|
180 | + if (!empty($settings['field'])) { |
|
181 | + $merge_tag = sprintf('{gpoll: field="%d" style="%s" percentages="%s" counts="%s"}', $settings['field'], $settings['style'], $percentages, $counts); |
|
182 | 182 | } else { |
183 | - $merge_tag = sprintf( '{all_poll_results: style="%s" percentages="%s" counts="%s"}', $settings['style'], $percentages, $counts ); |
|
183 | + $merge_tag = sprintf('{all_poll_results: style="%s" percentages="%s" counts="%s"}', $settings['style'], $percentages, $counts); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | $gravityview_view = GravityView_View::getInstance(); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | $gravityview_view->poll_settings = $settings; |
191 | 191 | |
192 | - $gravityview_view->render('widget', 'poll', false ); |
|
192 | + $gravityview_view->render('widget', 'poll', false); |
|
193 | 193 | |
194 | 194 | } |
195 | 195 |
@@ -13,4 +13,4 @@ |
||
13 | 13 | */ |
14 | 14 | $merge_tag = $gravityview_view->poll_merge_tag; |
15 | 15 | |
16 | -echo GFCommon::replace_variables( $merge_tag, $gravityview_view->getForm(), array() ); |
|
17 | 16 | \ No newline at end of file |
17 | +echo GFCommon::replace_variables($merge_tag, $gravityview_view->getForm(), array()); |
|
18 | 18 | \ No newline at end of file |
@@ -20,18 +20,18 @@ |
||
20 | 20 | */ |
21 | 21 | function gravityview_register_gravityview_widgets() { |
22 | 22 | |
23 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget.php' ); |
|
23 | + include_once(GRAVITYVIEW_DIR.'includes/widgets/class-gravityview-widget.php'); |
|
24 | 24 | |
25 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget-pagination-info.php' ); |
|
26 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget-page-links.php' ); |
|
27 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget-custom-content.php' ); |
|
28 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/search-widget/class-search-widget.php' ); |
|
25 | + include_once(GRAVITYVIEW_DIR.'includes/widgets/class-gravityview-widget-pagination-info.php'); |
|
26 | + include_once(GRAVITYVIEW_DIR.'includes/widgets/class-gravityview-widget-page-links.php'); |
|
27 | + include_once(GRAVITYVIEW_DIR.'includes/widgets/class-gravityview-widget-custom-content.php'); |
|
28 | + include_once(GRAVITYVIEW_DIR.'includes/widgets/search-widget/class-search-widget.php'); |
|
29 | 29 | |
30 | - if( class_exists('GFPolls') ) { |
|
31 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/poll/class-gravityview-widget-poll.php' ); |
|
30 | + if (class_exists('GFPolls')) { |
|
31 | + include_once(GRAVITYVIEW_DIR.'includes/widgets/poll/class-gravityview-widget-poll.php'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | } |
35 | 35 | |
36 | 36 | // Load default widgets |
37 | -add_action( 'init', 'gravityview_register_gravityview_widgets', 11 ); |
|
38 | 37 | \ No newline at end of file |
38 | +add_action('init', 'gravityview_register_gravityview_widgets', 11); |
|
39 | 39 | \ No newline at end of file |
@@ -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,31 +137,31 @@ 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 | - 'input_labels' => json_encode( $input_labels ), |
|
156 | - 'input_types' => json_encode( $input_types ), |
|
157 | - ) ); |
|
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 | + 'input_labels' => json_encode($input_labels), |
|
156 | + 'input_types' => json_encode($input_types), |
|
157 | + )); |
|
158 | 158 | |
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Add admin script to the whitelist |
163 | 163 | */ |
164 | - public function register_no_conflict( $required ) { |
|
164 | + public function register_no_conflict($required) { |
|
165 | 165 | $required[] = 'gravityview_searchwidget_admin'; |
166 | 166 | return $required; |
167 | 167 | } |
@@ -175,30 +175,30 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public static function get_searchable_fields() { |
177 | 177 | |
178 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
179 | - exit( 0 ); |
|
178 | + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxsearchwidget')) { |
|
179 | + exit(0); |
|
180 | 180 | } |
181 | 181 | $form = ''; |
182 | 182 | |
183 | 183 | // Fetch the form for the current View |
184 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
184 | + if (!empty($_POST['view_id'])) { |
|
185 | 185 | |
186 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
186 | + $form = gravityview_get_form_id($_POST['view_id']); |
|
187 | 187 | |
188 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
188 | + } elseif (!empty($_POST['formid'])) { |
|
189 | 189 | |
190 | - $form = (int) $_POST['formid']; |
|
190 | + $form = (int)$_POST['formid']; |
|
191 | 191 | |
192 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
192 | + } elseif (!empty($_POST['template_id']) && class_exists('GravityView_Ajax')) { |
|
193 | 193 | |
194 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
194 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
195 | 195 | |
196 | 196 | } |
197 | 197 | |
198 | 198 | // fetch form id assigned to the view |
199 | - $response = self::render_searchable_fields( $form ); |
|
199 | + $response = self::render_searchable_fields($form); |
|
200 | 200 | |
201 | - exit( $response ); |
|
201 | + exit($response); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -207,14 +207,14 @@ discard block |
||
207 | 207 | * @param string $current (for future use) |
208 | 208 | * @return string |
209 | 209 | */ |
210 | - public static function render_searchable_fields( $form_id = null, $current = '' ) { |
|
210 | + public static function render_searchable_fields($form_id = null, $current = '') { |
|
211 | 211 | |
212 | - if ( is_null( $form_id ) ) { |
|
212 | + if (is_null($form_id)) { |
|
213 | 213 | return ''; |
214 | 214 | } |
215 | 215 | |
216 | 216 | // Get fields with sub-inputs and no parent |
217 | - $fields = gravityview_get_form_fields( $form_id, true, true ); |
|
217 | + $fields = gravityview_get_form_fields($form_id, true, true); |
|
218 | 218 | |
219 | 219 | // start building output |
220 | 220 | |
@@ -222,40 +222,40 @@ discard block |
||
222 | 222 | |
223 | 223 | $custom_fields = array( |
224 | 224 | 'search_all' => array( |
225 | - 'text' => esc_html__( 'Search Everything', 'gravityview' ), |
|
225 | + 'text' => esc_html__('Search Everything', 'gravityview'), |
|
226 | 226 | 'type' => 'text', |
227 | 227 | ), |
228 | 228 | 'entry_date' => array( |
229 | - 'text' => esc_html__( 'Entry Date', 'gravityview' ), |
|
229 | + 'text' => esc_html__('Entry Date', 'gravityview'), |
|
230 | 230 | 'type' => 'date', |
231 | 231 | ), |
232 | 232 | 'entry_id' => array( |
233 | - 'text' => esc_html__( 'Entry ID', 'gravityview' ), |
|
233 | + 'text' => esc_html__('Entry ID', 'gravityview'), |
|
234 | 234 | 'type' => 'text', |
235 | 235 | ), |
236 | 236 | 'created_by' => array( |
237 | - 'text' => esc_html__( 'Entry Creator', 'gravityview' ), |
|
237 | + 'text' => esc_html__('Entry Creator', 'gravityview'), |
|
238 | 238 | 'type' => 'select', |
239 | 239 | ) |
240 | 240 | ); |
241 | 241 | |
242 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
243 | - $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'] ); |
|
242 | + foreach ($custom_fields as $custom_field_key => $custom_field) { |
|
243 | + $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 | 244 | } |
245 | 245 | |
246 | - if ( ! empty( $fields ) ) { |
|
246 | + if (!empty($fields)) { |
|
247 | 247 | |
248 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'fileupload', 'post_image', 'post_id' ), null ); |
|
248 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array('fileupload', 'post_image', 'post_id'), null); |
|
249 | 249 | |
250 | - foreach ( $fields as $id => $field ) { |
|
250 | + foreach ($fields as $id => $field) { |
|
251 | 251 | |
252 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
252 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
253 | 253 | continue; |
254 | 254 | } |
255 | 255 | |
256 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
256 | + $types = self::get_search_input_types($id, $field['type']); |
|
257 | 257 | |
258 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
258 | + $output .= '<option value="'.$id.'" '.selected($id, $current, false).'data-inputtypes="'.esc_attr($types).'">'.esc_html($field['label']).'</option>'; |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
@@ -274,21 +274,21 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return string GV field search input type ('multi', 'boolean', 'select', 'date', 'text') |
276 | 276 | */ |
277 | - public static function get_search_input_types( $id = '', $field_type = null ) { |
|
277 | + public static function get_search_input_types($id = '', $field_type = null) { |
|
278 | 278 | |
279 | 279 | // @todo - This needs to be improved - many fields have . including products and addresses |
280 | - if ( false !== strpos( (string) $id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
280 | + if (false !== strpos((string)$id, '.') && in_array($field_type, array('checkbox')) || in_array($id, array('is_fulfilled'))) { |
|
281 | 281 | // on/off checkbox |
282 | 282 | $input_type = 'boolean'; |
283 | - } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
|
283 | + } elseif (in_array($field_type, array('checkbox', 'post_category', 'multiselect'))) { |
|
284 | 284 | //multiselect |
285 | 285 | $input_type = 'multi'; |
286 | 286 | |
287 | - } elseif ( in_array( $field_type, array( 'select', 'radio' ) ) ) { |
|
287 | + } elseif (in_array($field_type, array('select', 'radio'))) { |
|
288 | 288 | //single select |
289 | 289 | $input_type = 'select'; |
290 | 290 | |
291 | - } elseif ( in_array( $field_type, array( 'date' ) ) || in_array( $id, array( 'payment_date' ) ) ) { |
|
291 | + } elseif (in_array($field_type, array('date')) || in_array($id, array('payment_date'))) { |
|
292 | 292 | // date |
293 | 293 | $input_type = 'date'; |
294 | 294 | } else { |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @param string $field_type Gravity Forms field type |
303 | 303 | * @since 1.2 |
304 | 304 | */ |
305 | - $input_type = apply_filters( 'gravityview/extension/search/input_type', $input_type, $field_type ); |
|
305 | + $input_type = apply_filters('gravityview/extension/search/input_type', $input_type, $field_type); |
|
306 | 306 | |
307 | 307 | return $input_type; |
308 | 308 | } |
@@ -313,29 +313,29 @@ discard block |
||
313 | 313 | * @since 1.8 |
314 | 314 | * @return array Search fields, modified if not using permalinks |
315 | 315 | */ |
316 | - public function add_no_permalink_fields( $search_fields, $object, $widget_args = array() ) { |
|
316 | + public function add_no_permalink_fields($search_fields, $object, $widget_args = array()) { |
|
317 | 317 | /** @global WP_Rewrite $wp_rewrite */ |
318 | 318 | global $wp_rewrite; |
319 | 319 | |
320 | 320 | // Support default permalink structure |
321 | - if ( false === $wp_rewrite->using_permalinks() ) { |
|
321 | + if (false === $wp_rewrite->using_permalinks()) { |
|
322 | 322 | |
323 | 323 | // By default, use current post. |
324 | 324 | $post_id = 0; |
325 | 325 | |
326 | 326 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
327 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
328 | - $post_id = absint( $widget_args['post_id'] ); |
|
327 | + if (!empty($widget_args['post_id'])) { |
|
328 | + $post_id = absint($widget_args['post_id']); |
|
329 | 329 | } |
330 | 330 | // We're in the WordPress Widget context, and the base View ID should be used |
331 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
332 | - $post_id = absint( $widget_args['view_id'] ); |
|
331 | + else if (!empty($widget_args['view_id'])) { |
|
332 | + $post_id = absint($widget_args['view_id']); |
|
333 | 333 | } |
334 | 334 | |
335 | - $args = gravityview_get_permalink_query_args( $post_id ); |
|
335 | + $args = gravityview_get_permalink_query_args($post_id); |
|
336 | 336 | |
337 | 337 | // Add hidden fields to the search form |
338 | - foreach ( $args as $key => $value ) { |
|
338 | + foreach ($args as $key => $value) { |
|
339 | 339 | $search_fields[] = array( |
340 | 340 | 'name' => $key, |
341 | 341 | 'input' => 'hidden', |
@@ -355,23 +355,23 @@ discard block |
||
355 | 355 | * @param array $search_criteria |
356 | 356 | * @return array |
357 | 357 | */ |
358 | - public function filter_entries( $search_criteria ) { |
|
358 | + public function filter_entries($search_criteria) { |
|
359 | 359 | |
360 | - do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Requested $_GET: ', get_class( $this ) ), $_GET ); |
|
360 | + do_action('gravityview_log_debug', sprintf('%s[filter_entries] Requested $_GET: ', get_class($this)), $_GET); |
|
361 | 361 | |
362 | - if ( empty( $_GET ) || ! is_array( $_GET ) ) { |
|
362 | + if (empty($_GET) || !is_array($_GET)) { |
|
363 | 363 | return $search_criteria; |
364 | 364 | } |
365 | 365 | |
366 | 366 | // add free search |
367 | - if ( ! empty( $_GET['gv_search'] ) ) { |
|
367 | + if (!empty($_GET['gv_search'])) { |
|
368 | 368 | |
369 | 369 | // Search for a piece |
370 | - $words = explode( ' ', stripslashes_deep( urldecode( $_GET['gv_search'] ) ) ); |
|
370 | + $words = explode(' ', stripslashes_deep(urldecode($_GET['gv_search']))); |
|
371 | 371 | |
372 | - $words = array_filter( $words ); |
|
372 | + $words = array_filter($words); |
|
373 | 373 | |
374 | - foreach ( $words as $word ) { |
|
374 | + foreach ($words as $word) { |
|
375 | 375 | $search_criteria['field_filters'][] = array( |
376 | 376 | 'key' => null, // The field ID to search |
377 | 377 | 'value' => $word, // The value to search |
@@ -381,8 +381,8 @@ discard block |
||
381 | 381 | } |
382 | 382 | |
383 | 383 | //start date & end date |
384 | - $curr_start = esc_attr( rgget( 'gv_start' ) ); |
|
385 | - $curr_end = esc_attr( rgget( 'gv_end' ) ); |
|
384 | + $curr_start = esc_attr(rgget('gv_start')); |
|
385 | + $curr_end = esc_attr(rgget('gv_end')); |
|
386 | 386 | |
387 | 387 | /** |
388 | 388 | * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
@@ -391,51 +391,51 @@ discard block |
||
391 | 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 | 392 | * @param[in] string $context Where the filter is being called from. `search` in this case. |
393 | 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; |
|
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 |
400 | - if ( ! empty( $_GET[ 'gv_id' ] ) ) { |
|
400 | + if (!empty($_GET['gv_id'])) { |
|
401 | 401 | $search_criteria['field_filters'][] = array( |
402 | 402 | 'key' => 'id', |
403 | - 'value' => absint( $_GET[ 'gv_id' ] ), |
|
403 | + 'value' => absint($_GET['gv_id']), |
|
404 | 404 | 'operator' => '=', |
405 | 405 | ); |
406 | 406 | } |
407 | 407 | |
408 | 408 | // search for a specific Created_by ID |
409 | - if ( ! empty( $_GET[ 'gv_by' ] ) ) { |
|
409 | + if (!empty($_GET['gv_by'])) { |
|
410 | 410 | $search_criteria['field_filters'][] = array( |
411 | 411 | 'key' => 'created_by', |
412 | - 'value' => absint( $_GET['gv_by'] ), |
|
412 | + 'value' => absint($_GET['gv_by']), |
|
413 | 413 | 'operator' => '=', |
414 | 414 | ); |
415 | 415 | } |
416 | 416 | |
417 | 417 | |
418 | 418 | // Get search mode passed in URL |
419 | - $mode = in_array( rgget( 'mode' ), array( 'any', 'all' ) ) ? esc_attr( rgget( 'mode' ) ) : 'any'; |
|
419 | + $mode = in_array(rgget('mode'), array('any', 'all')) ? esc_attr(rgget('mode')) : 'any'; |
|
420 | 420 | |
421 | 421 | // get the other search filters |
422 | - foreach ( $_GET as $key => $value ) { |
|
422 | + foreach ($_GET as $key => $value) { |
|
423 | 423 | |
424 | - if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[0] ) ) ) { |
|
424 | + if (0 !== strpos($key, 'filter_') || empty($value) || (is_array($value) && count($value) === 1 && empty($value[0]))) { |
|
425 | 425 | continue; |
426 | 426 | } |
427 | 427 | |
428 | 428 | // could return simple filter or multiple filters |
429 | - $filter = $this->prepare_field_filter( $key, $value ); |
|
429 | + $filter = $this->prepare_field_filter($key, $value); |
|
430 | 430 | |
431 | - if ( isset( $filter[0]['value'] ) ) { |
|
432 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
431 | + if (isset($filter[0]['value'])) { |
|
432 | + $search_criteria['field_filters'] = array_merge($search_criteria['field_filters'], $filter); |
|
433 | 433 | |
434 | 434 | // if date range type, set search mode to ALL |
435 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>', '<' ) ) ) { |
|
435 | + if (!empty($filter[0]['operator']) && in_array($filter[0]['operator'], array('>', '<'))) { |
|
436 | 436 | $mode = 'all'; |
437 | 437 | } |
438 | - } elseif( !empty( $filter ) ) { |
|
438 | + } elseif (!empty($filter)) { |
|
439 | 439 | $search_criteria['field_filters'][] = $filter; |
440 | 440 | } |
441 | 441 | } |
@@ -445,9 +445,9 @@ discard block |
||
445 | 445 | * @since 1.5.1 |
446 | 446 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
447 | 447 | */ |
448 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
448 | + $search_criteria['field_filters']['mode'] = apply_filters('gravityview/search/mode', $mode); |
|
449 | 449 | |
450 | - do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria ); |
|
450 | + do_action('gravityview_log_debug', sprintf('%s[filter_entries] Returned Search Criteria: ', get_class($this)), $search_criteria); |
|
451 | 451 | |
452 | 452 | return $search_criteria; |
453 | 453 | } |
@@ -462,16 +462,16 @@ discard block |
||
462 | 462 | * @param string $value $_GET search value |
463 | 463 | * @return array 1 or 2 deph levels |
464 | 464 | */ |
465 | - public function prepare_field_filter( $key, $value ) { |
|
465 | + public function prepare_field_filter($key, $value) { |
|
466 | 466 | |
467 | 467 | $gravityview_view = GravityView_View::getInstance(); |
468 | 468 | |
469 | 469 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
470 | - $field_id = str_replace( '_', '.', str_replace( 'filter_', '', $key ) ); |
|
470 | + $field_id = str_replace('_', '.', str_replace('filter_', '', $key)); |
|
471 | 471 | |
472 | 472 | // get form field array |
473 | 473 | $form = $gravityview_view->getForm(); |
474 | - $form_field = gravityview_get_field( $form, $field_id ); |
|
474 | + $form_field = gravityview_get_field($form, $field_id); |
|
475 | 475 | |
476 | 476 | // default filter array |
477 | 477 | $filter = array( |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | 'value' => $value, |
480 | 480 | ); |
481 | 481 | |
482 | - switch ( $form_field['type'] ) { |
|
482 | + switch ($form_field['type']) { |
|
483 | 483 | |
484 | 484 | case 'select': |
485 | 485 | case 'radio': |
@@ -488,18 +488,18 @@ discard block |
||
488 | 488 | |
489 | 489 | case 'post_category': |
490 | 490 | |
491 | - if ( ! is_array( $value ) ) { |
|
492 | - $value = array( $value ); |
|
491 | + if (!is_array($value)) { |
|
492 | + $value = array($value); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | // Reset filter variable |
496 | 496 | $filter = array(); |
497 | 497 | |
498 | - foreach ( $value as $val ) { |
|
499 | - $cat = get_term( $val, 'category' ); |
|
498 | + foreach ($value as $val) { |
|
499 | + $cat = get_term($val, 'category'); |
|
500 | 500 | $filter[] = array( |
501 | 501 | 'key' => $field_id, |
502 | - 'value' => esc_attr( $cat->name ) . ':' . $val, |
|
502 | + 'value' => esc_attr($cat->name).':'.$val, |
|
503 | 503 | 'operator' => 'is', |
504 | 504 | ); |
505 | 505 | } |
@@ -508,35 +508,35 @@ discard block |
||
508 | 508 | |
509 | 509 | case 'multiselect': |
510 | 510 | |
511 | - if ( ! is_array( $value ) ) { |
|
511 | + if (!is_array($value)) { |
|
512 | 512 | break; |
513 | 513 | } |
514 | 514 | |
515 | 515 | // Reset filter variable |
516 | 516 | $filter = array(); |
517 | 517 | |
518 | - foreach ( $value as $val ) { |
|
519 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
518 | + foreach ($value as $val) { |
|
519 | + $filter[] = array('key' => $field_id, 'value' => $val); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | break; |
523 | 523 | |
524 | 524 | case 'checkbox': |
525 | 525 | // convert checkbox on/off into the correct search filter |
526 | - if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) { |
|
527 | - foreach ( $form_field['inputs'] as $k => $input ) { |
|
528 | - if ( $input['id'] == $field_id ) { |
|
529 | - $filter['value'] = $form_field['choices'][ $k ]['value']; |
|
526 | + if (false !== strpos($field_id, '.') && !empty($form_field['inputs']) && !empty($form_field['choices'])) { |
|
527 | + foreach ($form_field['inputs'] as $k => $input) { |
|
528 | + if ($input['id'] == $field_id) { |
|
529 | + $filter['value'] = $form_field['choices'][$k]['value']; |
|
530 | 530 | $filter['operator'] = 'is'; |
531 | 531 | break; |
532 | 532 | } |
533 | 533 | } |
534 | - } elseif ( is_array( $value ) ) { |
|
534 | + } elseif (is_array($value)) { |
|
535 | 535 | |
536 | 536 | // Reset filter variable |
537 | 537 | $filter = array(); |
538 | 538 | |
539 | - foreach ( $value as $val ) { |
|
539 | + foreach ($value as $val) { |
|
540 | 540 | $filter[] = array( |
541 | 541 | 'key' => $field_id, |
542 | 542 | 'value' => $val, |
@@ -550,13 +550,13 @@ discard block |
||
550 | 550 | case 'name': |
551 | 551 | case 'address': |
552 | 552 | |
553 | - if ( false === strpos( $field_id, '.' ) ) { |
|
553 | + if (false === strpos($field_id, '.')) { |
|
554 | 554 | |
555 | - $words = explode( ' ', $value ); |
|
555 | + $words = explode(' ', $value); |
|
556 | 556 | |
557 | 557 | $filters = array(); |
558 | - foreach ( $words as $word ) { |
|
559 | - if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
|
558 | + foreach ($words as $word) { |
|
559 | + if (!empty($word) && strlen($word) > 1) { |
|
560 | 560 | // Keep the same key for each filter |
561 | 561 | $filter['value'] = $word; |
562 | 562 | // Add a search for the value |
@@ -571,25 +571,25 @@ discard block |
||
571 | 571 | |
572 | 572 | case 'date': |
573 | 573 | |
574 | - if ( is_array( $value ) ) { |
|
574 | + if (is_array($value)) { |
|
575 | 575 | |
576 | 576 | // Reset filter variable |
577 | 577 | $filter = array(); |
578 | 578 | |
579 | - foreach ( $value as $k => $date ) { |
|
580 | - if ( empty( $date ) ) { |
|
579 | + foreach ($value as $k => $date) { |
|
580 | + if (empty($date)) { |
|
581 | 581 | continue; |
582 | 582 | } |
583 | 583 | $operator = 'start' === $k ? '>' : '<'; |
584 | 584 | |
585 | 585 | $filter[] = array( |
586 | 586 | 'key' => $field_id, |
587 | - 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
|
587 | + 'value' => self::get_formatted_date($date, 'Y-m-d'), |
|
588 | 588 | 'operator' => $operator, |
589 | 589 | ); |
590 | 590 | } |
591 | 591 | } else { |
592 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
592 | + $filter['value'] = self::get_formatted_date($value, 'Y-m-d'); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | break; |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * |
609 | 609 | * @return string Format of the date in the database |
610 | 610 | */ |
611 | - public static function get_date_field_format( GF_Field_Date $field ) { |
|
611 | + public static function get_date_field_format(GF_Field_Date $field) { |
|
612 | 612 | $format = 'm/d/Y'; |
613 | 613 | $datepicker = array( |
614 | 614 | 'mdy' => 'm/d/Y', |
@@ -620,8 +620,8 @@ discard block |
||
620 | 620 | 'ymd_dot' => 'Y.m.d', |
621 | 621 | ); |
622 | 622 | |
623 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
624 | - $format = $datepicker[ $field->dateFormat ]; |
|
623 | + if (!empty($field->dateFormat) && isset($datepicker[$field->dateFormat])) { |
|
624 | + $format = $datepicker[$field->dateFormat]; |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | return $format; |
@@ -634,13 +634,13 @@ discard block |
||
634 | 634 | * @param string $format Wanted formatted date |
635 | 635 | * @return string |
636 | 636 | */ |
637 | - public static function get_formatted_date( $value = '', $format = 'Y-m-d' ) { |
|
638 | - $date = date_create( $value ); |
|
639 | - if ( empty( $date ) ) { |
|
640 | - do_action( 'gravityview_log_debug', sprintf( '%s[get_formatted_date] Date format not valid: ', get_class( self::$instance ) ), $value ); |
|
637 | + public static function get_formatted_date($value = '', $format = 'Y-m-d') { |
|
638 | + $date = date_create($value); |
|
639 | + if (empty($date)) { |
|
640 | + do_action('gravityview_log_debug', sprintf('%s[get_formatted_date] Date format not valid: ', get_class(self::$instance)), $value); |
|
641 | 641 | return ''; |
642 | 642 | } |
643 | - return $date->format( $format ); |
|
643 | + return $date->format($format); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | |
@@ -648,10 +648,10 @@ discard block |
||
648 | 648 | * Include this extension templates path |
649 | 649 | * @param array $file_paths List of template paths ordered |
650 | 650 | */ |
651 | - public function add_template_path( $file_paths ) { |
|
651 | + public function add_template_path($file_paths) { |
|
652 | 652 | |
653 | 653 | // Index 100 is the default GravityView template path. |
654 | - $file_paths[102] = self::$file . 'templates/'; |
|
654 | + $file_paths[102] = self::$file.'templates/'; |
|
655 | 655 | |
656 | 656 | return $file_paths; |
657 | 657 | } |
@@ -663,50 +663,50 @@ discard block |
||
663 | 663 | * @param type $context |
664 | 664 | * @return type |
665 | 665 | */ |
666 | - public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
666 | + public function render_frontend($widget_args, $content = '', $context = '') { |
|
667 | 667 | /** @var GravityView_View $gravityview_view */ |
668 | 668 | $gravityview_view = GravityView_View::getInstance(); |
669 | 669 | |
670 | - if ( empty( $gravityview_view ) ) { |
|
671 | - do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class( $this ) ) ); |
|
670 | + if (empty($gravityview_view)) { |
|
671 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this))); |
|
672 | 672 | return; |
673 | 673 | } |
674 | 674 | |
675 | 675 | // get configured search fields |
676 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
676 | + $search_fields = !empty($widget_args['search_fields']) ? json_decode($widget_args['search_fields'], true) : ''; |
|
677 | 677 | |
678 | - if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
|
679 | - do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args ); |
|
678 | + if (empty($search_fields) || !is_array($search_fields)) { |
|
679 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend] No search fields configured for widget:', get_class($this)), $widget_args); |
|
680 | 680 | return; |
681 | 681 | } |
682 | 682 | |
683 | 683 | $has_date = false; |
684 | 684 | |
685 | 685 | // prepare fields |
686 | - foreach ( $search_fields as $k => $field ) { |
|
686 | + foreach ($search_fields as $k => $field) { |
|
687 | 687 | |
688 | 688 | $updated_field = $field; |
689 | 689 | |
690 | - if ( in_array( $field['input'], array( 'date', 'date_range' ) ) ) { |
|
690 | + if (in_array($field['input'], array('date', 'date_range'))) { |
|
691 | 691 | $has_date = true; |
692 | 692 | } |
693 | 693 | |
694 | - $updated_field = $this->get_search_filter_details( $updated_field ); |
|
694 | + $updated_field = $this->get_search_filter_details($updated_field); |
|
695 | 695 | |
696 | - switch ( $field['field'] ) { |
|
696 | + switch ($field['field']) { |
|
697 | 697 | |
698 | 698 | case 'search_all': |
699 | 699 | $updated_field['key'] = 'search_all'; |
700 | 700 | $updated_field['input'] = 'search_all'; |
701 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_search' ) ) ); |
|
701 | + $updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_search'))); |
|
702 | 702 | break; |
703 | 703 | |
704 | 704 | case 'entry_date': |
705 | 705 | $updated_field['key'] = 'entry_date'; |
706 | 706 | $updated_field['input'] = 'entry_date'; |
707 | 707 | $updated_field['value'] = array( |
708 | - 'start' => esc_attr( stripslashes_deep( rgget( 'gv_start' ) ) ), |
|
709 | - 'end' => esc_attr( stripslashes_deep( rgget( 'gv_end' ) ) ), |
|
708 | + 'start' => esc_attr(stripslashes_deep(rgget('gv_start'))), |
|
709 | + 'end' => esc_attr(stripslashes_deep(rgget('gv_end'))), |
|
710 | 710 | ); |
711 | 711 | $has_date = true; |
712 | 712 | break; |
@@ -714,21 +714,21 @@ discard block |
||
714 | 714 | case 'entry_id': |
715 | 715 | $updated_field['key'] = 'entry_id'; |
716 | 716 | $updated_field['input'] = 'entry_id'; |
717 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_id' ) ) ); |
|
717 | + $updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_id'))); |
|
718 | 718 | break; |
719 | 719 | |
720 | 720 | case 'created_by': |
721 | 721 | $updated_field['key'] = 'created_by'; |
722 | 722 | $updated_field['name'] = 'gv_by'; |
723 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_by' ) ) ); |
|
723 | + $updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_by'))); |
|
724 | 724 | $updated_field['choices'] = self::get_created_by_choices(); |
725 | 725 | break; |
726 | 726 | } |
727 | 727 | |
728 | - $search_fields[ $k ] = $updated_field; |
|
728 | + $search_fields[$k] = $updated_field; |
|
729 | 729 | } |
730 | 730 | |
731 | - do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] Calculated Search Fields: ', get_class( $this ) ), $search_fields ); |
|
731 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend] Calculated Search Fields: ', get_class($this)), $search_fields); |
|
732 | 732 | |
733 | 733 | /** |
734 | 734 | * @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. |
@@ -737,25 +737,25 @@ discard block |
||
737 | 737 | * @param array $widget_args Args passed to this method. {@since 1.8} |
738 | 738 | * @var array |
739 | 739 | */ |
740 | - $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args ); |
|
740 | + $gravityview_view->search_fields = apply_filters('gravityview_widget_search_filters', $search_fields, $this, $widget_args); |
|
741 | 741 | |
742 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
742 | + $gravityview_view->search_layout = !empty($widget_args['search_layout']) ? $widget_args['search_layout'] : 'horizontal'; |
|
743 | 743 | |
744 | 744 | /** @since 1.14 */ |
745 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
745 | + $gravityview_view->search_mode = !empty($widget_args['search_mode']) ? $widget_args['search_mode'] : 'any'; |
|
746 | 746 | |
747 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
747 | + $custom_class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : ''; |
|
748 | 748 | |
749 | - $gravityview_view->search_class = self::get_search_class( $custom_class ); |
|
749 | + $gravityview_view->search_class = self::get_search_class($custom_class); |
|
750 | 750 | |
751 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
751 | + $gravityview_view->search_clear = !empty($widget_args['search_clear']) ? $widget_args['search_clear'] : false; |
|
752 | 752 | |
753 | - if ( $has_date ) { |
|
753 | + if ($has_date) { |
|
754 | 754 | // enqueue datepicker stuff only if needed! |
755 | 755 | $this->enqueue_datepicker(); |
756 | 756 | } |
757 | 757 | |
758 | - $gravityview_view->render( 'widget', 'search', false ); |
|
758 | + $gravityview_view->render('widget', 'search', false); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | /** |
@@ -765,12 +765,12 @@ discard block |
||
765 | 765 | * |
766 | 766 | * @return string Sanitized CSS class for the search form |
767 | 767 | */ |
768 | - public static function get_search_class( $custom_class = '' ) { |
|
768 | + public static function get_search_class($custom_class = '') { |
|
769 | 769 | $gravityview_view = GravityView_View::getInstance(); |
770 | 770 | |
771 | 771 | $search_class = 'gv-search-'.$gravityview_view->search_layout; |
772 | 772 | |
773 | - if ( ! empty( $custom_class ) ) { |
|
773 | + if (!empty($custom_class)) { |
|
774 | 774 | $search_class .= ' '.$custom_class; |
775 | 775 | } |
776 | 776 | |
@@ -779,12 +779,12 @@ discard block |
||
779 | 779 | * |
780 | 780 | * @param string $search_class The CSS class for the search form |
781 | 781 | */ |
782 | - $search_class = apply_filters( 'gravityview_search_class', $search_class ); |
|
782 | + $search_class = apply_filters('gravityview_search_class', $search_class); |
|
783 | 783 | |
784 | 784 | // Is there an active search being performed? Used by fe-views.js |
785 | 785 | $search_class .= GravityView_frontend::getInstance()->isSearch() ? ' gv-is-search' : ''; |
786 | 786 | |
787 | - return gravityview_sanitize_html_class( $search_class ); |
|
787 | + return gravityview_sanitize_html_class($search_class); |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | |
@@ -799,9 +799,9 @@ discard block |
||
799 | 799 | |
800 | 800 | $post_id = $gravityview_view->getPostId() ? $gravityview_view->getPostId() : $gravityview_view->getViewId(); |
801 | 801 | |
802 | - $url = add_query_arg( array(), get_permalink( $post_id ) ); |
|
802 | + $url = add_query_arg(array(), get_permalink($post_id)); |
|
803 | 803 | |
804 | - return esc_url( $url ); |
|
804 | + return esc_url($url); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | /** |
@@ -810,42 +810,42 @@ discard block |
||
810 | 810 | * @param array $form_field Form field data, as fetched by `gravityview_get_field()` |
811 | 811 | * @return string Label for the search form |
812 | 812 | */ |
813 | - private static function get_field_label( $field, $form_field = array() ) { |
|
813 | + private static function get_field_label($field, $form_field = array()) { |
|
814 | 814 | |
815 | - $label = rgget( 'label', $field ); |
|
815 | + $label = rgget('label', $field); |
|
816 | 816 | |
817 | - if( '' === $label ) { |
|
817 | + if ('' === $label) { |
|
818 | 818 | |
819 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
819 | + $label = isset($form_field['label']) ? $form_field['label'] : ''; |
|
820 | 820 | |
821 | - switch( $field['field'] ) { |
|
821 | + switch ($field['field']) { |
|
822 | 822 | case 'search_all': |
823 | - $label = __( 'Search Entries:', 'gravityview' ); |
|
823 | + $label = __('Search Entries:', 'gravityview'); |
|
824 | 824 | break; |
825 | 825 | case 'entry_date': |
826 | - $label = __( 'Filter by date:', 'gravityview' ); |
|
826 | + $label = __('Filter by date:', 'gravityview'); |
|
827 | 827 | break; |
828 | 828 | case 'entry_id': |
829 | - $label = __( 'Entry ID:', 'gravityview' ); |
|
829 | + $label = __('Entry ID:', 'gravityview'); |
|
830 | 830 | break; |
831 | 831 | case 'created_by': |
832 | - $label = __( 'Submitted by:', 'gravityview' ); |
|
832 | + $label = __('Submitted by:', 'gravityview'); |
|
833 | 833 | break; |
834 | 834 | case 'is_fulfilled': |
835 | - $label = __( 'Is Fulfilled', 'gravityview' ); |
|
835 | + $label = __('Is Fulfilled', 'gravityview'); |
|
836 | 836 | break; |
837 | 837 | default: |
838 | 838 | // If this is a field input, not a field |
839 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
839 | + if (strpos($field['field'], '.') > 0 && !empty($form_field['inputs'])) { |
|
840 | 840 | |
841 | 841 | // Get the label for the field in question, which returns an array |
842 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
842 | + $items = wp_list_filter($form_field['inputs'], array('id' => $field['field'])); |
|
843 | 843 | |
844 | 844 | // Get the item with the `label` key |
845 | - $values = wp_list_pluck( $items, 'label' ); |
|
845 | + $values = wp_list_pluck($items, 'label'); |
|
846 | 846 | |
847 | 847 | // There will only one item in the array, but this is easier |
848 | - foreach ( $values as $value ) { |
|
848 | + foreach ($values as $value) { |
|
849 | 849 | $label = $value; |
850 | 850 | break; |
851 | 851 | } |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | * @param[in,out] string $label Existing label text, sanitized. |
859 | 859 | * @param[in] array $form_field Gravity Forms field array, as returned by `GFFormsModel::get_field()` |
860 | 860 | */ |
861 | - $label = apply_filters( 'gravityview_search_field_label', esc_attr( $label ), $form_field ); |
|
861 | + $label = apply_filters('gravityview_search_field_label', esc_attr($label), $form_field); |
|
862 | 862 | |
863 | 863 | return $label; |
864 | 864 | } |
@@ -869,39 +869,39 @@ discard block |
||
869 | 869 | * @param array $field |
870 | 870 | * @return array |
871 | 871 | */ |
872 | - private function get_search_filter_details( $field ) { |
|
872 | + private function get_search_filter_details($field) { |
|
873 | 873 | |
874 | 874 | $gravityview_view = GravityView_View::getInstance(); |
875 | 875 | |
876 | 876 | $form = $gravityview_view->getForm(); |
877 | 877 | |
878 | 878 | // for advanced field ids (eg, first name / last name ) |
879 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
879 | + $name = 'filter_'.str_replace('.', '_', $field['field']); |
|
880 | 880 | |
881 | 881 | // get searched value from $_GET (string or array) |
882 | - $value = rgget( $name ); |
|
882 | + $value = rgget($name); |
|
883 | 883 | |
884 | 884 | // get form field details |
885 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
885 | + $form_field = gravityview_get_field($form, $field['field']); |
|
886 | 886 | |
887 | 887 | $filter = array( |
888 | 888 | 'key' => $field['field'], |
889 | 889 | 'name' => $name, |
890 | - 'label' => self::get_field_label( $field, $form_field ), |
|
890 | + 'label' => self::get_field_label($field, $form_field), |
|
891 | 891 | 'input' => $field['input'], |
892 | 892 | 'value' => $value, |
893 | 893 | 'type' => $form_field['type'], |
894 | 894 | ); |
895 | 895 | |
896 | 896 | // collect choices |
897 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
897 | + if ('post_category' === $form_field['type'] && !empty($form_field['displayAllCategories']) && empty($form_field['choices'])) { |
|
898 | 898 | $filter['choices'] = self::get_post_categories_choices(); |
899 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
899 | + } elseif (!empty($form_field['choices'])) { |
|
900 | 900 | $filter['choices'] = $form_field['choices']; |
901 | 901 | } |
902 | 902 | |
903 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
904 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
903 | + if ('date_range' === $field['input'] && empty($value)) { |
|
904 | + $filter['value'] = array('start' => '', 'end' => ''); |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | return $filter; |
@@ -921,10 +921,10 @@ discard block |
||
921 | 921 | * filter gravityview/get_users/search_widget |
922 | 922 | * @see \GVCommon::get_users |
923 | 923 | */ |
924 | - $users = GVCommon::get_users( 'search_widget', array( 'fields' => array( 'ID', 'display_name' ) ) ); |
|
924 | + $users = GVCommon::get_users('search_widget', array('fields' => array('ID', 'display_name'))); |
|
925 | 925 | |
926 | 926 | $choices = array(); |
927 | - foreach ( $users as $user ) { |
|
927 | + foreach ($users as $user) { |
|
928 | 928 | $choices[] = array( |
929 | 929 | 'value' => $user->ID, |
930 | 930 | 'text' => $user->display_name, |
@@ -945,16 +945,16 @@ discard block |
||
945 | 945 | 'hierarchical' => 1, |
946 | 946 | 'taxonomy' => 'category', |
947 | 947 | ); |
948 | - $categories = get_categories( $args ); |
|
948 | + $categories = get_categories($args); |
|
949 | 949 | |
950 | - if ( empty( $categories ) ) { |
|
950 | + if (empty($categories)) { |
|
951 | 951 | return array(); |
952 | 952 | } |
953 | 953 | |
954 | 954 | $choices = array(); |
955 | 955 | |
956 | - foreach ( $categories as $category ) { |
|
957 | - $choices[] = array( 'text' => $category->name, 'value' => $category->term_id ); |
|
956 | + foreach ($categories as $category) { |
|
957 | + $choices[] = array('text' => $category->name, 'value' => $category->term_id); |
|
958 | 958 | } |
959 | 959 | |
960 | 960 | return $choices; |
@@ -968,11 +968,11 @@ discard block |
||
968 | 968 | public static function the_clear_search_button() { |
969 | 969 | $gravityview_view = GravityView_View::getInstance(); |
970 | 970 | |
971 | - if ( $gravityview_view->search_clear ) { |
|
971 | + if ($gravityview_view->search_clear) { |
|
972 | 972 | |
973 | - $url = strtok( add_query_arg( array() ), '?' ); |
|
973 | + $url = strtok(add_query_arg(array()), '?'); |
|
974 | 974 | |
975 | - echo gravityview_get_link( $url, esc_html__( 'Clear', 'gravityview' ), 'class=button gv-search-clear' ); |
|
975 | + echo gravityview_get_link($url, esc_html__('Clear', 'gravityview'), 'class=button gv-search-clear'); |
|
976 | 976 | |
977 | 977 | } |
978 | 978 | } |
@@ -983,7 +983,7 @@ discard block |
||
983 | 983 | * Require the datepicker script for the frontend GV script |
984 | 984 | * @param array $js_dependencies Array of existing required scripts for the fe-views.js script |
985 | 985 | */ |
986 | - public function add_datepicker_js_dependency( $js_dependencies ) { |
|
986 | + public function add_datepicker_js_dependency($js_dependencies) { |
|
987 | 987 | |
988 | 988 | $js_dependencies[] = 'jquery-ui-datepicker'; |
989 | 989 | |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | * |
999 | 999 | * @return array |
1000 | 1000 | */ |
1001 | - public function add_datepicker_localization( $localizations = array(), $view_data = array() ) { |
|
1001 | + public function add_datepicker_localization($localizations = array(), $view_data = array()) { |
|
1002 | 1002 | global $wp_locale; |
1003 | 1003 | |
1004 | 1004 | /** |
@@ -1008,26 +1008,26 @@ discard block |
||
1008 | 1008 | * @param array $js_localization The data padded to the Javascript file |
1009 | 1009 | * @param array $view_data View data array with View settings |
1010 | 1010 | */ |
1011 | - $datepicker_settings = apply_filters( 'gravityview_datepicker_settings', array( |
|
1011 | + $datepicker_settings = apply_filters('gravityview_datepicker_settings', array( |
|
1012 | 1012 | 'yearRange' => '-5:+5', |
1013 | 1013 | 'changeMonth' => true, |
1014 | 1014 | 'changeYear' => true, |
1015 | - 'closeText' => esc_attr_x( 'Close', 'Close calendar', 'gravityview' ), |
|
1016 | - 'prevText' => esc_attr_x( 'Prev', 'Previous month in calendar', 'gravityview' ), |
|
1017 | - 'nextText' => esc_attr_x( 'Next', 'Next month in calendar', 'gravityview' ), |
|
1018 | - 'currentText' => esc_attr_x( 'Today', 'Today in calendar', 'gravityview' ), |
|
1019 | - 'weekHeader' => esc_attr_x( 'Week', 'Week in calendar', 'gravityview' ), |
|
1020 | - 'monthStatus' => __( 'Show a different month', 'gravityview' ), |
|
1021 | - 'monthNames' => array_values( $wp_locale->month ), |
|
1022 | - 'monthNamesShort' => array_values( $wp_locale->month_abbrev ), |
|
1023 | - 'dayNames' => array_values( $wp_locale->weekday ), |
|
1024 | - 'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ), |
|
1025 | - 'dayNamesMin' => array_values( $wp_locale->weekday_initial ), |
|
1015 | + 'closeText' => esc_attr_x('Close', 'Close calendar', 'gravityview'), |
|
1016 | + 'prevText' => esc_attr_x('Prev', 'Previous month in calendar', 'gravityview'), |
|
1017 | + 'nextText' => esc_attr_x('Next', 'Next month in calendar', 'gravityview'), |
|
1018 | + 'currentText' => esc_attr_x('Today', 'Today in calendar', 'gravityview'), |
|
1019 | + 'weekHeader' => esc_attr_x('Week', 'Week in calendar', 'gravityview'), |
|
1020 | + 'monthStatus' => __('Show a different month', 'gravityview'), |
|
1021 | + 'monthNames' => array_values($wp_locale->month), |
|
1022 | + 'monthNamesShort' => array_values($wp_locale->month_abbrev), |
|
1023 | + 'dayNames' => array_values($wp_locale->weekday), |
|
1024 | + 'dayNamesShort' => array_values($wp_locale->weekday_abbrev), |
|
1025 | + 'dayNamesMin' => array_values($wp_locale->weekday_initial), |
|
1026 | 1026 | // get the start of week from WP general setting |
1027 | - 'firstDay' => get_option( 'start_of_week' ), |
|
1027 | + 'firstDay' => get_option('start_of_week'), |
|
1028 | 1028 | // is Right to left language? default is false |
1029 | 1029 | 'isRTL' => is_rtl(), |
1030 | - ), $view_data ); |
|
1030 | + ), $view_data); |
|
1031 | 1031 | |
1032 | 1032 | $localizations['datepicker'] = $datepicker_settings; |
1033 | 1033 | |
@@ -1046,13 +1046,13 @@ discard block |
||
1046 | 1046 | public function enqueue_datepicker() { |
1047 | 1047 | $gravityview_view = GravityView_View::getInstance(); |
1048 | 1048 | |
1049 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1049 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
1050 | 1050 | |
1051 | - add_filter( 'gravityview_js_dependencies', array( $this, 'add_datepicker_js_dependency' ) ); |
|
1052 | - add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
|
1051 | + add_filter('gravityview_js_dependencies', array($this, 'add_datepicker_js_dependency')); |
|
1052 | + add_filter('gravityview_js_localization', array($this, 'add_datepicker_localization'), 10, 2); |
|
1053 | 1053 | |
1054 | 1054 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1055 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1055 | + wp_enqueue_style('jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css'); |
|
1056 | 1056 | |
1057 | 1057 | /** |
1058 | 1058 | * @filter `gravityview_search_datepicker_class` |
@@ -1067,7 +1067,7 @@ discard block |
||
1067 | 1067 | * - `ymd_dash` (yyyy-mm-dd) |
1068 | 1068 | * - `ymp_dot` (yyyy.mm.dd) |
1069 | 1069 | */ |
1070 | - $datepicker_class = apply_filters( 'gravityview_search_datepicker_class', 'gv-datepicker datepicker mdy' ); |
|
1070 | + $datepicker_class = apply_filters('gravityview_search_datepicker_class', 'gv-datepicker datepicker mdy'); |
|
1071 | 1071 | |
1072 | 1072 | $gravityview_view->datepicker_class = $datepicker_class; |
1073 | 1073 |
@@ -10,22 +10,22 @@ |
||
10 | 10 | $search_field = $gravityview_view->search_field; |
11 | 11 | |
12 | 12 | // Make sure that there are choices to display |
13 | -if( empty( $search_field['choices'] ) ) { |
|
14 | - do_action('gravityview_log_debug', 'search-field-checkbox.php - No choices for field' ); |
|
13 | +if (empty($search_field['choices'])) { |
|
14 | + do_action('gravityview_log_debug', 'search-field-checkbox.php - No choices for field'); |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
18 | 18 | ?> |
19 | 19 | <div class="gv-search-box"> |
20 | - <?php if( ! gv_empty( $search_field['label'], false ) ) { ?> |
|
21 | - <label for=search-box-<?php echo esc_attr( $search_field['name'] ); ?>><?php echo esc_html( $search_field['label'] ); ?></label> |
|
20 | + <?php if (!gv_empty($search_field['label'], false)) { ?> |
|
21 | + <label for=search-box-<?php echo esc_attr($search_field['name']); ?>><?php echo esc_html($search_field['label']); ?></label> |
|
22 | 22 | <?php } ?> |
23 | 23 | <p> |
24 | - <?php foreach( $search_field['choices'] as $choice ) { ?> |
|
24 | + <?php foreach ($search_field['choices'] as $choice) { ?> |
|
25 | 25 | |
26 | - <label for="search-box-<?php echo sanitize_html_class( $search_field['name'].$choice['value'].$choice['text'] ); ?>" class="gv-check-radio"> |
|
27 | - <input type="checkbox" name="<?php echo esc_attr( $search_field['name'] ); ?>[]" value="<?php echo esc_attr( $choice['value'] ); ?>" id="search-box-<?php echo sanitize_html_class( $search_field['name'].$choice['value'].$choice['text'] ); ?>" <?php gv_selected( $choice['value'], $search_field['value'], true, 'checked' ); ?>> |
|
28 | - <?php echo esc_html( $choice['text'] ); ?> |
|
26 | + <label for="search-box-<?php echo sanitize_html_class($search_field['name'].$choice['value'].$choice['text']); ?>" class="gv-check-radio"> |
|
27 | + <input type="checkbox" name="<?php echo esc_attr($search_field['name']); ?>[]" value="<?php echo esc_attr($choice['value']); ?>" id="search-box-<?php echo sanitize_html_class($search_field['name'].$choice['value'].$choice['text']); ?>" <?php gv_selected($choice['value'], $search_field['value'], true, 'checked'); ?>> |
|
28 | + <?php echo esc_html($choice['text']); ?> |
|
29 | 29 | </label> |
30 | 30 | |
31 | 31 | <?php } ?> |
@@ -11,10 +11,10 @@ |
||
11 | 11 | ?> |
12 | 12 | |
13 | 13 | <div class="gv-search-box"> |
14 | - <?php if( ! gv_empty( $search_field['label'], false ) ) { ?> |
|
15 | - <label for=search-box-<?php echo esc_attr( $search_field['name'] ); ?>><?php echo esc_html( $search_field['label'] ); ?></label> |
|
14 | + <?php if (!gv_empty($search_field['label'], false)) { ?> |
|
15 | + <label for=search-box-<?php echo esc_attr($search_field['name']); ?>><?php echo esc_html($search_field['label']); ?></label> |
|
16 | 16 | <?php } ?> |
17 | 17 | <p> |
18 | - <input type="text" name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" value="<?php echo esc_attr( $search_field['value'] ); ?>" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" > |
|
18 | + <input type="text" name="<?php echo esc_attr($search_field['name']); ?>" id="search-box-<?php echo esc_attr($search_field['name']); ?>" value="<?php echo esc_attr($search_field['value']); ?>" class="<?php echo esc_html($gravityview_view->datepicker_class); ?>" > |
|
19 | 19 | </p> |
20 | 20 | </div> |
21 | 21 | \ No newline at end of file |
@@ -13,11 +13,11 @@ |
||
13 | 13 | ?> |
14 | 14 | |
15 | 15 | <div class="gv-search-box gv-search-date"> |
16 | - <?php if( ! gv_empty( $label, false ) ) { ?> |
|
17 | - <label for="search-box-<?php echo esc_attr( $name ).'-start'; ?>"><?php echo esc_html( $label ); ?></label> |
|
16 | + <?php if (!gv_empty($label, false)) { ?> |
|
17 | + <label for="search-box-<?php echo esc_attr($name).'-start'; ?>"><?php echo esc_html($label); ?></label> |
|
18 | 18 | <?php } ?> |
19 | 19 | <p> |
20 | - <input name="<?php echo esc_attr( $name ).'[start]'; ?>" id="search-box-<?php echo esc_attr( $name ).'-start'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('Start date', 'gravityview' ); ?>" value="<?php echo $value['start']; ?>"> |
|
21 | - <input name="<?php echo esc_attr( $name ).'[end]'; ?>" id="search-box-<?php echo esc_attr( $name ).'-end'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('End date', 'gravityview' ); ?>" value="<?php echo $value['end']; ?>"> |
|
20 | + <input name="<?php echo esc_attr($name).'[start]'; ?>" id="search-box-<?php echo esc_attr($name).'-start'; ?>" type="text" class="<?php echo esc_html($gravityview_view->datepicker_class); ?>" placeholder="<?php esc_attr_e('Start date', 'gravityview'); ?>" value="<?php echo $value['start']; ?>"> |
|
21 | + <input name="<?php echo esc_attr($name).'[end]'; ?>" id="search-box-<?php echo esc_attr($name).'-end'; ?>" type="text" class="<?php echo esc_html($gravityview_view->datepicker_class); ?>" placeholder="<?php esc_attr_e('End date', 'gravityview'); ?>" value="<?php echo $value['end']; ?>"> |
|
22 | 22 | </p> |
23 | 23 | </div> |
24 | 24 | \ No newline at end of file |
@@ -13,11 +13,11 @@ |
||
13 | 13 | ?> |
14 | 14 | |
15 | 15 | <div class="gv-search-box gv-search-date"> |
16 | - <?php if( ! gv_empty( $label, false ) ) { ?> |
|
17 | - <label for="gv_start_date_<?php echo $view_id; ?>"><?php echo esc_html( $label ); ?></label> |
|
16 | + <?php if (!gv_empty($label, false)) { ?> |
|
17 | + <label for="gv_start_date_<?php echo $view_id; ?>"><?php echo esc_html($label); ?></label> |
|
18 | 18 | <?php } ?> |
19 | 19 | <p> |
20 | - <input name="gv_start" id="gv_start_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('Start date', 'gravityview' ); ?>" value="<?php echo $value['start']; ?>"> |
|
21 | - <input name="gv_end" id="gv_end_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('End date', 'gravityview' ); ?>" value="<?php echo $value['end']; ?>"> |
|
20 | + <input name="gv_start" id="gv_start_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_html($gravityview_view->datepicker_class); ?>" placeholder="<?php esc_attr_e('Start date', 'gravityview'); ?>" value="<?php echo $value['start']; ?>"> |
|
21 | + <input name="gv_end" id="gv_end_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_html($gravityview_view->datepicker_class); ?>" placeholder="<?php esc_attr_e('End date', 'gravityview'); ?>" value="<?php echo $value['end']; ?>"> |
|
22 | 22 | </p> |
23 | 23 | </div> |
24 | 24 | \ No newline at end of file |
@@ -13,8 +13,8 @@ |
||
13 | 13 | |
14 | 14 | <div class="gv-search-box"> |
15 | 15 | <div class="gv-search"> |
16 | - <?php if( ! gv_empty( $label, false ) ) { ?> |
|
17 | - <label for="gv_entry_id_<?php echo $view_id; ?>"><?php echo esc_html( $label ); ?></label> |
|
16 | + <?php if (!gv_empty($label, false)) { ?> |
|
17 | + <label for="gv_entry_id_<?php echo $view_id; ?>"><?php echo esc_html($label); ?></label> |
|
18 | 18 | <?php } ?> |
19 | 19 | <p><input type="text" name="gv_id" id="gv_entry_id_<?php echo $view_id; ?>" value="<?php echo $value; ?>" /></p> |
20 | 20 | </div> |