@@ -414,7 +414,6 @@ discard block |
||
414 | 414 | * Render the HTML for an input text to be used on the field & widgets options |
415 | 415 | * @param string $name Unique name of the field. Exampe: `fields[directory_list-title][5374ff6ab128b][custom_label]` |
416 | 416 | * @param string $current [current value] |
417 | - * @param string $desc Option description |
|
418 | 417 | * @param string $add_merge_tags Add merge tags to the input? |
419 | 418 | * @return string [html tags] |
420 | 419 | */ |
@@ -444,7 +443,6 @@ discard block |
||
444 | 443 | * Render the HTML for an textarea input to be used on the field & widgets options |
445 | 444 | * @param string $name Unique name of the field. Exampe: `fields[directory_list-title][5374ff6ab128b][custom_label]` |
446 | 445 | * @param string $current [current value] |
447 | - * @param string $desc Option description |
|
448 | 446 | * @param string $add_merge_tags Add merge tags to the input? |
449 | 447 | * @return string [html tags] |
450 | 448 | */ |
@@ -23,53 +23,53 @@ discard block |
||
23 | 23 | * @param string $input_type (textarea, list, select, etc.) |
24 | 24 | * @return array Array of field options with `label`, `value`, `type`, `default` keys |
25 | 25 | */ |
26 | - public static function get_default_field_options( $field_type, $template_id, $field_id, $context, $input_type ) { |
|
26 | + public static function get_default_field_options($field_type, $template_id, $field_id, $context, $input_type) { |
|
27 | 27 | |
28 | 28 | $field_options = array(); |
29 | 29 | |
30 | - if( 'field' === $field_type ) { |
|
30 | + if ('field' === $field_type) { |
|
31 | 31 | |
32 | 32 | // Default options - fields |
33 | 33 | $field_options = array( |
34 | 34 | 'show_label' => array( |
35 | 35 | 'type' => 'checkbox', |
36 | - 'label' => __( 'Show Label', 'gravityview' ), |
|
36 | + 'label' => __('Show Label', 'gravityview'), |
|
37 | 37 | 'value' => true, |
38 | 38 | ), |
39 | 39 | 'custom_label' => array( |
40 | 40 | 'type' => 'text', |
41 | - 'label' => __( 'Custom Label:', 'gravityview' ), |
|
41 | + 'label' => __('Custom Label:', 'gravityview'), |
|
42 | 42 | 'value' => '', |
43 | 43 | 'merge_tags' => true, |
44 | 44 | ), |
45 | 45 | 'custom_class' => array( |
46 | 46 | 'type' => 'text', |
47 | - 'label' => __( 'Custom CSS Class:', 'gravityview' ), |
|
48 | - 'desc' => __( 'This class will be added to the field container', 'gravityview'), |
|
47 | + 'label' => __('Custom CSS Class:', 'gravityview'), |
|
48 | + 'desc' => __('This class will be added to the field container', 'gravityview'), |
|
49 | 49 | 'value' => '', |
50 | 50 | 'merge_tags' => true, |
51 | 51 | 'tooltip' => 'gv_css_merge_tags', |
52 | 52 | ), |
53 | 53 | 'only_loggedin' => array( |
54 | 54 | 'type' => 'checkbox', |
55 | - 'label' => __( 'Make visible only to logged-in users?', 'gravityview' ), |
|
55 | + 'label' => __('Make visible only to logged-in users?', 'gravityview'), |
|
56 | 56 | 'value' => '' |
57 | 57 | ), |
58 | 58 | 'only_loggedin_cap' => array( |
59 | 59 | 'type' => 'select', |
60 | - 'label' => __( 'Make visible for:', 'gravityview' ), |
|
61 | - 'options' => self::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
|
60 | + 'label' => __('Make visible for:', 'gravityview'), |
|
61 | + 'options' => self::get_cap_choices($template_id, $field_id, $context, $input_type), |
|
62 | 62 | 'class' => 'widefat', |
63 | 63 | 'value' => 'read', |
64 | 64 | ), |
65 | 65 | ); |
66 | 66 | |
67 | 67 | // Match Table as well as DataTables |
68 | - if( preg_match( '/table/ism', $template_id ) && 'single' !== $context ) { |
|
68 | + if (preg_match('/table/ism', $template_id) && 'single' !== $context) { |
|
69 | 69 | $field_options['width'] = array( |
70 | 70 | 'type' => 'number', |
71 | 71 | 'label' => __('Percent Width', 'gravityview'), |
72 | - 'desc' => __( 'Leave blank for column width to be based on the field content.', 'gravityview'), |
|
72 | + 'desc' => __('Leave blank for column width to be based on the field content.', 'gravityview'), |
|
73 | 73 | 'class' => 'code widefat', |
74 | 74 | 'value' => '', |
75 | 75 | ); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param[in] string $context What context are we in? Example: `single` or `directory` |
86 | 86 | * @param[in] string $input_type (textarea, list, select, etc.) |
87 | 87 | */ |
88 | - $field_options = apply_filters( "gravityview_template_{$field_type}_options", $field_options, $template_id, $field_id, $context, $input_type ); |
|
88 | + $field_options = apply_filters("gravityview_template_{$field_type}_options", $field_options, $template_id, $field_id, $context, $input_type); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @filter `gravityview_template_{$input_type}_options` Filter the field options by input type (`$input_type` examples: `textarea`, `list`, `select`, etc.) |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @param[in] string $context What context are we in? Example: `single` or `directory` |
96 | 96 | * @param[in] string $input_type (textarea, list, select, etc.) |
97 | 97 | */ |
98 | - $field_options = apply_filters( "gravityview_template_{$input_type}_options", $field_options, $template_id, $field_id, $context, $input_type ); |
|
98 | + $field_options = apply_filters("gravityview_template_{$input_type}_options", $field_options, $template_id, $field_id, $context, $input_type); |
|
99 | 99 | |
100 | 100 | return $field_options; |
101 | 101 | } |
@@ -111,19 +111,19 @@ discard block |
||
111 | 111 | * @param string $input_type Optional. (textarea, list, select, etc.) |
112 | 112 | * @return array Associative array, with the key being the capability and the value being the label shown. |
113 | 113 | */ |
114 | - static public function get_cap_choices( $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
|
114 | + static public function get_cap_choices($template_id = '', $field_id = '', $context = '', $input_type = '') { |
|
115 | 115 | |
116 | 116 | $select_cap_choices = array( |
117 | - 'read' => __( 'Any Logged-In User', 'gravityview' ), |
|
118 | - 'publish_posts' => __( 'Author Or Higher', 'gravityview' ), |
|
119 | - 'gravityforms_view_entries' => __( 'Can View Gravity Forms Entries', 'gravityview' ), |
|
120 | - 'delete_others_posts' => __( 'Editor Or Higher', 'gravityview' ), |
|
121 | - 'gravityforms_edit_entries' => __( 'Can Edit Gravity Forms Entries', 'gravityview' ), |
|
122 | - 'manage_options' => __( 'Administrator', 'gravityview' ), |
|
117 | + 'read' => __('Any Logged-In User', 'gravityview'), |
|
118 | + 'publish_posts' => __('Author Or Higher', 'gravityview'), |
|
119 | + 'gravityforms_view_entries' => __('Can View Gravity Forms Entries', 'gravityview'), |
|
120 | + 'delete_others_posts' => __('Editor Or Higher', 'gravityview'), |
|
121 | + 'gravityforms_edit_entries' => __('Can Edit Gravity Forms Entries', 'gravityview'), |
|
122 | + 'manage_options' => __('Administrator', 'gravityview'), |
|
123 | 123 | ); |
124 | 124 | |
125 | - if( is_multisite() ) { |
|
126 | - $select_cap_choices['manage_network'] = __('Multisite Super Admin', 'gravityview' ); |
|
125 | + if (is_multisite()) { |
|
126 | + $select_cap_choices['manage_network'] = __('Multisite Super Admin', 'gravityview'); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param string $context Optional. What context are we in? Example: `single` or `directory` |
137 | 137 | * @param string $input_type Optional. (textarea, list, select, etc.) |
138 | 138 | */ |
139 | - $select_cap_choices = apply_filters('gravityview_field_visibility_caps', $select_cap_choices, $template_id, $field_id, $context, $input_type ); |
|
139 | + $select_cap_choices = apply_filters('gravityview_field_visibility_caps', $select_cap_choices, $template_id, $field_id, $context, $input_type); |
|
140 | 140 | |
141 | 141 | return $select_cap_choices; |
142 | 142 | } |
@@ -161,26 +161,26 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @return string HTML of dialog box |
163 | 163 | */ |
164 | - public static function render_field_options( $field_type, $template_id, $field_id, $field_label, $area, $input_type = NULL, $uniqid = '', $current = '', $context = 'single', $item = array() ) { |
|
164 | + public static function render_field_options($field_type, $template_id, $field_id, $field_label, $area, $input_type = NULL, $uniqid = '', $current = '', $context = 'single', $item = array()) { |
|
165 | 165 | |
166 | - if( empty( $uniqid ) ) { |
|
166 | + if (empty($uniqid)) { |
|
167 | 167 | //generate a unique field id |
168 | 168 | $uniqid = uniqid('', false); |
169 | 169 | } |
170 | 170 | |
171 | 171 | // get field/widget options |
172 | - $options = self::get_default_field_options( $field_type, $template_id, $field_id, $context, $input_type ); |
|
172 | + $options = self::get_default_field_options($field_type, $template_id, $field_id, $context, $input_type); |
|
173 | 173 | |
174 | 174 | // two different post arrays, depending of the field type |
175 | - $name_prefix = $field_type .'s' .'['. $area .']['. $uniqid .']'; |
|
175 | + $name_prefix = $field_type.'s'.'['.$area.']['.$uniqid.']'; |
|
176 | 176 | |
177 | 177 | // build output |
178 | 178 | $output = ''; |
179 | - $output .= '<input type="hidden" class="field-key" name="'. $name_prefix .'[id]" value="'. esc_attr( $field_id ) .'">'; |
|
180 | - $output .= '<input type="hidden" class="field-label" name="'. $name_prefix .'[label]" value="'. esc_attr( $field_label ) .'">'; |
|
179 | + $output .= '<input type="hidden" class="field-key" name="'.$name_prefix.'[id]" value="'.esc_attr($field_id).'">'; |
|
180 | + $output .= '<input type="hidden" class="field-label" name="'.$name_prefix.'[label]" value="'.esc_attr($field_label).'">'; |
|
181 | 181 | |
182 | 182 | // If there are no options, return what we got. |
183 | - if(empty($options)) { |
|
183 | + if (empty($options)) { |
|
184 | 184 | |
185 | 185 | // This is here for checking if the output is empty in render_label() |
186 | 186 | $output .= '<!-- No Options -->'; |
@@ -188,33 +188,33 @@ discard block |
||
188 | 188 | return $output; |
189 | 189 | } |
190 | 190 | |
191 | - $output .= '<div class="gv-dialog-options" title="'. esc_attr( sprintf( __( 'Options: %s', 'gravityview' ) , strip_tags( html_entity_decode( $field_label ) ) ) ) .'">'; |
|
191 | + $output .= '<div class="gv-dialog-options" title="'.esc_attr(sprintf(__('Options: %s', 'gravityview'), strip_tags(html_entity_decode($field_label)))).'">'; |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * @since 1.8 |
195 | 195 | */ |
196 | - if( !empty( $item['subtitle'] ) ) { |
|
197 | - $output .= '<div class="subtitle">' . $item['subtitle'] . '</div>'; |
|
196 | + if (!empty($item['subtitle'])) { |
|
197 | + $output .= '<div class="subtitle">'.$item['subtitle'].'</div>'; |
|
198 | 198 | } |
199 | 199 | |
200 | - foreach( $options as $key => $option ) { |
|
200 | + foreach ($options as $key => $option) { |
|
201 | 201 | |
202 | - $value = isset( $current[ $key ] ) ? $current[ $key ] : NULL; |
|
202 | + $value = isset($current[$key]) ? $current[$key] : NULL; |
|
203 | 203 | |
204 | - $field_output = self::render_field_option( $name_prefix . '['. $key .']' , $option, $value); |
|
204 | + $field_output = self::render_field_option($name_prefix.'['.$key.']', $option, $value); |
|
205 | 205 | |
206 | 206 | // The setting is empty |
207 | - if( empty( $field_output ) ) { |
|
207 | + if (empty($field_output)) { |
|
208 | 208 | continue; |
209 | 209 | } |
210 | 210 | |
211 | - switch( $option['type'] ) { |
|
211 | + switch ($option['type']) { |
|
212 | 212 | // Hide hidden fields |
213 | 213 | case 'hidden': |
214 | - $output .= '<div class="gv-setting-container gv-setting-container-'. esc_attr( $key ) . ' screen-reader-text">'. $field_output . '</div>'; |
|
214 | + $output .= '<div class="gv-setting-container gv-setting-container-'.esc_attr($key).' screen-reader-text">'.$field_output.'</div>'; |
|
215 | 215 | break; |
216 | 216 | default: |
217 | - $output .= '<div class="gv-setting-container gv-setting-container-'. esc_attr( $key ) . '">'. $field_output .'</div>'; |
|
217 | + $output .= '<div class="gv-setting-container gv-setting-container-'.esc_attr($key).'">'.$field_output.'</div>'; |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @param mixed $curr_value Current value of option |
236 | 236 | * @return string HTML output of option |
237 | 237 | */ |
238 | - public static function render_field_option( $name = '', $option, $curr_value = NULL ) { |
|
238 | + public static function render_field_option($name = '', $option, $curr_value = NULL) { |
|
239 | 239 | |
240 | 240 | $output = ''; |
241 | 241 | |
@@ -243,19 +243,19 @@ discard block |
||
243 | 243 | * @deprecated setting index 'default' was replaced by 'value' |
244 | 244 | * @see GravityView_FieldType::get_field_defaults |
245 | 245 | */ |
246 | - if( !empty( $option['default'] ) && empty( $option['value'] ) ) { |
|
246 | + if (!empty($option['default']) && empty($option['value'])) { |
|
247 | 247 | $option['value'] = $option['default']; |
248 | - _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[value] instead of [default] when defining the setting '. $name .' details' ); |
|
248 | + _deprecated_function('GravityView_FieldType::get_field_defaults', '1.1.7', '[value] instead of [default] when defining the setting '.$name.' details'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | // prepare to render option field type |
252 | - if( isset( $option['type'] ) ) { |
|
252 | + if (isset($option['type'])) { |
|
253 | 253 | |
254 | - $type_class = self::load_type_class( $option ); |
|
254 | + $type_class = self::load_type_class($option); |
|
255 | 255 | |
256 | - if( class_exists( $type_class ) ) { |
|
256 | + if (class_exists($type_class)) { |
|
257 | 257 | |
258 | - $render_type = new $type_class( $name, $option, $curr_value ); |
|
258 | + $render_type = new $type_class($name, $option, $curr_value); |
|
259 | 259 | |
260 | 260 | ob_start(); |
261 | 261 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @param[in,out] string $output field class name |
270 | 270 | * @param[in] array $option option field data |
271 | 271 | */ |
272 | - $output = apply_filters( "gravityview/option/output/{$option['type']}" , $output, $option ); |
|
272 | + $output = apply_filters("gravityview/option/output/{$option['type']}", $output, $option); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | } // isset option[type] |
@@ -291,35 +291,35 @@ discard block |
||
291 | 291 | * @param string $id [description] |
292 | 292 | * @return [type] [description] |
293 | 293 | */ |
294 | - public static function render_setting_row( $key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s' ) { |
|
294 | + public static function render_setting_row($key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s') { |
|
295 | 295 | |
296 | - $setting = GravityView_View_Data::get_default_arg( $key, true ); |
|
296 | + $setting = GravityView_View_Data::get_default_arg($key, true); |
|
297 | 297 | |
298 | 298 | // If the key doesn't exist, there's something wrong. |
299 | - if( empty( $setting ) ) { return; } |
|
299 | + if (empty($setting)) { return; } |
|
300 | 300 | |
301 | 301 | /** |
302 | 302 | * @deprecated setting index 'name' was replaced by 'label' |
303 | 303 | * @see GravityView_FieldType::get_field_defaults |
304 | 304 | */ |
305 | - if( isset( $setting['name'] ) && empty( $setting['label'] ) ) { |
|
305 | + if (isset($setting['name']) && empty($setting['label'])) { |
|
306 | 306 | $setting['label'] = $setting['name']; |
307 | - _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting '. $key .' details' ); |
|
307 | + _deprecated_function('GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting '.$key.' details'); |
|
308 | 308 | } |
309 | 309 | |
310 | - $name = esc_attr( sprintf( $name, $key ) ); |
|
311 | - $setting['id'] = esc_attr( sprintf( $id, $key ) ); |
|
312 | - $setting['tooltip'] = 'gv_' . $key; |
|
310 | + $name = esc_attr(sprintf($name, $key)); |
|
311 | + $setting['id'] = esc_attr(sprintf($id, $key)); |
|
312 | + $setting['tooltip'] = 'gv_'.$key; |
|
313 | 313 | |
314 | 314 | // Use default if current setting isn't set. |
315 | - $curr_value = isset( $current_settings[ $key ] ) ? $current_settings[ $key ] : $setting['value']; |
|
315 | + $curr_value = isset($current_settings[$key]) ? $current_settings[$key] : $setting['value']; |
|
316 | 316 | |
317 | 317 | // default setting type = text |
318 | - $setting['type'] = empty( $setting['type'] ) ? 'text' : $setting['type']; |
|
318 | + $setting['type'] = empty($setting['type']) ? 'text' : $setting['type']; |
|
319 | 319 | |
320 | 320 | // merge tags |
321 | - if( !isset( $setting['merge_tags'] ) ) { |
|
322 | - if( $setting['type'] === 'text' ) { |
|
321 | + if (!isset($setting['merge_tags'])) { |
|
322 | + if ($setting['type'] === 'text') { |
|
323 | 323 | $setting['merge_tags'] = true; |
324 | 324 | } else { |
325 | 325 | $setting['merge_tags'] = false; |
@@ -327,26 +327,26 @@ discard block |
||
327 | 327 | } |
328 | 328 | |
329 | 329 | // render the setting |
330 | - $type_class = self::load_type_class( $setting ); |
|
331 | - if( class_exists( $type_class ) ) { |
|
332 | - $render_type = new $type_class( $name, $setting, $curr_value ); |
|
330 | + $type_class = self::load_type_class($setting); |
|
331 | + if (class_exists($type_class)) { |
|
332 | + $render_type = new $type_class($name, $setting, $curr_value); |
|
333 | 333 | ob_start(); |
334 | - $render_type->render_setting( $override_input ); |
|
334 | + $render_type->render_setting($override_input); |
|
335 | 335 | $output = ob_get_clean(); |
336 | 336 | } |
337 | 337 | |
338 | 338 | // Check if setting is specific for a template |
339 | - if( !empty( $setting['show_in_template'] ) ) { |
|
340 | - if( !is_array( $setting['show_in_template'] ) ) { |
|
341 | - $setting['show_in_template'] = array( $setting['show_in_template'] ); |
|
339 | + if (!empty($setting['show_in_template'])) { |
|
340 | + if (!is_array($setting['show_in_template'])) { |
|
341 | + $setting['show_in_template'] = array($setting['show_in_template']); |
|
342 | 342 | } |
343 | - $show_if = ' data-show-if="'. implode( ' ', $setting['show_in_template'] ).'"'; |
|
343 | + $show_if = ' data-show-if="'.implode(' ', $setting['show_in_template']).'"'; |
|
344 | 344 | } else { |
345 | 345 | $show_if = ''; |
346 | 346 | } |
347 | 347 | |
348 | 348 | // output |
349 | - echo '<tr valign="top" '. $show_if .'>' . $output . '</tr>'; |
|
349 | + echo '<tr valign="top" '.$show_if.'>'.$output.'</tr>'; |
|
350 | 350 | |
351 | 351 | } |
352 | 352 | |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | * @param array $field |
357 | 357 | * @return string type class name |
358 | 358 | */ |
359 | - public static function load_type_class( $field = NULL ) { |
|
359 | + public static function load_type_class($field = NULL) { |
|
360 | 360 | |
361 | - if( empty( $field['type'] ) ) { |
|
361 | + if (empty($field['type'])) { |
|
362 | 362 | return NULL; |
363 | 363 | } |
364 | 364 | |
@@ -367,20 +367,20 @@ discard block |
||
367 | 367 | * @param string $class_suffix field class suffix; `GravityView_FieldType_{$class_suffix}` |
368 | 368 | * @param array $field field data |
369 | 369 | */ |
370 | - $type_class = apply_filters( "gravityview/setting/class/{$field['type']}", 'GravityView_FieldType_' . $field['type'], $field ); |
|
370 | + $type_class = apply_filters("gravityview/setting/class/{$field['type']}", 'GravityView_FieldType_'.$field['type'], $field); |
|
371 | 371 | |
372 | - if( !class_exists( $type_class ) ) { |
|
372 | + if (!class_exists($type_class)) { |
|
373 | 373 | |
374 | 374 | /** |
375 | 375 | * @filter `gravityview/setting/class_file/{field_type}` |
376 | 376 | * @param string $field_type_include_path field class file path |
377 | 377 | * @param array $field field data |
378 | 378 | */ |
379 | - $class_file = apply_filters( "gravityview/setting/class_file/{$field['type']}", GRAVITYVIEW_DIR . "includes/admin/field-types/type_{$field['type']}.php", $field ); |
|
379 | + $class_file = apply_filters("gravityview/setting/class_file/{$field['type']}", GRAVITYVIEW_DIR."includes/admin/field-types/type_{$field['type']}.php", $field); |
|
380 | 380 | |
381 | - if( $class_file ) { |
|
382 | - if( file_exists( $class_file ) ) { |
|
383 | - require_once( $class_file ); |
|
381 | + if ($class_file) { |
|
382 | + if (file_exists($class_file)) { |
|
383 | + require_once($class_file); |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
@@ -400,10 +400,10 @@ discard block |
||
400 | 400 | * @param string $current current value |
401 | 401 | * @return string html tags |
402 | 402 | */ |
403 | - public static function render_checkbox_option( $name = '', $id = '', $current = '' ) { |
|
403 | + public static function render_checkbox_option($name = '', $id = '', $current = '') { |
|
404 | 404 | |
405 | - $output = '<input name="'. esc_attr( $name ) .'" type="hidden" value="0">'; |
|
406 | - $output .= '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="checkbox" value="1" '. checked( $current, '1', false ) .' >'; |
|
405 | + $output = '<input name="'.esc_attr($name).'" type="hidden" value="0">'; |
|
406 | + $output .= '<input name="'.esc_attr($name).'" id="'.esc_attr($id).'" type="checkbox" value="1" '.checked($current, '1', false).' >'; |
|
407 | 407 | |
408 | 408 | return $output; |
409 | 409 | } |
@@ -418,25 +418,25 @@ discard block |
||
418 | 418 | * @param string $add_merge_tags Add merge tags to the input? |
419 | 419 | * @return string [html tags] |
420 | 420 | */ |
421 | - public static function render_text_option( $name = '', $id = '', $current = '', $add_merge_tags = NULL, $args = array() ) { |
|
421 | + public static function render_text_option($name = '', $id = '', $current = '', $add_merge_tags = NULL, $args = array()) { |
|
422 | 422 | |
423 | 423 | // Show the merge tags if the field is a list view |
424 | - $is_list = ( preg_match( '/_list-/ism', $name )); |
|
424 | + $is_list = (preg_match('/_list-/ism', $name)); |
|
425 | 425 | |
426 | 426 | // Or is a single entry view |
427 | - $is_single = ( preg_match( '/single_/ism', $name )); |
|
428 | - $show = ( $is_single || $is_list ); |
|
427 | + $is_single = (preg_match('/single_/ism', $name)); |
|
428 | + $show = ($is_single || $is_list); |
|
429 | 429 | |
430 | 430 | $class = ''; |
431 | 431 | // and $add_merge_tags is not false |
432 | - if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
432 | + if ($show && $add_merge_tags !== false || $add_merge_tags === 'force') { |
|
433 | 433 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
434 | 434 | } |
435 | 435 | |
436 | - $class .= !empty( $args['class'] ) ? $args['class'] : 'widefat'; |
|
437 | - $type = !empty( $args['type'] ) ? $args['type'] : 'text'; |
|
436 | + $class .= !empty($args['class']) ? $args['class'] : 'widefat'; |
|
437 | + $type = !empty($args['type']) ? $args['type'] : 'text'; |
|
438 | 438 | |
439 | - return '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="'.esc_attr($type).'" value="'. esc_attr( $current ) .'" class="'.esc_attr( $class ).'">'; |
|
439 | + return '<input name="'.esc_attr($name).'" id="'.esc_attr($id).'" type="'.esc_attr($type).'" value="'.esc_attr($current).'" class="'.esc_attr($class).'">'; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -448,25 +448,25 @@ discard block |
||
448 | 448 | * @param string $add_merge_tags Add merge tags to the input? |
449 | 449 | * @return string [html tags] |
450 | 450 | */ |
451 | - public static function render_textarea_option( $name = '', $id = '', $current = '', $add_merge_tags = NULL, $args = array() ) { |
|
451 | + public static function render_textarea_option($name = '', $id = '', $current = '', $add_merge_tags = NULL, $args = array()) { |
|
452 | 452 | |
453 | 453 | // Show the merge tags if the field is a list view |
454 | - $is_list = ( preg_match( '/_list-/ism', $name )); |
|
454 | + $is_list = (preg_match('/_list-/ism', $name)); |
|
455 | 455 | |
456 | 456 | // Or is a single entry view |
457 | - $is_single = ( preg_match( '/single_/ism', $name )); |
|
458 | - $show = ( $is_single || $is_list ); |
|
457 | + $is_single = (preg_match('/single_/ism', $name)); |
|
458 | + $show = ($is_single || $is_list); |
|
459 | 459 | |
460 | 460 | $class = ''; |
461 | 461 | // and $add_merge_tags is not false |
462 | - if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
462 | + if ($show && $add_merge_tags !== false || $add_merge_tags === 'force') { |
|
463 | 463 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
464 | 464 | } |
465 | 465 | |
466 | - $class .= !empty( $args['class'] ) ? 'widefat '.$args['class'] : 'widefat'; |
|
467 | - $type = !empty( $args['type'] ) ? $args['type'] : 'text'; |
|
466 | + $class .= !empty($args['class']) ? 'widefat '.$args['class'] : 'widefat'; |
|
467 | + $type = !empty($args['type']) ? $args['type'] : 'text'; |
|
468 | 468 | |
469 | - return '<textarea name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" class="'.esc_attr( $class ).'">'. esc_textarea( $current ) .'</textarea>'; |
|
469 | + return '<textarea name="'.esc_attr($name).'" id="'.esc_attr($id).'" class="'.esc_attr($class).'">'.esc_textarea($current).'</textarea>'; |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | /** |
@@ -478,11 +478,11 @@ discard block |
||
478 | 478 | * @param string $current [current value] |
479 | 479 | * @return string [html tags] |
480 | 480 | */ |
481 | - public static function render_select_option( $name = '', $id = '', $choices, $current = '' ) { |
|
481 | + public static function render_select_option($name = '', $id = '', $choices, $current = '') { |
|
482 | 482 | |
483 | - $output = '<select name="'. $name .'" id="'. $id .'">'; |
|
484 | - foreach( $choices as $value => $label ) { |
|
485 | - $output .= '<option value="'. esc_attr( $value ) .'" '. selected( $value, $current, false ) .'>'. esc_html( $label ) .'</option>'; |
|
483 | + $output = '<select name="'.$name.'" id="'.$id.'">'; |
|
484 | + foreach ($choices as $value => $label) { |
|
485 | + $output .= '<option value="'.esc_attr($value).'" '.selected($value, $current, false).'>'.esc_html($label).'</option>'; |
|
486 | 486 | } |
487 | 487 | $output .= '</select>'; |
488 | 488 |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | /** |
215 | 215 | * Generate the script tags necessary for the Gravity Forms Merge Tag picker to work. |
216 | 216 | * |
217 | - * @param mixed $curr_form Form ID |
|
217 | + * @param string $curr_form Form ID |
|
218 | 218 | * @return null|string Merge tags html; NULL if $curr_form isn't defined. |
219 | 219 | */ |
220 | 220 | public static function render_merge_tags_scripts( $curr_form ) { |
@@ -290,7 +290,6 @@ discard block |
||
290 | 290 | * Render shortcode hint in the Publish metabox |
291 | 291 | * |
292 | 292 | * @access public |
293 | - * @param object $post |
|
294 | 293 | * @return void |
295 | 294 | */ |
296 | 295 | function render_shortcode_hint() { |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | if( !GravityView_Compatibility::is_valid() ) { return; } |
16 | 16 | |
17 | - self::$metaboxes_dir = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/'; |
|
17 | + self::$metaboxes_dir = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/'; |
|
18 | 18 | |
19 | 19 | include_once self::$metaboxes_dir . 'class-gravityview-metabox-tab.php'; |
20 | 20 | |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | $get_id_backup = isset($_GET['id']) ? $_GET['id'] : NULL; |
229 | 229 | |
230 | 230 | if( isset( $form['id'] ) ) { |
231 | - $form_script = 'var form = ' . GFCommon::json_encode($form) . ';'; |
|
231 | + $form_script = 'var form = ' . GFCommon::json_encode($form) . ';'; |
|
232 | 232 | |
233 | - // The `gf_vars()` method needs a $_GET[id] variable set with the form ID. |
|
234 | - $_GET['id'] = $form['id']; |
|
233 | + // The `gf_vars()` method needs a $_GET[id] variable set with the form ID. |
|
234 | + $_GET['id'] = $form['id']; |
|
235 | 235 | |
236 | 236 | } else { |
237 | - $form_script = 'var form = new Form();'; |
|
237 | + $form_script = 'var form = new Form();'; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | $output = '<script type="text/javascript" data-gv-merge-tags="1">' . $form_script . "\n" . GFCommon::gf_vars(false) . '</script>'; |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | */ |
13 | 13 | function __construct() { |
14 | 14 | |
15 | - if( !GravityView_Compatibility::is_valid() ) { return; } |
|
15 | + if (!GravityView_Compatibility::is_valid()) { return; } |
|
16 | 16 | |
17 | - self::$metaboxes_dir = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/'; |
|
17 | + self::$metaboxes_dir = GRAVITYVIEW_DIR.'includes/admin/metaboxes/'; |
|
18 | 18 | |
19 | - include_once self::$metaboxes_dir . 'class-gravityview-metabox-tab.php'; |
|
19 | + include_once self::$metaboxes_dir.'class-gravityview-metabox-tab.php'; |
|
20 | 20 | |
21 | - include_once self::$metaboxes_dir . 'class-gravityview-metabox-tabs.php'; |
|
21 | + include_once self::$metaboxes_dir.'class-gravityview-metabox-tabs.php'; |
|
22 | 22 | |
23 | 23 | $this->initialize(); |
24 | 24 | |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | */ |
31 | 31 | function initialize() { |
32 | 32 | |
33 | - add_action( 'add_meta_boxes', array( $this, 'register_metaboxes' )); |
|
33 | + add_action('add_meta_boxes', array($this, 'register_metaboxes')); |
|
34 | 34 | |
35 | - add_action( 'add_meta_boxes_gravityview' , array( $this, 'update_priority' ) ); |
|
35 | + add_action('add_meta_boxes_gravityview', array($this, 'update_priority')); |
|
36 | 36 | |
37 | 37 | // information box |
38 | - add_action( 'post_submitbox_misc_actions', array( $this, 'render_shortcode_hint' ) ); |
|
38 | + add_action('post_submitbox_misc_actions', array($this, 'render_shortcode_hint')); |
|
39 | 39 | |
40 | 40 | } |
41 | 41 | |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | function update_priority() { |
47 | 47 | global $wp_meta_boxes; |
48 | 48 | |
49 | - if( ! empty( $wp_meta_boxes['gravityview'] ) ) { |
|
50 | - foreach( array( 'high', 'core', 'low' ) as $position ) { |
|
51 | - if( isset( $wp_meta_boxes['gravityview']['normal'][ $position ] ) ) { |
|
52 | - foreach( $wp_meta_boxes['gravityview']['normal'][ $position ] as $key => $meta_box ) { |
|
53 | - if( ! preg_match( '/^gravityview_/ism', $key ) ) { |
|
54 | - $wp_meta_boxes['gravityview']['advanced'][ $position ][ $key ] = $meta_box; |
|
55 | - unset( $wp_meta_boxes['gravityview']['normal'][ $position ][ $key ] ); |
|
49 | + if (!empty($wp_meta_boxes['gravityview'])) { |
|
50 | + foreach (array('high', 'core', 'low') as $position) { |
|
51 | + if (isset($wp_meta_boxes['gravityview']['normal'][$position])) { |
|
52 | + foreach ($wp_meta_boxes['gravityview']['normal'][$position] as $key => $meta_box) { |
|
53 | + if (!preg_match('/^gravityview_/ism', $key)) { |
|
54 | + $wp_meta_boxes['gravityview']['advanced'][$position][$key] = $meta_box; |
|
55 | + unset($wp_meta_boxes['gravityview']['normal'][$position][$key]); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | } |
@@ -64,23 +64,23 @@ discard block |
||
64 | 64 | global $post; |
65 | 65 | |
66 | 66 | // On Comment Edit, for example, $post isn't set. |
67 | - if( empty( $post ) || !is_object( $post ) || !isset( $post->ID ) ) { |
|
67 | + if (empty($post) || !is_object($post) || !isset($post->ID)) { |
|
68 | 68 | return; |
69 | 69 | } |
70 | 70 | |
71 | 71 | // select data source for this view |
72 | - add_meta_box( 'gravityview_select_form', $this->get_data_source_header( $post->ID ), array( $this, 'render_data_source_metabox' ), 'gravityview', 'normal', 'high' ); |
|
72 | + add_meta_box('gravityview_select_form', $this->get_data_source_header($post->ID), array($this, 'render_data_source_metabox'), 'gravityview', 'normal', 'high'); |
|
73 | 73 | |
74 | 74 | // select view type/template |
75 | - add_meta_box( 'gravityview_select_template', __( 'Choose a View Type', 'gravityview' ), array( $this, 'render_select_template_metabox' ), 'gravityview', 'normal', 'high' ); |
|
75 | + add_meta_box('gravityview_select_template', __('Choose a View Type', 'gravityview'), array($this, 'render_select_template_metabox'), 'gravityview', 'normal', 'high'); |
|
76 | 76 | |
77 | 77 | // View Configuration box |
78 | - add_meta_box( 'gravityview_view_config', __( 'View Configuration', 'gravityview' ), array( $this, 'render_view_configuration_metabox' ), 'gravityview', 'normal', 'high' ); |
|
78 | + add_meta_box('gravityview_view_config', __('View Configuration', 'gravityview'), array($this, 'render_view_configuration_metabox'), 'gravityview', 'normal', 'high'); |
|
79 | 79 | |
80 | 80 | $this->add_settings_metabox_tabs(); |
81 | 81 | |
82 | 82 | // Other Settings box |
83 | - add_meta_box( 'gravityview_settings', __( 'View Settings', 'gravityview' ), array( $this, 'settings_metabox_render' ), 'gravityview', 'normal', 'core' ); |
|
83 | + add_meta_box('gravityview_settings', __('View Settings', 'gravityview'), array($this, 'settings_metabox_render'), 'gravityview', 'normal', 'core'); |
|
84 | 84 | |
85 | 85 | } |
86 | 86 | |
@@ -89,22 +89,22 @@ discard block |
||
89 | 89 | * @since 1.8 |
90 | 90 | * @param WP_Post $post |
91 | 91 | */ |
92 | - function settings_metabox_render( $post ) { |
|
92 | + function settings_metabox_render($post) { |
|
93 | 93 | |
94 | 94 | /** |
95 | 95 | * @param WP_Post $post |
96 | 96 | */ |
97 | - do_action( 'gravityview/metaboxes/before_render', $post ); |
|
97 | + do_action('gravityview/metaboxes/before_render', $post); |
|
98 | 98 | |
99 | 99 | $metaboxes = GravityView_Metabox_Tabs::get_all(); |
100 | 100 | |
101 | - include self::$metaboxes_dir . 'views/gravityview-navigation.php'; |
|
102 | - include self::$metaboxes_dir . 'views/gravityview-content.php'; |
|
101 | + include self::$metaboxes_dir.'views/gravityview-navigation.php'; |
|
102 | + include self::$metaboxes_dir.'views/gravityview-content.php'; |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * @param WP_Post $post |
106 | 106 | */ |
107 | - do_action( 'gravityview/metaboxes/after_render', $post ); |
|
107 | + do_action('gravityview/metaboxes/after_render', $post); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $metaboxes = array( |
117 | 117 | array( |
118 | 118 | 'id' => 'template_settings', |
119 | - 'title' => __( 'View Settings', 'gravityview' ), |
|
119 | + 'title' => __('View Settings', 'gravityview'), |
|
120 | 120 | 'file' => 'view-settings.php', |
121 | 121 | 'icon-class' => 'dashicons-admin-generic', |
122 | 122 | 'callback' => '', |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | ), |
125 | 125 | array( |
126 | 126 | 'id' => 'single_entry', // Use the same ID as View Settings for backward compatibility |
127 | - 'title' => __( 'Single Entry', 'gravityview' ), |
|
127 | + 'title' => __('Single Entry', 'gravityview'), |
|
128 | 128 | 'file' => 'single-entry.php', |
129 | 129 | 'icon-class' => 'dashicons-media-default', |
130 | 130 | 'callback' => '', |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | ), |
133 | 133 | array( |
134 | 134 | 'id' => 'sort_filter', |
135 | - 'title' => __( 'Filter & Sort', 'gravityview' ), |
|
135 | + 'title' => __('Filter & Sort', 'gravityview'), |
|
136 | 136 | 'file' => 'sort-filter.php', |
137 | 137 | 'icon-class' => 'dashicons-sort', |
138 | 138 | 'callback' => '', |
@@ -145,17 +145,17 @@ discard block |
||
145 | 145 | * @param array $metaboxes |
146 | 146 | * @since 1.8 |
147 | 147 | */ |
148 | - $metaboxes = apply_filters( 'gravityview/metaboxes/default', $metaboxes ); |
|
148 | + $metaboxes = apply_filters('gravityview/metaboxes/default', $metaboxes); |
|
149 | 149 | |
150 | - foreach( $metaboxes as $m ) { |
|
150 | + foreach ($metaboxes as $m) { |
|
151 | 151 | |
152 | - $tab = new GravityView_Metabox_Tab( $m['id'], $m['title'], $m['file'], $m['icon-class'], $m['callback'], $m['callback_args'] ); |
|
152 | + $tab = new GravityView_Metabox_Tab($m['id'], $m['title'], $m['file'], $m['icon-class'], $m['callback'], $m['callback_args']); |
|
153 | 153 | |
154 | - GravityView_Metabox_Tabs::add( $tab ); |
|
154 | + GravityView_Metabox_Tabs::add($tab); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | |
158 | - unset( $tab ); |
|
158 | + unset($tab); |
|
159 | 159 | |
160 | 160 | } |
161 | 161 | |
@@ -168,18 +168,18 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return string "Data Source", plus links if any |
170 | 170 | */ |
171 | - private function get_data_source_header( $post_id ) { |
|
171 | + private function get_data_source_header($post_id) { |
|
172 | 172 | |
173 | 173 | //current value |
174 | - $current_form = gravityview_get_form_id( $post_id ); |
|
174 | + $current_form = gravityview_get_form_id($post_id); |
|
175 | 175 | |
176 | - $links = GravityView_Admin_Views::get_connected_form_links( $current_form, false ); |
|
176 | + $links = GravityView_Admin_Views::get_connected_form_links($current_form, false); |
|
177 | 177 | |
178 | - if( !empty( $links ) ) { |
|
179 | - $links = '<span class="alignright gv-form-links">'. $links .'</span>'; |
|
178 | + if (!empty($links)) { |
|
179 | + $links = '<span class="alignright gv-form-links">'.$links.'</span>'; |
|
180 | 180 | } |
181 | 181 | |
182 | - return __( 'Data Source', 'gravityview' ) . $links; |
|
182 | + return __('Data Source', 'gravityview').$links; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | * @param object $post |
190 | 190 | * @return void |
191 | 191 | */ |
192 | - function render_data_source_metabox( $post ) { |
|
192 | + function render_data_source_metabox($post) { |
|
193 | 193 | |
194 | - if( !empty( $post->ID ) ) { |
|
194 | + if (!empty($post->ID)) { |
|
195 | 195 | $this->post_id = $post->ID; |
196 | 196 | } |
197 | 197 | |
198 | - include self::$metaboxes_dir . 'views/data-source.php'; |
|
198 | + include self::$metaboxes_dir.'views/data-source.php'; |
|
199 | 199 | |
200 | 200 | } |
201 | 201 | |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | * @param object $post |
207 | 207 | * @return void |
208 | 208 | */ |
209 | - function render_select_template_metabox( $post ) { |
|
209 | + function render_select_template_metabox($post) { |
|
210 | 210 | |
211 | - include self::$metaboxes_dir . 'views/select-template.php'; |
|
211 | + include self::$metaboxes_dir.'views/select-template.php'; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -217,18 +217,18 @@ discard block |
||
217 | 217 | * @param mixed $curr_form Form ID |
218 | 218 | * @return null|string Merge tags html; NULL if $curr_form isn't defined. |
219 | 219 | */ |
220 | - public static function render_merge_tags_scripts( $curr_form ) { |
|
220 | + public static function render_merge_tags_scripts($curr_form) { |
|
221 | 221 | |
222 | - if( empty( $curr_form )) { |
|
222 | + if (empty($curr_form)) { |
|
223 | 223 | return NULL; |
224 | 224 | } |
225 | 225 | |
226 | - $form = gravityview_get_form( $curr_form ); |
|
226 | + $form = gravityview_get_form($curr_form); |
|
227 | 227 | |
228 | 228 | $get_id_backup = isset($_GET['id']) ? $_GET['id'] : NULL; |
229 | 229 | |
230 | - if( isset( $form['id'] ) ) { |
|
231 | - $form_script = 'var form = ' . GFCommon::json_encode($form) . ';'; |
|
230 | + if (isset($form['id'])) { |
|
231 | + $form_script = 'var form = '.GFCommon::json_encode($form).';'; |
|
232 | 232 | |
233 | 233 | // The `gf_vars()` method needs a $_GET[id] variable set with the form ID. |
234 | 234 | $_GET['id'] = $form['id']; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $form_script = 'var form = new Form();'; |
238 | 238 | } |
239 | 239 | |
240 | - $output = '<script type="text/javascript" data-gv-merge-tags="1">' . $form_script . "\n" . GFCommon::gf_vars(false) . '</script>'; |
|
240 | + $output = '<script type="text/javascript" data-gv-merge-tags="1">'.$form_script."\n".GFCommon::gf_vars(false).'</script>'; |
|
241 | 241 | |
242 | 242 | // Restore previous $_GET setting |
243 | 243 | $_GET['id'] = $get_id_backup; |
@@ -252,20 +252,20 @@ discard block |
||
252 | 252 | * @param mixed $post |
253 | 253 | * @return void |
254 | 254 | */ |
255 | - function render_view_configuration_metabox( $post ) { |
|
255 | + function render_view_configuration_metabox($post) { |
|
256 | 256 | |
257 | 257 | // Use nonce for verification |
258 | - wp_nonce_field( 'gravityview_view_configuration', 'gravityview_view_configuration_nonce' ); |
|
258 | + wp_nonce_field('gravityview_view_configuration', 'gravityview_view_configuration_nonce'); |
|
259 | 259 | |
260 | 260 | // Selected Form |
261 | - $curr_form = gravityview_get_form_id( $post->ID ); |
|
261 | + $curr_form = gravityview_get_form_id($post->ID); |
|
262 | 262 | |
263 | 263 | // Selected template |
264 | - $curr_template = gravityview_get_template_id( $post->ID ); |
|
264 | + $curr_template = gravityview_get_template_id($post->ID); |
|
265 | 265 | |
266 | - echo self::render_merge_tags_scripts( $curr_form ); |
|
266 | + echo self::render_merge_tags_scripts($curr_form); |
|
267 | 267 | |
268 | - include self::$metaboxes_dir . 'views/view-configuration.php'; |
|
268 | + include self::$metaboxes_dir.'views/view-configuration.php'; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -275,12 +275,12 @@ discard block |
||
275 | 275 | * @param object $post |
276 | 276 | * @return void |
277 | 277 | */ |
278 | - function render_view_settings_metabox( $post ) { |
|
278 | + function render_view_settings_metabox($post) { |
|
279 | 279 | |
280 | 280 | // View template settings |
281 | - $current_settings = gravityview_get_template_settings( $post->ID ); |
|
281 | + $current_settings = gravityview_get_template_settings($post->ID); |
|
282 | 282 | |
283 | - include self::$metaboxes_dir . 'views/view-settings.php'; |
|
283 | + include self::$metaboxes_dir.'views/view-settings.php'; |
|
284 | 284 | |
285 | 285 | } |
286 | 286 | |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | global $post; |
298 | 298 | |
299 | 299 | // Only show this on GravityView post types. |
300 | - if( false === gravityview_is_admin_page() ) { return; } |
|
300 | + if (false === gravityview_is_admin_page()) { return; } |
|
301 | 301 | |
302 | 302 | // If the View hasn't been configured yet, don't show embed shortcode |
303 | - if( !gravityview_get_directory_fields( $post->ID ) ) { return; } |
|
303 | + if (!gravityview_get_directory_fields($post->ID)) { return; } |
|
304 | 304 | |
305 | - include self::$metaboxes_dir . 'views/shortcode-hint.php'; |
|
305 | + include self::$metaboxes_dir.'views/shortcode-hint.php'; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | } |
@@ -95,7 +95,7 @@ |
||
95 | 95 | * @param string $icon_class_name Icon class used in vertical tabs. Supports non-dashicon. If dashicons, no need for `dashicons ` prefix |
96 | 96 | * @param string $callback Function to render the metabox, if $file is not defined. |
97 | 97 | * @param null $callback_args Arguments passed to the callback |
98 | - * @return void |
|
98 | + * @return GravityView_Metabox_Tab |
|
99 | 99 | */ |
100 | 100 | function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = null ) { |
101 | 101 |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | * @param null $callback_args Arguments passed to the callback |
98 | 98 | * @return void |
99 | 99 | */ |
100 | - function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = null ) { |
|
100 | + function __construct($id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = null) { |
|
101 | 101 | |
102 | 102 | $this->id = $this->prefix.$id; |
103 | 103 | $this->title = $title; |
104 | 104 | $this->render_template_file = $file; |
105 | 105 | $this->callback = $callback; |
106 | 106 | $this->callback_args = $callback_args; |
107 | - $this->icon_class_name = $this->parse_icon_class_name( $icon_class_name ); |
|
107 | + $this->icon_class_name = $this->parse_icon_class_name($icon_class_name); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return string sanitized CSS class |
118 | 118 | */ |
119 | - function parse_icon_class_name( $icon_class_name = '' ) { |
|
119 | + function parse_icon_class_name($icon_class_name = '') { |
|
120 | 120 | |
121 | - if( preg_match( '/dashicon/i', $icon_class_name ) ) { |
|
122 | - $icon_class_name = 'dashicons ' . $icon_class_name; |
|
121 | + if (preg_match('/dashicon/i', $icon_class_name)) { |
|
122 | + $icon_class_name = 'dashicons '.$icon_class_name; |
|
123 | 123 | } |
124 | 124 | |
125 | - return esc_attr( $icon_class_name ); |
|
125 | + return esc_attr($icon_class_name); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -140,38 +140,38 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @param WP_Post $post Currently edited post object |
142 | 142 | */ |
143 | - function render( $post ) { |
|
143 | + function render($post) { |
|
144 | 144 | |
145 | - if( !empty( $this->render_template_file ) ) { |
|
145 | + if (!empty($this->render_template_file)) { |
|
146 | 146 | |
147 | 147 | $file = $this->render_template_file; |
148 | 148 | |
149 | 149 | // If the full path exists, use it |
150 | - if( file_exists( $file ) ) { |
|
150 | + if (file_exists($file)) { |
|
151 | 151 | $path = $file; |
152 | 152 | } else { |
153 | - $path = GRAVITYVIEW_DIR .'includes/admin/metaboxes/views/'.$file; |
|
153 | + $path = GRAVITYVIEW_DIR.'includes/admin/metaboxes/views/'.$file; |
|
154 | 154 | } |
155 | 155 | |
156 | - if( file_exists( $path ) ) { |
|
156 | + if (file_exists($path)) { |
|
157 | 157 | include $path; |
158 | 158 | } else { |
159 | - do_action( 'gravityview_log_error', 'Metabox template file not found', $this ); |
|
159 | + do_action('gravityview_log_error', 'Metabox template file not found', $this); |
|
160 | 160 | } |
161 | 161 | |
162 | - } else if( !empty( $this->callback ) ) { |
|
162 | + } else if (!empty($this->callback)) { |
|
163 | 163 | |
164 | - if( is_callable( $this->callback ) ) { |
|
164 | + if (is_callable($this->callback)) { |
|
165 | 165 | |
166 | 166 | /** @see do_accordion_sections() */ |
167 | - call_user_func( $this->callback, $post, (array) $this ); |
|
167 | + call_user_func($this->callback, $post, (array)$this); |
|
168 | 168 | |
169 | 169 | } else { |
170 | - do_action( 'gravityview_log_error', 'Metabox callback was not callable', $this ); |
|
170 | + do_action('gravityview_log_error', 'Metabox callback was not callable', $this); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | } else { |
174 | - do_action( 'gravityview_log_error', 'Metabox file and callback were not found', $this ); |
|
174 | + do_action('gravityview_log_error', 'Metabox file and callback were not found', $this); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 |
@@ -144,7 +144,6 @@ |
||
144 | 144 | * Enqueue scripts and styles |
145 | 145 | * |
146 | 146 | * @access public |
147 | - * @param mixed $hook |
|
148 | 147 | * @return void |
149 | 148 | */ |
150 | 149 | function add_scripts_and_styles() { |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Adds a button to add the View shortcode into the post content |
|
4 | - * |
|
5 | - * @package GravityView |
|
6 | - * @license GPL2+ |
|
7 | - * @author Katz Web Services, Inc. |
|
8 | - * @link http://gravityview.co |
|
9 | - * @copyright Copyright 2014, Katz Web Services, Inc. |
|
10 | - * |
|
11 | - * @since 1.0.0 |
|
12 | - */ |
|
3 | + * Adds a button to add the View shortcode into the post content |
|
4 | + * |
|
5 | + * @package GravityView |
|
6 | + * @license GPL2+ |
|
7 | + * @author Katz Web Services, Inc. |
|
8 | + * @link http://gravityview.co |
|
9 | + * @copyright Copyright 2014, Katz Web Services, Inc. |
|
10 | + * |
|
11 | + * @since 1.0.0 |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | /** If this file is called directly, abort. */ |
15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | /** If this file is called directly, abort. */ |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | die; |
17 | 17 | } |
18 | 18 | |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | |
21 | 21 | function __construct() { |
22 | 22 | |
23 | - add_action( 'media_buttons', array( $this, 'add_shortcode_button'), 30); |
|
23 | + add_action('media_buttons', array($this, 'add_shortcode_button'), 30); |
|
24 | 24 | |
25 | - add_action( 'admin_footer', array( $this, 'add_shortcode_popup') ); |
|
25 | + add_action('admin_footer', array($this, 'add_shortcode_popup')); |
|
26 | 26 | |
27 | 27 | // adding styles and scripts |
28 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') ); |
|
28 | + add_action('admin_enqueue_scripts', array($this, 'add_scripts_and_styles')); |
|
29 | 29 | |
30 | 30 | // ajax - populate sort fields based on the selected view |
31 | - add_action( 'wp_ajax_gv_sortable_fields', array( $this, 'get_sortable_fields' ) ); |
|
31 | + add_action('wp_ajax_gv_sortable_fields', array($this, 'get_sortable_fields')); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function is_post_editor_screen() { |
42 | 42 | global $current_screen, $pagenow; |
43 | - return !empty( $current_screen->post_type ) && 'gravityview' != $current_screen->post_type && in_array( $pagenow , array( 'post.php' , 'post-new.php' ) ); |
|
43 | + return !empty($current_screen->post_type) && 'gravityview' != $current_screen->post_type && in_array($pagenow, array('post.php', 'post-new.php')); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | * @return void |
52 | 52 | */ |
53 | 53 | function add_shortcode_button() { |
54 | - if( !$this->is_post_editor_screen() ) { |
|
54 | + if (!$this->is_post_editor_screen()) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | ?> |
58 | - <a href="#TB_inline?width=480&inlineId=select_gravityview_view&width=600&height=800" class="thickbox button gform_media_link" id="add_gravityview" title="<?php esc_attr_e("Insert View", 'gravityview'); ?>"><span class="icon gv-icon-astronaut-head"></span><?php esc_html_e( 'Add View', 'gravityview' ); ?></a> |
|
58 | + <a href="#TB_inline?width=480&inlineId=select_gravityview_view&width=600&height=800" class="thickbox button gform_media_link" id="add_gravityview" title="<?php esc_attr_e("Insert View", 'gravityview'); ?>"><span class="icon gv-icon-astronaut-head"></span><?php esc_html_e('Add View', 'gravityview'); ?></a> |
|
59 | 59 | <?php |
60 | 60 | |
61 | 61 | } |
@@ -71,17 +71,17 @@ discard block |
||
71 | 71 | function add_shortcode_popup() { |
72 | 72 | global $post; |
73 | 73 | |
74 | - if( !$this->is_post_editor_screen() ) { |
|
74 | + if (!$this->is_post_editor_screen()) { |
|
75 | 75 | return; |
76 | 76 | } |
77 | 77 | |
78 | 78 | $post_type = get_post_type_object($post->post_type); |
79 | 79 | |
80 | - $views = get_posts( array('post_type' => 'gravityview', 'posts_per_page' => -1 ) ); |
|
80 | + $views = get_posts(array('post_type' => 'gravityview', 'posts_per_page' => -1)); |
|
81 | 81 | |
82 | 82 | // If there are no views set up yet, we get outta here. |
83 | - if( empty( $views ) ) { |
|
84 | - echo '<div id="select_gravityview_view"><div class="wrap">'. GravityView_Post_Types::no_views_text() .'</div></div>'; |
|
83 | + if (empty($views)) { |
|
84 | + echo '<div id="select_gravityview_view"><div class="wrap">'.GravityView_Post_Types::no_views_text().'</div></div>'; |
|
85 | 85 | return; |
86 | 86 | } |
87 | 87 | |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | <form action="#" method="get" id="select_gravityview_view_form"> |
91 | 91 | <div class="wrap"> |
92 | 92 | |
93 | - <h2 class=""><?php esc_html_e( 'Embed a View', 'gravityview' ); ?></h2> |
|
94 | - <p class="subtitle"><?php printf( esc_attr ( __( 'Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s', 'gravityview') ), $post_type->labels->singular_name, '<a href="http://gravityview.co/support/documentation/202934188/" target="_blank">', '</a>' ); ?></p> |
|
93 | + <h2 class=""><?php esc_html_e('Embed a View', 'gravityview'); ?></h2> |
|
94 | + <p class="subtitle"><?php printf(esc_attr(__('Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s', 'gravityview')), $post_type->labels->singular_name, '<a href="http://gravityview.co/support/documentation/202934188/" target="_blank">', '</a>'); ?></p> |
|
95 | 95 | |
96 | 96 | <div> |
97 | - <h3><label for="gravityview_id"><?php esc_html_e( 'Select a View', 'gravityview' ); ?></label></h3> |
|
97 | + <h3><label for="gravityview_id"><?php esc_html_e('Select a View', 'gravityview'); ?></label></h3> |
|
98 | 98 | |
99 | 99 | <select name="gravityview_id" id="gravityview_id"> |
100 | - <option value=""><?php esc_html_e( '— Select a View to Insert —', 'gravityview' ); ?></option> |
|
100 | + <option value=""><?php esc_html_e('— Select a View to Insert —', 'gravityview'); ?></option> |
|
101 | 101 | <?php |
102 | - foreach( $views as $view ) { |
|
103 | - $title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title; |
|
104 | - echo '<option value="'. $view->ID .'">'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>'; |
|
102 | + foreach ($views as $view) { |
|
103 | + $title = empty($view->post_title) ? __('(no title)', 'gravityview') : $view->post_title; |
|
104 | + echo '<option value="'.$view->ID.'">'.esc_html(sprintf('%s #%d', $title, $view->ID)).'</option>'; |
|
105 | 105 | } |
106 | 106 | ?> |
107 | 107 | </select> |
@@ -109,24 +109,24 @@ discard block |
||
109 | 109 | |
110 | 110 | <table class="form-table hide-if-js"> |
111 | 111 | |
112 | - <caption><?php esc_html_e( 'View Settings', 'gravityview' ); ?></caption> |
|
112 | + <caption><?php esc_html_e('View Settings', 'gravityview'); ?></caption> |
|
113 | 113 | |
114 | 114 | <?php |
115 | 115 | |
116 | - $settings = GravityView_View_Data::get_default_args( true ); |
|
116 | + $settings = GravityView_View_Data::get_default_args(true); |
|
117 | 117 | |
118 | - foreach ( $settings as $key => $setting ) { |
|
118 | + foreach ($settings as $key => $setting) { |
|
119 | 119 | |
120 | - if( empty( $setting['show_in_shortcode'] ) ) { continue; } |
|
120 | + if (empty($setting['show_in_shortcode'])) { continue; } |
|
121 | 121 | |
122 | - GravityView_Render_Settings::render_setting_row( $key, array(), NULL, 'gravityview_%s', 'gravityview_%s' ); |
|
122 | + GravityView_Render_Settings::render_setting_row($key, array(), NULL, 'gravityview_%s', 'gravityview_%s'); |
|
123 | 123 | } |
124 | 124 | ?> |
125 | 125 | |
126 | 126 | </table> |
127 | 127 | |
128 | 128 | <div class="submit"> |
129 | - <input type="submit" class="button button-primary button-large alignleft hide-if-js" value="<?php esc_attr_e('Insert View', 'gravityview' ); ?>" id="insert_gravityview_view" /> |
|
129 | + <input type="submit" class="button button-primary button-large alignleft hide-if-js" value="<?php esc_attr_e('Insert View', 'gravityview'); ?>" id="insert_gravityview_view" /> |
|
130 | 130 | <input class="button button-secondary alignright" type="submit" onclick="tb_remove(); return false;" value="<?php esc_attr_e("Cancel", 'gravityview'); ?>" /> |
131 | 131 | </div> |
132 | 132 | |
@@ -149,32 +149,32 @@ discard block |
||
149 | 149 | */ |
150 | 150 | function add_scripts_and_styles() { |
151 | 151 | |
152 | - if( ! $this->is_post_editor_screen() ) { |
|
152 | + if (!$this->is_post_editor_screen()) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | - wp_enqueue_style( 'dashicons' ); |
|
156 | + wp_enqueue_style('dashicons'); |
|
157 | 157 | |
158 | 158 | // date picker |
159 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
159 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
160 | 160 | |
161 | 161 | $protocol = is_ssl() ? 'https://' : 'http://'; |
162 | 162 | |
163 | - wp_enqueue_style( 'jquery-ui-datepicker', $protocol.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(), GravityView_Plugin::version ); |
|
163 | + wp_enqueue_style('jquery-ui-datepicker', $protocol.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(), GravityView_Plugin::version); |
|
164 | 164 | |
165 | 165 | //enqueue styles |
166 | - wp_register_style( 'gravityview_postedit_styles', plugins_url('assets/css/admin-post-edit.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
167 | - wp_enqueue_style( 'gravityview_postedit_styles' ); |
|
166 | + wp_register_style('gravityview_postedit_styles', plugins_url('assets/css/admin-post-edit.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version); |
|
167 | + wp_enqueue_style('gravityview_postedit_styles'); |
|
168 | 168 | |
169 | 169 | $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
170 | 170 | |
171 | 171 | // custom js |
172 | - wp_register_script( 'gravityview_postedit_scripts', plugins_url('assets/js/admin-post-edit'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery', 'jquery-ui-datepicker' ), GravityView_Plugin::version ); |
|
173 | - wp_enqueue_script( 'gravityview_postedit_scripts' ); |
|
172 | + wp_register_script('gravityview_postedit_scripts', plugins_url('assets/js/admin-post-edit'.$script_debug.'.js', GRAVITYVIEW_FILE), array('jquery', 'jquery-ui-datepicker'), GravityView_Plugin::version); |
|
173 | + wp_enqueue_script('gravityview_postedit_scripts'); |
|
174 | 174 | wp_localize_script('gravityview_postedit_scripts', 'gvGlobals', array( |
175 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxaddshortcode'), |
|
176 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
177 | - 'alert_1' => esc_html__( 'Please select a View', 'gravityview'), |
|
175 | + 'nonce' => wp_create_nonce('gravityview_ajaxaddshortcode'), |
|
176 | + 'loading_text' => esc_html__('Loading…', 'gravityview'), |
|
177 | + 'alert_1' => esc_html__('Please select a View', 'gravityview'), |
|
178 | 178 | )); |
179 | 179 | |
180 | 180 | } |
@@ -191,27 +191,27 @@ discard block |
||
191 | 191 | function get_sortable_fields() { |
192 | 192 | |
193 | 193 | // Not properly formatted request |
194 | - if ( empty( $_POST['viewid'] ) || !is_numeric( $_POST['viewid'] ) ) { |
|
195 | - exit( false ); |
|
194 | + if (empty($_POST['viewid']) || !is_numeric($_POST['viewid'])) { |
|
195 | + exit(false); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | // Not valid request |
199 | - if( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxaddshortcode' ) ) { |
|
200 | - exit( false ); |
|
199 | + if (empty($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxaddshortcode')) { |
|
200 | + exit(false); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | $viewid = (int)$_POST['viewid']; |
204 | 204 | |
205 | 205 | // fetch form id assigned to the view |
206 | - $formid = gravityview_get_form_id( $viewid ); |
|
206 | + $formid = gravityview_get_form_id($viewid); |
|
207 | 207 | |
208 | 208 | // Get the default sort field for the view |
209 | - $sort_field = gravityview_get_template_setting( $viewid, 'sort_field' ); |
|
209 | + $sort_field = gravityview_get_template_setting($viewid, 'sort_field'); |
|
210 | 210 | |
211 | 211 | // Generate the output `<option>`s |
212 | - $response = gravityview_get_sortable_fields( $formid, $sort_field ); |
|
212 | + $response = gravityview_get_sortable_fields($formid, $sort_field); |
|
213 | 213 | |
214 | - exit( $response ); |
|
214 | + exit($response); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @uses GravityView_frontend::get_search_criteria() Convert the $_POST search request into a properly formatted request. |
172 | 172 | * @access public |
173 | - * @return void|boolean |
|
173 | + * @return null|false |
|
174 | 174 | */ |
175 | 175 | public function process_bulk_action() { |
176 | 176 | if ( ! class_exists( 'RGForms' ) ) { |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @param array|boolean $entries If array, array of entry IDs that are to be updated. If true: update all entries. |
253 | 253 | * @param int $approved Approved status. If `0`: unapproved, if not empty, `Approved` |
254 | 254 | * @param int $form_id The Gravity Forms Form ID |
255 | - * @return boolean|void |
|
255 | + * @return false|null |
|
256 | 256 | */ |
257 | 257 | private static function update_bulk( $entries, $approved, $form_id ) { |
258 | 258 | |
@@ -284,7 +284,6 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @access public |
286 | 286 | * @static |
287 | - * @param int $lead_id (default: 0) |
|
288 | 287 | * @param int $approved (default: 0) |
289 | 288 | * @param int $form_id (default: 0) |
290 | 289 | * @param int $approvedcolumn (default: 0) |
@@ -470,7 +469,7 @@ discard block |
||
470 | 469 | * @access public |
471 | 470 | * @static |
472 | 471 | * @param mixed $form GF Form or Form ID |
473 | - * @return false|null|string Returns the input ID of the approved field. Returns NULL if no approved fields were found. Returns false if $form_id wasn't set. |
|
472 | + * @return integer Returns the input ID of the approved field. Returns NULL if no approved fields were found. Returns false if $form_id wasn't set. |
|
474 | 473 | */ |
475 | 474 | static public function get_approved_column( $form ) { |
476 | 475 |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | |
322 | 322 | if( class_exists( 'GravityView_Entry_Notes' ) ){ |
323 | 323 | global $current_user; |
324 | - get_currentuserinfo(); |
|
324 | + get_currentuserinfo(); |
|
325 | 325 | GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $current_user->display_name, $note ); |
326 | 326 | } |
327 | 327 | |
@@ -356,12 +356,12 @@ discard block |
||
356 | 356 | |
357 | 357 | $approvedcolumn = self::get_approved_column( $form['id'] ); |
358 | 358 | |
359 | - /** |
|
360 | - * If the form doesn't contain the approve field, don't assume anything. |
|
361 | - */ |
|
362 | - if( empty( $approvedcolumn ) ) { |
|
363 | - return; |
|
364 | - } |
|
359 | + /** |
|
360 | + * If the form doesn't contain the approve field, don't assume anything. |
|
361 | + */ |
|
362 | + if( empty( $approvedcolumn ) ) { |
|
363 | + return; |
|
364 | + } |
|
365 | 365 | |
366 | 366 | $entry = GFAPI::get_entry( $entry_id ); |
367 | 367 | |
@@ -474,17 +474,17 @@ discard block |
||
474 | 474 | */ |
475 | 475 | static public function get_approved_column( $form ) { |
476 | 476 | |
477 | - if( empty( $form ) ) { |
|
478 | - return null; |
|
479 | - } |
|
477 | + if( empty( $form ) ) { |
|
478 | + return null; |
|
479 | + } |
|
480 | 480 | |
481 | - if( !is_array( $form ) ) { |
|
482 | - $form = GVCommon::get_form( $form ); |
|
483 | - } |
|
481 | + if( !is_array( $form ) ) { |
|
482 | + $form = GVCommon::get_form( $form ); |
|
483 | + } |
|
484 | 484 | |
485 | 485 | foreach( $form['fields'] as $key => $field ) { |
486 | 486 | |
487 | - $field = (array) $field; |
|
487 | + $field = (array) $field; |
|
488 | 488 | |
489 | 489 | if( !empty( $field['gravityview_approved'] ) ) { |
490 | 490 | if( !empty($field['inputs'][0]['id']) ) { |
@@ -492,14 +492,14 @@ discard block |
||
492 | 492 | } |
493 | 493 | } |
494 | 494 | |
495 | - // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
|
496 | - if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) { |
|
497 | - foreach ( $field['inputs'] as $key2 => $input ) { |
|
498 | - if ( strtolower( $input['label'] ) == 'approved' ) { |
|
499 | - return $input['id']; |
|
500 | - } |
|
501 | - } |
|
502 | - } |
|
495 | + // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
|
496 | + if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) { |
|
497 | + foreach ( $field['inputs'] as $key2 => $input ) { |
|
498 | + if ( strtolower( $input['label'] ) == 'approved' ) { |
|
499 | + return $input['id']; |
|
500 | + } |
|
501 | + } |
|
502 | + } |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | return null; |
@@ -27,29 +27,29 @@ discard block |
||
27 | 27 | /** Edit Gravity Form page */ |
28 | 28 | |
29 | 29 | // Add button to left menu |
30 | - add_filter( 'gform_add_field_buttons', array( $this, 'add_field_buttons' ) ); |
|
30 | + add_filter('gform_add_field_buttons', array($this, 'add_field_buttons')); |
|
31 | 31 | // Set defaults |
32 | - add_action( 'gform_editor_js_set_default_values', array( $this, 'set_defaults' ) ); |
|
32 | + add_action('gform_editor_js_set_default_values', array($this, 'set_defaults')); |
|
33 | 33 | |
34 | 34 | /** gf_entries page - entries table screen */ |
35 | 35 | |
36 | 36 | // capture bulk actions |
37 | - add_action( 'init', array( $this, 'process_bulk_action') ); |
|
37 | + add_action('init', array($this, 'process_bulk_action')); |
|
38 | 38 | // add hidden field with approve status |
39 | - add_action( 'gform_entries_first_column', array( $this, 'add_entry_approved_hidden_input' ), 1, 5 ); |
|
39 | + add_action('gform_entries_first_column', array($this, 'add_entry_approved_hidden_input'), 1, 5); |
|
40 | 40 | // process ajax approve entry requests |
41 | - add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved')); |
|
41 | + add_action('wp_ajax_gv_update_approved', array($this, 'ajax_update_approved')); |
|
42 | 42 | |
43 | 43 | // in case entry is edited (on admin or frontend) |
44 | - add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2); |
|
44 | + add_action('gform_after_update_entry', array($this, 'after_update_entry_update_approved_meta'), 10, 2); |
|
45 | 45 | |
46 | - add_filter( 'gravityview_tooltips', array( $this, 'tooltips' ) ); |
|
46 | + add_filter('gravityview_tooltips', array($this, 'tooltips')); |
|
47 | 47 | |
48 | 48 | // adding styles and scripts |
49 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') ); |
|
49 | + add_action('admin_enqueue_scripts', array($this, 'add_scripts_and_styles')); |
|
50 | 50 | // bypass Gravity Forms no-conflict mode |
51 | - add_filter( 'gform_noconflict_scripts', array( $this, 'register_gform_noconflict_script' ) ); |
|
52 | - add_filter( 'gform_noconflict_styles', array( $this, 'register_gform_noconflict_style' ) ); |
|
51 | + add_filter('gform_noconflict_scripts', array($this, 'register_gform_noconflict_script')); |
|
52 | + add_filter('gform_noconflict_styles', array($this, 'register_gform_noconflict_style')); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return array Tooltips array with GravityView fields tooltip |
61 | 61 | */ |
62 | - function tooltips( $tooltips ) { |
|
62 | + function tooltips($tooltips) { |
|
63 | 63 | |
64 | 64 | $tooltips['form_gravityview_fields'] = array( |
65 | 65 | 'title' => __('GravityView Fields', 'gravityview'), |
66 | - 'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview'), |
|
66 | + 'value' => __('Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview'), |
|
67 | 67 | ); |
68 | 68 | |
69 | 69 | return $tooltips; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param mixed $field_groups |
78 | 78 | * @return array Array of fields |
79 | 79 | */ |
80 | - function add_field_buttons( $field_groups ) { |
|
80 | + function add_field_buttons($field_groups) { |
|
81 | 81 | |
82 | 82 | $gravityview_fields = array( |
83 | 83 | 'name' => 'gravityview_fields', |
@@ -85,20 +85,20 @@ discard block |
||
85 | 85 | 'fields' => array( |
86 | 86 | array( |
87 | 87 | 'class' => 'button', |
88 | - 'value' => __( 'Approve/Reject', 'gravityview' ), |
|
88 | + 'value' => __('Approve/Reject', 'gravityview'), |
|
89 | 89 | 'onclick' => "StartAddField('gravityviewapproved_admin');", |
90 | 90 | 'data-type' => 'gravityviewapproved_admin' |
91 | 91 | ), |
92 | 92 | array( |
93 | 93 | 'class' => 'button', |
94 | - 'value' => __( 'User Opt-In', 'gravityview' ), |
|
94 | + 'value' => __('User Opt-In', 'gravityview'), |
|
95 | 95 | 'onclick' => "StartAddField('gravityviewapproved');", |
96 | 96 | 'data-type' => 'gravityviewapproved' |
97 | 97 | ), |
98 | 98 | ) |
99 | 99 | ); |
100 | 100 | |
101 | - array_push( $field_groups, $gravityview_fields ); |
|
101 | + array_push($field_groups, $gravityview_fields); |
|
102 | 102 | |
103 | 103 | return $field_groups; |
104 | 104 | } |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | function set_defaults() { |
116 | 116 | ?> |
117 | 117 | case 'gravityviewapproved_admin': |
118 | - field.label = "<?php _e( 'Approved? (Admin-only)', 'gravityview' ); ?>"; |
|
118 | + field.label = "<?php _e('Approved? (Admin-only)', 'gravityview'); ?>"; |
|
119 | 119 | |
120 | - field.adminLabel = "<?php _e( 'Approved?', 'gravityview' ); ?>"; |
|
120 | + field.adminLabel = "<?php _e('Approved?', 'gravityview'); ?>"; |
|
121 | 121 | field.adminOnly = true; |
122 | 122 | |
123 | 123 | field.choices = null; |
124 | 124 | field.inputs = null; |
125 | 125 | |
126 | 126 | if( !field.choices ) { |
127 | - field.choices = new Array( new Choice("<?php _e( 'Approved', 'gravityview' ); ?>") ); |
|
127 | + field.choices = new Array( new Choice("<?php _e('Approved', 'gravityview'); ?>") ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | field.inputs = new Array(); |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | |
138 | 138 | break; |
139 | 139 | case 'gravityviewapproved': |
140 | - field.label = "<?php _e( 'Show Entry on Website', 'gravityview' ); ?>"; |
|
140 | + field.label = "<?php _e('Show Entry on Website', 'gravityview'); ?>"; |
|
141 | 141 | |
142 | - field.adminLabel = "<?php _e( 'Opt-In', 'gravityview' ); ?>"; |
|
142 | + field.adminLabel = "<?php _e('Opt-In', 'gravityview'); ?>"; |
|
143 | 143 | field.adminOnly = false; |
144 | 144 | |
145 | 145 | field.choices = null; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | if( !field.choices ) { |
149 | 149 | field.choices = new Array( |
150 | - new Choice("<?php _e( 'Yes, display my entry on the website', 'gravityview' ); ?>") |
|
150 | + new Choice("<?php _e('Yes, display my entry on the website', 'gravityview'); ?>") |
|
151 | 151 | ); |
152 | 152 | } |
153 | 153 | |
@@ -173,17 +173,17 @@ discard block |
||
173 | 173 | * @return void|boolean |
174 | 174 | */ |
175 | 175 | public function process_bulk_action() { |
176 | - if ( ! class_exists( 'RGForms' ) ) { |
|
176 | + if (!class_exists('RGForms')) { |
|
177 | 177 | return; |
178 | 178 | } |
179 | 179 | |
180 | 180 | // gforms_update_note is sent when bulk editing entry notes. We don't want to process then. |
181 | - if ( 'bulk' === RGForms::post( 'action' ) && empty( $_POST['gforms_update_note'] ) ) { |
|
181 | + if ('bulk' === RGForms::post('action') && empty($_POST['gforms_update_note'])) { |
|
182 | 182 | |
183 | - check_admin_referer( 'gforms_entry_list', 'gforms_entry_list' ); |
|
183 | + check_admin_referer('gforms_entry_list', 'gforms_entry_list'); |
|
184 | 184 | |
185 | 185 | // The action is formatted like: approve-16 or disapprove-16, where the first word is the name of the action and the second is the ID of the form. Bulk action 2 is the bottom bulk action select form. |
186 | - $bulk_action = ! empty( $_POST['bulk_action'] ) ? $_POST['bulk_action'] : $_POST['bulk_action2']; |
|
186 | + $bulk_action = !empty($_POST['bulk_action']) ? $_POST['bulk_action'] : $_POST['bulk_action2']; |
|
187 | 187 | |
188 | 188 | /** |
189 | 189 | * The extra '-' is to make sure that there are at *least* two items in array. |
@@ -191,27 +191,27 @@ discard block |
||
191 | 191 | */ |
192 | 192 | $bulk_action .= '-'; |
193 | 193 | |
194 | - list( $approved_status, $form_id ) = explode( '-', $bulk_action ); |
|
194 | + list($approved_status, $form_id) = explode('-', $bulk_action); |
|
195 | 195 | |
196 | - if ( empty( $form_id ) ) { |
|
197 | - do_action( 'gravityview_log_error', '[process_bulk_action] Form ID is empty from parsing bulk action.', $bulk_action ); |
|
196 | + if (empty($form_id)) { |
|
197 | + do_action('gravityview_log_error', '[process_bulk_action] Form ID is empty from parsing bulk action.', $bulk_action); |
|
198 | 198 | return false; |
199 | 199 | } |
200 | 200 | |
201 | 201 | // All entries are set to be updated, not just the visible ones |
202 | - if ( ! empty( $_POST['all_entries'] ) ) { |
|
202 | + if (!empty($_POST['all_entries'])) { |
|
203 | 203 | |
204 | 204 | // Convert the current entry search into GF-formatted search criteria |
205 | 205 | $search = array( |
206 | - 'search_field' => isset( $_POST['f'] ) ? $_POST['f'][0] : 0, |
|
207 | - 'search_value' => isset( $_POST['v'][0] ) ? $_POST['v'][0] : '', |
|
208 | - 'search_operator' => isset( $_POST['o'][0] ) ? $_POST['o'][0] : 'contains', |
|
206 | + 'search_field' => isset($_POST['f']) ? $_POST['f'][0] : 0, |
|
207 | + 'search_value' => isset($_POST['v'][0]) ? $_POST['v'][0] : '', |
|
208 | + 'search_operator' => isset($_POST['o'][0]) ? $_POST['o'][0] : 'contains', |
|
209 | 209 | ); |
210 | 210 | |
211 | - $search_criteria = GravityView_frontend::get_search_criteria( $search, $form_id ); |
|
211 | + $search_criteria = GravityView_frontend::get_search_criteria($search, $form_id); |
|
212 | 212 | |
213 | 213 | // Get all the entry IDs for the form |
214 | - $entries = gravityview_get_entry_ids( $form_id, $search_criteria ); |
|
214 | + $entries = gravityview_get_entry_ids($form_id, $search_criteria); |
|
215 | 215 | |
216 | 216 | } else { |
217 | 217 | |
@@ -219,22 +219,22 @@ discard block |
||
219 | 219 | |
220 | 220 | } |
221 | 221 | |
222 | - if ( empty( $entries ) ) { |
|
223 | - do_action( 'gravityview_log_error', '[process_bulk_action] Entries are empty' ); |
|
222 | + if (empty($entries)) { |
|
223 | + do_action('gravityview_log_error', '[process_bulk_action] Entries are empty'); |
|
224 | 224 | return false; |
225 | 225 | } |
226 | 226 | |
227 | - $entry_count = count( $entries ) > 1 ? sprintf( __( '%d entries', 'gravityview' ), count( $entries ) ) : __( '1 entry', 'gravityview' ); |
|
227 | + $entry_count = count($entries) > 1 ? sprintf(__('%d entries', 'gravityview'), count($entries)) : __('1 entry', 'gravityview'); |
|
228 | 228 | |
229 | - switch ( $approved_status ) { |
|
229 | + switch ($approved_status) { |
|
230 | 230 | case 'approve': |
231 | - self::update_bulk( $entries, 1, $form_id ); |
|
232 | - $this->bulk_update_message = sprintf( __( '%s approved.', 'gravityview' ), $entry_count ); |
|
231 | + self::update_bulk($entries, 1, $form_id); |
|
232 | + $this->bulk_update_message = sprintf(__('%s approved.', 'gravityview'), $entry_count); |
|
233 | 233 | break; |
234 | 234 | |
235 | 235 | case 'unapprove': |
236 | - self::update_bulk( $entries, 0, $form_id ); |
|
237 | - $this->bulk_update_message = sprintf( __( '%s disapproved.', 'gravityview' ), $entry_count ); |
|
236 | + self::update_bulk($entries, 0, $form_id); |
|
237 | + $this->bulk_update_message = sprintf(__('%s disapproved.', 'gravityview'), $entry_count); |
|
238 | 238 | break; |
239 | 239 | } |
240 | 240 | } |
@@ -254,25 +254,25 @@ discard block |
||
254 | 254 | * @param int $form_id The Gravity Forms Form ID |
255 | 255 | * @return boolean|void |
256 | 256 | */ |
257 | - private static function update_bulk( $entries, $approved, $form_id ) { |
|
257 | + private static function update_bulk($entries, $approved, $form_id) { |
|
258 | 258 | |
259 | - if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) { |
|
260 | - do_action( 'gravityview_log_error', __METHOD__ . ' Entries were empty or malformed.', $entries ); |
|
259 | + if (empty($entries) || ($entries !== true && !is_array($entries))) { |
|
260 | + do_action('gravityview_log_error', __METHOD__.' Entries were empty or malformed.', $entries); |
|
261 | 261 | return false; |
262 | 262 | } |
263 | 263 | |
264 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
265 | - do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
|
264 | + if (!GVCommon::has_cap('gravityview_moderate_entries')) { |
|
265 | + do_action('gravityview_log_error', __METHOD__.' User does not have the `gravityview_moderate_entries` capability.'); |
|
266 | 266 | return false; |
267 | 267 | } |
268 | 268 | |
269 | - $approved = empty( $approved ) ? 0 : 'Approved'; |
|
269 | + $approved = empty($approved) ? 0 : 'Approved'; |
|
270 | 270 | |
271 | 271 | // calculate approved field id |
272 | - $approved_column_id = self::get_approved_column( $form_id ); |
|
272 | + $approved_column_id = self::get_approved_column($form_id); |
|
273 | 273 | |
274 | - foreach( $entries as $entry_id ) { |
|
275 | - self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
|
274 | + foreach ($entries as $entry_id) { |
|
275 | + self::update_approved((int)$entry_id, $approved, $form_id, $approved_column_id); |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | |
@@ -290,39 +290,39 @@ discard block |
||
290 | 290 | * @param int $approvedcolumn (default: 0) |
291 | 291 | * @return boolean True: It worked; False: it failed |
292 | 292 | */ |
293 | - public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { |
|
293 | + public static function update_approved($entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { |
|
294 | 294 | |
295 | - if( !class_exists( 'GFAPI' ) ) { |
|
296 | - do_action( 'gravityview_log_error', __METHOD__ . 'GFAPI does not exist' ); |
|
295 | + if (!class_exists('GFAPI')) { |
|
296 | + do_action('gravityview_log_error', __METHOD__.'GFAPI does not exist'); |
|
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | |
300 | - if( empty( $approvedcolumn ) ) { |
|
301 | - $approvedcolumn = self::get_approved_column( $form_id ); |
|
300 | + if (empty($approvedcolumn)) { |
|
301 | + $approvedcolumn = self::get_approved_column($form_id); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | //get the entry |
305 | - $entry = GFAPI::get_entry( $entry_id ); |
|
305 | + $entry = GFAPI::get_entry($entry_id); |
|
306 | 306 | |
307 | 307 | //update entry |
308 | - $entry[ (string)$approvedcolumn ] = $approved; |
|
308 | + $entry[(string)$approvedcolumn] = $approved; |
|
309 | 309 | |
310 | 310 | /** @var bool|WP_Error $result */ |
311 | - $result = GFAPI::update_entry( $entry ); |
|
311 | + $result = GFAPI::update_entry($entry); |
|
312 | 312 | |
313 | 313 | /** |
314 | 314 | * GFAPI::update_entry() doesn't trigger `gform_after_update_entry`, so we trigger updating the meta ourselves. |
315 | 315 | */ |
316 | - self::update_approved_meta( $entry_id, $approved ); |
|
316 | + self::update_approved_meta($entry_id, $approved); |
|
317 | 317 | |
318 | 318 | // add note to entry |
319 | - if( $result === true ) { |
|
320 | - $note = empty( $approved ) ? __( 'Disapproved the Entry for GravityView', 'gravityview' ) : __( 'Approved the Entry for GravityView', 'gravityview' ); |
|
319 | + if ($result === true) { |
|
320 | + $note = empty($approved) ? __('Disapproved the Entry for GravityView', 'gravityview') : __('Approved the Entry for GravityView', 'gravityview'); |
|
321 | 321 | |
322 | - if( class_exists( 'GravityView_Entry_Notes' ) ){ |
|
322 | + if (class_exists('GravityView_Entry_Notes')) { |
|
323 | 323 | global $current_user; |
324 | 324 | get_currentuserinfo(); |
325 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $current_user->display_name, $note ); |
|
325 | + GravityView_Entry_Notes::add_note($entry_id, $current_user->ID, $current_user->display_name, $note); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -330,11 +330,11 @@ discard block |
||
330 | 330 | * @see class-cache.php |
331 | 331 | * @since 1.5.1 |
332 | 332 | */ |
333 | - do_action( 'gravityview_clear_form_cache', $form_id ); |
|
333 | + do_action('gravityview_clear_form_cache', $form_id); |
|
334 | 334 | |
335 | - } else if( is_wp_error( $result ) ) { |
|
335 | + } else if (is_wp_error($result)) { |
|
336 | 336 | |
337 | - do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - Entry approval not updated: %s', $result->get_error_message() ) ); |
|
337 | + do_action('gravityview_log_error', __METHOD__.sprintf(' - Entry approval not updated: %s', $result->get_error_message())); |
|
338 | 338 | |
339 | 339 | $result = false; |
340 | 340 | } |
@@ -352,20 +352,20 @@ discard block |
||
352 | 352 | * @param int $entry_id ID of the Gravity Forms entry |
353 | 353 | * @return void |
354 | 354 | */ |
355 | - public static function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
|
355 | + public static function after_update_entry_update_approved_meta($form, $entry_id = NULL) { |
|
356 | 356 | |
357 | - $approvedcolumn = self::get_approved_column( $form['id'] ); |
|
357 | + $approvedcolumn = self::get_approved_column($form['id']); |
|
358 | 358 | |
359 | 359 | /** |
360 | 360 | * If the form doesn't contain the approve field, don't assume anything. |
361 | 361 | */ |
362 | - if( empty( $approvedcolumn ) ) { |
|
362 | + if (empty($approvedcolumn)) { |
|
363 | 363 | return; |
364 | 364 | } |
365 | 365 | |
366 | - $entry = GFAPI::get_entry( $entry_id ); |
|
366 | + $entry = GFAPI::get_entry($entry_id); |
|
367 | 367 | |
368 | - self::update_approved_meta( $entry_id, $entry[ (string)$approvedcolumn ] ); |
|
368 | + self::update_approved_meta($entry_id, $entry[(string)$approvedcolumn]); |
|
369 | 369 | |
370 | 370 | } |
371 | 371 | |
@@ -378,12 +378,12 @@ discard block |
||
378 | 378 | * |
379 | 379 | * @return void |
380 | 380 | */ |
381 | - private static function update_approved_meta( $entry_id, $is_approved ) { |
|
381 | + private static function update_approved_meta($entry_id, $is_approved) { |
|
382 | 382 | |
383 | 383 | // update entry meta |
384 | - if( function_exists('gform_update_meta') ) { |
|
384 | + if (function_exists('gform_update_meta')) { |
|
385 | 385 | |
386 | - gform_update_meta( $entry_id, 'is_approved', $is_approved ); |
|
386 | + gform_update_meta($entry_id, 'is_approved', $is_approved); |
|
387 | 387 | |
388 | 388 | /** |
389 | 389 | * @action `gravityview/approve_entries/updated` Triggered when an entry approval is updated |
@@ -391,16 +391,16 @@ discard block |
||
391 | 391 | * @param int $entry_id ID of the Gravity Forms entry |
392 | 392 | * @param string $is_approved String whether entry is approved or not. `0` for not approved, `Approved` for approved. |
393 | 393 | */ |
394 | - do_action( 'gravityview/approve_entries/updated', $entry_id, $is_approved ); |
|
394 | + do_action('gravityview/approve_entries/updated', $entry_id, $is_approved); |
|
395 | 395 | |
396 | - if( empty( $is_approved ) ) { |
|
396 | + if (empty($is_approved)) { |
|
397 | 397 | |
398 | 398 | /** |
399 | 399 | * @action `gravityview/approve_entries/disapproved` Triggered when an entry is rejected |
400 | 400 | * @since 1.7.6.1 |
401 | 401 | * @param int $entry_id ID of the Gravity Forms entry |
402 | 402 | */ |
403 | - do_action( 'gravityview/approve_entries/disapproved', $entry_id ); |
|
403 | + do_action('gravityview/approve_entries/disapproved', $entry_id); |
|
404 | 404 | |
405 | 405 | } else { |
406 | 406 | |
@@ -409,13 +409,13 @@ discard block |
||
409 | 409 | * @since 1.7.6.1 |
410 | 410 | * @param int $entry_id ID of the Gravity Forms entry |
411 | 411 | */ |
412 | - do_action( 'gravityview/approve_entries/approved', $entry_id ); |
|
412 | + do_action('gravityview/approve_entries/approved', $entry_id); |
|
413 | 413 | |
414 | 414 | } |
415 | 415 | |
416 | 416 | } else { |
417 | 417 | |
418 | - do_action('gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' ); |
|
418 | + do_action('gravityview_log_error', __METHOD__.' - `gform_update_meta` does not exist.'); |
|
419 | 419 | |
420 | 420 | } |
421 | 421 | } |
@@ -427,40 +427,40 @@ discard block |
||
427 | 427 | */ |
428 | 428 | public function ajax_update_approved() { |
429 | 429 | |
430 | - if( empty( $_POST['entry_id'] ) || empty( $_POST['form_id'] ) ) { |
|
430 | + if (empty($_POST['entry_id']) || empty($_POST['form_id'])) { |
|
431 | 431 | |
432 | - do_action( 'gravityview_log_error', __METHOD__ . ' entry_id or form_id are empty.', $_POST ); |
|
432 | + do_action('gravityview_log_error', __METHOD__.' entry_id or form_id are empty.', $_POST); |
|
433 | 433 | |
434 | 434 | $result = false; |
435 | 435 | } |
436 | 436 | |
437 | - else if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxgfentries' ) ) { |
|
437 | + else if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxgfentries')) { |
|
438 | 438 | |
439 | - do_action( 'gravityview_log_error', __METHOD__ . ' Security check failed.', $_POST ); |
|
439 | + do_action('gravityview_log_error', __METHOD__.' Security check failed.', $_POST); |
|
440 | 440 | |
441 | 441 | $result = false; |
442 | 442 | } |
443 | 443 | |
444 | - else if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $_POST['entry_id'] ) ) { |
|
444 | + else if (!GVCommon::has_cap('gravityview_moderate_entries', $_POST['entry_id'])) { |
|
445 | 445 | |
446 | - do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
|
446 | + do_action('gravityview_log_error', __METHOD__.' User does not have the `gravityview_moderate_entries` capability.'); |
|
447 | 447 | |
448 | 448 | $result = false; |
449 | 449 | } |
450 | 450 | |
451 | 451 | else { |
452 | 452 | |
453 | - $result = self::update_approved( $_POST['entry_id'], $_POST['approved'], $_POST['form_id'] ); |
|
453 | + $result = self::update_approved($_POST['entry_id'], $_POST['approved'], $_POST['form_id']); |
|
454 | 454 | |
455 | - if( is_wp_error( $result ) ) { |
|
455 | + if (is_wp_error($result)) { |
|
456 | 456 | /** @var WP_Error $result */ |
457 | - do_action( 'gravityview_log_error', __METHOD__ .' Error updating approval: ' . $result->get_error_message() ); |
|
457 | + do_action('gravityview_log_error', __METHOD__.' Error updating approval: '.$result->get_error_message()); |
|
458 | 458 | $result = false; |
459 | 459 | } |
460 | 460 | |
461 | 461 | } |
462 | 462 | |
463 | - exit( $result ); |
|
463 | + exit($result); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | |
@@ -472,30 +472,30 @@ discard block |
||
472 | 472 | * @param mixed $form GF Form or Form ID |
473 | 473 | * @return false|null|string Returns the input ID of the approved field. Returns NULL if no approved fields were found. Returns false if $form_id wasn't set. |
474 | 474 | */ |
475 | - static public function get_approved_column( $form ) { |
|
475 | + static public function get_approved_column($form) { |
|
476 | 476 | |
477 | - if( empty( $form ) ) { |
|
477 | + if (empty($form)) { |
|
478 | 478 | return null; |
479 | 479 | } |
480 | 480 | |
481 | - if( !is_array( $form ) ) { |
|
482 | - $form = GVCommon::get_form( $form ); |
|
481 | + if (!is_array($form)) { |
|
482 | + $form = GVCommon::get_form($form); |
|
483 | 483 | } |
484 | 484 | |
485 | - foreach( $form['fields'] as $key => $field ) { |
|
485 | + foreach ($form['fields'] as $key => $field) { |
|
486 | 486 | |
487 | - $field = (array) $field; |
|
487 | + $field = (array)$field; |
|
488 | 488 | |
489 | - if( !empty( $field['gravityview_approved'] ) ) { |
|
490 | - if( !empty($field['inputs'][0]['id']) ) { |
|
489 | + if (!empty($field['gravityview_approved'])) { |
|
490 | + if (!empty($field['inputs'][0]['id'])) { |
|
491 | 491 | return $field['inputs'][0]['id']; |
492 | 492 | } |
493 | 493 | } |
494 | 494 | |
495 | 495 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
496 | - if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) { |
|
497 | - foreach ( $field['inputs'] as $key2 => $input ) { |
|
498 | - if ( strtolower( $input['label'] ) == 'approved' ) { |
|
496 | + if ('checkbox' == $field['type'] && isset($field['inputs']) && is_array($field['inputs'])) { |
|
497 | + foreach ($field['inputs'] as $key2 => $input) { |
|
498 | + if (strtolower($input['label']) == 'approved') { |
|
499 | 499 | return $input['id']; |
500 | 500 | } |
501 | 501 | } |
@@ -507,70 +507,70 @@ discard block |
||
507 | 507 | |
508 | 508 | |
509 | 509 | |
510 | - static public function add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string ) { |
|
510 | + static public function add_entry_approved_hidden_input($form_id, $field_id, $value, $entry, $query_string) { |
|
511 | 511 | |
512 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry['id'] ) ) { |
|
512 | + if (!GVCommon::has_cap('gravityview_moderate_entries', $entry['id'])) { |
|
513 | 513 | return; |
514 | 514 | } |
515 | 515 | |
516 | - if( empty( $entry['id'] ) ) { |
|
516 | + if (empty($entry['id'])) { |
|
517 | 517 | return; |
518 | 518 | } |
519 | 519 | |
520 | - if( gform_get_meta( $entry['id'], 'is_approved' ) ) { |
|
521 | - echo '<input type="hidden" class="entry_approved" id="entry_approved_'. $entry['id'] .'" value="true" />'; |
|
520 | + if (gform_get_meta($entry['id'], 'is_approved')) { |
|
521 | + echo '<input type="hidden" class="entry_approved" id="entry_approved_'.$entry['id'].'" value="true" />'; |
|
522 | 522 | } |
523 | 523 | } |
524 | 524 | |
525 | 525 | |
526 | 526 | |
527 | 527 | |
528 | - function add_scripts_and_styles( $hook ) { |
|
528 | + function add_scripts_and_styles($hook) { |
|
529 | 529 | |
530 | - if( !class_exists( 'RGForms' ) ) { |
|
530 | + if (!class_exists('RGForms')) { |
|
531 | 531 | |
532 | - do_action( 'gravityview_log_error', 'GravityView_Admin_ApproveEntries[add_scripts_and_styles] RGForms does not exist.' ); |
|
532 | + do_action('gravityview_log_error', 'GravityView_Admin_ApproveEntries[add_scripts_and_styles] RGForms does not exist.'); |
|
533 | 533 | |
534 | 534 | return; |
535 | 535 | } |
536 | 536 | |
537 | 537 | // enqueue styles & scripts gf_entries |
538 | 538 | // But only if we're on the main Entries page, not on reports pages |
539 | - if( RGForms::get_page() === 'entry_list' ) { |
|
539 | + if (RGForms::get_page() === 'entry_list') { |
|
540 | 540 | |
541 | 541 | $form_id = RGForms::get('id'); |
542 | 542 | |
543 | 543 | // If there are no forms identified, use the first form. That's how GF does it. |
544 | - if( empty( $form_id ) && class_exists('RGFormsModel') ) { |
|
544 | + if (empty($form_id) && class_exists('RGFormsModel')) { |
|
545 | 545 | $forms = gravityview_get_forms(); |
546 | - if( !empty( $forms ) ) { |
|
546 | + if (!empty($forms)) { |
|
547 | 547 | $form_id = $forms[0]['id']; |
548 | 548 | } |
549 | 549 | } |
550 | 550 | |
551 | - $approvedcolumn = self::get_approved_column( $form_id ); |
|
551 | + $approvedcolumn = self::get_approved_column($form_id); |
|
552 | 552 | |
553 | - wp_register_style( 'gravityview_entries_list', plugins_url('assets/css/admin-entries-list.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
554 | - wp_enqueue_style( 'gravityview_entries_list' ); |
|
553 | + wp_register_style('gravityview_entries_list', plugins_url('assets/css/admin-entries-list.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version); |
|
554 | + wp_enqueue_style('gravityview_entries_list'); |
|
555 | 555 | |
556 | 556 | $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
557 | 557 | |
558 | - wp_register_script( 'gravityview_gf_entries_scripts', plugins_url('assets/js/admin-entries-list'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version ); |
|
559 | - wp_enqueue_script( 'gravityview_gf_entries_scripts' ); |
|
558 | + wp_register_script('gravityview_gf_entries_scripts', plugins_url('assets/js/admin-entries-list'.$script_debug.'.js', GRAVITYVIEW_FILE), array('jquery'), GravityView_Plugin::version); |
|
559 | + wp_enqueue_script('gravityview_gf_entries_scripts'); |
|
560 | 560 | |
561 | - wp_localize_script( 'gravityview_gf_entries_scripts', 'gvGlobals', array( |
|
562 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxgfentries'), |
|
561 | + wp_localize_script('gravityview_gf_entries_scripts', 'gvGlobals', array( |
|
562 | + 'nonce' => wp_create_nonce('gravityview_ajaxgfentries'), |
|
563 | 563 | 'form_id' => $form_id, |
564 | - 'show_column' => (int)$this->show_approve_entry_column( $form_id ), |
|
565 | - 'add_bulk_action' => (int)GVCommon::has_cap( 'gravityview_moderate_entries' ), |
|
566 | - 'label_approve' => __( 'Approve', 'gravityview' ) , |
|
567 | - 'label_disapprove' => __( 'Disapprove', 'gravityview' ), |
|
564 | + 'show_column' => (int)$this->show_approve_entry_column($form_id), |
|
565 | + 'add_bulk_action' => (int)GVCommon::has_cap('gravityview_moderate_entries'), |
|
566 | + 'label_approve' => __('Approve', 'gravityview'), |
|
567 | + 'label_disapprove' => __('Disapprove', 'gravityview'), |
|
568 | 568 | 'bulk_message' => $this->bulk_update_message, |
569 | - 'approve_title' => __( 'Entry not approved for directory viewing. Click to approve this entry.', 'gravityview'), |
|
570 | - 'unapprove_title' => __( 'Entry approved for directory viewing. Click to disapprove this entry.', 'gravityview'), |
|
571 | - 'column_title' => __( 'Show entry in directory view?', 'gravityview'), |
|
572 | - 'column_link' => esc_url( add_query_arg( array('sort' => $approvedcolumn) ) ), |
|
573 | - ) ); |
|
569 | + 'approve_title' => __('Entry not approved for directory viewing. Click to approve this entry.', 'gravityview'), |
|
570 | + 'unapprove_title' => __('Entry approved for directory viewing. Click to disapprove this entry.', 'gravityview'), |
|
571 | + 'column_title' => __('Show entry in directory view?', 'gravityview'), |
|
572 | + 'column_link' => esc_url(add_query_arg(array('sort' => $approvedcolumn))), |
|
573 | + )); |
|
574 | 574 | |
575 | 575 | } |
576 | 576 | |
@@ -585,22 +585,22 @@ discard block |
||
585 | 585 | * |
586 | 586 | * @return bool True: Show column; False: hide column |
587 | 587 | */ |
588 | - private function show_approve_entry_column( $form_id ) { |
|
588 | + private function show_approve_entry_column($form_id) { |
|
589 | 589 | |
590 | - $show_approve_column = GVCommon::has_cap( 'gravityview_moderate_entries' ); |
|
590 | + $show_approve_column = GVCommon::has_cap('gravityview_moderate_entries'); |
|
591 | 591 | |
592 | 592 | /** |
593 | 593 | * @filter `gravityview/approve_entries/hide-if-no-connections` Return true to hide reject/approve if there are no connected Views |
594 | 594 | * @since 1.7.2 |
595 | 595 | * @param boolean $hide_if_no_connections |
596 | 596 | */ |
597 | - $hide_if_no_connections = apply_filters('gravityview/approve_entries/hide-if-no-connections', false ); |
|
597 | + $hide_if_no_connections = apply_filters('gravityview/approve_entries/hide-if-no-connections', false); |
|
598 | 598 | |
599 | - if( $hide_if_no_connections ) { |
|
599 | + if ($hide_if_no_connections) { |
|
600 | 600 | |
601 | - $connected_views = gravityview_get_connected_views( $form_id ); |
|
601 | + $connected_views = gravityview_get_connected_views($form_id); |
|
602 | 602 | |
603 | - if( empty( $connected_views ) ) { |
|
603 | + if (empty($connected_views)) { |
|
604 | 604 | $show_approve_column = false; |
605 | 605 | } |
606 | 606 | } |
@@ -610,17 +610,17 @@ discard block |
||
610 | 610 | * @param boolean $show_approve_column Whether the column will be shown |
611 | 611 | * @param int $form_id The ID of the Gravity Forms form for which entries are being shown |
612 | 612 | */ |
613 | - $show_approve_column = apply_filters('gravityview/approve_entries/show-column', $show_approve_column, $form_id ); |
|
613 | + $show_approve_column = apply_filters('gravityview/approve_entries/show-column', $show_approve_column, $form_id); |
|
614 | 614 | |
615 | 615 | return $show_approve_column; |
616 | 616 | } |
617 | 617 | |
618 | - function register_gform_noconflict_script( $scripts ) { |
|
618 | + function register_gform_noconflict_script($scripts) { |
|
619 | 619 | $scripts[] = 'gravityview_gf_entries_scripts'; |
620 | 620 | return $scripts; |
621 | 621 | } |
622 | 622 | |
623 | - function register_gform_noconflict_style( $styles ) { |
|
623 | + function register_gform_noconflict_style($styles) { |
|
624 | 624 | $styles[] = 'gravityview_entries_list'; |
625 | 625 | return $styles; |
626 | 626 | } |
@@ -432,23 +432,17 @@ |
||
432 | 432 | do_action( 'gravityview_log_error', __METHOD__ . ' entry_id or form_id are empty.', $_POST ); |
433 | 433 | |
434 | 434 | $result = false; |
435 | - } |
|
436 | - |
|
437 | - else if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxgfentries' ) ) { |
|
435 | + } else if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxgfentries' ) ) { |
|
438 | 436 | |
439 | 437 | do_action( 'gravityview_log_error', __METHOD__ . ' Security check failed.', $_POST ); |
440 | 438 | |
441 | 439 | $result = false; |
442 | - } |
|
443 | - |
|
444 | - else if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $_POST['entry_id'] ) ) { |
|
440 | + } else if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $_POST['entry_id'] ) ) { |
|
445 | 441 | |
446 | 442 | do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
447 | 443 | |
448 | 444 | $result = false; |
449 | - } |
|
450 | - |
|
451 | - else { |
|
445 | + } else { |
|
452 | 446 | |
453 | 447 | $result = self::update_approved( $_POST['entry_id'], $_POST['approved'], $_POST['form_id'] ); |
454 | 448 |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Get HTML links relating to a connected form, like Edit, Entries, Settings, Preview |
329 | - * @param array|int $form_id Gravity Forms forms array, or the form ID |
|
329 | + * @param array|int $form Gravity Forms forms array, or the form ID |
|
330 | 330 | * @param boolean $include_form_link Whether to include the bold name of the form in the output |
331 | 331 | * @return string HTML links |
332 | 332 | */ |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | * $blacklist_field_types - contains the field types which are not proper to be shown in a directory. |
548 | 548 | * |
549 | 549 | * @access public |
550 | - * @param int $form_id Gravity Forms Form ID (default: '') |
|
550 | + * @param int $form Gravity Forms Form ID (default: '') |
|
551 | 551 | * @param string $context (default: 'single') |
552 | 552 | * @return void |
553 | 553 | */ |
@@ -592,6 +592,10 @@ discard block |
||
592 | 592 | $this->render_additional_fields( $form, $context ); |
593 | 593 | } |
594 | 594 | |
595 | + /** |
|
596 | + * @param string $form |
|
597 | + * @param string $context |
|
598 | + */ |
|
595 | 599 | function render_additional_fields( $form, $context ) { |
596 | 600 | |
597 | 601 | /** |
@@ -790,6 +794,7 @@ discard block |
||
790 | 794 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
791 | 795 | * @param array $rows The layout structure: rows, columns and areas |
792 | 796 | * @param array $values Saved objects |
797 | + * @param string $template_id |
|
793 | 798 | * @return void |
794 | 799 | */ |
795 | 800 | function render_active_areas( $template_id, $type, $zone, $rows, $values ) { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * Start using GravityView_Render_Settings::render_setting_row |
111 | 111 | */ |
112 | 112 | public static function render_setting_row( $key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s' ) { |
113 | - _deprecated_function( 'GravityView_Admin_Views::render_setting_row', '1.1.7', 'GravityView_Render_Settings::render_setting_row' ); |
|
113 | + _deprecated_function( 'GravityView_Admin_Views::render_setting_row', '1.1.7', 'GravityView_Render_Settings::render_setting_row' ); |
|
114 | 114 | GravityView_Render_Settings::render_setting_row( $key, $current_settings, $override_input, $name , $id ); |
115 | 115 | } |
116 | 116 | |
@@ -688,22 +688,22 @@ discard block |
||
688 | 688 | /** |
689 | 689 | * @since 1.7.2 |
690 | 690 | */ |
691 | - 'other_entries' => array( |
|
692 | - 'label' => __('Other Entries', 'gravityview'), |
|
693 | - 'type' => 'other_entries', |
|
694 | - 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
695 | - ), |
|
696 | - ); |
|
691 | + 'other_entries' => array( |
|
692 | + 'label' => __('Other Entries', 'gravityview'), |
|
693 | + 'type' => 'other_entries', |
|
694 | + 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
695 | + ), |
|
696 | + ); |
|
697 | 697 | |
698 | 698 | |
699 | 699 | if( 'single' !== $zone) { |
700 | 700 | |
701 | - $entry_default_fields['entry_link'] = array( |
|
702 | - 'label' => __('Link to Entry', 'gravityview'), |
|
703 | - 'desc' => __('A dedicated link to the single entry with customizable text.', 'gravityview'), |
|
704 | - 'type' => 'entry_link', |
|
705 | - ); |
|
706 | - } |
|
701 | + $entry_default_fields['entry_link'] = array( |
|
702 | + 'label' => __('Link to Entry', 'gravityview'), |
|
703 | + 'desc' => __('A dedicated link to the single entry with customizable text.', 'gravityview'), |
|
704 | + 'type' => 'entry_link', |
|
705 | + ); |
|
706 | + } |
|
707 | 707 | |
708 | 708 | } // if not zone directory or single |
709 | 709 | |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | * @param string|array $form form_ID or form object |
715 | 715 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
716 | 716 | */ |
717 | - return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone); |
|
717 | + return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
@@ -1028,15 +1028,15 @@ discard block |
||
1028 | 1028 | GFForms::register_scripts(); |
1029 | 1029 | |
1030 | 1030 | $scripts = array( |
1031 | - 'sack', |
|
1032 | - 'gform_gravityforms', |
|
1033 | - 'gform_forms', |
|
1034 | - 'gform_form_admin', |
|
1035 | - 'jquery-ui-autocomplete' |
|
1031 | + 'sack', |
|
1032 | + 'gform_gravityforms', |
|
1033 | + 'gform_forms', |
|
1034 | + 'gform_form_admin', |
|
1035 | + 'jquery-ui-autocomplete' |
|
1036 | 1036 | ); |
1037 | 1037 | |
1038 | 1038 | if ( wp_is_mobile() ) |
1039 | - $scripts[] = 'jquery-touch-punch'; |
|
1039 | + $scripts[] = 'jquery-touch-punch'; |
|
1040 | 1040 | |
1041 | 1041 | foreach ($scripts as $script) { |
1042 | 1042 | wp_enqueue_script( $script ); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | /** If this file is called directly, abort. */ |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | die; |
17 | 17 | } |
18 | 18 | |
@@ -22,40 +22,40 @@ discard block |
||
22 | 22 | |
23 | 23 | function __construct() { |
24 | 24 | |
25 | - add_action( 'save_post', array( $this, 'save_postdata' ) ); |
|
25 | + add_action('save_post', array($this, 'save_postdata')); |
|
26 | 26 | |
27 | 27 | // set the blacklist field types across the entire plugin |
28 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'default_field_blacklist' ), 10, 2 ); |
|
28 | + add_filter('gravityview_blacklist_field_types', array($this, 'default_field_blacklist'), 10, 2); |
|
29 | 29 | |
30 | 30 | // Tooltips |
31 | - add_filter( 'gform_tooltips', array( $this, 'tooltips') ); |
|
31 | + add_filter('gform_tooltips', array($this, 'tooltips')); |
|
32 | 32 | |
33 | 33 | // adding styles and scripts |
34 | - add_action( 'admin_enqueue_scripts', array( 'GravityView_Admin_Views', 'add_scripts_and_styles'), 999 ); |
|
35 | - add_filter( 'gform_noconflict_styles', array( $this, 'register_no_conflict') ); |
|
36 | - add_filter( 'gform_noconflict_scripts', array( $this, 'register_no_conflict') ); |
|
37 | - add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict') ); |
|
38 | - add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict') ); |
|
39 | - |
|
40 | - add_action( 'gravityview_render_directory_active_areas', array( $this, 'render_directory_active_areas'), 10, 4 ); |
|
41 | - add_action( 'gravityview_render_widgets_active_areas', array( $this, 'render_widgets_active_areas'), 10, 3 ); |
|
42 | - add_action( 'gravityview_render_available_fields', array( $this, 'render_available_fields'), 10, 2 ); |
|
43 | - add_action( 'gravityview_render_available_widgets', array( $this, 'render_available_widgets') ); |
|
44 | - add_action( 'gravityview_render_active_areas', array( $this, 'render_active_areas'), 10, 5 ); |
|
34 | + add_action('admin_enqueue_scripts', array('GravityView_Admin_Views', 'add_scripts_and_styles'), 999); |
|
35 | + add_filter('gform_noconflict_styles', array($this, 'register_no_conflict')); |
|
36 | + add_filter('gform_noconflict_scripts', array($this, 'register_no_conflict')); |
|
37 | + add_filter('gravityview_noconflict_styles', array($this, 'register_no_conflict')); |
|
38 | + add_filter('gravityview_noconflict_scripts', array($this, 'register_no_conflict')); |
|
39 | + |
|
40 | + add_action('gravityview_render_directory_active_areas', array($this, 'render_directory_active_areas'), 10, 4); |
|
41 | + add_action('gravityview_render_widgets_active_areas', array($this, 'render_widgets_active_areas'), 10, 3); |
|
42 | + add_action('gravityview_render_available_fields', array($this, 'render_available_fields'), 10, 2); |
|
43 | + add_action('gravityview_render_available_widgets', array($this, 'render_available_widgets')); |
|
44 | + add_action('gravityview_render_active_areas', array($this, 'render_active_areas'), 10, 5); |
|
45 | 45 | |
46 | 46 | // @todo check if this hook is needed.. |
47 | 47 | //add_action( 'gravityview_render_field_options', array( $this, 'render_field_options'), 10, 9 ); |
48 | 48 | |
49 | 49 | // Add Connected Form column |
50 | - add_filter('manage_gravityview_posts_columns' , array( $this, 'add_post_type_columns' ) ); |
|
50 | + add_filter('manage_gravityview_posts_columns', array($this, 'add_post_type_columns')); |
|
51 | 51 | |
52 | - add_filter( 'gform_toolbar_menu', array( 'GravityView_Admin_Views', 'gform_toolbar_menu' ), 10, 2 ); |
|
52 | + add_filter('gform_toolbar_menu', array('GravityView_Admin_Views', 'gform_toolbar_menu'), 10, 2); |
|
53 | 53 | |
54 | - add_action( 'manage_gravityview_posts_custom_column', array( $this, 'add_custom_column_content'), 10, 2 ); |
|
54 | + add_action('manage_gravityview_posts_custom_column', array($this, 'add_custom_column_content'), 10, 2); |
|
55 | 55 | |
56 | - add_action( 'restrict_manage_posts', array( $this, 'add_view_dropdown' ) ); |
|
56 | + add_action('restrict_manage_posts', array($this, 'add_view_dropdown')); |
|
57 | 57 | |
58 | - add_action( 'pre_get_posts', array( $this, 'filter_pre_get_posts_by_gravityview_form_id' ) ); |
|
58 | + add_action('pre_get_posts', array($this, 'filter_pre_get_posts_by_gravityview_form_id')); |
|
59 | 59 | |
60 | 60 | } |
61 | 61 | |
@@ -63,42 +63,42 @@ discard block |
||
63 | 63 | * @since 1.15 |
64 | 64 | * @param WP_Query $query |
65 | 65 | */ |
66 | - public function filter_pre_get_posts_by_gravityview_form_id( &$query ) { |
|
66 | + public function filter_pre_get_posts_by_gravityview_form_id(&$query) { |
|
67 | 67 | global $pagenow; |
68 | 68 | |
69 | - if ( !is_admin() ) { |
|
69 | + if (!is_admin()) { |
|
70 | 70 | return; |
71 | 71 | } |
72 | 72 | |
73 | - if( 'edit.php' !== $pagenow || ! rgget( 'gravityview_form_id' ) || ! isset( $query->query_vars[ 'post_type' ] ) ) { |
|
73 | + if ('edit.php' !== $pagenow || !rgget('gravityview_form_id') || !isset($query->query_vars['post_type'])) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
77 | - if ( $query->query_vars[ 'post_type' ] == 'gravityview' ) { |
|
78 | - $query->set( 'meta_query', array( |
|
77 | + if ($query->query_vars['post_type'] == 'gravityview') { |
|
78 | + $query->set('meta_query', array( |
|
79 | 79 | array( |
80 | 80 | 'key' => '_gravityview_form_id', |
81 | - 'value' => rgget( 'gravityview_form_id' ), |
|
81 | + 'value' => rgget('gravityview_form_id'), |
|
82 | 82 | ) |
83 | - ) ); |
|
83 | + )); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | 87 | function add_view_dropdown() { |
88 | 88 | $current_screen = get_current_screen(); |
89 | 89 | |
90 | - if( 'gravityview' !== $current_screen->post_type ) { |
|
90 | + if ('gravityview' !== $current_screen->post_type) { |
|
91 | 91 | return; |
92 | 92 | } |
93 | 93 | |
94 | 94 | $forms = gravityview_get_forms(); |
95 | - $current_form = rgget( 'gravityview_form_id' ); |
|
95 | + $current_form = rgget('gravityview_form_id'); |
|
96 | 96 | // If there are no forms to select, show no forms. |
97 | - if( !empty( $forms ) ) { ?> |
|
97 | + if (!empty($forms)) { ?> |
|
98 | 98 | <select name="gravityview_form_id" id="gravityview_form_id"> |
99 | - <option value="" <?php selected( '', $current_form, true ); ?>><?php esc_html_e( 'All forms', 'gravityview' ); ?></option> |
|
100 | - <?php foreach( $forms as $form ) { ?> |
|
101 | - <option value="<?php echo $form['id']; ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option> |
|
99 | + <option value="" <?php selected('', $current_form, true); ?>><?php esc_html_e('All forms', 'gravityview'); ?></option> |
|
100 | + <?php foreach ($forms as $form) { ?> |
|
101 | + <option value="<?php echo $form['id']; ?>" <?php selected($form['id'], $current_form, true); ?>><?php echo esc_html($form['title']); ?></option> |
|
102 | 102 | <?php } ?> |
103 | 103 | </select> |
104 | 104 | <?php } |
@@ -109,18 +109,18 @@ discard block |
||
109 | 109 | * @deprecated since 1.2 |
110 | 110 | * Start using GravityView_Render_Settings::render_setting_row |
111 | 111 | */ |
112 | - public static function render_setting_row( $key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s' ) { |
|
113 | - _deprecated_function( 'GravityView_Admin_Views::render_setting_row', '1.1.7', 'GravityView_Render_Settings::render_setting_row' ); |
|
114 | - GravityView_Render_Settings::render_setting_row( $key, $current_settings, $override_input, $name , $id ); |
|
112 | + public static function render_setting_row($key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s') { |
|
113 | + _deprecated_function('GravityView_Admin_Views::render_setting_row', '1.1.7', 'GravityView_Render_Settings::render_setting_row'); |
|
114 | + GravityView_Render_Settings::render_setting_row($key, $current_settings, $override_input, $name, $id); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
118 | 118 | * @deprecated since 1.2 |
119 | 119 | * Start using GravityView_Render_Settings::render_field_option |
120 | 120 | */ |
121 | - public static function render_field_option( $name = '', $option, $curr_value = NULL ) { |
|
122 | - _deprecated_function( 'GravityView_Admin_Views::render_field_option', '1.1.7', 'GravityView_Render_Settings::render_field_option' ); |
|
123 | - return GravityView_Render_Settings::render_field_option( $name, $option, $curr_value ); |
|
121 | + public static function render_field_option($name = '', $option, $curr_value = NULL) { |
|
122 | + _deprecated_function('GravityView_Admin_Views::render_field_option', '1.1.7', 'GravityView_Render_Settings::render_field_option'); |
|
123 | + return GravityView_Render_Settings::render_field_option($name, $option, $curr_value); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -130,31 +130,31 @@ discard block |
||
130 | 130 | * @param int $id ID of the current Gravity form |
131 | 131 | * @return array Modified array |
132 | 132 | */ |
133 | - static function gform_toolbar_menu( $menu_items = array(), $id = NULL ) { |
|
133 | + static function gform_toolbar_menu($menu_items = array(), $id = NULL) { |
|
134 | 134 | |
135 | - $connected_views = gravityview_get_connected_views( $id ); |
|
135 | + $connected_views = gravityview_get_connected_views($id); |
|
136 | 136 | |
137 | - if( empty( $connected_views ) ) { |
|
137 | + if (empty($connected_views)) { |
|
138 | 138 | return $menu_items; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $sub_menu_items = array(); |
142 | - foreach ( (array)$connected_views as $view ) { |
|
142 | + foreach ((array)$connected_views as $view) { |
|
143 | 143 | |
144 | - if( ! GVCommon::has_cap( 'edit_gravityview', $view->ID ) ) { |
|
144 | + if (!GVCommon::has_cap('edit_gravityview', $view->ID)) { |
|
145 | 145 | continue; |
146 | 146 | } |
147 | 147 | |
148 | - $label = empty( $view->post_title ) ? sprintf( __('No Title (View #%d)', 'gravityview' ), $view->ID ) : $view->post_title; |
|
148 | + $label = empty($view->post_title) ? sprintf(__('No Title (View #%d)', 'gravityview'), $view->ID) : $view->post_title; |
|
149 | 149 | |
150 | 150 | $sub_menu_items[] = array( |
151 | - 'label' => esc_attr( $label ), |
|
152 | - 'url' => admin_url( 'post.php?action=edit&post='.$view->ID ), |
|
151 | + 'label' => esc_attr($label), |
|
152 | + 'url' => admin_url('post.php?action=edit&post='.$view->ID), |
|
153 | 153 | ); |
154 | 154 | } |
155 | 155 | |
156 | 156 | // If there were no items added, then let's create the parent menu |
157 | - if( $sub_menu_items ) { |
|
157 | + if ($sub_menu_items) { |
|
158 | 158 | |
159 | 159 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
160 | 160 | $sub_menu_items[] = array( |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | ); |
166 | 166 | |
167 | 167 | $menu_items['gravityview'] = array( |
168 | - 'label' => __( 'Connected Views', 'gravityview' ), |
|
168 | + 'label' => __('Connected Views', 'gravityview'), |
|
169 | 169 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
170 | - 'title' => __( 'GravityView Views using this form as a data source', 'gravityview' ), |
|
170 | + 'title' => __('GravityView Views using this form as a data source', 'gravityview'), |
|
171 | 171 | 'url' => '#', |
172 | 172 | 'onclick' => 'return false;', |
173 | 173 | 'menu_class' => 'gv_connected_forms gf_form_toolbar_settings', |
174 | - 'link_class' => ( 1 === 1 ? '' : 'gf_toolbar_disabled' ), |
|
174 | + 'link_class' => (1 === 1 ? '' : 'gf_toolbar_disabled'), |
|
175 | 175 | 'sub_menu_items' => $sub_menu_items, |
176 | 176 | 'priority' => 0, |
177 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
177 | + 'capabilities' => array('edit_gravityviews'), |
|
178 | 178 | ); |
179 | 179 | } |
180 | 180 | |
@@ -189,16 +189,16 @@ discard block |
||
189 | 189 | * @access public |
190 | 190 | * @return array Default blacklist fields merged with existing blacklist fields |
191 | 191 | */ |
192 | - function default_field_blacklist( $array = array(), $context = NULL ) { |
|
192 | + function default_field_blacklist($array = array(), $context = NULL) { |
|
193 | 193 | |
194 | - $add = array( 'captcha', 'page' ); |
|
194 | + $add = array('captcha', 'page'); |
|
195 | 195 | |
196 | 196 | // Don't allowing editing the following values: |
197 | - if( $context === 'edit' ) { |
|
197 | + if ($context === 'edit') { |
|
198 | 198 | $add[] = 'post_id'; |
199 | 199 | } |
200 | 200 | |
201 | - $return = array_merge( $array, $add ); |
|
201 | + $return = array_merge($array, $add); |
|
202 | 202 | |
203 | 203 | return $return; |
204 | 204 | } |
@@ -208,33 +208,33 @@ discard block |
||
208 | 208 | * @param array $tooltips Array of Gravity Forms tooltips |
209 | 209 | * @return array Modified tooltips array |
210 | 210 | */ |
211 | - public function tooltips( $tooltips = array() ) { |
|
211 | + public function tooltips($tooltips = array()) { |
|
212 | 212 | |
213 | 213 | $gv_tooltips = array(); |
214 | 214 | |
215 | 215 | // Generate tooltips for View settings |
216 | - $default_args = GravityView_View_Data::get_default_args( true ); |
|
216 | + $default_args = GravityView_View_Data::get_default_args(true); |
|
217 | 217 | |
218 | - foreach ( $default_args as $key => $arg ) { |
|
218 | + foreach ($default_args as $key => $arg) { |
|
219 | 219 | |
220 | 220 | // If an arg has `tooltip` defined, but it's false, don't display a tooltip |
221 | - if( isset( $arg['tooltip'] ) && empty( $arg['tooltip'] ) ) { continue; } |
|
221 | + if (isset($arg['tooltip']) && empty($arg['tooltip'])) { continue; } |
|
222 | 222 | |
223 | 223 | // By default, use `tooltip` if defined. |
224 | - $tooltip = empty( $arg['tooltip'] ) ? NULL : $arg['tooltip']; |
|
224 | + $tooltip = empty($arg['tooltip']) ? NULL : $arg['tooltip']; |
|
225 | 225 | |
226 | 226 | // Otherwise, use the description as a tooltip. |
227 | - if( empty( $tooltip ) && !empty( $arg['desc'] ) ) { |
|
227 | + if (empty($tooltip) && !empty($arg['desc'])) { |
|
228 | 228 | $tooltip = $arg['desc']; |
229 | 229 | } |
230 | 230 | |
231 | 231 | // If there's no tooltip set, continue |
232 | - if( empty( $tooltip ) ) { |
|
232 | + if (empty($tooltip)) { |
|
233 | 233 | continue; |
234 | 234 | } |
235 | 235 | |
236 | 236 | // Add the tooltip |
237 | - $gv_tooltips[ 'gv_'.$key ] = array( |
|
237 | + $gv_tooltips['gv_'.$key] = array( |
|
238 | 238 | 'title' => $arg['label'], |
239 | 239 | 'value' => $tooltip, |
240 | 240 | ); |
@@ -243,20 +243,20 @@ discard block |
||
243 | 243 | |
244 | 244 | $gv_tooltips['gv_css_merge_tags'] = array( |
245 | 245 | 'title' => __('CSS Merge Tags', 'gravityview'), |
246 | - 'value' => sprintf( __( 'Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview'), '<code>', '</code>' ) |
|
246 | + 'value' => sprintf(__('Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview'), '<code>', '</code>') |
|
247 | 247 | ); |
248 | 248 | |
249 | 249 | /** |
250 | 250 | * @filter `gravityview_tooltips` The tooltips GravityView adds to the Gravity Forms tooltip array |
251 | 251 | * @param array $gv_tooltips Associative array with unique keys containing array of `title` and `value` keys, as expected by `gform_tooltips` filter |
252 | 252 | */ |
253 | - $gv_tooltips = apply_filters( 'gravityview_tooltips', $gv_tooltips ); |
|
253 | + $gv_tooltips = apply_filters('gravityview_tooltips', $gv_tooltips); |
|
254 | 254 | |
255 | - foreach ( $gv_tooltips as $key => $tooltip ) { |
|
255 | + foreach ($gv_tooltips as $key => $tooltip) { |
|
256 | 256 | |
257 | - $title = empty( $tooltip['title'] ) ? '' : '<h6>'.esc_html( $tooltip['title'] ) .'</h6>'; |
|
257 | + $title = empty($tooltip['title']) ? '' : '<h6>'.esc_html($tooltip['title']).'</h6>'; |
|
258 | 258 | |
259 | - $tooltips[ $key ] = $title . wpautop( esc_html( $tooltip['value'] ) ); |
|
259 | + $tooltips[$key] = $title.wpautop(esc_html($tooltip['value'])); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | return $tooltips; |
@@ -270,27 +270,27 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @return void |
272 | 272 | */ |
273 | - public function add_custom_column_content( $column_name = NULL, $post_id ) { |
|
273 | + public function add_custom_column_content($column_name = NULL, $post_id) { |
|
274 | 274 | |
275 | 275 | $output = ''; |
276 | 276 | |
277 | - switch ( $column_name ) { |
|
277 | + switch ($column_name) { |
|
278 | 278 | case 'gv_template': |
279 | 279 | |
280 | - $template_id = gravityview_get_template_id( $post_id ); |
|
280 | + $template_id = gravityview_get_template_id($post_id); |
|
281 | 281 | |
282 | 282 | // All Views should have a connected form. If it doesn't, that's not right. |
283 | - if ( empty( $template_id ) ) { |
|
284 | - do_action( 'gravityview_log_error', sprintf( __METHOD__ . ' View ID %s does not have a connected template.', $post_id ) ); |
|
283 | + if (empty($template_id)) { |
|
284 | + do_action('gravityview_log_error', sprintf(__METHOD__.' View ID %s does not have a connected template.', $post_id)); |
|
285 | 285 | break; |
286 | 286 | } |
287 | 287 | |
288 | 288 | $templates = gravityview_get_registered_templates(); |
289 | 289 | |
290 | - $template = isset( $templates[ $template_id ] ) ? $templates[ $template_id ] : false; |
|
290 | + $template = isset($templates[$template_id]) ? $templates[$template_id] : false; |
|
291 | 291 | |
292 | 292 | // Generate backup if label doesn't exist: `example_name` => `Example Name` |
293 | - $template_id_pretty = ucwords( implode( ' ', explode( '_', $template_id ) ) ); |
|
293 | + $template_id_pretty = ucwords(implode(' ', explode('_', $template_id))); |
|
294 | 294 | |
295 | 295 | $output = $template ? $template['label'] : $template_id_pretty; |
296 | 296 | |
@@ -298,24 +298,24 @@ discard block |
||
298 | 298 | |
299 | 299 | case 'gv_connected_form': |
300 | 300 | |
301 | - $form_id = gravityview_get_form_id( $post_id ); |
|
301 | + $form_id = gravityview_get_form_id($post_id); |
|
302 | 302 | |
303 | 303 | // All Views should have a connected form. If it doesn't, that's not right. |
304 | - if ( empty( $form_id ) ) { |
|
305 | - do_action( 'gravityview_log_error', sprintf( '[add_data_source_column_content] View ID %s does not have a connected GF form.', $post_id ) ); |
|
306 | - $output = __( 'Not connected.', 'gravityview' ); |
|
304 | + if (empty($form_id)) { |
|
305 | + do_action('gravityview_log_error', sprintf('[add_data_source_column_content] View ID %s does not have a connected GF form.', $post_id)); |
|
306 | + $output = __('Not connected.', 'gravityview'); |
|
307 | 307 | break; |
308 | 308 | } |
309 | 309 | |
310 | - $form = gravityview_get_form( $form_id ); |
|
310 | + $form = gravityview_get_form($form_id); |
|
311 | 311 | |
312 | - if ( ! $form ) { |
|
313 | - do_action( 'gravityview_log_error', sprintf( '[add_data_source_column_content] Connected form not found: Form #%d', $form_id ) ); |
|
312 | + if (!$form) { |
|
313 | + do_action('gravityview_log_error', sprintf('[add_data_source_column_content] Connected form not found: Form #%d', $form_id)); |
|
314 | 314 | |
315 | - $output = __( 'The connected form can not be found; it may no longer exist.', 'gravityview' ); |
|
315 | + $output = __('The connected form can not be found; it may no longer exist.', 'gravityview'); |
|
316 | 316 | } |
317 | 317 | |
318 | - $output = self::get_connected_form_links( $form ); |
|
318 | + $output = self::get_connected_form_links($form); |
|
319 | 319 | |
320 | 320 | break; |
321 | 321 | } |
@@ -330,47 +330,47 @@ discard block |
||
330 | 330 | * @param boolean $include_form_link Whether to include the bold name of the form in the output |
331 | 331 | * @return string HTML links |
332 | 332 | */ |
333 | - static public function get_connected_form_links( $form, $include_form_link = true ) { |
|
333 | + static public function get_connected_form_links($form, $include_form_link = true) { |
|
334 | 334 | |
335 | 335 | // Either the form is empty or the form ID is 0, not yet set. |
336 | - if( empty( $form ) ) { |
|
336 | + if (empty($form)) { |
|
337 | 337 | return ''; |
338 | 338 | } |
339 | 339 | |
340 | 340 | // The $form is passed as the form ID |
341 | - if( !is_array( $form ) ) { |
|
342 | - $form = gravityview_get_form( $form ); |
|
341 | + if (!is_array($form)) { |
|
342 | + $form = gravityview_get_form($form); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | $form_id = $form['id']; |
346 | 346 | $links = array(); |
347 | 347 | |
348 | - if( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) { |
|
349 | - $form_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&id=%d', $form_id ) ); |
|
350 | - $form_link = '<strong class="gv-form-title">'.gravityview_get_link( $form_url, $form['title'], 'class=row-title' ).'</strong>'; |
|
351 | - $links[] = '<span>'.gravityview_get_link( $form_url, __('Edit Form', 'gravityview') ).'</span>'; |
|
348 | + if (GVCommon::has_cap('gravityforms_edit_forms')) { |
|
349 | + $form_url = admin_url(sprintf('admin.php?page=gf_edit_forms&id=%d', $form_id)); |
|
350 | + $form_link = '<strong class="gv-form-title">'.gravityview_get_link($form_url, $form['title'], 'class=row-title').'</strong>'; |
|
351 | + $links[] = '<span>'.gravityview_get_link($form_url, __('Edit Form', 'gravityview')).'</span>'; |
|
352 | 352 | } else { |
353 | - $form_link = '<strong class="gv-form-title">'. esc_html( $form['title'] ). '</strong>'; |
|
353 | + $form_link = '<strong class="gv-form-title">'.esc_html($form['title']).'</strong>'; |
|
354 | 354 | } |
355 | 355 | |
356 | - if( GVCommon::has_cap( 'gravityforms_view_entries' ) ) { |
|
357 | - $entries_url = admin_url( sprintf( 'admin.php?page=gf_entries&id=%d', $form_id ) ); |
|
358 | - $links[] = '<span>'.gravityview_get_link( $entries_url, __('Entries', 'gravityview') ).'</span>'; |
|
356 | + if (GVCommon::has_cap('gravityforms_view_entries')) { |
|
357 | + $entries_url = admin_url(sprintf('admin.php?page=gf_entries&id=%d', $form_id)); |
|
358 | + $links[] = '<span>'.gravityview_get_link($entries_url, __('Entries', 'gravityview')).'</span>'; |
|
359 | 359 | } |
360 | 360 | |
361 | - if( GVCommon::has_cap( array( 'gravityforms_edit_settings', 'gravityview_view_settings' ) ) ) { |
|
362 | - $settings_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&view=settings&id=%d', $form_id ) ); |
|
363 | - $links[] = '<span>'.gravityview_get_link( $settings_url, __('Settings', 'gravityview'), 'title='.__('Edit settings for this form', 'gravityview') ).'</span>'; |
|
361 | + if (GVCommon::has_cap(array('gravityforms_edit_settings', 'gravityview_view_settings'))) { |
|
362 | + $settings_url = admin_url(sprintf('admin.php?page=gf_edit_forms&view=settings&id=%d', $form_id)); |
|
363 | + $links[] = '<span>'.gravityview_get_link($settings_url, __('Settings', 'gravityview'), 'title='.__('Edit settings for this form', 'gravityview')).'</span>'; |
|
364 | 364 | } |
365 | 365 | |
366 | - if( GVCommon::has_cap( array("gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms") ) ) { |
|
367 | - $preview_url = site_url( sprintf( '?gf_page=preview&id=%d', $form_id ) ); |
|
368 | - $links[] = '<span>'.gravityview_get_link( $preview_url, __('Preview Form', 'gravityview'), 'title='.__('Preview this form', 'gravityview') ).'</span>'; |
|
366 | + if (GVCommon::has_cap(array("gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms"))) { |
|
367 | + $preview_url = site_url(sprintf('?gf_page=preview&id=%d', $form_id)); |
|
368 | + $links[] = '<span>'.gravityview_get_link($preview_url, __('Preview Form', 'gravityview'), 'title='.__('Preview this form', 'gravityview')).'</span>'; |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | $output = ''; |
372 | 372 | |
373 | - if( !empty( $include_form_link ) ) { |
|
373 | + if (!empty($include_form_link)) { |
|
374 | 374 | $output .= $form_link; |
375 | 375 | } |
376 | 376 | |
@@ -380,9 +380,9 @@ discard block |
||
380 | 380 | * @param array $links Links to show |
381 | 381 | * @param array $form Gravity Forms form array |
382 | 382 | */ |
383 | - $links = apply_filters( 'gravityview_connected_form_links', $links, $form ); |
|
383 | + $links = apply_filters('gravityview_connected_form_links', $links, $form); |
|
384 | 384 | |
385 | - $output .= '<div class="row-actions">'. implode( ' | ', $links ) .'</div>'; |
|
385 | + $output .= '<div class="row-actions">'.implode(' | ', $links).'</div>'; |
|
386 | 386 | |
387 | 387 | return $output; |
388 | 388 | } |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | * Add the Data Source column to the Views page |
392 | 392 | * @param array $columns Columns array |
393 | 393 | */ |
394 | - public function add_post_type_columns( $columns ) { |
|
394 | + public function add_post_type_columns($columns) { |
|
395 | 395 | |
396 | 396 | // Get the date column and save it for later to add back in. |
397 | 397 | // This adds it after the Data Source column. |
398 | 398 | // This way, we don't need to do array_slice, array_merge, etc. |
399 | 399 | $date = $columns['date']; |
400 | - unset( $columns['date'] ); |
|
400 | + unset($columns['date']); |
|
401 | 401 | |
402 | 402 | $data_source_required_caps = array( |
403 | 403 | 'gravityforms_edit_forms', |
@@ -408,11 +408,11 @@ discard block |
||
408 | 408 | 'gravityforms_preview_forms', |
409 | 409 | ); |
410 | 410 | |
411 | - if( GVCommon::has_cap( $data_source_required_caps ) ) { |
|
412 | - $columns['gv_connected_form'] = __( 'Data Source', 'gravityview' ); |
|
411 | + if (GVCommon::has_cap($data_source_required_caps)) { |
|
412 | + $columns['gv_connected_form'] = __('Data Source', 'gravityview'); |
|
413 | 413 | } |
414 | 414 | |
415 | - $columns['gv_template'] = _x( 'Template', 'Column title that shows what template is being used for Views', 'gravityview' ); |
|
415 | + $columns['gv_template'] = _x('Template', 'Column title that shows what template is being used for Views', 'gravityview'); |
|
416 | 416 | |
417 | 417 | // Add the date back in. |
418 | 418 | $columns['date'] = $date; |
@@ -427,91 +427,91 @@ discard block |
||
427 | 427 | * @param int $post_id Currently saved Post ID |
428 | 428 | * @return void |
429 | 429 | */ |
430 | - function save_postdata( $post_id ) { |
|
430 | + function save_postdata($post_id) { |
|
431 | 431 | |
432 | - if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){ |
|
432 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
433 | 433 | return; |
434 | 434 | } |
435 | 435 | |
436 | 436 | // validate post_type |
437 | - if ( ! isset( $_POST['post_type'] ) || 'gravityview' != $_POST['post_type'] ) { |
|
437 | + if (!isset($_POST['post_type']) || 'gravityview' != $_POST['post_type']) { |
|
438 | 438 | return; |
439 | 439 | } |
440 | 440 | |
441 | 441 | // validate user can edit and save View |
442 | - if ( ! GVCommon::has_cap( 'edit_gravityview', $post_id ) ) { |
|
443 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Current user does not have the capability to edit View #' . $post_id, wp_get_current_user() ); |
|
442 | + if (!GVCommon::has_cap('edit_gravityview', $post_id)) { |
|
443 | + do_action('gravityview_log_error', __METHOD__.' - Current user does not have the capability to edit View #'.$post_id, wp_get_current_user()); |
|
444 | 444 | return; |
445 | 445 | } |
446 | 446 | |
447 | - do_action( 'gravityview_log_debug', '[save_postdata] Saving View post type.', $_POST ); |
|
447 | + do_action('gravityview_log_debug', '[save_postdata] Saving View post type.', $_POST); |
|
448 | 448 | |
449 | 449 | $statii = array(); |
450 | 450 | |
451 | 451 | // check if this is a start fresh View |
452 | - if ( isset( $_POST['gravityview_select_form_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_form_nonce'], 'gravityview_select_form' ) ) { |
|
452 | + if (isset($_POST['gravityview_select_form_nonce']) && wp_verify_nonce($_POST['gravityview_select_form_nonce'], 'gravityview_select_form')) { |
|
453 | 453 | |
454 | - $form_id = !empty( $_POST['gravityview_form_id'] ) ? $_POST['gravityview_form_id'] : ''; |
|
454 | + $form_id = !empty($_POST['gravityview_form_id']) ? $_POST['gravityview_form_id'] : ''; |
|
455 | 455 | // save form id |
456 | - $statii['form_id'] = update_post_meta( $post_id, '_gravityview_form_id', $form_id ); |
|
456 | + $statii['form_id'] = update_post_meta($post_id, '_gravityview_form_id', $form_id); |
|
457 | 457 | |
458 | 458 | } |
459 | 459 | |
460 | - if( false === GVCommon::has_cap( 'gravityforms_create_form' ) && empty( $statii['form_id'] ) ) { |
|
461 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Current user does not have the capability to create a new Form.', wp_get_current_user() ); |
|
460 | + if (false === GVCommon::has_cap('gravityforms_create_form') && empty($statii['form_id'])) { |
|
461 | + do_action('gravityview_log_error', __METHOD__.' - Current user does not have the capability to create a new Form.', wp_get_current_user()); |
|
462 | 462 | return; |
463 | 463 | } |
464 | 464 | |
465 | 465 | // Was this a start fresh? |
466 | - if ( ! empty( $_POST['gravityview_form_id_start_fresh'] ) ) { |
|
467 | - $statii['start_fresh'] = add_post_meta( $post_id, '_gravityview_start_fresh', 1 ); |
|
466 | + if (!empty($_POST['gravityview_form_id_start_fresh'])) { |
|
467 | + $statii['start_fresh'] = add_post_meta($post_id, '_gravityview_start_fresh', 1); |
|
468 | 468 | } else { |
469 | - $statii['start_fresh'] = delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
469 | + $statii['start_fresh'] = delete_post_meta($post_id, '_gravityview_start_fresh'); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | // Check if we have a template id |
473 | - if ( isset( $_POST['gravityview_select_template_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_template_nonce'], 'gravityview_select_template' ) ) { |
|
473 | + if (isset($_POST['gravityview_select_template_nonce']) && wp_verify_nonce($_POST['gravityview_select_template_nonce'], 'gravityview_select_template')) { |
|
474 | 474 | |
475 | - $template_id = !empty( $_POST['gravityview_directory_template'] ) ? $_POST['gravityview_directory_template'] : ''; |
|
475 | + $template_id = !empty($_POST['gravityview_directory_template']) ? $_POST['gravityview_directory_template'] : ''; |
|
476 | 476 | |
477 | 477 | // now save template id |
478 | - $statii['directory_template'] = update_post_meta( $post_id, '_gravityview_directory_template', $template_id ); |
|
478 | + $statii['directory_template'] = update_post_meta($post_id, '_gravityview_directory_template', $template_id); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | |
482 | 482 | // save View Configuration metabox |
483 | - if ( isset( $_POST['gravityview_view_configuration_nonce'] ) && wp_verify_nonce( $_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration' ) ) { |
|
483 | + if (isset($_POST['gravityview_view_configuration_nonce']) && wp_verify_nonce($_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration')) { |
|
484 | 484 | |
485 | 485 | // template settings |
486 | - if( empty( $_POST['template_settings'] ) ) { |
|
486 | + if (empty($_POST['template_settings'])) { |
|
487 | 487 | $_POST['template_settings'] = array(); |
488 | 488 | } |
489 | - $statii['template_settings'] = update_post_meta( $post_id, '_gravityview_template_settings', $_POST['template_settings'] ); |
|
489 | + $statii['template_settings'] = update_post_meta($post_id, '_gravityview_template_settings', $_POST['template_settings']); |
|
490 | 490 | |
491 | 491 | $fields = array(); |
492 | 492 | |
493 | 493 | // Directory&single Visible Fields |
494 | - if( !empty( $preset_fields ) ) { |
|
494 | + if (!empty($preset_fields)) { |
|
495 | 495 | |
496 | 496 | $fields = $preset_fields; |
497 | 497 | |
498 | - } elseif( !empty( $_POST['fields'] ) ) { |
|
498 | + } elseif (!empty($_POST['fields'])) { |
|
499 | 499 | |
500 | - if( !is_array( $_POST['fields'] ) ) { |
|
500 | + if (!is_array($_POST['fields'])) { |
|
501 | 501 | |
502 | 502 | // Fields are passed as a jQuery-serialized array, created in admin-views.js in the serializeForm method |
503 | 503 | // Not using parse_str due to max_input_vars limitation |
504 | 504 | $fields_holder = array(); |
505 | - GVCommon::gv_parse_str( $_POST['fields'], $fields_holder ); |
|
505 | + GVCommon::gv_parse_str($_POST['fields'], $fields_holder); |
|
506 | 506 | |
507 | - if( isset( $fields_holder['fields'] ) ) { |
|
507 | + if (isset($fields_holder['fields'])) { |
|
508 | 508 | |
509 | 509 | // When parsed, there's a m |
510 | 510 | $fields = $fields_holder['fields']; |
511 | 511 | |
512 | 512 | } else { |
513 | 513 | |
514 | - do_action('gravityview_log_error', '[save_postdata] No `fields` key was found after parsing $fields string', $fields_holder ); |
|
514 | + do_action('gravityview_log_error', '[save_postdata] No `fields` key was found after parsing $fields string', $fields_holder); |
|
515 | 515 | |
516 | 516 | } |
517 | 517 | |
@@ -522,24 +522,24 @@ discard block |
||
522 | 522 | } |
523 | 523 | } |
524 | 524 | |
525 | - $statii['directory_fields'] = update_post_meta( $post_id, '_gravityview_directory_fields', $fields ); |
|
525 | + $statii['directory_fields'] = update_post_meta($post_id, '_gravityview_directory_fields', $fields); |
|
526 | 526 | |
527 | 527 | // Directory Visible Widgets |
528 | - if( empty( $_POST['widgets'] ) ) { |
|
528 | + if (empty($_POST['widgets'])) { |
|
529 | 529 | $_POST['widgets'] = array(); |
530 | 530 | } |
531 | - $statii['directory_widgets'] = update_post_meta( $post_id, '_gravityview_directory_widgets', $_POST['widgets'] ); |
|
531 | + $statii['directory_widgets'] = update_post_meta($post_id, '_gravityview_directory_widgets', $_POST['widgets']); |
|
532 | 532 | |
533 | 533 | } // end save view configuration |
534 | 534 | |
535 | - do_action('gravityview_log_debug', '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array_map( 'intval', $statii ) ); |
|
535 | + do_action('gravityview_log_debug', '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array_map('intval', $statii)); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
539 | 539 | * @deprecated 1.1.6 |
540 | 540 | */ |
541 | 541 | function render_label() { |
542 | - _deprecated_function( 'GravityView_Admin_Views::render_label()', '1.1.6', 'Use the GravityView_Admin_View_Field class instead.' ); |
|
542 | + _deprecated_function('GravityView_Admin_Views::render_label()', '1.1.6', 'Use the GravityView_Admin_View_Field class instead.'); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | /** |
@@ -551,33 +551,33 @@ discard block |
||
551 | 551 | * @param string $context (default: 'single') |
552 | 552 | * @return void |
553 | 553 | */ |
554 | - function render_available_fields( $form = '', $context = 'single' ) { |
|
554 | + function render_available_fields($form = '', $context = 'single') { |
|
555 | 555 | |
556 | 556 | /** |
557 | 557 | * @filter `gravityview_blacklist_field_types` Modify the types of fields that shouldn't be shown in a View. |
558 | 558 | * @param[in,out] array $blacklist_field_types Array of field types to block for this context. |
559 | 559 | * @param[in] string $context View context ('single', 'directory', or 'edit') |
560 | 560 | */ |
561 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array(), $context ); |
|
561 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array(), $context); |
|
562 | 562 | |
563 | - $fields = $this->get_available_fields( $form, $context ); |
|
563 | + $fields = $this->get_available_fields($form, $context); |
|
564 | 564 | |
565 | 565 | $output = ''; |
566 | 566 | |
567 | - if( !empty( $fields ) ) { |
|
567 | + if (!empty($fields)) { |
|
568 | 568 | |
569 | - foreach( $fields as $id => $details ) { |
|
569 | + foreach ($fields as $id => $details) { |
|
570 | 570 | |
571 | - if( in_array( $details['type'], $blacklist_field_types ) ) { |
|
571 | + if (in_array($details['type'], $blacklist_field_types)) { |
|
572 | 572 | continue; |
573 | 573 | } |
574 | 574 | |
575 | 575 | // Edit mode only allows editing the parent fields, not single inputs. |
576 | - if( $context === 'edit' && !empty( $details['parent'] ) ) { |
|
576 | + if ($context === 'edit' && !empty($details['parent'])) { |
|
577 | 577 | continue; |
578 | 578 | } |
579 | 579 | |
580 | - $output .= new GravityView_Admin_View_Field( $details['label'], $id, $details ); |
|
580 | + $output .= new GravityView_Admin_View_Field($details['label'], $id, $details); |
|
581 | 581 | |
582 | 582 | } // End foreach |
583 | 583 | } |
@@ -585,22 +585,22 @@ discard block |
||
585 | 585 | echo $output; |
586 | 586 | |
587 | 587 | // For the EDIT view we only want to allow the form fields. |
588 | - if( $context === 'edit' ) { |
|
588 | + if ($context === 'edit') { |
|
589 | 589 | return; |
590 | 590 | } |
591 | 591 | |
592 | - $this->render_additional_fields( $form, $context ); |
|
592 | + $this->render_additional_fields($form, $context); |
|
593 | 593 | } |
594 | 594 | |
595 | - function render_additional_fields( $form, $context ) { |
|
595 | + function render_additional_fields($form, $context) { |
|
596 | 596 | |
597 | 597 | /** |
598 | 598 | * @filter `gravityview_additional_fields` non-standard Fields to show at the bottom of the field picker |
599 | 599 | * @param array $additional_fields Associative array of field arrays, with `label_text`, `desc`, `field_id`, `label_type`, `input_type`, `field_options`, and `settings_html` keys |
600 | 600 | */ |
601 | - $additional_fields = apply_filters( 'gravityview_additional_fields', array( |
|
601 | + $additional_fields = apply_filters('gravityview_additional_fields', array( |
|
602 | 602 | array( |
603 | - 'label_text' => __( '+ Add All Fields', 'gravityview' ), |
|
603 | + 'label_text' => __('+ Add All Fields', 'gravityview'), |
|
604 | 604 | 'desc' => __('Add all the available fields at once.', 'gravityview'), |
605 | 605 | 'field_id' => 'all-fields', |
606 | 606 | 'label_type' => 'field', |
@@ -610,11 +610,11 @@ discard block |
||
610 | 610 | ) |
611 | 611 | )); |
612 | 612 | |
613 | - if( !empty( $additional_fields )) { |
|
614 | - foreach ( (array)$additional_fields as $item ) { |
|
613 | + if (!empty($additional_fields)) { |
|
614 | + foreach ((array)$additional_fields as $item) { |
|
615 | 615 | |
616 | 616 | // Prevent items from not having index set |
617 | - $item = wp_parse_args( $item, array( |
|
617 | + $item = wp_parse_args($item, array( |
|
618 | 618 | 'label_text' => NULL, |
619 | 619 | 'field_id' => NULL, |
620 | 620 | 'label_type' => NULL, |
@@ -624,13 +624,13 @@ discard block |
||
624 | 624 | )); |
625 | 625 | |
626 | 626 | // Backward compat. |
627 | - if( !empty( $item['field_options'] ) ) { |
|
627 | + if (!empty($item['field_options'])) { |
|
628 | 628 | // Use settings_html from now on. |
629 | 629 | $item['settings_html'] = $item['field_options']; |
630 | 630 | } |
631 | 631 | |
632 | 632 | // Render a label for each of them |
633 | - echo new GravityView_Admin_View_Field( $item['label_text'], $item['field_id'], $item ); |
|
633 | + echo new GravityView_Admin_View_Field($item['label_text'], $item['field_id'], $item); |
|
634 | 634 | |
635 | 635 | } |
636 | 636 | } |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | |
648 | 648 | $entry_default_fields = array(); |
649 | 649 | |
650 | - if( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
650 | + if (in_array($zone, array('directory', 'single'))) { |
|
651 | 651 | |
652 | 652 | $entry_default_fields = array( |
653 | 653 | 'id' => array( |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | ); |
697 | 697 | |
698 | 698 | |
699 | - if( 'single' !== $zone) { |
|
699 | + if ('single' !== $zone) { |
|
700 | 700 | |
701 | 701 | $entry_default_fields['entry_link'] = array( |
702 | 702 | 'label' => __('Link to Entry', 'gravityview'), |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | * @param string|array $form form_ID or form object |
715 | 715 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
716 | 716 | */ |
717 | - return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone); |
|
717 | + return apply_filters('gravityview_entry_default_fields', $entry_default_fields, $form, $zone); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
@@ -723,25 +723,25 @@ discard block |
||
723 | 723 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
724 | 724 | * @return array fields |
725 | 725 | */ |
726 | - function get_available_fields( $form = '', $zone = NULL ) { |
|
726 | + function get_available_fields($form = '', $zone = NULL) { |
|
727 | 727 | |
728 | - if( empty( $form ) ) { |
|
729 | - do_action( 'gravityview_log_error', '[get_available_fields] $form is empty' ); |
|
728 | + if (empty($form)) { |
|
729 | + do_action('gravityview_log_error', '[get_available_fields] $form is empty'); |
|
730 | 730 | return array(); |
731 | 731 | } |
732 | 732 | |
733 | 733 | // get form fields |
734 | - $fields = gravityview_get_form_fields( $form, true ); |
|
734 | + $fields = gravityview_get_form_fields($form, true); |
|
735 | 735 | |
736 | 736 | // get meta fields ( only if form was already created ) |
737 | - if( !is_array( $form ) ) { |
|
738 | - $meta_fields = gravityview_get_entry_meta( $form ); |
|
737 | + if (!is_array($form)) { |
|
738 | + $meta_fields = gravityview_get_entry_meta($form); |
|
739 | 739 | } else { |
740 | 740 | $meta_fields = array(); |
741 | 741 | } |
742 | 742 | |
743 | 743 | // get default fields |
744 | - $default_fields = $this->get_entry_default_fields( $form, $zone ); |
|
744 | + $default_fields = $this->get_entry_default_fields($form, $zone); |
|
745 | 745 | |
746 | 746 | //merge without loosing the keys |
747 | 747 | $fields = $fields + $meta_fields + $default_fields; |
@@ -758,11 +758,11 @@ discard block |
||
758 | 758 | |
759 | 759 | $widgets = $this->get_registered_widgets(); |
760 | 760 | |
761 | - if( !empty( $widgets ) ) { |
|
761 | + if (!empty($widgets)) { |
|
762 | 762 | |
763 | - foreach( $widgets as $id => $details ) { |
|
763 | + foreach ($widgets as $id => $details) { |
|
764 | 764 | |
765 | - echo new GravityView_Admin_View_Widget( $details['label'], $id, $details ); |
|
765 | + echo new GravityView_Admin_View_Widget($details['label'], $id, $details); |
|
766 | 766 | |
767 | 767 | } |
768 | 768 | } |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | * @filter `gravityview_register_directory_widgets` Get the list of registered widgets. Each item is used to instantiate a GravityView_Admin_View_Widget object |
780 | 780 | * @param array $registered_widgets Empty array |
781 | 781 | */ |
782 | - $registered_widgets = apply_filters( 'gravityview_register_directory_widgets', array() ); |
|
782 | + $registered_widgets = apply_filters('gravityview_register_directory_widgets', array()); |
|
783 | 783 | |
784 | 784 | return $registered_widgets; |
785 | 785 | } |
@@ -792,67 +792,67 @@ discard block |
||
792 | 792 | * @param array $values Saved objects |
793 | 793 | * @return void |
794 | 794 | */ |
795 | - function render_active_areas( $template_id, $type, $zone, $rows, $values ) { |
|
795 | + function render_active_areas($template_id, $type, $zone, $rows, $values) { |
|
796 | 796 | global $post; |
797 | 797 | |
798 | - if( $type === 'widget' ) { |
|
799 | - $button_label = __( 'Add Widget', 'gravityview' ); |
|
798 | + if ($type === 'widget') { |
|
799 | + $button_label = __('Add Widget', 'gravityview'); |
|
800 | 800 | } else { |
801 | - $button_label = __( 'Add Field', 'gravityview' ); |
|
801 | + $button_label = __('Add Field', 'gravityview'); |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | $available_items = array(); |
805 | 805 | |
806 | 806 | // if saved values, get available fields to label everyone |
807 | - if( !empty( $values ) && ( !empty( $post->ID ) || !empty( $_POST['template_id'] ) ) ) { |
|
807 | + if (!empty($values) && (!empty($post->ID) || !empty($_POST['template_id']))) { |
|
808 | 808 | |
809 | - if( !empty( $_POST['template_id'] ) ) { |
|
810 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
809 | + if (!empty($_POST['template_id'])) { |
|
810 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
811 | 811 | } else { |
812 | - $form = gravityview_get_form_id( $post->ID ); |
|
812 | + $form = gravityview_get_form_id($post->ID); |
|
813 | 813 | } |
814 | 814 | |
815 | - if( 'field' === $type ) { |
|
816 | - $available_items = $this->get_available_fields( $form, $zone ); |
|
815 | + if ('field' === $type) { |
|
816 | + $available_items = $this->get_available_fields($form, $zone); |
|
817 | 817 | } else { |
818 | 818 | $available_items = $this->get_registered_widgets(); |
819 | 819 | } |
820 | 820 | |
821 | 821 | } |
822 | 822 | |
823 | - foreach( $rows as $row ) : |
|
824 | - foreach( $row as $col => $areas ) : |
|
823 | + foreach ($rows as $row) : |
|
824 | + foreach ($row as $col => $areas) : |
|
825 | 825 | $column = ($col == '2-2') ? '1-2' : $col; ?> |
826 | 826 | |
827 | - <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
|
827 | + <div class="gv-grid-col-<?php echo esc_attr($column); ?>"> |
|
828 | 828 | |
829 | - <?php foreach( $areas as $area ) : ?> |
|
829 | + <?php foreach ($areas as $area) : ?> |
|
830 | 830 | |
831 | 831 | <div class="gv-droppable-area"> |
832 | - <div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>"> |
|
832 | + <div class="active-drop active-drop-<?php echo esc_attr($type); ?>" data-areaid="<?php echo esc_attr($zone.'_'.$area['areaid']); ?>"> |
|
833 | 833 | |
834 | 834 | <?php // render saved fields |
835 | 835 | |
836 | - if( !empty( $values[ $zone .'_'. $area['areaid'] ] ) ) { |
|
836 | + if (!empty($values[$zone.'_'.$area['areaid']])) { |
|
837 | 837 | |
838 | - foreach( $values[ $zone .'_'. $area['areaid'] ] as $uniqid => $field ) { |
|
838 | + foreach ($values[$zone.'_'.$area['areaid']] as $uniqid => $field) { |
|
839 | 839 | |
840 | 840 | $input_type = NULL; |
841 | - $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
|
841 | + $original_item = isset($available_items[$field['id']]) ? $available_items[$field['id']] : false; |
|
842 | 842 | |
843 | - if( !$original_item ) { |
|
843 | + if (!$original_item) { |
|
844 | 844 | |
845 | - do_action('gravityview_log_error', 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array('available_items' => $available_items, 'field' => $field )); |
|
845 | + do_action('gravityview_log_error', 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array('available_items' => $available_items, 'field' => $field)); |
|
846 | 846 | |
847 | 847 | $original_item = $field; |
848 | 848 | } else { |
849 | 849 | |
850 | - $input_type = isset( $original_item['type'] ) ? $original_item['type'] : NULL; |
|
850 | + $input_type = isset($original_item['type']) ? $original_item['type'] : NULL; |
|
851 | 851 | |
852 | 852 | } |
853 | 853 | |
854 | 854 | // Field options dialog box |
855 | - $field_options = GravityView_Render_Settings::render_field_options( $type, $template_id, $field['id'], $original_item['label'], $zone .'_'. $area['areaid'], $input_type, $uniqid, $field, $zone, $original_item ); |
|
855 | + $field_options = GravityView_Render_Settings::render_field_options($type, $template_id, $field['id'], $original_item['label'], $zone.'_'.$area['areaid'], $input_type, $uniqid, $field, $zone, $original_item); |
|
856 | 856 | |
857 | 857 | $item = array( |
858 | 858 | 'input_type' => $input_type, |
@@ -861,16 +861,16 @@ discard block |
||
861 | 861 | ); |
862 | 862 | |
863 | 863 | // Merge the values with the current item to pass things like widget descriptions and original field names |
864 | - if( $original_item ) { |
|
865 | - $item = wp_parse_args( $item, $original_item ); |
|
864 | + if ($original_item) { |
|
865 | + $item = wp_parse_args($item, $original_item); |
|
866 | 866 | } |
867 | 867 | |
868 | - switch( $type ) { |
|
868 | + switch ($type) { |
|
869 | 869 | case 'widget': |
870 | - echo new GravityView_Admin_View_Widget( $item['label'], $field['id'], $item, $field ); |
|
870 | + echo new GravityView_Admin_View_Widget($item['label'], $field['id'], $item, $field); |
|
871 | 871 | break; |
872 | 872 | default: |
873 | - echo new GravityView_Admin_View_Field( $item['label'], $field['id'], $item, $field ); |
|
873 | + echo new GravityView_Admin_View_Field($item['label'], $field['id'], $item, $field); |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | |
@@ -880,11 +880,11 @@ discard block |
||
880 | 880 | |
881 | 881 | } // End if zone is not empty ?> |
882 | 882 | |
883 | - <span class="drop-message"><?php echo sprintf(esc_attr__('"+ %s" or drag existing %ss here.', 'gravityview'), $button_label, $type ); ?></span> |
|
883 | + <span class="drop-message"><?php echo sprintf(esc_attr__('"+ %s" or drag existing %ss here.', 'gravityview'), $button_label, $type); ?></span> |
|
884 | 884 | </div> |
885 | 885 | <div class="gv-droppable-area-action"> |
886 | - <a href="#" class="gv-add-field button-secondary" title="" data-objecttype="<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>"><?php echo '+ '.esc_html( $button_label ); ?></a> |
|
887 | - <p class="gv-droppable-area-title"><strong><?php echo esc_html( $area['title'] ); ?></strong><?php if( !empty( $area['subtitle'] ) ) { ?><span class="gv-droppable-area-subtitle"> – <?php echo esc_html( $area['subtitle'] ); ?></span><?php } ?></p> |
|
886 | + <a href="#" class="gv-add-field button-secondary" title="" data-objecttype="<?php echo esc_attr($type); ?>" data-areaid="<?php echo esc_attr($zone.'_'.$area['areaid']); ?>" data-context="<?php echo esc_attr($zone); ?>"><?php echo '+ '.esc_html($button_label); ?></a> |
|
887 | + <p class="gv-droppable-area-title"><strong><?php echo esc_html($area['title']); ?></strong><?php if (!empty($area['subtitle'])) { ?><span class="gv-droppable-area-subtitle"> – <?php echo esc_html($area['subtitle']); ?></span><?php } ?></p> |
|
888 | 888 | </div> |
889 | 889 | </div> |
890 | 890 | |
@@ -901,13 +901,13 @@ discard block |
||
901 | 901 | * @param string $post_id Current Post ID (view) |
902 | 902 | * @return string html |
903 | 903 | */ |
904 | - function render_widgets_active_areas( $template_id = '', $zone, $post_id = '' ) { |
|
904 | + function render_widgets_active_areas($template_id = '', $zone, $post_id = '') { |
|
905 | 905 | |
906 | 906 | $default_widget_areas = GravityView_Plugin::get_default_widget_areas(); |
907 | 907 | |
908 | 908 | $widgets = array(); |
909 | - if( !empty( $post_id ) ) { |
|
910 | - $widgets = get_post_meta( $post_id, '_gravityview_directory_widgets', true ); |
|
909 | + if (!empty($post_id)) { |
|
910 | + $widgets = get_post_meta($post_id, '_gravityview_directory_widgets', true); |
|
911 | 911 | |
912 | 912 | } |
913 | 913 | |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | ?> |
916 | 916 | |
917 | 917 | <div class="gv-grid gv-grid-pad gv-grid-border" id="directory-<?php echo $zone; ?>-widgets"> |
918 | - <?php $this->render_active_areas( $template_id, 'widget', $zone, $default_widget_areas, $widgets ); ?> |
|
918 | + <?php $this->render_active_areas($template_id, 'widget', $zone, $default_widget_areas, $widgets); ?> |
|
919 | 919 | </div> |
920 | 920 | |
921 | 921 | <?php |
@@ -935,36 +935,36 @@ discard block |
||
935 | 935 | * @param string $context (default: 'single') |
936 | 936 | * @return string HTML of the active areas |
937 | 937 | */ |
938 | - function render_directory_active_areas( $template_id = '', $context = 'single', $post_id = '', $echo = false ) { |
|
938 | + function render_directory_active_areas($template_id = '', $context = 'single', $post_id = '', $echo = false) { |
|
939 | 939 | |
940 | - if( empty( $template_id ) ) { |
|
941 | - do_action( 'gravityview_log_debug', '[render_directory_active_areas] $template_id is empty' ); |
|
940 | + if (empty($template_id)) { |
|
941 | + do_action('gravityview_log_debug', '[render_directory_active_areas] $template_id is empty'); |
|
942 | 942 | return; |
943 | 943 | } |
944 | 944 | |
945 | - $template_areas = apply_filters( 'gravityview_template_active_areas', array(), $template_id, $context ); |
|
945 | + $template_areas = apply_filters('gravityview_template_active_areas', array(), $template_id, $context); |
|
946 | 946 | |
947 | - if( empty( $template_areas ) ) { |
|
947 | + if (empty($template_areas)) { |
|
948 | 948 | |
949 | - do_action( 'gravityview_log_debug', '[render_directory_active_areas] No areas defined. Maybe template %s is disabled.', $template_id ); |
|
949 | + do_action('gravityview_log_debug', '[render_directory_active_areas] No areas defined. Maybe template %s is disabled.', $template_id); |
|
950 | 950 | $output = '<div>'; |
951 | - $output .= '<h2 class="description" style="font-size: 16px; margin:0">'. sprintf( esc_html__( 'This View is configured using the %s View type, which is disabled.', 'gravityview' ), '<em>'.$template_id.'</em>' ) .'</h2>'; |
|
951 | + $output .= '<h2 class="description" style="font-size: 16px; margin:0">'.sprintf(esc_html__('This View is configured using the %s View type, which is disabled.', 'gravityview'), '<em>'.$template_id.'</em>').'</h2>'; |
|
952 | 952 | $output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">'.esc_html__('The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview').'</p>'; |
953 | 953 | $output .= '</div>'; |
954 | 954 | } else { |
955 | 955 | |
956 | 956 | $fields = ''; |
957 | - if ( ! empty( $post_id ) ) { |
|
958 | - $fields = gravityview_get_directory_fields( $post_id ); |
|
957 | + if (!empty($post_id)) { |
|
958 | + $fields = gravityview_get_directory_fields($post_id); |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | ob_start(); |
962 | - $this->render_active_areas( $template_id, 'field', $context, $template_areas, $fields ); |
|
962 | + $this->render_active_areas($template_id, 'field', $context, $template_areas, $fields); |
|
963 | 963 | $output = ob_get_clean(); |
964 | 964 | |
965 | 965 | } |
966 | 966 | |
967 | - if( $echo ) { |
|
967 | + if ($echo) { |
|
968 | 968 | echo $output; |
969 | 969 | } |
970 | 970 | |
@@ -978,46 +978,46 @@ discard block |
||
978 | 978 | * @param mixed $hook |
979 | 979 | * @return void |
980 | 980 | */ |
981 | - static function add_scripts_and_styles( $hook ) { |
|
981 | + static function add_scripts_and_styles($hook) { |
|
982 | 982 | global $plugin_page, $pagenow; |
983 | 983 | |
984 | - $is_widgets_page = ( $pagenow === 'widgets.php' ); |
|
984 | + $is_widgets_page = ($pagenow === 'widgets.php'); |
|
985 | 985 | |
986 | 986 | // Add the GV font (with the Astronaut) |
987 | - wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
987 | + wp_enqueue_style('gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version); |
|
988 | 988 | |
989 | - wp_register_script( 'gravityview-jquery-cookie', plugins_url('includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version, true ); |
|
989 | + wp_register_script('gravityview-jquery-cookie', plugins_url('includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE), array('jquery'), GravityView_Plugin::version, true); |
|
990 | 990 | |
991 | 991 | // Don't process any scripts below here if it's not a GravityView page. |
992 | - if( !gravityview_is_admin_page($hook) && !$is_widgets_page ) { return; } |
|
992 | + if (!gravityview_is_admin_page($hook) && !$is_widgets_page) { return; } |
|
993 | 993 | |
994 | 994 | // Only enqueue the following on single pages |
995 | - if( gravityview_is_admin_page($hook, 'single') || $is_widgets_page ) { |
|
995 | + if (gravityview_is_admin_page($hook, 'single') || $is_widgets_page) { |
|
996 | 996 | |
997 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
998 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version ); |
|
997 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
998 | + wp_enqueue_style('gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version); |
|
999 | 999 | |
1000 | 1000 | $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
1001 | 1001 | |
1002 | 1002 | //enqueue scripts |
1003 | - wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), GravityView_Plugin::version ); |
|
1003 | + wp_enqueue_script('gravityview_views_scripts', plugins_url('assets/js/admin-views'.$script_debug.'.js', GRAVITYVIEW_FILE), array('jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore'), GravityView_Plugin::version); |
|
1004 | 1004 | |
1005 | 1005 | wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
1006 | 1006 | 'cookiepath' => COOKIEPATH, |
1007 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1008 | - 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1009 | - 'label_close' => __( 'Close', 'gravityview' ), |
|
1010 | - 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1011 | - 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1012 | - 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1013 | - 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1014 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1015 | - 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1016 | - 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1017 | - 'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ), |
|
1007 | + 'nonce' => wp_create_nonce('gravityview_ajaxviews'), |
|
1008 | + 'label_viewname' => __('Enter View name here', 'gravityview'), |
|
1009 | + 'label_close' => __('Close', 'gravityview'), |
|
1010 | + 'label_cancel' => __('Cancel', 'gravityview'), |
|
1011 | + 'label_continue' => __('Continue', 'gravityview'), |
|
1012 | + 'label_ok' => __('Ok', 'gravityview'), |
|
1013 | + 'label_publisherror' => __('Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview'), |
|
1014 | + 'loading_text' => esc_html__('Loading…', 'gravityview'), |
|
1015 | + 'loading_error' => esc_html__('There was an error loading dynamic content.', 'gravityview'), |
|
1016 | + 'field_loaderror' => __('Error while adding the field. Please try again or contact GravityView support.', 'gravityview'), |
|
1017 | + 'remove_all_fields' => __('Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview'), |
|
1018 | 1018 | )); |
1019 | 1019 | |
1020 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
1020 | + wp_enqueue_style('gravityview_views_styles', plugins_url('assets/css/admin-views.css', GRAVITYVIEW_FILE), array('dashicons', 'wp-jquery-ui-dialog'), GravityView_Plugin::version); |
|
1021 | 1021 | |
1022 | 1022 | self::enqueue_gravity_forms_scripts(); |
1023 | 1023 | |
@@ -1035,25 +1035,25 @@ discard block |
||
1035 | 1035 | 'jquery-ui-autocomplete' |
1036 | 1036 | ); |
1037 | 1037 | |
1038 | - if ( wp_is_mobile() ) |
|
1038 | + if (wp_is_mobile()) |
|
1039 | 1039 | $scripts[] = 'jquery-touch-punch'; |
1040 | 1040 | |
1041 | 1041 | foreach ($scripts as $script) { |
1042 | - wp_enqueue_script( $script ); |
|
1042 | + wp_enqueue_script($script); |
|
1043 | 1043 | } |
1044 | 1044 | } |
1045 | 1045 | |
1046 | - function register_no_conflict( $registered ) { |
|
1046 | + function register_no_conflict($registered) { |
|
1047 | 1047 | |
1048 | 1048 | $filter = current_filter(); |
1049 | 1049 | |
1050 | - if( preg_match('/script/ism', $filter ) ) { |
|
1051 | - $allow_scripts = array( 'jquery-ui-core', 'jquery-ui-dialog', 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'gravityview_views_scripts', 'gravityview-support', 'gravityview-jquery-cookie', 'gravityview_views_datepicker', |
|
1052 | - 'sack', 'gform_gravityforms', 'gform_forms', 'gform_form_admin', 'jquery-ui-autocomplete' ); |
|
1053 | - $registered = array_merge( $registered, $allow_scripts ); |
|
1054 | - } elseif( preg_match('/style/ism', $filter ) ) { |
|
1055 | - $allow_styles = array( 'dashicons', 'wp-jquery-ui-dialog', 'gravityview_views_styles', 'gravityview_global', 'gravityview_views_datepicker' ); |
|
1056 | - $registered = array_merge( $registered, $allow_styles ); |
|
1050 | + if (preg_match('/script/ism', $filter)) { |
|
1051 | + $allow_scripts = array('jquery-ui-core', 'jquery-ui-dialog', 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'gravityview_views_scripts', 'gravityview-support', 'gravityview-jquery-cookie', 'gravityview_views_datepicker', |
|
1052 | + 'sack', 'gform_gravityforms', 'gform_forms', 'gform_form_admin', 'jquery-ui-autocomplete'); |
|
1053 | + $registered = array_merge($registered, $allow_scripts); |
|
1054 | + } elseif (preg_match('/style/ism', $filter)) { |
|
1055 | + $allow_styles = array('dashicons', 'wp-jquery-ui-dialog', 'gravityview_views_styles', 'gravityview_global', 'gravityview_views_datepicker'); |
|
1056 | + $registered = array_merge($registered, $allow_styles); |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | return $registered; |
@@ -1035,8 +1035,9 @@ |
||
1035 | 1035 | 'jquery-ui-autocomplete' |
1036 | 1036 | ); |
1037 | 1037 | |
1038 | - if ( wp_is_mobile() ) |
|
1039 | - $scripts[] = 'jquery-touch-punch'; |
|
1038 | + if ( wp_is_mobile() ) { |
|
1039 | + $scripts[] = 'jquery-touch-punch'; |
|
1040 | + } |
|
1040 | 1041 | |
1041 | 1042 | foreach ($scripts as $script) { |
1042 | 1043 | wp_enqueue_script( $script ); |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * Remove any style or script non-registered in the no conflict mode |
312 | 312 | * @todo Move this to GravityView_Admin_Views |
313 | 313 | * @param WP_Dependencies $wp_objects Object of WP_Styles or WP_Scripts |
314 | - * @param array $required_objects List of registered script/style handles |
|
314 | + * @param string[] $required_objects List of registered script/style handles |
|
315 | 315 | * @param string $type Either 'styles' or 'scripts' |
316 | 316 | * @return void |
317 | 317 | */ |
@@ -472,6 +472,9 @@ discard block |
||
472 | 472 | |
473 | 473 | new GravityView_Admin; |
474 | 474 | |
475 | +/** |
|
476 | + * @param string $page |
|
477 | + */ |
|
475 | 478 | function gravityview_is_admin_page($hook = '', $page = NULL) { |
476 | 479 | return GravityView_Admin::is_admin_page( $hook, $page ); |
477 | 480 | } |
@@ -215,39 +215,39 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | $wp_allowed_scripts = array( |
218 | - 'common', |
|
219 | - 'admin-bar', |
|
220 | - 'autosave', |
|
221 | - 'post', |
|
218 | + 'common', |
|
219 | + 'admin-bar', |
|
220 | + 'autosave', |
|
221 | + 'post', |
|
222 | 222 | 'inline-edit-post', |
223 | - 'utils', |
|
224 | - 'svg-painter', |
|
225 | - 'wp-auth-check', |
|
226 | - 'heartbeat', |
|
223 | + 'utils', |
|
224 | + 'svg-painter', |
|
225 | + 'wp-auth-check', |
|
226 | + 'heartbeat', |
|
227 | 227 | 'media-editor', |
228 | 228 | 'media-upload', |
229 | - 'thickbox', |
|
229 | + 'thickbox', |
|
230 | 230 | 'wp-color-picker', |
231 | 231 | |
232 | - // Settings |
|
232 | + // Settings |
|
233 | 233 | 'gv-admin-edd-license', |
234 | 234 | |
235 | - // Common |
|
236 | - 'select2-js', |
|
237 | - 'qtip-js', |
|
235 | + // Common |
|
236 | + 'select2-js', |
|
237 | + 'qtip-js', |
|
238 | 238 | |
239 | - // jQuery |
|
239 | + // jQuery |
|
240 | 240 | 'jquery', |
241 | - 'jquery-ui-core', |
|
242 | - 'jquery-ui-sortable', |
|
243 | - 'jquery-ui-datepicker', |
|
244 | - 'jquery-ui-dialog', |
|
245 | - 'jquery-ui-slider', |
|
241 | + 'jquery-ui-core', |
|
242 | + 'jquery-ui-sortable', |
|
243 | + 'jquery-ui-datepicker', |
|
244 | + 'jquery-ui-dialog', |
|
245 | + 'jquery-ui-slider', |
|
246 | 246 | 'jquery-ui-dialog', |
247 | 247 | 'jquery-ui-tabs', |
248 | 248 | 'jquery-ui-draggable', |
249 | 249 | 'jquery-ui-droppable', |
250 | - 'jquery-ui-accordion', |
|
250 | + 'jquery-ui-accordion', |
|
251 | 251 | ); |
252 | 252 | |
253 | 253 | $this->remove_conflicts( $wp_scripts, $wp_allowed_scripts, 'scripts' ); |
@@ -281,23 +281,23 @@ discard block |
||
281 | 281 | return; |
282 | 282 | } |
283 | 283 | |
284 | - $wp_allowed_styles = array( |
|
285 | - 'admin-bar', |
|
286 | - 'colors', |
|
287 | - 'ie', |
|
288 | - 'wp-auth-check', |
|
289 | - 'media-views', |
|
284 | + $wp_allowed_styles = array( |
|
285 | + 'admin-bar', |
|
286 | + 'colors', |
|
287 | + 'ie', |
|
288 | + 'wp-auth-check', |
|
289 | + 'media-views', |
|
290 | 290 | 'thickbox', |
291 | 291 | 'dashicons', |
292 | - 'wp-jquery-ui-dialog', |
|
293 | - 'jquery-ui-sortable', |
|
292 | + 'wp-jquery-ui-dialog', |
|
293 | + 'jquery-ui-sortable', |
|
294 | 294 | |
295 | - // Settings |
|
296 | - 'gravityview_settings', |
|
295 | + // Settings |
|
296 | + 'gravityview_settings', |
|
297 | 297 | |
298 | - // @todo qTip styles not loading for some reason! |
|
299 | - 'jquery-qtip.js', |
|
300 | - ); |
|
298 | + // @todo qTip styles not loading for some reason! |
|
299 | + 'jquery-qtip.js', |
|
300 | + ); |
|
301 | 301 | |
302 | 302 | $this->remove_conflicts( $wp_styles, $wp_allowed_styles, 'styles' ); |
303 | 303 | |
@@ -317,32 +317,32 @@ discard block |
||
317 | 317 | */ |
318 | 318 | private function remove_conflicts( &$wp_objects, $required_objects, $type = 'scripts' ) { |
319 | 319 | |
320 | - /** |
|
321 | - * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n |
|
322 | - * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles` |
|
323 | - * @param array $required_objects |
|
324 | - */ |
|
325 | - $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects ); |
|
326 | - |
|
327 | - //reset queue |
|
328 | - $queue = array(); |
|
329 | - foreach( $wp_objects->queue as $object ) { |
|
330 | - if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
331 | - $queue[] = $object; |
|
332 | - } |
|
333 | - } |
|
334 | - $wp_objects->queue = $queue; |
|
335 | - |
|
336 | - $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects ); |
|
337 | - |
|
338 | - //unregistering scripts |
|
339 | - $registered = array(); |
|
340 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
341 | - if( in_array( $handle, $required_objects ) ){ |
|
342 | - $registered[ $handle ] = $script_registration; |
|
343 | - } |
|
344 | - } |
|
345 | - $wp_objects->registered = $registered; |
|
320 | + /** |
|
321 | + * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n |
|
322 | + * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles` |
|
323 | + * @param array $required_objects |
|
324 | + */ |
|
325 | + $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects ); |
|
326 | + |
|
327 | + //reset queue |
|
328 | + $queue = array(); |
|
329 | + foreach( $wp_objects->queue as $object ) { |
|
330 | + if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
331 | + $queue[] = $object; |
|
332 | + } |
|
333 | + } |
|
334 | + $wp_objects->queue = $queue; |
|
335 | + |
|
336 | + $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects ); |
|
337 | + |
|
338 | + //unregistering scripts |
|
339 | + $registered = array(); |
|
340 | + foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
341 | + if( in_array( $handle, $required_objects ) ){ |
|
342 | + $registered[ $handle ] = $script_registration; |
|
343 | + } |
|
344 | + } |
|
345 | + $wp_objects->registered = $registered; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -405,7 +405,6 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @deprecated since 1.12 |
407 | 407 | * @see GravityView_Compatibility::get_plugin_status() |
408 | - |
|
409 | 408 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
410 | 409 | */ |
411 | 410 | static function get_plugin_status( $location = '' ) { |
@@ -4,10 +4,10 @@ discard block |
||
4 | 4 | |
5 | 5 | function __construct() { |
6 | 6 | |
7 | - if( ! is_admin() ) { return; } |
|
7 | + if (!is_admin()) { return; } |
|
8 | 8 | |
9 | 9 | // If Gravity Forms isn't active or compatibile, stop loading |
10 | - if( false === GravityView_Compatibility::is_valid() ) { |
|
10 | + if (false === GravityView_Compatibility::is_valid()) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 | |
@@ -22,22 +22,22 @@ discard block |
||
22 | 22 | private function include_required_files() { |
23 | 23 | |
24 | 24 | // Migrate Class |
25 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-migrate.php' ); |
|
25 | + require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-migrate.php'); |
|
26 | 26 | |
27 | 27 | // Don't load tooltips if on Gravity Forms, otherwise it overrides translations |
28 | - if( class_exists( 'GFCommon' ) && class_exists( 'GFForms' ) && !GFForms::is_gravity_page() ) { |
|
29 | - require_once( GFCommon::get_base_path() . '/tooltips.php' ); |
|
28 | + if (class_exists('GFCommon') && class_exists('GFForms') && !GFForms::is_gravity_page()) { |
|
29 | + require_once(GFCommon::get_base_path().'/tooltips.php'); |
|
30 | 30 | } |
31 | 31 | |
32 | - require_once( GRAVITYVIEW_DIR . 'includes/admin/metaboxes/class-gravityview-admin-metaboxes.php' ); |
|
33 | - require_once( GRAVITYVIEW_DIR . 'includes/admin/entry-list.php' ); |
|
34 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' ); |
|
32 | + require_once(GRAVITYVIEW_DIR.'includes/admin/metaboxes/class-gravityview-admin-metaboxes.php'); |
|
33 | + require_once(GRAVITYVIEW_DIR.'includes/admin/entry-list.php'); |
|
34 | + require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-change-entry-creator.php'); |
|
35 | 35 | |
36 | 36 | /** @since 1.15 **/ |
37 | - require_once( GRAVITYVIEW_DIR . 'includes/admin/class-gravityview-support-port.php' ); |
|
37 | + require_once(GRAVITYVIEW_DIR.'includes/admin/class-gravityview-support-port.php'); |
|
38 | 38 | |
39 | 39 | /** @since 1.6 */ |
40 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-duplicate-view.php' ); |
|
40 | + require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-admin-duplicate-view.php'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -47,21 +47,21 @@ discard block |
||
47 | 47 | private function add_hooks() { |
48 | 48 | |
49 | 49 | // Filter Admin messages |
50 | - add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) ); |
|
51 | - add_filter( 'bulk_post_updated_messages', array( $this, 'post_updated_messages' ) ); |
|
50 | + add_filter('post_updated_messages', array($this, 'post_updated_messages')); |
|
51 | + add_filter('bulk_post_updated_messages', array($this, 'post_updated_messages')); |
|
52 | 52 | |
53 | - add_filter( 'plugin_action_links_'. plugin_basename( GRAVITYVIEW_FILE ) , array( $this, 'plugin_action_links' ) ); |
|
53 | + add_filter('plugin_action_links_'.plugin_basename(GRAVITYVIEW_FILE), array($this, 'plugin_action_links')); |
|
54 | 54 | |
55 | - add_action( 'plugins_loaded', array( $this, 'backend_actions' ), 100 ); |
|
55 | + add_action('plugins_loaded', array($this, 'backend_actions'), 100); |
|
56 | 56 | |
57 | 57 | //Hooks for no-conflict functionality |
58 | - add_action( 'wp_print_scripts', array( $this, 'no_conflict_scripts' ), 1000); |
|
59 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_scripts' ), 9); |
|
58 | + add_action('wp_print_scripts', array($this, 'no_conflict_scripts'), 1000); |
|
59 | + add_action('admin_print_footer_scripts', array($this, 'no_conflict_scripts'), 9); |
|
60 | 60 | |
61 | - add_action( 'wp_print_styles', array( $this, 'no_conflict_styles' ), 1000); |
|
62 | - add_action( 'admin_print_styles', array( $this, 'no_conflict_styles' ), 11); |
|
63 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_styles' ), 1); |
|
64 | - add_action( 'admin_footer', array( $this, 'no_conflict_styles' ), 1); |
|
61 | + add_action('wp_print_styles', array($this, 'no_conflict_styles'), 1000); |
|
62 | + add_action('admin_print_styles', array($this, 'no_conflict_styles'), 11); |
|
63 | + add_action('admin_print_footer_scripts', array($this, 'no_conflict_styles'), 1); |
|
64 | + add_action('admin_footer', array($this, 'no_conflict_styles'), 1); |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | public function backend_actions() { |
75 | 75 | |
76 | 76 | /** @define "GRAVITYVIEW_DIR" "../" */ |
77 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class.field.type.php' ); |
|
78 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class.render.settings.php' ); |
|
79 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-label.php' ); |
|
80 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-views.php' ); |
|
81 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-welcome.php' ); |
|
82 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-add-shortcode.php' ); |
|
83 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
77 | + include_once(GRAVITYVIEW_DIR.'includes/admin/class.field.type.php'); |
|
78 | + include_once(GRAVITYVIEW_DIR.'includes/admin/class.render.settings.php'); |
|
79 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-label.php'); |
|
80 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-views.php'); |
|
81 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-welcome.php'); |
|
82 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-add-shortcode.php'); |
|
83 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-approve-entries.php'); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * @action `gravityview_include_backend_actions` Triggered after all GravityView admin files are loaded |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | * @param array $links Array of action links under GravityView on the plugin page |
100 | 100 | * @return array Action links with Settings and Support included, if the user has the appropriate caps |
101 | 101 | */ |
102 | - public static function plugin_action_links( $links ) { |
|
102 | + public static function plugin_action_links($links) { |
|
103 | 103 | |
104 | 104 | $actions = array(); |
105 | 105 | |
106 | - if( GVCommon::has_cap( 'gravityview_view_settings' ) ) { |
|
107 | - $actions[] = sprintf( '<a href="%s">%s</a>', admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ), esc_html__( 'Settings', 'gravityview' ) ); |
|
106 | + if (GVCommon::has_cap('gravityview_view_settings')) { |
|
107 | + $actions[] = sprintf('<a href="%s">%s</a>', admin_url('edit.php?post_type=gravityview&page=gravityview_settings'), esc_html__('Settings', 'gravityview')); |
|
108 | 108 | } |
109 | 109 | |
110 | - if( GVCommon::has_cap( 'gravityview_support_port' ) ) { |
|
111 | - $actions[] = '<a href="http://docs.gravityview.co">' . esc_html__( 'Support', 'gravityview' ) . '</a>'; |
|
110 | + if (GVCommon::has_cap('gravityview_support_port')) { |
|
111 | + $actions[] = '<a href="http://docs.gravityview.co">'.esc_html__('Support', 'gravityview').'</a>'; |
|
112 | 112 | } |
113 | 113 | |
114 | - return array_merge( $actions, $links ); |
|
114 | + return array_merge($actions, $links); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -128,70 +128,70 @@ discard block |
||
128 | 128 | * @param array $messages Existing messages |
129 | 129 | * @return array Messages with GravityView views! |
130 | 130 | */ |
131 | - function post_updated_messages( $messages, $bulk_counts = NULL ) { |
|
131 | + function post_updated_messages($messages, $bulk_counts = NULL) { |
|
132 | 132 | global $post; |
133 | 133 | |
134 | - $post_id = isset($_GET['post']) ? intval($_GET['post']) : ( is_object( $post ) && isset( $post->ID ) ? $post->ID : NULL ); |
|
134 | + $post_id = isset($_GET['post']) ? intval($_GET['post']) : (is_object($post) && isset($post->ID) ? $post->ID : NULL); |
|
135 | 135 | |
136 | 136 | // By default, there will only be one item being modified. |
137 | 137 | // When in the `bulk_post_updated_messages` filter, there will be passed a number |
138 | 138 | // of modified items that will override this array. |
139 | - $bulk_counts = is_null( $bulk_counts ) ? array( 'updated' => 1 , 'locked' => 1 , 'deleted' => 1 , 'trashed' => 1, 'untrashed' => 1 ) : $bulk_counts; |
|
139 | + $bulk_counts = is_null($bulk_counts) ? array('updated' => 1, 'locked' => 1, 'deleted' => 1, 'trashed' => 1, 'untrashed' => 1) : $bulk_counts; |
|
140 | 140 | |
141 | 141 | |
142 | 142 | // If we're starting fresh, a new form was created. |
143 | 143 | // We should let the user know this is the case. |
144 | - $start_fresh = get_post_meta( $post_id, '_gravityview_start_fresh', true ); |
|
144 | + $start_fresh = get_post_meta($post_id, '_gravityview_start_fresh', true); |
|
145 | 145 | |
146 | 146 | $new_form_text = ''; |
147 | 147 | |
148 | - if( !empty( $start_fresh ) ) { |
|
148 | + if (!empty($start_fresh)) { |
|
149 | 149 | |
150 | 150 | // Get the form that was created |
151 | - $connected_form = gravityview_get_form_id( $post_id ); |
|
151 | + $connected_form = gravityview_get_form_id($post_id); |
|
152 | 152 | |
153 | - if( !empty( $connected_form ) ) { |
|
154 | - $form = gravityview_get_form( $connected_form ); |
|
155 | - $form_name = esc_attr( $form['title'] ); |
|
153 | + if (!empty($connected_form)) { |
|
154 | + $form = gravityview_get_form($connected_form); |
|
155 | + $form_name = esc_attr($form['title']); |
|
156 | 156 | $image = self::get_floaty(); |
157 | - $new_form_text .= '<h3>'.$image.sprintf( __( 'A new form was created for this View: "%s"', 'gravityview' ), $form_name ).'</h3>'; |
|
158 | - $new_form_text .= sprintf( __( '%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s |
|
157 | + $new_form_text .= '<h3>'.$image.sprintf(__('A new form was created for this View: "%s"', 'gravityview'), $form_name).'</h3>'; |
|
158 | + $new_form_text .= sprintf(__('%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s |
|
159 | 159 | |
160 | 160 | You can %sedit the form%s in Gravity Forms and the updated fields will be available here. Don’t forget to %scustomize the form settings%s. |
161 | - ', 'gravityview' ), '<strong>', '</strong>', '<a href="'.site_url( '?gf_page=preview&id='.$connected_form ).'">', '</a>', '<code>[gravityform id="'.$connected_form.'" name="'.$form_name.'"]</code>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&id='.$connected_form ).'">', '</a>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&view=settings&id='.$connected_form ).'">', '</a>'); |
|
162 | - $new_form_text = wpautop( $new_form_text ); |
|
161 | + ', 'gravityview'), '<strong>', '</strong>', '<a href="'.site_url('?gf_page=preview&id='.$connected_form).'">', '</a>', '<code>[gravityform id="'.$connected_form.'" name="'.$form_name.'"]</code>', '<a href="'.admin_url('admin.php?page=gf_edit_forms&id='.$connected_form).'">', '</a>', '<a href="'.admin_url('admin.php?page=gf_edit_forms&view=settings&id='.$connected_form).'">', '</a>'); |
|
162 | + $new_form_text = wpautop($new_form_text); |
|
163 | 163 | |
164 | - delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
164 | + delete_post_meta($post_id, '_gravityview_start_fresh'); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | $messages['gravityview'] = array( |
169 | 169 | 0 => '', // Unused. Messages start at index 1. |
170 | - 1 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
171 | - 2 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
172 | - 3 => __( 'View deleted.', 'gravityview' ), |
|
173 | - 4 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
170 | + 1 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
171 | + 2 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
172 | + 3 => __('View deleted.', 'gravityview'), |
|
173 | + 4 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
174 | 174 | /* translators: %s: date and time of the revision */ |
175 | - 5 => isset( $_GET['revision'] ) ? sprintf( __( 'View restored to revision from %s', 'gravityview' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
176 | - 6 => sprintf(__( 'View published. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
177 | - 7 => sprintf(__( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
178 | - 8 => __( 'View submitted.', 'gravityview' ), |
|
175 | + 5 => isset($_GET['revision']) ? sprintf(__('View restored to revision from %s', 'gravityview'), wp_post_revision_title((int)$_GET['revision'], false)) : false, |
|
176 | + 6 => sprintf(__('View published. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>').$new_form_text, |
|
177 | + 7 => sprintf(__('View saved. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>').$new_form_text, |
|
178 | + 8 => __('View submitted.', 'gravityview'), |
|
179 | 179 | 9 => sprintf( |
180 | - __( 'View scheduled for: %1$s.', 'gravityview' ), |
|
180 | + __('View scheduled for: %1$s.', 'gravityview'), |
|
181 | 181 | // translators: Publish box date format, see http://php.net/date |
182 | - date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
|
183 | - ) . $new_form_text, |
|
184 | - 10 => sprintf(__( 'View draft updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
182 | + date_i18n(__('M j, Y @ G:i', 'gravityview'), strtotime((isset($post->post_date) ? $post->post_date : NULL))) |
|
183 | + ).$new_form_text, |
|
184 | + 10 => sprintf(__('View draft updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
185 | 185 | |
186 | 186 | /** |
187 | 187 | * These apply to `bulk_post_updated_messages` |
188 | 188 | * @file wp-admin/edit.php |
189 | 189 | */ |
190 | - 'updated' => _n( '%s View updated.', '%s Views updated.', $bulk_counts['updated'], 'gravityview' ), |
|
191 | - 'locked' => _n( '%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts['locked'], 'gravityview' ), |
|
192 | - 'deleted' => _n( '%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts['deleted'], 'gravityview' ), |
|
193 | - 'trashed' => _n( '%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts['trashed'], 'gravityview' ), |
|
194 | - 'untrashed' => _n( '%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts['untrashed'], 'gravityview' ), |
|
190 | + 'updated' => _n('%s View updated.', '%s Views updated.', $bulk_counts['updated'], 'gravityview'), |
|
191 | + 'locked' => _n('%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts['locked'], 'gravityview'), |
|
192 | + 'deleted' => _n('%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts['deleted'], 'gravityview'), |
|
193 | + 'trashed' => _n('%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts['trashed'], 'gravityview'), |
|
194 | + 'untrashed' => _n('%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts['untrashed'], 'gravityview'), |
|
195 | 195 | ); |
196 | 196 | |
197 | 197 | return $messages; |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | function no_conflict_scripts() { |
205 | 205 | global $wp_scripts; |
206 | 206 | |
207 | - if( ! gravityview_is_admin_page() ) { |
|
207 | + if (!gravityview_is_admin_page()) { |
|
208 | 208 | return; |
209 | 209 | } |
210 | 210 | |
211 | 211 | $no_conflict_mode = GravityView_Settings::getSetting('no-conflict-mode'); |
212 | 212 | |
213 | - if( empty( $no_conflict_mode ) ) { |
|
213 | + if (empty($no_conflict_mode)) { |
|
214 | 214 | return; |
215 | 215 | } |
216 | 216 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | 'jquery-ui-accordion', |
251 | 251 | ); |
252 | 252 | |
253 | - $this->remove_conflicts( $wp_scripts, $wp_allowed_scripts, 'scripts' ); |
|
253 | + $this->remove_conflicts($wp_scripts, $wp_allowed_scripts, 'scripts'); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -260,16 +260,16 @@ discard block |
||
260 | 260 | function no_conflict_styles() { |
261 | 261 | global $wp_styles; |
262 | 262 | |
263 | - if( ! gravityview_is_admin_page() ) { |
|
263 | + if (!gravityview_is_admin_page()) { |
|
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Dequeue other jQuery styles even if no-conflict is off. |
268 | 268 | // Terrible-looking tabs help no one. |
269 | - if( !empty( $wp_styles->registered ) ) { |
|
269 | + if (!empty($wp_styles->registered)) { |
|
270 | 270 | foreach ($wp_styles->registered as $key => $style) { |
271 | - if( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) { |
|
272 | - wp_dequeue_style( $key ); |
|
271 | + if (preg_match('/^(?:wp\-)?jquery/ism', $key)) { |
|
272 | + wp_dequeue_style($key); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $no_conflict_mode = GravityView_Settings::getSetting('no-conflict-mode'); |
278 | 278 | |
279 | 279 | // If no conflict is off, jQuery will suffice. |
280 | - if( empty( $no_conflict_mode ) ) { |
|
280 | + if (empty($no_conflict_mode)) { |
|
281 | 281 | return; |
282 | 282 | } |
283 | 283 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | 'jquery-qtip.js', |
300 | 300 | ); |
301 | 301 | |
302 | - $this->remove_conflicts( $wp_styles, $wp_allowed_styles, 'styles' ); |
|
302 | + $this->remove_conflicts($wp_styles, $wp_allowed_styles, 'styles'); |
|
303 | 303 | |
304 | 304 | /** |
305 | 305 | * @action `gravityview_remove_conflicts_after` Runs after no-conflict styles are removed. You can re-add styles here. |
@@ -315,31 +315,31 @@ discard block |
||
315 | 315 | * @param string $type Either 'styles' or 'scripts' |
316 | 316 | * @return void |
317 | 317 | */ |
318 | - private function remove_conflicts( &$wp_objects, $required_objects, $type = 'scripts' ) { |
|
318 | + private function remove_conflicts(&$wp_objects, $required_objects, $type = 'scripts') { |
|
319 | 319 | |
320 | 320 | /** |
321 | 321 | * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n |
322 | 322 | * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles` |
323 | 323 | * @param array $required_objects |
324 | 324 | */ |
325 | - $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects ); |
|
325 | + $required_objects = apply_filters("gravityview_noconflict_{$type}", $required_objects); |
|
326 | 326 | |
327 | 327 | //reset queue |
328 | 328 | $queue = array(); |
329 | - foreach( $wp_objects->queue as $object ) { |
|
330 | - if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
329 | + foreach ($wp_objects->queue as $object) { |
|
330 | + if (in_array($object, $required_objects) || preg_match('/gravityview|gf_|gravityforms/ism', $object)) { |
|
331 | 331 | $queue[] = $object; |
332 | 332 | } |
333 | 333 | } |
334 | 334 | $wp_objects->queue = $queue; |
335 | 335 | |
336 | - $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects ); |
|
336 | + $required_objects = $this->add_script_dependencies($wp_objects->registered, $required_objects); |
|
337 | 337 | |
338 | 338 | //unregistering scripts |
339 | 339 | $registered = array(); |
340 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
341 | - if( in_array( $handle, $required_objects ) ){ |
|
342 | - $registered[ $handle ] = $script_registration; |
|
340 | + foreach ($wp_objects->registered as $handle => $script_registration) { |
|
341 | + if (in_array($handle, $required_objects)) { |
|
342 | + $registered[$handle] = $script_registration; |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | $wp_objects->registered = $registered; |
@@ -356,16 +356,16 @@ discard block |
||
356 | 356 | //gets all dependent scripts linked to the $scripts array passed |
357 | 357 | do { |
358 | 358 | $dependents = array(); |
359 | - foreach ( $scripts as $script ) { |
|
360 | - $deps = isset( $registered[ $script ] ) && is_array( $registered[ $script ]->deps ) ? $registered[ $script ]->deps : array(); |
|
361 | - foreach ( $deps as $dep ) { |
|
362 | - if ( ! in_array( $dep, $scripts ) && ! in_array( $dep, $dependents ) ) { |
|
359 | + foreach ($scripts as $script) { |
|
360 | + $deps = isset($registered[$script]) && is_array($registered[$script]->deps) ? $registered[$script]->deps : array(); |
|
361 | + foreach ($deps as $dep) { |
|
362 | + if (!in_array($dep, $scripts) && !in_array($dep, $dependents)) { |
|
363 | 363 | $dependents[] = $dep; |
364 | 364 | } |
365 | 365 | } |
366 | 366 | } |
367 | - $scripts = array_merge( $scripts, $dependents ); |
|
368 | - } while ( ! empty( $dependents ) ); |
|
367 | + $scripts = array_merge($scripts, $dependents); |
|
368 | + } while (!empty($dependents)); |
|
369 | 369 | |
370 | 370 | return $scripts; |
371 | 371 | } |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | * @deprecated since 1.12 |
386 | 386 | * @param array $notice Array with `class` and `message` keys. The message is not escaped. |
387 | 387 | */ |
388 | - public static function add_notice( $notice = array() ) { |
|
389 | - GravityView_Admin_Notices::add_notice( $notice ); |
|
388 | + public static function add_notice($notice = array()) { |
|
389 | + GravityView_Admin_Notices::add_notice($notice); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | |
409 | 409 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
410 | 410 | */ |
411 | - static function get_plugin_status( $location = '' ) { |
|
412 | - return GravityView_Compatibility::get_plugin_status( $location ); |
|
411 | + static function get_plugin_status($location = '') { |
|
412 | + return GravityView_Compatibility::get_plugin_status($location); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -421,10 +421,10 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return bool|string|void If `false`, not a GravityView page. `true` if $page is passed and is the same as current page. Otherwise, the name of the page (`single`, `settings`, or `views`) |
423 | 423 | */ |
424 | - static function is_admin_page( $hook = '', $page = NULL ) { |
|
424 | + static function is_admin_page($hook = '', $page = NULL) { |
|
425 | 425 | global $current_screen, $plugin_page, $pagenow, $post; |
426 | 426 | |
427 | - if( ! is_admin() ) { return false; } |
|
427 | + if (!is_admin()) { return false; } |
|
428 | 428 | |
429 | 429 | $is_page = false; |
430 | 430 | |
@@ -432,21 +432,21 @@ discard block |
||
432 | 432 | |
433 | 433 | $is_gv_post_type_get = (isset($_GET['post_type']) && $_GET['post_type'] === 'gravityview'); |
434 | 434 | |
435 | - $is_gv_settings_get = isset( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings'; |
|
435 | + $is_gv_settings_get = isset($_GET['page']) && $_GET['page'] === 'gravityview_settings'; |
|
436 | 436 | |
437 | - if( empty( $post ) && $pagenow === 'post.php' && !empty( $_GET['post'] ) ) { |
|
438 | - $gv_post = get_post( intval( $_GET['post'] ) ); |
|
437 | + if (empty($post) && $pagenow === 'post.php' && !empty($_GET['post'])) { |
|
438 | + $gv_post = get_post(intval($_GET['post'])); |
|
439 | 439 | $is_gv_post_type = (!empty($gv_post) && !empty($gv_post->post_type) && $gv_post->post_type === 'gravityview'); |
440 | 440 | } else { |
441 | 441 | $is_gv_post_type = (!empty($post) && !empty($post->post_type) && $post->post_type === 'gravityview'); |
442 | 442 | } |
443 | 443 | |
444 | - if( $is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get ) { |
|
444 | + if ($is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get) { |
|
445 | 445 | |
446 | 446 | // $_GET `post_type` variable |
447 | - if(in_array($pagenow, array( 'post.php' , 'post-new.php' )) ) { |
|
447 | + if (in_array($pagenow, array('post.php', 'post-new.php'))) { |
|
448 | 448 | $is_page = 'single'; |
449 | - } else if ( in_array( $plugin_page, array( 'gravityview_settings', 'gravityview_page_gravityview_settings' ) ) || ( !empty( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings' ) ) { |
|
449 | + } else if (in_array($plugin_page, array('gravityview_settings', 'gravityview_page_gravityview_settings')) || (!empty($_GET['page']) && $_GET['page'] === 'gravityview_settings')) { |
|
450 | 450 | $is_page = 'settings'; |
451 | 451 | } else { |
452 | 452 | $is_page = 'views'; |
@@ -458,10 +458,10 @@ discard block |
||
458 | 458 | * @param[in,out] string|bool $is_page If false, no. If string, the name of the page (`single`, `settings`, or `views`) |
459 | 459 | * @param[in] string $hook The name of the page to check against. Is passed to the method. |
460 | 460 | */ |
461 | - $is_page = apply_filters( 'gravityview_is_admin_page', $is_page, $hook ); |
|
461 | + $is_page = apply_filters('gravityview_is_admin_page', $is_page, $hook); |
|
462 | 462 | |
463 | 463 | // If the current page is the same as the compared page |
464 | - if( !empty( $page ) ) { |
|
464 | + if (!empty($page)) { |
|
465 | 465 | return $is_page === $page; |
466 | 466 | } |
467 | 467 | |
@@ -473,5 +473,5 @@ discard block |
||
473 | 473 | new GravityView_Admin; |
474 | 474 | |
475 | 475 | function gravityview_is_admin_page($hook = '', $page = NULL) { |
476 | - return GravityView_Admin::is_admin_page( $hook, $page ); |
|
476 | + return GravityView_Admin::is_admin_page($hook, $page); |
|
477 | 477 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @since 1.15 |
29 | 29 | * @param bool|false $mixed |
30 | 30 | * |
31 | - * @return bool |
|
31 | + * @return boolean|null |
|
32 | 32 | */ |
33 | 33 | private function _exit( $mixed = NULL ) { |
34 | 34 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * Import Gravity Form XML or JSON |
201 | 201 | * |
202 | 202 | * @param string $xml_or_json_path Path to form XML or JSON file |
203 | - * @return int|bool Imported form ID or false |
|
203 | + * @return false|string Imported form ID or false |
|
204 | 204 | */ |
205 | 205 | function import_form( $xml_or_json_path = '' ) { |
206 | 206 |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | // template areas |
138 | 138 | $template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' ); |
139 | - $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' ); |
|
139 | + $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' ); |
|
140 | 140 | |
141 | 141 | // widget areas |
142 | 142 | $default_widget_areas = GravityView_Plugin::get_default_widget_areas(); |
@@ -328,40 +328,40 @@ discard block |
||
328 | 328 | // load file |
329 | 329 | $xmlstr = file_get_contents( $form_file ); |
330 | 330 | |
331 | - $options = array( |
|
332 | - "page" => array("unserialize_as_array" => true), |
|
333 | - "form"=> array("unserialize_as_array" => true), |
|
334 | - "field"=> array("unserialize_as_array" => true), |
|
335 | - "rule"=> array("unserialize_as_array" => true), |
|
336 | - "choice"=> array("unserialize_as_array" => true), |
|
337 | - "input"=> array("unserialize_as_array" => true), |
|
338 | - "routing_item"=> array("unserialize_as_array" => true), |
|
339 | - "creditCard"=> array("unserialize_as_array" => true), |
|
340 | - "routin"=> array("unserialize_as_array" => true), |
|
341 | - "confirmation" => array("unserialize_as_array" => true), |
|
342 | - "notification" => array("unserialize_as_array" => true) |
|
343 | - ); |
|
331 | + $options = array( |
|
332 | + "page" => array("unserialize_as_array" => true), |
|
333 | + "form"=> array("unserialize_as_array" => true), |
|
334 | + "field"=> array("unserialize_as_array" => true), |
|
335 | + "rule"=> array("unserialize_as_array" => true), |
|
336 | + "choice"=> array("unserialize_as_array" => true), |
|
337 | + "input"=> array("unserialize_as_array" => true), |
|
338 | + "routing_item"=> array("unserialize_as_array" => true), |
|
339 | + "creditCard"=> array("unserialize_as_array" => true), |
|
340 | + "routin"=> array("unserialize_as_array" => true), |
|
341 | + "confirmation" => array("unserialize_as_array" => true), |
|
342 | + "notification" => array("unserialize_as_array" => true) |
|
343 | + ); |
|
344 | 344 | |
345 | 345 | $xml = new RGXML($options); |
346 | - $forms = $xml->unserialize($xmlstr); |
|
346 | + $forms = $xml->unserialize($xmlstr); |
|
347 | 347 | |
348 | - if( !$forms ) { |
|
349 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file ); |
|
350 | - return false; |
|
351 | - } |
|
348 | + if( !$forms ) { |
|
349 | + do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file ); |
|
350 | + return false; |
|
351 | + } |
|
352 | 352 | |
353 | - if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
354 | - $form = $forms[0]; |
|
355 | - } |
|
353 | + if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
354 | + $form = $forms[0]; |
|
355 | + } |
|
356 | 356 | |
357 | - if( empty( $form ) ) { |
|
358 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms ); |
|
359 | - return false; |
|
360 | - } |
|
357 | + if( empty( $form ) ) { |
|
358 | + do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms ); |
|
359 | + return false; |
|
360 | + } |
|
361 | 361 | |
362 | - do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form ); |
|
362 | + do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form ); |
|
363 | 363 | |
364 | - return $form; |
|
364 | + return $form; |
|
365 | 365 | |
366 | 366 | } |
367 | 367 |
@@ -5,21 +5,21 @@ discard block |
||
5 | 5 | function __construct() { |
6 | 6 | |
7 | 7 | //get field options |
8 | - add_action( 'wp_ajax_gv_field_options', array( $this, 'get_field_options' ) ); |
|
8 | + add_action('wp_ajax_gv_field_options', array($this, 'get_field_options')); |
|
9 | 9 | |
10 | 10 | // get available fields |
11 | - add_action( 'wp_ajax_gv_available_fields', array( $this, 'get_available_fields_html' ) ); |
|
11 | + add_action('wp_ajax_gv_available_fields', array($this, 'get_available_fields_html')); |
|
12 | 12 | |
13 | 13 | // get active areas |
14 | - add_action( 'wp_ajax_gv_get_active_areas', array( $this, 'get_active_areas' ) ); |
|
14 | + add_action('wp_ajax_gv_get_active_areas', array($this, 'get_active_areas')); |
|
15 | 15 | |
16 | 16 | // get preset fields |
17 | - add_action( 'wp_ajax_gv_get_preset_fields', array( $this, 'get_preset_fields_config' ) ); |
|
17 | + add_action('wp_ajax_gv_get_preset_fields', array($this, 'get_preset_fields_config')); |
|
18 | 18 | |
19 | 19 | // get preset fields |
20 | - add_action( 'wp_ajax_gv_set_preset_form', array( $this, 'create_preset_form' ) ); |
|
20 | + add_action('wp_ajax_gv_set_preset_form', array($this, 'create_preset_form')); |
|
21 | 21 | |
22 | - add_action( 'wp_ajax_gv_sortable_fields_form', array( $this, 'get_sortable_fields' ) ); |
|
22 | + add_action('wp_ajax_gv_sortable_fields_form', array($this, 'get_sortable_fields')); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -30,17 +30,17 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool |
32 | 32 | */ |
33 | - private function _exit( $mixed = NULL ) { |
|
33 | + private function _exit($mixed = NULL) { |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Don't exit if we're running test suite. |
37 | 37 | * @since 1.15 |
38 | 38 | */ |
39 | - if( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) { |
|
39 | + if (defined('DOING_GRAVITYVIEW_TESTS') && DOING_GRAVITYVIEW_TESTS) { |
|
40 | 40 | return $mixed; |
41 | 41 | } |
42 | 42 | |
43 | - exit( $mixed ); |
|
43 | + exit($mixed); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** -------- AJAX ---------- */ |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @return void |
51 | 51 | */ |
52 | 52 | function check_ajax_nonce() { |
53 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxviews' ) ) { |
|
54 | - $this->_exit( false ); |
|
53 | + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxviews')) { |
|
54 | + $this->_exit(false); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -67,20 +67,20 @@ discard block |
||
67 | 67 | //check nonce |
68 | 68 | $this->check_ajax_nonce(); |
69 | 69 | |
70 | - $context = isset($_POST['context']) ? esc_attr( $_POST['context'] ) : 'directory'; |
|
70 | + $context = isset($_POST['context']) ? esc_attr($_POST['context']) : 'directory'; |
|
71 | 71 | |
72 | 72 | // If Form was changed, JS sends form ID, if start fresh, JS sends template_id |
73 | - if( !empty( $_POST['form_id'] ) ) { |
|
74 | - do_action( 'gravityview_render_available_fields', (int) $_POST['form_id'], $context ); |
|
73 | + if (!empty($_POST['form_id'])) { |
|
74 | + do_action('gravityview_render_available_fields', (int)$_POST['form_id'], $context); |
|
75 | 75 | $this->_exit(); |
76 | - } elseif( !empty( $_POST['template_id'] ) ) { |
|
77 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
78 | - do_action( 'gravityview_render_available_fields', $form, $context ); |
|
76 | + } elseif (!empty($_POST['template_id'])) { |
|
77 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
78 | + do_action('gravityview_render_available_fields', $form, $context); |
|
79 | 79 | $this->_exit(); |
80 | 80 | } |
81 | 81 | |
82 | 82 | //if everything fails.. |
83 | - $this->_exit( false ); |
|
83 | + $this->_exit(false); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -94,21 +94,21 @@ discard block |
||
94 | 94 | function get_active_areas() { |
95 | 95 | $this->check_ajax_nonce(); |
96 | 96 | |
97 | - if( empty( $_POST['template_id'] ) ) { |
|
98 | - $this->_exit( false ); |
|
97 | + if (empty($_POST['template_id'])) { |
|
98 | + $this->_exit(false); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | ob_start(); |
102 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true ); |
|
102 | + do_action('gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true); |
|
103 | 103 | $response['directory'] = ob_get_clean(); |
104 | 104 | |
105 | 105 | ob_start(); |
106 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true ); |
|
106 | + do_action('gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true); |
|
107 | 107 | $response['single'] = ob_get_clean(); |
108 | 108 | |
109 | - $response = array_map( 'gravityview_strip_whitespace', $response ); |
|
109 | + $response = array_map('gravityview_strip_whitespace', $response); |
|
110 | 110 | |
111 | - $this->_exit( json_encode( $response ) ); |
|
111 | + $this->_exit(json_encode($response)); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -119,49 +119,49 @@ discard block |
||
119 | 119 | |
120 | 120 | $this->check_ajax_nonce(); |
121 | 121 | |
122 | - if( empty( $_POST['template_id'] ) ) { |
|
123 | - $this->_exit( false ); |
|
122 | + if (empty($_POST['template_id'])) { |
|
123 | + $this->_exit(false); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // get the fields xml config file for this specific preset |
127 | - $preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST['template_id'] ); |
|
127 | + $preset_fields_path = apply_filters('gravityview_template_fieldsxml', array(), $_POST['template_id']); |
|
128 | 128 | // import fields |
129 | - if( !empty( $preset_fields_path ) ) { |
|
130 | - $presets = $this->import_fields( $preset_fields_path ); |
|
129 | + if (!empty($preset_fields_path)) { |
|
130 | + $presets = $this->import_fields($preset_fields_path); |
|
131 | 131 | } else { |
132 | - $presets = array( 'widgets' => array(), 'fields' => array() ); |
|
132 | + $presets = array('widgets' => array(), 'fields' => array()); |
|
133 | 133 | } |
134 | 134 | |
135 | - $template_id = esc_attr( $_POST['template_id'] ); |
|
135 | + $template_id = esc_attr($_POST['template_id']); |
|
136 | 136 | |
137 | 137 | // template areas |
138 | - $template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' ); |
|
139 | - $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' ); |
|
138 | + $template_areas_directory = apply_filters('gravityview_template_active_areas', array(), $template_id, 'directory'); |
|
139 | + $template_areas_single = apply_filters('gravityview_template_active_areas', array(), $template_id, 'single'); |
|
140 | 140 | |
141 | 141 | // widget areas |
142 | 142 | $default_widget_areas = GravityView_Plugin::get_default_widget_areas(); |
143 | 143 | |
144 | 144 | ob_start(); |
145 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets'] ); |
|
145 | + do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets']); |
|
146 | 146 | $response['header'] = ob_get_clean(); |
147 | 147 | |
148 | 148 | ob_start(); |
149 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets'] ); |
|
149 | + do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets']); |
|
150 | 150 | $response['footer'] = ob_get_clean(); |
151 | 151 | |
152 | 152 | ob_start(); |
153 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields'] ); |
|
153 | + do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields']); |
|
154 | 154 | $response['directory'] = ob_get_clean(); |
155 | 155 | |
156 | 156 | ob_start(); |
157 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields'] ); |
|
157 | + do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields']); |
|
158 | 158 | $response['single'] = ob_get_clean(); |
159 | 159 | |
160 | - $response = array_map( 'gravityview_strip_whitespace', $response ); |
|
160 | + $response = array_map('gravityview_strip_whitespace', $response); |
|
161 | 161 | |
162 | - do_action( 'gravityview_log_debug', '[get_preset_fields_config] AJAX Response', $response ); |
|
162 | + do_action('gravityview_log_debug', '[get_preset_fields_config] AJAX Response', $response); |
|
163 | 163 | |
164 | - $this->_exit( json_encode( $response ) ); |
|
164 | + $this->_exit(json_encode($response)); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -173,26 +173,26 @@ discard block |
||
173 | 173 | |
174 | 174 | $this->check_ajax_nonce(); |
175 | 175 | |
176 | - if( empty( $_POST['template_id'] ) ) { |
|
177 | - do_action( 'gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.' ); |
|
178 | - $this->_exit( false ); |
|
176 | + if (empty($_POST['template_id'])) { |
|
177 | + do_action('gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.'); |
|
178 | + $this->_exit(false); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | // get the xml for this specific template_id |
182 | - $preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST['template_id'] ); |
|
182 | + $preset_form_xml_path = apply_filters('gravityview_template_formxml', '', $_POST['template_id']); |
|
183 | 183 | |
184 | 184 | // import form |
185 | - $form = $this->import_form( $preset_form_xml_path ); |
|
185 | + $form = $this->import_form($preset_form_xml_path); |
|
186 | 186 | |
187 | 187 | // get the form ID |
188 | - if( false === $form ) { |
|
188 | + if (false === $form) { |
|
189 | 189 | // send error to user |
190 | - do_action( 'gravityview_log_error', '[create_preset_form] Error importing form for template id: ' . (int) $_POST['template_id'] ); |
|
190 | + do_action('gravityview_log_error', '[create_preset_form] Error importing form for template id: '.(int)$_POST['template_id']); |
|
191 | 191 | |
192 | - $this->_exit( false ); |
|
192 | + $this->_exit(false); |
|
193 | 193 | } |
194 | 194 | |
195 | - $this->_exit( '<option value="'.esc_attr( $form['id'] ).'" selected="selected">'.esc_html( $form['title'] ).'</option>' ); |
|
195 | + $this->_exit('<option value="'.esc_attr($form['id']).'" selected="selected">'.esc_html($form['title']).'</option>'); |
|
196 | 196 | |
197 | 197 | } |
198 | 198 | |
@@ -202,24 +202,24 @@ discard block |
||
202 | 202 | * @param string $xml_or_json_path Path to form XML or JSON file |
203 | 203 | * @return int|bool Imported form ID or false |
204 | 204 | */ |
205 | - function import_form( $xml_or_json_path = '' ) { |
|
205 | + function import_form($xml_or_json_path = '') { |
|
206 | 206 | |
207 | - do_action( 'gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path ); |
|
207 | + do_action('gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path); |
|
208 | 208 | |
209 | - if( empty( $xml_or_json_path ) || !class_exists('GFExport') || !file_exists( $xml_or_json_path ) ) { |
|
210 | - do_action( 'gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path ); |
|
209 | + if (empty($xml_or_json_path) || !class_exists('GFExport') || !file_exists($xml_or_json_path)) { |
|
210 | + do_action('gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path); |
|
211 | 211 | return false; |
212 | 212 | } |
213 | 213 | |
214 | 214 | // import form |
215 | 215 | $forms = ''; |
216 | - $count = GFExport::import_file( $xml_or_json_path, $forms ); |
|
216 | + $count = GFExport::import_file($xml_or_json_path, $forms); |
|
217 | 217 | |
218 | - do_action( 'gravityview_log_debug', '[import_form] Importing form (Result)', $count ); |
|
219 | - do_action( 'gravityview_log_debug', '[import_form] Importing form (Form) ', $forms ); |
|
218 | + do_action('gravityview_log_debug', '[import_form] Importing form (Result)', $count); |
|
219 | + do_action('gravityview_log_debug', '[import_form] Importing form (Form) ', $forms); |
|
220 | 220 | |
221 | - if( $count != 1 || empty( $forms[0]['id'] ) ) { |
|
222 | - do_action( 'gravityview_log_error', '[import_form] Form Import Failed!' ); |
|
221 | + if ($count != 1 || empty($forms[0]['id'])) { |
|
222 | + do_action('gravityview_log_error', '[import_form] Form Import Failed!'); |
|
223 | 223 | return false; |
224 | 224 | } |
225 | 225 | |
@@ -238,26 +238,26 @@ discard block |
||
238 | 238 | function get_field_options() { |
239 | 239 | $this->check_ajax_nonce(); |
240 | 240 | |
241 | - if( empty( $_POST['template'] ) || empty( $_POST['area'] ) || empty( $_POST['field_id'] ) || empty( $_POST['field_type'] ) ) { |
|
242 | - do_action( 'gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. ' ); |
|
243 | - $this->_exit( false ); |
|
241 | + if (empty($_POST['template']) || empty($_POST['area']) || empty($_POST['field_id']) || empty($_POST['field_type'])) { |
|
242 | + do_action('gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. '); |
|
243 | + $this->_exit(false); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | // Fix apostrophes added by JSON response |
247 | - $_post = array_map( 'stripslashes_deep', $_POST ); |
|
247 | + $_post = array_map('stripslashes_deep', $_POST); |
|
248 | 248 | |
249 | 249 | // Sanitize |
250 | - $_post = array_map( 'esc_attr', $_post ); |
|
250 | + $_post = array_map('esc_attr', $_post); |
|
251 | 251 | |
252 | 252 | // The GF type of field: `product`, `name`, `creditcard`, `id`, `text` |
253 | - $input_type = isset($_post['input_type']) ? esc_attr( $_post['input_type'] ) : NULL; |
|
254 | - $context = isset($_post['context']) ? esc_attr( $_post['context'] ) : NULL; |
|
253 | + $input_type = isset($_post['input_type']) ? esc_attr($_post['input_type']) : NULL; |
|
254 | + $context = isset($_post['context']) ? esc_attr($_post['context']) : NULL; |
|
255 | 255 | |
256 | - $response = GravityView_Render_Settings::render_field_options( $_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context ); |
|
256 | + $response = GravityView_Render_Settings::render_field_options($_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context); |
|
257 | 257 | |
258 | - $response = gravityview_strip_whitespace( $response ); |
|
258 | + $response = gravityview_strip_whitespace($response); |
|
259 | 259 | |
260 | - $this->_exit( $response ); |
|
260 | + $this->_exit($response); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -274,23 +274,23 @@ discard block |
||
274 | 274 | $form = ''; |
275 | 275 | |
276 | 276 | // if form id is set, use it, else, get form from preset |
277 | - if( !empty( $_POST['form_id'] ) ) { |
|
277 | + if (!empty($_POST['form_id'])) { |
|
278 | 278 | |
279 | - $form = (int) $_POST['form_id']; |
|
279 | + $form = (int)$_POST['form_id']; |
|
280 | 280 | |
281 | 281 | } |
282 | 282 | // get form from preset |
283 | - elseif( !empty( $_POST['template_id'] ) ) { |
|
283 | + elseif (!empty($_POST['template_id'])) { |
|
284 | 284 | |
285 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
285 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
286 | 286 | |
287 | 287 | } |
288 | 288 | |
289 | - $response = gravityview_get_sortable_fields( $form ); |
|
289 | + $response = gravityview_get_sortable_fields($form); |
|
290 | 290 | |
291 | - $response = gravityview_strip_whitespace( $response ); |
|
291 | + $response = gravityview_strip_whitespace($response); |
|
292 | 292 | |
293 | - $this->_exit( $response ); |
|
293 | + $this->_exit($response); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -298,35 +298,35 @@ discard block |
||
298 | 298 | * @param string $template_id Preset template |
299 | 299 | * |
300 | 300 | */ |
301 | - static function pre_get_form_fields( $template_id = '') { |
|
301 | + static function pre_get_form_fields($template_id = '') { |
|
302 | 302 | |
303 | - if( empty( $template_id ) ) { |
|
304 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Template ID not set.' ); |
|
303 | + if (empty($template_id)) { |
|
304 | + do_action('gravityview_log_error', __METHOD__.' - Template ID not set.'); |
|
305 | 305 | return false; |
306 | 306 | } else { |
307 | - $form_file = apply_filters( 'gravityview_template_formxml', '', $template_id ); |
|
308 | - if( !file_exists( $form_file ) ) { |
|
309 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Importing Form Fields for preset ['. $template_id .']. File not found. file: ' . $form_file ); |
|
307 | + $form_file = apply_filters('gravityview_template_formxml', '', $template_id); |
|
308 | + if (!file_exists($form_file)) { |
|
309 | + do_action('gravityview_log_error', __METHOD__.' - Importing Form Fields for preset ['.$template_id.']. File not found. file: '.$form_file); |
|
310 | 310 | return false; |
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | 314 | // Load xml parser (from GravityForms) |
315 | - if( class_exists( 'GFCommon' ) ) { |
|
316 | - $xml_parser = GFCommon::get_base_path() . '/xml.php'; |
|
315 | + if (class_exists('GFCommon')) { |
|
316 | + $xml_parser = GFCommon::get_base_path().'/xml.php'; |
|
317 | 317 | } else { |
318 | - $xml_parser = trailingslashit( WP_PLUGIN_DIR ) . 'gravityforms/xml.php'; |
|
318 | + $xml_parser = trailingslashit(WP_PLUGIN_DIR).'gravityforms/xml.php'; |
|
319 | 319 | } |
320 | 320 | |
321 | - if( file_exists( $xml_parser ) ) { |
|
322 | - require_once( $xml_parser ); |
|
321 | + if (file_exists($xml_parser)) { |
|
322 | + require_once($xml_parser); |
|
323 | 323 | } else { |
324 | - do_action( 'gravityview_log_debug', __METHOD__ . ' - Gravity Forms XML Parser not found.', $xml_parser ); |
|
324 | + do_action('gravityview_log_debug', __METHOD__.' - Gravity Forms XML Parser not found.', $xml_parser); |
|
325 | 325 | return false; |
326 | 326 | } |
327 | 327 | |
328 | 328 | // load file |
329 | - $xmlstr = file_get_contents( $form_file ); |
|
329 | + $xmlstr = file_get_contents($form_file); |
|
330 | 330 | |
331 | 331 | $options = array( |
332 | 332 | "page" => array("unserialize_as_array" => true), |
@@ -345,21 +345,21 @@ discard block |
||
345 | 345 | $xml = new RGXML($options); |
346 | 346 | $forms = $xml->unserialize($xmlstr); |
347 | 347 | |
348 | - if( !$forms ) { |
|
349 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file ); |
|
348 | + if (!$forms) { |
|
349 | + do_action('gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['.$template_id.']. Error importing file. (File)', $form_file); |
|
350 | 350 | return false; |
351 | 351 | } |
352 | 352 | |
353 | - if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
353 | + if (!empty($forms[0]) && is_array($forms[0])) { |
|
354 | 354 | $form = $forms[0]; |
355 | 355 | } |
356 | 356 | |
357 | - if( empty( $form ) ) { |
|
358 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms ); |
|
357 | + if (empty($form)) { |
|
358 | + do_action('gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms); |
|
359 | 359 | return false; |
360 | 360 | } |
361 | 361 | |
362 | - do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form ); |
|
362 | + do_action('gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['.$template_id.']. (Form)', $form); |
|
363 | 363 | |
364 | 364 | return $form; |
365 | 365 | |
@@ -371,46 +371,46 @@ discard block |
||
371 | 371 | * @param string $file path to file |
372 | 372 | * @return array Fields config array (unserialized) |
373 | 373 | */ |
374 | - function import_fields( $file ) { |
|
374 | + function import_fields($file) { |
|
375 | 375 | |
376 | - if( empty( $file ) || !file_exists( $file ) ) { |
|
377 | - do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file ); |
|
376 | + if (empty($file) || !file_exists($file)) { |
|
377 | + do_action('gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file); |
|
378 | 378 | return false; |
379 | 379 | } |
380 | 380 | |
381 | - if( !class_exists('WXR_Parser') ) { |
|
382 | - include_once GRAVITYVIEW_DIR . 'includes/lib/xml-parsers/parsers.php'; |
|
381 | + if (!class_exists('WXR_Parser')) { |
|
382 | + include_once GRAVITYVIEW_DIR.'includes/lib/xml-parsers/parsers.php'; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | $parser = new WXR_Parser(); |
386 | - $presets = $parser->parse( $file ); |
|
386 | + $presets = $parser->parse($file); |
|
387 | 387 | |
388 | - if(is_wp_error( $presets )) { |
|
389 | - do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets ); |
|
388 | + if (is_wp_error($presets)) { |
|
389 | + do_action('gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets); |
|
390 | 390 | return false; |
391 | 391 | } |
392 | 392 | |
393 | - if( empty( $presets['posts'][0]['postmeta'] ) && !is_array( $presets['posts'][0]['postmeta'] ) ) { |
|
394 | - do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file ); |
|
393 | + if (empty($presets['posts'][0]['postmeta']) && !is_array($presets['posts'][0]['postmeta'])) { |
|
394 | + do_action('gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file); |
|
395 | 395 | return false; |
396 | 396 | } |
397 | 397 | |
398 | - do_action( 'gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta'] ); |
|
398 | + do_action('gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta']); |
|
399 | 399 | |
400 | 400 | $fields = $widgets = array(); |
401 | - foreach( $presets['posts'][0]['postmeta'] as $meta ) { |
|
401 | + foreach ($presets['posts'][0]['postmeta'] as $meta) { |
|
402 | 402 | switch ($meta['key']) { |
403 | 403 | case '_gravityview_directory_fields': |
404 | - $fields = maybe_unserialize( $meta['value'] ); |
|
404 | + $fields = maybe_unserialize($meta['value']); |
|
405 | 405 | break; |
406 | 406 | case '_gravityview_directory_widgets': |
407 | - $widgets = maybe_unserialize( $meta['value'] ); |
|
407 | + $widgets = maybe_unserialize($meta['value']); |
|
408 | 408 | break; |
409 | 409 | } |
410 | 410 | } |
411 | 411 | |
412 | - do_action( 'gravityview_log_debug', '[import_fields] Imported Preset (Fields)', $fields ); |
|
413 | - do_action( 'gravityview_log_debug', '[import_fields] Imported Preset (Widgets)', $widgets ); |
|
412 | + do_action('gravityview_log_debug', '[import_fields] Imported Preset (Fields)', $fields); |
|
413 | + do_action('gravityview_log_debug', '[import_fields] Imported Preset (Widgets)', $widgets); |
|
414 | 414 | |
415 | 415 | return array( |
416 | 416 | 'fields' => $fields, |
@@ -108,7 +108,6 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @since 1.9 |
110 | 110 | * |
111 | - * @param array $field_setting Array of settings for the field |
|
112 | 111 | * @param string $format Format for width. "%" (default) will return |
113 | 112 | * |
114 | 113 | * @return string|null If not empty, string in $format format. Otherwise, null. |
@@ -214,7 +213,6 @@ discard block |
||
214 | 213 | * |
215 | 214 | * @access public |
216 | 215 | * @param array $entry |
217 | - * @param integer $field |
|
218 | 216 | * @return null|string |
219 | 217 | */ |
220 | 218 | public static function field_value( $entry, $field_settings, $format = 'html' ) { |
@@ -967,7 +965,7 @@ discard block |
||
967 | 965 | * Get the current View ID being rendered |
968 | 966 | * |
969 | 967 | * @global GravityView_View $gravityview_view |
970 | - * @return string View context "directory" or "single" |
|
968 | + * @return integer View context "directory" or "single" |
|
971 | 969 | */ |
972 | 970 | function gravityview_get_view_id() { |
973 | 971 | return GravityView_View::getInstance()->getViewId(); |
@@ -146,20 +146,20 @@ discard block |
||
146 | 146 | |
147 | 147 | if( !empty( $field['custom_class'] ) ) { |
148 | 148 | |
149 | - $custom_class = $field['custom_class']; |
|
149 | + $custom_class = $field['custom_class']; |
|
150 | 150 | |
151 | - if( !empty( $entry ) ) { |
|
151 | + if( !empty( $entry ) ) { |
|
152 | 152 | |
153 | - // We want the merge tag to be formatted as a class. The merge tag may be |
|
154 | - // replaced by a multiple-word value that should be output as a single class. |
|
155 | - // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
|
156 | - add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
153 | + // We want the merge tag to be formatted as a class. The merge tag may be |
|
154 | + // replaced by a multiple-word value that should be output as a single class. |
|
155 | + // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
|
156 | + add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
157 | 157 | |
158 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
158 | + $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
159 | 159 | |
160 | - // And then we want life to return to normal |
|
161 | - remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
162 | - } |
|
160 | + // And then we want life to return to normal |
|
161 | + remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
162 | + } |
|
163 | 163 | |
164 | 164 | // And now we want the spaces to be handled nicely. |
165 | 165 | $classes[] = gravityview_sanitize_html_class( $custom_class ); |
@@ -591,29 +591,29 @@ discard block |
||
591 | 591 | return sanitize_title( $slug ); |
592 | 592 | } |
593 | 593 | |
594 | - /** |
|
595 | - * If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta |
|
596 | - * |
|
597 | - * Triggered by add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 ); |
|
598 | - * |
|
599 | - * @param $entry array Gravity Forms entry object |
|
600 | - * @param $form array Gravity Forms form object |
|
601 | - */ |
|
602 | - public static function entry_create_custom_slug( $entry, $form ) { |
|
603 | - /** |
|
604 | - * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta |
|
605 | - * @param boolean $custom Should we process the custom entry slug? |
|
606 | - */ |
|
607 | - $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
608 | - if( $custom ) { |
|
609 | - // create the gravityview_unique_id and save it |
|
594 | + /** |
|
595 | + * If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta |
|
596 | + * |
|
597 | + * Triggered by add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 ); |
|
598 | + * |
|
599 | + * @param $entry array Gravity Forms entry object |
|
600 | + * @param $form array Gravity Forms form object |
|
601 | + */ |
|
602 | + public static function entry_create_custom_slug( $entry, $form ) { |
|
603 | + /** |
|
604 | + * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta |
|
605 | + * @param boolean $custom Should we process the custom entry slug? |
|
606 | + */ |
|
607 | + $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
608 | + if( $custom ) { |
|
609 | + // create the gravityview_unique_id and save it |
|
610 | 610 | |
611 | - // Get the entry hash |
|
612 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
613 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash ); |
|
611 | + // Get the entry hash |
|
612 | + $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
613 | + gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash ); |
|
614 | 614 | |
615 | - } |
|
616 | - } |
|
615 | + } |
|
616 | + } |
|
617 | 617 | |
618 | 618 | |
619 | 619 | |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | |
852 | 852 | // If there was an error, continue to the next term. |
853 | 853 | if ( is_wp_error( $term_link ) ) { |
854 | - continue; |
|
854 | + continue; |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
@@ -23,36 +23,36 @@ discard block |
||
23 | 23 | * @param boolean $force_show_label Whether to always show the label, regardless of field settings |
24 | 24 | * @return string |
25 | 25 | */ |
26 | - public static function field_label( $field, $entry = array(), $force_show_label = false ) { |
|
26 | + public static function field_label($field, $entry = array(), $force_show_label = false) { |
|
27 | 27 | $gravityview_view = GravityView_View::getInstance(); |
28 | 28 | |
29 | 29 | $form = $gravityview_view->getForm(); |
30 | 30 | |
31 | 31 | $label = ''; |
32 | 32 | |
33 | - if( !empty( $field['show_label'] ) || $force_show_label ) { |
|
33 | + if (!empty($field['show_label']) || $force_show_label) { |
|
34 | 34 | |
35 | 35 | $label = $field['label']; |
36 | 36 | |
37 | 37 | // Support Gravity Forms 1.9+ |
38 | - if( class_exists( 'GF_Field' ) ) { |
|
38 | + if (class_exists('GF_Field')) { |
|
39 | 39 | |
40 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
40 | + $field_object = RGFormsModel::get_field($form, $field['id']); |
|
41 | 41 | |
42 | - if( $field_object ) { |
|
42 | + if ($field_object) { |
|
43 | 43 | |
44 | - $input = GFFormsModel::get_input( $field_object, $field['id'] ); |
|
44 | + $input = GFFormsModel::get_input($field_object, $field['id']); |
|
45 | 45 | |
46 | 46 | // This is a complex field, with labels on a per-input basis |
47 | - if( $input ) { |
|
47 | + if ($input) { |
|
48 | 48 | |
49 | 49 | // Does the input have a custom label on a per-input basis? Otherwise, default label. |
50 | - $label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label']; |
|
50 | + $label = !empty($input['customLabel']) ? $input['customLabel'] : $input['label']; |
|
51 | 51 | |
52 | 52 | } else { |
53 | 53 | |
54 | 54 | // This is a field with one label |
55 | - $label = $field_object->get_field_label( true, $field['label'] ); |
|
55 | + $label = $field_object->get_field_label(true, $field['label']); |
|
56 | 56 | |
57 | 57 | } |
58 | 58 | |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // Use Gravity Forms label by default, but if a custom label is defined in GV, use it. |
64 | - if ( !empty( $field['custom_label'] ) ) { |
|
64 | + if (!empty($field['custom_label'])) { |
|
65 | 65 | |
66 | - $label = self::replace_variables( $field['custom_label'], $form, $entry ); |
|
66 | + $label = self::replace_variables($field['custom_label'], $form, $entry); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param[in,out] string $appended_content Content you can add after a label. Empty by default. |
73 | 73 | * @param[in] array $field GravityView field array |
74 | 74 | */ |
75 | - $label .= apply_filters( 'gravityview_render_after_label', '', $field ); |
|
75 | + $label .= apply_filters('gravityview_render_after_label', '', $field); |
|
76 | 76 | |
77 | 77 | } // End $field['show_label'] |
78 | 78 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param[in] array $form Gravity Forms form array |
85 | 85 | * @param[in] array $entry Gravity Forms entry array |
86 | 86 | */ |
87 | - $label = apply_filters( 'gravityview/template/field_label', $label, $field, $form, $entry ); |
|
87 | + $label = apply_filters('gravityview/template/field_label', $label, $field, $form, $entry); |
|
88 | 88 | |
89 | 89 | return $label; |
90 | 90 | } |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | * @param array $entry GF Entry array |
100 | 100 | * @return string Text with variables maybe replaced |
101 | 101 | */ |
102 | - public static function replace_variables($text, $form, $entry ) { |
|
103 | - return GravityView_Merge_Tags::replace_variables( $text, $form, $entry ); |
|
102 | + public static function replace_variables($text, $form, $entry) { |
|
103 | + return GravityView_Merge_Tags::replace_variables($text, $form, $entry); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -113,19 +113,19 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string|null If not empty, string in $format format. Otherwise, null. |
115 | 115 | */ |
116 | - public static function field_width( $field, $format = '%d%%' ) { |
|
116 | + public static function field_width($field, $format = '%d%%') { |
|
117 | 117 | |
118 | 118 | $width = NULL; |
119 | 119 | |
120 | - if( !empty( $field['width'] ) ) { |
|
121 | - $width = absint( $field['width'] ); |
|
120 | + if (!empty($field['width'])) { |
|
121 | + $width = absint($field['width']); |
|
122 | 122 | |
123 | 123 | // If using percentages, limit to 100% |
124 | - if( '%d%%' === $format && $width > 100 ) { |
|
124 | + if ('%d%%' === $format && $width > 100) { |
|
125 | 125 | $width = 100; |
126 | 126 | } |
127 | 127 | |
128 | - $width = sprintf( $format, $width ); |
|
128 | + $width = sprintf($format, $width); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | return $width; |
@@ -139,38 +139,38 @@ discard block |
||
139 | 139 | * @param mixed $field |
140 | 140 | * @return string |
141 | 141 | */ |
142 | - public static function field_class( $field, $form = NULL, $entry = NULL ) { |
|
142 | + public static function field_class($field, $form = NULL, $entry = NULL) { |
|
143 | 143 | $gravityview_view = GravityView_View::getInstance(); |
144 | 144 | |
145 | 145 | $classes = array(); |
146 | 146 | |
147 | - if( !empty( $field['custom_class'] ) ) { |
|
147 | + if (!empty($field['custom_class'])) { |
|
148 | 148 | |
149 | 149 | $custom_class = $field['custom_class']; |
150 | 150 | |
151 | - if( !empty( $entry ) ) { |
|
151 | + if (!empty($entry)) { |
|
152 | 152 | |
153 | 153 | // We want the merge tag to be formatted as a class. The merge tag may be |
154 | 154 | // replaced by a multiple-word value that should be output as a single class. |
155 | 155 | // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
156 | 156 | add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
157 | 157 | |
158 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
158 | + $custom_class = self::replace_variables($custom_class, $form, $entry); |
|
159 | 159 | |
160 | 160 | // And then we want life to return to normal |
161 | 161 | remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
162 | 162 | } |
163 | 163 | |
164 | 164 | // And now we want the spaces to be handled nicely. |
165 | - $classes[] = gravityview_sanitize_html_class( $custom_class ); |
|
165 | + $classes[] = gravityview_sanitize_html_class($custom_class); |
|
166 | 166 | |
167 | 167 | } |
168 | 168 | |
169 | - if(!empty($field['id'])) { |
|
170 | - if( !empty( $form ) && !empty( $form['id'] ) ) { |
|
169 | + if (!empty($field['id'])) { |
|
170 | + if (!empty($form) && !empty($form['id'])) { |
|
171 | 171 | $form_id = '-'.$form['id']; |
172 | 172 | } else { |
173 | - $form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : ''; |
|
173 | + $form_id = $gravityview_view->getFormId() ? '-'.$gravityview_view->getFormId() : ''; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | $classes[] = 'gv-field'.$form_id.'-'.$field['id']; |
@@ -191,21 +191,21 @@ discard block |
||
191 | 191 | * @param array $entry Gravity Forms entry array |
192 | 192 | * @return string Sanitized unique HTML `id` attribute for the field |
193 | 193 | */ |
194 | - public static function field_html_attr_id( $field, $form = array(), $entry = array() ) { |
|
194 | + public static function field_html_attr_id($field, $form = array(), $entry = array()) { |
|
195 | 195 | $gravityview_view = GravityView_View::getInstance(); |
196 | 196 | $id = $field['id']; |
197 | 197 | |
198 | - if ( ! empty( $id ) ) { |
|
199 | - if ( ! empty( $form ) && ! empty( $form['id'] ) ) { |
|
200 | - $form_id = '-' . $form['id']; |
|
198 | + if (!empty($id)) { |
|
199 | + if (!empty($form) && !empty($form['id'])) { |
|
200 | + $form_id = '-'.$form['id']; |
|
201 | 201 | } else { |
202 | - $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
|
202 | + $form_id = $gravityview_view->getFormId() ? '-'.$gravityview_view->getFormId() : ''; |
|
203 | 203 | } |
204 | 204 | |
205 | - $id = 'gv-field' . $form_id . '-' . $field['id']; |
|
205 | + $id = 'gv-field'.$form_id.'-'.$field['id']; |
|
206 | 206 | } |
207 | 207 | |
208 | - return esc_attr( $id ); |
|
208 | + return esc_attr($id); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -217,15 +217,15 @@ discard block |
||
217 | 217 | * @param integer $field |
218 | 218 | * @return null|string |
219 | 219 | */ |
220 | - public static function field_value( $entry, $field_settings, $format = 'html' ) { |
|
220 | + public static function field_value($entry, $field_settings, $format = 'html') { |
|
221 | 221 | |
222 | - if( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) { |
|
222 | + if (empty($entry['form_id']) || empty($field_settings['id'])) { |
|
223 | 223 | return NULL; |
224 | 224 | } |
225 | 225 | |
226 | 226 | $gravityview_view = GravityView_View::getInstance(); |
227 | 227 | |
228 | - if( class_exists( 'GFCache' ) ) { |
|
228 | + if (class_exists('GFCache')) { |
|
229 | 229 | /** |
230 | 230 | * Gravity Forms' GFCache function was thrashing the database, causing double the amount of time for the field_value() method to run. |
231 | 231 | * |
@@ -240,18 +240,18 @@ discard block |
||
240 | 240 | * @param boolean false Tell Gravity Forms not to store this as a transient |
241 | 241 | * @param int 0 Time to store the value. 0 is maximum amount of time possible. |
242 | 242 | */ |
243 | - GFCache::set( "GFFormsModel::get_lead_field_value_" . $entry["id"] . "_" . $field_settings["id"], false, false, 0 ); |
|
243 | + GFCache::set("GFFormsModel::get_lead_field_value_".$entry["id"]."_".$field_settings["id"], false, false, 0); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | $field_id = $field_settings['id']; |
247 | 247 | |
248 | 248 | $form = $gravityview_view->getForm(); |
249 | 249 | |
250 | - $field = gravityview_get_field( $form, $field_id ); |
|
250 | + $field = gravityview_get_field($form, $field_id); |
|
251 | 251 | |
252 | 252 | $field_type = RGFormsModel::get_input_type($field); |
253 | 253 | |
254 | - if( $field_type ) { |
|
254 | + if ($field_type) { |
|
255 | 255 | $field_type = $field['type']; |
256 | 256 | $value = RGFormsModel::get_lead_field_value($entry, $field); |
257 | 257 | } else { |
@@ -266,15 +266,15 @@ discard block |
||
266 | 266 | |
267 | 267 | $display_value = GFCommon::get_lead_field_display($field, $value, $entry["currency"], false, $format); |
268 | 268 | |
269 | - if( $errors = ob_get_clean() ) { |
|
270 | - do_action( 'gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors ); |
|
269 | + if ($errors = ob_get_clean()) { |
|
270 | + do_action('gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $entry, $form); |
274 | 274 | |
275 | 275 | // prevent the use of merge_tags for non-admin fields |
276 | - if( !empty( $field['adminOnly'] ) ) { |
|
277 | - $display_value = self::replace_variables( $display_value, $form, $entry ); |
|
276 | + if (!empty($field['adminOnly'])) { |
|
277 | + $display_value = self::replace_variables($display_value, $form, $entry); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | // Check whether the field exists in /includes/fields/{$field_type}.php |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $field_exists = $gravityview_view->locate_template("fields/{$field_type}.php"); |
283 | 283 | |
284 | 284 | // Set the field data to be available in the templates |
285 | - $gravityview_view->setCurrentField( array( |
|
285 | + $gravityview_view->setCurrentField(array( |
|
286 | 286 | 'form' => $form, |
287 | 287 | 'field_id' => $field_id, |
288 | 288 | 'field' => $field, |
@@ -294,13 +294,13 @@ discard block |
||
294 | 294 | 'field_type' => $field_type, /** {@since 1.6} **/ |
295 | 295 | )); |
296 | 296 | |
297 | - if( $field_exists ) { |
|
297 | + if ($field_exists) { |
|
298 | 298 | |
299 | - do_action( 'gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_exists ) ); |
|
299 | + do_action('gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_exists)); |
|
300 | 300 | |
301 | 301 | ob_start(); |
302 | 302 | |
303 | - load_template( $field_exists, false ); |
|
303 | + load_template($field_exists, false); |
|
304 | 304 | |
305 | 305 | $output = ob_get_clean(); |
306 | 306 | |
@@ -319,11 +319,11 @@ discard block |
||
319 | 319 | * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example. |
320 | 320 | * |
321 | 321 | */ |
322 | - if( !empty( $field_settings['show_as_link'] ) ) { |
|
322 | + if (!empty($field_settings['show_as_link'])) { |
|
323 | 323 | |
324 | - $link_atts = empty( $field_settings['new_window'] ) ? array() : array( 'target' => '_blank' ); |
|
324 | + $link_atts = empty($field_settings['new_window']) ? array() : array('target' => '_blank'); |
|
325 | 325 | |
326 | - $output = self::entry_link_html( $entry, $output, $link_atts, $field_settings ); |
|
326 | + $output = self::entry_link_html($entry, $output, $link_atts, $field_settings); |
|
327 | 327 | |
328 | 328 | } |
329 | 329 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @param array $entry The GF entry array |
335 | 335 | * @param array $field_settings Settings for the particular GV field |
336 | 336 | */ |
337 | - $output = apply_filters( 'gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
337 | + $output = apply_filters('gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField()); |
|
338 | 338 | |
339 | 339 | /** |
340 | 340 | * @filter `gravityview_field_entry_value` Modify the field value output for all field types |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @param array $field_settings Settings for the particular GV field |
344 | 344 | * @param array $field_data {@since 1.6} |
345 | 345 | */ |
346 | - $output = apply_filters( 'gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
346 | + $output = apply_filters('gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField()); |
|
347 | 347 | |
348 | 348 | return $output; |
349 | 349 | } |
@@ -357,18 +357,18 @@ discard block |
||
357 | 357 | * @param array $entry Gravity Forms entry array |
358 | 358 | * @param array $field_settings Array of field settings. Optional, but passed to the `gravityview_field_entry_link` filter |
359 | 359 | */ |
360 | - public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array() ) { |
|
360 | + public static function entry_link_html($entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array()) { |
|
361 | 361 | |
362 | - if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) { |
|
362 | + if (empty($entry) || !is_array($entry) || !isset($entry['id'])) { |
|
363 | 363 | |
364 | - do_action( 'gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry ); |
|
364 | + do_action('gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry); |
|
365 | 365 | |
366 | 366 | return NULL; |
367 | 367 | } |
368 | 368 | |
369 | - $href = self::entry_link( $entry ); |
|
369 | + $href = self::entry_link($entry); |
|
370 | 370 | |
371 | - $link = gravityview_get_link( $href, $anchor_text, $passed_tag_atts ); |
|
371 | + $link = gravityview_get_link($href, $anchor_text, $passed_tag_atts); |
|
372 | 372 | |
373 | 373 | /** |
374 | 374 | * @filter `gravityview_field_entry_link` Modify the link HTML |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | * @param array $entry The GF entry array |
378 | 378 | * @param array $field_settings Settings for the particular GV field |
379 | 379 | */ |
380 | - $output = apply_filters( 'gravityview_field_entry_link', $link, $href, $entry, $field_settings ); |
|
380 | + $output = apply_filters('gravityview_field_entry_link', $link, $href, $entry, $field_settings); |
|
381 | 381 | |
382 | 382 | return $output; |
383 | 383 | } |
@@ -392,11 +392,11 @@ discard block |
||
392 | 392 | |
393 | 393 | $is_search = false; |
394 | 394 | |
395 | - if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
395 | + if ($gravityview_view && ($gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search)) { |
|
396 | 396 | $is_search = true; |
397 | 397 | } |
398 | 398 | |
399 | - if($is_search) { |
|
399 | + if ($is_search) { |
|
400 | 400 | $output = __('This search returned no results.', 'gravityview'); |
401 | 401 | } else { |
402 | 402 | $output = __('No entries match your request.', 'gravityview'); |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * @param string $output The existing "No Entries" text |
408 | 408 | * @param boolean $is_search Is the current page a search result, or just a multiple entries screen? |
409 | 409 | */ |
410 | - $output = apply_filters( 'gravitview_no_entries_text', $output, $is_search); |
|
410 | + $output = apply_filters('gravitview_no_entries_text', $output, $is_search); |
|
411 | 411 | |
412 | 412 | return $wpautop ? wpautop($output) : $output; |
413 | 413 | } |
@@ -421,42 +421,42 @@ discard block |
||
421 | 421 | * @param boolean $add_query_args Add pagination and sorting arguments |
422 | 422 | * @return string Permalink to multiple entries view |
423 | 423 | */ |
424 | - public static function directory_link( $post_id = NULL, $add_query_args = true ) { |
|
424 | + public static function directory_link($post_id = NULL, $add_query_args = true) { |
|
425 | 425 | global $post; |
426 | 426 | |
427 | 427 | $gravityview_view = GravityView_View::getInstance(); |
428 | 428 | |
429 | - if( empty( $post_id ) ) { |
|
429 | + if (empty($post_id)) { |
|
430 | 430 | |
431 | 431 | $post_id = false; |
432 | 432 | |
433 | 433 | // DataTables passes the Post ID |
434 | - if( defined('DOING_AJAX') && DOING_AJAX ) { |
|
434 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
435 | 435 | |
436 | - $post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : false; |
|
436 | + $post_id = isset($_POST['post_id']) ? (int)$_POST['post_id'] : false; |
|
437 | 437 | |
438 | 438 | } else { |
439 | 439 | |
440 | 440 | // The Post ID has been passed via the shortcode |
441 | - if( !empty( $gravityview_view ) && $gravityview_view->getPostId() ) { |
|
441 | + if (!empty($gravityview_view) && $gravityview_view->getPostId()) { |
|
442 | 442 | |
443 | 443 | $post_id = $gravityview_view->getPostId(); |
444 | 444 | |
445 | 445 | } else { |
446 | 446 | |
447 | 447 | // This is a GravityView post type |
448 | - if( GravityView_frontend::getInstance()->is_gravityview_post_type ) { |
|
448 | + if (GravityView_frontend::getInstance()->is_gravityview_post_type) { |
|
449 | 449 | |
450 | - $post_id = isset( $gravityview_view ) ? $gravityview_view->getViewId() : $post->ID; |
|
450 | + $post_id = isset($gravityview_view) ? $gravityview_view->getViewId() : $post->ID; |
|
451 | 451 | |
452 | 452 | } else { |
453 | 453 | |
454 | 454 | // This is an embedded GravityView; use the embedded post's ID as the base. |
455 | - if( GravityView_frontend::getInstance()->post_has_shortcode && is_a( $post, 'WP_Post' ) ) { |
|
455 | + if (GravityView_frontend::getInstance()->post_has_shortcode && is_a($post, 'WP_Post')) { |
|
456 | 456 | |
457 | 457 | $post_id = $post->ID; |
458 | 458 | |
459 | - } elseif( $gravityview_view->getViewId() ) { |
|
459 | + } elseif ($gravityview_view->getViewId()) { |
|
460 | 460 | |
461 | 461 | // The GravityView has been embedded in a widget or in a template, and |
462 | 462 | // is not in the current content. Thus, we defer to the View's own ID. |
@@ -471,39 +471,39 @@ discard block |
||
471 | 471 | } |
472 | 472 | |
473 | 473 | // No post ID, get outta here. |
474 | - if( empty( $post_id ) ) { |
|
474 | + if (empty($post_id)) { |
|
475 | 475 | return NULL; |
476 | 476 | } |
477 | 477 | |
478 | 478 | // If we've saved the permalink in memory, use it |
479 | 479 | // @since 1.3 |
480 | - $link = wp_cache_get( 'gv_directory_link_'.$post_id ); |
|
480 | + $link = wp_cache_get('gv_directory_link_'.$post_id); |
|
481 | 481 | |
482 | - if( empty( $link ) ) { |
|
482 | + if (empty($link)) { |
|
483 | 483 | |
484 | - $link = get_permalink( $post_id ); |
|
484 | + $link = get_permalink($post_id); |
|
485 | 485 | |
486 | 486 | // If not yet saved, cache the permalink. |
487 | 487 | // @since 1.3 |
488 | - wp_cache_set( 'gv_directory_link_'.$post_id, $link ); |
|
488 | + wp_cache_set('gv_directory_link_'.$post_id, $link); |
|
489 | 489 | |
490 | 490 | } |
491 | 491 | |
492 | 492 | // Deal with returning to proper pagination for embedded views |
493 | - if( $link && $add_query_args ) { |
|
493 | + if ($link && $add_query_args) { |
|
494 | 494 | |
495 | 495 | $args = array(); |
496 | 496 | |
497 | - if( $pagenum = rgget('pagenum') ) { |
|
498 | - $args['pagenum'] = intval( $pagenum ); |
|
497 | + if ($pagenum = rgget('pagenum')) { |
|
498 | + $args['pagenum'] = intval($pagenum); |
|
499 | 499 | } |
500 | 500 | |
501 | - if( $sort = rgget('sort') ) { |
|
501 | + if ($sort = rgget('sort')) { |
|
502 | 502 | $args['sort'] = $sort; |
503 | 503 | $args['dir'] = rgget('dir'); |
504 | 504 | } |
505 | 505 | |
506 | - $link = add_query_arg( $args, $link ); |
|
506 | + $link = add_query_arg($args, $link); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | return $link; |
@@ -520,10 +520,10 @@ discard block |
||
520 | 520 | * @param array $entry Entry data passed to provide additional information when generating the hash. Optional - don't rely on it being available. |
521 | 521 | * @return string Hashed unique value for entry |
522 | 522 | */ |
523 | - private static function get_custom_entry_slug( $id, $entry = array() ) { |
|
523 | + private static function get_custom_entry_slug($id, $entry = array()) { |
|
524 | 524 | |
525 | 525 | // Generate an unique hash to use as the default value |
526 | - $slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 ); |
|
526 | + $slug = substr(wp_hash($id, 'gravityview'.$id), 0, 8); |
|
527 | 527 | |
528 | 528 | /** |
529 | 529 | * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}` |
@@ -531,14 +531,14 @@ discard block |
||
531 | 531 | * @param string $id The entry ID |
532 | 532 | * @param array $entry Entry data array. May be empty. |
533 | 533 | */ |
534 | - $slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry ); |
|
534 | + $slug = apply_filters('gravityview_entry_slug', $slug, $id, $entry); |
|
535 | 535 | |
536 | 536 | // Make sure we have something - use the original ID as backup. |
537 | - if( empty( $slug ) ) { |
|
537 | + if (empty($slug)) { |
|
538 | 538 | $slug = $id; |
539 | 539 | } |
540 | 540 | |
541 | - return sanitize_title( $slug ); |
|
541 | + return sanitize_title($slug); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | * @param array $entry Gravity Forms Entry array, optional. Used only to provide data to customize the `gravityview_entry_slug` filter |
553 | 553 | * @return string Unique slug ID, passed through `sanitize_title()` |
554 | 554 | */ |
555 | - public static function get_entry_slug( $id_or_string, $entry = array() ) { |
|
555 | + public static function get_entry_slug($id_or_string, $entry = array()) { |
|
556 | 556 | |
557 | 557 | /** |
558 | 558 | * Default: use the entry ID as the unique identifier |
@@ -563,32 +563,32 @@ discard block |
||
563 | 563 | * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. |
564 | 564 | * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) |
565 | 565 | */ |
566 | - $custom = apply_filters('gravityview_custom_entry_slug', false ); |
|
566 | + $custom = apply_filters('gravityview_custom_entry_slug', false); |
|
567 | 567 | |
568 | 568 | // If we're using custom slug... |
569 | - if ( $custom ) { |
|
569 | + if ($custom) { |
|
570 | 570 | |
571 | 571 | // Get the entry hash |
572 | - $hash = self::get_custom_entry_slug( $id_or_string, $entry ); |
|
572 | + $hash = self::get_custom_entry_slug($id_or_string, $entry); |
|
573 | 573 | |
574 | 574 | // See if the entry already has a hash set |
575 | - $value = gform_get_meta( $id_or_string, 'gravityview_unique_id' ); |
|
575 | + $value = gform_get_meta($id_or_string, 'gravityview_unique_id'); |
|
576 | 576 | |
577 | 577 | // If it does have a hash set, and the hash is expected, use it. |
578 | 578 | // This check allows users to change the hash structure using the |
579 | 579 | // gravityview_entry_hash filter and have the old hashes expire. |
580 | - if( empty( $value ) || $value !== $hash ) { |
|
580 | + if (empty($value) || $value !== $hash) { |
|
581 | 581 | |
582 | - gform_update_meta( $id_or_string, 'gravityview_unique_id', $hash ); |
|
582 | + gform_update_meta($id_or_string, 'gravityview_unique_id', $hash); |
|
583 | 583 | |
584 | 584 | } |
585 | 585 | |
586 | 586 | $slug = $hash; |
587 | 587 | |
588 | - unset( $value, $hash ); |
|
588 | + unset($value, $hash); |
|
589 | 589 | } |
590 | 590 | |
591 | - return sanitize_title( $slug ); |
|
591 | + return sanitize_title($slug); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
@@ -599,18 +599,18 @@ discard block |
||
599 | 599 | * @param $entry array Gravity Forms entry object |
600 | 600 | * @param $form array Gravity Forms form object |
601 | 601 | */ |
602 | - public static function entry_create_custom_slug( $entry, $form ) { |
|
602 | + public static function entry_create_custom_slug($entry, $form) { |
|
603 | 603 | /** |
604 | 604 | * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta |
605 | 605 | * @param boolean $custom Should we process the custom entry slug? |
606 | 606 | */ |
607 | - $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
608 | - if( $custom ) { |
|
607 | + $custom = apply_filters('gravityview_custom_entry_slug', false); |
|
608 | + if ($custom) { |
|
609 | 609 | // create the gravityview_unique_id and save it |
610 | 610 | |
611 | 611 | // Get the entry hash |
612 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
613 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash ); |
|
612 | + $hash = self::get_custom_entry_slug($entry['id'], $entry); |
|
613 | + gform_update_meta($entry['id'], 'gravityview_unique_id', $hash); |
|
614 | 614 | |
615 | 615 | } |
616 | 616 | } |
@@ -625,55 +625,55 @@ discard block |
||
625 | 625 | * @param boolean $add_directory_args True: Add args to help return to directory; False: only include args required to get to entry {@since 1.7.3} |
626 | 626 | * @return string Link to the entry with the directory parent slug |
627 | 627 | */ |
628 | - public static function entry_link( $entry, $post_id = NULL, $add_directory_args = true ) { |
|
628 | + public static function entry_link($entry, $post_id = NULL, $add_directory_args = true) { |
|
629 | 629 | |
630 | - if( ! empty( $entry ) && ! is_array( $entry ) ) { |
|
631 | - $entry = GVCommon::get_entry( $entry ); |
|
632 | - } else if( empty( $entry ) ) { |
|
630 | + if (!empty($entry) && !is_array($entry)) { |
|
631 | + $entry = GVCommon::get_entry($entry); |
|
632 | + } else if (empty($entry)) { |
|
633 | 633 | $entry = GravityView_frontend::getInstance()->getEntry(); |
634 | 634 | } |
635 | 635 | |
636 | 636 | // Second parameter used to be passed as $field; this makes sure it's not an array |
637 | - if( !is_numeric( $post_id ) ) { |
|
637 | + if (!is_numeric($post_id)) { |
|
638 | 638 | $post_id = NULL; |
639 | 639 | } |
640 | 640 | |
641 | 641 | // Get the permalink to the View |
642 | - $directory_link = self::directory_link( $post_id, false ); |
|
642 | + $directory_link = self::directory_link($post_id, false); |
|
643 | 643 | |
644 | 644 | // No post ID? Get outta here. |
645 | - if( empty( $directory_link ) ) { |
|
645 | + if (empty($directory_link)) { |
|
646 | 646 | return ''; |
647 | 647 | } |
648 | 648 | |
649 | 649 | $query_arg_name = GravityView_Post_Types::get_entry_var_name(); |
650 | 650 | |
651 | - $entry_slug = self::get_entry_slug( $entry['id'], $entry ); |
|
651 | + $entry_slug = self::get_entry_slug($entry['id'], $entry); |
|
652 | 652 | |
653 | - if( get_option('permalink_structure') && !is_preview() ) { |
|
653 | + if (get_option('permalink_structure') && !is_preview()) { |
|
654 | 654 | |
655 | 655 | $args = array(); |
656 | 656 | |
657 | - $directory_link = trailingslashit( $directory_link ) . $query_arg_name . '/'. $entry_slug .'/'; |
|
657 | + $directory_link = trailingslashit($directory_link).$query_arg_name.'/'.$entry_slug.'/'; |
|
658 | 658 | |
659 | 659 | } else { |
660 | 660 | |
661 | - $args = array( $query_arg_name => $entry_slug ); |
|
661 | + $args = array($query_arg_name => $entry_slug); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | /** |
665 | 665 | * @since 1.7.3 |
666 | 666 | */ |
667 | - if( $add_directory_args ) { |
|
667 | + if ($add_directory_args) { |
|
668 | 668 | |
669 | - if( !empty( $_GET['pagenum'] ) ) { |
|
670 | - $args['pagenum'] = intval( $_GET['pagenum'] ); |
|
669 | + if (!empty($_GET['pagenum'])) { |
|
670 | + $args['pagenum'] = intval($_GET['pagenum']); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
674 | 674 | * @since 1.7 |
675 | 675 | */ |
676 | - if( $sort = rgget('sort') ) { |
|
676 | + if ($sort = rgget('sort')) { |
|
677 | 677 | $args['sort'] = $sort; |
678 | 678 | $args['dir'] = rgget('dir'); |
679 | 679 | } |
@@ -685,11 +685,11 @@ discard block |
||
685 | 685 | * has the view id so that Advanced Filters can be applied correctly when rendering the single view |
686 | 686 | * @see GravityView_frontend::get_context_view_id() |
687 | 687 | */ |
688 | - if( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
|
688 | + if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views()) { |
|
689 | 689 | $args['gvid'] = gravityview_get_view_id(); |
690 | 690 | } |
691 | 691 | |
692 | - return add_query_arg( $args, $directory_link ); |
|
692 | + return add_query_arg($args, $directory_link); |
|
693 | 693 | |
694 | 694 | } |
695 | 695 | |
@@ -699,54 +699,54 @@ discard block |
||
699 | 699 | |
700 | 700 | // inside loop functions |
701 | 701 | |
702 | -function gv_label( $field, $entry = NULL ) { |
|
703 | - return GravityView_API::field_label( $field, $entry ); |
|
702 | +function gv_label($field, $entry = NULL) { |
|
703 | + return GravityView_API::field_label($field, $entry); |
|
704 | 704 | } |
705 | 705 | |
706 | -function gv_class( $field, $form = NULL, $entry = array() ) { |
|
707 | - return GravityView_API::field_class( $field, $form, $entry ); |
|
706 | +function gv_class($field, $form = NULL, $entry = array()) { |
|
707 | + return GravityView_API::field_class($field, $form, $entry); |
|
708 | 708 | } |
709 | 709 | |
710 | -function gv_container_class( $class = '' ) { |
|
710 | +function gv_container_class($class = '') { |
|
711 | 711 | |
712 | 712 | $default = ' gv-container'; |
713 | 713 | |
714 | - if( GravityView_View::getInstance()->isHideUntilSearched() ) { |
|
714 | + if (GravityView_View::getInstance()->isHideUntilSearched()) { |
|
715 | 715 | $default .= ' hidden'; |
716 | 716 | } |
717 | 717 | |
718 | - $class = apply_filters( 'gravityview/render/container/class', $class . $default ); |
|
718 | + $class = apply_filters('gravityview/render/container/class', $class.$default); |
|
719 | 719 | |
720 | - $class = gravityview_sanitize_html_class( $class ); |
|
720 | + $class = gravityview_sanitize_html_class($class); |
|
721 | 721 | |
722 | 722 | echo $class; |
723 | 723 | } |
724 | 724 | |
725 | -function gv_value( $entry, $field ) { |
|
725 | +function gv_value($entry, $field) { |
|
726 | 726 | |
727 | - $value = GravityView_API::field_value( $entry, $field ); |
|
727 | + $value = GravityView_API::field_value($entry, $field); |
|
728 | 728 | |
729 | - if( $value === '') { |
|
729 | + if ($value === '') { |
|
730 | 730 | /** |
731 | 731 | * @filter `gravityview_empty_value` What to display when a field is empty |
732 | 732 | * @param string $value (empty string) |
733 | 733 | */ |
734 | - $value = apply_filters( 'gravityview_empty_value', '' ); |
|
734 | + $value = apply_filters('gravityview_empty_value', ''); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | return $value; |
738 | 738 | } |
739 | 739 | |
740 | -function gv_directory_link( $post = NULL, $add_pagination = true ) { |
|
741 | - return GravityView_API::directory_link( $post, $add_pagination ); |
|
740 | +function gv_directory_link($post = NULL, $add_pagination = true) { |
|
741 | + return GravityView_API::directory_link($post, $add_pagination); |
|
742 | 742 | } |
743 | 743 | |
744 | -function gv_entry_link( $entry, $post_id = NULL ) { |
|
745 | - return GravityView_API::entry_link( $entry, $post_id ); |
|
744 | +function gv_entry_link($entry, $post_id = NULL) { |
|
745 | + return GravityView_API::entry_link($entry, $post_id); |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | function gv_no_results($wpautop = true) { |
749 | - return GravityView_API::no_results( $wpautop ); |
|
749 | + return GravityView_API::no_results($wpautop); |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | /** |
@@ -758,21 +758,21 @@ discard block |
||
758 | 758 | |
759 | 759 | $href = gv_directory_link(); |
760 | 760 | |
761 | - if( empty( $href ) ) { return NULL; } |
|
761 | + if (empty($href)) { return NULL; } |
|
762 | 762 | |
763 | 763 | // calculate link label |
764 | 764 | $gravityview_view = GravityView_View::getInstance(); |
765 | 765 | |
766 | - $label = $gravityview_view->getBackLinkLabel() ? $gravityview_view->getBackLinkLabel() : __( '← Go back', 'gravityview' ); |
|
766 | + $label = $gravityview_view->getBackLinkLabel() ? $gravityview_view->getBackLinkLabel() : __('← Go back', 'gravityview'); |
|
767 | 767 | |
768 | 768 | /** |
769 | 769 | * @filter `gravityview_go_back_label` Modify the back link text |
770 | 770 | * @since 1.0.9 |
771 | 771 | * @param string $label Existing label text |
772 | 772 | */ |
773 | - $label = apply_filters( 'gravityview_go_back_label', $label ); |
|
773 | + $label = apply_filters('gravityview_go_back_label', $label); |
|
774 | 774 | |
775 | - $link = gravityview_get_link( $href, esc_html( $label ), array( |
|
775 | + $link = gravityview_get_link($href, esc_html($label), array( |
|
776 | 776 | 'data-viewid' => $gravityview_view->getViewId() |
777 | 777 | )); |
778 | 778 | |
@@ -791,9 +791,9 @@ discard block |
||
791 | 791 | * @param string $display_value The value generated by Gravity Forms |
792 | 792 | * @return string Value |
793 | 793 | */ |
794 | -function gravityview_get_field_value( $entry, $field_id, $display_value ) { |
|
794 | +function gravityview_get_field_value($entry, $field_id, $display_value) { |
|
795 | 795 | |
796 | - if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
796 | + if (floatval($field_id) === floor(floatval($field_id))) { |
|
797 | 797 | |
798 | 798 | // For the complete field value as generated by Gravity Forms |
799 | 799 | return $display_value; |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | } else { |
802 | 802 | |
803 | 803 | // For one part of the address (City, ZIP, etc.) |
804 | - return isset( $entry[ $field_id ] ) ? $entry[ $field_id ] : ''; |
|
804 | + return isset($entry[$field_id]) ? $entry[$field_id] : ''; |
|
805 | 805 | |
806 | 806 | } |
807 | 807 | |
@@ -817,48 +817,48 @@ discard block |
||
817 | 817 | * @param string $taxonomy Type of term (`post_tag` or `category`) |
818 | 818 | * @return string CSV of linked terms |
819 | 819 | */ |
820 | -function gravityview_convert_value_to_term_list( $value, $taxonomy = 'post_tag' ) { |
|
820 | +function gravityview_convert_value_to_term_list($value, $taxonomy = 'post_tag') { |
|
821 | 821 | |
822 | 822 | $output = array(); |
823 | 823 | |
824 | - $terms = explode( ', ', $value ); |
|
824 | + $terms = explode(', ', $value); |
|
825 | 825 | |
826 | - foreach ($terms as $term_name ) { |
|
826 | + foreach ($terms as $term_name) { |
|
827 | 827 | |
828 | 828 | // If we're processing a category, |
829 | - if( $taxonomy === 'category' ) { |
|
829 | + if ($taxonomy === 'category') { |
|
830 | 830 | |
831 | 831 | // Use rgexplode to prevent errors if : doesn't exist |
832 | - list( $term_name, $term_id ) = rgexplode( ':', $value, 2 ); |
|
832 | + list($term_name, $term_id) = rgexplode(':', $value, 2); |
|
833 | 833 | |
834 | 834 | // The explode was succesful; we have the category ID |
835 | - if( !empty( $term_id )) { |
|
836 | - $term = get_term_by( 'id', $term_id, $taxonomy ); |
|
835 | + if (!empty($term_id)) { |
|
836 | + $term = get_term_by('id', $term_id, $taxonomy); |
|
837 | 837 | } else { |
838 | 838 | // We have to fall back to the name |
839 | - $term = get_term_by( 'name', $term_name, $taxonomy ); |
|
839 | + $term = get_term_by('name', $term_name, $taxonomy); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | } else { |
843 | 843 | // Use the name of the tag to get the full term information |
844 | - $term = get_term_by( 'name', $term_name, $taxonomy ); |
|
844 | + $term = get_term_by('name', $term_name, $taxonomy); |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | // There's still a tag/category here. |
848 | - if( $term ) { |
|
848 | + if ($term) { |
|
849 | 849 | |
850 | - $term_link = get_term_link( $term, $taxonomy ); |
|
850 | + $term_link = get_term_link($term, $taxonomy); |
|
851 | 851 | |
852 | 852 | // If there was an error, continue to the next term. |
853 | - if ( is_wp_error( $term_link ) ) { |
|
853 | + if (is_wp_error($term_link)) { |
|
854 | 854 | continue; |
855 | 855 | } |
856 | 856 | |
857 | - $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
857 | + $output[] = gravityview_get_link($term_link, esc_html($term->name)); |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | |
861 | - return implode(', ', $output ); |
|
861 | + return implode(', ', $output); |
|
862 | 862 | } |
863 | 863 | |
864 | 864 | /** |
@@ -868,12 +868,12 @@ discard block |
||
868 | 868 | * @param string $taxonomy Taxonomy of term to fetch. |
869 | 869 | * @return string String with terms |
870 | 870 | */ |
871 | -function gravityview_get_the_term_list( $post_id, $link = true, $taxonomy = 'post_tag' ) { |
|
871 | +function gravityview_get_the_term_list($post_id, $link = true, $taxonomy = 'post_tag') { |
|
872 | 872 | |
873 | - $output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' ); |
|
873 | + $output = get_the_term_list($post_id, $taxonomy, NULL, ', '); |
|
874 | 874 | |
875 | - if( empty( $link ) ) { |
|
876 | - return strip_tags( $output); |
|
875 | + if (empty($link)) { |
|
876 | + return strip_tags($output); |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | return $output; |
@@ -892,17 +892,17 @@ discard block |
||
892 | 892 | $fe = GravityView_frontend::getInstance(); |
893 | 893 | |
894 | 894 | // Solve problem when loading content via admin-ajax.php |
895 | - if( ! $fe->getGvOutputData() ) { |
|
895 | + if (!$fe->getGvOutputData()) { |
|
896 | 896 | |
897 | - do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.' ); |
|
897 | + do_action('gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.'); |
|
898 | 898 | |
899 | 899 | $fe->parse_content(); |
900 | 900 | } |
901 | 901 | |
902 | 902 | // Make 100% sure that we're dealing with a properly called situation |
903 | - if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
903 | + if (!is_a($fe->getGvOutputData(), 'GravityView_View_Data')) { |
|
904 | 904 | |
905 | - do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData() ); |
|
905 | + do_action('gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData()); |
|
906 | 906 | |
907 | 907 | return array(); |
908 | 908 | } |
@@ -916,18 +916,18 @@ discard block |
||
916 | 916 | * @see GravityView_View_Data::get_view() |
917 | 917 | * @return array View data with `id`, `view_id`, `form_id`, `template_id`, `atts`, `fields`, `widgets`, `form` keys. |
918 | 918 | */ |
919 | -function gravityview_get_current_view_data( $view_id = 0 ) { |
|
919 | +function gravityview_get_current_view_data($view_id = 0) { |
|
920 | 920 | |
921 | 921 | $fe = GravityView_frontend::getInstance(); |
922 | 922 | |
923 | - if( ! $fe->getGvOutputData() ) { return array(); } |
|
923 | + if (!$fe->getGvOutputData()) { return array(); } |
|
924 | 924 | |
925 | 925 | // If not set, grab the current view ID |
926 | - if( empty( $view_id ) ) { |
|
926 | + if (empty($view_id)) { |
|
927 | 927 | $view_id = $fe->get_context_view_id(); |
928 | 928 | } |
929 | 929 | |
930 | - return $fe->getGvOutputData()->get_view( $view_id ); |
|
930 | + return $fe->getGvOutputData()->get_view($view_id); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | // Templates' hooks |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | * @action `gravityview_before` Display content before a View. Used to render widget areas. Rendered outside the View container `<div>` |
937 | 937 | * @param int $view_id The ID of the View being displayed |
938 | 938 | */ |
939 | - do_action( 'gravityview_before', gravityview_get_view_id() ); |
|
939 | + do_action('gravityview_before', gravityview_get_view_id()); |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | function gravityview_header() { |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | * @action `gravityview_header` Prepend content to the View container `<div>` |
945 | 945 | * @param int $view_id The ID of the View being displayed |
946 | 946 | */ |
947 | - do_action( 'gravityview_header', gravityview_get_view_id() ); |
|
947 | + do_action('gravityview_header', gravityview_get_view_id()); |
|
948 | 948 | } |
949 | 949 | |
950 | 950 | function gravityview_footer() { |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | * @action `gravityview_after` Display content after a View. Used to render footer widget areas. Rendered outside the View container `<div>` |
953 | 953 | * @param int $view_id The ID of the View being displayed |
954 | 954 | */ |
955 | - do_action( 'gravityview_footer', gravityview_get_view_id() ); |
|
955 | + do_action('gravityview_footer', gravityview_get_view_id()); |
|
956 | 956 | } |
957 | 957 | |
958 | 958 | function gravityview_after() { |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | * @action `gravityview_after` Append content to the View container `<div>` |
961 | 961 | * @param int $view_id The ID of the View being displayed |
962 | 962 | */ |
963 | - do_action( 'gravityview_after', gravityview_get_view_id() ); |
|
963 | + do_action('gravityview_after', gravityview_get_view_id()); |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | /** |
@@ -986,13 +986,13 @@ discard block |
||
986 | 986 | * The Edit Entry functionality overrides this value. |
987 | 987 | * @param boolean $is_edit_entry |
988 | 988 | */ |
989 | - $is_edit_entry = apply_filters( 'gravityview_is_edit_entry', false ); |
|
989 | + $is_edit_entry = apply_filters('gravityview_is_edit_entry', false); |
|
990 | 990 | |
991 | - if( $is_edit_entry ) { |
|
991 | + if ($is_edit_entry) { |
|
992 | 992 | $context = 'edit'; |
993 | - } else if( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) { |
|
993 | + } else if (class_exists('GravityView_frontend') && $single = GravityView_frontend::is_single_entry()) { |
|
994 | 994 | $context = 'single'; |
995 | - } else if( class_exists( 'GravityView_View' ) ) { |
|
995 | + } else if (class_exists('GravityView_View')) { |
|
996 | 996 | $context = GravityView_View::getInstance()->getContext(); |
997 | 997 | } |
998 | 998 | |
@@ -1017,18 +1017,18 @@ discard block |
||
1017 | 1017 | * @param string $gv_class Field class to add to the output HTML |
1018 | 1018 | * @return array Array of file output, with `file_path` and `html` keys (see comments above) |
1019 | 1019 | */ |
1020 | -function gravityview_get_files_array( $value, $gv_class = '' ) { |
|
1020 | +function gravityview_get_files_array($value, $gv_class = '') { |
|
1021 | 1021 | /** @define "GRAVITYVIEW_DIR" "../" */ |
1022 | 1022 | |
1023 | - if( !class_exists( 'GravityView_Field' ) ) { |
|
1024 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' ); |
|
1023 | + if (!class_exists('GravityView_Field')) { |
|
1024 | + include_once(GRAVITYVIEW_DIR.'includes/fields/class-gravityview-field.php'); |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | - if( !class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
1028 | - include_once( GRAVITYVIEW_DIR .'includes/fields/fileupload.php' ); |
|
1027 | + if (!class_exists('GravityView_Field_FileUpload')) { |
|
1028 | + include_once(GRAVITYVIEW_DIR.'includes/fields/fileupload.php'); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | - return GravityView_Field_FileUpload::get_files_array( $value, $gv_class ); |
|
1031 | + return GravityView_Field_FileUpload::get_files_array($value, $gv_class); |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | /** |
@@ -1042,16 +1042,16 @@ discard block |
||
1042 | 1042 | * @param string $address Address |
1043 | 1043 | * @return string URL of link to map of address |
1044 | 1044 | */ |
1045 | -function gravityview_get_map_link( $address ) { |
|
1045 | +function gravityview_get_map_link($address) { |
|
1046 | 1046 | |
1047 | - $address_qs = str_replace( array( '<br />', "\n" ), ' ', $address ); // Replace \n with spaces |
|
1048 | - $address_qs = urlencode( $address_qs ); |
|
1047 | + $address_qs = str_replace(array('<br />', "\n"), ' ', $address); // Replace \n with spaces |
|
1048 | + $address_qs = urlencode($address_qs); |
|
1049 | 1049 | |
1050 | 1050 | $url = "https://maps.google.com/maps?q={$address_qs}"; |
1051 | 1051 | |
1052 | - $link_text = esc_html__( 'Map It', 'gravityview' ); |
|
1052 | + $link_text = esc_html__('Map It', 'gravityview'); |
|
1053 | 1053 | |
1054 | - $link = gravityview_get_link( $url, $link_text, 'class=map-it-link' ); |
|
1054 | + $link = gravityview_get_link($url, $link_text, 'class=map-it-link'); |
|
1055 | 1055 | |
1056 | 1056 | /** |
1057 | 1057 | * @filter `gravityview_map_link` Modify the map link generated. You can use a different mapping service, for example. |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | * @param[in] string $address Address to generate link for |
1060 | 1060 | * @param[in] string $url URL generated by the function |
1061 | 1061 | */ |
1062 | - $link = apply_filters( 'gravityview_map_link', $link, $address, $url ); |
|
1062 | + $link = apply_filters('gravityview_map_link', $link, $address, $url); |
|
1063 | 1063 | |
1064 | 1064 | return $link; |
1065 | 1065 | } |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | * @param array $passed_args Associative array with field data. `field` and `form` are required. |
1081 | 1081 | * @return string Field output. If empty value and hide empty is true, return empty. |
1082 | 1082 | */ |
1083 | -function gravityview_field_output( $passed_args ) { |
|
1083 | +function gravityview_field_output($passed_args) { |
|
1084 | 1084 | $defaults = array( |
1085 | 1085 | 'entry' => null, |
1086 | 1086 | 'field' => null, |
@@ -1092,7 +1092,7 @@ discard block |
||
1092 | 1092 | 'zone_id' => null, |
1093 | 1093 | ); |
1094 | 1094 | |
1095 | - $args = wp_parse_args( $passed_args, $defaults ); |
|
1095 | + $args = wp_parse_args($passed_args, $defaults); |
|
1096 | 1096 | |
1097 | 1097 | /** |
1098 | 1098 | * @filter `gravityview/field_output/args` Modify the args before generation begins |
@@ -1100,15 +1100,15 @@ discard block |
||
1100 | 1100 | * @param array $args Associative array; `field` and `form` is required. |
1101 | 1101 | * @param array $passed_args Original associative array with field data. `field` and `form` are required. |
1102 | 1102 | */ |
1103 | - $args = apply_filters( 'gravityview/field_output/args', $args, $passed_args ); |
|
1103 | + $args = apply_filters('gravityview/field_output/args', $args, $passed_args); |
|
1104 | 1104 | |
1105 | 1105 | // Required fields. |
1106 | - if ( empty( $args['field'] ) || empty( $args['form'] ) ) { |
|
1107 | - do_action( 'gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args ); |
|
1106 | + if (empty($args['field']) || empty($args['form'])) { |
|
1107 | + do_action('gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args); |
|
1108 | 1108 | return ''; |
1109 | 1109 | } |
1110 | 1110 | |
1111 | - $entry = empty( $args['entry'] ) ? array() : $args['entry']; |
|
1111 | + $entry = empty($args['entry']) ? array() : $args['entry']; |
|
1112 | 1112 | |
1113 | 1113 | /** |
1114 | 1114 | * Create the content variables for replacing. |
@@ -1124,36 +1124,36 @@ discard block |
||
1124 | 1124 | 'field_id' => '', |
1125 | 1125 | ); |
1126 | 1126 | |
1127 | - $context['value'] = gv_value( $entry, $args['field'] ); |
|
1127 | + $context['value'] = gv_value($entry, $args['field']); |
|
1128 | 1128 | |
1129 | 1129 | // If the value is empty and we're hiding empty, return empty. |
1130 | - if ( $context['value'] === '' && ! empty( $args['hide_empty'] ) ) { |
|
1130 | + if ($context['value'] === '' && !empty($args['hide_empty'])) { |
|
1131 | 1131 | return ''; |
1132 | 1132 | } |
1133 | 1133 | |
1134 | - if ( $context['value'] !== '' && ! empty( $args['wpautop'] ) ) { |
|
1135 | - $context['value'] = wpautop( $context['value'] ); |
|
1134 | + if ($context['value'] !== '' && !empty($args['wpautop'])) { |
|
1135 | + $context['value'] = wpautop($context['value']); |
|
1136 | 1136 | } |
1137 | 1137 | |
1138 | 1138 | // Get width setting, if exists |
1139 | - $context['width'] = GravityView_API::field_width( $args['field'] ); |
|
1139 | + $context['width'] = GravityView_API::field_width($args['field']); |
|
1140 | 1140 | |
1141 | 1141 | // If replacing with CSS inline formatting, let's do it. |
1142 | - $context['width:style'] = GravityView_API::field_width( $args['field'], 'width:' . $context['width'] . '%;' ); |
|
1142 | + $context['width:style'] = GravityView_API::field_width($args['field'], 'width:'.$context['width'].'%;'); |
|
1143 | 1143 | |
1144 | 1144 | // Grab the Class using `gv_class` |
1145 | - $context['class'] = gv_class( $args['field'], $args['form'], $entry ); |
|
1146 | - $context['field_id'] = GravityView_API::field_html_attr_id( $args['field'], $args['form'], $entry ); |
|
1145 | + $context['class'] = gv_class($args['field'], $args['form'], $entry); |
|
1146 | + $context['field_id'] = GravityView_API::field_html_attr_id($args['field'], $args['form'], $entry); |
|
1147 | 1147 | |
1148 | 1148 | // Get field label if needed |
1149 | - if ( ! empty( $args['label_markup'] ) ) { |
|
1150 | - $context['label'] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup'] ); |
|
1149 | + if (!empty($args['label_markup'])) { |
|
1150 | + $context['label'] = str_replace(array('{{label}}', '{{ label }}'), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup']); |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | // Default Label value |
1154 | - $context['label_value'] = gv_label( $args['field'], $entry ); |
|
1154 | + $context['label_value'] = gv_label($args['field'], $entry); |
|
1155 | 1155 | |
1156 | - if ( empty( $context['label'] ) && ! empty( $context['label_value'] ) ){ |
|
1156 | + if (empty($context['label']) && !empty($context['label_value'])) { |
|
1157 | 1157 | $context['label'] = '<span class="gv-field-label">{{ label_value }}</span>'; |
1158 | 1158 | } |
1159 | 1159 | |
@@ -1163,37 +1163,37 @@ discard block |
||
1163 | 1163 | * @param string $markup The HTML for the markup |
1164 | 1164 | * @param array $args All args for the field output |
1165 | 1165 | */ |
1166 | - $html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args ); |
|
1166 | + $html = apply_filters('gravityview/field_output/pre_html', $args['markup'], $args); |
|
1167 | 1167 | |
1168 | 1168 | /** |
1169 | 1169 | * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders |
1170 | 1170 | * @since 1.11 |
1171 | 1171 | * @param string $open_tag Open tag for template content placeholders. Default: `{{` |
1172 | 1172 | */ |
1173 | - $open_tag = apply_filters( 'gravityview/field_output/open_tag', '{{', $args ); |
|
1173 | + $open_tag = apply_filters('gravityview/field_output/open_tag', '{{', $args); |
|
1174 | 1174 | |
1175 | 1175 | /** |
1176 | 1176 | * @filter `gravityview/field_output/close_tag` Modify the closing tags for the template content placeholders |
1177 | 1177 | * @since 1.11 |
1178 | 1178 | * @param string $close_tag Close tag for template content placeholders. Default: `}}` |
1179 | 1179 | */ |
1180 | - $close_tag = apply_filters( 'gravityview/field_output/close_tag', '}}', $args ); |
|
1180 | + $close_tag = apply_filters('gravityview/field_output/close_tag', '}}', $args); |
|
1181 | 1181 | |
1182 | 1182 | /** |
1183 | 1183 | * Loop through each of the tags to replace and replace both `{{tag}}` and `{{ tag }}` with the values |
1184 | 1184 | * @since 1.11 |
1185 | 1185 | */ |
1186 | - foreach ( $context as $tag => $value ) { |
|
1186 | + foreach ($context as $tag => $value) { |
|
1187 | 1187 | |
1188 | 1188 | // If the tag doesn't exist just skip it |
1189 | - if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){ |
|
1189 | + if (false === strpos($html, $open_tag.$tag.$close_tag) && false === strpos($html, $open_tag.' '.$tag.' '.$close_tag)) { |
|
1190 | 1190 | continue; |
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | // Array to search |
1194 | 1194 | $search = array( |
1195 | - $open_tag . $tag . $close_tag, |
|
1196 | - $open_tag . ' ' . $tag . ' ' . $close_tag, |
|
1195 | + $open_tag.$tag.$close_tag, |
|
1196 | + $open_tag.' '.$tag.' '.$close_tag, |
|
1197 | 1197 | ); |
1198 | 1198 | |
1199 | 1199 | /** |
@@ -1202,26 +1202,26 @@ discard block |
||
1202 | 1202 | * @param string $value The content to be shown instead of the {{tag}} placeholder |
1203 | 1203 | * @param array $args Arguments passed to the function |
1204 | 1204 | */ |
1205 | - $value = apply_filters( 'gravityview/field_output/context/' . $tag, $value, $args ); |
|
1205 | + $value = apply_filters('gravityview/field_output/context/'.$tag, $value, $args); |
|
1206 | 1206 | |
1207 | 1207 | // Finally do the replace |
1208 | - $html = str_replace( $search, $value, $html ); |
|
1208 | + $html = str_replace($search, $value, $html); |
|
1209 | 1209 | } |
1210 | 1210 | |
1211 | 1211 | /** |
1212 | 1212 | * @todo Depricate `gravityview_field_output` |
1213 | 1213 | */ |
1214 | - $html = apply_filters( 'gravityview_field_output', $html, $args ); |
|
1214 | + $html = apply_filters('gravityview_field_output', $html, $args); |
|
1215 | 1215 | |
1216 | 1216 | /** |
1217 | 1217 | * @filter `gravityview/field_output/html` Modify field HTML output |
1218 | 1218 | * @param string $html Existing HTML output |
1219 | 1219 | * @param array $args Arguments passed to the function |
1220 | 1220 | */ |
1221 | - $html = apply_filters( 'gravityview/field_output/html', $html, $args ); |
|
1221 | + $html = apply_filters('gravityview/field_output/html', $html, $args); |
|
1222 | 1222 | |
1223 | 1223 | // Just free up a tiny amount of memory |
1224 | - unset( $value, $args, $passed_args, $entry, $context, $search, $open_tag, $tag, $close_tag ); |
|
1224 | + unset($value, $args, $passed_args, $entry, $context, $search, $open_tag, $tag, $close_tag); |
|
1225 | 1225 | |
1226 | 1226 | return $html; |
1227 | 1227 | } |
@@ -1239,18 +1239,18 @@ discard block |
||
1239 | 1239 | * |
1240 | 1240 | * @return string html attribute or empty string |
1241 | 1241 | */ |
1242 | -function gv_selected( $value, $current, $echo = true, $type = 'selected' ) { |
|
1242 | +function gv_selected($value, $current, $echo = true, $type = 'selected') { |
|
1243 | 1243 | |
1244 | 1244 | $output = ''; |
1245 | - if( is_array( $current ) ) { |
|
1246 | - if( in_array( $value, $current ) ) { |
|
1247 | - $output = __checked_selected_helper( true, true, false, $type ); |
|
1245 | + if (is_array($current)) { |
|
1246 | + if (in_array($value, $current)) { |
|
1247 | + $output = __checked_selected_helper(true, true, false, $type); |
|
1248 | 1248 | } |
1249 | 1249 | } else { |
1250 | - $output = __checked_selected_helper( $value, $current, false, $type ); |
|
1250 | + $output = __checked_selected_helper($value, $current, false, $type); |
|
1251 | 1251 | } |
1252 | 1252 | |
1253 | - if( $echo ) { |
|
1253 | + if ($echo) { |
|
1254 | 1254 | echo $output; |
1255 | 1255 | } |
1256 | 1256 |