@@ -59,7 +59,6 @@ |
||
59 | 59 | * |
60 | 60 | * @param string $output HTML value output |
61 | 61 | * @param array $entry The GF entry array |
62 | - * @param array $field_settings Settings for the particular GV field |
|
63 | 62 | * @param array $field Field array, as fetched from GravityView_View::getCurrentField() |
64 | 63 | * |
65 | 64 | * @return string The field setting label for the current status. Uses defaults, if not configured. |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | function add_default_field( $entry_default_fields, $form, $zone ) { |
94 | 94 | |
95 | - if( 'edit' !== $zone ) { |
|
95 | + if ( 'edit' !== $zone ) { |
|
96 | 96 | $entry_default_fields[ $this->name ] = array( |
97 | 97 | 'label' => $this->label, |
98 | 98 | 'desc' => $this->description, |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | $merge_tags = array( |
119 | 119 | array( |
120 | - 'label' => __('Approval Status', 'gravityview'), |
|
120 | + 'label' => __( 'Approval Status', 'gravityview' ), |
|
121 | 121 | 'tag' => '{approval_status}' |
122 | 122 | ), |
123 | 123 | ); |
@@ -157,10 +157,10 @@ discard block |
||
157 | 157 | do_action( 'gravityview_log_error', __METHOD__ . ': No entry data available. Returning empty string.' ); |
158 | 158 | $replacement = ''; |
159 | 159 | } else { |
160 | - $replacement = GravityView_Entry_Approval::get_entry_status( $entry, $match[1] ); |
|
160 | + $replacement = GravityView_Entry_Approval::get_entry_status( $entry, $match[ 1 ] ); |
|
161 | 161 | } |
162 | 162 | |
163 | - $return = str_replace( $match[0], $replacement, $return ); |
|
163 | + $return = str_replace( $match[ 0 ], $replacement, $return ); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | return $return; |
@@ -168,25 +168,25 @@ discard block |
||
168 | 168 | |
169 | 169 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
170 | 170 | |
171 | - $field_options['approved_label'] = array( |
|
171 | + $field_options[ 'approved_label' ] = array( |
|
172 | 172 | 'type' => 'text', |
173 | 173 | 'label' => __( 'Approved Label', 'gravityview' ), |
174 | 174 | 'desc' => __( 'If the entry is approved, display this value', 'gravityview' ), |
175 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('approved'), |
|
175 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label( 'approved' ), |
|
176 | 176 | ); |
177 | 177 | |
178 | - $field_options['disapproved_label'] = array( |
|
178 | + $field_options[ 'disapproved_label' ] = array( |
|
179 | 179 | 'type' => 'text', |
180 | 180 | 'label' => __( 'Disapproved Label', 'gravityview' ), |
181 | 181 | 'desc' => __( 'If the entry is not approved, display this value', 'gravityview' ), |
182 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('disapproved'), |
|
182 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label( 'disapproved' ), |
|
183 | 183 | ); |
184 | 184 | |
185 | - $field_options['unapproved_label'] = array( |
|
185 | + $field_options[ 'unapproved_label' ] = array( |
|
186 | 186 | 'type' => 'text', |
187 | 187 | 'label' => __( 'Unapproved Label', 'gravityview' ), |
188 | 188 | 'desc' => __( 'If the entry has not yet been approved or disapproved, display this value', 'gravityview' ), |
189 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('unapproved'), |
|
189 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label( 'unapproved' ), |
|
190 | 190 | ); |
191 | 191 | |
192 | 192 | return $field_options; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | ?> |
10 | 10 | <label for="<?php echo $this->get_field_id(); ?>" class="<?php echo $this->get_label_class(); ?>"><?php |
11 | 11 | |
12 | - echo '<span class="gv-label">'.$this->get_field_label().'</span>'; |
|
12 | + echo '<span class="gv-label">' . $this->get_field_label() . '</span>'; |
|
13 | 13 | echo $this->get_tooltip() . $this->get_field_desc(); |
14 | 14 | ?><div> |
15 | 15 | <?php $this->render_input(); ?> |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | function render_input( $override_input = null ) { |
22 | - if( isset( $override_input ) ) { |
|
22 | + if ( isset( $override_input ) ) { |
|
23 | 23 | echo $override_input; |
24 | 24 | return; |
25 | 25 | } |
@@ -28,17 +28,17 @@ discard block |
||
28 | 28 | |
29 | 29 | $show_mt = $this->show_merge_tags(); |
30 | 30 | |
31 | - if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
31 | + if ( $show_mt && $this->field[ 'merge_tags' ] !== false || $this->field[ 'merge_tags' ] === 'force' ) { |
|
32 | 32 | $class .= ' merge-tag-support mt-position-right '; |
33 | 33 | |
34 | - if( empty( $this->field['show_all_fields'] ) ) { |
|
34 | + if ( empty( $this->field[ 'show_all_fields' ] ) ) { |
|
35 | 35 | $class .= ' mt-hide_all_fields '; |
36 | 36 | } |
37 | 37 | } |
38 | 38 | $class .= rgar( $this->field, 'class' ); |
39 | 39 | $placeholder = rgar( $this->field, 'placeholder' ); |
40 | 40 | ?> |
41 | - <textarea name="<?php echo esc_attr( $this->name ); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>" id="<?php echo $this->get_field_id(); ?>" class="<?php echo gravityview_sanitize_html_class( $class ); ?>" rows="5"><?php echo esc_textarea( $this->value ); ?></textarea> |
|
41 | + <textarea name="<?php echo esc_attr( $this->name ); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>" id="<?php echo $this->get_field_id(); ?>" class="<?php echo gravityview_sanitize_html_class( $class ); ?>" rows="5"><?php echo esc_textarea( $this->value ); ?></textarea> |
|
42 | 42 | <?php |
43 | 43 | } |
44 | 44 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | ?> |
9 | 9 | <label for="<?php echo $this->get_field_id(); ?>" class="<?php echo $this->get_label_class(); ?>"><?php |
10 | 10 | |
11 | - echo '<span class="gv-label">'.$this->get_field_label().'</span>'; |
|
11 | + echo '<span class="gv-label">' . $this->get_field_label() . '</span>'; |
|
12 | 12 | echo $this->get_tooltip() . $this->get_field_desc(); |
13 | 13 | ?><div> |
14 | 14 | <?php $this->render_input(); ?> |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | function render_input( $override_input = null ) { |
21 | 21 | |
22 | - if( isset( $override_input ) ) { |
|
22 | + if ( isset( $override_input ) ) { |
|
23 | 23 | echo $override_input; |
24 | 24 | return; |
25 | 25 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | $show_mt = $this->show_merge_tags(); |
30 | 30 | |
31 | - if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
31 | + if ( $show_mt && $this->field[ 'merge_tags' ] !== false || $this->field[ 'merge_tags' ] === 'force' ) { |
|
32 | 32 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
33 | 33 | } |
34 | 34 | $class .= rgar( $this->field, 'class', 'widefat' ); |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | |
135 | 135 | add_filter( 'gravityview/sortable/field_blacklist', array( $this, '_filter_sortable_fields' ), 1 ); |
136 | 136 | |
137 | - if( $this->entry_meta_key ) { |
|
137 | + if ( $this->entry_meta_key ) { |
|
138 | 138 | add_filter( 'gform_entry_meta', array( $this, 'add_entry_meta' ) ); |
139 | 139 | add_filter( 'gravityview/common/sortable_fields', array( $this, 'add_sortable_field' ), 10, 2 ); |
140 | 140 | } |
141 | 141 | |
142 | - if( $this->_custom_merge_tag ) { |
|
142 | + if ( $this->_custom_merge_tag ) { |
|
143 | 143 | add_filter( 'gform_custom_merge_tags', array( $this, '_filter_gform_custom_merge_tags' ), 10, 4 ); |
144 | 144 | add_filter( 'gform_replace_merge_tags', array( $this, '_filter_gform_replace_merge_tags' ), 10, 7 ); |
145 | 145 | } |
146 | 146 | |
147 | - if( 'meta' === $this->group || '' !== $this->default_search_label ) { |
|
147 | + if ( 'meta' === $this->group || '' !== $this->default_search_label ) { |
|
148 | 148 | add_filter( 'gravityview_search_field_label', array( $this, 'set_default_search_label' ), 10, 3 ); |
149 | 149 | } |
150 | 150 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | 'type' => $this->name |
168 | 168 | ); |
169 | 169 | |
170 | - $fields["{$this->entry_meta_key}"] = $added_field; |
|
170 | + $fields[ "{$this->entry_meta_key}" ] = $added_field; |
|
171 | 171 | |
172 | 172 | return $fields; |
173 | 173 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | function set_default_search_label( $label = '', $gf_field = null, $field = array() ) { |
189 | 189 | |
190 | - if( $this->name === $field['field'] && '' === $label ) { |
|
190 | + if ( $this->name === $field[ 'field' ] && '' === $label ) { |
|
191 | 191 | $label = esc_html( $this->default_search_label ); |
192 | 192 | } |
193 | 193 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @return string Original text if {_custom_merge_tag} isn't found. Otherwise, replaced text. |
210 | 210 | */ |
211 | - public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
211 | + public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
212 | 212 | |
213 | 213 | /** |
214 | 214 | * This prevents the gform_replace_merge_tags filter from being called twice, as defined in: |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * @see GFCommon::replace_variables_prepopulate() |
217 | 217 | * @todo Remove eventually: Gravity Forms fixed this issue in 1.9.14 |
218 | 218 | */ |
219 | - if( false === $form ) { |
|
219 | + if ( false === $form ) { |
|
220 | 220 | return $text; |
221 | 221 | } |
222 | 222 | |
@@ -249,19 +249,19 @@ discard block |
||
249 | 249 | */ |
250 | 250 | public function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
251 | 251 | |
252 | - foreach( $matches as $match ) { |
|
252 | + foreach ( $matches as $match ) { |
|
253 | 253 | |
254 | - $full_tag = $match[0]; |
|
254 | + $full_tag = $match[ 0 ]; |
|
255 | 255 | |
256 | 256 | // Strip the Merge Tags |
257 | - $tag = str_replace( array( '{', '}'), '', $full_tag ); |
|
257 | + $tag = str_replace( array( '{', '}' ), '', $full_tag ); |
|
258 | 258 | |
259 | 259 | // Replace the value from the entry, if exists |
260 | - if( isset( $entry[ $tag ] ) ) { |
|
260 | + if ( isset( $entry[ $tag ] ) ) { |
|
261 | 261 | |
262 | 262 | $value = $entry[ $tag ]; |
263 | 263 | |
264 | - if( is_callable( array( $this, 'get_content') ) ) { |
|
264 | + if ( is_callable( array( $this, 'get_content' ) ) ) { |
|
265 | 265 | $value = $this->get_content( $value ); |
266 | 266 | } |
267 | 267 | |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | */ |
335 | 335 | public function _filter_sortable_fields( $not_sortable ) { |
336 | 336 | |
337 | - if( ! $this->is_sortable ) { |
|
338 | - $not_sortable[] = $this->name; |
|
337 | + if ( ! $this->is_sortable ) { |
|
338 | + $not_sortable[ ] = $this->name; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $not_sortable; |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | */ |
353 | 353 | function add_entry_meta( $entry_meta ) { |
354 | 354 | |
355 | - if( ! isset( $entry_meta["{$this->entry_meta_key}"] ) ) { |
|
355 | + if ( ! isset( $entry_meta[ "{$this->entry_meta_key}" ] ) ) { |
|
356 | 356 | |
357 | 357 | $added_meta = array( |
358 | 358 | 'label' => $this->label, |
@@ -361,13 +361,13 @@ discard block |
||
361 | 361 | ); |
362 | 362 | |
363 | 363 | if ( $this->entry_meta_update_callback && is_callable( $this->entry_meta_update_callback ) ) { |
364 | - $added_meta['update_entry_meta_callback'] = $this->entry_meta_update_callback; |
|
364 | + $added_meta[ 'update_entry_meta_callback' ] = $this->entry_meta_update_callback; |
|
365 | 365 | } |
366 | 366 | |
367 | - $entry_meta["{$this->entry_meta_key}"] = $added_meta; |
|
367 | + $entry_meta[ "{$this->entry_meta_key}" ] = $added_meta; |
|
368 | 368 | |
369 | 369 | } else { |
370 | - do_action( 'gravityview_log_error', __METHOD__ . ' Entry meta already set: ' . $this->entry_meta_key, $entry_meta["{$this->entry_meta_key}"] ); |
|
370 | + do_action( 'gravityview_log_error', __METHOD__ . ' Entry meta already set: ' . $this->entry_meta_key, $entry_meta[ "{$this->entry_meta_key}" ] ); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | return $entry_meta; |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | 'date_display' => array( |
397 | 397 | 'type' => 'text', |
398 | 398 | 'label' => __( 'Override Date Format', 'gravityview' ), |
399 | - 'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gravityview'), '<a href="https://codex.wordpress.org/Formatting_Date_and_Time">', '</a>' ), |
|
399 | + 'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gravityview' ), '<a href="https://codex.wordpress.org/Formatting_Date_and_Time">', '</a>' ), |
|
400 | 400 | /** |
401 | 401 | * @filter `gravityview_date_format` Override the date format with a [PHP date format](https://codex.wordpress.org/Formatting_Date_and_Time) |
402 | 402 | * @param[in,out] null|string $date_format Date Format (default: null) |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | |
422 | 422 | $options = $this->field_support_options(); |
423 | 423 | |
424 | - if( isset( $options[ $key ] ) ) { |
|
424 | + if ( isset( $options[ $key ] ) ) { |
|
425 | 425 | $field_options[ $key ] = $options[ $key ]; |
426 | 426 | } |
427 | 427 | |
@@ -485,11 +485,11 @@ discard block |
||
485 | 485 | $connected_form = rgpost( 'form_id' ); |
486 | 486 | |
487 | 487 | // Otherwise, get the Form ID from the Post page |
488 | - if( empty( $connected_form ) ) { |
|
488 | + if ( empty( $connected_form ) ) { |
|
489 | 489 | $connected_form = gravityview_get_form_id( get_the_ID() ); |
490 | 490 | } |
491 | 491 | |
492 | - if( empty( $connected_form ) ) { |
|
492 | + if ( empty( $connected_form ) ) { |
|
493 | 493 | do_action( 'gravityview_log_error', sprintf( '%s: Form not found for form ID "%s"', __METHOD__, $connected_form ) ); |
494 | 494 | return false; |
495 | 495 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /** gf_entries page - entries table screen */ |
45 | 45 | |
46 | 46 | // capture bulk actions |
47 | - add_action( 'gform_loaded', array( $this, 'process_bulk_action') ); |
|
47 | + add_action( 'gform_loaded', array( $this, 'process_bulk_action' ) ); |
|
48 | 48 | |
49 | 49 | // add hidden field with approve status |
50 | 50 | add_action( 'gform_entries_first_column_actions', array( $this, 'add_entry_approved_hidden_input' ), 1, 5 ); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | add_filter( 'gravityview_tooltips', array( $this, 'tooltips' ) ); |
53 | 53 | |
54 | 54 | // adding styles and scripts |
55 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') ); |
|
55 | + add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ) ); |
|
56 | 56 | // bypass Gravity Forms no-conflict mode |
57 | 57 | add_filter( 'gform_noconflict_scripts', array( $this, 'register_gform_noconflict_script' ) ); |
58 | 58 | add_filter( 'gform_noconflict_styles', array( $this, 'register_gform_noconflict_style' ) ); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param bool $show_filter_links True: show the "approved"/"disapproved" filter links. False: hide them. |
82 | 82 | * @param array $form GF Form object of current form |
83 | 83 | */ |
84 | - if( false === apply_filters( 'gravityview/approve_entries/show_filter_links_entry_list', true, $form ) ) { |
|
84 | + if ( false === apply_filters( 'gravityview/approve_entries/show_filter_links_entry_list', true, $form ) ) { |
|
85 | 85 | return $filter_links; |
86 | 86 | } |
87 | 87 | |
@@ -102,19 +102,19 @@ discard block |
||
102 | 102 | $approved_count = $disapproved_count = 0; |
103 | 103 | |
104 | 104 | // Only count if necessary |
105 | - if( $include_counts ) { |
|
106 | - $approved_count = count( gravityview_get_entry_ids( $form['id'], array( 'status' => 'active', 'field_filters' => $field_filters_approved ) ) ); |
|
107 | - $disapproved_count = count( gravityview_get_entry_ids( $form['id'], array( 'status' => 'active', 'field_filters' => $field_filters_disapproved ) ) ); |
|
105 | + if ( $include_counts ) { |
|
106 | + $approved_count = count( gravityview_get_entry_ids( $form[ 'id' ], array( 'status' => 'active', 'field_filters' => $field_filters_approved ) ) ); |
|
107 | + $disapproved_count = count( gravityview_get_entry_ids( $form[ 'id' ], array( 'status' => 'active', 'field_filters' => $field_filters_disapproved ) ) ); |
|
108 | 108 | } |
109 | 109 | |
110 | - $filter_links[] = array( |
|
110 | + $filter_links[ ] = array( |
|
111 | 111 | 'id' => 'gv_approved', |
112 | 112 | 'field_filters' => $field_filters_approved, |
113 | 113 | 'count' => $approved_count, |
114 | 114 | 'label' => GravityView_Entry_Approval_Status::get_label( GravityView_Entry_Approval_Status::APPROVED ), |
115 | 115 | ); |
116 | 116 | |
117 | - $filter_links[] = array( |
|
117 | + $filter_links[ ] = array( |
|
118 | 118 | 'id' => 'gv_disapproved', |
119 | 119 | 'field_filters' => $field_filters_disapproved, |
120 | 120 | 'count' => $disapproved_count, |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | */ |
134 | 134 | function tooltips( $tooltips ) { |
135 | 135 | |
136 | - $tooltips['form_gravityview_fields'] = array( |
|
137 | - 'title' => __('GravityView Fields', 'gravityview'), |
|
138 | - 'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview'), |
|
136 | + $tooltips[ 'form_gravityview_fields' ] = array( |
|
137 | + 'title' => __( 'GravityView Fields', 'gravityview' ), |
|
138 | + 'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview' ), |
|
139 | 139 | ); |
140 | 140 | |
141 | 141 | return $tooltips; |
@@ -246,15 +246,15 @@ discard block |
||
246 | 246 | |
247 | 247 | $gv_bulk_action = false; |
248 | 248 | |
249 | - if( version_compare( GFForms::$version, '2.0', '>=' ) ) { |
|
250 | - $bulk_action = ( '-1' !== rgpost('action') ) ? rgpost('action') : rgpost('action2'); |
|
249 | + if ( version_compare( GFForms::$version, '2.0', '>=' ) ) { |
|
250 | + $bulk_action = ( '-1' !== rgpost( 'action' ) ) ? rgpost( 'action' ) : rgpost( 'action2' ); |
|
251 | 251 | } else { |
252 | 252 | // GF 1.9.x - Bulk action 2 is the bottom bulk action select form. |
253 | - $bulk_action = rgpost('bulk_action') ? rgpost('bulk_action') : rgpost('bulk_action2'); |
|
253 | + $bulk_action = rgpost( 'bulk_action' ) ? rgpost( 'bulk_action' ) : rgpost( 'bulk_action2' ); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | // Check the $bulk_action value against GV actions, see if they're the same. I hate strpos(). |
257 | - if( ! empty( $bulk_action ) && preg_match( '/^('. implode( '|', $this->bulk_action_prefixes ) .')/ism', $bulk_action ) ) { |
|
257 | + if ( ! empty( $bulk_action ) && preg_match( '/^(' . implode( '|', $this->bulk_action_prefixes ) . ')/ism', $bulk_action ) ) { |
|
258 | 258 | $gv_bulk_action = $bulk_action; |
259 | 259 | } |
260 | 260 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | |
280 | 280 | // gforms_entry_list is the nonce that confirms we're on the right page |
281 | 281 | // gforms_update_note is sent when bulk editing entry notes. We don't want to process then. |
282 | - if ( $bulk_action && rgpost('gforms_entry_list') && empty( $_POST['gforms_update_note'] ) ) { |
|
282 | + if ( $bulk_action && rgpost( 'gforms_entry_list' ) && empty( $_POST[ 'gforms_update_note' ] ) ) { |
|
283 | 283 | |
284 | 284 | check_admin_referer( 'gforms_entry_list', 'gforms_entry_list' ); |
285 | 285 | |
@@ -297,13 +297,13 @@ discard block |
||
297 | 297 | } |
298 | 298 | |
299 | 299 | // All entries are set to be updated, not just the visible ones |
300 | - if ( ! empty( $_POST['all_entries'] ) ) { |
|
300 | + if ( ! empty( $_POST[ 'all_entries' ] ) ) { |
|
301 | 301 | |
302 | 302 | // Convert the current entry search into GF-formatted search criteria |
303 | 303 | $search = array( |
304 | - 'search_field' => isset( $_POST['f'] ) ? $_POST['f'][0] : 0, |
|
305 | - 'search_value' => isset( $_POST['v'][0] ) ? $_POST['v'][0] : '', |
|
306 | - 'search_operator' => isset( $_POST['o'][0] ) ? $_POST['o'][0] : 'contains', |
|
304 | + 'search_field' => isset( $_POST[ 'f' ] ) ? $_POST[ 'f' ][ 0 ] : 0, |
|
305 | + 'search_value' => isset( $_POST[ 'v' ][ 0 ] ) ? $_POST[ 'v' ][ 0 ] : '', |
|
306 | + 'search_operator' => isset( $_POST[ 'o' ][ 0 ] ) ? $_POST[ 'o' ][ 0 ] : 'contains', |
|
307 | 307 | ); |
308 | 308 | |
309 | 309 | $search_criteria = GravityView_frontend::get_search_criteria( $search, $form_id ); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | } else { |
315 | 315 | |
316 | 316 | // Changed from 'lead' to 'entry' in 2.0 |
317 | - $entries = isset( $_POST['lead'] ) ? $_POST['lead'] : $_POST['entry']; |
|
317 | + $entries = isset( $_POST[ 'lead' ] ) ? $_POST[ 'lead' ] : $_POST[ 'entry' ]; |
|
318 | 318 | |
319 | 319 | } |
320 | 320 | |
@@ -326,15 +326,15 @@ discard block |
||
326 | 326 | $entry_count = count( $entries ) > 1 ? sprintf( __( '%d entries', 'gravityview' ), count( $entries ) ) : __( '1 entry', 'gravityview' ); |
327 | 327 | |
328 | 328 | switch ( $approved_status ) { |
329 | - case $this->bulk_action_prefixes['approve']: |
|
329 | + case $this->bulk_action_prefixes[ 'approve' ]: |
|
330 | 330 | GravityView_Entry_Approval::update_bulk( $entries, GravityView_Entry_Approval_Status::APPROVED, $form_id ); |
331 | 331 | $this->bulk_update_message = sprintf( __( '%s approved.', 'gravityview' ), $entry_count ); |
332 | 332 | break; |
333 | - case $this->bulk_action_prefixes['unapprove']: |
|
333 | + case $this->bulk_action_prefixes[ 'unapprove' ]: |
|
334 | 334 | GravityView_Entry_Approval::update_bulk( $entries, GravityView_Entry_Approval_Status::UNAPPROVED, $form_id ); |
335 | 335 | $this->bulk_update_message = sprintf( __( '%s unapproved.', 'gravityview' ), $entry_count ); |
336 | 336 | break; |
337 | - case $this->bulk_action_prefixes['disapprove']: |
|
337 | + case $this->bulk_action_prefixes[ 'disapprove' ]: |
|
338 | 338 | GravityView_Entry_Approval::update_bulk( $entries, GravityView_Entry_Approval_Status::DISAPPROVED, $form_id ); |
339 | 339 | $this->bulk_update_message = sprintf( __( '%s disapproved.', 'gravityview' ), $entry_count ); |
340 | 340 | break; |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @return boolean True: It worked; False: it failed |
358 | 358 | */ |
359 | - public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { |
|
359 | + public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0 ) { |
|
360 | 360 | return GravityView_Entry_Approval::update_approved( $entry_id, $approved, $form_id, $approvedcolumn ); |
361 | 361 | } |
362 | 362 | |
@@ -386,20 +386,20 @@ discard block |
||
386 | 386 | * |
387 | 387 | * @return void |
388 | 388 | */ |
389 | - static public function add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string ) { |
|
389 | + static public function add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string ) { |
|
390 | 390 | |
391 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry['id'] ) ) { |
|
391 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry[ 'id' ] ) ) { |
|
392 | 392 | return; |
393 | 393 | } |
394 | 394 | |
395 | - if( empty( $entry['id'] ) ) { |
|
395 | + if ( empty( $entry[ 'id' ] ) ) { |
|
396 | 396 | return; |
397 | 397 | } |
398 | 398 | |
399 | 399 | $status_value = GravityView_Entry_Approval::get_entry_status( $entry, 'value' ); |
400 | 400 | |
401 | - if( $status_value ) { |
|
402 | - echo '<input type="hidden" class="entry_approval" id="entry_approved_'. $entry['id'] .'" value="' . esc_attr( $status_value ) . '" />'; |
|
401 | + if ( $status_value ) { |
|
402 | + echo '<input type="hidden" class="entry_approval" id="entry_approved_' . $entry[ 'id' ] . '" value="' . esc_attr( $status_value ) . '" />'; |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
@@ -412,10 +412,10 @@ discard block |
||
412 | 412 | */ |
413 | 413 | private function get_form_id() { |
414 | 414 | |
415 | - $form_id = GFForms::get('id'); |
|
415 | + $form_id = GFForms::get( 'id' ); |
|
416 | 416 | |
417 | 417 | // If there are no forms identified, use the first form. That's how GF does it. |
418 | - if( empty( $form_id ) && class_exists('RGFormsModel') ) { |
|
418 | + if ( empty( $form_id ) && class_exists( 'RGFormsModel' ) ) { |
|
419 | 419 | $form_id = $this->get_first_form_id(); |
420 | 420 | } |
421 | 421 | |
@@ -435,14 +435,14 @@ discard block |
||
435 | 435 | |
436 | 436 | $forms = RGFormsModel::get_forms( null, 'title' ); |
437 | 437 | |
438 | - if( ! isset( $forms[0] ) ) { |
|
438 | + if ( ! isset( $forms[ 0 ] ) ) { |
|
439 | 439 | do_action( 'gravityview_log_error', __METHOD__ . ': No forms were found' ); |
440 | 440 | return 0; |
441 | 441 | } |
442 | 442 | |
443 | - $first_form = $forms[0]; |
|
443 | + $first_form = $forms[ 0 ]; |
|
444 | 444 | |
445 | - $form_id = is_object( $forms[0] ) ? $first_form->id : $first_form['id']; |
|
445 | + $form_id = is_object( $forms[ 0 ] ) ? $first_form->id : $first_form[ 'id' ]; |
|
446 | 446 | |
447 | 447 | return intval( $form_id ); |
448 | 448 | } |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | |
451 | 451 | function add_scripts_and_styles( $hook ) { |
452 | 452 | |
453 | - if( ! class_exists( 'RGForms' ) ) { |
|
453 | + if ( ! class_exists( 'RGForms' ) ) { |
|
454 | 454 | |
455 | 455 | do_action( 'gravityview_log_error', 'GravityView_Admin_ApproveEntries[add_scripts_and_styles] RGForms does not exist.' ); |
456 | 456 | |
@@ -459,26 +459,26 @@ discard block |
||
459 | 459 | |
460 | 460 | // enqueue styles & scripts gf_entries |
461 | 461 | // But only if we're on the main Entries page, not on reports pages |
462 | - if( GFForms::get_page() !== 'entry_list' ) { |
|
462 | + if ( GFForms::get_page() !== 'entry_list' ) { |
|
463 | 463 | return; |
464 | 464 | } |
465 | 465 | |
466 | 466 | $form_id = $this->get_form_id(); |
467 | 467 | |
468 | 468 | // Things are broken; no forms were found |
469 | - if( empty( $form_id ) ) { |
|
469 | + if ( empty( $form_id ) ) { |
|
470 | 470 | return; |
471 | 471 | } |
472 | 472 | |
473 | - wp_enqueue_style( 'gravityview_entries_list', plugins_url('assets/css/admin-entries-list.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
473 | + wp_enqueue_style( 'gravityview_entries_list', plugins_url( 'assets/css/admin-entries-list.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
|
474 | 474 | |
475 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
475 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
476 | 476 | |
477 | - wp_enqueue_script( 'gravityview_gf_entries_scripts', plugins_url('assets/js/admin-entries-list'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version ); |
|
477 | + wp_enqueue_script( 'gravityview_gf_entries_scripts', plugins_url( 'assets/js/admin-entries-list' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version ); |
|
478 | 478 | |
479 | 479 | wp_localize_script( 'gravityview_gf_entries_scripts', 'gvGlobals', array( |
480 | - 'nonce' => wp_create_nonce( 'gravityview_entry_approval'), |
|
481 | - 'admin_nonce' => wp_create_nonce( 'gravityview_admin_entry_approval'), |
|
480 | + 'nonce' => wp_create_nonce( 'gravityview_entry_approval' ), |
|
481 | + 'admin_nonce' => wp_create_nonce( 'gravityview_admin_entry_approval' ), |
|
482 | 482 | 'form_id' => $form_id, |
483 | 483 | 'show_column' => (int)$this->show_approve_entry_column( $form_id ), |
484 | 484 | 'add_bulk_action' => (int)GVCommon::has_cap( 'gravityview_moderate_entries' ), |
@@ -487,10 +487,10 @@ discard block |
||
487 | 487 | 'status_unapproved' => GravityView_Entry_Approval_Status::UNAPPROVED, |
488 | 488 | 'bulk_actions' => $this->get_bulk_actions( $form_id ), |
489 | 489 | 'bulk_message' => $this->bulk_update_message, |
490 | - 'unapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('unapproved'), |
|
491 | - 'approve_title' => GravityView_Entry_Approval_Status::get_title_attr('disapproved'), |
|
492 | - 'disapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('approved'), |
|
493 | - 'column_title' => __( 'Show entry in directory view?', 'gravityview'), |
|
490 | + 'unapprove_title' => GravityView_Entry_Approval_Status::get_title_attr( 'unapproved' ), |
|
491 | + 'approve_title' => GravityView_Entry_Approval_Status::get_title_attr( 'disapproved' ), |
|
492 | + 'disapprove_title' => GravityView_Entry_Approval_Status::get_title_attr( 'approved' ), |
|
493 | + 'column_title' => __( 'Show entry in directory view?', 'gravityview' ), |
|
494 | 494 | 'column_link' => esc_url( $this->get_sort_link( $form_id ) ), |
495 | 495 | ) ); |
496 | 496 | |
@@ -510,11 +510,11 @@ discard block |
||
510 | 510 | |
511 | 511 | $approved_column_id = self::get_approved_column( $form_id ); |
512 | 512 | |
513 | - if( ! $approved_column_id ) { |
|
513 | + if ( ! $approved_column_id ) { |
|
514 | 514 | return ''; |
515 | 515 | } |
516 | 516 | |
517 | - $order = ( 'desc' === rgget('order') ) ? 'asc' : 'desc'; |
|
517 | + $order = ( 'desc' === rgget( 'order' ) ) ? 'asc' : 'desc'; |
|
518 | 518 | |
519 | 519 | $args = array( |
520 | 520 | 'orderby' => $approved_column_id, |
@@ -540,16 +540,16 @@ discard block |
||
540 | 540 | $bulk_actions = array( |
541 | 541 | 'GravityView' => array( |
542 | 542 | array( |
543 | - 'label' => GravityView_Entry_Approval_Status::get_string('approved', 'action'), |
|
544 | - 'value' => sprintf( '%s-%d', $this->bulk_action_prefixes['approve'], $form_id ), |
|
543 | + 'label' => GravityView_Entry_Approval_Status::get_string( 'approved', 'action' ), |
|
544 | + 'value' => sprintf( '%s-%d', $this->bulk_action_prefixes[ 'approve' ], $form_id ), |
|
545 | 545 | ), |
546 | 546 | array( |
547 | - 'label' => GravityView_Entry_Approval_Status::get_string('disapproved', 'action'), |
|
548 | - 'value' => sprintf( '%s-%d', $this->bulk_action_prefixes['disapprove'], $form_id ), |
|
547 | + 'label' => GravityView_Entry_Approval_Status::get_string( 'disapproved', 'action' ), |
|
548 | + 'value' => sprintf( '%s-%d', $this->bulk_action_prefixes[ 'disapprove' ], $form_id ), |
|
549 | 549 | ), |
550 | 550 | array( |
551 | - 'label' => GravityView_Entry_Approval_Status::get_string('unapproved', 'action'), |
|
552 | - 'value' => sprintf( '%s-%d', $this->bulk_action_prefixes['unapprove'], $form_id ), |
|
551 | + 'label' => GravityView_Entry_Approval_Status::get_string( 'unapproved', 'action' ), |
|
552 | + 'value' => sprintf( '%s-%d', $this->bulk_action_prefixes[ 'unapprove' ], $form_id ), |
|
553 | 553 | ), |
554 | 554 | ), |
555 | 555 | ); |
@@ -566,8 +566,8 @@ discard block |
||
566 | 566 | // Sanitize the values, just to be sure. |
567 | 567 | foreach ( $bulk_actions as $key => $group ) { |
568 | 568 | foreach ( $group as $i => $action ) { |
569 | - $bulk_actions[ $key ][ $i ]['label'] = esc_html( $bulk_actions[ $key ][ $i ]['label'] ); |
|
570 | - $bulk_actions[ $key ][ $i ]['value'] = esc_attr( $bulk_actions[ $key ][ $i ]['value'] ); |
|
569 | + $bulk_actions[ $key ][ $i ][ 'label' ] = esc_html( $bulk_actions[ $key ][ $i ][ 'label' ] ); |
|
570 | + $bulk_actions[ $key ][ $i ][ 'value' ] = esc_attr( $bulk_actions[ $key ][ $i ][ 'value' ] ); |
|
571 | 571 | } |
572 | 572 | } |
573 | 573 | |
@@ -592,13 +592,13 @@ discard block |
||
592 | 592 | * @since 1.7.2 |
593 | 593 | * @param boolean $hide_if_no_connections |
594 | 594 | */ |
595 | - $hide_if_no_connections = apply_filters('gravityview/approve_entries/hide-if-no-connections', false ); |
|
595 | + $hide_if_no_connections = apply_filters( 'gravityview/approve_entries/hide-if-no-connections', false ); |
|
596 | 596 | |
597 | - if( $hide_if_no_connections ) { |
|
597 | + if ( $hide_if_no_connections ) { |
|
598 | 598 | |
599 | 599 | $connected_views = gravityview_get_connected_views( $form_id ); |
600 | 600 | |
601 | - if( empty( $connected_views ) ) { |
|
601 | + if ( empty( $connected_views ) ) { |
|
602 | 602 | $show_approve_column = false; |
603 | 603 | } |
604 | 604 | } |
@@ -608,18 +608,18 @@ discard block |
||
608 | 608 | * @param boolean $show_approve_column Whether the column will be shown |
609 | 609 | * @param int $form_id The ID of the Gravity Forms form for which entries are being shown |
610 | 610 | */ |
611 | - $show_approve_column = apply_filters('gravityview/approve_entries/show-column', $show_approve_column, $form_id ); |
|
611 | + $show_approve_column = apply_filters( 'gravityview/approve_entries/show-column', $show_approve_column, $form_id ); |
|
612 | 612 | |
613 | 613 | return $show_approve_column; |
614 | 614 | } |
615 | 615 | |
616 | 616 | function register_gform_noconflict_script( $scripts ) { |
617 | - $scripts[] = 'gravityview_gf_entries_scripts'; |
|
617 | + $scripts[ ] = 'gravityview_gf_entries_scripts'; |
|
618 | 618 | return $scripts; |
619 | 619 | } |
620 | 620 | |
621 | 621 | function register_gform_noconflict_style( $styles ) { |
622 | - $styles[] = 'gravityview_entries_list'; |
|
622 | + $styles[ ] = 'gravityview_entries_list'; |
|
623 | 623 | return $styles; |
624 | 624 | } |
625 | 625 |
@@ -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,14 +121,14 @@ 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 | /** |
127 | 127 | * Override CSS file by placing in your theme's /gravityview/css/ sub-directory. |
128 | 128 | */ |
129 | 129 | $style_path = GravityView_View::getInstance()->locate_template( 'css/field-approval.css', false ); |
130 | 130 | |
131 | - $style_url = plugins_url( 'css/field-approval.css', trailingslashit( dirname( $style_path ) ) ); |
|
131 | + $style_url = plugins_url( 'css/field-approval.css', trailingslashit( dirname( $style_path ) ) ); |
|
132 | 132 | |
133 | 133 | /** |
134 | 134 | * @filter `gravityview/field/approval/css_url` URL to the Approval field CSS file. |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | $style_url = apply_filters( 'gravityview/field/approval/css_url', $style_url ); |
139 | 139 | |
140 | - if( ! empty( $style_url ) ) { |
|
140 | + if ( ! empty( $style_url ) ) { |
|
141 | 141 | wp_register_style( 'gravityview-field-approval', $style_url, array( 'dashicons' ), GravityView_Plugin::version, 'screen' ); |
142 | 142 | } |
143 | 143 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | public function enqueue_and_localize_script() { |
153 | 153 | |
154 | 154 | // The script is already registered and enqueued |
155 | - if( wp_script_is( 'gravityview-field-approval', 'enqueued' ) ) { |
|
155 | + if ( wp_script_is( 'gravityview-field-approval', 'enqueued' ) ) { |
|
156 | 156 | return; |
157 | 157 | } |
158 | 158 | |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | |
163 | 163 | wp_localize_script( 'gravityview-field-approval', 'gvApproval', array( |
164 | 164 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
165 | - 'nonce' => wp_create_nonce('gravityview_entry_approval'), |
|
165 | + 'nonce' => wp_create_nonce( 'gravityview_entry_approval' ), |
|
166 | 166 | 'status' => GravityView_Entry_Approval_Status::get_all(), |
167 | - )); |
|
167 | + ) ); |
|
168 | 168 | |
169 | 169 | } |
170 | 170 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function filter_gravityview_entry_default_field( $entry_default_fields, $form, $context ) { |
183 | 183 | |
184 | - if ( ! isset( $entry_default_fields["{$this->name}"] ) ) { |
|
185 | - $entry_default_fields["{$this->name}"] = array( |
|
184 | + if ( ! isset( $entry_default_fields[ "{$this->name}" ] ) ) { |
|
185 | + $entry_default_fields[ "{$this->name}" ] = array( |
|
186 | 186 | 'label' => $this->label, |
187 | 187 | 'desc' => $this->description, |
188 | 188 | 'type' => $this->name, |
@@ -27,7 +27,7 @@ discard block |
||
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( |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | 'custom_class' => array( |
46 | 46 | 'type' => 'text', |
47 | 47 | 'label' => __( 'Custom CSS Class:', 'gravityview' ), |
48 | - 'desc' => __( 'This class will be added to the field container', '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', |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | ); |
66 | 66 | |
67 | 67 | // Match Table as well as DataTables |
68 | - if( preg_match( '/table/ism', $template_id ) && 'directory' === $context ) { |
|
69 | - $field_options['width'] = array( |
|
68 | + if ( preg_match( '/table/ism', $template_id ) && 'directory' === $context ) { |
|
69 | + $field_options[ 'width' ] = array( |
|
70 | 70 | 'type' => 'number', |
71 | - 'label' => __('Percent Width', 'gravityview'), |
|
72 | - 'desc' => __( 'Leave blank for column width to be based on the field content.', 'gravityview'), |
|
71 | + 'label' => __( 'Percent Width', '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 | ); |
@@ -122,8 +122,8 @@ discard block |
||
122 | 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 | } |
@@ -163,24 +163,24 @@ discard block |
||
163 | 163 | */ |
164 | 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 | - $uniqid = uniqid('', false); |
|
168 | + $uniqid = uniqid( '', false ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | // get field/widget options |
172 | 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 | 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 | |
@@ -243,17 +243,17 @@ 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'] ) ) { |
|
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' ); |
|
246 | + if ( ! empty( $option[ 'default' ] ) && empty( $option[ 'value' ] ) ) { |
|
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' ); |
|
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 | 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 | 258 | /** @var GravityView_FieldType $render_type */ |
259 | 259 | $render_type = new $type_class( $name, $option, $curr_value ); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param[in,out] string $output field class name |
271 | 271 | * @param[in] array $option option field data |
272 | 272 | */ |
273 | - $output = apply_filters( "gravityview/option/output/{$option['type']}" , $output, $option ); |
|
273 | + $output = apply_filters( "gravityview/option/output/{$option[ 'type' ]}", $output, $option ); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | } // isset option[type] |
@@ -297,33 +297,33 @@ discard block |
||
297 | 297 | $setting = GravityView_View_Data::get_default_arg( $key, true ); |
298 | 298 | |
299 | 299 | // If the key doesn't exist, there's something wrong. |
300 | - if( empty( $setting ) ) { return; } |
|
300 | + if ( empty( $setting ) ) { return; } |
|
301 | 301 | |
302 | 302 | /** |
303 | 303 | * @deprecated setting index 'name' was replaced by 'label' |
304 | 304 | * @see GravityView_FieldType::get_field_defaults |
305 | 305 | */ |
306 | - if( isset( $setting['name'] ) && empty( $setting['label'] ) ) { |
|
307 | - $setting['label'] = $setting['name']; |
|
308 | - _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting '. $key .' details' ); |
|
306 | + if ( isset( $setting[ 'name' ] ) && empty( $setting[ 'label' ] ) ) { |
|
307 | + $setting[ 'label' ] = $setting[ 'name' ]; |
|
308 | + _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting ' . $key . ' details' ); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | $name = esc_attr( sprintf( $name, $key ) ); |
312 | - $setting['id'] = esc_attr( sprintf( $id, $key ) ); |
|
313 | - $setting['tooltip'] = 'gv_' . $key; |
|
312 | + $setting[ 'id' ] = esc_attr( sprintf( $id, $key ) ); |
|
313 | + $setting[ 'tooltip' ] = 'gv_' . $key; |
|
314 | 314 | |
315 | 315 | // Use default if current setting isn't set. |
316 | - $curr_value = isset( $current_settings[ $key ] ) ? $current_settings[ $key ] : $setting['value']; |
|
316 | + $curr_value = isset( $current_settings[ $key ] ) ? $current_settings[ $key ] : $setting[ 'value' ]; |
|
317 | 317 | |
318 | 318 | // default setting type = text |
319 | - $setting['type'] = empty( $setting['type'] ) ? 'text' : $setting['type']; |
|
319 | + $setting[ 'type' ] = empty( $setting[ 'type' ] ) ? 'text' : $setting[ 'type' ]; |
|
320 | 320 | |
321 | 321 | // merge tags |
322 | - if( !isset( $setting['merge_tags'] ) ) { |
|
323 | - if( $setting['type'] === 'text' ) { |
|
324 | - $setting['merge_tags'] = true; |
|
322 | + if ( ! isset( $setting[ 'merge_tags' ] ) ) { |
|
323 | + if ( $setting[ 'type' ] === 'text' ) { |
|
324 | + $setting[ 'merge_tags' ] = true; |
|
325 | 325 | } else { |
326 | - $setting['merge_tags'] = false; |
|
326 | + $setting[ 'merge_tags' ] = false; |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | |
332 | 332 | // render the setting |
333 | 333 | $type_class = self::load_type_class( $setting ); |
334 | - if( class_exists( $type_class ) ) { |
|
334 | + if ( class_exists( $type_class ) ) { |
|
335 | 335 | /** @var GravityView_FieldType $render_type */ |
336 | 336 | $render_type = new $type_class( $name, $setting, $curr_value ); |
337 | 337 | ob_start(); |
@@ -340,21 +340,21 @@ discard block |
||
340 | 340 | } |
341 | 341 | |
342 | 342 | // Check if setting is specific for a template |
343 | - if( !empty( $setting['show_in_template'] ) ) { |
|
344 | - if( !is_array( $setting['show_in_template'] ) ) { |
|
345 | - $setting['show_in_template'] = array( $setting['show_in_template'] ); |
|
343 | + if ( ! empty( $setting[ 'show_in_template' ] ) ) { |
|
344 | + if ( ! is_array( $setting[ 'show_in_template' ] ) ) { |
|
345 | + $setting[ 'show_in_template' ] = array( $setting[ 'show_in_template' ] ); |
|
346 | 346 | } |
347 | - $show_if = ' data-show-if="'. implode( ' ', $setting['show_in_template'] ).'"'; |
|
347 | + $show_if = ' data-show-if="' . implode( ' ', $setting[ 'show_in_template' ] ) . '"'; |
|
348 | 348 | } else { |
349 | 349 | $show_if = ''; |
350 | 350 | } |
351 | 351 | |
352 | - if( ! empty( $setting['requires'] ) ) { |
|
353 | - $show_if .= sprintf( ' data-requires="%s"', $setting['requires'] ); |
|
352 | + if ( ! empty( $setting[ 'requires' ] ) ) { |
|
353 | + $show_if .= sprintf( ' data-requires="%s"', $setting[ 'requires' ] ); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | // output |
357 | - echo '<tr valign="top" '. $show_if .'>' . $output . '</tr>'; |
|
357 | + echo '<tr valign="top" ' . $show_if . '>' . $output . '</tr>'; |
|
358 | 358 | |
359 | 359 | } |
360 | 360 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | */ |
367 | 367 | public static function load_type_class( $field = NULL ) { |
368 | 368 | |
369 | - if( empty( $field['type'] ) ) { |
|
369 | + if ( empty( $field[ 'type' ] ) ) { |
|
370 | 370 | return NULL; |
371 | 371 | } |
372 | 372 | |
@@ -375,19 +375,19 @@ discard block |
||
375 | 375 | * @param string $class_suffix field class suffix; `GravityView_FieldType_{$class_suffix}` |
376 | 376 | * @param array $field field data |
377 | 377 | */ |
378 | - $type_class = apply_filters( "gravityview/setting/class/{$field['type']}", 'GravityView_FieldType_' . $field['type'], $field ); |
|
378 | + $type_class = apply_filters( "gravityview/setting/class/{$field[ 'type' ]}", 'GravityView_FieldType_' . $field[ 'type' ], $field ); |
|
379 | 379 | |
380 | - if( !class_exists( $type_class ) ) { |
|
380 | + if ( ! class_exists( $type_class ) ) { |
|
381 | 381 | |
382 | 382 | /** |
383 | 383 | * @filter `gravityview/setting/class_file/{field_type}` |
384 | 384 | * @param string $field_type_include_path field class file path |
385 | 385 | * @param array $field field data |
386 | 386 | */ |
387 | - $class_file = apply_filters( "gravityview/setting/class_file/{$field['type']}", GRAVITYVIEW_DIR . "includes/admin/field-types/type_{$field['type']}.php", $field ); |
|
387 | + $class_file = apply_filters( "gravityview/setting/class_file/{$field[ 'type' ]}", GRAVITYVIEW_DIR . "includes/admin/field-types/type_{$field[ 'type' ]}.php", $field ); |
|
388 | 388 | |
389 | - if( $class_file ) { |
|
390 | - if( file_exists( $class_file ) ) { |
|
389 | + if ( $class_file ) { |
|
390 | + if ( file_exists( $class_file ) ) { |
|
391 | 391 | require_once( $class_file ); |
392 | 392 | } |
393 | 393 | } |
@@ -412,8 +412,8 @@ discard block |
||
412 | 412 | |
413 | 413 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_checkbox::render_input' ); |
414 | 414 | |
415 | - $output = '<input name="'. esc_attr( $name ) .'" type="hidden" value="0">'; |
|
416 | - $output .= '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="checkbox" value="1" '. checked( $current, '1', false ) .' >'; |
|
415 | + $output = '<input name="' . esc_attr( $name ) . '" type="hidden" value="0">'; |
|
416 | + $output .= '<input name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" type="checkbox" value="1" ' . checked( $current, '1', false ) . ' >'; |
|
417 | 417 | |
418 | 418 | return $output; |
419 | 419 | } |
@@ -433,22 +433,22 @@ discard block |
||
433 | 433 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_text::render_input' ); |
434 | 434 | |
435 | 435 | // Show the merge tags if the field is a list view |
436 | - $is_list = ( preg_match( '/_list-/ism', $name )); |
|
436 | + $is_list = ( preg_match( '/_list-/ism', $name ) ); |
|
437 | 437 | |
438 | 438 | // Or is a single entry view |
439 | - $is_single = ( preg_match( '/single_/ism', $name )); |
|
439 | + $is_single = ( preg_match( '/single_/ism', $name ) ); |
|
440 | 440 | $show = ( $is_single || $is_list ); |
441 | 441 | |
442 | 442 | $class = ''; |
443 | 443 | // and $add_merge_tags is not false |
444 | - if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
444 | + if ( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
445 | 445 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
446 | 446 | } |
447 | 447 | |
448 | - $class .= !empty( $args['class'] ) ? $args['class'] : 'widefat'; |
|
449 | - $type = !empty( $args['type'] ) ? $args['type'] : 'text'; |
|
448 | + $class .= ! empty( $args[ 'class' ] ) ? $args[ 'class' ] : 'widefat'; |
|
449 | + $type = ! empty( $args[ 'type' ] ) ? $args[ 'type' ] : 'text'; |
|
450 | 450 | |
451 | - return '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="'.esc_attr($type).'" value="'. esc_attr( $current ) .'" class="'.esc_attr( $class ).'">'; |
|
451 | + return '<input name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" type="' . esc_attr( $type ) . '" value="' . esc_attr( $current ) . '" class="' . esc_attr( $class ) . '">'; |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -465,21 +465,21 @@ discard block |
||
465 | 465 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_textarea::render_input' ); |
466 | 466 | |
467 | 467 | // Show the merge tags if the field is a list view |
468 | - $is_list = ( preg_match( '/_list-/ism', $name )); |
|
468 | + $is_list = ( preg_match( '/_list-/ism', $name ) ); |
|
469 | 469 | |
470 | 470 | // Or is a single entry view |
471 | - $is_single = ( preg_match( '/single_/ism', $name )); |
|
471 | + $is_single = ( preg_match( '/single_/ism', $name ) ); |
|
472 | 472 | $show = ( $is_single || $is_list ); |
473 | 473 | |
474 | 474 | $class = ''; |
475 | 475 | // and $add_merge_tags is not false |
476 | - if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
476 | + if ( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
477 | 477 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
478 | 478 | } |
479 | 479 | |
480 | - $class .= !empty( $args['class'] ) ? 'widefat '.$args['class'] : 'widefat'; |
|
480 | + $class .= ! empty( $args[ 'class' ] ) ? 'widefat ' . $args[ 'class' ] : 'widefat'; |
|
481 | 481 | |
482 | - return '<textarea name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" class="'.esc_attr( $class ).'">'. esc_textarea( $current ) .'</textarea>'; |
|
482 | + return '<textarea name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ) . '">' . esc_textarea( $current ) . '</textarea>'; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -495,9 +495,9 @@ discard block |
||
495 | 495 | |
496 | 496 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_select::render_input' ); |
497 | 497 | |
498 | - $output = '<select name="'. $name .'" id="'. $id .'">'; |
|
499 | - foreach( $choices as $value => $label ) { |
|
500 | - $output .= '<option value="'. esc_attr( $value ) .'" '. selected( $value, $current, false ) .'>'. esc_html( $label ) .'</option>'; |
|
498 | + $output = '<select name="' . $name . '" id="' . $id . '">'; |
|
499 | + foreach ( $choices as $value => $label ) { |
|
500 | + $output .= '<option value="' . esc_attr( $value ) . '" ' . selected( $value, $current, false ) . '>' . esc_html( $label ) . '</option>'; |
|
501 | 501 | } |
502 | 502 | $output .= '</select>'; |
503 | 503 |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | */ |
18 | 18 | private function __construct( $passed_post = NULL ) { |
19 | 19 | |
20 | - if( !empty( $passed_post ) ) { |
|
20 | + if ( ! empty( $passed_post ) ) { |
|
21 | 21 | |
22 | 22 | $id_or_id_array = $this->maybe_get_view_id( $passed_post ); |
23 | 23 | |
24 | - if( !empty( $id_or_id_array ) ) { |
|
24 | + if ( ! empty( $id_or_id_array ) ) { |
|
25 | 25 | $this->add_view( $id_or_id_array ); |
26 | 26 | } |
27 | 27 | } |
@@ -56,33 +56,33 @@ discard block |
||
56 | 56 | |
57 | 57 | $ids = array(); |
58 | 58 | |
59 | - if( ! empty( $passed_post ) ) { |
|
59 | + if ( ! empty( $passed_post ) ) { |
|
60 | 60 | |
61 | - if( is_numeric( $passed_post ) ) { |
|
61 | + if ( is_numeric( $passed_post ) ) { |
|
62 | 62 | $passed_post = get_post( $passed_post ); |
63 | 63 | } |
64 | 64 | |
65 | 65 | // Convert WP_Posts into WP_Posts[] array |
66 | - if( $passed_post instanceof WP_Post ) { |
|
66 | + if ( $passed_post instanceof WP_Post ) { |
|
67 | 67 | $passed_post = array( $passed_post ); |
68 | 68 | } |
69 | 69 | |
70 | - if( is_array( $passed_post ) ) { |
|
70 | + if ( is_array( $passed_post ) ) { |
|
71 | 71 | |
72 | - foreach ( $passed_post as &$post) { |
|
73 | - if( ( get_post_type( $post ) === 'gravityview' ) ) { |
|
74 | - $ids[] = $post->ID; |
|
75 | - } else{ |
|
72 | + foreach ( $passed_post as &$post ) { |
|
73 | + if ( ( get_post_type( $post ) === 'gravityview' ) ) { |
|
74 | + $ids[ ] = $post->ID; |
|
75 | + } else { |
|
76 | 76 | // Parse the Post Content |
77 | 77 | $id = $this->parse_post_content( $post->post_content ); |
78 | - if( $id ) { |
|
79 | - $ids = array_merge( $ids, (array) $id ); |
|
78 | + if ( $id ) { |
|
79 | + $ids = array_merge( $ids, (array)$id ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | // Parse the Post Meta |
83 | 83 | $id = $this->parse_post_meta( $post->ID ); |
84 | - if( $id ) { |
|
85 | - $ids = array_merge( $ids, (array) $id ); |
|
84 | + if ( $id ) { |
|
85 | + $ids = array_merge( $ids, (array)$id ); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -93,24 +93,24 @@ discard block |
||
93 | 93 | if ( is_string( $passed_post ) ) { |
94 | 94 | |
95 | 95 | $id = $this->parse_post_content( $passed_post ); |
96 | - if( $id ) { |
|
97 | - $ids = array_merge( $ids, (array) $id ); |
|
96 | + if ( $id ) { |
|
97 | + $ids = array_merge( $ids, (array)$id ); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | } else { |
101 | 101 | $id = $this->get_id_from_atts( $passed_post ); |
102 | - $ids[] = intval( $id ); |
|
102 | + $ids[ ] = intval( $id ); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - if( empty($ids) ) { |
|
107 | + if ( empty( $ids ) ) { |
|
108 | 108 | return NULL; |
109 | 109 | } |
110 | 110 | |
111 | 111 | // If it's just one ID, return that. |
112 | 112 | // Otherwise, return array of IDs |
113 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
113 | + return ( sizeof( $ids ) === 1 ) ? $ids[ 0 ] : $ids; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public static function getInstance( $passed_post = NULL ) { |
120 | 120 | |
121 | - if( empty( self::$instance ) ) { |
|
121 | + if ( empty( self::$instance ) ) { |
|
122 | 122 | self::$instance = new GravityView_View_Data( $passed_post ); |
123 | 123 | } |
124 | 124 | |
@@ -131,19 +131,19 @@ discard block |
||
131 | 131 | |
132 | 132 | function get_view( $view_id, $atts = NULL ) { |
133 | 133 | |
134 | - if( ! is_numeric( $view_id) ) { |
|
135 | - do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id) ); |
|
134 | + if ( ! is_numeric( $view_id ) ) { |
|
135 | + do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id ) ); |
|
136 | 136 | return false; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Backup: the view hasn't been fetched yet. Doing it now. |
140 | 140 | if ( ! isset( $this->views[ $view_id ] ) ) { |
141 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id) ); |
|
141 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[get_view] View #%s not set yet.', $view_id ) ); |
|
142 | 142 | return $this->add_view( $view_id, $atts ); |
143 | 143 | } |
144 | 144 | |
145 | 145 | if ( empty( $this->views[ $view_id ] ) ) { |
146 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id) ); |
|
146 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id ) ); |
|
147 | 147 | return false; |
148 | 148 | } |
149 | 149 | |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | function add_view( $view_id, $atts = NULL ) { |
175 | 175 | |
176 | 176 | // Handle array of IDs |
177 | - if( is_array( $view_id ) ) { |
|
178 | - foreach( $view_id as $id ) { |
|
177 | + if ( is_array( $view_id ) ) { |
|
178 | + foreach ( $view_id as $id ) { |
|
179 | 179 | |
180 | 180 | $this->add_view( $id, $atts ); |
181 | 181 | } |
@@ -184,21 +184,21 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | // The view has been set already; returning stored view. |
187 | - if ( !empty( $this->views[ $view_id ] ) ) { |
|
188 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id) ); |
|
187 | + if ( ! empty( $this->views[ $view_id ] ) ) { |
|
188 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id ) ); |
|
189 | 189 | return $this->views[ $view_id ]; |
190 | 190 | } |
191 | 191 | |
192 | - if( ! $this->view_exists( $view_id ) ) { |
|
193 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id) ); |
|
192 | + if ( ! $this->view_exists( $view_id ) ) { |
|
193 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id ) ); |
|
194 | 194 | return false; |
195 | 195 | } |
196 | 196 | |
197 | 197 | $form_id = gravityview_get_form_id( $view_id ); |
198 | 198 | |
199 | - if( empty( $form_id ) ) { |
|
199 | + if ( empty( $form_id ) ) { |
|
200 | 200 | |
201 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id) ); |
|
201 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id ) ); |
|
202 | 202 | |
203 | 203 | return false; |
204 | 204 | } |
@@ -206,21 +206,21 @@ discard block |
||
206 | 206 | // Get the settings for the View ID |
207 | 207 | $view_settings = gravityview_get_template_settings( $view_id ); |
208 | 208 | |
209 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings ); |
|
209 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id ), $view_settings ); |
|
210 | 210 | |
211 | 211 | // Merge the view settings with the defaults |
212 | 212 | $view_defaults = wp_parse_args( $view_settings, self::get_default_args() ); |
213 | 213 | |
214 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults ); |
|
214 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults ); |
|
215 | 215 | |
216 | - if( ! empty( $atts ) && is_array( $atts ) ) { |
|
216 | + if ( ! empty( $atts ) && is_array( $atts ) ) { |
|
217 | 217 | |
218 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts ); |
|
218 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts ); |
|
219 | 219 | |
220 | 220 | // Get the settings from the shortcode and merge them with defaults. |
221 | 221 | $atts = shortcode_atts( $view_defaults, $atts ); |
222 | 222 | |
223 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts ); |
|
223 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts ); |
|
224 | 224 | |
225 | 225 | } else { |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | |
230 | 230 | } |
231 | 231 | |
232 | - unset( $atts['id'], $view_defaults, $view_settings ); |
|
232 | + unset( $atts[ 'id' ], $view_defaults, $view_settings ); |
|
233 | 233 | |
234 | 234 | $data = array( |
235 | 235 | 'id' => $view_id, |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | 'form' => gravityview_get_form( $form_id ), |
243 | 243 | ); |
244 | 244 | |
245 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data ); |
|
245 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] View #%s being added.', $view_id ), $data ); |
|
246 | 246 | |
247 | 247 | $this->views[ $view_id ] = $data; |
248 | 248 | |
@@ -277,15 +277,15 @@ discard block |
||
277 | 277 | */ |
278 | 278 | private function filter_fields( $dir_fields ) { |
279 | 279 | |
280 | - if( empty( $dir_fields ) || !is_array( $dir_fields ) ) { |
|
280 | + if ( empty( $dir_fields ) || ! is_array( $dir_fields ) ) { |
|
281 | 281 | return $dir_fields; |
282 | 282 | } |
283 | 283 | |
284 | - foreach( $dir_fields as $area => $fields ) { |
|
284 | + foreach ( $dir_fields as $area => $fields ) { |
|
285 | 285 | |
286 | - foreach( (array)$fields as $uniqid => $properties ) { |
|
286 | + foreach ( (array)$fields as $uniqid => $properties ) { |
|
287 | 287 | |
288 | - if( $this->hide_field_check_conditions( $properties ) ) { |
|
288 | + if ( $this->hide_field_check_conditions( $properties ) ) { |
|
289 | 289 | unset( $dir_fields[ $area ][ $uniqid ] ); |
290 | 290 | } |
291 | 291 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | private function hide_field_check_conditions( $properties ) { |
308 | 308 | |
309 | 309 | // logged-in visibility |
310 | - if( ! empty( $properties['only_loggedin'] ) && ! GVCommon::has_cap( $properties['only_loggedin_cap'] ) ) { |
|
310 | + if ( ! empty( $properties[ 'only_loggedin' ] ) && ! GVCommon::has_cap( $properties[ 'only_loggedin_cap' ] ) ) { |
|
311 | 311 | return true; |
312 | 312 | } |
313 | 313 | |
@@ -321,14 +321,14 @@ discard block |
||
321 | 321 | // Get the settings from the shortcode and merge them with defaults. |
322 | 322 | $atts = wp_parse_args( $atts, self::get_default_args() ); |
323 | 323 | |
324 | - $view_id = ! empty( $atts['view_id'] ) ? (int)$atts['view_id'] : NULL; |
|
324 | + $view_id = ! empty( $atts[ 'view_id' ] ) ? (int)$atts[ 'view_id' ] : NULL; |
|
325 | 325 | |
326 | - if( empty( $view_id ) && !empty( $atts['id'] ) ) { |
|
327 | - $view_id = (int)$atts['id']; |
|
326 | + if ( empty( $view_id ) && ! empty( $atts[ 'id' ] ) ) { |
|
327 | + $view_id = (int)$atts[ 'id' ]; |
|
328 | 328 | } |
329 | 329 | |
330 | - if( empty( $view_id ) ) { |
|
331 | - do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts ); |
|
330 | + if ( empty( $view_id ) ) { |
|
331 | + do_action( 'gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts ); |
|
332 | 332 | return; |
333 | 333 | } |
334 | 334 | |
@@ -350,44 +350,44 @@ discard block |
||
350 | 350 | * @hack This is so that the shortcode is registered for the oEmbed preview in the Admin |
351 | 351 | * @since 1.6 |
352 | 352 | */ |
353 | - if( ! shortcode_exists('gravityview') && class_exists( 'GravityView_Shortcode' ) ) { |
|
353 | + if ( ! shortcode_exists( 'gravityview' ) && class_exists( 'GravityView_Shortcode' ) ) { |
|
354 | 354 | new GravityView_Shortcode; |
355 | 355 | } |
356 | 356 | |
357 | 357 | $shortcodes = gravityview_has_shortcode_r( $content, 'gravityview' ); |
358 | 358 | |
359 | - if( empty( $shortcodes ) ) { |
|
359 | + if ( empty( $shortcodes ) ) { |
|
360 | 360 | return NULL; |
361 | 361 | } |
362 | 362 | |
363 | - do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes ); |
|
363 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes ); |
|
364 | 364 | |
365 | 365 | $ids = array(); |
366 | 366 | |
367 | - foreach ($shortcodes as $key => $shortcode) { |
|
367 | + foreach ( $shortcodes as $key => $shortcode ) { |
|
368 | 368 | |
369 | - $args = shortcode_parse_atts( $shortcode[3] ); |
|
369 | + $args = shortcode_parse_atts( $shortcode[ 3 ] ); |
|
370 | 370 | |
371 | - if( empty( $args['id'] ) ) { |
|
372 | - do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode ); |
|
371 | + if ( empty( $args[ 'id' ] ) ) { |
|
372 | + do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode ); |
|
373 | 373 | continue; |
374 | 374 | } |
375 | 375 | |
376 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args ); |
|
376 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args[ 'id' ] ), $args ); |
|
377 | 377 | |
378 | 378 | // Store the View to the object for later fetching. |
379 | - $this->add_view( $args['id'], $args ); |
|
379 | + $this->add_view( $args[ 'id' ], $args ); |
|
380 | 380 | |
381 | - $ids[] = $args['id']; |
|
381 | + $ids[ ] = $args[ 'id' ]; |
|
382 | 382 | } |
383 | 383 | |
384 | - if( empty($ids) ) { |
|
384 | + if ( empty( $ids ) ) { |
|
385 | 385 | return NULL; |
386 | 386 | } |
387 | 387 | |
388 | 388 | // If it's just one ID, return that. |
389 | 389 | // Otherwise, return array of IDs |
390 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
390 | + return ( sizeof( $ids ) === 1 ) ? $ids[ 0 ] : $ids; |
|
391 | 391 | |
392 | 392 | } |
393 | 393 | |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | */ |
409 | 409 | $meta_keys = (array)apply_filters( 'gravityview/data/parse/meta_keys', array(), $post_id ); |
410 | 410 | |
411 | - if( empty( $meta_keys ) ) { |
|
411 | + if ( empty( $meta_keys ) ) { |
|
412 | 412 | return NULL; |
413 | 413 | } |
414 | 414 | |
@@ -416,16 +416,16 @@ discard block |
||
416 | 416 | |
417 | 417 | $meta_content = ''; |
418 | 418 | |
419 | - foreach( $meta_keys as $key ) { |
|
420 | - $meta = get_post_meta( $post_id, $key , true ); |
|
421 | - if( ! is_string( $meta ) ) { |
|
419 | + foreach ( $meta_keys as $key ) { |
|
420 | + $meta = get_post_meta( $post_id, $key, true ); |
|
421 | + if ( ! is_string( $meta ) ) { |
|
422 | 422 | continue; |
423 | 423 | } |
424 | 424 | $meta_content .= $meta . ' '; |
425 | 425 | } |
426 | 426 | |
427 | - if( empty( $meta_content ) ) { |
|
428 | - do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys ); |
|
427 | + if ( empty( $meta_content ) ) { |
|
428 | + do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys ); |
|
429 | 429 | return NULL; |
430 | 430 | } |
431 | 431 | |
@@ -452,16 +452,16 @@ discard block |
||
452 | 452 | $message = NULL; |
453 | 453 | |
454 | 454 | // Not invalid if not set! |
455 | - if( empty( $post_id ) || empty( $view_id ) ) { |
|
455 | + if ( empty( $post_id ) || empty( $view_id ) ) { |
|
456 | 456 | |
457 | - if( $empty_is_valid ) { |
|
457 | + if ( $empty_is_valid ) { |
|
458 | 458 | return true; |
459 | 459 | } |
460 | 460 | |
461 | 461 | $message = esc_html__( 'The ID is required.', 'gravityview' ); |
462 | 462 | } |
463 | 463 | |
464 | - if( ! $message ) { |
|
464 | + if ( ! $message ) { |
|
465 | 465 | $status = get_post_status( $post_id ); |
466 | 466 | |
467 | 467 | // Nothing exists with that post ID. |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
476 | - if( ! $message ) { |
|
476 | + if ( ! $message ) { |
|
477 | 477 | |
478 | 478 | // Nothing exists with that post ID. |
479 | 479 | if ( empty( $status ) || in_array( $status, array( 'revision', 'attachment' ) ) ) { |
@@ -482,25 +482,25 @@ discard block |
||
482 | 482 | |
483 | 483 | } |
484 | 484 | |
485 | - if( ! $message ) { |
|
485 | + if ( ! $message ) { |
|
486 | 486 | $view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id ); |
487 | 487 | |
488 | 488 | // The post or page specified does not contain the shortcode. |
489 | - if ( false === in_array( $view_id, (array) $view_ids_in_post ) ) { |
|
489 | + if ( false === in_array( $view_id, (array)$view_ids_in_post ) ) { |
|
490 | 490 | $message = sprintf( esc_html__( 'The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview' ), '<br /><code>[gravityview id="' . intval( $view_id ) . '"]</code>' ); |
491 | 491 | } |
492 | 492 | } |
493 | 493 | |
494 | - if( ! $message ) { |
|
494 | + if ( ! $message ) { |
|
495 | 495 | |
496 | 496 | // It's a View |
497 | - if( 'gravityview' === get_post_type( $post_id ) ) { |
|
498 | - $message = esc_html__( 'The ID is already a View.', 'gravityview' );; |
|
497 | + if ( 'gravityview' === get_post_type( $post_id ) ) { |
|
498 | + $message = esc_html__( 'The ID is already a View.', 'gravityview' ); ; |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | } |
502 | 502 | |
503 | - if( $message ) { |
|
503 | + if ( $message ) { |
|
504 | 504 | return new WP_Error( 'invalid_embed_id', $message ); |
505 | 505 | } |
506 | 506 | |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | |
518 | 518 | $args = self::get_default_args( $with_details ); |
519 | 519 | |
520 | - if( !isset( $args[ $key ] ) ) { return NULL; } |
|
520 | + if ( ! isset( $args[ $key ] ) ) { return NULL; } |
|
521 | 521 | |
522 | 522 | return $args[ $key ]; |
523 | 523 | } |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | */ |
547 | 547 | $default_settings = apply_filters( 'gravityview_default_args', array( |
548 | 548 | 'id' => array( |
549 | - 'label' => __('View ID', 'gravityview'), |
|
549 | + 'label' => __( 'View ID', 'gravityview' ), |
|
550 | 550 | 'type' => 'number', |
551 | 551 | 'group' => 'default', |
552 | 552 | 'value' => NULL, |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | 'show_in_shortcode' => false, |
555 | 555 | ), |
556 | 556 | 'page_size' => array( |
557 | - 'label' => __('Number of entries per page', 'gravityview'), |
|
557 | + 'label' => __( 'Number of entries per page', 'gravityview' ), |
|
558 | 558 | 'type' => 'number', |
559 | 559 | 'class' => 'small-text', |
560 | 560 | 'group' => 'default', |
@@ -578,8 +578,8 @@ discard block |
||
578 | 578 | ), |
579 | 579 | 'admin_show_all_approved' => array( |
580 | 580 | 'label' => __( 'Show all entries to administrators', 'gravityview' ), |
581 | - 'desc' => __('Administrators will be able to see entries with any approval status.', 'gravityview'), |
|
582 | - 'tooltip' => __('Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview'), |
|
581 | + 'desc' => __( 'Administrators will be able to see entries with any approval status.', 'gravityview' ), |
|
582 | + 'tooltip' => __( 'Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview' ), |
|
583 | 583 | 'requires' => 'show_only_approved', |
584 | 584 | 'type' => 'checkbox', |
585 | 585 | 'group' => 'default', |
@@ -604,40 +604,40 @@ discard block |
||
604 | 604 | 'user_edit' => array( |
605 | 605 | 'label' => __( 'Allow User Edit', 'gravityview' ), |
606 | 606 | 'group' => 'default', |
607 | - 'desc' => __('Allow logged-in users to edit entries they created.', 'gravityview'), |
|
607 | + 'desc' => __( 'Allow logged-in users to edit entries they created.', 'gravityview' ), |
|
608 | 608 | 'value' => 0, |
609 | - 'tooltip' => __('Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview'), |
|
609 | + 'tooltip' => __( 'Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview' ), |
|
610 | 610 | 'type' => 'checkbox', |
611 | 611 | 'show_in_shortcode' => true, |
612 | 612 | ), |
613 | 613 | 'user_delete' => array( |
614 | 614 | 'label' => __( 'Allow User Delete', 'gravityview' ), |
615 | 615 | 'group' => 'default', |
616 | - 'desc' => __('Allow logged-in users to delete entries they created.', 'gravityview'), |
|
616 | + 'desc' => __( 'Allow logged-in users to delete entries they created.', 'gravityview' ), |
|
617 | 617 | 'value' => 0, |
618 | - 'tooltip' => __('Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview'), |
|
618 | + 'tooltip' => __( 'Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview' ), |
|
619 | 619 | 'type' => 'checkbox', |
620 | 620 | 'show_in_shortcode' => true, |
621 | 621 | ), |
622 | 622 | 'sort_field' => array( |
623 | - 'label' => __('Sort by field', 'gravityview'), |
|
623 | + 'label' => __( 'Sort by field', 'gravityview' ), |
|
624 | 624 | 'type' => 'select', |
625 | 625 | 'value' => '', |
626 | 626 | 'group' => 'sort', |
627 | 627 | 'options' => array( |
628 | - '' => __( 'Default', 'gravityview'), |
|
629 | - 'date_created' => __( 'Date Created', 'gravityview'), |
|
628 | + '' => __( 'Default', 'gravityview' ), |
|
629 | + 'date_created' => __( 'Date Created', 'gravityview' ), |
|
630 | 630 | ), |
631 | 631 | 'show_in_shortcode' => true, |
632 | 632 | ), |
633 | 633 | 'sort_direction' => array( |
634 | - 'label' => __('Sort direction', 'gravityview'), |
|
634 | + 'label' => __( 'Sort direction', 'gravityview' ), |
|
635 | 635 | 'type' => 'select', |
636 | 636 | 'value' => 'ASC', |
637 | 637 | 'group' => 'sort', |
638 | 638 | 'options' => array( |
639 | - 'ASC' => __('ASC', 'gravityview'), |
|
640 | - 'DESC' => __('DESC', 'gravityview'), |
|
639 | + 'ASC' => __( 'ASC', 'gravityview' ), |
|
640 | + 'DESC' => __( 'DESC', 'gravityview' ), |
|
641 | 641 | //'RAND' => __('Random', 'gravityview'), |
642 | 642 | ), |
643 | 643 | 'show_in_shortcode' => true, |
@@ -653,69 +653,69 @@ discard block |
||
653 | 653 | 'show_in_template' => array( 'default_table' ), |
654 | 654 | ), |
655 | 655 | 'start_date' => array( |
656 | - 'label' => __('Filter by Start Date', 'gravityview'), |
|
656 | + 'label' => __( 'Filter by Start Date', 'gravityview' ), |
|
657 | 657 | 'class' => 'gv-datepicker', |
658 | - 'desc' => __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
658 | + 'desc' => __( 'Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
659 | 659 | 'type' => 'text', |
660 | 660 | 'value' => '', |
661 | 661 | 'group' => 'filter', |
662 | 662 | 'show_in_shortcode' => true, |
663 | 663 | ), |
664 | 664 | 'end_date' => array( |
665 | - 'label' => __('Filter by End Date', 'gravityview'), |
|
665 | + 'label' => __( 'Filter by End Date', 'gravityview' ), |
|
666 | 666 | 'class' => 'gv-datepicker', |
667 | - 'desc' => __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
667 | + 'desc' => __( 'Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
668 | 668 | 'type' => 'text', |
669 | 669 | 'value' => '', |
670 | 670 | 'group' => 'filter', |
671 | 671 | 'show_in_shortcode' => true, |
672 | 672 | ), |
673 | 673 | 'class' => array( |
674 | - 'label' => __('CSS Class', 'gravityview'), |
|
675 | - 'desc' => __('CSS class to add to the wrapping HTML container.', 'gravityview'), |
|
674 | + 'label' => __( 'CSS Class', 'gravityview' ), |
|
675 | + 'desc' => __( 'CSS class to add to the wrapping HTML container.', 'gravityview' ), |
|
676 | 676 | 'group' => 'default', |
677 | 677 | 'type' => 'text', |
678 | 678 | 'value' => '', |
679 | 679 | 'show_in_shortcode' => false, |
680 | 680 | ), |
681 | 681 | 'search_value' => array( |
682 | - 'label' => __('Search Value', 'gravityview'), |
|
683 | - 'desc' => __('Define a default search value for the View', 'gravityview'), |
|
682 | + 'label' => __( 'Search Value', 'gravityview' ), |
|
683 | + 'desc' => __( 'Define a default search value for the View', 'gravityview' ), |
|
684 | 684 | 'type' => 'text', |
685 | 685 | 'value' => '', |
686 | 686 | 'group' => 'filter', |
687 | 687 | 'show_in_shortcode' => false, |
688 | 688 | ), |
689 | 689 | 'search_field' => array( |
690 | - 'label' => __('Search Field', 'gravityview'), |
|
691 | - 'desc' => __('If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview'), |
|
690 | + 'label' => __( 'Search Field', 'gravityview' ), |
|
691 | + 'desc' => __( 'If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview' ), |
|
692 | 692 | 'type' => 'number', |
693 | 693 | 'value' => '', |
694 | 694 | 'group' => 'filter', |
695 | 695 | 'show_in_shortcode' => false, |
696 | 696 | ), |
697 | 697 | 'single_title' => array( |
698 | - 'label' => __('Single Entry Title', 'gravityview'), |
|
698 | + 'label' => __( 'Single Entry Title', 'gravityview' ), |
|
699 | 699 | 'type' => 'text', |
700 | - 'desc' => __('When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview'), |
|
700 | + 'desc' => __( 'When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview' ), |
|
701 | 701 | 'group' => 'default', |
702 | 702 | 'value' => '', |
703 | 703 | 'show_in_shortcode' => false, |
704 | 704 | 'full_width' => true, |
705 | 705 | ), |
706 | 706 | 'back_link_label' => array( |
707 | - 'label' => __('Back Link Label', 'gravityview'), |
|
707 | + 'label' => __( 'Back Link Label', 'gravityview' ), |
|
708 | 708 | 'group' => 'default', |
709 | - 'desc' => __('The text of the link that returns to the multiple entries view.', 'gravityview'), |
|
709 | + 'desc' => __( 'The text of the link that returns to the multiple entries view.', 'gravityview' ), |
|
710 | 710 | 'type' => 'text', |
711 | 711 | 'value' => '', |
712 | 712 | 'show_in_shortcode' => false, |
713 | 713 | 'full_width' => true, |
714 | 714 | ), |
715 | 715 | 'embed_only' => array( |
716 | - 'label' => __('Prevent Direct Access', 'gravityview'), |
|
716 | + 'label' => __( 'Prevent Direct Access', 'gravityview' ), |
|
717 | 717 | 'group' => 'default', |
718 | - 'desc' => __('Only allow access to this View when embedded using the shortcode.', 'gravityview'), |
|
718 | + 'desc' => __( 'Only allow access to this View when embedded using the shortcode.', 'gravityview' ), |
|
719 | 719 | 'type' => 'checkbox', |
720 | 720 | 'value' => '', |
721 | 721 | 'show_in_shortcode' => false, |
@@ -726,15 +726,15 @@ discard block |
||
726 | 726 | 'value' => '', |
727 | 727 | 'show_in_shortcode' => false, |
728 | 728 | ), |
729 | - )); |
|
729 | + ) ); |
|
730 | 730 | |
731 | 731 | // By default, we only want the key => value pairing, not the whole array. |
732 | - if( empty( $with_details ) ) { |
|
732 | + if ( empty( $with_details ) ) { |
|
733 | 733 | |
734 | 734 | $defaults = array(); |
735 | 735 | |
736 | - foreach( $default_settings as $key => $value ) { |
|
737 | - $defaults[ $key ] = $value['value']; |
|
736 | + foreach ( $default_settings as $key => $value ) { |
|
737 | + $defaults[ $key ] = $value[ 'value' ]; |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | return $defaults; |
@@ -743,12 +743,12 @@ discard block |
||
743 | 743 | // But sometimes, we want all the details. |
744 | 744 | else { |
745 | 745 | |
746 | - foreach ($default_settings as $key => $value) { |
|
746 | + foreach ( $default_settings as $key => $value ) { |
|
747 | 747 | |
748 | 748 | // If the $group argument is set for the method, |
749 | 749 | // ignore any settings that aren't in that group. |
750 | - if( !empty( $group ) && is_string( $group ) ) { |
|
751 | - if( empty( $value['group'] ) || $value['group'] !== $group ) { |
|
750 | + if ( ! empty( $group ) && is_string( $group ) ) { |
|
751 | + if ( empty( $value[ 'group' ] ) || $value[ 'group' ] !== $group ) { |
|
752 | 752 | unset( $default_settings[ $key ] ); |
753 | 753 | } |
754 | 754 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return GV_License_Handler |
41 | 41 | */ |
42 | 42 | public static function get_instance( GravityView_Settings $GFAddOn ) { |
43 | - if( empty( self::$instance ) ) { |
|
43 | + if ( empty( self::$instance ) ) { |
|
44 | 44 | self::$instance = new self( $GFAddOn ); |
45 | 45 | } |
46 | 46 | return self::$instance; |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | public function refresh_license_status() { |
71 | 71 | |
72 | 72 | // Only perform on GravityView pages |
73 | - if( ! gravityview_is_admin_page() ) { |
|
73 | + if ( ! gravityview_is_admin_page() ) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
77 | 77 | // The transient is fresh; don't fetch. |
78 | - if( $status = get_transient( self::status_transient_key ) ) { |
|
78 | + if ( $status = get_transient( self::status_transient_key ) ) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
@@ -101,37 +101,37 @@ discard block |
||
101 | 101 | $status = trim( $this->Addon->get_app_setting( 'license_key_status' ) ); |
102 | 102 | $key = trim( $this->Addon->get_app_setting( 'license_key' ) ); |
103 | 103 | |
104 | - if( !empty( $key ) ) { |
|
104 | + if ( ! empty( $key ) ) { |
|
105 | 105 | $response = $this->Addon->get_app_setting( 'license_key_response' ); |
106 | - $response = is_array( $response ) ? (object) $response : json_decode( $response ); |
|
106 | + $response = is_array( $response ) ? (object)$response : json_decode( $response ); |
|
107 | 107 | } else { |
108 | 108 | $response = array(); |
109 | 109 | } |
110 | 110 | |
111 | 111 | wp_localize_script( 'gv-admin-edd-license', 'GVGlobals', array( |
112 | 112 | 'license_box' => $this->get_license_message( $response ) |
113 | - )); |
|
113 | + ) ); |
|
114 | 114 | |
115 | 115 | |
116 | 116 | $fields = array( |
117 | 117 | array( |
118 | 118 | 'name' => 'edd-activate', |
119 | - 'value' => __('Activate License', 'gravityview'), |
|
120 | - 'data-pending_text' => __('Verifying license…', 'gravityview'), |
|
119 | + 'value' => __( 'Activate License', 'gravityview' ), |
|
120 | + 'data-pending_text' => __( 'Verifying license…', 'gravityview' ), |
|
121 | 121 | 'data-edd_action' => 'activate_license', |
122 | 122 | 'class' => 'button-primary', |
123 | 123 | ), |
124 | 124 | array( |
125 | 125 | 'name' => 'edd-deactivate', |
126 | - 'value' => __('Deactivate License', 'gravityview'), |
|
127 | - 'data-pending_text' => __('Deactivating license…', 'gravityview'), |
|
126 | + 'value' => __( 'Deactivate License', 'gravityview' ), |
|
127 | + 'data-pending_text' => __( 'Deactivating license…', 'gravityview' ), |
|
128 | 128 | 'data-edd_action' => 'deactivate_license', |
129 | 129 | 'class' => ( empty( $status ) ? 'button-primary hide' : 'button-primary' ), |
130 | 130 | ), |
131 | 131 | array( |
132 | 132 | 'name' => 'edd-check', |
133 | - 'value' => __('Check License', 'gravityview'), |
|
134 | - 'data-pending_text' => __('Verifying license…', 'gravityview'), |
|
133 | + 'value' => __( 'Check License', 'gravityview' ), |
|
134 | + 'data-pending_text' => __( 'Verifying license…', 'gravityview' ), |
|
135 | 135 | 'title' => 'Check the license before saving it', |
136 | 136 | 'data-edd_action' => 'check_license', |
137 | 137 | 'class' => 'button-secondary', |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | |
142 | 142 | $class = 'button gv-edd-action'; |
143 | 143 | |
144 | - $class .= ( !empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
144 | + $class .= ( ! empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
145 | 145 | |
146 | 146 | $disabled_attribute = GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled'; |
147 | 147 | |
148 | 148 | $submit = '<div class="gv-edd-button-wrapper">'; |
149 | 149 | foreach ( $fields as $field ) { |
150 | - $field['type'] = 'button'; |
|
151 | - $field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class; |
|
152 | - $field['style'] = 'margin-left: 10px;'; |
|
153 | - if( $disabled_attribute ) { |
|
154 | - $field['disabled'] = $disabled_attribute; |
|
150 | + $field[ 'type' ] = 'button'; |
|
151 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] . ' ' . $class : $class; |
|
152 | + $field[ 'style' ] = 'margin-left: 10px;'; |
|
153 | + if ( $disabled_attribute ) { |
|
154 | + $field[ 'disabled' ] = $disabled_attribute; |
|
155 | 155 | } |
156 | 156 | $submit .= $this->Addon->settings_submit( $field, $echo ); |
157 | 157 | } |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | */ |
168 | 168 | private function setup_edd() { |
169 | 169 | |
170 | - if( !class_exists('EDD_SL_Plugin_Updater') ) { |
|
171 | - require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php'); |
|
170 | + if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
171 | + require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php' ); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // setup the updater |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | 'url' => home_url(), |
206 | 206 | ); |
207 | 207 | |
208 | - if( !empty( $action ) ) { |
|
209 | - $settings['edd_action'] = esc_attr( $action ); |
|
208 | + if ( ! empty( $action ) ) { |
|
209 | + $settings[ 'edd_action' ] = esc_attr( $action ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | $settings = array_map( 'urlencode', $settings ); |
@@ -220,14 +220,14 @@ discard block |
||
220 | 220 | */ |
221 | 221 | private function _license_get_remote_response( $data, $license = '' ) { |
222 | 222 | |
223 | - $api_params = $this->_get_edd_settings( $data['edd_action'], $license ); |
|
223 | + $api_params = $this->_get_edd_settings( $data[ 'edd_action' ], $license ); |
|
224 | 224 | |
225 | 225 | $url = add_query_arg( $api_params, self::url ); |
226 | 226 | |
227 | 227 | $response = wp_remote_get( $url, array( |
228 | 228 | 'timeout' => 15, |
229 | 229 | 'sslverify' => false, |
230 | - )); |
|
230 | + ) ); |
|
231 | 231 | |
232 | 232 | if ( is_wp_error( $response ) ) { |
233 | 233 | return array(); |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | */ |
261 | 261 | function get_license_message( $license_data ) { |
262 | 262 | |
263 | - if( empty( $license_data ) ) { |
|
263 | + if ( empty( $license_data ) ) { |
|
264 | 264 | $message = ''; |
265 | 265 | } else { |
266 | 266 | |
267 | - if( ! empty( $license_data->error ) ) { |
|
267 | + if ( ! empty( $license_data->error ) ) { |
|
268 | 268 | $class = 'error'; |
269 | 269 | $string_key = $license_data->error; |
270 | 270 | } else { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $string_key = $license_data->license; |
273 | 273 | } |
274 | 274 | |
275 | - $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings( $string_key, $license_data ) ); |
|
275 | + $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings( 'status' ), $this->strings( $string_key, $license_data ) ); |
|
276 | 276 | |
277 | 277 | $message = $this->generate_license_box( $message, $class ); |
278 | 278 | } |
@@ -309,18 +309,18 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public function license_details( $response = array() ) { |
311 | 311 | |
312 | - $response = (array) $response; |
|
312 | + $response = (array)$response; |
|
313 | 313 | |
314 | 314 | $return = ''; |
315 | 315 | $wrapper = '<span class="gv-license-details" aria-live="polite" aria-busy="false">%s</span>'; |
316 | 316 | |
317 | - if( ! empty( $response['license_key'] ) ) { |
|
317 | + if ( ! empty( $response[ 'license_key' ] ) ) { |
|
318 | 318 | |
319 | 319 | $return .= '<h3>' . esc_html__( 'License Details:', 'gravityview' ) . '</h3>'; |
320 | 320 | |
321 | 321 | if ( in_array( rgar( $response, 'license' ), array( 'invalid', 'deactivated' ) ) ) { |
322 | - $return .= $this->strings( $response['license'], $response ); |
|
323 | - } elseif ( ! empty( $response['license_name'] ) ) { |
|
322 | + $return .= $this->strings( $response[ 'license' ], $response ); |
|
323 | + } elseif ( ! empty( $response[ 'license_name' ] ) ) { |
|
324 | 324 | |
325 | 325 | $response_keys = array( |
326 | 326 | 'license_name' => '', |
@@ -335,19 +335,19 @@ discard block |
||
335 | 335 | // Make sure all the keys are set |
336 | 336 | $response = wp_parse_args( $response, $response_keys ); |
337 | 337 | |
338 | - $login_link = sprintf( '<a href="%s" class="howto" rel="external">%s</a>', esc_url( sprintf( 'https://gravityview.co/wp-login.php?username=%s', $response['customer_email'] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) ); |
|
339 | - $local_text = ( ! empty( $response['is_local'] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
338 | + $login_link = sprintf( '<a href="%s" class="howto" rel="external">%s</a>', esc_url( sprintf( 'https://gravityview.co/wp-login.php?username=%s', $response[ 'customer_email' ] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) ); |
|
339 | + $local_text = ( ! empty( $response[ 'is_local' ] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
340 | 340 | $details = array( |
341 | - 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), esc_html( $response['license_name'] ), esc_html( $response['license_limit'] ) ), |
|
342 | - 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), esc_html__( $response['customer_name'], 'gravityview' ), esc_html__( $response['customer_email'], 'gravityview' ) ) . $login_link, |
|
343 | - 'activations' => sprintf( esc_html__( 'Activations: %d of %s sites', 'gravityview' ), intval( $response['site_count'] ), esc_html( $response['license_limit'] ) ) . $local_text, |
|
344 | - 'expires' => 'lifetime' === $response['expires'] ? '' : sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response['expires'] ) - DAY_IN_SECONDS ) ), |
|
345 | - 'upgrade' => $this->get_upgrade_html( $response['upgrades'] ), |
|
341 | + 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), esc_html( $response[ 'license_name' ] ), esc_html( $response[ 'license_limit' ] ) ), |
|
342 | + 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), esc_html__( $response[ 'customer_name' ], 'gravityview' ), esc_html__( $response[ 'customer_email' ], 'gravityview' ) ) . $login_link, |
|
343 | + 'activations' => sprintf( esc_html__( 'Activations: %d of %s sites', 'gravityview' ), intval( $response[ 'site_count' ] ), esc_html( $response[ 'license_limit' ] ) ) . $local_text, |
|
344 | + 'expires' => 'lifetime' === $response[ 'expires' ] ? '' : sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response[ 'expires' ] ) - DAY_IN_SECONDS ) ), |
|
345 | + 'upgrade' => $this->get_upgrade_html( $response[ 'upgrades' ] ), |
|
346 | 346 | ); |
347 | 347 | |
348 | - if ( ! empty( $response['error'] ) && 'expired' === $response['error'] ) { |
|
349 | - unset( $details['upgrade'] ); |
|
350 | - $details['expires'] = '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
348 | + if ( ! empty( $response[ 'error' ] ) && 'expired' === $response[ 'error' ] ) { |
|
349 | + unset( $details[ 'upgrade' ] ); |
|
350 | + $details[ 'expires' ] = '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | $return .= '<ul><li>' . implode( '</li><li>', array_filter( $details ) ) . '</li></ul>'; |
@@ -370,11 +370,11 @@ discard block |
||
370 | 370 | |
371 | 371 | $output = ''; |
372 | 372 | |
373 | - if( ! empty( $upgrades ) ) { |
|
373 | + if ( ! empty( $upgrades ) ) { |
|
374 | 374 | |
375 | 375 | $locale_parts = explode( '_', get_locale() ); |
376 | 376 | |
377 | - $is_english = ( 'en' === $locale_parts[0] ); |
|
377 | + $is_english = ( 'en' === $locale_parts[ 0 ] ); |
|
378 | 378 | |
379 | 379 | $output .= '<h4>' . esc_html__( 'Upgrades available:', 'gravityview' ) . '</h4>'; |
380 | 380 | |
@@ -382,14 +382,14 @@ discard block |
||
382 | 382 | |
383 | 383 | foreach ( $upgrades as $upgrade_id => $upgrade ) { |
384 | 384 | |
385 | - $upgrade = (object) $upgrade; |
|
385 | + $upgrade = (object)$upgrade; |
|
386 | 386 | |
387 | 387 | $anchor_text = sprintf( esc_html_x( 'Upgrade to %1$s for %2$s', '1: GravityView upgrade name, 2: Cost of upgrade', 'gravityview' ), esc_attr( $upgrade->name ), esc_attr( $upgrade->price ) ); |
388 | 388 | |
389 | - if( $is_english && isset( $upgrade->description ) ) { |
|
389 | + if ( $is_english && isset( $upgrade->description ) ) { |
|
390 | 390 | $message = esc_html( $upgrade->description ); |
391 | 391 | } else { |
392 | - switch( $upgrade->price_id ) { |
|
392 | + switch ( $upgrade->price_id ) { |
|
393 | 393 | // Interstellar |
394 | 394 | case 1: |
395 | 395 | default: |
@@ -427,16 +427,16 @@ discard block |
||
427 | 427 | */ |
428 | 428 | public function license_call( $array = array() ) { |
429 | 429 | |
430 | - $is_ajax = ( defined('DOING_AJAX') && DOING_AJAX ); |
|
431 | - $data = empty( $array ) ? $_POST['data'] : $array; |
|
430 | + $is_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
431 | + $data = empty( $array ) ? $_POST[ 'data' ] : $array; |
|
432 | 432 | $has_cap = GVCommon::has_cap( 'gravityview_edit_settings' ); |
433 | 433 | |
434 | - if ( $is_ajax && empty( $data['license'] ) ) { |
|
435 | - die( - 1 ); |
|
434 | + if ( $is_ajax && empty( $data[ 'license' ] ) ) { |
|
435 | + die( -1 ); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | // If the user isn't allowed to edit settings, show an error message |
439 | - if( ! $has_cap ) { |
|
439 | + if ( ! $has_cap ) { |
|
440 | 440 | $license_data = new stdClass(); |
441 | 441 | $license_data->error = 'capability'; |
442 | 442 | $license_data->message = $this->get_license_message( $license_data ); |
@@ -460,9 +460,9 @@ discard block |
||
460 | 460 | |
461 | 461 | $json = json_encode( $license_data ); |
462 | 462 | |
463 | - $update_license = ( ! isset( $data['update'] ) || ! empty( $data['update'] ) ); |
|
463 | + $update_license = ( ! isset( $data[ 'update' ] ) || ! empty( $data[ 'update' ] ) ); |
|
464 | 464 | |
465 | - $is_check_action_button = ( 'check_license' === $data['edd_action'] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
465 | + $is_check_action_button = ( 'check_license' === $data[ 'edd_action' ] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
466 | 466 | |
467 | 467 | // Failed is the response from trying to de-activate a license and it didn't work. |
468 | 468 | // This likely happened because people entered in a different key and clicked "Deactivate", |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | // most likely a mistake. |
471 | 471 | if ( $license_data->license !== 'failed' && ! $is_check_action_button && $update_license ) { |
472 | 472 | |
473 | - if ( ! empty( $data['field_id'] ) ) { |
|
473 | + if ( ! empty( $data[ 'field_id' ] ) ) { |
|
474 | 474 | set_transient( self::status_transient_key, $license_data, DAY_IN_SECONDS ); |
475 | 475 | } |
476 | 476 | |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | if ( $is_ajax ) { |
482 | 482 | exit( $json ); |
483 | 483 | } else { // Non-ajax call |
484 | - return ( rgget('format', $data ) === 'object' ) ? $license_data : $json; |
|
484 | + return ( rgget( 'format', $data ) === 'object' ) ? $license_data : $json; |
|
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
@@ -495,9 +495,9 @@ discard block |
||
495 | 495 | // Update option with passed data license |
496 | 496 | $settings = $this->Addon->get_app_settings(); |
497 | 497 | |
498 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
499 | - $settings['license_key_status'] = $license_data->license; |
|
500 | - $settings['license_key_response'] = (array)$license_data; |
|
498 | + $settings[ 'license_key' ] = $license_data->license_key = trim( $data[ 'license' ] ); |
|
499 | + $settings[ 'license_key_status' ] = $license_data->license; |
|
500 | + $settings[ 'license_key_response' ] = (array)$license_data; |
|
501 | 501 | |
502 | 502 | $this->Addon->update_app_settings( $settings ); |
503 | 503 | } |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | */ |
511 | 511 | private function get_license_renewal_url( $license_data ) { |
512 | 512 | $license_data = is_array( $license_data ) ? (object)$license_data : $license_data; |
513 | - $renew_license_url = ( ! empty( $license_data ) && !empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation&force_login=1', $license_data->license_key ) : 'https://gravityview.co/account/'; |
|
513 | + $renew_license_url = ( ! empty( $license_data ) && ! empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation&force_login=1', $license_data->license_key ) : 'https://gravityview.co/account/'; |
|
514 | 514 | return $renew_license_url; |
515 | 515 | } |
516 | 516 | |
@@ -525,31 +525,31 @@ discard block |
||
525 | 525 | |
526 | 526 | |
527 | 527 | $strings = array( |
528 | - 'status' => esc_html__('Status', 'gravityview'), |
|
529 | - 'error' => esc_html__('There was an error processing the request.', 'gravityview'), |
|
530 | - 'failed' => esc_html__('Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview'), |
|
531 | - 'site_inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), |
|
532 | - 'inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), |
|
533 | - 'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview') . ' ' . sprintf( esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
534 | - 'deactivated' => esc_html__('The license has been deactivated.', 'gravityview'), |
|
535 | - 'valid' => esc_html__('The license key is valid and active.', 'gravityview'), |
|
536 | - 'invalid' => esc_html__('The license key entered is invalid.', 'gravityview'), |
|
537 | - 'missing' => esc_html__('Invalid license key.', 'gravityview'), |
|
538 | - 'revoked' => esc_html__('This license key has been revoked.', 'gravityview'), |
|
539 | - 'expired' => sprintf( esc_html__('This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview'), '<a href="'. esc_url( $this->get_license_renewal_url( $license_data ) ) .'">', '</a>' ), |
|
528 | + 'status' => esc_html__( 'Status', 'gravityview' ), |
|
529 | + 'error' => esc_html__( 'There was an error processing the request.', 'gravityview' ), |
|
530 | + 'failed' => esc_html__( 'Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview' ), |
|
531 | + 'site_inactive' => esc_html__( 'The license key is valid, but it has not been activated for this site.', 'gravityview' ), |
|
532 | + 'inactive' => esc_html__( 'The license key is valid, but it has not been activated for this site.', 'gravityview' ), |
|
533 | + 'no_activations_left' => esc_html__( 'Invalid: this license has reached its activation limit.', 'gravityview' ) . ' ' . sprintf( esc_html__( 'You can manage license activations %son your GravityView account page%s.', 'gravityview' ), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
534 | + 'deactivated' => esc_html__( 'The license has been deactivated.', 'gravityview' ), |
|
535 | + 'valid' => esc_html__( 'The license key is valid and active.', 'gravityview' ), |
|
536 | + 'invalid' => esc_html__( 'The license key entered is invalid.', 'gravityview' ), |
|
537 | + 'missing' => esc_html__( 'Invalid license key.', 'gravityview' ), |
|
538 | + 'revoked' => esc_html__( 'This license key has been revoked.', 'gravityview' ), |
|
539 | + 'expired' => sprintf( esc_html__( 'This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview' ), '<a href="' . esc_url( $this->get_license_renewal_url( $license_data ) ) . '">', '</a>' ), |
|
540 | 540 | 'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ), |
541 | 541 | |
542 | - 'verifying_license' => esc_html__('Verifying license…', 'gravityview'), |
|
543 | - 'activate_license' => esc_html__('Activate License', 'gravityview'), |
|
544 | - 'deactivate_license' => esc_html__('Deactivate License', 'gravityview'), |
|
545 | - 'check_license' => esc_html__('Verify License', 'gravityview'), |
|
542 | + 'verifying_license' => esc_html__( 'Verifying license…', 'gravityview' ), |
|
543 | + 'activate_license' => esc_html__( 'Activate License', 'gravityview' ), |
|
544 | + 'deactivate_license' => esc_html__( 'Deactivate License', 'gravityview' ), |
|
545 | + 'check_license' => esc_html__( 'Verify License', 'gravityview' ), |
|
546 | 546 | ); |
547 | 547 | |
548 | - if( empty( $status ) ) { |
|
548 | + if ( empty( $status ) ) { |
|
549 | 549 | return $strings; |
550 | 550 | } |
551 | 551 | |
552 | - if( isset( $strings[ $status ] ) ) { |
|
552 | + if ( isset( $strings[ $status ] ) ) { |
|
553 | 553 | return $strings[ $status ]; |
554 | 554 | } |
555 | 555 |