@@ -11,13 +11,13 @@ discard block |
||
11 | 11 | wp_nonce_field( 'gravityview_select_form', 'gravityview_select_form_nonce' ); |
12 | 12 | |
13 | 13 | //current value |
14 | -$current_form = (int) rgar( (array) $_GET, 'form_id', gravityview_get_form_id( $post->ID ) ); |
|
14 | +$current_form = (int)rgar( (array)$_GET, 'form_id', gravityview_get_form_id( $post->ID ) ); |
|
15 | 15 | |
16 | 16 | // If form is in trash or not existing, show error |
17 | 17 | GravityView_Admin::connected_form_warning( $current_form ); |
18 | 18 | |
19 | 19 | // check for available gravity forms |
20 | -$forms = gravityview_get_forms('any'); |
|
20 | +$forms = gravityview_get_forms( 'any' ); |
|
21 | 21 | ?> |
22 | 22 | <label for="gravityview_form_id" ><?php esc_html_e( 'Where would you like the data to come from for this View?', 'gravityview' ); ?></label> |
23 | 23 | |
@@ -28,24 +28,24 @@ discard block |
||
28 | 28 | ?> |
29 | 29 | <a class="button button-primary" href="#gv_start_fresh" title="<?php esc_attr_e( 'Use a Form Preset', 'gravityview' ); ?>"><?php esc_html_e( 'Use a Form Preset', 'gravityview' ); ?></a> |
30 | 30 | |
31 | - <?php if( !empty( $forms ) ) { ?> |
|
31 | + <?php if ( ! empty( $forms ) ) { ?> |
|
32 | 32 | <span> <?php esc_html_e( 'or use an existing form', 'gravityview' ); ?> </span> |
33 | 33 | <?php } |
34 | 34 | } |
35 | 35 | |
36 | 36 | // If there are no forms to select, show no forms. |
37 | - if( !empty( $forms ) ) { ?> |
|
37 | + if ( ! empty( $forms ) ) { ?> |
|
38 | 38 | <select name="gravityview_form_id" id="gravityview_form_id"> |
39 | 39 | <option value="" <?php selected( '', $current_form, true ); ?>>— <?php esc_html_e( 'list of forms', 'gravityview' ); ?> —</option> |
40 | - <?php foreach( $forms as $form ) { ?> |
|
41 | - <option value="<?php echo $form['id']; ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option> |
|
40 | + <?php foreach ( $forms as $form ) { ?> |
|
41 | + <option value="<?php echo $form[ 'id' ]; ?>" <?php selected( $form[ 'id' ], $current_form, true ); ?>><?php echo esc_html( $form[ 'title' ] ); ?></option> |
|
42 | 42 | <?php } ?> |
43 | 43 | </select> |
44 | 44 | <?php } else { ?> |
45 | 45 | <select name="gravityview_form_id" id="gravityview_form_id" class="hidden"><option selected="selected" value=""></option></select> |
46 | 46 | <?php } ?> |
47 | 47 | |
48 | - <a class="button button-primary" <?php if( empty( $current_form ) ) { echo 'style="display:none;"'; } ?> id="gv_switch_view_button" href="#gv_switch_view" title="<?php esc_attr_e( 'Switch View', 'gravityview' ); ?>"><?php esc_html_e( 'Switch View Type', 'gravityview' ); ?></a> |
|
48 | + <a class="button button-primary" <?php if ( empty( $current_form ) ) { echo 'style="display:none;"'; } ?> id="gv_switch_view_button" href="#gv_switch_view" title="<?php esc_attr_e( 'Switch View', 'gravityview' ); ?>"><?php esc_html_e( 'Switch View Type', 'gravityview' ); ?></a> |
|
49 | 49 | </p> |
50 | 50 | |
51 | 51 | <?php // confirm dialog box ?> |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return array Blacklist, with "total" added. If not edit context, original field blacklist. Otherwise, blacklist including total. |
52 | 52 | */ |
53 | - public function add_to_blacklist( $blacklist = array(), $context = NULL ){ |
|
53 | + public function add_to_blacklist( $blacklist = array(), $context = NULL ) { |
|
54 | 54 | |
55 | - if( empty( $context ) || $context !== 'edit' ) { |
|
55 | + if ( empty( $context ) || $context !== 'edit' ) { |
|
56 | 56 | return $blacklist; |
57 | 57 | } |
58 | 58 | |
59 | - $blacklist[] = 'total'; |
|
59 | + $blacklist[ ] = 'total'; |
|
60 | 60 | |
61 | 61 | return $blacklist; |
62 | 62 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | function edit_entry_recalculate_totals( $form = array(), $entry_id = 0, $Edit_Entry_Render = null ) { |
76 | 76 | |
77 | - $original_form = GFAPI::get_form( $form['id'] ); |
|
77 | + $original_form = GFAPI::get_form( $form[ 'id' ] ); |
|
78 | 78 | |
79 | 79 | $total_fields = GFCommon::get_fields_by_type( $original_form, 'total' ); |
80 | 80 | |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | |
86 | 86 | /** @var GF_Field_Total $total_field */ |
87 | 87 | foreach ( $total_fields as $total_field ) { |
88 | - $entry["{$total_field->id}"] = GFCommon::get_order_total( $original_form, $entry ); |
|
88 | + $entry[ "{$total_field->id}" ] = GFCommon::get_order_total( $original_form, $entry ); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | $return_entry = GFAPI::update_entry( $entry ); |
92 | 92 | |
93 | - if( is_wp_error( $return_entry ) ) { |
|
93 | + if ( is_wp_error( $return_entry ) ) { |
|
94 | 94 | do_action( 'gravityview_log_error', __METHOD__ . ': Updating the entry total fields failed', $return_entry ); |
95 | 95 | } else { |
96 | 96 | do_action( 'gravityview_log_debug', __METHOD__ . ': Updating the entry total fields succeeded' ); |
@@ -50,7 +50,7 @@ |
||
50 | 50 | * |
51 | 51 | * @return array Blacklist, with "total" added. If not edit context, original field blacklist. Otherwise, blacklist including total. |
52 | 52 | */ |
53 | - public function add_to_blacklist( $blacklist = array(), $context = NULL ){ |
|
53 | + public function add_to_blacklist( $blacklist = array(), $context = NULL ) { |
|
54 | 54 | |
55 | 55 | if( empty( $context ) || $context !== 'edit' ) { |
56 | 56 | return $blacklist; |
@@ -313,6 +313,7 @@ |
||
313 | 313 | * Add a callback for lazy loading/counting. |
314 | 314 | * |
315 | 315 | * @param callable $callback The callback to call when needed. |
316 | + * @param string $type |
|
316 | 317 | * |
317 | 318 | * @return void |
318 | 319 | */ |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | |
104 | 104 | /** Call all lazy callbacks. */ |
105 | 105 | foreach ( $this->callbacks as $callback ) { |
106 | - if ( $callback[0] != 'count' ) { |
|
106 | + if ( $callback[ 0 ] != 'count' ) { |
|
107 | 107 | continue; |
108 | 108 | } |
109 | 109 | |
110 | - $total += $callback[1]( $this->filters ); |
|
110 | + $total += $callback[ 1 ]( $this->filters ); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return $total - $this->offset; |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | |
162 | 162 | /** Call all lazy callbacks. */ |
163 | 163 | foreach ( $this->callbacks as $i => $callback ) { |
164 | - if ( $callback[0] != 'fetch' ) { |
|
164 | + if ( $callback[ 0 ] != 'fetch' ) { |
|
165 | 165 | continue; |
166 | 166 | } |
167 | 167 | |
168 | - $this->merge( $callback[1]( $this->filters, $this->sorts, $offset ) ); |
|
168 | + $this->merge( $callback[ 1 ]( $this->filters, $this->sorts, $offset ) ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | $this->fetched = $this->count(); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | return; |
322 | 322 | } |
323 | 323 | |
324 | - $this->callbacks []= array( $type, $callback ); |
|
324 | + $this->callbacks [ ] = array( $type, $callback ); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | /** |
@@ -38,7 +38,6 @@ |
||
38 | 38 | * Set an setting. |
39 | 39 | * |
40 | 40 | * @param mixed $key The key in this setting to retrieve. |
41 | - * @param mixed $default A default in case the key is not set. |
|
42 | 41 | * |
43 | 42 | * @api |
44 | 43 | * @since future |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return void |
32 | 32 | */ |
33 | 33 | public function __set( $key, $value ) { |
34 | - $this->_context[$key] = $value; |
|
34 | + $this->_context[ $key ] = $value; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @return mixed|null |
46 | 46 | */ |
47 | 47 | public function __get( $key ) { |
48 | - return isset( $this->_context[$key] ) ? $this->_context[$key] : null; |
|
48 | + return isset( $this->_context[ $key ] ) ? $this->_context[ $key ] : null; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | * |
39 | 39 | * @api |
40 | 40 | * @since future |
41 | - * @return \GV\Entry|null An instance of this entry or null if not found. |
|
41 | + * @return null|GF_Entry An instance of this entry or null if not found. |
|
42 | 42 | */ |
43 | 43 | public static function by_id( $entry_id ) { |
44 | 44 | $entry = \GFAPI::get_entry( $entry_id ); |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function by_id( $entry_id ) { |
44 | 44 | $entry = \GFAPI::get_entry( $entry_id ); |
45 | - if ( !$entry ) { |
|
45 | + if ( ! $entry ) { |
|
46 | 46 | return null; |
47 | 47 | } |
48 | 48 | |
49 | 49 | $self = new self(); |
50 | 50 | $self->entry = $entry; |
51 | 51 | |
52 | - $self->ID = $self->entry['id']; |
|
52 | + $self->ID = $self->entry[ 'id' ]; |
|
53 | 53 | |
54 | 54 | return $self; |
55 | 55 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return bool Whether the offset exists or not. |
64 | 64 | */ |
65 | 65 | public function offsetExists( $offset ) { |
66 | - return isset( $this->entry[$offset] ); |
|
66 | + return isset( $this->entry[ $offset ] ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @return mixed The value of the requested entry data. |
81 | 81 | */ |
82 | 82 | public function offsetGet( $offset ) { |
83 | - return $this->entry[$offset]; |
|
83 | + return $this->entry[ $offset ]; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -298,7 +298,7 @@ |
||
298 | 298 | /** |
299 | 299 | * Determines if a view exists to begin with. |
300 | 300 | * |
301 | - * @param int|\WP_Post|null $view_id The WordPress post ID, a \WP_Post object or null for global $post; |
|
301 | + * @param int|\WP_Post|null $view The WordPress post ID, a \WP_Post object or null for global $post; |
|
302 | 302 | * |
303 | 303 | * @api |
304 | 304 | * @since future |
@@ -202,12 +202,12 @@ |
||
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
205 | - * @filter `gravityview/configuration/fields` Filter the View fields' configuration array |
|
206 | - * @since 1.6.5 |
|
207 | - * |
|
208 | - * @param $fields array Multi-array of fields with first level being the field zones |
|
209 | - * @param $view_id int The View the fields are being pulled for |
|
210 | - */ |
|
205 | + * @filter `gravityview/configuration/fields` Filter the View fields' configuration array |
|
206 | + * @since 1.6.5 |
|
207 | + * |
|
208 | + * @param $fields array Multi-array of fields with first level being the field zones |
|
209 | + * @param $view_id int The View the fields are being pulled for |
|
210 | + */ |
|
211 | 211 | $configuration = apply_filters( 'gravityview/configuration/fields', (array)$view->_gravityview_directory_fields, $view->ID ); |
212 | 212 | |
213 | 213 | /** Get all fields. */ |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $supports = array( 'title', 'revisions' ); |
87 | 87 | |
88 | 88 | if ( $is_hierarchical ) { |
89 | - $supports[] = 'page-attributes'; |
|
89 | + $supports[ ] = 'page-attributes'; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | if ( ! $view->form ) { |
198 | 198 | gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
199 | 199 | 'view_id' => $view->ID, |
200 | - 'form_id' => $view->_gravityview_form_id ? : 0, |
|
200 | + 'form_id' => $view->_gravityview_form_id ?: 0, |
|
201 | 201 | ) ); |
202 | 202 | } |
203 | 203 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * Add the other keys as they are moved out to ensure we're not using them in core. |
349 | 349 | */ |
350 | 350 | |
351 | - } else if ( ! empty( $GLOBALS['GRAVITYVIEW_TESTS_VIEW_ARRAY_ACCESS_OVERRIDE'] ) ) { |
|
351 | + } else if ( ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_VIEW_ARRAY_ACCESS_OVERRIDE' ] ) ) { |
|
352 | 352 | /** |
353 | 353 | * Suppress exception if specifically testing for array acess. |
354 | 354 | */ |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | } |
362 | 362 | } |
363 | 363 | |
364 | - if ( ! isset( $this[$offset] ) ) { |
|
364 | + if ( ! isset( $this[ $offset ] ) ) { |
|
365 | 365 | return null; |
366 | 366 | } |
367 | 367 | |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | return $this->template ? $this->template->ID : null; |
380 | 380 | default: |
381 | 381 | /** @todo move the rest out and get rid of _data completely! */ |
382 | - return $this->_data[$offset]; |
|
382 | + return $this->_data[ $offset ]; |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | array( 'form' => $this->form ? gravityview_get_form( $this->form->ID ) : null ), |
431 | 431 | array( 'atts' => $this->settings->as_atts() ), |
432 | 432 | array( 'fields' => $this->fields->by_visible()->as_configuration() ), |
433 | - array( 'template_id' => $this->template? $this->template->ID : null ), |
|
433 | + array( 'template_id' => $this->template ? $this->template->ID : null ), |
|
434 | 434 | $this->_data |
435 | 435 | ); |
436 | 436 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Sets the single entry ID and also the entry |
156 | - * @param bool|int|string $single_entry |
|
156 | + * @param boolean|string $single_entry |
|
157 | 157 | */ |
158 | 158 | public function setSingleEntry( $single_entry ) { |
159 | 159 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | |
171 | 171 | /** |
172 | 172 | * Set the current entry |
173 | - * @param array|int $entry Entry array or entry slug or ID |
|
173 | + * @param boolean|string $entry Entry array or entry slug or ID |
|
174 | 174 | */ |
175 | 175 | public function setEntry( $entry ) { |
176 | 176 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * |
229 | 229 | * |
230 | 230 | * |
231 | - * @param null $view_id |
|
231 | + * @param string $view_id |
|
232 | 232 | */ |
233 | 233 | public function set_context_view_id( $view_id = null ) { |
234 | 234 | $multiple_views = defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? gravityview()->views->count() > 1 : ( $this->getGvOutputData() && $this->getGvOutputData()->has_multiple_views() ); |
@@ -1213,7 +1213,7 @@ discard block |
||
1213 | 1213 | * |
1214 | 1214 | * @uses gravityview_get_entries() |
1215 | 1215 | * @access public |
1216 | - * @param array $args\n |
|
1216 | + * @param array $args |
|
1217 | 1217 | * - $id - View id |
1218 | 1218 | * - $page_size - Page |
1219 | 1219 | * - $sort_field - form field id to sort |
@@ -1370,7 +1370,6 @@ discard block |
||
1370 | 1370 | * @since 1.19.5 |
1371 | 1371 | * |
1372 | 1372 | * @param $args |
1373 | - * @param int $form_id |
|
1374 | 1373 | */ |
1375 | 1374 | public static function get_search_criteria_paging( $args ) { |
1376 | 1375 | |
@@ -1785,7 +1784,7 @@ discard block |
||
1785 | 1784 | /** |
1786 | 1785 | * Checks if field (column) is sortable |
1787 | 1786 | * |
1788 | - * @param string $field Field settings |
|
1787 | + * @param string $field_id Field settings |
|
1789 | 1788 | * @param array $form Gravity Forms form array |
1790 | 1789 | * |
1791 | 1790 | * @since 1.7 |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | } |
459 | 459 | |
460 | 460 | // User reported WooCommerce doesn't pass two args. |
461 | - if ( empty( $passed_post_id ) ) { |
|
461 | + if ( empty( $passed_post_id ) ) { |
|
462 | 462 | return $title; |
463 | 463 | } |
464 | 464 | |
@@ -494,8 +494,9 @@ discard block |
||
494 | 494 | } |
495 | 495 | |
496 | 496 | /** No matching form sources were found, happens when requesting an entry from a different form . */ |
497 | - if ( ! isset( $view ) ) |
|
498 | - return $title; |
|
497 | + if ( ! isset( $view ) ) { |
|
498 | + return $title; |
|
499 | + } |
|
499 | 500 | } else { |
500 | 501 | /** Deprecated. Use gravityview()->views->all() or gravityview()->request->all() */ |
501 | 502 | foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { |
@@ -1478,7 +1479,7 @@ discard block |
||
1478 | 1479 | */ |
1479 | 1480 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
1480 | 1481 | |
1481 | - switch( strtolower( $address_part ) ){ |
|
1482 | + switch( strtolower( $address_part ) ) { |
|
1482 | 1483 | case 'street': |
1483 | 1484 | $sort_field_id .= '.1'; |
1484 | 1485 | break; |
@@ -1563,7 +1564,7 @@ discard block |
||
1563 | 1564 | */ |
1564 | 1565 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
1565 | 1566 | |
1566 | - if ( empty( $single_entry ) ){ |
|
1567 | + if ( empty( $single_entry ) ) { |
|
1567 | 1568 | return false; |
1568 | 1569 | } else { |
1569 | 1570 | return $single_entry; |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | private function __construct() {} |
86 | 86 | |
87 | 87 | private function initialize() { |
88 | - add_action( 'wp', array( $this, 'parse_content'), 11 ); |
|
88 | + add_action( 'wp', array( $this, 'parse_content' ), 11 ); |
|
89 | 89 | add_filter( 'parse_query', array( $this, 'parse_query_fix_frontpage' ), 10 ); |
90 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 ); |
|
90 | + add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 ); |
|
91 | 91 | |
92 | 92 | // Enqueue scripts and styles after GravityView_Template::register_styles() |
93 | 93 | add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 ); |
@@ -237,12 +237,12 @@ discard block |
||
237 | 237 | |
238 | 238 | $this->context_view_id = $view_id; |
239 | 239 | |
240 | - } elseif ( isset( $_GET['gvid'] ) && $multiple_views ) { |
|
240 | + } elseif ( isset( $_GET[ 'gvid' ] ) && $multiple_views ) { |
|
241 | 241 | /** |
242 | 242 | * used on a has_multiple_views context |
243 | 243 | * @see GravityView_API::entry_link |
244 | 244 | */ |
245 | - $this->context_view_id = $_GET['gvid']; |
|
245 | + $this->context_view_id = $_GET[ 'gvid' ]; |
|
246 | 246 | |
247 | 247 | } elseif ( ! $multiple_views ) { |
248 | 248 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
@@ -285,24 +285,24 @@ discard block |
||
285 | 285 | global $wp_rewrite; |
286 | 286 | |
287 | 287 | $is_front_page = ( $query->is_home || $query->is_page ); |
288 | - $show_on_front = ( 'page' === get_option('show_on_front') ); |
|
289 | - $front_page_id = get_option('page_on_front'); |
|
288 | + $show_on_front = ( 'page' === get_option( 'show_on_front' ) ); |
|
289 | + $front_page_id = get_option( 'page_on_front' ); |
|
290 | 290 | |
291 | - if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
291 | + if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
292 | 292 | |
293 | 293 | // Force to be an array, potentially a query string ( entry=16 ) |
294 | 294 | $_query = wp_parse_args( $query->query ); |
295 | 295 | |
296 | 296 | // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. |
297 | - if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { |
|
298 | - unset( $_query['pagename'] ); |
|
297 | + if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) { |
|
298 | + unset( $_query[ 'pagename' ] ); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | // this is where will break from core wordpress |
302 | 302 | $ignore = array( 'preview', 'page', 'paged', 'cpage' ); |
303 | 303 | $endpoints = rgobj( $wp_rewrite, 'endpoints' ); |
304 | - foreach ( (array) $endpoints as $endpoint ) { |
|
305 | - $ignore[] = $endpoint[1]; |
|
304 | + foreach ( (array)$endpoints as $endpoint ) { |
|
305 | + $ignore[ ] = $endpoint[ 1 ]; |
|
306 | 306 | } |
307 | 307 | unset( $endpoints ); |
308 | 308 | |
@@ -312,21 +312,21 @@ discard block |
||
312 | 312 | // - The query includes keys that are associated with registered endpoints. `entry`, for example. |
313 | 313 | if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) { |
314 | 314 | |
315 | - $qv =& $query->query_vars; |
|
315 | + $qv = & $query->query_vars; |
|
316 | 316 | |
317 | 317 | // Prevent redirect when on the single entry endpoint |
318 | - if( self::is_single_entry() ) { |
|
318 | + if ( self::is_single_entry() ) { |
|
319 | 319 | add_filter( 'redirect_canonical', '__return_false' ); |
320 | 320 | } |
321 | 321 | |
322 | 322 | $query->is_page = true; |
323 | 323 | $query->is_home = false; |
324 | - $qv['page_id'] = $front_page_id; |
|
324 | + $qv[ 'page_id' ] = $front_page_id; |
|
325 | 325 | |
326 | 326 | // Correct <!--nextpage--> for page_on_front |
327 | - if ( ! empty( $qv['paged'] ) ) { |
|
328 | - $qv['page'] = $qv['paged']; |
|
329 | - unset( $qv['paged'] ); |
|
327 | + if ( ! empty( $qv[ 'paged' ] ) ) { |
|
328 | + $qv[ 'page' ] = $qv[ 'paged' ]; |
|
329 | + unset( $qv[ 'paged' ] ); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | |
360 | 360 | $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' ); |
361 | 361 | |
362 | - $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null ); |
|
362 | + $post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null ); |
|
363 | 363 | $this->setPostId( $post_id ); |
364 | 364 | $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false; |
365 | 365 | $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) ); |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | |
396 | 396 | $search_method = GravityView_Widget_Search::getInstance()->get_search_method(); |
397 | 397 | |
398 | - if( 'post' === $search_method ) { |
|
398 | + if ( 'post' === $search_method ) { |
|
399 | 399 | $get = $_POST; |
400 | 400 | } else { |
401 | 401 | $get = $_GET; |
@@ -451,20 +451,20 @@ discard block |
||
451 | 451 | * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop |
452 | 452 | * @param array $entry Current entry |
453 | 453 | */ |
454 | - $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry ); |
|
454 | + $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry ); |
|
455 | 455 | |
456 | 456 | if ( ! $apply_outside_loop ) { |
457 | 457 | return $title; |
458 | 458 | } |
459 | 459 | |
460 | 460 | // User reported WooCommerce doesn't pass two args. |
461 | - if ( empty( $passed_post_id ) ) { |
|
461 | + if ( empty( $passed_post_id ) ) { |
|
462 | 462 | return $title; |
463 | 463 | } |
464 | 464 | |
465 | 465 | // Don't modify the title for anything other than the current view/post. |
466 | 466 | // This is true for embedded shortcodes and Views. |
467 | - if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { |
|
467 | + if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) { |
|
468 | 468 | return $title; |
469 | 469 | } |
470 | 470 | |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | } else { |
488 | 488 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
489 | 489 | foreach ( gravityview()->views->all() as $_view ) { |
490 | - if ( intval( $_view->form->ID ) === intval( $entry['form_id'] ) ) { |
|
490 | + if ( intval( $_view->form->ID ) === intval( $entry[ 'form_id' ] ) ) { |
|
491 | 491 | $view = $_view; |
492 | 492 | break; |
493 | 493 | } |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | } else { |
500 | 500 | /** Deprecated. Use gravityview()->views->all() or gravityview()->request->all() */ |
501 | 501 | foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { |
502 | - if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) { |
|
502 | + if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) { |
|
503 | 503 | $view_meta = $view_data; |
504 | 504 | break; |
505 | 505 | } |
@@ -514,12 +514,12 @@ discard block |
||
514 | 514 | } |
515 | 515 | } else { |
516 | 516 | /** Deprecated stuff in the future. See the branch above. */ |
517 | - if ( ! empty( $view_meta['atts']['single_title'] ) ) { |
|
517 | + if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) { |
|
518 | 518 | |
519 | - $title = $view_meta['atts']['single_title']; |
|
519 | + $title = $view_meta[ 'atts' ][ 'single_title' ]; |
|
520 | 520 | |
521 | 521 | // We are allowing HTML in the fields, so no escaping the output |
522 | - $title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry ); |
|
522 | + $title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry ); |
|
523 | 523 | |
524 | 524 | $title = do_shortcode( $title ); |
525 | 525 | } |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | } |
558 | 558 | |
559 | 559 | // Only render in the loop. Fixes issues with the_content filter being applied in places like the sidebar |
560 | - if( ! in_the_loop() ) { |
|
560 | + if ( ! in_the_loop() ) { |
|
561 | 561 | return $content; |
562 | 562 | } |
563 | 563 | |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | |
633 | 633 | $context = GravityView_View::getInstance()->getContext(); |
634 | 634 | |
635 | - switch( $context ) { |
|
635 | + switch ( $context ) { |
|
636 | 636 | case 'directory': |
637 | 637 | $tab = __( 'Multiple Entries', 'gravityview' ); |
638 | 638 | break; |
@@ -646,12 +646,12 @@ discard block |
||
646 | 646 | } |
647 | 647 | |
648 | 648 | |
649 | - $title = sprintf( esc_html_x('The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
649 | + $title = sprintf( esc_html_x( 'The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
650 | 650 | $edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $view_id, $context ) ); |
651 | - $action_text = sprintf( esc_html__('Add fields to %s', 'gravityview' ), $tab ); |
|
651 | + $action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab ); |
|
652 | 652 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
653 | 653 | |
654 | - $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url(plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
654 | + $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
655 | 655 | $output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message ); |
656 | 656 | |
657 | 657 | echo GVCommon::generate_notice( $output . $image, 'gv-error error', 'edit_gravityview', $view_id ); |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | public function render_view( $passed_args ) { |
683 | 683 | |
684 | 684 | // validate attributes |
685 | - if ( empty( $passed_args['id'] ) ) { |
|
685 | + if ( empty( $passed_args[ 'id' ] ) ) { |
|
686 | 686 | do_action( 'gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args ); |
687 | 687 | return null; |
688 | 688 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | return null; |
705 | 705 | } |
706 | 706 | |
707 | - $view_id = $passed_args['id']; |
|
707 | + $view_id = $passed_args[ 'id' ]; |
|
708 | 708 | |
709 | 709 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
710 | 710 | $view = gravityview()->views->get( $view_id ); |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | $passed_args = array_filter( $passed_args, 'strlen' ); |
730 | 730 | |
731 | 731 | //Override shortcode args over View template settings |
732 | - $atts = wp_parse_args( $passed_args, $view_data['atts'] ); |
|
732 | + $atts = wp_parse_args( $passed_args, $view_data[ 'atts' ] ); |
|
733 | 733 | |
734 | 734 | do_action( 'gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts ); |
735 | 735 | } |
@@ -753,14 +753,14 @@ discard block |
||
753 | 753 | * @since 1.15 |
754 | 754 | * @since 1.17.2 Added check for if a user has no caps but is logged in (member of multisite, but not any site). Treat as if logged-out. |
755 | 755 | */ |
756 | - if( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
756 | + if ( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
757 | 757 | |
758 | 758 | do_action( 'gravityview_log_debug', sprintf( '%s Returning: View %d is not visible by current user.', __METHOD__, $view_id ) ); |
759 | 759 | |
760 | 760 | return null; |
761 | 761 | } |
762 | 762 | |
763 | - if( $this->isGravityviewPostType() ) { |
|
763 | + if ( $this->isGravityviewPostType() ) { |
|
764 | 764 | |
765 | 765 | /** |
766 | 766 | * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode? |
@@ -776,10 +776,10 @@ discard block |
||
776 | 776 | $embed_only = $view->settings->get( 'embed_only' ); |
777 | 777 | } else { |
778 | 778 | /** Deprecated. View attributes moved to \GV\View::$settings. */ |
779 | - $embed_only = ! empty( $atts['embed_only'] ); |
|
779 | + $embed_only = ! empty( $atts[ 'embed_only' ] ); |
|
780 | 780 | } |
781 | 781 | |
782 | - if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
782 | + if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
783 | 783 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
784 | 784 | } |
785 | 785 | } |
@@ -795,13 +795,13 @@ discard block |
||
795 | 795 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
796 | 796 | $view_data = $view->as_data(); |
797 | 797 | $gravityview_view = new GravityView_View( $view_data ); |
798 | - $post_id = intval( $view->settings->get( 'post_id' ) ? : get_the_ID() ); |
|
798 | + $post_id = intval( $view->settings->get( 'post_id' ) ?: get_the_ID() ); |
|
799 | 799 | $template_id = $view->template ? $view->template->ID : null; |
800 | 800 | } else { |
801 | 801 | /** These constructs are deprecated. Use the new gravityview() wrapper. */ |
802 | 802 | $gravityview_view = new GravityView_View( $view_data ); |
803 | - $post_id = ! empty( $atts['post_id'] ) ? intval( $atts['post_id'] ) : get_the_ID(); |
|
804 | - $template_id = $view_data['template_id']; |
|
803 | + $post_id = ! empty( $atts[ 'post_id' ] ) ? intval( $atts[ 'post_id' ] ) : get_the_ID(); |
|
804 | + $template_id = $view_data[ 'template_id' ]; |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | $gravityview_view->setPostId( $post_id ); |
@@ -812,20 +812,20 @@ discard block |
||
812 | 812 | do_action( 'gravityview_log_debug', '[render_view] Executing Directory View' ); |
813 | 813 | |
814 | 814 | //fetch template and slug |
815 | - $view_slug = apply_filters( 'gravityview_template_slug_'. $template_id, 'table', 'directory' ); |
|
815 | + $view_slug = apply_filters( 'gravityview_template_slug_' . $template_id, 'table', 'directory' ); |
|
816 | 816 | |
817 | 817 | do_action( 'gravityview_log_debug', '[render_view] View template slug: ', $view_slug ); |
818 | 818 | |
819 | 819 | /** |
820 | 820 | * Disable fetching initial entries for views that don't need it (DataTables) |
821 | 821 | */ |
822 | - $get_entries = apply_filters( 'gravityview_get_view_entries_'.$view_slug, true ); |
|
822 | + $get_entries = apply_filters( 'gravityview_get_view_entries_' . $view_slug, true ); |
|
823 | 823 | |
824 | 824 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
825 | 825 | $hide_until_searched = $view->settings->get( 'hide_until_searched' ); |
826 | 826 | } else { |
827 | 827 | /** $atts is deprecated, use \GV\View:$settings */ |
828 | - $hide_until_searched = ! empty( $atts['hide_until_searched'] ); |
|
828 | + $hide_until_searched = ! empty( $atts[ 'hide_until_searched' ] ); |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | /** |
@@ -843,12 +843,12 @@ discard block |
||
843 | 843 | $sort_columns = $view->settings->get( 'sort_columns' ); |
844 | 844 | } else { |
845 | 845 | /** $atts is deprecated, use \GV\View:$settings */ |
846 | - $sort_columns = ! empty( $atts['sort_columns'] ); |
|
846 | + $sort_columns = ! empty( $atts[ 'sort_columns' ] ); |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | if ( $sort_columns ) { |
850 | 850 | // add filter to enable column sorting |
851 | - add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ) , 100, 3 ); |
|
851 | + add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ), 100, 3 ); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
@@ -856,19 +856,19 @@ discard block |
||
856 | 856 | } else { |
857 | 857 | /** $atts is deprecated, use \GV\View:$settings */ |
858 | 858 | /** $view_data is depreacted, use \GV\View properties */ |
859 | - $view_entries = self::get_view_entries( $atts, $view_data['form_id'] ); |
|
859 | + $view_entries = self::get_view_entries( $atts, $view_data[ 'form_id' ] ); |
|
860 | 860 | } |
861 | 861 | |
862 | - do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof( $view_entries['entries'] ) ) ); |
|
862 | + do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries[ 'count' ], sizeof( $view_entries[ 'entries' ] ) ) ); |
|
863 | 863 | |
864 | 864 | } else { |
865 | 865 | |
866 | 866 | $view_entries = array( 'count' => null, 'entries' => null, 'paging' => null ); |
867 | 867 | |
868 | - do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false' ); |
|
868 | + do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_' . $view_slug . '` is false' ); |
|
869 | 869 | } |
870 | 870 | |
871 | - $gravityview_view->setPaging( $view_entries['paging'] ); |
|
871 | + $gravityview_view->setPaging( $view_entries[ 'paging' ] ); |
|
872 | 872 | $gravityview_view->setContext( 'directory' ); |
873 | 873 | $sections = array( 'header', 'body', 'footer' ); |
874 | 874 | |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | do_action( 'gravityview_render_entry_' . $view->ID ); |
886 | 886 | } else { |
887 | 887 | /** $view_data is depreacted, use \GV\View properties */ |
888 | - do_action( 'gravityview_render_entry_'.$view_data['id'] ); |
|
888 | + do_action( 'gravityview_render_entry_' . $view_data[ 'id' ] ); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | $entry = $this->getEntry(); |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | do_action( 'gravityview_log_debug', '[render_view] Entry does not exist. This may be because of View filters limiting access.' ); |
897 | 897 | |
898 | 898 | // Only display warning once when multiple Views are embedded |
899 | - if( $view_id !== (int) GravityView_frontend::get_context_view_id() ) { |
|
899 | + if ( $view_id !== (int)GravityView_frontend::get_context_view_id() ) { |
|
900 | 900 | ob_end_clean(); |
901 | 901 | return null; |
902 | 902 | } |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | // important: do not remove this as it prevents fake attempts of displaying entries from other views/forms |
922 | 922 | $multiple_views = defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? gravityview()->views->count() > 1 : $this->getGvOutputData()->has_multiple_views(); |
923 | 923 | if ( $multiple_views && $view_id != $this->get_context_view_id() ) { |
924 | - do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '. $view_id ); |
|
924 | + do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: ' . $view_id ); |
|
925 | 925 | ob_end_clean(); |
926 | 926 | return null; |
927 | 927 | } |
@@ -931,14 +931,14 @@ discard block |
||
931 | 931 | do_action( 'gravityview_log_debug', '[render_view] View single template slug: ', $view_slug ); |
932 | 932 | |
933 | 933 | //fetch entry detail |
934 | - $view_entries['count'] = 1; |
|
935 | - $view_entries['entries'][] = $entry; |
|
936 | - do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries'] ); |
|
934 | + $view_entries[ 'count' ] = 1; |
|
935 | + $view_entries[ 'entries' ][ ] = $entry; |
|
936 | + do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries[ 'entries' ] ); |
|
937 | 937 | |
938 | 938 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
939 | 939 | $back_link_label = $view->settings->get( 'back_link_label', null ); |
940 | 940 | } else { |
941 | - $back_link_label = isset( $atts['back_link_label'] ) ? $atts['back_link_label'] : null; |
|
941 | + $back_link_label = isset( $atts[ 'back_link_label' ] ) ? $atts[ 'back_link_label' ] : null; |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | // set back link label |
@@ -952,8 +952,8 @@ discard block |
||
952 | 952 | self::add_style( $template_id ); |
953 | 953 | |
954 | 954 | // Prepare to render view and set vars |
955 | - $gravityview_view->setEntries( $view_entries['entries'] ); |
|
956 | - $gravityview_view->setTotalEntries( $view_entries['count'] ); |
|
955 | + $gravityview_view->setEntries( $view_entries[ 'entries' ] ); |
|
956 | + $gravityview_view->setTotalEntries( $view_entries[ 'count' ] ); |
|
957 | 957 | |
958 | 958 | // If Edit |
959 | 959 | if ( 'edit' === gravityview_get_context() ) { |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | |
971 | 971 | do_action( 'gravityview_log_debug', '[render_view] Sections to render: ', $sections ); |
972 | 972 | foreach ( $sections as $section ) { |
973 | - do_action( 'gravityview_log_debug', '[render_view] Rendering '. $section . ' section.' ); |
|
973 | + do_action( 'gravityview_log_debug', '[render_view] Rendering ' . $section . ' section.' ); |
|
974 | 974 | $gravityview_view->render( $view_slug, $section, false ); |
975 | 975 | } |
976 | 976 | } |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | $datetime_format = 'Y-m-d H:i:s'; |
1025 | 1025 | $search_is_outside_view_bounds = false; |
1026 | 1026 | |
1027 | - if( ! empty( $search_criteria[ $key ] ) ) { |
|
1027 | + if ( ! empty( $search_criteria[ $key ] ) ) { |
|
1028 | 1028 | |
1029 | 1029 | $search_date = strtotime( $search_criteria[ $key ] ); |
1030 | 1030 | |
@@ -1052,14 +1052,14 @@ discard block |
||
1052 | 1052 | if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { |
1053 | 1053 | |
1054 | 1054 | // Then we override the search and re-set the start date |
1055 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true ); |
|
1055 | + $return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true ); |
|
1056 | 1056 | } |
1057 | 1057 | } |
1058 | 1058 | } |
1059 | 1059 | |
1060 | - if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { |
|
1060 | + if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) { |
|
1061 | 1061 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue. |
1062 | - if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { |
|
1062 | + if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) { |
|
1063 | 1063 | do_action( 'gravityview_log_error', __METHOD__ . ' Invalid search: the start date is after the end date.', $return_search_criteria ); |
1064 | 1064 | } |
1065 | 1065 | } |
@@ -1078,19 +1078,19 @@ discard block |
||
1078 | 1078 | public static function process_search_only_approved( $args, $search_criteria ) { |
1079 | 1079 | |
1080 | 1080 | /** @since 1.19 */ |
1081 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
1081 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
1082 | 1082 | do_action( 'gravityview_log_debug', __METHOD__ . ': User can moderate entries; showing all approval statuses' ); |
1083 | 1083 | return $search_criteria; |
1084 | 1084 | } |
1085 | 1085 | |
1086 | - if ( ! empty( $args['show_only_approved'] ) ) { |
|
1086 | + if ( ! empty( $args[ 'show_only_approved' ] ) ) { |
|
1087 | 1087 | |
1088 | - $search_criteria['field_filters'][] = array( |
|
1088 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
1089 | 1089 | 'key' => GravityView_Entry_Approval::meta_key, |
1090 | 1090 | 'value' => GravityView_Entry_Approval_Status::APPROVED |
1091 | 1091 | ); |
1092 | 1092 | |
1093 | - $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met |
|
1093 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met |
|
1094 | 1094 | |
1095 | 1095 | do_action( 'gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria ); |
1096 | 1096 | } |
@@ -1117,18 +1117,18 @@ discard block |
||
1117 | 1117 | */ |
1118 | 1118 | public static function is_entry_approved( $entry, $args = array() ) { |
1119 | 1119 | |
1120 | - if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { |
|
1120 | + if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) { |
|
1121 | 1121 | // is implicitly approved if entry is null or View settings doesn't require to check for approval |
1122 | 1122 | return true; |
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | /** @since 1.19 */ |
1126 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
1126 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
1127 | 1127 | do_action( 'gravityview_log_debug', __METHOD__ . ': User can moderate entries, so entry is approved for viewing' ); |
1128 | 1128 | return true; |
1129 | 1129 | } |
1130 | 1130 | |
1131 | - $is_approved = gform_get_meta( $entry['id'], GravityView_Entry_Approval::meta_key ); |
|
1131 | + $is_approved = gform_get_meta( $entry[ 'id' ], GravityView_Entry_Approval::meta_key ); |
|
1132 | 1132 | |
1133 | 1133 | return GravityView_Entry_Approval_Status::is_approved( $is_approved ); |
1134 | 1134 | } |
@@ -1162,26 +1162,26 @@ discard block |
||
1162 | 1162 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria ); |
1163 | 1163 | |
1164 | 1164 | // implicity search |
1165 | - if ( ! empty( $args['search_value'] ) ) { |
|
1165 | + if ( ! empty( $args[ 'search_value' ] ) ) { |
|
1166 | 1166 | |
1167 | 1167 | // Search operator options. Options: `is` or `contains` |
1168 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains'; |
|
1168 | + $operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains'; |
|
1169 | 1169 | |
1170 | - $search_criteria['field_filters'][] = array( |
|
1170 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
1171 | 1171 | 'key' => rgget( 'search_field', $args ), // The field ID to search |
1172 | - 'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes. |
|
1172 | + 'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes. |
|
1173 | 1173 | 'operator' => $operator, |
1174 | 1174 | ); |
1175 | 1175 | } |
1176 | 1176 | |
1177 | - if( $search_criteria !== $original_search_criteria ) { |
|
1177 | + if ( $search_criteria !== $original_search_criteria ) { |
|
1178 | 1178 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria ); |
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | // Handle setting date range |
1182 | 1182 | $search_criteria = self::process_search_dates( $args, $search_criteria ); |
1183 | 1183 | |
1184 | - if( $search_criteria !== $original_search_criteria ) { |
|
1184 | + if ( $search_criteria !== $original_search_criteria ) { |
|
1185 | 1185 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria ); |
1186 | 1186 | } |
1187 | 1187 | |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | * @filter `gravityview_status` Modify entry status requirements to be included in search results. |
1193 | 1193 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash` |
1194 | 1194 | */ |
1195 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args ); |
|
1195 | + $search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args ); |
|
1196 | 1196 | |
1197 | 1197 | return $search_criteria; |
1198 | 1198 | } |
@@ -1308,7 +1308,7 @@ discard block |
||
1308 | 1308 | 'search_criteria' => $search_criteria, |
1309 | 1309 | 'sorting' => self::updateViewSorting( $args, $form_id ), |
1310 | 1310 | 'paging' => $paging, |
1311 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true, |
|
1311 | + 'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true, |
|
1312 | 1312 | ); |
1313 | 1313 | |
1314 | 1314 | /** |
@@ -1333,7 +1333,7 @@ discard block |
||
1333 | 1333 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. |
1334 | 1334 | * @param array $args View configuration args. |
1335 | 1335 | */ |
1336 | - $parameters = apply_filters( 'gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id ); |
|
1336 | + $parameters = apply_filters( 'gravityview_get_entries_' . $args[ 'id' ], $parameters, $args, $form_id ); |
|
1337 | 1337 | |
1338 | 1338 | do_action( 'gravityview_log_debug', __METHOD__ . ': $parameters passed to gravityview_get_entries(): ', $parameters ); |
1339 | 1339 | |
@@ -1358,17 +1358,17 @@ discard block |
||
1358 | 1358 | $default_page_size = apply_filters( 'gravityview_default_page_size', 25 ); |
1359 | 1359 | |
1360 | 1360 | // Paging & offset |
1361 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : $default_page_size; |
|
1361 | + $page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : $default_page_size; |
|
1362 | 1362 | |
1363 | 1363 | if ( -1 === $page_size ) { |
1364 | 1364 | $page_size = PHP_INT_MAX; |
1365 | 1365 | } |
1366 | 1366 | |
1367 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
1367 | + $curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] ); |
|
1368 | 1368 | $offset = ( $curr_page - 1 ) * $page_size; |
1369 | 1369 | |
1370 | - if ( ! empty( $args['offset'] ) ) { |
|
1371 | - $offset += intval( $args['offset'] ); |
|
1370 | + if ( ! empty( $args[ 'offset' ] ) ) { |
|
1371 | + $offset += intval( $args[ 'offset' ] ); |
|
1372 | 1372 | } |
1373 | 1373 | |
1374 | 1374 | $paging = array( |
@@ -1392,8 +1392,8 @@ discard block |
||
1392 | 1392 | */ |
1393 | 1393 | public static function updateViewSorting( $args, $form_id ) { |
1394 | 1394 | $sorting = array(); |
1395 | - $sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : rgar( $args, 'sort_field' ); |
|
1396 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : rgar( $args, 'sort_direction' ); |
|
1395 | + $sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : rgar( $args, 'sort_field' ); |
|
1396 | + $sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : rgar( $args, 'sort_direction' ); |
|
1397 | 1397 | |
1398 | 1398 | $sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id ); |
1399 | 1399 | |
@@ -1433,11 +1433,11 @@ discard block |
||
1433 | 1433 | |
1434 | 1434 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
1435 | 1435 | |
1436 | - if( ! $sort_field ) { |
|
1436 | + if ( ! $sort_field ) { |
|
1437 | 1437 | return $sort_field_id; |
1438 | 1438 | } |
1439 | 1439 | |
1440 | - switch ( $sort_field['type'] ) { |
|
1440 | + switch ( $sort_field[ 'type' ] ) { |
|
1441 | 1441 | |
1442 | 1442 | case 'address': |
1443 | 1443 | // Sorting by full address |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | */ |
1455 | 1455 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
1456 | 1456 | |
1457 | - switch( strtolower( $address_part ) ){ |
|
1457 | + switch ( strtolower( $address_part ) ) { |
|
1458 | 1458 | case 'street': |
1459 | 1459 | $sort_field_id .= '.1'; |
1460 | 1460 | break; |
@@ -1539,7 +1539,7 @@ discard block |
||
1539 | 1539 | */ |
1540 | 1540 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
1541 | 1541 | |
1542 | - if ( empty( $single_entry ) ){ |
|
1542 | + if ( empty( $single_entry ) ) { |
|
1543 | 1543 | return false; |
1544 | 1544 | } else { |
1545 | 1545 | return $single_entry; |
@@ -1572,14 +1572,14 @@ discard block |
||
1572 | 1572 | $template_id = $view->template ? $view->template->ID : null; |
1573 | 1573 | $data = $view->as_data(); |
1574 | 1574 | } else { |
1575 | - $template_id = $data['template_id']; |
|
1575 | + $template_id = $data[ 'template_id' ]; |
|
1576 | 1576 | } |
1577 | 1577 | |
1578 | 1578 | /** |
1579 | 1579 | * Don't enqueue the scripts or styles if it's not going to be displayed. |
1580 | 1580 | * @since 1.15 |
1581 | 1581 | */ |
1582 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1582 | + if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1583 | 1583 | continue; |
1584 | 1584 | } |
1585 | 1585 | |
@@ -1591,7 +1591,7 @@ discard block |
||
1591 | 1591 | $lightbox = $view->settings->get( 'lightbox' ); |
1592 | 1592 | } else { |
1593 | 1593 | /** View data attributes are now stored in \GV\View::$settings */ |
1594 | - $lightbox = ! empty( $data['atts']['lightbox'] ); |
|
1594 | + $lightbox = ! empty( $data[ 'atts' ][ 'lightbox' ] ); |
|
1595 | 1595 | } |
1596 | 1596 | |
1597 | 1597 | // If the thickbox is enqueued, add dependencies |
@@ -1601,13 +1601,13 @@ discard block |
||
1601 | 1601 | * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox` |
1602 | 1602 | * @param string $script_slug If you want to use a different lightbox script, return the name of it here. |
1603 | 1603 | */ |
1604 | - $js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1604 | + $js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1605 | 1605 | |
1606 | 1606 | /** |
1607 | 1607 | * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox` |
1608 | 1608 | * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here. |
1609 | 1609 | */ |
1610 | - $css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1610 | + $css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1611 | 1611 | } |
1612 | 1612 | |
1613 | 1613 | /** |
@@ -1615,19 +1615,19 @@ discard block |
||
1615 | 1615 | * @see https://github.com/katzwebservices/GravityView/issues/536 |
1616 | 1616 | * @since 1.15 |
1617 | 1617 | */ |
1618 | - if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { |
|
1619 | - $css_dependencies[] = 'dashicons'; |
|
1618 | + if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) { |
|
1619 | + $css_dependencies[ ] = 'dashicons'; |
|
1620 | 1620 | } |
1621 | 1621 | |
1622 | 1622 | wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
1623 | 1623 | |
1624 | 1624 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
1625 | 1625 | |
1626 | - wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true ); |
|
1626 | + wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ), GravityView_Plugin::version, true ); |
|
1627 | 1627 | |
1628 | 1628 | wp_enqueue_script( 'gravityview-fe-view' ); |
1629 | 1629 | |
1630 | - if ( ! empty( $data['atts']['sort_columns'] ) ) { |
|
1630 | + if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) { |
|
1631 | 1631 | wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
1632 | 1632 | } |
1633 | 1633 | |
@@ -1695,7 +1695,7 @@ discard block |
||
1695 | 1695 | } elseif ( empty( $template_id ) ) { |
1696 | 1696 | do_action( 'gravityview_log_error', '[add_style] Cannot add template style; template_id is empty' ); |
1697 | 1697 | } else { |
1698 | - do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id ) ); |
|
1698 | + do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_' . $template_id ) ); |
|
1699 | 1699 | } |
1700 | 1700 | |
1701 | 1701 | } |
@@ -1720,11 +1720,11 @@ discard block |
||
1720 | 1720 | * Not a table-based template; don't add sort icons |
1721 | 1721 | * @since 1.12 |
1722 | 1722 | */ |
1723 | - if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1723 | + if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1724 | 1724 | return $label; |
1725 | 1725 | } |
1726 | 1726 | |
1727 | - if ( ! $this->is_field_sortable( $field['id'], $form ) ) { |
|
1727 | + if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) { |
|
1728 | 1728 | return $label; |
1729 | 1729 | } |
1730 | 1730 | |
@@ -1732,29 +1732,29 @@ discard block |
||
1732 | 1732 | |
1733 | 1733 | $class = 'gv-sort'; |
1734 | 1734 | |
1735 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] ); |
|
1735 | + $sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] ); |
|
1736 | 1736 | |
1737 | 1737 | $sort_args = array( |
1738 | - 'sort' => $field['id'], |
|
1738 | + 'sort' => $field[ 'id' ], |
|
1739 | 1739 | 'dir' => 'asc', |
1740 | 1740 | ); |
1741 | 1741 | |
1742 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
1742 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
1743 | 1743 | //toggle sorting direction. |
1744 | - if ( 'asc' === $sorting['direction'] ) { |
|
1745 | - $sort_args['dir'] = 'desc'; |
|
1744 | + if ( 'asc' === $sorting[ 'direction' ] ) { |
|
1745 | + $sort_args[ 'dir' ] = 'desc'; |
|
1746 | 1746 | $class .= ' gv-icon-sort-desc'; |
1747 | 1747 | } else { |
1748 | - $sort_args['dir'] = 'asc'; |
|
1748 | + $sort_args[ 'dir' ] = 'asc'; |
|
1749 | 1749 | $class .= ' gv-icon-sort-asc'; |
1750 | 1750 | } |
1751 | 1751 | } else { |
1752 | 1752 | $class .= ' gv-icon-caret-up-down'; |
1753 | 1753 | } |
1754 | 1754 | |
1755 | - $url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); |
|
1755 | + $url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) ); |
|
1756 | 1756 | |
1757 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label; |
|
1757 | + return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a> ' . $label; |
|
1758 | 1758 | |
1759 | 1759 | } |
1760 | 1760 | |
@@ -1772,7 +1772,7 @@ discard block |
||
1772 | 1772 | |
1773 | 1773 | $field_type = $field_id; |
1774 | 1774 | |
1775 | - if( is_numeric( $field_id ) ) { |
|
1775 | + if ( is_numeric( $field_id ) ) { |
|
1776 | 1776 | $field = GFFormsModel::get_field( $form, $field_id ); |
1777 | 1777 | $field_type = $field->type; |
1778 | 1778 | } |
@@ -1795,7 +1795,7 @@ discard block |
||
1795 | 1795 | return false; |
1796 | 1796 | } |
1797 | 1797 | |
1798 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1798 | + return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1799 | 1799 | |
1800 | 1800 | } |
1801 | 1801 |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | gravityview()->request = new \GV\Dummy_Request(); |
22 | 22 | } |
23 | 23 | |
24 | - if( !empty( $passed_post ) ) { |
|
24 | + if ( ! empty( $passed_post ) ) { |
|
25 | 25 | |
26 | 26 | $id_or_id_array = $this->maybe_get_view_id( $passed_post ); |
27 | 27 | |
28 | 28 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
29 | - foreach( is_array( $id_or_id_array ) ? $id_or_id_array : array( $id_or_id_array ) as $view_id ) { |
|
29 | + foreach ( is_array( $id_or_id_array ) ? $id_or_id_array : array( $id_or_id_array ) as $view_id ) { |
|
30 | 30 | if ( \GV\View::exists( $view_id ) && ! gravityview()->views->contains( $view_id ) ) { |
31 | 31 | gravityview()->views->add( \GV\View::by_id( $view_id ) ); |
32 | 32 | } |
@@ -73,24 +73,24 @@ discard block |
||
73 | 73 | public function maybe_get_view_id( $passed_post ) { |
74 | 74 | $ids = array(); |
75 | 75 | |
76 | - if( ! empty( $passed_post ) ) { |
|
76 | + if ( ! empty( $passed_post ) ) { |
|
77 | 77 | |
78 | - if( is_numeric( $passed_post ) ) { |
|
78 | + if ( is_numeric( $passed_post ) ) { |
|
79 | 79 | $passed_post = get_post( $passed_post ); |
80 | 80 | } |
81 | 81 | |
82 | 82 | // Convert WP_Posts into WP_Posts[] array |
83 | - if( $passed_post instanceof WP_Post ) { |
|
83 | + if ( $passed_post instanceof WP_Post ) { |
|
84 | 84 | $passed_post = array( $passed_post ); |
85 | 85 | } |
86 | 86 | |
87 | - if( is_array( $passed_post ) ) { |
|
87 | + if ( is_array( $passed_post ) ) { |
|
88 | 88 | |
89 | - foreach ( $passed_post as &$post) { |
|
89 | + foreach ( $passed_post as &$post ) { |
|
90 | 90 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) && $post instanceof WP_Post ) { |
91 | 91 | $views = \GV\View_Collection::from_post( $post ); |
92 | 92 | foreach ( $views->all() as $view ) { |
93 | - $ids []= $view->ID; |
|
93 | + $ids [ ] = $view->ID; |
|
94 | 94 | |
95 | 95 | /** And as a side-effect... add each view to the global scope. */ |
96 | 96 | if ( ! gravityview()->views->contains( $view->ID ) ) { |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | } |
100 | 100 | } else { |
101 | 101 | /** Deprecated, see \GV\View_Collection::from_post */ |
102 | - if( ( get_post_type( $post ) === 'gravityview' ) ) { |
|
103 | - $ids[] = $post->ID; |
|
104 | - } else{ |
|
102 | + if ( ( get_post_type( $post ) === 'gravityview' ) ) { |
|
103 | + $ids[ ] = $post->ID; |
|
104 | + } else { |
|
105 | 105 | // Parse the Post Content |
106 | 106 | $id = $this->parse_post_content( $post->post_content ); |
107 | - if( $id ) { |
|
108 | - $ids = array_merge( $ids, (array) $id ); |
|
107 | + if ( $id ) { |
|
108 | + $ids = array_merge( $ids, (array)$id ); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // Parse the Post Meta |
112 | 112 | $id = $this->parse_post_meta( $post->ID ); |
113 | - if( $id ) { |
|
114 | - $ids = array_merge( $ids, (array) $id ); |
|
113 | + if ( $id ) { |
|
114 | + $ids = array_merge( $ids, (array)$id ); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | } |
@@ -125,37 +125,37 @@ discard block |
||
125 | 125 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
126 | 126 | $shortcodes = \GV\Shortcode::parse( $passed_post ); |
127 | 127 | foreach ( $shortcodes as $shortcode ) { |
128 | - if ( $shortcode->name == 'gravityview' && !empty( $shortcode->atts['id'] ) ) { |
|
129 | - $ids []= $shortcode->atts['id']; |
|
128 | + if ( $shortcode->name == 'gravityview' && ! empty( $shortcode->atts[ 'id' ] ) ) { |
|
129 | + $ids [ ] = $shortcode->atts[ 'id' ]; |
|
130 | 130 | |
131 | 131 | /** And as a side-effect... add each view to the global scope. */ |
132 | - if ( ! gravityview()->views->contains( $shortcode->atts['id'] ) && \GV\View::exists( $shortcode->atts['id'] ) ) { |
|
133 | - gravityview()->views->add( $shortcode->atts['id'] ); |
|
132 | + if ( ! gravityview()->views->contains( $shortcode->atts[ 'id' ] ) && \GV\View::exists( $shortcode->atts[ 'id' ] ) ) { |
|
133 | + gravityview()->views->add( $shortcode->atts[ 'id' ] ); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | } |
137 | 137 | } else { |
138 | 138 | /** Deprecated, use \GV\Shortcode::parse. */ |
139 | 139 | $id = $this->parse_post_content( $passed_post ); |
140 | - if( $id ) { |
|
141 | - $ids = array_merge( $ids, (array) $id ); |
|
140 | + if ( $id ) { |
|
141 | + $ids = array_merge( $ids, (array)$id ); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | 145 | } else { |
146 | 146 | $id = $this->get_id_from_atts( $passed_post ); |
147 | - $ids[] = intval( $id ); |
|
147 | + $ids[ ] = intval( $id ); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | - if( empty($ids) ) { |
|
152 | + if ( empty( $ids ) ) { |
|
153 | 153 | return NULL; |
154 | 154 | } |
155 | 155 | |
156 | 156 | // If it's just one ID, return that. |
157 | 157 | // Otherwise, return array of IDs |
158 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
158 | + return ( sizeof( $ids ) === 1 ) ? $ids[ 0 ] : $ids; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public static function getInstance( $passed_post = NULL ) { |
165 | 165 | |
166 | - if( empty( self::$instance ) ) { |
|
166 | + if ( empty( self::$instance ) ) { |
|
167 | 167 | self::$instance = new GravityView_View_Data( $passed_post ); |
168 | 168 | } |
169 | 169 | |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | return array(); |
181 | 181 | } |
182 | 182 | return array_combine( |
183 | - array_map( function ( $view ) { return $view->ID; }, gravityview()->views->all() ), |
|
184 | - array_map( function ( $view ) { return $view->as_data(); }, gravityview()->views->all() ) |
|
183 | + array_map( function( $view ) { return $view->ID; }, gravityview()->views->all() ), |
|
184 | + array_map( function( $view ) { return $view->as_data(); }, gravityview()->views->all() ) |
|
185 | 185 | ); |
186 | 186 | } |
187 | 187 | return $this->views; |
@@ -208,19 +208,19 @@ discard block |
||
208 | 208 | return $view->as_data(); |
209 | 209 | } |
210 | 210 | |
211 | - if( ! is_numeric( $view_id) ) { |
|
212 | - do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id) ); |
|
211 | + if ( ! is_numeric( $view_id ) ) { |
|
212 | + do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id ) ); |
|
213 | 213 | return false; |
214 | 214 | } |
215 | 215 | |
216 | 216 | // Backup: the view hasn't been fetched yet. Doing it now. |
217 | 217 | if ( ! isset( $this->views[ $view_id ] ) ) { |
218 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id) ); |
|
218 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[get_view] View #%s not set yet.', $view_id ) ); |
|
219 | 219 | return $this->add_view( $view_id, $atts ); |
220 | 220 | } |
221 | 221 | |
222 | 222 | if ( empty( $this->views[ $view_id ] ) ) { |
223 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id) ); |
|
223 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id ) ); |
|
224 | 224 | return false; |
225 | 225 | } |
226 | 226 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | // Handle array of IDs |
268 | - if( is_array( $view_id ) ) { |
|
269 | - foreach( $view_id as $id ) { |
|
268 | + if ( is_array( $view_id ) ) { |
|
269 | + foreach ( $view_id as $id ) { |
|
270 | 270 | |
271 | 271 | $this->add_view( $id, $atts ); |
272 | 272 | } |
@@ -275,21 +275,21 @@ discard block |
||
275 | 275 | } |
276 | 276 | |
277 | 277 | // The view has been set already; returning stored view. |
278 | - if ( !empty( $this->views[ $view_id ] ) ) { |
|
279 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id) ); |
|
278 | + if ( ! empty( $this->views[ $view_id ] ) ) { |
|
279 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id ) ); |
|
280 | 280 | return $this->views[ $view_id ]; |
281 | 281 | } |
282 | 282 | |
283 | - if( ! $this->view_exists( $view_id ) ) { |
|
284 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id) ); |
|
283 | + if ( ! $this->view_exists( $view_id ) ) { |
|
284 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id ) ); |
|
285 | 285 | return false; |
286 | 286 | } |
287 | 287 | |
288 | 288 | $form_id = gravityview_get_form_id( $view_id ); |
289 | 289 | |
290 | - if( empty( $form_id ) ) { |
|
290 | + if ( empty( $form_id ) ) { |
|
291 | 291 | |
292 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id) ); |
|
292 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id ) ); |
|
293 | 293 | |
294 | 294 | return false; |
295 | 295 | } |
@@ -297,21 +297,21 @@ discard block |
||
297 | 297 | // Get the settings for the View ID |
298 | 298 | $view_settings = gravityview_get_template_settings( $view_id ); |
299 | 299 | |
300 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings ); |
|
300 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id ), $view_settings ); |
|
301 | 301 | |
302 | 302 | // Merge the view settings with the defaults |
303 | 303 | $view_defaults = wp_parse_args( $view_settings, defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? \GV\View_Settings::defaults() : self::get_default_args() ); |
304 | 304 | |
305 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults ); |
|
305 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults ); |
|
306 | 306 | |
307 | - if( ! empty( $atts ) && is_array( $atts ) ) { |
|
307 | + if ( ! empty( $atts ) && is_array( $atts ) ) { |
|
308 | 308 | |
309 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts ); |
|
309 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts ); |
|
310 | 310 | |
311 | 311 | // Get the settings from the shortcode and merge them with defaults. |
312 | 312 | $atts = shortcode_atts( $view_defaults, $atts ); |
313 | 313 | |
314 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts ); |
|
314 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts ); |
|
315 | 315 | |
316 | 316 | } else { |
317 | 317 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | |
321 | 321 | } |
322 | 322 | |
323 | - unset( $atts['id'], $view_defaults, $view_settings ); |
|
323 | + unset( $atts[ 'id' ], $view_defaults, $view_settings ); |
|
324 | 324 | |
325 | 325 | $data = array( |
326 | 326 | 'id' => $view_id, |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | 'form' => gravityview_get_form( $form_id ), |
334 | 334 | ); |
335 | 335 | |
336 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data ); |
|
336 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] View #%s being added.', $view_id ), $data ); |
|
337 | 337 | |
338 | 338 | $this->views[ $view_id ] = $data; |
339 | 339 | |
@@ -383,15 +383,15 @@ discard block |
||
383 | 383 | throw new Exception( __METHOD__ . ' should not be called anymore. Why was it?' ); |
384 | 384 | } |
385 | 385 | |
386 | - if( empty( $dir_fields ) || !is_array( $dir_fields ) ) { |
|
386 | + if ( empty( $dir_fields ) || ! is_array( $dir_fields ) ) { |
|
387 | 387 | return $dir_fields; |
388 | 388 | } |
389 | 389 | |
390 | - foreach( $dir_fields as $area => $fields ) { |
|
390 | + foreach ( $dir_fields as $area => $fields ) { |
|
391 | 391 | |
392 | - foreach( (array)$fields as $uniqid => $properties ) { |
|
392 | + foreach ( (array)$fields as $uniqid => $properties ) { |
|
393 | 393 | |
394 | - if( $this->hide_field_check_conditions( $properties ) ) { |
|
394 | + if ( $this->hide_field_check_conditions( $properties ) ) { |
|
395 | 395 | unset( $dir_fields[ $area ][ $uniqid ] ); |
396 | 396 | } |
397 | 397 | |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | } |
419 | 419 | |
420 | 420 | // logged-in visibility |
421 | - if( ! empty( $properties['only_loggedin'] ) && ! GVCommon::has_cap( $properties['only_loggedin_cap'] ) ) { |
|
421 | + if ( ! empty( $properties[ 'only_loggedin' ] ) && ! GVCommon::has_cap( $properties[ 'only_loggedin_cap' ] ) ) { |
|
422 | 422 | return true; |
423 | 423 | } |
424 | 424 | |
@@ -449,14 +449,14 @@ discard block |
||
449 | 449 | // Get the settings from the shortcode and merge them with defaults. |
450 | 450 | $atts = wp_parse_args( $atts, defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? \GV\View_Settings::defaults() : self::get_default_args() ); |
451 | 451 | |
452 | - $view_id = ! empty( $atts['view_id'] ) ? (int)$atts['view_id'] : NULL; |
|
452 | + $view_id = ! empty( $atts[ 'view_id' ] ) ? (int)$atts[ 'view_id' ] : NULL; |
|
453 | 453 | |
454 | - if( empty( $view_id ) && !empty( $atts['id'] ) ) { |
|
455 | - $view_id = (int)$atts['id']; |
|
454 | + if ( empty( $view_id ) && ! empty( $atts[ 'id' ] ) ) { |
|
455 | + $view_id = (int)$atts[ 'id' ]; |
|
456 | 456 | } |
457 | 457 | |
458 | - if( empty( $view_id ) ) { |
|
459 | - do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts ); |
|
458 | + if ( empty( $view_id ) ) { |
|
459 | + do_action( 'gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts ); |
|
460 | 460 | return; |
461 | 461 | } |
462 | 462 | |
@@ -480,68 +480,68 @@ discard block |
||
480 | 480 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
481 | 481 | $ids = array(); |
482 | 482 | foreach ( \GV\Shortcode::parse( $content ) as $shortcode ) { |
483 | - if ( $shortcode->name == 'gravityview' && is_numeric( $shortcode->atts['id'] ) ) { |
|
484 | - if ( \GV\View::exists( $shortcode->atts['id'] ) && ! gravityview()->views->contains( $shortcode->atts['id'] ) ) { |
|
485 | - gravityview()->views->add( \GV\View::by_id( $shortcode->atts['id'] ) ); |
|
483 | + if ( $shortcode->name == 'gravityview' && is_numeric( $shortcode->atts[ 'id' ] ) ) { |
|
484 | + if ( \GV\View::exists( $shortcode->atts[ 'id' ] ) && ! gravityview()->views->contains( $shortcode->atts[ 'id' ] ) ) { |
|
485 | + gravityview()->views->add( \GV\View::by_id( $shortcode->atts[ 'id' ] ) ); |
|
486 | 486 | } |
487 | 487 | /** |
488 | 488 | * The original function outputs the ID even though it wasn't added by ::add_view() |
489 | 489 | * Wether this is a bug or not remains a mystery. But we need to emulate this behavior |
490 | 490 | * until better times. |
491 | 491 | */ |
492 | - $ids []= $shortcode->atts['id']; |
|
492 | + $ids [ ] = $shortcode->atts[ 'id' ]; |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | if ( empty ( $ids ) ) { |
496 | 496 | return null; |
497 | 497 | } |
498 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
498 | + return ( sizeof( $ids ) === 1 ) ? $ids[ 0 ] : $ids; |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
502 | 502 | * @hack This is so that the shortcode is registered for the oEmbed preview in the Admin |
503 | 503 | * @since 1.6 |
504 | 504 | */ |
505 | - if( ! shortcode_exists('gravityview') && class_exists( 'GravityView_Shortcode' ) ) { |
|
505 | + if ( ! shortcode_exists( 'gravityview' ) && class_exists( 'GravityView_Shortcode' ) ) { |
|
506 | 506 | new GravityView_Shortcode; |
507 | 507 | } |
508 | 508 | |
509 | 509 | $shortcodes = gravityview_has_shortcode_r( $content, 'gravityview' ); |
510 | 510 | |
511 | - if( empty( $shortcodes ) ) { |
|
511 | + if ( empty( $shortcodes ) ) { |
|
512 | 512 | return NULL; |
513 | 513 | } |
514 | 514 | |
515 | - do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes ); |
|
515 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes ); |
|
516 | 516 | |
517 | 517 | $ids = array(); |
518 | 518 | |
519 | - foreach ($shortcodes as $key => $shortcode) { |
|
519 | + foreach ( $shortcodes as $key => $shortcode ) { |
|
520 | 520 | |
521 | - $shortcode[3] = htmlspecialchars_decode( $shortcode[3], ENT_QUOTES ); |
|
521 | + $shortcode[ 3 ] = htmlspecialchars_decode( $shortcode[ 3 ], ENT_QUOTES ); |
|
522 | 522 | |
523 | - $args = shortcode_parse_atts( $shortcode[3] ); |
|
523 | + $args = shortcode_parse_atts( $shortcode[ 3 ] ); |
|
524 | 524 | |
525 | - if( empty( $args['id'] ) ) { |
|
526 | - do_action('gravityview_log_error', 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts', $shortcode ); |
|
525 | + if ( empty( $args[ 'id' ] ) ) { |
|
526 | + do_action( 'gravityview_log_error', 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts', $shortcode ); |
|
527 | 527 | continue; |
528 | 528 | } |
529 | 529 | |
530 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args ); |
|
530 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args[ 'id' ] ), $args ); |
|
531 | 531 | |
532 | 532 | // Store the View to the object for later fetching. |
533 | - $this->add_view( $args['id'], $args ); |
|
533 | + $this->add_view( $args[ 'id' ], $args ); |
|
534 | 534 | |
535 | - $ids[] = $args['id']; |
|
535 | + $ids[ ] = $args[ 'id' ]; |
|
536 | 536 | } |
537 | 537 | |
538 | - if( empty($ids) ) { |
|
538 | + if ( empty( $ids ) ) { |
|
539 | 539 | return NULL; |
540 | 540 | } |
541 | 541 | |
542 | 542 | // If it's just one ID, return that. |
543 | 543 | // Otherwise, return array of IDs |
544 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
544 | + return ( sizeof( $ids ) === 1 ) ? $ids[ 0 ] : $ids; |
|
545 | 545 | |
546 | 546 | } |
547 | 547 | |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | */ |
571 | 571 | $meta_keys = (array)apply_filters( 'gravityview/data/parse/meta_keys', array(), $post_id ); |
572 | 572 | |
573 | - if( empty( $meta_keys ) ) { |
|
573 | + if ( empty( $meta_keys ) ) { |
|
574 | 574 | return NULL; |
575 | 575 | } |
576 | 576 | |
@@ -578,16 +578,16 @@ discard block |
||
578 | 578 | |
579 | 579 | $meta_content = ''; |
580 | 580 | |
581 | - foreach( $meta_keys as $key ) { |
|
582 | - $meta = get_post_meta( $post_id, $key , true ); |
|
583 | - if( ! is_string( $meta ) ) { |
|
581 | + foreach ( $meta_keys as $key ) { |
|
582 | + $meta = get_post_meta( $post_id, $key, true ); |
|
583 | + if ( ! is_string( $meta ) ) { |
|
584 | 584 | continue; |
585 | 585 | } |
586 | 586 | $meta_content .= $meta . ' '; |
587 | 587 | } |
588 | 588 | |
589 | - if( empty( $meta_content ) ) { |
|
590 | - 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 ); |
|
589 | + if ( empty( $meta_content ) ) { |
|
590 | + 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 ); |
|
591 | 591 | return NULL; |
592 | 592 | } |
593 | 593 | |
@@ -615,16 +615,16 @@ discard block |
||
615 | 615 | $message = NULL; |
616 | 616 | |
617 | 617 | // Not invalid if not set! |
618 | - if( empty( $post_id ) || empty( $view_id ) ) { |
|
618 | + if ( empty( $post_id ) || empty( $view_id ) ) { |
|
619 | 619 | |
620 | - if( $empty_is_valid ) { |
|
620 | + if ( $empty_is_valid ) { |
|
621 | 621 | return true; |
622 | 622 | } |
623 | 623 | |
624 | 624 | $message = esc_html__( 'The ID is required.', 'gravityview' ); |
625 | 625 | } |
626 | 626 | |
627 | - if( ! $message ) { |
|
627 | + if ( ! $message ) { |
|
628 | 628 | $status = get_post_status( $post_id ); |
629 | 629 | |
630 | 630 | // Nothing exists with that post ID. |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | } |
637 | 637 | } |
638 | 638 | |
639 | - if( ! $message ) { |
|
639 | + if ( ! $message ) { |
|
640 | 640 | |
641 | 641 | // Nothing exists with that post ID. |
642 | 642 | if ( empty( $status ) || in_array( $status, array( 'revision', 'attachment' ) ) ) { |
@@ -645,8 +645,8 @@ discard block |
||
645 | 645 | |
646 | 646 | } |
647 | 647 | |
648 | - if( ! $message ) { |
|
649 | - if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) && $post = get_post( $post_id ) ) { |
|
648 | + if ( ! $message ) { |
|
649 | + if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) && $post = get_post( $post_id ) ) { |
|
650 | 650 | $views = GV\View_Collection::from_post( $post ); |
651 | 651 | $view_ids_in_post = array_map( function( $view ) { return $view->ID; }, $views->all() ); |
652 | 652 | } else { |
@@ -655,21 +655,21 @@ discard block |
||
655 | 655 | } |
656 | 656 | |
657 | 657 | // The post or page specified does not contain the shortcode. |
658 | - if ( false === in_array( $view_id, (array) $view_ids_in_post ) ) { |
|
658 | + if ( false === in_array( $view_id, (array)$view_ids_in_post ) ) { |
|
659 | 659 | $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>' ); |
660 | 660 | } |
661 | 661 | } |
662 | 662 | |
663 | - if( ! $message ) { |
|
663 | + if ( ! $message ) { |
|
664 | 664 | |
665 | 665 | // It's a View |
666 | 666 | if ( ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) && \GV\View::exists( $post_id ) ) |
667 | 667 | || 'gravityview' === get_post_type( $post_id ) ) { |
668 | - $message = esc_html__( 'The ID is already a View.', 'gravityview' );; |
|
668 | + $message = esc_html__( 'The ID is already a View.', 'gravityview' ); ; |
|
669 | 669 | } |
670 | 670 | } |
671 | 671 | |
672 | - if( $message ) { |
|
672 | + if ( $message ) { |
|
673 | 673 | return new WP_Error( 'invalid_embed_id', $message ); |
674 | 674 | } |
675 | 675 | |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | |
687 | 687 | $args = defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? \GV\View_Settings::defaults( $with_details ) : self::get_default_args( $with_details ); |
688 | 688 | |
689 | - if( !isset( $args[ $key ] ) ) { return NULL; } |
|
689 | + if ( ! isset( $args[ $key ] ) ) { return NULL; } |
|
690 | 690 | |
691 | 691 | return $args[ $key ]; |
692 | 692 | } |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | */ |
724 | 724 | $default_settings = apply_filters( 'gravityview_default_args', array( |
725 | 725 | 'id' => array( |
726 | - 'label' => __('View ID', 'gravityview'), |
|
726 | + 'label' => __( 'View ID', 'gravityview' ), |
|
727 | 727 | 'type' => 'number', |
728 | 728 | 'group' => 'default', |
729 | 729 | 'value' => NULL, |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | 'show_in_shortcode' => false, |
732 | 732 | ), |
733 | 733 | 'page_size' => array( |
734 | - 'label' => __('Number of entries per page', 'gravityview'), |
|
734 | + 'label' => __( 'Number of entries per page', 'gravityview' ), |
|
735 | 735 | 'type' => 'number', |
736 | 736 | 'class' => 'small-text', |
737 | 737 | 'group' => 'default', |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | 'show_in_shortcode' => true, |
740 | 740 | ), |
741 | 741 | 'offset' => array( |
742 | - 'label' => __('Offset entries starting from', 'gravityview'), |
|
742 | + 'label' => __( 'Offset entries starting from', 'gravityview' ), |
|
743 | 743 | 'type' => 'number', |
744 | 744 | 'class' => 'small-text', |
745 | 745 | 'group' => 'default', |
@@ -763,8 +763,8 @@ discard block |
||
763 | 763 | ), |
764 | 764 | 'admin_show_all_statuses' => array( |
765 | 765 | 'label' => __( 'Show all entries to administrators', 'gravityview' ), |
766 | - 'desc' => __('Administrators will be able to see entries with any approval status.', 'gravityview'), |
|
767 | - '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'), |
|
766 | + 'desc' => __( 'Administrators will be able to see entries with any approval status.', 'gravityview' ), |
|
767 | + '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' ), |
|
768 | 768 | 'requires' => 'show_only_approved', |
769 | 769 | 'type' => 'checkbox', |
770 | 770 | 'group' => 'default', |
@@ -789,40 +789,40 @@ discard block |
||
789 | 789 | 'user_edit' => array( |
790 | 790 | 'label' => __( 'Allow User Edit', 'gravityview' ), |
791 | 791 | 'group' => 'default', |
792 | - 'desc' => __('Allow logged-in users to edit entries they created.', 'gravityview'), |
|
792 | + 'desc' => __( 'Allow logged-in users to edit entries they created.', 'gravityview' ), |
|
793 | 793 | 'value' => 0, |
794 | - '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'), |
|
794 | + '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' ), |
|
795 | 795 | 'type' => 'checkbox', |
796 | 796 | 'show_in_shortcode' => true, |
797 | 797 | ), |
798 | 798 | 'user_delete' => array( |
799 | 799 | 'label' => __( 'Allow User Delete', 'gravityview' ), |
800 | 800 | 'group' => 'default', |
801 | - 'desc' => __('Allow logged-in users to delete entries they created.', 'gravityview'), |
|
801 | + 'desc' => __( 'Allow logged-in users to delete entries they created.', 'gravityview' ), |
|
802 | 802 | 'value' => 0, |
803 | - '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'), |
|
803 | + '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' ), |
|
804 | 804 | 'type' => 'checkbox', |
805 | 805 | 'show_in_shortcode' => true, |
806 | 806 | ), |
807 | 807 | 'sort_field' => array( |
808 | - 'label' => __('Sort by field', 'gravityview'), |
|
808 | + 'label' => __( 'Sort by field', 'gravityview' ), |
|
809 | 809 | 'type' => 'select', |
810 | 810 | 'value' => '', |
811 | 811 | 'group' => 'sort', |
812 | 812 | 'options' => array( |
813 | - '' => __( 'Default', 'gravityview'), |
|
814 | - 'date_created' => __( 'Date Created', 'gravityview'), |
|
813 | + '' => __( 'Default', 'gravityview' ), |
|
814 | + 'date_created' => __( 'Date Created', 'gravityview' ), |
|
815 | 815 | ), |
816 | 816 | 'show_in_shortcode' => true, |
817 | 817 | ), |
818 | 818 | 'sort_direction' => array( |
819 | - 'label' => __('Sort direction', 'gravityview'), |
|
819 | + 'label' => __( 'Sort direction', 'gravityview' ), |
|
820 | 820 | 'type' => 'select', |
821 | 821 | 'value' => 'ASC', |
822 | 822 | 'group' => 'sort', |
823 | 823 | 'options' => array( |
824 | - 'ASC' => __('ASC', 'gravityview'), |
|
825 | - 'DESC' => __('DESC', 'gravityview'), |
|
824 | + 'ASC' => __( 'ASC', 'gravityview' ), |
|
825 | + 'DESC' => __( 'DESC', 'gravityview' ), |
|
826 | 826 | //'RAND' => __('Random', 'gravityview'), |
827 | 827 | ), |
828 | 828 | 'show_in_shortcode' => true, |
@@ -838,69 +838,69 @@ discard block |
||
838 | 838 | 'show_in_template' => array( 'default_table' ), |
839 | 839 | ), |
840 | 840 | 'start_date' => array( |
841 | - 'label' => __('Filter by Start Date', 'gravityview'), |
|
841 | + 'label' => __( 'Filter by Start Date', 'gravityview' ), |
|
842 | 842 | 'class' => 'gv-datepicker', |
843 | - 'desc' => __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
843 | + 'desc' => __( 'Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
844 | 844 | 'type' => 'text', |
845 | 845 | 'value' => '', |
846 | 846 | 'group' => 'filter', |
847 | 847 | 'show_in_shortcode' => true, |
848 | 848 | ), |
849 | 849 | 'end_date' => array( |
850 | - 'label' => __('Filter by End Date', 'gravityview'), |
|
850 | + 'label' => __( 'Filter by End Date', 'gravityview' ), |
|
851 | 851 | 'class' => 'gv-datepicker', |
852 | - 'desc' => __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
852 | + 'desc' => __( 'Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
853 | 853 | 'type' => 'text', |
854 | 854 | 'value' => '', |
855 | 855 | 'group' => 'filter', |
856 | 856 | 'show_in_shortcode' => true, |
857 | 857 | ), |
858 | 858 | 'class' => array( |
859 | - 'label' => __('CSS Class', 'gravityview'), |
|
860 | - 'desc' => __('CSS class to add to the wrapping HTML container.', 'gravityview'), |
|
859 | + 'label' => __( 'CSS Class', 'gravityview' ), |
|
860 | + 'desc' => __( 'CSS class to add to the wrapping HTML container.', 'gravityview' ), |
|
861 | 861 | 'group' => 'default', |
862 | 862 | 'type' => 'text', |
863 | 863 | 'value' => '', |
864 | 864 | 'show_in_shortcode' => false, |
865 | 865 | ), |
866 | 866 | 'search_value' => array( |
867 | - 'label' => __('Search Value', 'gravityview'), |
|
868 | - 'desc' => __('Define a default search value for the View', 'gravityview'), |
|
867 | + 'label' => __( 'Search Value', 'gravityview' ), |
|
868 | + 'desc' => __( 'Define a default search value for the View', 'gravityview' ), |
|
869 | 869 | 'type' => 'text', |
870 | 870 | 'value' => '', |
871 | 871 | 'group' => 'filter', |
872 | 872 | 'show_in_shortcode' => false, |
873 | 873 | ), |
874 | 874 | 'search_field' => array( |
875 | - 'label' => __('Search Field', 'gravityview'), |
|
876 | - 'desc' => __('If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview'), |
|
875 | + 'label' => __( 'Search Field', 'gravityview' ), |
|
876 | + 'desc' => __( 'If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview' ), |
|
877 | 877 | 'type' => 'number', |
878 | 878 | 'value' => '', |
879 | 879 | 'group' => 'filter', |
880 | 880 | 'show_in_shortcode' => false, |
881 | 881 | ), |
882 | 882 | 'single_title' => array( |
883 | - 'label' => __('Single Entry Title', 'gravityview'), |
|
883 | + 'label' => __( 'Single Entry Title', 'gravityview' ), |
|
884 | 884 | 'type' => 'text', |
885 | - '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'), |
|
885 | + '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' ), |
|
886 | 886 | 'group' => 'default', |
887 | 887 | 'value' => '', |
888 | 888 | 'show_in_shortcode' => false, |
889 | 889 | 'full_width' => true, |
890 | 890 | ), |
891 | 891 | 'back_link_label' => array( |
892 | - 'label' => __('Back Link Label', 'gravityview'), |
|
892 | + 'label' => __( 'Back Link Label', 'gravityview' ), |
|
893 | 893 | 'group' => 'default', |
894 | - 'desc' => __('The text of the link that returns to the multiple entries view.', 'gravityview'), |
|
894 | + 'desc' => __( 'The text of the link that returns to the multiple entries view.', 'gravityview' ), |
|
895 | 895 | 'type' => 'text', |
896 | 896 | 'value' => '', |
897 | 897 | 'show_in_shortcode' => false, |
898 | 898 | 'full_width' => true, |
899 | 899 | ), |
900 | 900 | 'embed_only' => array( |
901 | - 'label' => __('Prevent Direct Access', 'gravityview'), |
|
901 | + 'label' => __( 'Prevent Direct Access', 'gravityview' ), |
|
902 | 902 | 'group' => 'default', |
903 | - 'desc' => __('Only allow access to this View when embedded using the shortcode.', 'gravityview'), |
|
903 | + 'desc' => __( 'Only allow access to this View when embedded using the shortcode.', 'gravityview' ), |
|
904 | 904 | 'type' => 'checkbox', |
905 | 905 | 'value' => '', |
906 | 906 | 'show_in_shortcode' => false, |
@@ -911,15 +911,15 @@ discard block |
||
911 | 911 | 'value' => '', |
912 | 912 | 'show_in_shortcode' => false, |
913 | 913 | ), |
914 | - )); |
|
914 | + ) ); |
|
915 | 915 | |
916 | 916 | // By default, we only want the key => value pairing, not the whole array. |
917 | - if( empty( $with_details ) ) { |
|
917 | + if ( empty( $with_details ) ) { |
|
918 | 918 | |
919 | 919 | $defaults = array(); |
920 | 920 | |
921 | - foreach( $default_settings as $key => $value ) { |
|
922 | - $defaults[ $key ] = $value['value']; |
|
921 | + foreach ( $default_settings as $key => $value ) { |
|
922 | + $defaults[ $key ] = $value[ 'value' ]; |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | return $defaults; |
@@ -928,12 +928,12 @@ discard block |
||
928 | 928 | // But sometimes, we want all the details. |
929 | 929 | else { |
930 | 930 | |
931 | - foreach ($default_settings as $key => $value) { |
|
931 | + foreach ( $default_settings as $key => $value ) { |
|
932 | 932 | |
933 | 933 | // If the $group argument is set for the method, |
934 | 934 | // ignore any settings that aren't in that group. |
935 | - if( !empty( $group ) && is_string( $group ) ) { |
|
936 | - if( empty( $value['group'] ) || $value['group'] !== $group ) { |
|
935 | + if ( ! empty( $group ) && is_string( $group ) ) { |
|
936 | + if ( empty( $value[ 'group' ] ) || $value[ 'group' ] !== $group ) { |
|
937 | 937 | unset( $default_settings[ $key ] ); |
938 | 938 | } |
939 | 939 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | /** Deprecated, see \GV\View_Collection::from_post */ |
102 | 102 | if( ( get_post_type( $post ) === 'gravityview' ) ) { |
103 | 103 | $ids[] = $post->ID; |
104 | - } else{ |
|
104 | + } else { |
|
105 | 105 | // Parse the Post Content |
106 | 106 | $id = $this->parse_post_content( $post->post_content ); |
107 | 107 | if( $id ) { |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | } |
647 | 647 | |
648 | 648 | if( ! $message ) { |
649 | - if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) && $post = get_post( $post_id ) ) { |
|
649 | + if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) && $post = get_post( $post_id ) ) { |
|
650 | 650 | $views = GV\View_Collection::from_post( $post ); |
651 | 651 | $view_ids_in_post = array_map( function( $view ) { return $view->ID; }, $views->all() ); |
652 | 652 | } else { |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | /** @var WP_Admin_Bar $wp_admin_bar */ |
39 | 39 | global $wp_admin_bar; |
40 | 40 | |
41 | - if( is_admin() || ! GVCommon::has_cap( array( 'edit_gravityviews', 'gravityview_edit_entry', 'gravityforms_edit_forms' ) ) ) { |
|
41 | + if ( is_admin() || ! GVCommon::has_cap( array( 'edit_gravityviews', 'gravityview_edit_entry', 'gravityforms_edit_forms' ) ) ) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | 'parent' => 'gravityview', |
111 | 111 | 'title' => __( 'Edit Entry', 'gravityview' ), |
112 | 112 | 'meta' => array( |
113 | - 'title' => sprintf( __( 'Edit Entry %s', 'gravityview' ), GravityView_API::get_entry_slug( $entry['id'], $entry ) ), |
|
113 | + 'title' => sprintf( __( 'Edit Entry %s', 'gravityview' ), GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ) ), |
|
114 | 114 | ), |
115 | - 'href' => esc_url_raw( admin_url( sprintf( 'admin.php?page=gf_entries&screen_mode=edit&view=entry&id=%d&lid=%d', $entry['form_id'], $entry['id'] ) ) ), |
|
115 | + 'href' => esc_url_raw( admin_url( sprintf( 'admin.php?page=gf_entries&screen_mode=edit&view=entry&id=%d&lid=%d', $entry[ 'form_id' ], $entry[ 'id' ] ) ) ), |
|
116 | 116 | ) ); |
117 | 117 | |
118 | 118 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | /** @var WP_Admin_Bar $wp_admin_bar */ |
129 | 129 | global $wp_admin_bar; |
130 | 130 | |
131 | - if( GVCommon::has_cap( array( 'edit_gravityviews', 'edit_gravityview', 'gravityforms_edit_forms' ) ) ) { |
|
131 | + if ( GVCommon::has_cap( array( 'edit_gravityviews', 'edit_gravityview', 'gravityforms_edit_forms' ) ) ) { |
|
132 | 132 | |
133 | 133 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
134 | 134 | $views = gravityview()->views->all(); |
@@ -152,21 +152,21 @@ discard block |
||
152 | 152 | $form_id = $view->form ? $view->form->ID : null; |
153 | 153 | } else { |
154 | 154 | /** Deprecated. */ |
155 | - $view_id = $view['id']; |
|
156 | - $form_id = $view['form_id']; |
|
155 | + $view_id = $view[ 'id' ]; |
|
156 | + $form_id = $view[ 'form_id' ]; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | $edit_view_title = __( 'Edit View', 'gravityview' ); |
160 | 160 | $edit_form_title = __( 'Edit Form', 'gravityview' ); |
161 | 161 | |
162 | - if( sizeof( $views ) > 1 ) { |
|
162 | + if ( sizeof( $views ) > 1 ) { |
|
163 | 163 | $edit_view_title = sprintf( _x( 'Edit View #%d', 'Edit View with the ID of %d', 'gravityview' ), $view_id ); |
164 | 164 | $edit_form_title = sprintf( __( 'Edit Form #%d', 'Edit Form with the ID of %d', 'gravityview' ), $form_id ); |
165 | 165 | } |
166 | 166 | |
167 | - if( GVCommon::has_cap( 'edit_gravityview', $view_id ) && ! in_array( $view_id, $added_views ) ) { |
|
167 | + if ( GVCommon::has_cap( 'edit_gravityview', $view_id ) && ! in_array( $view_id, $added_views ) ) { |
|
168 | 168 | |
169 | - $added_views[] = $view_id; |
|
169 | + $added_views[ ] = $view_id; |
|
170 | 170 | |
171 | 171 | $wp_admin_bar->add_menu( array( |
172 | 172 | 'id' => 'edit-view-' . $view_id, |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | ) ); |
177 | 177 | } |
178 | 178 | |
179 | - if ( ! empty( $form_id ) && GVCommon::has_cap( array( 'gravityforms_edit_forms' ), $form_id ) && ! in_array( $form_id, $added_forms ) ) { |
|
179 | + if ( ! empty( $form_id ) && GVCommon::has_cap( array( 'gravityforms_edit_forms' ), $form_id ) && ! in_array( $form_id, $added_forms ) ) { |
|
180 | 180 | |
181 | - $added_forms[] = $form_id; |
|
181 | + $added_forms[ ] = $form_id; |
|
182 | 182 | |
183 | 183 | $wp_admin_bar->add_menu( array( |
184 | 184 | 'id' => 'edit-form-' . $form_id, |