@@ -11,35 +11,35 @@ discard block |
||
11 | 11 | |
12 | 12 | function __construct() { |
13 | 13 | |
14 | - $this->widget_description = __('Links to multiple pages of results.', 'gravityview' ); |
|
14 | + $this->widget_description = __( 'Links to multiple pages of results.', 'gravityview' ); |
|
15 | 15 | |
16 | 16 | $default_values = array( 'header' => 1, 'footer' => 1 ); |
17 | 17 | $settings = array( 'show_all' => array( |
18 | 18 | 'type' => 'checkbox', |
19 | 19 | 'label' => __( 'Show each page number', 'gravityview' ), |
20 | - 'desc' => __('Show every page number instead of summary (eg: 1 2 3 ... 8 »)', 'gravityview'), |
|
20 | + 'desc' => __( 'Show every page number instead of summary (eg: 1 2 3 ... 8 »)', 'gravityview' ), |
|
21 | 21 | 'value' => false |
22 | - )); |
|
23 | - parent::__construct( __( 'Page Links', 'gravityview' ) , 'page_links', $default_values, $settings ); |
|
22 | + ) ); |
|
23 | + parent::__construct( __( 'Page Links', 'gravityview' ), 'page_links', $default_values, $settings ); |
|
24 | 24 | |
25 | 25 | } |
26 | 26 | |
27 | - public function render_frontend( $widget_args, $content = '', $context = '') { |
|
27 | + public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
28 | 28 | $gravityview_view = GravityView_View::getInstance(); |
29 | 29 | |
30 | - if( !$this->pre_render_frontend() ) { |
|
30 | + if ( ! $this->pre_render_frontend() ) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | |
34 | 34 | $atts = shortcode_atts( array( |
35 | 35 | 'page_size' => rgar( $gravityview_view->paging, 'page_size' ), |
36 | 36 | 'total' => $gravityview_view->total_entries, |
37 | - 'show_all' => !empty( $this->settings['show_all']['default'] ), |
|
38 | - 'current' => (int) rgar( $_GET, 'pagenum', 1 ), |
|
37 | + 'show_all' => ! empty( $this->settings[ 'show_all' ][ 'default' ] ), |
|
38 | + 'current' => (int)rgar( $_GET, 'pagenum', 1 ), |
|
39 | 39 | ), $widget_args, 'gravityview_widget_page_links' ); |
40 | 40 | |
41 | 41 | $page_link_args = array( |
42 | - 'base' => add_query_arg('pagenum','%#%', gv_directory_link() ), |
|
42 | + 'base' => add_query_arg( 'pagenum', '%#%', gv_directory_link() ), |
|
43 | 43 | 'format' => '&pagenum=%#%', |
44 | 44 | 'add_args' => array(), // |
45 | 45 | 'prev_text' => '«', |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | 'type' => 'list', |
48 | 48 | 'end_size' => 1, |
49 | 49 | 'mid_size' => 2, |
50 | - 'total' => empty( $atts['page_size'] ) ? 0 : ceil( $atts['total'] / $atts['page_size'] ), |
|
51 | - 'current' => $atts['current'], |
|
52 | - 'show_all' => !empty( $atts['show_all'] ), // to be available at backoffice |
|
50 | + 'total' => empty( $atts[ 'page_size' ] ) ? 0 : ceil( $atts[ 'total' ] / $atts[ 'page_size' ] ), |
|
51 | + 'current' => $atts[ 'current' ], |
|
52 | + 'show_all' => ! empty( $atts[ 'show_all' ] ), // to be available at backoffice |
|
53 | 53 | ); |
54 | 54 | |
55 | 55 | /** |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | * @since 1.1.4 |
58 | 58 | * @param array $page_link_args Array of arguments for the `paginate_links()` function. [Read more about `paginate_links()`](http://developer.wordpress.org/reference/functions/paginate_links/) |
59 | 59 | */ |
60 | - $page_link_args = apply_filters('gravityview_page_links_args', $page_link_args ); |
|
60 | + $page_link_args = apply_filters( 'gravityview_page_links_args', $page_link_args ); |
|
61 | 61 | |
62 | 62 | $page_links = paginate_links( $page_link_args ); |
63 | 63 | |
64 | - if( !empty( $page_links )) { |
|
65 | - $class = !empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
64 | + if ( ! empty( $page_links ) ) { |
|
65 | + $class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
66 | 66 | $class = gravityview_sanitize_html_class( 'gv-widget-page-links ' . $class ); |
67 | - echo '<div class="'.$class.'">'. $page_links .'</div>'; |
|
67 | + echo '<div class="' . $class . '">' . $page_links . '</div>'; |
|
68 | 68 | } else { |
69 | 69 | do_action( 'gravityview_log_debug', 'GravityView_Widget_Page_Links[render_frontend] No page links; paginate_links() returned empty response.' ); |
70 | 70 | } |
@@ -102,7 +102,7 @@ |
||
102 | 102 | $field_data = array( |
103 | 103 | 'label' => rgar( $edit_field, 'custom_label' ), |
104 | 104 | 'customLabel' => rgar( $edit_field, 'custom_label' ), |
105 | - 'content' => rgar( $edit_field, 'content' ), |
|
105 | + 'content' => rgar( $edit_field, 'content' ), |
|
106 | 106 | ); |
107 | 107 | |
108 | 108 | // Replace merge tags in the content |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
42 | 42 | |
43 | - unset ( $field_options['search_filter'], $field_options['show_as_link'] ); |
|
43 | + unset ( $field_options[ 'search_filter' ], $field_options[ 'show_as_link' ] ); |
|
44 | 44 | |
45 | 45 | $new_fields = array( |
46 | 46 | 'content' => array( |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | ), |
61 | 61 | ); |
62 | 62 | |
63 | - if( 'edit' === $context ) { |
|
64 | - unset( $field_options['custom_label'], $field_options['show_label'], $field_options['allow_edit_cap'], $new_fields['wpautop'] ); |
|
63 | + if ( 'edit' === $context ) { |
|
64 | + unset( $field_options[ 'custom_label' ], $field_options[ 'show_label' ], $field_options[ 'allow_edit_cap' ], $new_fields[ 'wpautop' ] ); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | return $new_fields + $field_options; |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | |
96 | 96 | // Loop through the configured Edit Entry fields and add Custom Content fields if there are any |
97 | 97 | // TODO: Make this available to other custom GV field types |
98 | - foreach ( (array) $edit_fields as $edit_field ) { |
|
98 | + foreach ( (array)$edit_fields as $edit_field ) { |
|
99 | 99 | |
100 | - if( 'custom' === rgar( $edit_field, 'id') ) { |
|
100 | + if ( 'custom' === rgar( $edit_field, 'id' ) ) { |
|
101 | 101 | |
102 | 102 | $field_data = array( |
103 | 103 | 'label' => rgar( $edit_field, 'custom_label' ), |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | $field_data[ $key ] = GravityView_Merge_Tags::replace_variables( $field_datum, $form, $entry, false, false ); |
111 | 111 | } |
112 | 112 | |
113 | - $field_data['cssClass'] = rgar( $edit_field, 'custom_class' ); |
|
113 | + $field_data[ 'cssClass' ] = rgar( $edit_field, 'custom_class' ); |
|
114 | 114 | |
115 | - $new_fields[] = new GF_Field_HTML( $field_data ); |
|
115 | + $new_fields[ ] = new GF_Field_HTML( $field_data ); |
|
116 | 116 | |
117 | 117 | } else { |
118 | - if( isset( $fields[ $i ] ) ) { |
|
119 | - $new_fields[] = $fields[ $i ]; |
|
118 | + if ( isset( $fields[ $i ] ) ) { |
|
119 | + $new_fields[ ] = $fields[ $i ]; |
|
120 | 120 | } |
121 | 121 | $i++; |
122 | 122 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * Return array of fields' id and label, for a given Form ID |
218 | 218 | * |
219 | 219 | * @access public |
220 | - * @param string|array $form_id (default: '') or $form object |
|
220 | + * @param string|array $form (default: '') or $form object |
|
221 | 221 | * @param bool $add_default_properties |
222 | 222 | * @param bool $include_parent_field |
223 | 223 | * @return array |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | * |
883 | 883 | * @param array $form Gravity Forms form array |
884 | 884 | * @param string $field_id ID of the field. If an input, full input ID (like `1.3`) |
885 | - * @param string|array $field_value Raw value of the field. |
|
885 | + * @param string $field_value Raw value of the field. |
|
886 | 886 | * @return string |
887 | 887 | */ |
888 | 888 | public static function get_field_label( $form = array(), $field_id = '', $field_value = '' ) { |
@@ -1514,6 +1514,7 @@ discard block |
||
1514 | 1514 | * @param string $notice text/HTML of notice |
1515 | 1515 | * @param string $class CSS class for notice (`updated` or `error`) |
1516 | 1516 | * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
1517 | + * @param integer $object_id |
|
1517 | 1518 | * |
1518 | 1519 | * @return string |
1519 | 1520 | */ |
@@ -1557,9 +1558,9 @@ discard block |
||
1557 | 1558 | * @param string $message Message body (required) |
1558 | 1559 | * @param string $from_name Displayed name of the sender |
1559 | 1560 | * @param string $message_format If "html", sent text as `text/html`. Otherwise, `text/plain`. Default: "html". |
1560 | - * @param string|array $attachments Optional. Files to attach. {@see wp_mail()} for usage. Default: "". |
|
1561 | + * @param string $attachments Optional. Files to attach. {@see wp_mail()} for usage. Default: "". |
|
1561 | 1562 | * @param array|false $entry Gravity Forms entry array, related to the email. Default: false. |
1562 | - * @param array|false $notification Gravity Forms notification that triggered the email. {@see GFCommon::send_notification}. Default:false. |
|
1563 | + * @param boolean $notification Gravity Forms notification that triggered the email. {@see GFCommon::send_notification}. Default:false. |
|
1563 | 1564 | */ |
1564 | 1565 | public static function send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name = '', $message_format = 'html', $attachments = '', $entry = false, $notification = false ) { |
1565 | 1566 |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
309 | - * @hack |
|
310 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
311 | - */ |
|
309 | + * @hack |
|
310 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
311 | + */ |
|
312 | 312 | if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
313 | - continue; |
|
314 | - } |
|
313 | + continue; |
|
314 | + } |
|
315 | 315 | $fields["{$input['id']}"] = array( |
316 | 316 | 'label' => rgar( $input, 'label' ), |
317 | 317 | 'customLabel' => rgar( $input, 'customLabel' ), |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | } elseif ( 'delete' === GFForms::get( 'action' ) ) { |
489 | 489 | $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
490 | 490 | } elseif( !isset( $criteria['context_view_id'] ) ) { |
491 | - // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
491 | + // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
492 | 492 | $criteria['context_view_id'] = null; |
493 | 493 | } |
494 | 494 | |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | ), |
1252 | 1252 | ); |
1253 | 1253 | |
1254 | - $fields = $date_created + $fields; |
|
1254 | + $fields = $date_created + $fields; |
|
1255 | 1255 | |
1256 | 1256 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1257 | 1257 | |
@@ -1263,13 +1263,13 @@ discard block |
||
1263 | 1263 | } |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - /** |
|
1267 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1268 | - * @since 1.12 |
|
1269 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
1270 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
1271 | - */ |
|
1272 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1266 | + /** |
|
1267 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1268 | + * @since 1.12 |
|
1269 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
1270 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
1271 | + */ |
|
1272 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1273 | 1273 | |
1274 | 1274 | return $fields; |
1275 | 1275 | } |
@@ -1561,26 +1561,26 @@ discard block |
||
1561 | 1561 | } |
1562 | 1562 | |
1563 | 1563 | |
1564 | - /** |
|
1565 | - * Display updated/error notice |
|
1566 | - * |
|
1567 | - * @since 1.19.2 Added $cap and $object_id parameters |
|
1568 | - * |
|
1569 | - * @param string $notice text/HTML of notice |
|
1570 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
1571 | - * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
1572 | - * |
|
1573 | - * @return string |
|
1574 | - */ |
|
1575 | - public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
1576 | - |
|
1577 | - // If $cap is defined, only show notice if user has capability |
|
1578 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1579 | - return ''; |
|
1580 | - } |
|
1581 | - |
|
1582 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1583 | - } |
|
1564 | + /** |
|
1565 | + * Display updated/error notice |
|
1566 | + * |
|
1567 | + * @since 1.19.2 Added $cap and $object_id parameters |
|
1568 | + * |
|
1569 | + * @param string $notice text/HTML of notice |
|
1570 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
1571 | + * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
1572 | + * |
|
1573 | + * @return string |
|
1574 | + */ |
|
1575 | + public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
1576 | + |
|
1577 | + // If $cap is defined, only show notice if user has capability |
|
1578 | + if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1579 | + return ''; |
|
1580 | + } |
|
1581 | + |
|
1582 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1583 | + } |
|
1584 | 1584 | |
1585 | 1585 | /** |
1586 | 1586 | * Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | } |
325 | 325 | |
326 | 326 | |
327 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
327 | + if( GFCommon::is_product_field( $field['type'] ) ) { |
|
328 | 328 | $has_product_fields = true; |
329 | 329 | } |
330 | 330 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | |
385 | 385 | $fields = array(); |
386 | 386 | |
387 | - foreach ( $extra_fields as $key => $field ){ |
|
387 | + foreach ( $extra_fields as $key => $field ) { |
|
388 | 388 | if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
389 | 389 | $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
390 | 390 | } |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | $form = GFAPI::get_form( $form ); |
979 | 979 | } |
980 | 980 | |
981 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
981 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
982 | 982 | return GFFormsModel::get_field( $form, $field_id ); |
983 | 983 | } else { |
984 | 984 | return null; |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | $shortcodes = array(); |
1026 | 1026 | |
1027 | 1027 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
1028 | - if ( empty( $matches ) ){ |
|
1028 | + if ( empty( $matches ) ) { |
|
1029 | 1029 | return false; |
1030 | 1030 | } |
1031 | 1031 |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | |
127 | 127 | $form = false; |
128 | 128 | |
129 | - if( $entry ) { |
|
130 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
129 | + if ( $entry ) { |
|
130 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | return $form; |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | |
194 | 194 | $has_transaction_data = rgar( $entry, $meta, false ); |
195 | 195 | |
196 | - if( ! empty( $has_transaction_data ) ) { |
|
196 | + if ( ! empty( $has_transaction_data ) ) { |
|
197 | 197 | break; |
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
201 | - return (bool) $has_transaction_data; |
|
201 | + return (bool)$has_transaction_data; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
238 | 238 | |
239 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
239 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
240 | 240 | |
241 | 241 | return $result; |
242 | 242 | } |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
255 | 255 | */ |
256 | - public static function get_forms( $active = true, $trash = false ) { |
|
256 | + public static function get_forms( $active = true, $trash = false ) { |
|
257 | 257 | $forms = array(); |
258 | 258 | if ( class_exists( 'GFAPI' ) ) { |
259 | - if( 'any' === $active ) { |
|
259 | + if ( 'any' === $active ) { |
|
260 | 260 | $active_forms = GFAPI::get_forms( true, $trash ); |
261 | 261 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
262 | 262 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | $has_post_fields = false; |
288 | 288 | |
289 | 289 | if ( $form ) { |
290 | - foreach ( $form['fields'] as $field ) { |
|
291 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
292 | - $fields["{$field['id']}"] = array( |
|
290 | + foreach ( $form[ 'fields' ] as $field ) { |
|
291 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
292 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
293 | 293 | 'label' => rgar( $field, 'label' ), |
294 | 294 | 'parent' => null, |
295 | 295 | 'type' => rgar( $field, 'type' ), |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | ); |
299 | 299 | } |
300 | 300 | |
301 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
302 | - foreach ( $field['inputs'] as $input ) { |
|
301 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
302 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
303 | 303 | |
304 | - if( ! empty( $input['isHidden'] ) ) { |
|
304 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
305 | 305 | continue; |
306 | 306 | } |
307 | 307 | |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | * @hack |
310 | 310 | * In case of email/email confirmation, the input for email has the same id as the parent field |
311 | 311 | */ |
312 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
312 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
313 | 313 | continue; |
314 | 314 | } |
315 | - $fields["{$input['id']}"] = array( |
|
315 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
316 | 316 | 'label' => rgar( $input, 'label' ), |
317 | 317 | 'customLabel' => rgar( $input, 'customLabel' ), |
318 | 318 | 'parent' => $field, |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | } |
325 | 325 | |
326 | 326 | |
327 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
327 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
328 | 328 | $has_product_fields = true; |
329 | 329 | } |
330 | 330 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @since 1.7 |
339 | 339 | */ |
340 | 340 | if ( $has_post_fields ) { |
341 | - $fields['post_id'] = array( |
|
341 | + $fields[ 'post_id' ] = array( |
|
342 | 342 | 'label' => __( 'Post ID', 'gravityview' ), |
343 | 343 | 'type' => 'post_id', |
344 | 344 | ); |
@@ -351,11 +351,11 @@ discard block |
||
351 | 351 | foreach ( $payment_fields as $payment_field ) { |
352 | 352 | |
353 | 353 | // Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key |
354 | - if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
354 | + if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
355 | 355 | continue; |
356 | 356 | } |
357 | 357 | |
358 | - $fields["{$payment_field->name}"] = array( |
|
358 | + $fields[ "{$payment_field->name}" ] = array( |
|
359 | 359 | 'label' => $payment_field->label, |
360 | 360 | 'desc' => $payment_field->description, |
361 | 361 | 'type' => $payment_field->name, |
@@ -387,9 +387,9 @@ discard block |
||
387 | 387 | |
388 | 388 | $fields = array(); |
389 | 389 | |
390 | - foreach ( $extra_fields as $key => $field ){ |
|
391 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
392 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
390 | + foreach ( $extra_fields as $key => $field ) { |
|
391 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
392 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
@@ -429,32 +429,32 @@ discard block |
||
429 | 429 | 'search_criteria' => null, |
430 | 430 | 'sorting' => null, |
431 | 431 | 'paging' => null, |
432 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
432 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
433 | 433 | ); |
434 | 434 | |
435 | 435 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
436 | 436 | |
437 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
438 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
437 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
438 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
439 | 439 | |
440 | 440 | if ( ! is_array( $filter ) ) { |
441 | 441 | continue; |
442 | 442 | } |
443 | 443 | |
444 | 444 | // By default, we want searches to be wildcard for each field. |
445 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
445 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
446 | 446 | |
447 | 447 | /** |
448 | 448 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
449 | 449 | * @param string $operator Existing search operator |
450 | 450 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
451 | 451 | */ |
452 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
452 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | // don't send just the [mode] without any field filter. |
456 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
457 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
456 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
457 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | } |
@@ -465,21 +465,21 @@ discard block |
||
465 | 465 | * Prepare date formats to be in Gravity Forms DB format; |
466 | 466 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
467 | 467 | */ |
468 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
468 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
469 | 469 | |
470 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
470 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
471 | 471 | |
472 | 472 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
473 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
473 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
474 | 474 | |
475 | 475 | if ( $date ) { |
476 | 476 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
477 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
477 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
478 | 478 | } else { |
479 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
479 | + do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] ); |
|
480 | 480 | |
481 | 481 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
482 | - unset( $criteria['search_criteria'][ $key ] ); |
|
482 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | } |
@@ -498,14 +498,14 @@ discard block |
||
498 | 498 | |
499 | 499 | // Calculate the context view id and send it to the advanced filter |
500 | 500 | if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
501 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
501 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
502 | 502 | } elseif ( $multiple_original ) { |
503 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
503 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
504 | 504 | } elseif ( 'delete' === GFForms::get( 'action' ) ) { |
505 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
506 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
505 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
506 | + } elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) { |
|
507 | 507 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
508 | - $criteria['context_view_id'] = null; |
|
508 | + $criteria[ 'context_view_id' ] = null; |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | /** |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | * @param array $form_ids Forms to search |
515 | 515 | * @param int $view_id ID of the view being used to search |
516 | 516 | */ |
517 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
517 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
518 | 518 | |
519 | 519 | return (array)$criteria; |
520 | 520 | } |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | /** Reduce # of database calls */ |
545 | 545 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
546 | 546 | |
547 | - if ( ! empty( $criteria['cache'] ) ) { |
|
547 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
548 | 548 | |
549 | 549 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
550 | 550 | |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | |
553 | 553 | // Still update the total count when using cached results |
554 | 554 | if ( ! is_null( $total ) ) { |
555 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
555 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | $return = $entries; |
@@ -572,9 +572,9 @@ discard block |
||
572 | 572 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
573 | 573 | |
574 | 574 | // No entries returned from gravityview_before_get_entries |
575 | - if( is_null( $entries ) ) { |
|
575 | + if ( is_null( $entries ) ) { |
|
576 | 576 | |
577 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
577 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
578 | 578 | |
579 | 579 | if ( is_wp_error( $entries ) ) { |
580 | 580 | do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | } |
584 | 584 | } |
585 | 585 | |
586 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
586 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
587 | 587 | |
588 | 588 | // Cache results |
589 | 589 | $Cache->set( $entries, 'entries' ); |
@@ -688,12 +688,12 @@ discard block |
||
688 | 688 | */ |
689 | 689 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
690 | 690 | |
691 | - if( $check_entry_display ) { |
|
691 | + if ( $check_entry_display ) { |
|
692 | 692 | // Is the entry allowed |
693 | 693 | $entry = self::check_entry_display( $entry ); |
694 | 694 | } |
695 | 695 | |
696 | - if( is_wp_error( $entry ) ) { |
|
696 | + if ( is_wp_error( $entry ) ) { |
|
697 | 697 | do_action( 'gravityview_log_error', __METHOD__ . ': ' . $entry->get_error_message() ); |
698 | 698 | return false; |
699 | 699 | } |
@@ -725,12 +725,12 @@ discard block |
||
725 | 725 | |
726 | 726 | $value = false; |
727 | 727 | |
728 | - if( 'context' === $val1 ) { |
|
728 | + if ( 'context' === $val1 ) { |
|
729 | 729 | |
730 | 730 | $matching_contexts = array( $val2 ); |
731 | 731 | |
732 | 732 | // We allow for non-standard contexts. |
733 | - switch( $val2 ) { |
|
733 | + switch ( $val2 ) { |
|
734 | 734 | // Check for either single or edit |
735 | 735 | case 'singular': |
736 | 736 | $matching_contexts = array( 'single', 'edit' ); |
@@ -786,73 +786,73 @@ discard block |
||
786 | 786 | public static function check_entry_display( $entry ) { |
787 | 787 | |
788 | 788 | if ( ! $entry || is_wp_error( $entry ) ) { |
789 | - return new WP_Error('entry_not_found', 'Entry was not found.', $entry ); |
|
789 | + return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry ); |
|
790 | 790 | } |
791 | 791 | |
792 | - if ( empty( $entry['form_id'] ) ) { |
|
792 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
793 | 793 | return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry ); |
794 | 794 | } |
795 | 795 | |
796 | 796 | $criteria = self::calculate_get_entries_criteria(); |
797 | 797 | |
798 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
798 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
799 | 799 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
800 | 800 | return $entry; |
801 | 801 | } |
802 | 802 | |
803 | 803 | // Make sure the current View is connected to the same form as the Entry |
804 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
805 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
804 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
805 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
806 | 806 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
807 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
808 | - return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
807 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
808 | + return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
809 | 809 | } |
810 | 810 | } |
811 | 811 | |
812 | - $search_criteria = $criteria['search_criteria']; |
|
812 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
813 | 813 | |
814 | 814 | // check entry status |
815 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
816 | - return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
815 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
816 | + return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | // check entry date |
820 | 820 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
821 | 821 | |
822 | 822 | // field_filters |
823 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
823 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
824 | 824 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
825 | 825 | return $entry; |
826 | 826 | } |
827 | 827 | |
828 | - $filters = $search_criteria['field_filters']; |
|
828 | + $filters = $search_criteria[ 'field_filters' ]; |
|
829 | 829 | |
830 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
830 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
831 | 831 | |
832 | - $form = self::get_form( $entry['form_id'] ); |
|
832 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
833 | 833 | |
834 | 834 | foreach ( $filters as $filter ) { |
835 | 835 | |
836 | - if ( ! isset( $filter['key'] ) ) { |
|
836 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
837 | 837 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Filter key not set', $filter ); |
838 | 838 | continue; |
839 | 839 | } |
840 | 840 | |
841 | - $k = $filter['key']; |
|
841 | + $k = $filter[ 'key' ]; |
|
842 | 842 | |
843 | 843 | $field = self::get_field( $form, $k ); |
844 | 844 | |
845 | 845 | if ( is_null( $field ) ) { |
846 | 846 | $field_value = isset( $entry[ $k ] ) ? $entry[ $k ] : null; |
847 | 847 | } else { |
848 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
848 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
849 | 849 | // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it |
850 | 850 | $field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? rgar( $field_value, $k ) : $field_value; |
851 | 851 | } |
852 | 852 | |
853 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
853 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
854 | 854 | |
855 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
855 | + $is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
856 | 856 | |
857 | 857 | // Any match is all we need to know |
858 | 858 | if ( $is_value_match && 'any' === $mode ) { |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | |
862 | 862 | // Any failed match is a total fail |
863 | 863 | if ( ! $is_value_match && 'all' === $mode ) { |
864 | - return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
864 | + return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
865 | 865 | } |
866 | 866 | } |
867 | 867 | |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved: all conditions were met' ); |
872 | 872 | return $entry; |
873 | 873 | } else { |
874 | - return new WP_Error('failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
874 | + return new WP_Error( 'failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
875 | 875 | } |
876 | 876 | |
877 | 877 | } |
@@ -912,18 +912,18 @@ discard block |
||
912 | 912 | * Gravity Forms code to adjust date to locally-configured Time Zone |
913 | 913 | * @see GFCommon::format_date() for original code |
914 | 914 | */ |
915 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
915 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
916 | 916 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
917 | 917 | |
918 | - $format = rgar( $atts, 'format' ); |
|
919 | - $is_human = ! empty( $atts['human'] ); |
|
920 | - $is_diff = ! empty( $atts['diff'] ); |
|
921 | - $is_raw = ! empty( $atts['raw'] ); |
|
922 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
923 | - $include_time = ! empty( $atts['time'] ); |
|
918 | + $format = rgar( $atts, 'format' ); |
|
919 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
920 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
921 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
922 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
923 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
924 | 924 | |
925 | 925 | // If we're using time diff, we want to have a different default format |
926 | - if( empty( $format ) ) { |
|
926 | + if ( empty( $format ) ) { |
|
927 | 927 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
928 | 928 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
929 | 929 | } |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | // If raw was specified, don't modify the stored value |
932 | 932 | if ( $is_raw ) { |
933 | 933 | $formatted_date = $date_string; |
934 | - } elseif( $is_timestamp ) { |
|
934 | + } elseif ( $is_timestamp ) { |
|
935 | 935 | $formatted_date = $date_local_timestamp; |
936 | 936 | } elseif ( $is_diff ) { |
937 | 937 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | |
966 | 966 | $label = rgar( $field, 'label' ); |
967 | 967 | |
968 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
968 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
969 | 969 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
970 | 970 | } |
971 | 971 | |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | $form = GFAPI::get_form( $form ); |
994 | 994 | } |
995 | 995 | |
996 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
996 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
997 | 997 | return GFFormsModel::get_field( $form, $field_id ); |
998 | 998 | } else { |
999 | 999 | return null; |
@@ -1040,19 +1040,19 @@ discard block |
||
1040 | 1040 | $shortcodes = array(); |
1041 | 1041 | |
1042 | 1042 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
1043 | - if ( empty( $matches ) ){ |
|
1043 | + if ( empty( $matches ) ) { |
|
1044 | 1044 | return false; |
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | foreach ( $matches as $shortcode ) { |
1048 | - if ( $tag === $shortcode[2] ) { |
|
1048 | + if ( $tag === $shortcode[ 2 ] ) { |
|
1049 | 1049 | |
1050 | 1050 | // Changed this to $shortcode instead of true so we get the parsed atts. |
1051 | - $shortcodes[] = $shortcode; |
|
1051 | + $shortcodes[ ] = $shortcode; |
|
1052 | 1052 | |
1053 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
1054 | - foreach( $results as $result ) { |
|
1055 | - $shortcodes[] = $result; |
|
1053 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
1054 | + foreach ( $results as $result ) { |
|
1055 | + $shortcodes[ ] = $result; |
|
1056 | 1056 | } |
1057 | 1057 | } |
1058 | 1058 | } |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | public static function get_directory_fields( $post_id, $apply_filter = true ) { |
1197 | 1197 | $fields = get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
1198 | 1198 | |
1199 | - if( $apply_filter ) { |
|
1199 | + if ( $apply_filter ) { |
|
1200 | 1200 | /** |
1201 | 1201 | * @filter `gravityview/configuration/fields` Filter the View fields' configuration array |
1202 | 1202 | * @since 1.6.5 |
@@ -1219,7 +1219,7 @@ discard block |
||
1219 | 1219 | * @return string html |
1220 | 1220 | */ |
1221 | 1221 | public static function get_sortable_fields( $formid, $current = '' ) { |
1222 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1222 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
1223 | 1223 | |
1224 | 1224 | if ( empty( $formid ) ) { |
1225 | 1225 | return $output; |
@@ -1232,11 +1232,11 @@ discard block |
||
1232 | 1232 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
1233 | 1233 | |
1234 | 1234 | foreach ( $fields as $id => $field ) { |
1235 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1235 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1236 | 1236 | continue; |
1237 | 1237 | } |
1238 | 1238 | |
1239 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1239 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
1240 | 1240 | } |
1241 | 1241 | } |
1242 | 1242 | |
@@ -1271,9 +1271,9 @@ discard block |
||
1271 | 1271 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1272 | 1272 | |
1273 | 1273 | // TODO: Convert to using array_filter |
1274 | - foreach( $fields as $id => $field ) { |
|
1274 | + foreach ( $fields as $id => $field ) { |
|
1275 | 1275 | |
1276 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1276 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1277 | 1277 | unset( $fields[ $id ] ); |
1278 | 1278 | } |
1279 | 1279 | } |
@@ -1314,14 +1314,14 @@ discard block |
||
1314 | 1314 | * @param int|array $field field key or field array |
1315 | 1315 | * @return boolean |
1316 | 1316 | */ |
1317 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1317 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
1318 | 1318 | |
1319 | 1319 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
1320 | 1320 | $form = self::get_form( $form ); |
1321 | 1321 | } |
1322 | 1322 | |
1323 | 1323 | // If entry meta, it's a string. Otherwise, numeric |
1324 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1324 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1325 | 1325 | $type = $field; |
1326 | 1326 | } else { |
1327 | 1327 | $type = self::get_field_type( $form, $field ); |
@@ -1335,9 +1335,9 @@ discard block |
||
1335 | 1335 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
1336 | 1336 | |
1337 | 1337 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1338 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1339 | - if( true === $gv_field->is_numeric ) { |
|
1340 | - $numeric_types[] = $gv_field->is_numeric; |
|
1338 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1339 | + if ( true === $gv_field->is_numeric ) { |
|
1340 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
1341 | 1341 | } |
1342 | 1342 | } |
1343 | 1343 | |
@@ -1487,18 +1487,18 @@ discard block |
||
1487 | 1487 | $final_atts = array_filter( $final_atts ); |
1488 | 1488 | |
1489 | 1489 | // If the href wasn't passed as an attribute, use the value passed to the function |
1490 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1491 | - $final_atts['href'] = $href; |
|
1490 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
1491 | + $final_atts[ 'href' ] = $href; |
|
1492 | 1492 | } |
1493 | 1493 | |
1494 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1494 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
1495 | 1495 | |
1496 | 1496 | /** |
1497 | 1497 | * Fix potential security issue with target=_blank |
1498 | 1498 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
1499 | 1499 | */ |
1500 | - if( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
1501 | - $final_atts['rel'] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1500 | + if ( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
1501 | + $final_atts[ 'rel' ] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1502 | 1502 | } |
1503 | 1503 | |
1504 | 1504 | // Sort the attributes alphabetically, to help testing |
@@ -1510,7 +1510,7 @@ discard block |
||
1510 | 1510 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
1511 | 1511 | } |
1512 | 1512 | |
1513 | - if( '' !== $output ) { |
|
1513 | + if ( '' !== $output ) { |
|
1514 | 1514 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
1515 | 1515 | } |
1516 | 1516 | |
@@ -1537,7 +1537,7 @@ discard block |
||
1537 | 1537 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
1538 | 1538 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
1539 | 1539 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
1540 | - $merged[] = $value; |
|
1540 | + $merged[ ] = $value; |
|
1541 | 1541 | } else { |
1542 | 1542 | $merged[ $key ] = $value; |
1543 | 1543 | } |
@@ -1570,7 +1570,7 @@ discard block |
||
1570 | 1570 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1571 | 1571 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1572 | 1572 | */ |
1573 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1573 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1574 | 1574 | |
1575 | 1575 | return get_users( $get_users_settings ); |
1576 | 1576 | } |
@@ -1590,11 +1590,11 @@ discard block |
||
1590 | 1590 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
1591 | 1591 | |
1592 | 1592 | // If $cap is defined, only show notice if user has capability |
1593 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1593 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1594 | 1594 | return ''; |
1595 | 1595 | } |
1596 | 1596 | |
1597 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1597 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
1598 | 1598 | } |
1599 | 1599 | |
1600 | 1600 | /** |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | $this->label = esc_attr__( 'Approve Entries', 'gravityview' ); |
24 | 24 | |
25 | - $this->description = esc_attr__( 'Approve and reject entries from the View.', 'gravityview' ); |
|
25 | + $this->description = esc_attr__( 'Approve and reject entries from the View.', 'gravityview' ); |
|
26 | 26 | |
27 | 27 | $this->add_hooks(); |
28 | 28 | |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | */ |
45 | 45 | function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
46 | 46 | |
47 | - unset( $field_options['only_loggedin'] ); |
|
47 | + unset( $field_options[ 'only_loggedin' ] ); |
|
48 | 48 | |
49 | - unset( $field_options['new_window'] ); |
|
49 | + unset( $field_options[ 'new_window' ] ); |
|
50 | 50 | |
51 | - unset( $field_options['show_as_link'] ); |
|
51 | + unset( $field_options[ 'show_as_link' ] ); |
|
52 | 52 | |
53 | 53 | return $field_options; |
54 | 54 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | add_action( 'gravityview/field/approval/load_scripts', array( $this, 'enqueue_and_localize_script' ) ); |
70 | 70 | |
71 | - add_action( 'gravityview_datatables_scripts_styles', array( $this, 'enqueue_and_localize_script' ) ); |
|
71 | + add_action( 'gravityview_datatables_scripts_styles', array( $this, 'enqueue_and_localize_script' ) ); |
|
72 | 72 | |
73 | 73 | add_filter( 'gravityview_get_entries', array( $this, 'modify_search_parameters' ), 1000 ); |
74 | 74 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | public function maybe_prevent_field_render( $html, $args ) { |
89 | 89 | |
90 | 90 | // If the field is `entry_approval` type but the user doesn't have the moderate entries cap, don't render. |
91 | - if( $this->name === rgar( $args['field'], 'id' ) && ! GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
91 | + if ( $this->name === rgar( $args[ 'field' ], 'id' ) && ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
92 | 92 | return ''; |
93 | 93 | } |
94 | 94 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function modify_search_parameters( $parameters ) { |
106 | 106 | |
107 | - if( $this->name === rgars( $parameters, 'sorting/key' ) ) { |
|
108 | - $parameters['sorting']['key'] = 'is_approved'; |
|
107 | + if ( $this->name === rgars( $parameters, 'sorting/key' ) ) { |
|
108 | + $parameters[ 'sorting' ][ 'key' ] = 'is_approved'; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | return $parameters; |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | function register_scripts_and_styles() { |
122 | 122 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
123 | 123 | |
124 | - wp_register_script( 'gravityview-field-approval', GRAVITYVIEW_URL . 'assets/js/field-approval'.$script_debug.'.js', array( 'jquery' ), GravityView_Plugin::version, true ); |
|
124 | + wp_register_script( 'gravityview-field-approval', GRAVITYVIEW_URL . 'assets/js/field-approval' . $script_debug . '.js', array( 'jquery' ), GravityView_Plugin::version, true ); |
|
125 | 125 | |
126 | 126 | $style_path = GRAVITYVIEW_DIR . 'templates/css/field-approval.css'; |
127 | 127 | |
128 | - if( class_exists( 'GravityView_View' ) ) { |
|
128 | + if ( class_exists( 'GravityView_View' ) ) { |
|
129 | 129 | /** |
130 | 130 | * Override CSS file by placing in your theme's /gravityview/css/ sub-directory. |
131 | 131 | */ |
132 | 132 | $style_path = GravityView_View::getInstance()->locate_template( 'css/field-approval.css', false ); |
133 | 133 | } |
134 | 134 | |
135 | - $style_url = plugins_url( 'css/field-approval.css', trailingslashit( dirname( $style_path ) ) ); |
|
135 | + $style_url = plugins_url( 'css/field-approval.css', trailingslashit( dirname( $style_path ) ) ); |
|
136 | 136 | |
137 | 137 | /** |
138 | 138 | * @filter `gravityview/field/approval/css_url` URL to the Approval field CSS file. |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | $style_url = apply_filters( 'gravityview/field/approval/css_url', $style_url ); |
143 | 143 | |
144 | - if( ! empty( $style_url ) ) { |
|
144 | + if ( ! empty( $style_url ) ) { |
|
145 | 145 | wp_register_style( 'gravityview-field-approval', $style_url, array( 'dashicons' ), GravityView_Plugin::version, 'screen' ); |
146 | 146 | } |
147 | 147 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | public function enqueue_and_localize_script() { |
157 | 157 | |
158 | 158 | // The script is already registered and enqueued |
159 | - if( wp_script_is( 'gravityview-field-approval', 'enqueued' ) ) { |
|
159 | + if ( wp_script_is( 'gravityview-field-approval', 'enqueued' ) ) { |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | |
167 | 167 | wp_localize_script( 'gravityview-field-approval', 'gvApproval', array( |
168 | 168 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
169 | - 'nonce' => wp_create_nonce('gravityview_entry_approval'), |
|
169 | + 'nonce' => wp_create_nonce( 'gravityview_entry_approval' ), |
|
170 | 170 | 'status' => GravityView_Entry_Approval_Status::get_all(), |
171 | - )); |
|
171 | + ) ); |
|
172 | 172 | |
173 | 173 | } |
174 | 174 | |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function filter_gravityview_entry_default_field( $entry_default_fields, $form, $context ) { |
187 | 187 | |
188 | - if ( ! isset( $entry_default_fields["{$this->name}"] ) && 'edit' !== $context ) { |
|
189 | - $entry_default_fields["{$this->name}"] = array( |
|
188 | + if ( ! isset( $entry_default_fields[ "{$this->name}" ] ) && 'edit' !== $context ) { |
|
189 | + $entry_default_fields[ "{$this->name}" ] = array( |
|
190 | 190 | 'label' => $this->label, |
191 | 191 | 'desc' => $this->description, |
192 | 192 | 'type' => $this->name, |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function get_instance() { |
87 | 87 | |
88 | - if( empty( self::$instance ) ) { |
|
88 | + if ( empty( self::$instance ) ) { |
|
89 | 89 | self::$instance = new self; |
90 | 90 | } |
91 | 91 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | |
119 | 119 | $operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS ); |
120 | 120 | |
121 | - if( $with_values ) { |
|
121 | + if ( $with_values ) { |
|
122 | 122 | $operators_with_values = array(); |
123 | - foreach( $operators as $key ) { |
|
123 | + foreach ( $operators as $key ) { |
|
124 | 124 | $operators_with_values[ $key ] = ''; |
125 | 125 | } |
126 | 126 | return $operators_with_values; |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | */ |
138 | 138 | function set_operation( $operation = '' ) { |
139 | 139 | |
140 | - if( empty( $operation ) ) { |
|
140 | + if ( empty( $operation ) ) { |
|
141 | 141 | return false; |
142 | 142 | } |
143 | 143 | |
144 | 144 | $operators = $this->get_operators( false ); |
145 | 145 | |
146 | - if( !in_array( $operation, $operators ) ) { |
|
147 | - do_action( 'gravityview_log_debug', __METHOD__ .' Attempted to add invalid operation type.', $operation ); |
|
146 | + if ( ! in_array( $operation, $operators ) ) { |
|
147 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Attempted to add invalid operation type.', $operation ); |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | */ |
165 | 165 | private function setup_operation_and_comparison() { |
166 | 166 | |
167 | - foreach( $this->atts as $key => $value ) { |
|
167 | + foreach ( $this->atts as $key => $value ) { |
|
168 | 168 | |
169 | 169 | $valid = $this->set_operation( $key ); |
170 | 170 | |
171 | - if( $valid ) { |
|
171 | + if ( $valid ) { |
|
172 | 172 | $this->comparison = $value; |
173 | 173 | return true; |
174 | 174 | } |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | return null; |
192 | 192 | } |
193 | 193 | |
194 | - if( empty( $atts ) ) { |
|
195 | - do_action( 'gravityview_log_error', __METHOD__.' $atts are empty.', $atts ); |
|
194 | + if ( empty( $atts ) ) { |
|
195 | + do_action( 'gravityview_log_error', __METHOD__ . ' $atts are empty.', $atts ); |
|
196 | 196 | return null; |
197 | 197 | } |
198 | 198 | |
@@ -203,16 +203,16 @@ discard block |
||
203 | 203 | $this->parse_atts(); |
204 | 204 | |
205 | 205 | // We need an "if" |
206 | - if( false === $this->if ) { |
|
207 | - do_action( 'gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->passed_atts ); |
|
206 | + if ( false === $this->if ) { |
|
207 | + do_action( 'gravityview_log_error', __METHOD__ . ' $atts->if is empty.', $this->passed_atts ); |
|
208 | 208 | return null; |
209 | 209 | } |
210 | 210 | |
211 | 211 | $setup = $this->setup_operation_and_comparison(); |
212 | 212 | |
213 | 213 | // We need an operation and comparison value |
214 | - if( ! $setup ) { |
|
215 | - do_action( 'gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts ); |
|
214 | + if ( ! $setup ) { |
|
215 | + do_action( 'gravityview_log_error', __METHOD__ . ' No valid operators were passed.', $this->atts ); |
|
216 | 216 | return null; |
217 | 217 | } |
218 | 218 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | private function get_output() { |
247 | 247 | |
248 | - if( $this->is_match ) { |
|
248 | + if ( $this->is_match ) { |
|
249 | 249 | $output = $this->content; |
250 | 250 | } else { |
251 | 251 | $output = $this->else_content; |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | * @param string $output HTML/text output |
260 | 260 | * @param GVLogic_Shortcode $this This class |
261 | 261 | */ |
262 | - $output = apply_filters('gravityview/gvlogic/output', $output, $this ); |
|
262 | + $output = apply_filters( 'gravityview/gvlogic/output', $output, $this ); |
|
263 | 263 | |
264 | - do_action( 'gravityview_log_debug', __METHOD__ .' Output: ', $output ); |
|
264 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Output: ', $output ); |
|
265 | 265 | |
266 | 266 | return $output; |
267 | 267 | } |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | |
278 | 278 | $content = explode( '[else]', $this->passed_content ); |
279 | 279 | |
280 | - $this->content = $content[0]; |
|
280 | + $this->content = $content[ 0 ]; |
|
281 | 281 | |
282 | - $else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL; |
|
282 | + $else_attr = isset( $this->atts[ 'else' ] ) ? $this->atts[ 'else' ] : NULL; |
|
283 | 283 | |
284 | - $this->else_content = isset( $content[1] ) ? $content[1] : $else_attr; |
|
284 | + $this->else_content = isset( $content[ 1 ] ) ? $content[ 1 ] : $else_attr; |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | $this->atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( $this->passed_atts, $this->atts ) : $this->atts; |
305 | 305 | |
306 | 306 | // Strip whitespace if it's not default false |
307 | - $this->if = ( isset( $this->atts['if'] ) && is_string( $this->atts['if'] ) ) ? trim( $this->atts['if'] ) : false; |
|
307 | + $this->if = ( isset( $this->atts[ 'if' ] ) && is_string( $this->atts[ 'if' ] ) ) ? trim( $this->atts[ 'if' ] ) : false; |
|
308 | 308 | |
309 | 309 | // Make sure the "if" isn't processed in self::setup_operation_and_comparison() |
310 | - unset( $this->atts['if'] ); |
|
310 | + unset( $this->atts[ 'if' ] ); |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 |
@@ -232,7 +232,7 @@ |
||
232 | 232 | * Does the if and the comparison match? |
233 | 233 | * @uses GVCommon::matches_operation |
234 | 234 | * |
235 | - * @return boolean True: yep; false: nope |
|
235 | + * @return boolean|null True: yep; false: nope |
|
236 | 236 | */ |
237 | 237 | private function set_is_match() { |
238 | 238 | $this->is_match = GVCommon::matches_operation( $this->if, $this->comparison, $this->operation ); |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | |
59 | 59 | if ( 'address' === rgar( $search_field, 'type' ) ) { |
60 | 60 | |
61 | - $field_id = intval( floor( $search_field['key'] ) ); |
|
62 | - $input_id = gravityview_get_input_id_from_id( $search_field['key'] ); |
|
61 | + $field_id = intval( floor( $search_field[ 'key' ] ) ); |
|
62 | + $input_id = gravityview_get_input_id_from_id( $search_field[ 'key' ] ); |
|
63 | 63 | $form = GravityView_View::getInstance()->getForm(); |
64 | 64 | |
65 | 65 | /** @var GF_Field_Address $address_field */ |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $choices = array(); |
69 | 69 | |
70 | 70 | $method_name = 'get_choices_' . self::get_input_type_from_input_id( $input_id ); |
71 | - if( method_exists( $this, $method_name ) ) { |
|
71 | + if ( method_exists( $this, $method_name ) ) { |
|
72 | 72 | /** |
73 | 73 | * @uses GravityView_Field_Address::get_choices_country() |
74 | 74 | * @uses GravityView_Field_Address::get_choices_state() |
@@ -76,12 +76,12 @@ discard block |
||
76 | 76 | $choices = $this->{$method_name}( $address_field ); |
77 | 77 | } |
78 | 78 | |
79 | - if( ! empty( $choices ) ) { |
|
80 | - $search_field['choices'] = $choices; |
|
81 | - $search_field['type'] = rgar( $search_field, 'input'); |
|
79 | + if ( ! empty( $choices ) ) { |
|
80 | + $search_field[ 'choices' ] = $choices; |
|
81 | + $search_field[ 'type' ] = rgar( $search_field, 'input' ); |
|
82 | 82 | } else { |
83 | - $search_field['type'] = 'text'; |
|
84 | - $search_field['input'] = 'input_text'; |
|
83 | + $search_field[ 'type' ] = 'text'; |
|
84 | + $search_field[ 'input' ] = 'input_text'; |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $country_choices = array(); |
108 | 108 | |
109 | 109 | foreach ( $countries as $key => $country ) { |
110 | - $country_choices[] = array( |
|
110 | + $country_choices[ ] = array( |
|
111 | 111 | 'value' => $country, |
112 | 112 | 'text' => $country, |
113 | 113 | ); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | private function get_choices_state( $address_field ) { |
133 | 133 | |
134 | - $address_type = empty( $address_field->addressType ) ? $address_field->get_default_address_type( $form['id'] ) : $address_field->addressType; |
|
134 | + $address_type = empty( $address_field->addressType ) ? $address_field->get_default_address_type( $form[ 'id' ] ) : $address_field->addressType; |
|
135 | 135 | |
136 | 136 | $state_choices = array(); |
137 | 137 | |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | $states = GFCommon::get_canadian_provinces(); |
144 | 144 | break; |
145 | 145 | default: |
146 | - $states = empty( $address_types[ $address_type ]['states'] ) ? array() : $address_types[ $address_type ]['states']; |
|
146 | + $states = empty( $address_types[ $address_type ][ 'states' ] ) ? array() : $address_types[ $address_type ][ 'states' ]; |
|
147 | 147 | break; |
148 | 148 | } |
149 | 149 | |
150 | 150 | foreach ( $states as $key => $state ) { |
151 | - $state_choices[] = array( |
|
151 | + $state_choices[ ] = array( |
|
152 | 152 | 'value' => $state, |
153 | 153 | 'text' => $state, |
154 | 154 | ); |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | // Use the same inputs as the "text" input type allows |
172 | 172 | $text_inputs = rgar( $input_types, 'text' ); |
173 | 173 | |
174 | - $input_types['street'] = $text_inputs; |
|
175 | - $input_types['street2'] = $text_inputs; |
|
176 | - $input_types['city'] = $text_inputs; |
|
174 | + $input_types[ 'street' ] = $text_inputs; |
|
175 | + $input_types[ 'street2' ] = $text_inputs; |
|
176 | + $input_types[ 'city' ] = $text_inputs; |
|
177 | 177 | |
178 | - $input_types['state'] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
179 | - $input_types['zip'] = array( 'input_text' ); |
|
180 | - $input_types['country'] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
178 | + $input_types[ 'state' ] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
179 | + $input_types[ 'zip' ] = array( 'input_text' ); |
|
180 | + $input_types[ 'country' ] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
181 | 181 | |
182 | 182 | return $input_types; |
183 | 183 | } |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | // Is this search field for an input (eg: 4.2) or the whole address field (eg: 4)? |
199 | 199 | $input_id = gravityview_get_input_id_from_id( $field_id ); |
200 | 200 | |
201 | - if( 'address' === $field_type && $input_id ) { |
|
201 | + if ( 'address' === $field_type && $input_id ) { |
|
202 | 202 | |
203 | 203 | // If the input ID matches an expected address input, set to that. Otherwise, keep existing input type. |
204 | - if( $address_field_name = self::get_input_type_from_input_id( $input_id ) ) { |
|
204 | + if ( $address_field_name = self::get_input_type_from_input_id( $input_id ) ) { |
|
205 | 205 | $input_type = $address_field_name; |
206 | 206 | } |
207 | 207 | } |
@@ -250,20 +250,20 @@ discard block |
||
250 | 250 | function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
251 | 251 | |
252 | 252 | // If this is NOT the full address field, return default options. |
253 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
253 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
254 | 254 | return $field_options; |
255 | 255 | } |
256 | 256 | |
257 | - if( 'edit' === $context ) { |
|
257 | + if ( 'edit' === $context ) { |
|
258 | 258 | return $field_options; |
259 | 259 | } |
260 | 260 | |
261 | 261 | $add_options = array(); |
262 | 262 | |
263 | - $add_options['show_map_link'] = array( |
|
263 | + $add_options[ 'show_map_link' ] = array( |
|
264 | 264 | 'type' => 'checkbox', |
265 | 265 | 'label' => __( 'Show Map Link:', 'gravityview' ), |
266 | - 'desc' => __('Display a "Map It" link below the address', 'gravityview'), |
|
266 | + 'desc' => __( 'Display a "Map It" link below the address', 'gravityview' ), |
|
267 | 267 | 'value' => true, |
268 | 268 | 'merge_tags' => false, |
269 | 269 | ); |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | var $is_numeric = true; |
16 | 16 | |
17 | - var $search_operators = array( 'is', 'isnot', 'starts_with', 'ends_with' ); |
|
17 | + var $search_operators = array( 'is', 'isnot', 'starts_with', 'ends_with' ); |
|
18 | 18 | |
19 | 19 | var $group = 'pricing'; |
20 | 20 |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type ); |
46 | 46 | |
47 | 47 | // It's not the parent field; it's an input |
48 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
48 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
49 | 49 | |
50 | - if( $this->is_choice_value_enabled() ) { |
|
50 | + if ( $this->is_choice_value_enabled() ) { |
|
51 | 51 | |
52 | 52 | $desc = esc_html__( 'This input has a label and a value. What should be displayed?', 'gravityview' ); |
53 | 53 | $default = 'value'; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | ); |
66 | 66 | } |
67 | 67 | |
68 | - $field_options['choice_display'] = array( |
|
68 | + $field_options[ 'choice_display' ] = array( |
|
69 | 69 | 'type' => 'radio', |
70 | 70 | 'class' => 'vertical', |
71 | 71 | 'label' => __( 'What should be displayed:', 'gravityview' ), |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function clear_product_info_cache( $form = array(), $entry_id = 0, $Edit_Entry_Render = null ) { |
51 | 51 | |
52 | - if( $this->should_hide_product_fields( $Edit_Entry_Render->entry ) ) { |
|
52 | + if ( $this->should_hide_product_fields( $Edit_Entry_Render->entry ) ) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @see GVCommon::entry_has_transaction_data() |
102 | 102 | * @param boolean $hide_product_fields Whether to hide product fields in the editor. Uses $entry data to determine. |
103 | 103 | */ |
104 | - $hide_product_fields = (bool) apply_filters( 'gravityview/edit_entry/hide-product-fields', $has_transaction_data ); |
|
104 | + $hide_product_fields = (bool)apply_filters( 'gravityview/edit_entry/hide-product-fields', $has_transaction_data ); |
|
105 | 105 | |
106 | 106 | return $hide_product_fields; |
107 | 107 | } |