@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'tooltips' ) ); |
50 | 50 | |
51 | 51 | // adding styles and scripts |
52 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') ); |
|
52 | + add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ) ); |
|
53 | 53 | // bypass Gravity Forms no-conflict mode |
54 | 54 | add_filter( 'gform_noconflict_scripts', array( $this, 'register_gform_noconflict_script' ) ); |
55 | 55 | add_filter( 'gform_noconflict_styles', array( $this, 'register_gform_noconflict_style' ) ); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param bool $show_filter_links True: show the "approved"/"disapproved" filter links. False: hide them. |
79 | 79 | * @param array $form GF Form object of current form |
80 | 80 | */ |
81 | - if( false === apply_filters( 'gravityview/approve_entries/show_filter_links_entry_list', true, $form ) ) { |
|
81 | + if ( false === apply_filters( 'gravityview/approve_entries/show_filter_links_entry_list', true, $form ) ) { |
|
82 | 82 | return $filter_links; |
83 | 83 | } |
84 | 84 | |
@@ -106,27 +106,27 @@ discard block |
||
106 | 106 | $approved_count = $disapproved_count = $unapproved_count = 0; |
107 | 107 | |
108 | 108 | // Only count if necessary |
109 | - if( $include_counts ) { |
|
110 | - $approved_count = count( gravityview_get_entry_ids( $form['id'], array( 'status' => 'active', 'field_filters' => $field_filters_approved ) ) ); |
|
111 | - $disapproved_count = count( gravityview_get_entry_ids( $form['id'], array( 'status' => 'active', 'field_filters' => $field_filters_disapproved ) ) ); |
|
112 | - $unapproved_count = count( gravityview_get_entry_ids( $form['id'], array( 'status' => 'active', 'field_filters' => $field_filters_unapproved ) ) ); |
|
109 | + if ( $include_counts ) { |
|
110 | + $approved_count = count( gravityview_get_entry_ids( $form[ 'id' ], array( 'status' => 'active', 'field_filters' => $field_filters_approved ) ) ); |
|
111 | + $disapproved_count = count( gravityview_get_entry_ids( $form[ 'id' ], array( 'status' => 'active', 'field_filters' => $field_filters_disapproved ) ) ); |
|
112 | + $unapproved_count = count( gravityview_get_entry_ids( $form[ 'id' ], array( 'status' => 'active', 'field_filters' => $field_filters_unapproved ) ) ); |
|
113 | 113 | } |
114 | 114 | |
115 | - $filter_links[] = array( |
|
115 | + $filter_links[ ] = array( |
|
116 | 116 | 'id' => 'gv_approved', |
117 | 117 | 'field_filters' => $field_filters_approved, |
118 | 118 | 'count' => $approved_count, |
119 | 119 | 'label' => GravityView_Entry_Approval_Status::get_label( GravityView_Entry_Approval_Status::APPROVED ), |
120 | 120 | ); |
121 | 121 | |
122 | - $filter_links[] = array( |
|
122 | + $filter_links[ ] = array( |
|
123 | 123 | 'id' => 'gv_disapproved', |
124 | 124 | 'field_filters' => $field_filters_disapproved, |
125 | 125 | 'count' => $disapproved_count, |
126 | 126 | 'label' => GravityView_Entry_Approval_Status::get_label( GravityView_Entry_Approval_Status::DISAPPROVED ), |
127 | 127 | ); |
128 | 128 | |
129 | - $filter_links[] = array( |
|
129 | + $filter_links[ ] = array( |
|
130 | 130 | 'id' => 'gv_unapproved', |
131 | 131 | 'field_filters' => $field_filters_unapproved, |
132 | 132 | 'count' => $unapproved_count, |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function tooltips( $tooltips ) { |
147 | 147 | |
148 | - $tooltips['form_gravityview_fields'] = array( |
|
149 | - 'title' => __('GravityView Fields', 'gravityview'), |
|
150 | - 'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview'), |
|
148 | + $tooltips[ 'form_gravityview_fields' ] = array( |
|
149 | + 'title' => __( 'GravityView Fields', 'gravityview' ), |
|
150 | + 'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview' ), |
|
151 | 151 | ); |
152 | 152 | |
153 | 153 | return $tooltips; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @return boolean True: It worked; False: it failed |
262 | 262 | */ |
263 | - public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { |
|
263 | + public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0 ) { |
|
264 | 264 | return GravityView_Entry_Approval::update_approved( $entry_id, $approved, $form_id, $approvedcolumn ); |
265 | 265 | } |
266 | 266 | |
@@ -290,20 +290,20 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @return void |
292 | 292 | */ |
293 | - static public function add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string ) { |
|
293 | + static public function add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string ) { |
|
294 | 294 | |
295 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry['id'] ) ) { |
|
295 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry[ 'id' ] ) ) { |
|
296 | 296 | return; |
297 | 297 | } |
298 | 298 | |
299 | - if( empty( $entry['id'] ) ) { |
|
299 | + if ( empty( $entry[ 'id' ] ) ) { |
|
300 | 300 | return; |
301 | 301 | } |
302 | 302 | |
303 | 303 | $status_value = GravityView_Entry_Approval::get_entry_status( $entry, 'value' ); |
304 | 304 | |
305 | - if( $status_value ) { |
|
306 | - echo '<input type="hidden" class="entry_approval" id="entry_approved_'. $entry['id'] .'" value="' . esc_attr( $status_value ) . '" />'; |
|
305 | + if ( $status_value ) { |
|
306 | + echo '<input type="hidden" class="entry_approval" id="entry_approved_' . $entry[ 'id' ] . '" value="' . esc_attr( $status_value ) . '" />'; |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
@@ -316,10 +316,10 @@ discard block |
||
316 | 316 | */ |
317 | 317 | private function get_form_id() { |
318 | 318 | |
319 | - $form_id = GFForms::get('id'); |
|
319 | + $form_id = GFForms::get( 'id' ); |
|
320 | 320 | |
321 | 321 | // If there are no forms identified, use the first form. That's how GF does it. |
322 | - if( empty( $form_id ) && class_exists('RGFormsModel') ) { |
|
322 | + if ( empty( $form_id ) && class_exists( 'RGFormsModel' ) ) { |
|
323 | 323 | $form_id = $this->get_first_form_id(); |
324 | 324 | } |
325 | 325 | |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | |
340 | 340 | $forms = RGFormsModel::get_forms( null, 'title' ); |
341 | 341 | |
342 | - if( ! isset( $forms[0] ) ) { |
|
342 | + if ( ! isset( $forms[ 0 ] ) ) { |
|
343 | 343 | gravityview()->log->error( 'No forms were found' ); |
344 | 344 | return 0; |
345 | 345 | } |
346 | 346 | |
347 | - $first_form = $forms[0]; |
|
347 | + $first_form = $forms[ 0 ]; |
|
348 | 348 | |
349 | - $form_id = is_object( $forms[0] ) ? $first_form->id : $first_form['id']; |
|
349 | + $form_id = is_object( $forms[ 0 ] ) ? $first_form->id : $first_form[ 'id' ]; |
|
350 | 350 | |
351 | 351 | return intval( $form_id ); |
352 | 352 | } |
@@ -354,37 +354,37 @@ discard block |
||
354 | 354 | |
355 | 355 | function add_scripts_and_styles( $hook ) { |
356 | 356 | |
357 | - if( ! class_exists( 'GFForms' ) ) { |
|
357 | + if ( ! class_exists( 'GFForms' ) ) { |
|
358 | 358 | gravityview()->log->error( 'GFForms does not exist.' ); |
359 | 359 | return; |
360 | 360 | } |
361 | 361 | |
362 | 362 | // enqueue styles & scripts gf_entries |
363 | 363 | // But only if we're on the main Entries page, not on reports pages |
364 | - if( GFForms::get_page() !== 'entry_list' ) { |
|
364 | + if ( GFForms::get_page() !== 'entry_list' ) { |
|
365 | 365 | return; |
366 | 366 | } |
367 | 367 | |
368 | 368 | $form_id = $this->get_form_id(); |
369 | 369 | |
370 | 370 | // Things are broken; no forms were found |
371 | - if( empty( $form_id ) ) { |
|
371 | + if ( empty( $form_id ) ) { |
|
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | - wp_enqueue_style( 'gravityview_entries_list', plugins_url('assets/css/admin-entries-list.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
375 | + wp_enqueue_style( 'gravityview_entries_list', plugins_url( 'assets/css/admin-entries-list.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
|
376 | 376 | |
377 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
377 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
378 | 378 | |
379 | - wp_enqueue_script( 'gravityview_gf_entries_scripts', plugins_url('assets/js/admin-entries-list'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version ); |
|
379 | + wp_enqueue_script( 'gravityview_gf_entries_scripts', plugins_url( 'assets/js/admin-entries-list' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version ); |
|
380 | 380 | |
381 | 381 | wp_enqueue_script( 'gravityview_entries_list-popper', plugins_url( 'assets/lib/tippy/popper.min.js', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
382 | 382 | wp_enqueue_script( 'gravityview_entries_list-tippy', plugins_url( 'assets/lib/tippy/tippy.min.js', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
383 | 383 | wp_enqueue_style( 'gravityview_entries_list-tippy', plugins_url( 'assets/lib/tippy/tippy.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
384 | 384 | |
385 | 385 | wp_localize_script( 'gravityview_gf_entries_scripts', 'gvGlobals', array( |
386 | - 'nonce' => wp_create_nonce( 'gravityview_entry_approval'), |
|
387 | - 'admin_nonce' => wp_create_nonce( 'gravityview_admin_entry_approval'), |
|
386 | + 'nonce' => wp_create_nonce( 'gravityview_entry_approval' ), |
|
387 | + 'admin_nonce' => wp_create_nonce( 'gravityview_admin_entry_approval' ), |
|
388 | 388 | 'form_id' => $form_id, |
389 | 389 | 'show_column' => (int)$this->show_approve_entry_column( $form_id ), |
390 | 390 | 'add_bulk_action' => (int)GVCommon::has_cap( 'gravityview_moderate_entries' ), |
@@ -393,10 +393,10 @@ discard block |
||
393 | 393 | 'status_unapproved' => GravityView_Entry_Approval_Status::UNAPPROVED, |
394 | 394 | 'bulk_actions' => GravityView_Bulk_Actions::get_bulk_actions( $form_id ), |
395 | 395 | 'bulk_message' => $this->bulk_update_message, |
396 | - 'unapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('unapproved'), |
|
397 | - 'approve_title' => GravityView_Entry_Approval_Status::get_title_attr('disapproved'), |
|
398 | - 'disapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('approved'), |
|
399 | - 'column_title' => __( 'Show entry in directory view?', 'gravityview'), |
|
396 | + 'unapprove_title' => GravityView_Entry_Approval_Status::get_title_attr( 'unapproved' ), |
|
397 | + 'approve_title' => GravityView_Entry_Approval_Status::get_title_attr( 'disapproved' ), |
|
398 | + 'disapprove_title' => GravityView_Entry_Approval_Status::get_title_attr( 'approved' ), |
|
399 | + 'column_title' => __( 'Show entry in directory view?', 'gravityview' ), |
|
400 | 400 | 'column_link' => esc_url( $this->get_sort_link() ), |
401 | 401 | 'status_popover_template' => GravityView_Entry_Approval::get_popover_template(), |
402 | 402 | 'status_popover_placement' => GravityView_Entry_Approval::get_popover_placement(), |
@@ -444,13 +444,13 @@ discard block |
||
444 | 444 | * @since 1.7.2 |
445 | 445 | * @param boolean $hide_if_no_connections |
446 | 446 | */ |
447 | - $hide_if_no_connections = apply_filters('gravityview/approve_entries/hide-if-no-connections', false ); |
|
447 | + $hide_if_no_connections = apply_filters( 'gravityview/approve_entries/hide-if-no-connections', false ); |
|
448 | 448 | |
449 | - if( $hide_if_no_connections ) { |
|
449 | + if ( $hide_if_no_connections ) { |
|
450 | 450 | |
451 | 451 | $connected_views = gravityview_get_connected_views( $form_id ); |
452 | 452 | |
453 | - if( empty( $connected_views ) ) { |
|
453 | + if ( empty( $connected_views ) ) { |
|
454 | 454 | $show_approve_column = false; |
455 | 455 | } |
456 | 456 | } |
@@ -460,21 +460,21 @@ discard block |
||
460 | 460 | * @param boolean $show_approve_column Whether the column will be shown |
461 | 461 | * @param int $form_id The ID of the Gravity Forms form for which entries are being shown |
462 | 462 | */ |
463 | - $show_approve_column = apply_filters('gravityview/approve_entries/show-column', $show_approve_column, $form_id ); |
|
463 | + $show_approve_column = apply_filters( 'gravityview/approve_entries/show-column', $show_approve_column, $form_id ); |
|
464 | 464 | |
465 | 465 | return $show_approve_column; |
466 | 466 | } |
467 | 467 | |
468 | 468 | function register_gform_noconflict_script( $scripts ) { |
469 | - $scripts[] = 'gravityview_gf_entries_scripts'; |
|
470 | - $scripts[] = 'gravityview_entries_list-popper'; |
|
471 | - $scripts[] = 'gravityview_entries_list-tippy'; |
|
469 | + $scripts[ ] = 'gravityview_gf_entries_scripts'; |
|
470 | + $scripts[ ] = 'gravityview_entries_list-popper'; |
|
471 | + $scripts[ ] = 'gravityview_entries_list-tippy'; |
|
472 | 472 | return $scripts; |
473 | 473 | } |
474 | 474 | |
475 | 475 | function register_gform_noconflict_style( $styles ) { |
476 | - $styles[] = 'gravityview_entries_list'; |
|
477 | - $styles[] = 'gravityview_entries_list-tippy'; |
|
476 | + $styles[ ] = 'gravityview_entries_list'; |
|
477 | + $styles[ ] = 'gravityview_entries_list-tippy'; |
|
478 | 478 | return $styles; |
479 | 479 | } |
480 | 480 |
@@ -108,17 +108,17 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function allowed_atts( $atts = array() ) { |
110 | 110 | |
111 | - $atts['data-fancybox'] = null; |
|
112 | - $atts['data-fancybox-trigger'] = null; |
|
113 | - $atts['data-fancybox-index'] = null; |
|
114 | - $atts['data-src'] = null; |
|
115 | - $atts['data-type'] = null; |
|
116 | - $atts['data-width'] = null; |
|
117 | - $atts['data-height'] = null; |
|
118 | - $atts['data-srcset'] = null; |
|
119 | - $atts['data-caption'] = null; |
|
120 | - $atts['data-options'] = null; |
|
121 | - $atts['data-filter'] = null; |
|
111 | + $atts[ 'data-fancybox' ] = null; |
|
112 | + $atts[ 'data-fancybox-trigger' ] = null; |
|
113 | + $atts[ 'data-fancybox-index' ] = null; |
|
114 | + $atts[ 'data-src' ] = null; |
|
115 | + $atts[ 'data-type' ] = null; |
|
116 | + $atts[ 'data-width' ] = null; |
|
117 | + $atts[ 'data-height' ] = null; |
|
118 | + $atts[ 'data-srcset' ] = null; |
|
119 | + $atts[ 'data-caption' ] = null; |
|
120 | + $atts[ 'data-options' ] = null; |
|
121 | + $atts[ 'data-filter' ] = null; |
|
122 | 122 | |
123 | 123 | return $atts; |
124 | 124 | } |
@@ -133,23 +133,23 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | // Prevent empty content from getting added to the lightbox gallery |
136 | - if ( is_array( $additional_details ) && empty( $additional_details['file_path'] ) ) { |
|
136 | + if ( is_array( $additional_details ) && empty( $additional_details[ 'file_path' ] ) ) { |
|
137 | 137 | return $link_atts; |
138 | 138 | } |
139 | 139 | |
140 | 140 | // Prevent empty content from getting added to the lightbox gallery |
141 | - if ( is_array( $additional_details ) && ! empty( $additional_details['disable_lightbox'] ) ) { |
|
141 | + if ( is_array( $additional_details ) && ! empty( $additional_details[ 'disable_lightbox' ] ) ) { |
|
142 | 142 | return $link_atts; |
143 | 143 | } |
144 | 144 | |
145 | - $link_atts['class'] = \GV\Utils::get( $link_atts, 'class' ) . ' gravityview-fancybox'; |
|
145 | + $link_atts[ 'class' ] = \GV\Utils::get( $link_atts, 'class' ) . ' gravityview-fancybox'; |
|
146 | 146 | |
147 | - $link_atts['class'] = gravityview_sanitize_html_class( $link_atts['class'] ); |
|
147 | + $link_atts[ 'class' ] = gravityview_sanitize_html_class( $link_atts[ 'class' ] ); |
|
148 | 148 | |
149 | 149 | if ( $context && ! empty( $context->field->field ) ) { |
150 | 150 | if ( $context->field->field->multipleFiles ) { |
151 | 151 | $entry = $context->entry->as_entry(); |
152 | - $link_atts['data-fancybox'] = 'gallery-' . sprintf( "%s-%s-%s", $entry['form_id'], $context->field->ID, $context->entry->get_slug() ); |
|
152 | + $link_atts[ 'data-fancybox' ] = 'gallery-' . sprintf( "%s-%s-%s", $entry[ 'form_id' ], $context->field->ID, $context->entry->get_slug() ); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @see https://fancyapps.com/docs/ui/fancybox#media-types |
161 | 161 | */ |
162 | 162 | if ( false !== strpos( $file_path, 'gv-iframe' ) ) { |
163 | - $link_atts['data-type'] = 'pdf'; |
|
163 | + $link_atts[ 'data-type' ] = 'pdf'; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | return $link_atts; |
@@ -44,35 +44,35 @@ discard block |
||
44 | 44 | |
45 | 45 | if ( $object->show_previous_button ) { |
46 | 46 | $previous_tabindex = GFCommon::get_tabindex(); |
47 | - $previous_label = GFCommon::replace_variables( $labels['previous'], $object->form, $object->entry ); |
|
47 | + $previous_label = GFCommon::replace_variables( $labels[ 'previous' ], $object->form, $object->entry ); |
|
48 | 48 | ?> |
49 | - <input id="gform_previous_button_<?php echo esc_attr( $object->form['id'] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-previous" type="submit" <?php echo $previous_tabindex; ?> value="<?php echo esc_attr( $previous_label ); ?>" name="save" /> |
|
49 | + <input id="gform_previous_button_<?php echo esc_attr( $object->form[ 'id' ] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-previous" type="submit" <?php echo $previous_tabindex; ?> value="<?php echo esc_attr( $previous_label ); ?>" name="save" /> |
|
50 | 50 | <?php |
51 | 51 | } |
52 | 52 | |
53 | 53 | if ( $object->show_next_button ) { |
54 | - $next_tabindex = GFCommon::get_tabindex(); |
|
55 | - $next_label = GFCommon::replace_variables( $labels['next'], $object->form, $object->entry ); |
|
54 | + $next_tabindex = GFCommon::get_tabindex(); |
|
55 | + $next_label = GFCommon::replace_variables( $labels[ 'next' ], $object->form, $object->entry ); |
|
56 | 56 | ?> |
57 | - <input id="gform_next_button_<?php echo esc_attr( $object->form['id'] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-next" type="submit" <?php echo $next_tabindex; ?> value="<?php echo esc_attr( $next_label ); ?>" name="save" /> |
|
57 | + <input id="gform_next_button_<?php echo esc_attr( $object->form[ 'id' ] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-next" type="submit" <?php echo $next_tabindex; ?> value="<?php echo esc_attr( $next_label ); ?>" name="save" /> |
|
58 | 58 | <?php |
59 | 59 | } |
60 | 60 | |
61 | 61 | if ( $object->show_update_button ) { |
62 | - $update_tabindex = GFCommon::get_tabindex(); |
|
63 | - $update_label = GFCommon::replace_variables( $labels['submit'], $object->form, $object->entry ); |
|
62 | + $update_tabindex = GFCommon::get_tabindex(); |
|
63 | + $update_label = GFCommon::replace_variables( $labels[ 'submit' ], $object->form, $object->entry ); |
|
64 | 64 | ?> |
65 | - <input id="gform_submit_button_<?php echo esc_attr( $object->form['id'] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-update" type="submit" <?php echo $update_tabindex; ?> value="<?php echo esc_attr( $update_label ); ?>" name="save" /> |
|
65 | + <input id="gform_submit_button_<?php echo esc_attr( $object->form[ 'id' ] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-update" type="submit" <?php echo $update_tabindex; ?> value="<?php echo esc_attr( $update_label ); ?>" name="save" /> |
|
66 | 66 | <?php |
67 | 67 | } |
68 | 68 | |
69 | - $cancel_tabindex = GFCommon::get_tabindex(); |
|
70 | - $cancel_label = GFCommon::replace_variables( $labels['cancel'], $object->form, $object->entry ); |
|
69 | + $cancel_tabindex = GFCommon::get_tabindex(); |
|
70 | + $cancel_label = GFCommon::replace_variables( $labels[ 'cancel' ], $object->form, $object->entry ); |
|
71 | 71 | |
72 | 72 | // If the entry has been edited, history.back() will keep pointing to the Edit Entry screen. Go back before editing, please! |
73 | 73 | // On first visit, will be history.go(-1) because (0 + 1 * -1). |
74 | 74 | // After updating twice, history.go(-3) because (2 + 1 * -1) |
75 | - $update_count = (int) \GV\Utils::_POST( 'update_count', 0 ); |
|
75 | + $update_count = (int)\GV\Utils::_POST( 'update_count', 0 ); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @filter `gravityview/edit_entry/cancel_onclick` Modify the `onclick` attribute for the back link. To remove `onclick` altogether, return an empty string. |
@@ -106,5 +106,5 @@ discard block |
||
106 | 106 | ?> |
107 | 107 | <input type='hidden' name='update_count' value='<?php echo $update_count + 1; ?>'/> |
108 | 108 | <input type="hidden" name="action" value="update" /> |
109 | - <input type="hidden" name="lid" value="<?php echo esc_attr( $object->entry['id'] ); ?>" /> |
|
109 | + <input type="hidden" name="lid" value="<?php echo esc_attr( $object->entry[ 'id' ] ); ?>" /> |
|
110 | 110 | </div> |
@@ -85,10 +85,10 @@ 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( 'render_block', array( $this, 'detect_views_in_block_content' ) ); |
90 | 90 | add_filter( 'parse_query', array( $this, 'parse_query_fix_frontpage' ), 10 ); |
91 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 ); |
|
91 | + add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 ); |
|
92 | 92 | |
93 | 93 | // Enqueue scripts and styles after GravityView_Template::register_styles() |
94 | 94 | add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 ); |
@@ -235,18 +235,18 @@ discard block |
||
235 | 235 | |
236 | 236 | if ( ! empty( $view_id ) ) { |
237 | 237 | |
238 | - $this->context_view_id = (int) $view_id; |
|
238 | + $this->context_view_id = (int)$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 = (int) $_GET['gvid']; |
|
245 | + $this->context_view_id = (int)$_GET[ 'gvid' ]; |
|
246 | 246 | |
247 | 247 | } elseif ( ! $multiple_views ) { |
248 | 248 | $array_keys = array_keys( $this->getGvOutputData()->get_views() ); |
249 | - $this->context_view_id = (int) array_pop( $array_keys ); |
|
249 | + $this->context_view_id = (int)array_pop( $array_keys ); |
|
250 | 250 | unset( $array_keys ); |
251 | 251 | } |
252 | 252 | |
@@ -279,25 +279,25 @@ discard block |
||
279 | 279 | global $wp_rewrite; |
280 | 280 | |
281 | 281 | $is_front_page = ( $query->is_home || $query->is_page ); |
282 | - $show_on_front = ( 'page' === get_option('show_on_front') ); |
|
283 | - $front_page_id = get_option('page_on_front'); |
|
282 | + $show_on_front = ( 'page' === get_option( 'show_on_front' ) ); |
|
283 | + $front_page_id = get_option( 'page_on_front' ); |
|
284 | 284 | |
285 | - if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
285 | + if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
286 | 286 | |
287 | 287 | // Force to be an array, potentially a query string ( entry=16 ) |
288 | 288 | $_query = wp_parse_args( $query->query ); |
289 | 289 | |
290 | 290 | // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. |
291 | - if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { |
|
292 | - unset( $_query['pagename'] ); |
|
291 | + if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) { |
|
292 | + unset( $_query[ 'pagename' ] ); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | // this is where will break from core wordpress |
296 | 296 | /** @internal Don't use this filter; it will be unnecessary soon - it's just a patch for specific use case */ |
297 | 297 | $ignore = apply_filters( 'gravityview/internal/ignored_endpoints', array( 'preview', 'page', 'paged', 'cpage' ), $query ); |
298 | 298 | $endpoints = \GV\Utils::get( $wp_rewrite, 'endpoints' ); |
299 | - foreach ( (array) $endpoints as $endpoint ) { |
|
300 | - $ignore[] = $endpoint[1]; |
|
299 | + foreach ( (array)$endpoints as $endpoint ) { |
|
300 | + $ignore[ ] = $endpoint[ 1 ]; |
|
301 | 301 | } |
302 | 302 | unset( $endpoints ); |
303 | 303 | |
@@ -307,21 +307,21 @@ discard block |
||
307 | 307 | // - The query includes keys that are associated with registered endpoints. `entry`, for example. |
308 | 308 | if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) { |
309 | 309 | |
310 | - $qv =& $query->query_vars; |
|
310 | + $qv = & $query->query_vars; |
|
311 | 311 | |
312 | 312 | // Prevent redirect when on the single entry endpoint |
313 | - if( self::is_single_entry() ) { |
|
313 | + if ( self::is_single_entry() ) { |
|
314 | 314 | add_filter( 'redirect_canonical', '__return_false' ); |
315 | 315 | } |
316 | 316 | |
317 | 317 | $query->is_page = true; |
318 | 318 | $query->is_home = false; |
319 | - $qv['page_id'] = $front_page_id; |
|
319 | + $qv[ 'page_id' ] = $front_page_id; |
|
320 | 320 | |
321 | 321 | // Correct <!--nextpage--> for page_on_front |
322 | - if ( ! empty( $qv['paged'] ) ) { |
|
323 | - $qv['page'] = $qv['paged']; |
|
324 | - unset( $qv['paged'] ); |
|
322 | + if ( ! empty( $qv[ 'paged' ] ) ) { |
|
323 | + $qv[ 'page' ] = $qv[ 'paged' ]; |
|
324 | + unset( $qv[ 'paged' ] ); |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | |
@@ -383,11 +383,11 @@ discard block |
||
383 | 383 | $blocks = parse_blocks( $post_content ); |
384 | 384 | |
385 | 385 | foreach ( $blocks as $block ) { |
386 | - if ( empty( $block['attrs']['ref'] ) ) { |
|
386 | + if ( empty( $block[ 'attrs' ][ 'ref' ] ) ) { |
|
387 | 387 | continue; |
388 | 388 | } |
389 | 389 | |
390 | - $block_post = get_post( $block['attrs']['ref'] ); |
|
390 | + $block_post = get_post( $block[ 'attrs' ][ 'ref' ] ); |
|
391 | 391 | |
392 | 392 | if ( $block_post ) { |
393 | 393 | $post_content .= $block_post->post_content; |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | |
441 | 441 | $search_method = GravityView_Widget_Search::getInstance()->get_search_method(); |
442 | 442 | |
443 | - if( 'post' === $search_method ) { |
|
443 | + if ( 'post' === $search_method ) { |
|
444 | 444 | $get = $_POST; |
445 | 445 | } else { |
446 | 446 | $get = $_GET; |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | $gventry = gravityview()->request->is_entry(); |
493 | 493 | |
494 | 494 | // If this is the directory view, return. |
495 | - if( ! $gventry ) { |
|
495 | + if ( ! $gventry ) { |
|
496 | 496 | return $passed_title; |
497 | 497 | } |
498 | 498 | |
@@ -510,19 +510,19 @@ discard block |
||
510 | 510 | } |
511 | 511 | |
512 | 512 | // WooCommerce doesn't $post_id |
513 | - if ( empty( $passed_post_id ) ) { |
|
513 | + if ( empty( $passed_post_id ) ) { |
|
514 | 514 | return $passed_title; |
515 | 515 | } |
516 | 516 | |
517 | 517 | // Don't modify the title for anything other than the current view/post. |
518 | 518 | // This is true for embedded shortcodes and Views. |
519 | - if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { |
|
519 | + if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) { |
|
520 | 520 | return $passed_title; |
521 | 521 | } |
522 | 522 | |
523 | 523 | $view = gravityview()->request->is_view(); |
524 | 524 | |
525 | - if( $view ) { |
|
525 | + if ( $view ) { |
|
526 | 526 | return $this->_get_single_entry_title( $view, $entry, $passed_title ); |
527 | 527 | } |
528 | 528 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | $view_collection = \GV\View_Collection::from_post( $post ); |
546 | 546 | |
547 | 547 | // We have multiple Views, but no gvid...this isn't valid security |
548 | - if( 1 < $view_collection->count() ) { |
|
548 | + if ( 1 < $view_collection->count() ) { |
|
549 | 549 | return $passed_title; |
550 | 550 | } |
551 | 551 | |
@@ -579,18 +579,18 @@ discard block |
||
579 | 579 | */ |
580 | 580 | $check_entry_display = apply_filters( 'gravityview/single/title/check_entry_display', true, $entry, $view ); |
581 | 581 | |
582 | - if( $check_entry_display ) { |
|
582 | + if ( $check_entry_display ) { |
|
583 | 583 | |
584 | 584 | $check_display = GVCommon::check_entry_display( $entry, $view ); |
585 | 585 | |
586 | - if( is_wp_error( $check_display ) ) { |
|
586 | + if ( is_wp_error( $check_display ) ) { |
|
587 | 587 | return $passed_title; |
588 | 588 | } |
589 | 589 | } |
590 | 590 | |
591 | 591 | $title = $view->settings->get( 'single_title', $passed_title ); |
592 | 592 | |
593 | - $form = GVCommon::get_form( $entry['form_id'] ); |
|
593 | + $form = GVCommon::get_form( $entry[ 'form_id' ] ); |
|
594 | 594 | |
595 | 595 | // We are allowing HTML in the fields, so no escaping the output |
596 | 596 | $title = GravityView_API::replace_variables( $title, $form, $entry ); |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | |
662 | 662 | $context = GravityView_View::getInstance()->getContext(); |
663 | 663 | |
664 | - switch( $context ) { |
|
664 | + switch ( $context ) { |
|
665 | 665 | case 'directory': |
666 | 666 | $tab = __( 'Multiple Entries', 'gravityview' ); |
667 | 667 | break; |
@@ -675,12 +675,12 @@ discard block |
||
675 | 675 | } |
676 | 676 | |
677 | 677 | |
678 | - $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 ); |
|
678 | + $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 ); |
|
679 | 679 | $edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $view_id, $context ) ); |
680 | - $action_text = sprintf( esc_html__('Add fields to %s', 'gravityview' ), $tab ); |
|
680 | + $action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab ); |
|
681 | 681 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
682 | 682 | |
683 | - $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 ) ) ); |
|
683 | + $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 ) ) ); |
|
684 | 684 | $output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message ); |
685 | 685 | |
686 | 686 | echo GVCommon::generate_notice( $output . $image, 'gv-error error', 'edit_gravityview', $view_id ); |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | $direct_access = apply_filters( 'gravityview_direct_access', true, $view->ID ); |
728 | 728 | $embed_only = $view->settings->get( 'embed_only' ); |
729 | 729 | |
730 | - if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
730 | + if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
731 | 731 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
732 | 732 | } |
733 | 733 | |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | $datetime_format = 'Y-m-d H:i:s'; |
775 | 775 | $search_is_outside_view_bounds = false; |
776 | 776 | |
777 | - if( ! empty( $search_criteria[ $key ] ) ) { |
|
777 | + if ( ! empty( $search_criteria[ $key ] ) ) { |
|
778 | 778 | |
779 | 779 | $search_date = strtotime( $search_criteria[ $key ], GFCommon::get_local_timestamp() ); |
780 | 780 | |
@@ -802,14 +802,14 @@ discard block |
||
802 | 802 | if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { |
803 | 803 | |
804 | 804 | // Then we override the search and re-set the start date |
805 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true ); |
|
805 | + $return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true ); |
|
806 | 806 | } |
807 | 807 | } |
808 | 808 | } |
809 | 809 | |
810 | - if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { |
|
810 | + if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) { |
|
811 | 811 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue. |
812 | - if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { |
|
812 | + if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) { |
|
813 | 813 | gravityview()->log->error( 'Invalid search: the start date is after the end date.', array( 'data' => $return_search_criteria ) ); |
814 | 814 | } |
815 | 815 | } |
@@ -828,19 +828,19 @@ discard block |
||
828 | 828 | public static function process_search_only_approved( $args, $search_criteria ) { |
829 | 829 | |
830 | 830 | /** @since 1.19 */ |
831 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
831 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
832 | 832 | gravityview()->log->debug( 'User can moderate entries; showing all approval statuses' ); |
833 | 833 | return $search_criteria; |
834 | 834 | } |
835 | 835 | |
836 | - if ( ! empty( $args['show_only_approved'] ) ) { |
|
836 | + if ( ! empty( $args[ 'show_only_approved' ] ) ) { |
|
837 | 837 | |
838 | - $search_criteria['field_filters'][] = array( |
|
838 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
839 | 839 | 'key' => GravityView_Entry_Approval::meta_key, |
840 | 840 | 'value' => GravityView_Entry_Approval_Status::APPROVED |
841 | 841 | ); |
842 | 842 | |
843 | - $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met |
|
843 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met |
|
844 | 844 | |
845 | 845 | gravityview()->log->debug( '[process_search_only_approved] Search Criteria if show only approved: ', array( 'data' => $search_criteria ) ); |
846 | 846 | } |
@@ -867,18 +867,18 @@ discard block |
||
867 | 867 | */ |
868 | 868 | public static function is_entry_approved( $entry, $args = array() ) { |
869 | 869 | |
870 | - if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { |
|
870 | + if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) { |
|
871 | 871 | // is implicitly approved if entry is null or View settings doesn't require to check for approval |
872 | 872 | return true; |
873 | 873 | } |
874 | 874 | |
875 | 875 | /** @since 1.19 */ |
876 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
876 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
877 | 877 | gravityview()->log->debug( 'User can moderate entries, so entry is approved for viewing' ); |
878 | 878 | return true; |
879 | 879 | } |
880 | 880 | |
881 | - $is_approved = gform_get_meta( $entry['id'], GravityView_Entry_Approval::meta_key ); |
|
881 | + $is_approved = gform_get_meta( $entry[ 'id' ], GravityView_Entry_Approval::meta_key ); |
|
882 | 882 | |
883 | 883 | return GravityView_Entry_Approval_Status::is_approved( $is_approved ); |
884 | 884 | } |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | * Compatibility with filters hooking in `gravityview_search_criteria` instead of `gravityview_fe_search_criteria`. |
903 | 903 | */ |
904 | 904 | $criteria = apply_filters( 'gravityview_search_criteria', array(), array( $form_id ), \GV\Utils::get( $args, 'id' ) ); |
905 | - $search_criteria = isset( $criteria['search_criteria'] ) ? $criteria['search_criteria'] : array( 'field_filters' => array() ); |
|
905 | + $search_criteria = isset( $criteria[ 'search_criteria' ] ) ? $criteria[ 'search_criteria' ] : array( 'field_filters' => array() ); |
|
906 | 906 | |
907 | 907 | /** |
908 | 908 | * @filter `gravityview_fe_search_criteria` Modify the search criteria |
@@ -922,29 +922,29 @@ discard block |
||
922 | 922 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', array( 'data' =>$search_criteria ) ); |
923 | 923 | |
924 | 924 | // implicity search |
925 | - if ( ! empty( $args['search_value'] ) ) { |
|
925 | + if ( ! empty( $args[ 'search_value' ] ) ) { |
|
926 | 926 | |
927 | 927 | // Search operator options. Options: `is` or `contains` |
928 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains'; |
|
928 | + $operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains'; |
|
929 | 929 | |
930 | - $search_criteria['field_filters'][] = array( |
|
930 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
931 | 931 | 'key' => \GV\Utils::_GET( 'search_field', \GV\Utils::get( $args, 'search_field' ) ), // The field ID to search |
932 | - 'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes. |
|
932 | + 'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes. |
|
933 | 933 | 'operator' => $operator, |
934 | 934 | ); |
935 | 935 | |
936 | 936 | // Lock search mode to "all" with implicit presearch filter. |
937 | - $search_criteria['field_filters']['mode'] = 'all'; |
|
937 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; |
|
938 | 938 | } |
939 | 939 | |
940 | - if( $search_criteria !== $original_search_criteria ) { |
|
940 | + if ( $search_criteria !== $original_search_criteria ) { |
|
941 | 941 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after implicity search: ', array( 'data' => $search_criteria ) ); |
942 | 942 | } |
943 | 943 | |
944 | 944 | // Handle setting date range |
945 | 945 | $search_criteria = self::process_search_dates( $args, $search_criteria ); |
946 | 946 | |
947 | - if( $search_criteria !== $original_search_criteria ) { |
|
947 | + if ( $search_criteria !== $original_search_criteria ) { |
|
948 | 948 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after date params: ', array( 'data' => $search_criteria ) ); |
949 | 949 | } |
950 | 950 | |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | * @filter `gravityview_status` Modify entry status requirements to be included in search results. |
956 | 956 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash` |
957 | 957 | */ |
958 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args ); |
|
958 | + $search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args ); |
|
959 | 959 | |
960 | 960 | return $search_criteria; |
961 | 961 | } |
@@ -1067,7 +1067,7 @@ discard block |
||
1067 | 1067 | 'search_criteria' => $search_criteria, |
1068 | 1068 | 'sorting' => self::updateViewSorting( $args, $form_id ), |
1069 | 1069 | 'paging' => $paging, |
1070 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true, |
|
1070 | + 'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true, |
|
1071 | 1071 | ); |
1072 | 1072 | |
1073 | 1073 | /** |
@@ -1092,7 +1092,7 @@ discard block |
||
1092 | 1092 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. |
1093 | 1093 | * @param array $args View configuration args. |
1094 | 1094 | */ |
1095 | - $parameters = apply_filters( 'gravityview_get_entries_'.\GV\Utils::get( $args, 'id' ), $parameters, $args, $form_id ); |
|
1095 | + $parameters = apply_filters( 'gravityview_get_entries_' . \GV\Utils::get( $args, 'id' ), $parameters, $args, $form_id ); |
|
1096 | 1096 | |
1097 | 1097 | gravityview()->log->debug( '$parameters passed to gravityview_get_entries(): ', array( 'data' => $parameters ) ); |
1098 | 1098 | |
@@ -1117,17 +1117,17 @@ discard block |
||
1117 | 1117 | $default_page_size = apply_filters( 'gravityview_default_page_size', 25 ); |
1118 | 1118 | |
1119 | 1119 | // Paging & offset |
1120 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : $default_page_size; |
|
1120 | + $page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : $default_page_size; |
|
1121 | 1121 | |
1122 | 1122 | if ( -1 === $page_size ) { |
1123 | 1123 | $page_size = PHP_INT_MAX; |
1124 | 1124 | } |
1125 | 1125 | |
1126 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
1126 | + $curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] ); |
|
1127 | 1127 | $offset = ( $curr_page - 1 ) * $page_size; |
1128 | 1128 | |
1129 | - if ( ! empty( $args['offset'] ) ) { |
|
1130 | - $offset += intval( $args['offset'] ); |
|
1129 | + if ( ! empty( $args[ 'offset' ] ) ) { |
|
1130 | + $offset += intval( $args[ 'offset' ] ); |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | $paging = array( |
@@ -1152,11 +1152,11 @@ discard block |
||
1152 | 1152 | public static function updateViewSorting( $args, $form_id ) { |
1153 | 1153 | $sorting = array(); |
1154 | 1154 | |
1155 | - $has_values = isset( $_GET['sort'] ); |
|
1155 | + $has_values = isset( $_GET[ 'sort' ] ); |
|
1156 | 1156 | |
1157 | - if ( $has_values && is_array( $_GET['sort'] ) ) { |
|
1158 | - $sorts = array_keys( $_GET['sort'] ); |
|
1159 | - $dirs = array_values( $_GET['sort'] ); |
|
1157 | + if ( $has_values && is_array( $_GET[ 'sort' ] ) ) { |
|
1158 | + $sorts = array_keys( $_GET[ 'sort' ] ); |
|
1159 | + $dirs = array_values( $_GET[ 'sort' ] ); |
|
1160 | 1160 | |
1161 | 1161 | if ( $has_values = array_filter( $dirs ) ) { |
1162 | 1162 | $sort_field_id = end( $sorts ); |
@@ -1165,11 +1165,11 @@ discard block |
||
1165 | 1165 | } |
1166 | 1166 | |
1167 | 1167 | if ( ! isset( $sort_field_id ) ) { |
1168 | - $sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : \GV\Utils::get( $args, 'sort_field' ); |
|
1168 | + $sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : \GV\Utils::get( $args, 'sort_field' ); |
|
1169 | 1169 | } |
1170 | 1170 | |
1171 | 1171 | if ( ! isset( $sort_direction ) ) { |
1172 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : \GV\Utils::get( $args, 'sort_direction' ); |
|
1172 | + $sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : \GV\Utils::get( $args, 'sort_direction' ); |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | 1175 | if ( is_array( $sort_field_id ) ) { |
@@ -1201,10 +1201,10 @@ discard block |
||
1201 | 1201 | $form = GFAPI::get_form( $form_id ); |
1202 | 1202 | |
1203 | 1203 | // Get the first GF_Field field ID, set as the key for entry randomization |
1204 | - if ( ! empty( $form['fields'] ) ) { |
|
1204 | + if ( ! empty( $form[ 'fields' ] ) ) { |
|
1205 | 1205 | |
1206 | 1206 | /** @var GF_Field $field */ |
1207 | - foreach ( $form['fields'] as $field ) { |
|
1207 | + foreach ( $form[ 'fields' ] as $field ) { |
|
1208 | 1208 | if ( ! is_a( $field, 'GF_Field' ) ) { |
1209 | 1209 | continue; |
1210 | 1210 | } |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | if ( is_array( $sort_field_id ) ) { |
1250 | 1250 | $modified_ids = array(); |
1251 | 1251 | foreach ( $sort_field_id as $_sort_field_id ) { |
1252 | - $modified_ids []= self::_override_sorting_id_by_field_type( $_sort_field_id, $form_id ); |
|
1252 | + $modified_ids [ ] = self::_override_sorting_id_by_field_type( $_sort_field_id, $form_id ); |
|
1253 | 1253 | } |
1254 | 1254 | return $modified_ids; |
1255 | 1255 | } |
@@ -1258,11 +1258,11 @@ discard block |
||
1258 | 1258 | |
1259 | 1259 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
1260 | 1260 | |
1261 | - if( ! $sort_field ) { |
|
1261 | + if ( ! $sort_field ) { |
|
1262 | 1262 | return $sort_field_id; |
1263 | 1263 | } |
1264 | 1264 | |
1265 | - switch ( $sort_field['type'] ) { |
|
1265 | + switch ( $sort_field[ 'type' ] ) { |
|
1266 | 1266 | |
1267 | 1267 | case 'address': |
1268 | 1268 | // Sorting by full address |
@@ -1279,7 +1279,7 @@ discard block |
||
1279 | 1279 | */ |
1280 | 1280 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
1281 | 1281 | |
1282 | - switch( strtolower( $address_part ) ){ |
|
1282 | + switch ( strtolower( $address_part ) ) { |
|
1283 | 1283 | case 'street': |
1284 | 1284 | $sort_field_id .= '.1'; |
1285 | 1285 | break; |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | if ( ! class_exists( '\GV\Entry' ) ) { |
1353 | 1353 | |
1354 | 1354 | // Not using gravityview()->log->error(), since that may not exist yet either! |
1355 | - do_action( 'gravityview_log_error', '\GV\Entry not defined yet. Backtrace: ' . wp_debug_backtrace_summary() ); |
|
1355 | + do_action( 'gravityview_log_error', '\GV\Entry not defined yet. Backtrace: ' . wp_debug_backtrace_summary() ); |
|
1356 | 1356 | |
1357 | 1357 | return null; |
1358 | 1358 | } |
@@ -1369,7 +1369,7 @@ discard block |
||
1369 | 1369 | */ |
1370 | 1370 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
1371 | 1371 | |
1372 | - if ( empty( $single_entry ) ){ |
|
1372 | + if ( empty( $single_entry ) ) { |
|
1373 | 1373 | return false; |
1374 | 1374 | } else { |
1375 | 1375 | return $single_entry; |
@@ -1390,7 +1390,7 @@ discard block |
||
1390 | 1390 | $views = $this->getGvOutputData()->get_views(); |
1391 | 1391 | |
1392 | 1392 | foreach ( $views as $view_id => $data ) { |
1393 | - $view = \GV\View::by_id( $data['id'] ); |
|
1393 | + $view = \GV\View::by_id( $data[ 'id' ] ); |
|
1394 | 1394 | $view_id = $view->ID; |
1395 | 1395 | $template_id = gravityview_get_template_id( $view->ID ); |
1396 | 1396 | $data = $view->as_data(); |
@@ -1399,7 +1399,7 @@ discard block |
||
1399 | 1399 | * Don't enqueue the scripts or styles if it's not going to be displayed. |
1400 | 1400 | * @since 1.15 |
1401 | 1401 | */ |
1402 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1402 | + if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1403 | 1403 | continue; |
1404 | 1404 | } |
1405 | 1405 | |
@@ -1428,7 +1428,7 @@ discard block |
||
1428 | 1428 | * @param \GV\View The View. |
1429 | 1429 | */ |
1430 | 1430 | $js_dependency = apply_filters( 'gravityview_lightbox_script', $js_dependency, $view ); |
1431 | - $js_dependencies[] = $js_dependency; |
|
1431 | + $js_dependencies[ ] = $js_dependency; |
|
1432 | 1432 | |
1433 | 1433 | /** |
1434 | 1434 | * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox` |
@@ -1444,7 +1444,7 @@ discard block |
||
1444 | 1444 | * @param \GV\View The View. |
1445 | 1445 | */ |
1446 | 1446 | $css_dependency = apply_filters( 'gravityview_lightbox_style', $css_dependency, $view ); |
1447 | - $css_dependencies[] = $css_dependency; |
|
1447 | + $css_dependencies[ ] = $css_dependency; |
|
1448 | 1448 | } |
1449 | 1449 | |
1450 | 1450 | /** |
@@ -1452,19 +1452,19 @@ discard block |
||
1452 | 1452 | * @see https://github.com/katzwebservices/GravityView/issues/536 |
1453 | 1453 | * @since 1.15 |
1454 | 1454 | */ |
1455 | - if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { |
|
1456 | - $css_dependencies[] = 'dashicons'; |
|
1455 | + if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) { |
|
1456 | + $css_dependencies[ ] = 'dashicons'; |
|
1457 | 1457 | } |
1458 | 1458 | |
1459 | 1459 | wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
1460 | 1460 | |
1461 | 1461 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
1462 | 1462 | |
1463 | - 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 ); |
|
1463 | + 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 ); |
|
1464 | 1464 | |
1465 | 1465 | wp_enqueue_script( 'gravityview-fe-view' ); |
1466 | 1466 | |
1467 | - if ( ! empty( $data['atts']['sort_columns'] ) ) { |
|
1467 | + if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) { |
|
1468 | 1468 | wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
1469 | 1469 | } |
1470 | 1470 | |
@@ -1527,7 +1527,7 @@ discard block |
||
1527 | 1527 | public static function add_style( $template_id ) { |
1528 | 1528 | |
1529 | 1529 | if ( ! empty( $template_id ) && wp_style_is( 'gravityview_style_' . $template_id, 'registered' ) ) { |
1530 | - gravityview()->log->debug( 'Adding extra template style for {template_id}', array( 'template_id' => $template_id ) ); |
|
1530 | + gravityview()->log->debug( 'Adding extra template style for {template_id}', array( 'template_id' => $template_id ) ); |
|
1531 | 1531 | wp_enqueue_style( 'gravityview_style_' . $template_id ); |
1532 | 1532 | } elseif ( empty( $template_id ) ) { |
1533 | 1533 | gravityview()->log->error( 'Cannot add template style; template_id is empty' ); |
@@ -1558,11 +1558,11 @@ discard block |
||
1558 | 1558 | * Not a table-based template; don't add sort icons |
1559 | 1559 | * @since 1.12 |
1560 | 1560 | */ |
1561 | - if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1561 | + if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1562 | 1562 | return $label; |
1563 | 1563 | } |
1564 | 1564 | |
1565 | - if ( ! $this->is_field_sortable( $field['id'], $form ) ) { |
|
1565 | + if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) { |
|
1566 | 1566 | return $label; |
1567 | 1567 | } |
1568 | 1568 | |
@@ -1570,29 +1570,29 @@ discard block |
||
1570 | 1570 | |
1571 | 1571 | $class = 'gv-sort'; |
1572 | 1572 | |
1573 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] ); |
|
1573 | + $sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] ); |
|
1574 | 1574 | |
1575 | 1575 | $sort_args = array( |
1576 | - 'sort' => $field['id'], |
|
1576 | + 'sort' => $field[ 'id' ], |
|
1577 | 1577 | 'dir' => 'asc', |
1578 | 1578 | ); |
1579 | 1579 | |
1580 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
1580 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
1581 | 1581 | //toggle sorting direction. |
1582 | - if ( 'asc' === $sorting['direction'] ) { |
|
1583 | - $sort_args['dir'] = 'desc'; |
|
1582 | + if ( 'asc' === $sorting[ 'direction' ] ) { |
|
1583 | + $sort_args[ 'dir' ] = 'desc'; |
|
1584 | 1584 | $class .= ' gv-icon-sort-desc'; |
1585 | 1585 | } else { |
1586 | - $sort_args['dir'] = 'asc'; |
|
1586 | + $sort_args[ 'dir' ] = 'asc'; |
|
1587 | 1587 | $class .= ' gv-icon-sort-asc'; |
1588 | 1588 | } |
1589 | 1589 | } else { |
1590 | 1590 | $class .= ' gv-icon-caret-up-down'; |
1591 | 1591 | } |
1592 | 1592 | |
1593 | - $url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); |
|
1593 | + $url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) ); |
|
1594 | 1594 | |
1595 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label; |
|
1595 | + return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a> ' . $label; |
|
1596 | 1596 | |
1597 | 1597 | } |
1598 | 1598 | |
@@ -1610,7 +1610,7 @@ discard block |
||
1610 | 1610 | |
1611 | 1611 | $field_type = $field_id; |
1612 | 1612 | |
1613 | - if( is_numeric( $field_id ) ) { |
|
1613 | + if ( is_numeric( $field_id ) ) { |
|
1614 | 1614 | $field = GFFormsModel::get_field( $form, $field_id ); |
1615 | 1615 | $field_type = $field ? $field->type : $field_id; |
1616 | 1616 | } |
@@ -1633,7 +1633,7 @@ discard block |
||
1633 | 1633 | return false; |
1634 | 1634 | } |
1635 | 1635 | |
1636 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1636 | + return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1637 | 1637 | |
1638 | 1638 | } |
1639 | 1639 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | namespace GravityView\TrustedLogin; |
10 | 10 | |
11 | 11 | // Exit if accessed directly |
12 | -if ( ! defined('ABSPATH') ) { |
|
12 | +if ( ! defined( 'ABSPATH' ) ) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | $unschedule_expiration = wp_clear_scheduled_hook( $this->hook_name, array( $site_identifier_hash ) ); |
92 | 92 | |
93 | - if ( false === $unschedule_expiration ){ |
|
93 | + if ( false === $unschedule_expiration ) { |
|
94 | 94 | $this->logging->log( sprintf( 'Could not unschedule event for %s', $this->hook_name ), __METHOD__, 'error' ); |
95 | 95 | return false; |
96 | 96 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | /** |
104 | 104 | * @param ?string $vendorDir |
105 | 105 | */ |
106 | - public function __construct($vendorDir = null) |
|
106 | + public function __construct( $vendorDir = null ) |
|
107 | 107 | { |
108 | 108 | $this->vendorDir = $vendorDir; |
109 | 109 | } |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function getPrefixes() |
115 | 115 | { |
116 | - if (!empty($this->prefixesPsr0)) { |
|
117 | - return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); |
|
116 | + if ( ! empty( $this->prefixesPsr0 ) ) { |
|
117 | + return call_user_func_array( 'array_merge', array_values( $this->prefixesPsr0 ) ); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | return array(); |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return void |
164 | 164 | */ |
165 | - public function addClassMap(array $classMap) |
|
165 | + public function addClassMap( array $classMap ) |
|
166 | 166 | { |
167 | - if ($this->classMap) { |
|
168 | - $this->classMap = array_merge($this->classMap, $classMap); |
|
167 | + if ( $this->classMap ) { |
|
168 | + $this->classMap = array_merge( $this->classMap, $classMap ); |
|
169 | 169 | } else { |
170 | 170 | $this->classMap = $classMap; |
171 | 171 | } |
@@ -181,39 +181,39 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return void |
183 | 183 | */ |
184 | - public function add($prefix, $paths, $prepend = false) |
|
184 | + public function add( $prefix, $paths, $prepend = false ) |
|
185 | 185 | { |
186 | - if (!$prefix) { |
|
187 | - if ($prepend) { |
|
186 | + if ( ! $prefix ) { |
|
187 | + if ( $prepend ) { |
|
188 | 188 | $this->fallbackDirsPsr0 = array_merge( |
189 | - (array) $paths, |
|
189 | + (array)$paths, |
|
190 | 190 | $this->fallbackDirsPsr0 |
191 | 191 | ); |
192 | 192 | } else { |
193 | 193 | $this->fallbackDirsPsr0 = array_merge( |
194 | 194 | $this->fallbackDirsPsr0, |
195 | - (array) $paths |
|
195 | + (array)$paths |
|
196 | 196 | ); |
197 | 197 | } |
198 | 198 | |
199 | 199 | return; |
200 | 200 | } |
201 | 201 | |
202 | - $first = $prefix[0]; |
|
203 | - if (!isset($this->prefixesPsr0[$first][$prefix])) { |
|
204 | - $this->prefixesPsr0[$first][$prefix] = (array) $paths; |
|
202 | + $first = $prefix[ 0 ]; |
|
203 | + if ( ! isset( $this->prefixesPsr0[ $first ][ $prefix ] ) ) { |
|
204 | + $this->prefixesPsr0[ $first ][ $prefix ] = (array)$paths; |
|
205 | 205 | |
206 | 206 | return; |
207 | 207 | } |
208 | - if ($prepend) { |
|
209 | - $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
210 | - (array) $paths, |
|
211 | - $this->prefixesPsr0[$first][$prefix] |
|
208 | + if ( $prepend ) { |
|
209 | + $this->prefixesPsr0[ $first ][ $prefix ] = array_merge( |
|
210 | + (array)$paths, |
|
211 | + $this->prefixesPsr0[ $first ][ $prefix ] |
|
212 | 212 | ); |
213 | 213 | } else { |
214 | - $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
215 | - $this->prefixesPsr0[$first][$prefix], |
|
216 | - (array) $paths |
|
214 | + $this->prefixesPsr0[ $first ][ $prefix ] = array_merge( |
|
215 | + $this->prefixesPsr0[ $first ][ $prefix ], |
|
216 | + (array)$paths |
|
217 | 217 | ); |
218 | 218 | } |
219 | 219 | } |
@@ -230,40 +230,40 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @return void |
232 | 232 | */ |
233 | - public function addPsr4($prefix, $paths, $prepend = false) |
|
233 | + public function addPsr4( $prefix, $paths, $prepend = false ) |
|
234 | 234 | { |
235 | - if (!$prefix) { |
|
235 | + if ( ! $prefix ) { |
|
236 | 236 | // Register directories for the root namespace. |
237 | - if ($prepend) { |
|
237 | + if ( $prepend ) { |
|
238 | 238 | $this->fallbackDirsPsr4 = array_merge( |
239 | - (array) $paths, |
|
239 | + (array)$paths, |
|
240 | 240 | $this->fallbackDirsPsr4 |
241 | 241 | ); |
242 | 242 | } else { |
243 | 243 | $this->fallbackDirsPsr4 = array_merge( |
244 | 244 | $this->fallbackDirsPsr4, |
245 | - (array) $paths |
|
245 | + (array)$paths |
|
246 | 246 | ); |
247 | 247 | } |
248 | - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { |
|
248 | + } elseif ( ! isset( $this->prefixDirsPsr4[ $prefix ] ) ) { |
|
249 | 249 | // Register directories for a new namespace. |
250 | - $length = strlen($prefix); |
|
251 | - if ('\\' !== $prefix[$length - 1]) { |
|
252 | - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
|
250 | + $length = strlen( $prefix ); |
|
251 | + if ( '\\' !== $prefix[ $length - 1 ] ) { |
|
252 | + throw new \InvalidArgumentException( "A non-empty PSR-4 prefix must end with a namespace separator." ); |
|
253 | 253 | } |
254 | - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
255 | - $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
256 | - } elseif ($prepend) { |
|
254 | + $this->prefixLengthsPsr4[ $prefix[ 0 ] ][ $prefix ] = $length; |
|
255 | + $this->prefixDirsPsr4[ $prefix ] = (array)$paths; |
|
256 | + } elseif ( $prepend ) { |
|
257 | 257 | // Prepend directories for an already registered namespace. |
258 | - $this->prefixDirsPsr4[$prefix] = array_merge( |
|
259 | - (array) $paths, |
|
260 | - $this->prefixDirsPsr4[$prefix] |
|
258 | + $this->prefixDirsPsr4[ $prefix ] = array_merge( |
|
259 | + (array)$paths, |
|
260 | + $this->prefixDirsPsr4[ $prefix ] |
|
261 | 261 | ); |
262 | 262 | } else { |
263 | 263 | // Append directories for an already registered namespace. |
264 | - $this->prefixDirsPsr4[$prefix] = array_merge( |
|
265 | - $this->prefixDirsPsr4[$prefix], |
|
266 | - (array) $paths |
|
264 | + $this->prefixDirsPsr4[ $prefix ] = array_merge( |
|
265 | + $this->prefixDirsPsr4[ $prefix ], |
|
266 | + (array)$paths |
|
267 | 267 | ); |
268 | 268 | } |
269 | 269 | } |
@@ -277,12 +277,12 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return void |
279 | 279 | */ |
280 | - public function set($prefix, $paths) |
|
280 | + public function set( $prefix, $paths ) |
|
281 | 281 | { |
282 | - if (!$prefix) { |
|
283 | - $this->fallbackDirsPsr0 = (array) $paths; |
|
282 | + if ( ! $prefix ) { |
|
283 | + $this->fallbackDirsPsr0 = (array)$paths; |
|
284 | 284 | } else { |
285 | - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; |
|
285 | + $this->prefixesPsr0[ $prefix[ 0 ] ][ $prefix ] = (array)$paths; |
|
286 | 286 | } |
287 | 287 | } |
288 | 288 | |
@@ -297,17 +297,17 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return void |
299 | 299 | */ |
300 | - public function setPsr4($prefix, $paths) |
|
300 | + public function setPsr4( $prefix, $paths ) |
|
301 | 301 | { |
302 | - if (!$prefix) { |
|
303 | - $this->fallbackDirsPsr4 = (array) $paths; |
|
302 | + if ( ! $prefix ) { |
|
303 | + $this->fallbackDirsPsr4 = (array)$paths; |
|
304 | 304 | } else { |
305 | - $length = strlen($prefix); |
|
306 | - if ('\\' !== $prefix[$length - 1]) { |
|
307 | - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
|
305 | + $length = strlen( $prefix ); |
|
306 | + if ( '\\' !== $prefix[ $length - 1 ] ) { |
|
307 | + throw new \InvalidArgumentException( "A non-empty PSR-4 prefix must end with a namespace separator." ); |
|
308 | 308 | } |
309 | - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
310 | - $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
309 | + $this->prefixLengthsPsr4[ $prefix[ 0 ] ][ $prefix ] = $length; |
|
310 | + $this->prefixDirsPsr4[ $prefix ] = (array)$paths; |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @return void |
320 | 320 | */ |
321 | - public function setUseIncludePath($useIncludePath) |
|
321 | + public function setUseIncludePath( $useIncludePath ) |
|
322 | 322 | { |
323 | 323 | $this->useIncludePath = $useIncludePath; |
324 | 324 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @return void |
344 | 344 | */ |
345 | - public function setClassMapAuthoritative($classMapAuthoritative) |
|
345 | + public function setClassMapAuthoritative( $classMapAuthoritative ) |
|
346 | 346 | { |
347 | 347 | $this->classMapAuthoritative = $classMapAuthoritative; |
348 | 348 | } |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | * |
365 | 365 | * @return void |
366 | 366 | */ |
367 | - public function setApcuPrefix($apcuPrefix) |
|
367 | + public function setApcuPrefix( $apcuPrefix ) |
|
368 | 368 | { |
369 | - $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; |
|
369 | + $this->apcuPrefix = function_exists( 'apcu_fetch' ) && filter_var( ini_get( 'apc.enabled' ), FILTER_VALIDATE_BOOLEAN ) ? $apcuPrefix : null; |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -386,19 +386,19 @@ discard block |
||
386 | 386 | * |
387 | 387 | * @return void |
388 | 388 | */ |
389 | - public function register($prepend = false) |
|
389 | + public function register( $prepend = false ) |
|
390 | 390 | { |
391 | - spl_autoload_register(array($this, 'loadClass'), true, $prepend); |
|
391 | + spl_autoload_register( array( $this, 'loadClass' ), true, $prepend ); |
|
392 | 392 | |
393 | - if (null === $this->vendorDir) { |
|
393 | + if ( null === $this->vendorDir ) { |
|
394 | 394 | return; |
395 | 395 | } |
396 | 396 | |
397 | - if ($prepend) { |
|
398 | - self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; |
|
397 | + if ( $prepend ) { |
|
398 | + self::$registeredLoaders = array( $this->vendorDir => $this ) + self::$registeredLoaders; |
|
399 | 399 | } else { |
400 | - unset(self::$registeredLoaders[$this->vendorDir]); |
|
401 | - self::$registeredLoaders[$this->vendorDir] = $this; |
|
400 | + unset( self::$registeredLoaders[ $this->vendorDir ] ); |
|
401 | + self::$registeredLoaders[ $this->vendorDir ] = $this; |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
@@ -409,10 +409,10 @@ discard block |
||
409 | 409 | */ |
410 | 410 | public function unregister() |
411 | 411 | { |
412 | - spl_autoload_unregister(array($this, 'loadClass')); |
|
412 | + spl_autoload_unregister( array( $this, 'loadClass' ) ); |
|
413 | 413 | |
414 | - if (null !== $this->vendorDir) { |
|
415 | - unset(self::$registeredLoaders[$this->vendorDir]); |
|
414 | + if ( null !== $this->vendorDir ) { |
|
415 | + unset( self::$registeredLoaders[ $this->vendorDir ] ); |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
@@ -422,10 +422,10 @@ discard block |
||
422 | 422 | * @param string $class The name of the class |
423 | 423 | * @return true|null True if loaded, null otherwise |
424 | 424 | */ |
425 | - public function loadClass($class) |
|
425 | + public function loadClass( $class ) |
|
426 | 426 | { |
427 | - if ($file = $this->findFile($class)) { |
|
428 | - includeFile($file); |
|
427 | + if ( $file = $this->findFile( $class ) ) { |
|
428 | + includeFile( $file ); |
|
429 | 429 | |
430 | 430 | return true; |
431 | 431 | } |
@@ -440,36 +440,36 @@ discard block |
||
440 | 440 | * |
441 | 441 | * @return string|false The path if found, false otherwise |
442 | 442 | */ |
443 | - public function findFile($class) |
|
443 | + public function findFile( $class ) |
|
444 | 444 | { |
445 | 445 | // class map lookup |
446 | - if (isset($this->classMap[$class])) { |
|
447 | - return $this->classMap[$class]; |
|
446 | + if ( isset( $this->classMap[ $class ] ) ) { |
|
447 | + return $this->classMap[ $class ]; |
|
448 | 448 | } |
449 | - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { |
|
449 | + if ( $this->classMapAuthoritative || isset( $this->missingClasses[ $class ] ) ) { |
|
450 | 450 | return false; |
451 | 451 | } |
452 | - if (null !== $this->apcuPrefix) { |
|
453 | - $file = apcu_fetch($this->apcuPrefix.$class, $hit); |
|
454 | - if ($hit) { |
|
452 | + if ( null !== $this->apcuPrefix ) { |
|
453 | + $file = apcu_fetch( $this->apcuPrefix . $class, $hit ); |
|
454 | + if ( $hit ) { |
|
455 | 455 | return $file; |
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
459 | - $file = $this->findFileWithExtension($class, '.php'); |
|
459 | + $file = $this->findFileWithExtension( $class, '.php' ); |
|
460 | 460 | |
461 | 461 | // Search for Hack files if we are running on HHVM |
462 | - if (false === $file && defined('HHVM_VERSION')) { |
|
463 | - $file = $this->findFileWithExtension($class, '.hh'); |
|
462 | + if ( false === $file && defined( 'HHVM_VERSION' ) ) { |
|
463 | + $file = $this->findFileWithExtension( $class, '.hh' ); |
|
464 | 464 | } |
465 | 465 | |
466 | - if (null !== $this->apcuPrefix) { |
|
467 | - apcu_add($this->apcuPrefix.$class, $file); |
|
466 | + if ( null !== $this->apcuPrefix ) { |
|
467 | + apcu_add( $this->apcuPrefix . $class, $file ); |
|
468 | 468 | } |
469 | 469 | |
470 | - if (false === $file) { |
|
470 | + if ( false === $file ) { |
|
471 | 471 | // Remember that this class does not exist. |
472 | - $this->missingClasses[$class] = true; |
|
472 | + $this->missingClasses[ $class ] = true; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | return $file; |
@@ -490,21 +490,21 @@ discard block |
||
490 | 490 | * @param string $ext |
491 | 491 | * @return string|false |
492 | 492 | */ |
493 | - private function findFileWithExtension($class, $ext) |
|
493 | + private function findFileWithExtension( $class, $ext ) |
|
494 | 494 | { |
495 | 495 | // PSR-4 lookup |
496 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
496 | + $logicalPathPsr4 = strtr( $class, '\\', DIRECTORY_SEPARATOR ) . $ext; |
|
497 | 497 | |
498 | - $first = $class[0]; |
|
499 | - if (isset($this->prefixLengthsPsr4[$first])) { |
|
498 | + $first = $class[ 0 ]; |
|
499 | + if ( isset( $this->prefixLengthsPsr4[ $first ] ) ) { |
|
500 | 500 | $subPath = $class; |
501 | - while (false !== $lastPos = strrpos($subPath, '\\')) { |
|
502 | - $subPath = substr($subPath, 0, $lastPos); |
|
501 | + while ( false !== $lastPos = strrpos( $subPath, '\\' ) ) { |
|
502 | + $subPath = substr( $subPath, 0, $lastPos ); |
|
503 | 503 | $search = $subPath . '\\'; |
504 | - if (isset($this->prefixDirsPsr4[$search])) { |
|
505 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
506 | - foreach ($this->prefixDirsPsr4[$search] as $dir) { |
|
507 | - if (file_exists($file = $dir . $pathEnd)) { |
|
504 | + if ( isset( $this->prefixDirsPsr4[ $search ] ) ) { |
|
505 | + $pathEnd = DIRECTORY_SEPARATOR . substr( $logicalPathPsr4, $lastPos + 1 ); |
|
506 | + foreach ( $this->prefixDirsPsr4[ $search ] as $dir ) { |
|
507 | + if ( file_exists( $file = $dir . $pathEnd ) ) { |
|
508 | 508 | return $file; |
509 | 509 | } |
510 | 510 | } |
@@ -513,27 +513,27 @@ discard block |
||
513 | 513 | } |
514 | 514 | |
515 | 515 | // PSR-4 fallback dirs |
516 | - foreach ($this->fallbackDirsPsr4 as $dir) { |
|
517 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
516 | + foreach ( $this->fallbackDirsPsr4 as $dir ) { |
|
517 | + if ( file_exists( $file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4 ) ) { |
|
518 | 518 | return $file; |
519 | 519 | } |
520 | 520 | } |
521 | 521 | |
522 | 522 | // PSR-0 lookup |
523 | - if (false !== $pos = strrpos($class, '\\')) { |
|
523 | + if ( false !== $pos = strrpos( $class, '\\' ) ) { |
|
524 | 524 | // namespaced class name |
525 | - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) |
|
526 | - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
|
525 | + $logicalPathPsr0 = substr( $logicalPathPsr4, 0, $pos + 1 ) |
|
526 | + . strtr( substr( $logicalPathPsr4, $pos + 1 ), '_', DIRECTORY_SEPARATOR ); |
|
527 | 527 | } else { |
528 | 528 | // PEAR-like class name |
529 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
529 | + $logicalPathPsr0 = strtr( $class, '_', DIRECTORY_SEPARATOR ) . $ext; |
|
530 | 530 | } |
531 | 531 | |
532 | - if (isset($this->prefixesPsr0[$first])) { |
|
533 | - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
|
534 | - if (0 === strpos($class, $prefix)) { |
|
535 | - foreach ($dirs as $dir) { |
|
536 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
532 | + if ( isset( $this->prefixesPsr0[ $first ] ) ) { |
|
533 | + foreach ( $this->prefixesPsr0[ $first ] as $prefix => $dirs ) { |
|
534 | + if ( 0 === strpos( $class, $prefix ) ) { |
|
535 | + foreach ( $dirs as $dir ) { |
|
536 | + if ( file_exists( $file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0 ) ) { |
|
537 | 537 | return $file; |
538 | 538 | } |
539 | 539 | } |
@@ -542,14 +542,14 @@ discard block |
||
542 | 542 | } |
543 | 543 | |
544 | 544 | // PSR-0 fallback dirs |
545 | - foreach ($this->fallbackDirsPsr0 as $dir) { |
|
546 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
545 | + foreach ( $this->fallbackDirsPsr0 as $dir ) { |
|
546 | + if ( file_exists( $file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0 ) ) { |
|
547 | 547 | return $file; |
548 | 548 | } |
549 | 549 | } |
550 | 550 | |
551 | 551 | // PSR-0 include paths. |
552 | - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { |
|
552 | + if ( $this->useIncludePath && $file = stream_resolve_include_path( $logicalPathPsr0 ) ) { |
|
553 | 553 | return $file; |
554 | 554 | } |
555 | 555 | |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | * @return void |
567 | 567 | * @private |
568 | 568 | */ |
569 | -function includeFile($file) |
|
569 | +function includeFile( $file ) |
|
570 | 570 | { |
571 | 571 | include $file; |
572 | 572 | } |
@@ -37,15 +37,15 @@ discard block |
||
37 | 37 | public static function getInstalledPackages() |
38 | 38 | { |
39 | 39 | $packages = array(); |
40 | - foreach (self::getInstalled() as $installed) { |
|
41 | - $packages[] = array_keys($installed['versions']); |
|
40 | + foreach ( self::getInstalled() as $installed ) { |
|
41 | + $packages[ ] = array_keys( $installed[ 'versions' ] ); |
|
42 | 42 | } |
43 | 43 | |
44 | - if (1 === \count($packages)) { |
|
45 | - return $packages[0]; |
|
44 | + if ( 1 === \count( $packages ) ) { |
|
45 | + return $packages[ 0 ]; |
|
46 | 46 | } |
47 | 47 | |
48 | - return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); |
|
48 | + return array_keys( array_flip( \call_user_func_array( 'array_merge', $packages ) ) ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | * @return string[] |
56 | 56 | * @psalm-return list<string> |
57 | 57 | */ |
58 | - public static function getInstalledPackagesByType($type) |
|
58 | + public static function getInstalledPackagesByType( $type ) |
|
59 | 59 | { |
60 | 60 | $packagesByType = array(); |
61 | 61 | |
62 | - foreach (self::getInstalled() as $installed) { |
|
63 | - foreach ($installed['versions'] as $name => $package) { |
|
64 | - if (isset($package['type']) && $package['type'] === $type) { |
|
65 | - $packagesByType[] = $name; |
|
62 | + foreach ( self::getInstalled() as $installed ) { |
|
63 | + foreach ( $installed[ 'versions' ] as $name => $package ) { |
|
64 | + if ( isset( $package[ 'type' ] ) && $package[ 'type' ] === $type ) { |
|
65 | + $packagesByType[ ] = $name; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | * @param bool $includeDevRequirements |
80 | 80 | * @return bool |
81 | 81 | */ |
82 | - public static function isInstalled($packageName, $includeDevRequirements = true) |
|
82 | + public static function isInstalled( $packageName, $includeDevRequirements = true ) |
|
83 | 83 | { |
84 | - foreach (self::getInstalled() as $installed) { |
|
85 | - if (isset($installed['versions'][$packageName])) { |
|
86 | - return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); |
|
84 | + foreach ( self::getInstalled() as $installed ) { |
|
85 | + if ( isset( $installed[ 'versions' ][ $packageName ] ) ) { |
|
86 | + return $includeDevRequirements || empty( $installed[ 'versions' ][ $packageName ][ 'dev_requirement' ] ); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package |
103 | 103 | * @return bool |
104 | 104 | */ |
105 | - public static function satisfies(VersionParser $parser, $packageName, $constraint) |
|
105 | + public static function satisfies( VersionParser $parser, $packageName, $constraint ) |
|
106 | 106 | { |
107 | - $constraint = $parser->parseConstraints($constraint); |
|
108 | - $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); |
|
107 | + $constraint = $parser->parseConstraints( $constraint ); |
|
108 | + $provided = $parser->parseConstraints( self::getVersionRanges( $packageName ) ); |
|
109 | 109 | |
110 | - return $provided->matches($constraint); |
|
110 | + return $provided->matches( $constraint ); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -119,111 +119,111 @@ discard block |
||
119 | 119 | * @param string $packageName |
120 | 120 | * @return string Version constraint usable with composer/semver |
121 | 121 | */ |
122 | - public static function getVersionRanges($packageName) |
|
122 | + public static function getVersionRanges( $packageName ) |
|
123 | 123 | { |
124 | - foreach (self::getInstalled() as $installed) { |
|
125 | - if (!isset($installed['versions'][$packageName])) { |
|
124 | + foreach ( self::getInstalled() as $installed ) { |
|
125 | + if ( ! isset( $installed[ 'versions' ][ $packageName ] ) ) { |
|
126 | 126 | continue; |
127 | 127 | } |
128 | 128 | |
129 | 129 | $ranges = array(); |
130 | - if (isset($installed['versions'][$packageName]['pretty_version'])) { |
|
131 | - $ranges[] = $installed['versions'][$packageName]['pretty_version']; |
|
130 | + if ( isset( $installed[ 'versions' ][ $packageName ][ 'pretty_version' ] ) ) { |
|
131 | + $ranges[ ] = $installed[ 'versions' ][ $packageName ][ 'pretty_version' ]; |
|
132 | 132 | } |
133 | - if (array_key_exists('aliases', $installed['versions'][$packageName])) { |
|
134 | - $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); |
|
133 | + if ( array_key_exists( 'aliases', $installed[ 'versions' ][ $packageName ] ) ) { |
|
134 | + $ranges = array_merge( $ranges, $installed[ 'versions' ][ $packageName ][ 'aliases' ] ); |
|
135 | 135 | } |
136 | - if (array_key_exists('replaced', $installed['versions'][$packageName])) { |
|
137 | - $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); |
|
136 | + if ( array_key_exists( 'replaced', $installed[ 'versions' ][ $packageName ] ) ) { |
|
137 | + $ranges = array_merge( $ranges, $installed[ 'versions' ][ $packageName ][ 'replaced' ] ); |
|
138 | 138 | } |
139 | - if (array_key_exists('provided', $installed['versions'][$packageName])) { |
|
140 | - $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); |
|
139 | + if ( array_key_exists( 'provided', $installed[ 'versions' ][ $packageName ] ) ) { |
|
140 | + $ranges = array_merge( $ranges, $installed[ 'versions' ][ $packageName ][ 'provided' ] ); |
|
141 | 141 | } |
142 | 142 | |
143 | - return implode(' || ', $ranges); |
|
143 | + return implode( ' || ', $ranges ); |
|
144 | 144 | } |
145 | 145 | |
146 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
146 | + throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
150 | 150 | * @param string $packageName |
151 | 151 | * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present |
152 | 152 | */ |
153 | - public static function getVersion($packageName) |
|
153 | + public static function getVersion( $packageName ) |
|
154 | 154 | { |
155 | - foreach (self::getInstalled() as $installed) { |
|
156 | - if (!isset($installed['versions'][$packageName])) { |
|
155 | + foreach ( self::getInstalled() as $installed ) { |
|
156 | + if ( ! isset( $installed[ 'versions' ][ $packageName ] ) ) { |
|
157 | 157 | continue; |
158 | 158 | } |
159 | 159 | |
160 | - if (!isset($installed['versions'][$packageName]['version'])) { |
|
160 | + if ( ! isset( $installed[ 'versions' ][ $packageName ][ 'version' ] ) ) { |
|
161 | 161 | return null; |
162 | 162 | } |
163 | 163 | |
164 | - return $installed['versions'][$packageName]['version']; |
|
164 | + return $installed[ 'versions' ][ $packageName ][ 'version' ]; |
|
165 | 165 | } |
166 | 166 | |
167 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
167 | + throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
171 | 171 | * @param string $packageName |
172 | 172 | * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present |
173 | 173 | */ |
174 | - public static function getPrettyVersion($packageName) |
|
174 | + public static function getPrettyVersion( $packageName ) |
|
175 | 175 | { |
176 | - foreach (self::getInstalled() as $installed) { |
|
177 | - if (!isset($installed['versions'][$packageName])) { |
|
176 | + foreach ( self::getInstalled() as $installed ) { |
|
177 | + if ( ! isset( $installed[ 'versions' ][ $packageName ] ) ) { |
|
178 | 178 | continue; |
179 | 179 | } |
180 | 180 | |
181 | - if (!isset($installed['versions'][$packageName]['pretty_version'])) { |
|
181 | + if ( ! isset( $installed[ 'versions' ][ $packageName ][ 'pretty_version' ] ) ) { |
|
182 | 182 | return null; |
183 | 183 | } |
184 | 184 | |
185 | - return $installed['versions'][$packageName]['pretty_version']; |
|
185 | + return $installed[ 'versions' ][ $packageName ][ 'pretty_version' ]; |
|
186 | 186 | } |
187 | 187 | |
188 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
188 | + throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
192 | 192 | * @param string $packageName |
193 | 193 | * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference |
194 | 194 | */ |
195 | - public static function getReference($packageName) |
|
195 | + public static function getReference( $packageName ) |
|
196 | 196 | { |
197 | - foreach (self::getInstalled() as $installed) { |
|
198 | - if (!isset($installed['versions'][$packageName])) { |
|
197 | + foreach ( self::getInstalled() as $installed ) { |
|
198 | + if ( ! isset( $installed[ 'versions' ][ $packageName ] ) ) { |
|
199 | 199 | continue; |
200 | 200 | } |
201 | 201 | |
202 | - if (!isset($installed['versions'][$packageName]['reference'])) { |
|
202 | + if ( ! isset( $installed[ 'versions' ][ $packageName ][ 'reference' ] ) ) { |
|
203 | 203 | return null; |
204 | 204 | } |
205 | 205 | |
206 | - return $installed['versions'][$packageName]['reference']; |
|
206 | + return $installed[ 'versions' ][ $packageName ][ 'reference' ]; |
|
207 | 207 | } |
208 | 208 | |
209 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
209 | + throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
213 | 213 | * @param string $packageName |
214 | 214 | * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. |
215 | 215 | */ |
216 | - public static function getInstallPath($packageName) |
|
216 | + public static function getInstallPath( $packageName ) |
|
217 | 217 | { |
218 | - foreach (self::getInstalled() as $installed) { |
|
219 | - if (!isset($installed['versions'][$packageName])) { |
|
218 | + foreach ( self::getInstalled() as $installed ) { |
|
219 | + if ( ! isset( $installed[ 'versions' ][ $packageName ] ) ) { |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | |
223 | - return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; |
|
223 | + return isset( $installed[ 'versions' ][ $packageName ][ 'install_path' ] ) ? $installed[ 'versions' ][ $packageName ][ 'install_path' ] : null; |
|
224 | 224 | } |
225 | 225 | |
226 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
226 | + throw new \OutOfBoundsException( 'Package "' . $packageName . '" is not installed' ); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | { |
235 | 235 | $installed = self::getInstalled(); |
236 | 236 | |
237 | - return $installed[0]['root']; |
|
237 | + return $installed[ 0 ][ 'root' ]; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public static function getRawData() |
248 | 248 | { |
249 | - @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); |
|
249 | + @trigger_error( 'getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED ); |
|
250 | 250 | |
251 | - if (null === self::$installed) { |
|
251 | + if ( null === self::$installed ) { |
|
252 | 252 | // only require the installed.php file if this file is loaded from its dumped location, |
253 | 253 | // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 |
254 | - if (substr(__DIR__, -8, 1) !== 'C') { |
|
254 | + if ( substr( __DIR__, -8, 1 ) !== 'C' ) { |
|
255 | 255 | self::$installed = include __DIR__ . '/installed.php'; |
256 | 256 | } else { |
257 | 257 | self::$installed = array(); |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data |
292 | 292 | */ |
293 | - public static function reload($data) |
|
293 | + public static function reload( $data ) |
|
294 | 294 | { |
295 | 295 | self::$installed = $data; |
296 | 296 | self::$installedByVendor = array(); |
@@ -302,35 +302,35 @@ discard block |
||
302 | 302 | */ |
303 | 303 | private static function getInstalled() |
304 | 304 | { |
305 | - if (null === self::$canGetVendors) { |
|
306 | - self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); |
|
305 | + if ( null === self::$canGetVendors ) { |
|
306 | + self::$canGetVendors = method_exists( 'Composer\Autoload\ClassLoader', 'getRegisteredLoaders' ); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | $installed = array(); |
310 | 310 | |
311 | - if (self::$canGetVendors) { |
|
312 | - foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { |
|
313 | - if (isset(self::$installedByVendor[$vendorDir])) { |
|
314 | - $installed[] = self::$installedByVendor[$vendorDir]; |
|
315 | - } elseif (is_file($vendorDir.'/composer/installed.php')) { |
|
316 | - $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; |
|
317 | - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { |
|
318 | - self::$installed = $installed[count($installed) - 1]; |
|
311 | + if ( self::$canGetVendors ) { |
|
312 | + foreach ( ClassLoader::getRegisteredLoaders() as $vendorDir => $loader ) { |
|
313 | + if ( isset( self::$installedByVendor[ $vendorDir ] ) ) { |
|
314 | + $installed[ ] = self::$installedByVendor[ $vendorDir ]; |
|
315 | + } elseif ( is_file( $vendorDir . '/composer/installed.php' ) ) { |
|
316 | + $installed[ ] = self::$installedByVendor[ $vendorDir ] = require $vendorDir . '/composer/installed.php'; |
|
317 | + if ( null === self::$installed && strtr( $vendorDir . '/composer', '\\', '/' ) === strtr( __DIR__, '\\', '/' ) ) { |
|
318 | + self::$installed = $installed[ count( $installed ) - 1 ]; |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
324 | - if (null === self::$installed) { |
|
324 | + if ( null === self::$installed ) { |
|
325 | 325 | // only require the installed.php file if this file is loaded from its dumped location, |
326 | 326 | // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 |
327 | - if (substr(__DIR__, -8, 1) !== 'C') { |
|
327 | + if ( substr( __DIR__, -8, 1 ) !== 'C' ) { |
|
328 | 328 | self::$installed = require __DIR__ . '/installed.php'; |
329 | 329 | } else { |
330 | 330 | self::$installed = array(); |
331 | 331 | } |
332 | 332 | } |
333 | - $installed[] = self::$installed; |
|
333 | + $installed[ ] = self::$installed; |
|
334 | 334 | |
335 | 335 | return $installed; |
336 | 336 | } |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return array Blocklist, with "total" added. If not edit context, original field blocklist. Otherwise, blocklist including total. |
54 | 54 | */ |
55 | - public function add_to_blocklist( $blocklist = array(), $context = NULL ){ |
|
55 | + public function add_to_blocklist( $blocklist = array(), $context = NULL ) { |
|
56 | 56 | |
57 | - if( empty( $context ) || $context !== 'edit' ) { |
|
57 | + if ( empty( $context ) || $context !== 'edit' ) { |
|
58 | 58 | return $blocklist; |
59 | 59 | } |
60 | 60 | |
61 | - $blocklist[] = 'total'; |
|
61 | + $blocklist[ ] = 'total'; |
|
62 | 62 | |
63 | 63 | return $blocklist; |
64 | 64 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | function edit_entry_recalculate_totals( $form = array(), $entry_id = 0, $Edit_Entry_Render = null ) { |
78 | 78 | |
79 | - $original_form = GFAPI::get_form( $form['id'] ); |
|
79 | + $original_form = GFAPI::get_form( $form[ 'id' ] ); |
|
80 | 80 | |
81 | 81 | $total_fields = GFCommon::get_fields_by_type( $original_form, 'total' ); |
82 | 82 | |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | |
88 | 88 | /** @type GF_Field_Total $total_field */ |
89 | 89 | foreach ( $total_fields as $total_field ) { |
90 | - $entry["{$total_field->id}"] = GFCommon::get_order_total( $original_form, $entry ); |
|
90 | + $entry[ "{$total_field->id}" ] = GFCommon::get_order_total( $original_form, $entry ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | $return_entry = GFAPI::update_entry( $entry ); |
94 | 94 | |
95 | - if( is_wp_error( $return_entry ) ) { |
|
95 | + if ( is_wp_error( $return_entry ) ) { |
|
96 | 96 | gravityview()->log->error( 'Updating the entry total fields failed', array( 'data' => $return_entry ) ); |
97 | 97 | } else { |
98 | 98 | gravityview()->log->debug( 'Updating the entry total fields succeeded' ); |
@@ -49,8 +49,8 @@ |
||
49 | 49 | public function blocklist_field_types( $field_types = array(), $context = '' ) { |
50 | 50 | |
51 | 51 | // Allow Calculation field in Edit Entry |
52 | - if( 'edit' !== $context ) { |
|
53 | - $field_types[] = $this->name; |
|
52 | + if ( 'edit' !== $context ) { |
|
53 | + $field_types[ ] = $this->name; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | return $field_types; |