@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | public function set_template_data( $data, $var_name = 'data' ) { |
132 | 132 | global $wp_query; |
133 | 133 | |
134 | - $wp_query->query_vars[ $var_name ] = (object) $data; |
|
134 | + $wp_query->query_vars[ $var_name ] = (object)$data; |
|
135 | 135 | |
136 | 136 | // Add $var_name to custom variable store if not default value. |
137 | 137 | if ( 'data' !== $var_name ) { |
138 | - $this->template_data_var_names[] = $var_name; |
|
138 | + $this->template_data_var_names[ ] = $var_name; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | return $this; |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | protected function get_template_file_names( $slug, $name ) { |
179 | 179 | $templates = array(); |
180 | 180 | if ( isset( $name ) ) { |
181 | - $templates[] = $slug . '-' . $name . '.php'; |
|
181 | + $templates[ ] = $slug . '-' . $name . '.php'; |
|
182 | 182 | } |
183 | - $templates[] = $slug . '.php'; |
|
183 | + $templates[ ] = $slug . '.php'; |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Allow template choices to be filtered. |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $located = false; |
227 | 227 | |
228 | 228 | // Remove empty entries. |
229 | - $template_names = array_filter( (array) $template_names ); |
|
229 | + $template_names = array_filter( (array)$template_names ); |
|
230 | 230 | $template_paths = $this->get_template_paths(); |
231 | 231 | |
232 | 232 | // Try to find a template file. |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | } |
247 | 247 | |
248 | 248 | // The templates weren't found; don't look this up again. |
249 | - if( ! $located ) { |
|
249 | + if ( ! $located ) { |
|
250 | 250 | $template_path_cache[ $this->filter_prefix ][ $cache_key ] = false; |
251 | 251 | } |
252 | 252 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | |
286 | 286 | // Only add this conditionally, so non-child themes don't redundantly check active theme twice. |
287 | 287 | if ( get_stylesheet_directory() !== get_template_directory() ) { |
288 | - $file_paths[1] = trailingslashit( get_stylesheet_directory() ) . $theme_directory; |
|
288 | + $file_paths[ 1 ] = trailingslashit( get_stylesheet_directory() ) . $theme_directory; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | /** |
251 | 251 | * update_approved function. |
252 | 252 | * |
253 | - * @since 1.18 Moved to GravityView_Entry_Approval::update_approved |
|
253 | + * @since 1.18 Moved to GravityView_Entry_Approval::update_approved |
|
254 | 254 | * @see GravityView_Entry_Approval::update_approved |
255 | - * |
|
255 | + * |
|
256 | 256 | * @param int $entry_id (default: 0) |
257 | 257 | * @param int $approved (default: 0) |
258 | 258 | * @param int $form_id (default: 0) |
259 | 259 | * @param int $approvedcolumn (default: 0) |
260 | - * |
|
260 | + * |
|
261 | 261 | * @return boolean True: It worked; False: it failed |
262 | 262 | */ |
263 | 263 | public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | /** |
268 | 268 | * Calculate the approve field.input id |
269 | 269 | * |
270 | - * @since 1.18 Moved to GravityView_Entry_Approval::get_approved_column |
|
271 | - * @see GravityView_Entry_Approval::get_approved_column |
|
272 | - * |
|
270 | + * @since 1.18 Moved to GravityView_Entry_Approval::get_approved_column |
|
271 | + * @see GravityView_Entry_Approval::get_approved_column |
|
272 | + * |
|
273 | 273 | * @param mixed $form GF Form or Form ID |
274 | 274 | * @return false|null|string Returns the input ID of the approved field. Returns NULL if no approved fields were found. Returns false if $form_id wasn't set. |
275 | 275 | */ |
@@ -394,37 +394,37 @@ discard block |
||
394 | 394 | 'bulk_actions' => GravityView_Bulk_Actions::get_bulk_actions( $form_id ), |
395 | 395 | 'bulk_message' => $this->bulk_update_message, |
396 | 396 | 'unapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('unapproved'), |
397 | - 'approve_title' => GravityView_Entry_Approval_Status::get_title_attr('disapproved'), |
|
397 | + 'approve_title' => GravityView_Entry_Approval_Status::get_title_attr('disapproved'), |
|
398 | 398 | 'disapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('approved'), |
399 | 399 | 'column_title' => __( 'Show entry in directory view?', 'gravityview'), |
400 | 400 | 'column_link' => esc_url( $this->get_sort_link() ), |
401 | - 'status_popover_template' => GravityView_Entry_Approval::get_popover_template(), |
|
401 | + 'status_popover_template' => GravityView_Entry_Approval::get_popover_template(), |
|
402 | 402 | 'status_popover_placement' => GravityView_Entry_Approval::get_popover_placement(), |
403 | 403 | ) ); |
404 | 404 | |
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
408 | - * Generate a link to sort by approval status |
|
409 | - * |
|
410 | - * Note: Sorting by approval will never be great because it's not possible currently to declare the sorting as |
|
411 | - * numeric, but it does group the approved entries together. |
|
412 | - * |
|
413 | - * @since 2.0.14 Remove need for approval field for sorting by approval status |
|
414 | - * |
|
408 | + * Generate a link to sort by approval status |
|
409 | + * |
|
410 | + * Note: Sorting by approval will never be great because it's not possible currently to declare the sorting as |
|
411 | + * numeric, but it does group the approved entries together. |
|
412 | + * |
|
413 | + * @since 2.0.14 Remove need for approval field for sorting by approval status |
|
414 | + * |
|
415 | 415 | * @param int $form_id [NO LONGER USED] |
416 | 416 | * |
417 | 417 | * @return string Sorting link |
418 | 418 | */ |
419 | 419 | private function get_sort_link( $form_id = 0 ) { |
420 | 420 | |
421 | - $args = array( |
|
422 | - 'orderby' => 'is_approved', |
|
423 | - 'order' => ( 'desc' === \GV\Utils::_GET( 'order' ) ) ? 'asc' : 'desc', |
|
424 | - ); |
|
421 | + $args = array( |
|
422 | + 'orderby' => 'is_approved', |
|
423 | + 'order' => ( 'desc' === \GV\Utils::_GET( 'order' ) ) ? 'asc' : 'desc', |
|
424 | + ); |
|
425 | 425 | |
426 | 426 | return add_query_arg( $args ); |
427 | - } |
|
427 | + } |
|
428 | 428 | |
429 | 429 | /** |
430 | 430 | * Should the Approve/Reject Entry column be shown in the GF Entries page? |
@@ -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; |
@@ -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 | } |
@@ -90,7 +90,7 @@ |
||
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 | } |
@@ -42,519 +42,519 @@ discard block |
||
42 | 42 | */ |
43 | 43 | class ClassLoader |
44 | 44 | { |
45 | - /** @var ?string */ |
|
46 | - private $vendorDir; |
|
47 | - |
|
48 | - // PSR-4 |
|
49 | - /** |
|
50 | - * @var array[] |
|
51 | - * @psalm-var array<string, array<string, int>> |
|
52 | - */ |
|
53 | - private $prefixLengthsPsr4 = array(); |
|
54 | - /** |
|
55 | - * @var array[] |
|
56 | - * @psalm-var array<string, array<int, string>> |
|
57 | - */ |
|
58 | - private $prefixDirsPsr4 = array(); |
|
59 | - /** |
|
60 | - * @var array[] |
|
61 | - * @psalm-var array<string, string> |
|
62 | - */ |
|
63 | - private $fallbackDirsPsr4 = array(); |
|
64 | - |
|
65 | - // PSR-0 |
|
66 | - /** |
|
67 | - * @var array[] |
|
68 | - * @psalm-var array<string, array<string, string[]>> |
|
69 | - */ |
|
70 | - private $prefixesPsr0 = array(); |
|
71 | - /** |
|
72 | - * @var array[] |
|
73 | - * @psalm-var array<string, string> |
|
74 | - */ |
|
75 | - private $fallbackDirsPsr0 = array(); |
|
76 | - |
|
77 | - /** @var bool */ |
|
78 | - private $useIncludePath = false; |
|
79 | - |
|
80 | - /** |
|
81 | - * @var string[] |
|
82 | - * @psalm-var array<string, string> |
|
83 | - */ |
|
84 | - private $classMap = array(); |
|
85 | - |
|
86 | - /** @var bool */ |
|
87 | - private $classMapAuthoritative = false; |
|
88 | - |
|
89 | - /** |
|
90 | - * @var bool[] |
|
91 | - * @psalm-var array<string, bool> |
|
92 | - */ |
|
93 | - private $missingClasses = array(); |
|
94 | - |
|
95 | - /** @var ?string */ |
|
96 | - private $apcuPrefix; |
|
97 | - |
|
98 | - /** |
|
99 | - * @var self[] |
|
100 | - */ |
|
101 | - private static $registeredLoaders = array(); |
|
102 | - |
|
103 | - /** |
|
104 | - * @param ?string $vendorDir |
|
105 | - */ |
|
106 | - public function __construct($vendorDir = null) |
|
107 | - { |
|
108 | - $this->vendorDir = $vendorDir; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * @return string[] |
|
113 | - */ |
|
114 | - public function getPrefixes() |
|
115 | - { |
|
116 | - if (!empty($this->prefixesPsr0)) { |
|
117 | - return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); |
|
118 | - } |
|
119 | - |
|
120 | - return array(); |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * @return array[] |
|
125 | - * @psalm-return array<string, array<int, string>> |
|
126 | - */ |
|
127 | - public function getPrefixesPsr4() |
|
128 | - { |
|
129 | - return $this->prefixDirsPsr4; |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * @return array[] |
|
134 | - * @psalm-return array<string, string> |
|
135 | - */ |
|
136 | - public function getFallbackDirs() |
|
137 | - { |
|
138 | - return $this->fallbackDirsPsr0; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * @return array[] |
|
143 | - * @psalm-return array<string, string> |
|
144 | - */ |
|
145 | - public function getFallbackDirsPsr4() |
|
146 | - { |
|
147 | - return $this->fallbackDirsPsr4; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * @return string[] Array of classname => path |
|
152 | - * @psalm-return array<string, string> |
|
153 | - */ |
|
154 | - public function getClassMap() |
|
155 | - { |
|
156 | - return $this->classMap; |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * @param string[] $classMap Class to filename map |
|
161 | - * @psalm-param array<string, string> $classMap |
|
162 | - * |
|
163 | - * @return void |
|
164 | - */ |
|
165 | - public function addClassMap(array $classMap) |
|
166 | - { |
|
167 | - if ($this->classMap) { |
|
168 | - $this->classMap = array_merge($this->classMap, $classMap); |
|
169 | - } else { |
|
170 | - $this->classMap = $classMap; |
|
171 | - } |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * Registers a set of PSR-0 directories for a given prefix, either |
|
176 | - * appending or prepending to the ones previously set for this prefix. |
|
177 | - * |
|
178 | - * @param string $prefix The prefix |
|
179 | - * @param string[]|string $paths The PSR-0 root directories |
|
180 | - * @param bool $prepend Whether to prepend the directories |
|
181 | - * |
|
182 | - * @return void |
|
183 | - */ |
|
184 | - public function add($prefix, $paths, $prepend = false) |
|
185 | - { |
|
186 | - if (!$prefix) { |
|
187 | - if ($prepend) { |
|
188 | - $this->fallbackDirsPsr0 = array_merge( |
|
189 | - (array) $paths, |
|
190 | - $this->fallbackDirsPsr0 |
|
191 | - ); |
|
192 | - } else { |
|
193 | - $this->fallbackDirsPsr0 = array_merge( |
|
194 | - $this->fallbackDirsPsr0, |
|
195 | - (array) $paths |
|
196 | - ); |
|
197 | - } |
|
198 | - |
|
199 | - return; |
|
200 | - } |
|
201 | - |
|
202 | - $first = $prefix[0]; |
|
203 | - if (!isset($this->prefixesPsr0[$first][$prefix])) { |
|
204 | - $this->prefixesPsr0[$first][$prefix] = (array) $paths; |
|
205 | - |
|
206 | - return; |
|
207 | - } |
|
208 | - if ($prepend) { |
|
209 | - $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
210 | - (array) $paths, |
|
211 | - $this->prefixesPsr0[$first][$prefix] |
|
212 | - ); |
|
213 | - } else { |
|
214 | - $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
215 | - $this->prefixesPsr0[$first][$prefix], |
|
216 | - (array) $paths |
|
217 | - ); |
|
218 | - } |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * Registers a set of PSR-4 directories for a given namespace, either |
|
223 | - * appending or prepending to the ones previously set for this namespace. |
|
224 | - * |
|
225 | - * @param string $prefix The prefix/namespace, with trailing '\\' |
|
226 | - * @param string[]|string $paths The PSR-4 base directories |
|
227 | - * @param bool $prepend Whether to prepend the directories |
|
228 | - * |
|
229 | - * @throws \InvalidArgumentException |
|
230 | - * |
|
231 | - * @return void |
|
232 | - */ |
|
233 | - public function addPsr4($prefix, $paths, $prepend = false) |
|
234 | - { |
|
235 | - if (!$prefix) { |
|
236 | - // Register directories for the root namespace. |
|
237 | - if ($prepend) { |
|
238 | - $this->fallbackDirsPsr4 = array_merge( |
|
239 | - (array) $paths, |
|
240 | - $this->fallbackDirsPsr4 |
|
241 | - ); |
|
242 | - } else { |
|
243 | - $this->fallbackDirsPsr4 = array_merge( |
|
244 | - $this->fallbackDirsPsr4, |
|
245 | - (array) $paths |
|
246 | - ); |
|
247 | - } |
|
248 | - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { |
|
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."); |
|
253 | - } |
|
254 | - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
255 | - $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
256 | - } elseif ($prepend) { |
|
257 | - // Prepend directories for an already registered namespace. |
|
258 | - $this->prefixDirsPsr4[$prefix] = array_merge( |
|
259 | - (array) $paths, |
|
260 | - $this->prefixDirsPsr4[$prefix] |
|
261 | - ); |
|
262 | - } else { |
|
263 | - // Append directories for an already registered namespace. |
|
264 | - $this->prefixDirsPsr4[$prefix] = array_merge( |
|
265 | - $this->prefixDirsPsr4[$prefix], |
|
266 | - (array) $paths |
|
267 | - ); |
|
268 | - } |
|
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * Registers a set of PSR-0 directories for a given prefix, |
|
273 | - * replacing any others previously set for this prefix. |
|
274 | - * |
|
275 | - * @param string $prefix The prefix |
|
276 | - * @param string[]|string $paths The PSR-0 base directories |
|
277 | - * |
|
278 | - * @return void |
|
279 | - */ |
|
280 | - public function set($prefix, $paths) |
|
281 | - { |
|
282 | - if (!$prefix) { |
|
283 | - $this->fallbackDirsPsr0 = (array) $paths; |
|
284 | - } else { |
|
285 | - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; |
|
286 | - } |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * Registers a set of PSR-4 directories for a given namespace, |
|
291 | - * replacing any others previously set for this namespace. |
|
292 | - * |
|
293 | - * @param string $prefix The prefix/namespace, with trailing '\\' |
|
294 | - * @param string[]|string $paths The PSR-4 base directories |
|
295 | - * |
|
296 | - * @throws \InvalidArgumentException |
|
297 | - * |
|
298 | - * @return void |
|
299 | - */ |
|
300 | - public function setPsr4($prefix, $paths) |
|
301 | - { |
|
302 | - if (!$prefix) { |
|
303 | - $this->fallbackDirsPsr4 = (array) $paths; |
|
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."); |
|
308 | - } |
|
309 | - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
310 | - $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
311 | - } |
|
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * Turns on searching the include path for class files. |
|
316 | - * |
|
317 | - * @param bool $useIncludePath |
|
318 | - * |
|
319 | - * @return void |
|
320 | - */ |
|
321 | - public function setUseIncludePath($useIncludePath) |
|
322 | - { |
|
323 | - $this->useIncludePath = $useIncludePath; |
|
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * Can be used to check if the autoloader uses the include path to check |
|
328 | - * for classes. |
|
329 | - * |
|
330 | - * @return bool |
|
331 | - */ |
|
332 | - public function getUseIncludePath() |
|
333 | - { |
|
334 | - return $this->useIncludePath; |
|
335 | - } |
|
336 | - |
|
337 | - /** |
|
338 | - * Turns off searching the prefix and fallback directories for classes |
|
339 | - * that have not been registered with the class map. |
|
340 | - * |
|
341 | - * @param bool $classMapAuthoritative |
|
342 | - * |
|
343 | - * @return void |
|
344 | - */ |
|
345 | - public function setClassMapAuthoritative($classMapAuthoritative) |
|
346 | - { |
|
347 | - $this->classMapAuthoritative = $classMapAuthoritative; |
|
348 | - } |
|
349 | - |
|
350 | - /** |
|
351 | - * Should class lookup fail if not found in the current class map? |
|
352 | - * |
|
353 | - * @return bool |
|
354 | - */ |
|
355 | - public function isClassMapAuthoritative() |
|
356 | - { |
|
357 | - return $this->classMapAuthoritative; |
|
358 | - } |
|
359 | - |
|
360 | - /** |
|
361 | - * APCu prefix to use to cache found/not-found classes, if the extension is enabled. |
|
362 | - * |
|
363 | - * @param string|null $apcuPrefix |
|
364 | - * |
|
365 | - * @return void |
|
366 | - */ |
|
367 | - public function setApcuPrefix($apcuPrefix) |
|
368 | - { |
|
369 | - $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; |
|
370 | - } |
|
371 | - |
|
372 | - /** |
|
373 | - * The APCu prefix in use, or null if APCu caching is not enabled. |
|
374 | - * |
|
375 | - * @return string|null |
|
376 | - */ |
|
377 | - public function getApcuPrefix() |
|
378 | - { |
|
379 | - return $this->apcuPrefix; |
|
380 | - } |
|
381 | - |
|
382 | - /** |
|
383 | - * Registers this instance as an autoloader. |
|
384 | - * |
|
385 | - * @param bool $prepend Whether to prepend the autoloader or not |
|
386 | - * |
|
387 | - * @return void |
|
388 | - */ |
|
389 | - public function register($prepend = false) |
|
390 | - { |
|
391 | - spl_autoload_register(array($this, 'loadClass'), true, $prepend); |
|
392 | - |
|
393 | - if (null === $this->vendorDir) { |
|
394 | - return; |
|
395 | - } |
|
396 | - |
|
397 | - if ($prepend) { |
|
398 | - self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; |
|
399 | - } else { |
|
400 | - unset(self::$registeredLoaders[$this->vendorDir]); |
|
401 | - self::$registeredLoaders[$this->vendorDir] = $this; |
|
402 | - } |
|
403 | - } |
|
404 | - |
|
405 | - /** |
|
406 | - * Unregisters this instance as an autoloader. |
|
407 | - * |
|
408 | - * @return void |
|
409 | - */ |
|
410 | - public function unregister() |
|
411 | - { |
|
412 | - spl_autoload_unregister(array($this, 'loadClass')); |
|
413 | - |
|
414 | - if (null !== $this->vendorDir) { |
|
415 | - unset(self::$registeredLoaders[$this->vendorDir]); |
|
416 | - } |
|
417 | - } |
|
418 | - |
|
419 | - /** |
|
420 | - * Loads the given class or interface. |
|
421 | - * |
|
422 | - * @param string $class The name of the class |
|
423 | - * @return true|null True if loaded, null otherwise |
|
424 | - */ |
|
425 | - public function loadClass($class) |
|
426 | - { |
|
427 | - if ($file = $this->findFile($class)) { |
|
428 | - includeFile($file); |
|
429 | - |
|
430 | - return true; |
|
431 | - } |
|
432 | - |
|
433 | - return null; |
|
434 | - } |
|
435 | - |
|
436 | - /** |
|
437 | - * Finds the path to the file where the class is defined. |
|
438 | - * |
|
439 | - * @param string $class The name of the class |
|
440 | - * |
|
441 | - * @return string|false The path if found, false otherwise |
|
442 | - */ |
|
443 | - public function findFile($class) |
|
444 | - { |
|
445 | - // class map lookup |
|
446 | - if (isset($this->classMap[$class])) { |
|
447 | - return $this->classMap[$class]; |
|
448 | - } |
|
449 | - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { |
|
450 | - return false; |
|
451 | - } |
|
452 | - if (null !== $this->apcuPrefix) { |
|
453 | - $file = apcu_fetch($this->apcuPrefix.$class, $hit); |
|
454 | - if ($hit) { |
|
455 | - return $file; |
|
456 | - } |
|
457 | - } |
|
458 | - |
|
459 | - $file = $this->findFileWithExtension($class, '.php'); |
|
460 | - |
|
461 | - // Search for Hack files if we are running on HHVM |
|
462 | - if (false === $file && defined('HHVM_VERSION')) { |
|
463 | - $file = $this->findFileWithExtension($class, '.hh'); |
|
464 | - } |
|
465 | - |
|
466 | - if (null !== $this->apcuPrefix) { |
|
467 | - apcu_add($this->apcuPrefix.$class, $file); |
|
468 | - } |
|
469 | - |
|
470 | - if (false === $file) { |
|
471 | - // Remember that this class does not exist. |
|
472 | - $this->missingClasses[$class] = true; |
|
473 | - } |
|
474 | - |
|
475 | - return $file; |
|
476 | - } |
|
477 | - |
|
478 | - /** |
|
479 | - * Returns the currently registered loaders indexed by their corresponding vendor directories. |
|
480 | - * |
|
481 | - * @return self[] |
|
482 | - */ |
|
483 | - public static function getRegisteredLoaders() |
|
484 | - { |
|
485 | - return self::$registeredLoaders; |
|
486 | - } |
|
487 | - |
|
488 | - /** |
|
489 | - * @param string $class |
|
490 | - * @param string $ext |
|
491 | - * @return string|false |
|
492 | - */ |
|
493 | - private function findFileWithExtension($class, $ext) |
|
494 | - { |
|
495 | - // PSR-4 lookup |
|
496 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
497 | - |
|
498 | - $first = $class[0]; |
|
499 | - if (isset($this->prefixLengthsPsr4[$first])) { |
|
500 | - $subPath = $class; |
|
501 | - while (false !== $lastPos = strrpos($subPath, '\\')) { |
|
502 | - $subPath = substr($subPath, 0, $lastPos); |
|
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)) { |
|
508 | - return $file; |
|
509 | - } |
|
510 | - } |
|
511 | - } |
|
512 | - } |
|
513 | - } |
|
514 | - |
|
515 | - // PSR-4 fallback dirs |
|
516 | - foreach ($this->fallbackDirsPsr4 as $dir) { |
|
517 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
518 | - return $file; |
|
519 | - } |
|
520 | - } |
|
521 | - |
|
522 | - // PSR-0 lookup |
|
523 | - if (false !== $pos = strrpos($class, '\\')) { |
|
524 | - // namespaced class name |
|
525 | - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) |
|
526 | - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
|
527 | - } else { |
|
528 | - // PEAR-like class name |
|
529 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
530 | - } |
|
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)) { |
|
537 | - return $file; |
|
538 | - } |
|
539 | - } |
|
540 | - } |
|
541 | - } |
|
542 | - } |
|
543 | - |
|
544 | - // PSR-0 fallback dirs |
|
545 | - foreach ($this->fallbackDirsPsr0 as $dir) { |
|
546 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
547 | - return $file; |
|
548 | - } |
|
549 | - } |
|
550 | - |
|
551 | - // PSR-0 include paths. |
|
552 | - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { |
|
553 | - return $file; |
|
554 | - } |
|
555 | - |
|
556 | - return false; |
|
557 | - } |
|
45 | + /** @var ?string */ |
|
46 | + private $vendorDir; |
|
47 | + |
|
48 | + // PSR-4 |
|
49 | + /** |
|
50 | + * @var array[] |
|
51 | + * @psalm-var array<string, array<string, int>> |
|
52 | + */ |
|
53 | + private $prefixLengthsPsr4 = array(); |
|
54 | + /** |
|
55 | + * @var array[] |
|
56 | + * @psalm-var array<string, array<int, string>> |
|
57 | + */ |
|
58 | + private $prefixDirsPsr4 = array(); |
|
59 | + /** |
|
60 | + * @var array[] |
|
61 | + * @psalm-var array<string, string> |
|
62 | + */ |
|
63 | + private $fallbackDirsPsr4 = array(); |
|
64 | + |
|
65 | + // PSR-0 |
|
66 | + /** |
|
67 | + * @var array[] |
|
68 | + * @psalm-var array<string, array<string, string[]>> |
|
69 | + */ |
|
70 | + private $prefixesPsr0 = array(); |
|
71 | + /** |
|
72 | + * @var array[] |
|
73 | + * @psalm-var array<string, string> |
|
74 | + */ |
|
75 | + private $fallbackDirsPsr0 = array(); |
|
76 | + |
|
77 | + /** @var bool */ |
|
78 | + private $useIncludePath = false; |
|
79 | + |
|
80 | + /** |
|
81 | + * @var string[] |
|
82 | + * @psalm-var array<string, string> |
|
83 | + */ |
|
84 | + private $classMap = array(); |
|
85 | + |
|
86 | + /** @var bool */ |
|
87 | + private $classMapAuthoritative = false; |
|
88 | + |
|
89 | + /** |
|
90 | + * @var bool[] |
|
91 | + * @psalm-var array<string, bool> |
|
92 | + */ |
|
93 | + private $missingClasses = array(); |
|
94 | + |
|
95 | + /** @var ?string */ |
|
96 | + private $apcuPrefix; |
|
97 | + |
|
98 | + /** |
|
99 | + * @var self[] |
|
100 | + */ |
|
101 | + private static $registeredLoaders = array(); |
|
102 | + |
|
103 | + /** |
|
104 | + * @param ?string $vendorDir |
|
105 | + */ |
|
106 | + public function __construct($vendorDir = null) |
|
107 | + { |
|
108 | + $this->vendorDir = $vendorDir; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * @return string[] |
|
113 | + */ |
|
114 | + public function getPrefixes() |
|
115 | + { |
|
116 | + if (!empty($this->prefixesPsr0)) { |
|
117 | + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); |
|
118 | + } |
|
119 | + |
|
120 | + return array(); |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * @return array[] |
|
125 | + * @psalm-return array<string, array<int, string>> |
|
126 | + */ |
|
127 | + public function getPrefixesPsr4() |
|
128 | + { |
|
129 | + return $this->prefixDirsPsr4; |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * @return array[] |
|
134 | + * @psalm-return array<string, string> |
|
135 | + */ |
|
136 | + public function getFallbackDirs() |
|
137 | + { |
|
138 | + return $this->fallbackDirsPsr0; |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * @return array[] |
|
143 | + * @psalm-return array<string, string> |
|
144 | + */ |
|
145 | + public function getFallbackDirsPsr4() |
|
146 | + { |
|
147 | + return $this->fallbackDirsPsr4; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * @return string[] Array of classname => path |
|
152 | + * @psalm-return array<string, string> |
|
153 | + */ |
|
154 | + public function getClassMap() |
|
155 | + { |
|
156 | + return $this->classMap; |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * @param string[] $classMap Class to filename map |
|
161 | + * @psalm-param array<string, string> $classMap |
|
162 | + * |
|
163 | + * @return void |
|
164 | + */ |
|
165 | + public function addClassMap(array $classMap) |
|
166 | + { |
|
167 | + if ($this->classMap) { |
|
168 | + $this->classMap = array_merge($this->classMap, $classMap); |
|
169 | + } else { |
|
170 | + $this->classMap = $classMap; |
|
171 | + } |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * Registers a set of PSR-0 directories for a given prefix, either |
|
176 | + * appending or prepending to the ones previously set for this prefix. |
|
177 | + * |
|
178 | + * @param string $prefix The prefix |
|
179 | + * @param string[]|string $paths The PSR-0 root directories |
|
180 | + * @param bool $prepend Whether to prepend the directories |
|
181 | + * |
|
182 | + * @return void |
|
183 | + */ |
|
184 | + public function add($prefix, $paths, $prepend = false) |
|
185 | + { |
|
186 | + if (!$prefix) { |
|
187 | + if ($prepend) { |
|
188 | + $this->fallbackDirsPsr0 = array_merge( |
|
189 | + (array) $paths, |
|
190 | + $this->fallbackDirsPsr0 |
|
191 | + ); |
|
192 | + } else { |
|
193 | + $this->fallbackDirsPsr0 = array_merge( |
|
194 | + $this->fallbackDirsPsr0, |
|
195 | + (array) $paths |
|
196 | + ); |
|
197 | + } |
|
198 | + |
|
199 | + return; |
|
200 | + } |
|
201 | + |
|
202 | + $first = $prefix[0]; |
|
203 | + if (!isset($this->prefixesPsr0[$first][$prefix])) { |
|
204 | + $this->prefixesPsr0[$first][$prefix] = (array) $paths; |
|
205 | + |
|
206 | + return; |
|
207 | + } |
|
208 | + if ($prepend) { |
|
209 | + $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
210 | + (array) $paths, |
|
211 | + $this->prefixesPsr0[$first][$prefix] |
|
212 | + ); |
|
213 | + } else { |
|
214 | + $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
215 | + $this->prefixesPsr0[$first][$prefix], |
|
216 | + (array) $paths |
|
217 | + ); |
|
218 | + } |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * Registers a set of PSR-4 directories for a given namespace, either |
|
223 | + * appending or prepending to the ones previously set for this namespace. |
|
224 | + * |
|
225 | + * @param string $prefix The prefix/namespace, with trailing '\\' |
|
226 | + * @param string[]|string $paths The PSR-4 base directories |
|
227 | + * @param bool $prepend Whether to prepend the directories |
|
228 | + * |
|
229 | + * @throws \InvalidArgumentException |
|
230 | + * |
|
231 | + * @return void |
|
232 | + */ |
|
233 | + public function addPsr4($prefix, $paths, $prepend = false) |
|
234 | + { |
|
235 | + if (!$prefix) { |
|
236 | + // Register directories for the root namespace. |
|
237 | + if ($prepend) { |
|
238 | + $this->fallbackDirsPsr4 = array_merge( |
|
239 | + (array) $paths, |
|
240 | + $this->fallbackDirsPsr4 |
|
241 | + ); |
|
242 | + } else { |
|
243 | + $this->fallbackDirsPsr4 = array_merge( |
|
244 | + $this->fallbackDirsPsr4, |
|
245 | + (array) $paths |
|
246 | + ); |
|
247 | + } |
|
248 | + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { |
|
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."); |
|
253 | + } |
|
254 | + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
255 | + $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
256 | + } elseif ($prepend) { |
|
257 | + // Prepend directories for an already registered namespace. |
|
258 | + $this->prefixDirsPsr4[$prefix] = array_merge( |
|
259 | + (array) $paths, |
|
260 | + $this->prefixDirsPsr4[$prefix] |
|
261 | + ); |
|
262 | + } else { |
|
263 | + // Append directories for an already registered namespace. |
|
264 | + $this->prefixDirsPsr4[$prefix] = array_merge( |
|
265 | + $this->prefixDirsPsr4[$prefix], |
|
266 | + (array) $paths |
|
267 | + ); |
|
268 | + } |
|
269 | + } |
|
270 | + |
|
271 | + /** |
|
272 | + * Registers a set of PSR-0 directories for a given prefix, |
|
273 | + * replacing any others previously set for this prefix. |
|
274 | + * |
|
275 | + * @param string $prefix The prefix |
|
276 | + * @param string[]|string $paths The PSR-0 base directories |
|
277 | + * |
|
278 | + * @return void |
|
279 | + */ |
|
280 | + public function set($prefix, $paths) |
|
281 | + { |
|
282 | + if (!$prefix) { |
|
283 | + $this->fallbackDirsPsr0 = (array) $paths; |
|
284 | + } else { |
|
285 | + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; |
|
286 | + } |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * Registers a set of PSR-4 directories for a given namespace, |
|
291 | + * replacing any others previously set for this namespace. |
|
292 | + * |
|
293 | + * @param string $prefix The prefix/namespace, with trailing '\\' |
|
294 | + * @param string[]|string $paths The PSR-4 base directories |
|
295 | + * |
|
296 | + * @throws \InvalidArgumentException |
|
297 | + * |
|
298 | + * @return void |
|
299 | + */ |
|
300 | + public function setPsr4($prefix, $paths) |
|
301 | + { |
|
302 | + if (!$prefix) { |
|
303 | + $this->fallbackDirsPsr4 = (array) $paths; |
|
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."); |
|
308 | + } |
|
309 | + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
310 | + $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
311 | + } |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * Turns on searching the include path for class files. |
|
316 | + * |
|
317 | + * @param bool $useIncludePath |
|
318 | + * |
|
319 | + * @return void |
|
320 | + */ |
|
321 | + public function setUseIncludePath($useIncludePath) |
|
322 | + { |
|
323 | + $this->useIncludePath = $useIncludePath; |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * Can be used to check if the autoloader uses the include path to check |
|
328 | + * for classes. |
|
329 | + * |
|
330 | + * @return bool |
|
331 | + */ |
|
332 | + public function getUseIncludePath() |
|
333 | + { |
|
334 | + return $this->useIncludePath; |
|
335 | + } |
|
336 | + |
|
337 | + /** |
|
338 | + * Turns off searching the prefix and fallback directories for classes |
|
339 | + * that have not been registered with the class map. |
|
340 | + * |
|
341 | + * @param bool $classMapAuthoritative |
|
342 | + * |
|
343 | + * @return void |
|
344 | + */ |
|
345 | + public function setClassMapAuthoritative($classMapAuthoritative) |
|
346 | + { |
|
347 | + $this->classMapAuthoritative = $classMapAuthoritative; |
|
348 | + } |
|
349 | + |
|
350 | + /** |
|
351 | + * Should class lookup fail if not found in the current class map? |
|
352 | + * |
|
353 | + * @return bool |
|
354 | + */ |
|
355 | + public function isClassMapAuthoritative() |
|
356 | + { |
|
357 | + return $this->classMapAuthoritative; |
|
358 | + } |
|
359 | + |
|
360 | + /** |
|
361 | + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. |
|
362 | + * |
|
363 | + * @param string|null $apcuPrefix |
|
364 | + * |
|
365 | + * @return void |
|
366 | + */ |
|
367 | + public function setApcuPrefix($apcuPrefix) |
|
368 | + { |
|
369 | + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; |
|
370 | + } |
|
371 | + |
|
372 | + /** |
|
373 | + * The APCu prefix in use, or null if APCu caching is not enabled. |
|
374 | + * |
|
375 | + * @return string|null |
|
376 | + */ |
|
377 | + public function getApcuPrefix() |
|
378 | + { |
|
379 | + return $this->apcuPrefix; |
|
380 | + } |
|
381 | + |
|
382 | + /** |
|
383 | + * Registers this instance as an autoloader. |
|
384 | + * |
|
385 | + * @param bool $prepend Whether to prepend the autoloader or not |
|
386 | + * |
|
387 | + * @return void |
|
388 | + */ |
|
389 | + public function register($prepend = false) |
|
390 | + { |
|
391 | + spl_autoload_register(array($this, 'loadClass'), true, $prepend); |
|
392 | + |
|
393 | + if (null === $this->vendorDir) { |
|
394 | + return; |
|
395 | + } |
|
396 | + |
|
397 | + if ($prepend) { |
|
398 | + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; |
|
399 | + } else { |
|
400 | + unset(self::$registeredLoaders[$this->vendorDir]); |
|
401 | + self::$registeredLoaders[$this->vendorDir] = $this; |
|
402 | + } |
|
403 | + } |
|
404 | + |
|
405 | + /** |
|
406 | + * Unregisters this instance as an autoloader. |
|
407 | + * |
|
408 | + * @return void |
|
409 | + */ |
|
410 | + public function unregister() |
|
411 | + { |
|
412 | + spl_autoload_unregister(array($this, 'loadClass')); |
|
413 | + |
|
414 | + if (null !== $this->vendorDir) { |
|
415 | + unset(self::$registeredLoaders[$this->vendorDir]); |
|
416 | + } |
|
417 | + } |
|
418 | + |
|
419 | + /** |
|
420 | + * Loads the given class or interface. |
|
421 | + * |
|
422 | + * @param string $class The name of the class |
|
423 | + * @return true|null True if loaded, null otherwise |
|
424 | + */ |
|
425 | + public function loadClass($class) |
|
426 | + { |
|
427 | + if ($file = $this->findFile($class)) { |
|
428 | + includeFile($file); |
|
429 | + |
|
430 | + return true; |
|
431 | + } |
|
432 | + |
|
433 | + return null; |
|
434 | + } |
|
435 | + |
|
436 | + /** |
|
437 | + * Finds the path to the file where the class is defined. |
|
438 | + * |
|
439 | + * @param string $class The name of the class |
|
440 | + * |
|
441 | + * @return string|false The path if found, false otherwise |
|
442 | + */ |
|
443 | + public function findFile($class) |
|
444 | + { |
|
445 | + // class map lookup |
|
446 | + if (isset($this->classMap[$class])) { |
|
447 | + return $this->classMap[$class]; |
|
448 | + } |
|
449 | + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { |
|
450 | + return false; |
|
451 | + } |
|
452 | + if (null !== $this->apcuPrefix) { |
|
453 | + $file = apcu_fetch($this->apcuPrefix.$class, $hit); |
|
454 | + if ($hit) { |
|
455 | + return $file; |
|
456 | + } |
|
457 | + } |
|
458 | + |
|
459 | + $file = $this->findFileWithExtension($class, '.php'); |
|
460 | + |
|
461 | + // Search for Hack files if we are running on HHVM |
|
462 | + if (false === $file && defined('HHVM_VERSION')) { |
|
463 | + $file = $this->findFileWithExtension($class, '.hh'); |
|
464 | + } |
|
465 | + |
|
466 | + if (null !== $this->apcuPrefix) { |
|
467 | + apcu_add($this->apcuPrefix.$class, $file); |
|
468 | + } |
|
469 | + |
|
470 | + if (false === $file) { |
|
471 | + // Remember that this class does not exist. |
|
472 | + $this->missingClasses[$class] = true; |
|
473 | + } |
|
474 | + |
|
475 | + return $file; |
|
476 | + } |
|
477 | + |
|
478 | + /** |
|
479 | + * Returns the currently registered loaders indexed by their corresponding vendor directories. |
|
480 | + * |
|
481 | + * @return self[] |
|
482 | + */ |
|
483 | + public static function getRegisteredLoaders() |
|
484 | + { |
|
485 | + return self::$registeredLoaders; |
|
486 | + } |
|
487 | + |
|
488 | + /** |
|
489 | + * @param string $class |
|
490 | + * @param string $ext |
|
491 | + * @return string|false |
|
492 | + */ |
|
493 | + private function findFileWithExtension($class, $ext) |
|
494 | + { |
|
495 | + // PSR-4 lookup |
|
496 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
497 | + |
|
498 | + $first = $class[0]; |
|
499 | + if (isset($this->prefixLengthsPsr4[$first])) { |
|
500 | + $subPath = $class; |
|
501 | + while (false !== $lastPos = strrpos($subPath, '\\')) { |
|
502 | + $subPath = substr($subPath, 0, $lastPos); |
|
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)) { |
|
508 | + return $file; |
|
509 | + } |
|
510 | + } |
|
511 | + } |
|
512 | + } |
|
513 | + } |
|
514 | + |
|
515 | + // PSR-4 fallback dirs |
|
516 | + foreach ($this->fallbackDirsPsr4 as $dir) { |
|
517 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
518 | + return $file; |
|
519 | + } |
|
520 | + } |
|
521 | + |
|
522 | + // PSR-0 lookup |
|
523 | + if (false !== $pos = strrpos($class, '\\')) { |
|
524 | + // namespaced class name |
|
525 | + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) |
|
526 | + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
|
527 | + } else { |
|
528 | + // PEAR-like class name |
|
529 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
530 | + } |
|
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)) { |
|
537 | + return $file; |
|
538 | + } |
|
539 | + } |
|
540 | + } |
|
541 | + } |
|
542 | + } |
|
543 | + |
|
544 | + // PSR-0 fallback dirs |
|
545 | + foreach ($this->fallbackDirsPsr0 as $dir) { |
|
546 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
547 | + return $file; |
|
548 | + } |
|
549 | + } |
|
550 | + |
|
551 | + // PSR-0 include paths. |
|
552 | + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { |
|
553 | + return $file; |
|
554 | + } |
|
555 | + |
|
556 | + return false; |
|
557 | + } |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
@@ -568,5 +568,5 @@ discard block |
||
568 | 568 | */ |
569 | 569 | function includeFile($file) |
570 | 570 | { |
571 | - include $file; |
|
571 | + include $file; |
|
572 | 572 | } |
@@ -40,8 +40,7 @@ discard block |
||
40 | 40 | * @see https://www.php-fig.org/psr/psr-0/ |
41 | 41 | * @see https://www.php-fig.org/psr/psr-4/ |
42 | 42 | */ |
43 | -class ClassLoader |
|
44 | -{ |
|
43 | +class ClassLoader { |
|
45 | 44 | /** @var ?string */ |
46 | 45 | private $vendorDir; |
47 | 46 | |
@@ -103,16 +102,14 @@ discard block |
||
103 | 102 | /** |
104 | 103 | * @param ?string $vendorDir |
105 | 104 | */ |
106 | - public function __construct($vendorDir = null) |
|
107 | - { |
|
105 | + public function __construct($vendorDir = null) { |
|
108 | 106 | $this->vendorDir = $vendorDir; |
109 | 107 | } |
110 | 108 | |
111 | 109 | /** |
112 | 110 | * @return string[] |
113 | 111 | */ |
114 | - public function getPrefixes() |
|
115 | - { |
|
112 | + public function getPrefixes() { |
|
116 | 113 | if (!empty($this->prefixesPsr0)) { |
117 | 114 | return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); |
118 | 115 | } |
@@ -124,8 +121,7 @@ discard block |
||
124 | 121 | * @return array[] |
125 | 122 | * @psalm-return array<string, array<int, string>> |
126 | 123 | */ |
127 | - public function getPrefixesPsr4() |
|
128 | - { |
|
124 | + public function getPrefixesPsr4() { |
|
129 | 125 | return $this->prefixDirsPsr4; |
130 | 126 | } |
131 | 127 | |
@@ -133,8 +129,7 @@ discard block |
||
133 | 129 | * @return array[] |
134 | 130 | * @psalm-return array<string, string> |
135 | 131 | */ |
136 | - public function getFallbackDirs() |
|
137 | - { |
|
132 | + public function getFallbackDirs() { |
|
138 | 133 | return $this->fallbackDirsPsr0; |
139 | 134 | } |
140 | 135 | |
@@ -142,8 +137,7 @@ discard block |
||
142 | 137 | * @return array[] |
143 | 138 | * @psalm-return array<string, string> |
144 | 139 | */ |
145 | - public function getFallbackDirsPsr4() |
|
146 | - { |
|
140 | + public function getFallbackDirsPsr4() { |
|
147 | 141 | return $this->fallbackDirsPsr4; |
148 | 142 | } |
149 | 143 | |
@@ -151,8 +145,7 @@ discard block |
||
151 | 145 | * @return string[] Array of classname => path |
152 | 146 | * @psalm-return array<string, string> |
153 | 147 | */ |
154 | - public function getClassMap() |
|
155 | - { |
|
148 | + public function getClassMap() { |
|
156 | 149 | return $this->classMap; |
157 | 150 | } |
158 | 151 | |
@@ -162,8 +155,7 @@ discard block |
||
162 | 155 | * |
163 | 156 | * @return void |
164 | 157 | */ |
165 | - public function addClassMap(array $classMap) |
|
166 | - { |
|
158 | + public function addClassMap(array $classMap) { |
|
167 | 159 | if ($this->classMap) { |
168 | 160 | $this->classMap = array_merge($this->classMap, $classMap); |
169 | 161 | } else { |
@@ -181,8 +173,7 @@ discard block |
||
181 | 173 | * |
182 | 174 | * @return void |
183 | 175 | */ |
184 | - public function add($prefix, $paths, $prepend = false) |
|
185 | - { |
|
176 | + public function add($prefix, $paths, $prepend = false) { |
|
186 | 177 | if (!$prefix) { |
187 | 178 | if ($prepend) { |
188 | 179 | $this->fallbackDirsPsr0 = array_merge( |
@@ -230,8 +221,7 @@ discard block |
||
230 | 221 | * |
231 | 222 | * @return void |
232 | 223 | */ |
233 | - public function addPsr4($prefix, $paths, $prepend = false) |
|
234 | - { |
|
224 | + public function addPsr4($prefix, $paths, $prepend = false) { |
|
235 | 225 | if (!$prefix) { |
236 | 226 | // Register directories for the root namespace. |
237 | 227 | if ($prepend) { |
@@ -277,8 +267,7 @@ discard block |
||
277 | 267 | * |
278 | 268 | * @return void |
279 | 269 | */ |
280 | - public function set($prefix, $paths) |
|
281 | - { |
|
270 | + public function set($prefix, $paths) { |
|
282 | 271 | if (!$prefix) { |
283 | 272 | $this->fallbackDirsPsr0 = (array) $paths; |
284 | 273 | } else { |
@@ -297,8 +286,7 @@ discard block |
||
297 | 286 | * |
298 | 287 | * @return void |
299 | 288 | */ |
300 | - public function setPsr4($prefix, $paths) |
|
301 | - { |
|
289 | + public function setPsr4($prefix, $paths) { |
|
302 | 290 | if (!$prefix) { |
303 | 291 | $this->fallbackDirsPsr4 = (array) $paths; |
304 | 292 | } else { |
@@ -318,8 +306,7 @@ discard block |
||
318 | 306 | * |
319 | 307 | * @return void |
320 | 308 | */ |
321 | - public function setUseIncludePath($useIncludePath) |
|
322 | - { |
|
309 | + public function setUseIncludePath($useIncludePath) { |
|
323 | 310 | $this->useIncludePath = $useIncludePath; |
324 | 311 | } |
325 | 312 | |
@@ -329,8 +316,7 @@ discard block |
||
329 | 316 | * |
330 | 317 | * @return bool |
331 | 318 | */ |
332 | - public function getUseIncludePath() |
|
333 | - { |
|
319 | + public function getUseIncludePath() { |
|
334 | 320 | return $this->useIncludePath; |
335 | 321 | } |
336 | 322 | |
@@ -342,8 +328,7 @@ discard block |
||
342 | 328 | * |
343 | 329 | * @return void |
344 | 330 | */ |
345 | - public function setClassMapAuthoritative($classMapAuthoritative) |
|
346 | - { |
|
331 | + public function setClassMapAuthoritative($classMapAuthoritative) { |
|
347 | 332 | $this->classMapAuthoritative = $classMapAuthoritative; |
348 | 333 | } |
349 | 334 | |
@@ -352,8 +337,7 @@ discard block |
||
352 | 337 | * |
353 | 338 | * @return bool |
354 | 339 | */ |
355 | - public function isClassMapAuthoritative() |
|
356 | - { |
|
340 | + public function isClassMapAuthoritative() { |
|
357 | 341 | return $this->classMapAuthoritative; |
358 | 342 | } |
359 | 343 | |
@@ -364,8 +348,7 @@ discard block |
||
364 | 348 | * |
365 | 349 | * @return void |
366 | 350 | */ |
367 | - public function setApcuPrefix($apcuPrefix) |
|
368 | - { |
|
351 | + public function setApcuPrefix($apcuPrefix) { |
|
369 | 352 | $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; |
370 | 353 | } |
371 | 354 | |
@@ -374,8 +357,7 @@ discard block |
||
374 | 357 | * |
375 | 358 | * @return string|null |
376 | 359 | */ |
377 | - public function getApcuPrefix() |
|
378 | - { |
|
360 | + public function getApcuPrefix() { |
|
379 | 361 | return $this->apcuPrefix; |
380 | 362 | } |
381 | 363 | |
@@ -386,8 +368,7 @@ discard block |
||
386 | 368 | * |
387 | 369 | * @return void |
388 | 370 | */ |
389 | - public function register($prepend = false) |
|
390 | - { |
|
371 | + public function register($prepend = false) { |
|
391 | 372 | spl_autoload_register(array($this, 'loadClass'), true, $prepend); |
392 | 373 | |
393 | 374 | if (null === $this->vendorDir) { |
@@ -407,8 +388,7 @@ discard block |
||
407 | 388 | * |
408 | 389 | * @return void |
409 | 390 | */ |
410 | - public function unregister() |
|
411 | - { |
|
391 | + public function unregister() { |
|
412 | 392 | spl_autoload_unregister(array($this, 'loadClass')); |
413 | 393 | |
414 | 394 | if (null !== $this->vendorDir) { |
@@ -422,8 +402,7 @@ discard block |
||
422 | 402 | * @param string $class The name of the class |
423 | 403 | * @return true|null True if loaded, null otherwise |
424 | 404 | */ |
425 | - public function loadClass($class) |
|
426 | - { |
|
405 | + public function loadClass($class) { |
|
427 | 406 | if ($file = $this->findFile($class)) { |
428 | 407 | includeFile($file); |
429 | 408 | |
@@ -440,8 +419,7 @@ discard block |
||
440 | 419 | * |
441 | 420 | * @return string|false The path if found, false otherwise |
442 | 421 | */ |
443 | - public function findFile($class) |
|
444 | - { |
|
422 | + public function findFile($class) { |
|
445 | 423 | // class map lookup |
446 | 424 | if (isset($this->classMap[$class])) { |
447 | 425 | return $this->classMap[$class]; |
@@ -480,8 +458,7 @@ discard block |
||
480 | 458 | * |
481 | 459 | * @return self[] |
482 | 460 | */ |
483 | - public static function getRegisteredLoaders() |
|
484 | - { |
|
461 | + public static function getRegisteredLoaders() { |
|
485 | 462 | return self::$registeredLoaders; |
486 | 463 | } |
487 | 464 | |
@@ -490,8 +467,7 @@ discard block |
||
490 | 467 | * @param string $ext |
491 | 468 | * @return string|false |
492 | 469 | */ |
493 | - private function findFileWithExtension($class, $ext) |
|
494 | - { |
|
470 | + private function findFileWithExtension($class, $ext) { |
|
495 | 471 | // PSR-4 lookup |
496 | 472 | $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
497 | 473 | |
@@ -566,7 +542,6 @@ discard block |
||
566 | 542 | * @return void |
567 | 543 | * @private |
568 | 544 | */ |
569 | -function includeFile($file) |
|
570 | -{ |
|
545 | +function includeFile($file) { |
|
571 | 546 | include $file; |
572 | 547 | } |
@@ -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 | } |
@@ -24,327 +24,327 @@ |
||
24 | 24 | */ |
25 | 25 | class InstalledVersions |
26 | 26 | { |
27 | - /** |
|
28 | - * @var mixed[]|null |
|
29 | - * @psalm-var 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}>}|array{}|null |
|
30 | - */ |
|
31 | - private static $installed; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var bool|null |
|
35 | - */ |
|
36 | - private static $canGetVendors; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var array[] |
|
40 | - * @psalm-var array<string, 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}>}> |
|
41 | - */ |
|
42 | - private static $installedByVendor = array(); |
|
43 | - |
|
44 | - /** |
|
45 | - * Returns a list of all package names which are present, either by being installed, replaced or provided |
|
46 | - * |
|
47 | - * @return string[] |
|
48 | - * @psalm-return list<string> |
|
49 | - */ |
|
50 | - public static function getInstalledPackages() |
|
51 | - { |
|
52 | - $packages = array(); |
|
53 | - foreach (self::getInstalled() as $installed) { |
|
54 | - $packages[] = array_keys($installed['versions']); |
|
55 | - } |
|
56 | - |
|
57 | - if (1 === \count($packages)) { |
|
58 | - return $packages[0]; |
|
59 | - } |
|
60 | - |
|
61 | - return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * Returns a list of all package names with a specific type e.g. 'library' |
|
66 | - * |
|
67 | - * @param string $type |
|
68 | - * @return string[] |
|
69 | - * @psalm-return list<string> |
|
70 | - */ |
|
71 | - public static function getInstalledPackagesByType($type) |
|
72 | - { |
|
73 | - $packagesByType = array(); |
|
74 | - |
|
75 | - foreach (self::getInstalled() as $installed) { |
|
76 | - foreach ($installed['versions'] as $name => $package) { |
|
77 | - if (isset($package['type']) && $package['type'] === $type) { |
|
78 | - $packagesByType[] = $name; |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
82 | - |
|
83 | - return $packagesByType; |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Checks whether the given package is installed |
|
88 | - * |
|
89 | - * This also returns true if the package name is provided or replaced by another package |
|
90 | - * |
|
91 | - * @param string $packageName |
|
92 | - * @param bool $includeDevRequirements |
|
93 | - * @return bool |
|
94 | - */ |
|
95 | - public static function isInstalled($packageName, $includeDevRequirements = true) |
|
96 | - { |
|
97 | - foreach (self::getInstalled() as $installed) { |
|
98 | - if (isset($installed['versions'][$packageName])) { |
|
99 | - return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); |
|
100 | - } |
|
101 | - } |
|
102 | - |
|
103 | - return false; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Checks whether the given package satisfies a version constraint |
|
108 | - * |
|
109 | - * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: |
|
110 | - * |
|
111 | - * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') |
|
112 | - * |
|
113 | - * @param VersionParser $parser Install composer/semver to have access to this class and functionality |
|
114 | - * @param string $packageName |
|
115 | - * @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 |
|
116 | - * @return bool |
|
117 | - */ |
|
118 | - public static function satisfies(VersionParser $parser, $packageName, $constraint) |
|
119 | - { |
|
120 | - $constraint = $parser->parseConstraints($constraint); |
|
121 | - $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); |
|
122 | - |
|
123 | - return $provided->matches($constraint); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Returns a version constraint representing all the range(s) which are installed for a given package |
|
128 | - * |
|
129 | - * It is easier to use this via isInstalled() with the $constraint argument if you need to check |
|
130 | - * whether a given version of a package is installed, and not just whether it exists |
|
131 | - * |
|
132 | - * @param string $packageName |
|
133 | - * @return string Version constraint usable with composer/semver |
|
134 | - */ |
|
135 | - public static function getVersionRanges($packageName) |
|
136 | - { |
|
137 | - foreach (self::getInstalled() as $installed) { |
|
138 | - if (!isset($installed['versions'][$packageName])) { |
|
139 | - continue; |
|
140 | - } |
|
141 | - |
|
142 | - $ranges = array(); |
|
143 | - if (isset($installed['versions'][$packageName]['pretty_version'])) { |
|
144 | - $ranges[] = $installed['versions'][$packageName]['pretty_version']; |
|
145 | - } |
|
146 | - if (array_key_exists('aliases', $installed['versions'][$packageName])) { |
|
147 | - $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); |
|
148 | - } |
|
149 | - if (array_key_exists('replaced', $installed['versions'][$packageName])) { |
|
150 | - $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); |
|
151 | - } |
|
152 | - if (array_key_exists('provided', $installed['versions'][$packageName])) { |
|
153 | - $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); |
|
154 | - } |
|
155 | - |
|
156 | - return implode(' || ', $ranges); |
|
157 | - } |
|
158 | - |
|
159 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * @param string $packageName |
|
164 | - * @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 |
|
165 | - */ |
|
166 | - public static function getVersion($packageName) |
|
167 | - { |
|
168 | - foreach (self::getInstalled() as $installed) { |
|
169 | - if (!isset($installed['versions'][$packageName])) { |
|
170 | - continue; |
|
171 | - } |
|
172 | - |
|
173 | - if (!isset($installed['versions'][$packageName]['version'])) { |
|
174 | - return null; |
|
175 | - } |
|
176 | - |
|
177 | - return $installed['versions'][$packageName]['version']; |
|
178 | - } |
|
179 | - |
|
180 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * @param string $packageName |
|
185 | - * @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 |
|
186 | - */ |
|
187 | - public static function getPrettyVersion($packageName) |
|
188 | - { |
|
189 | - foreach (self::getInstalled() as $installed) { |
|
190 | - if (!isset($installed['versions'][$packageName])) { |
|
191 | - continue; |
|
192 | - } |
|
193 | - |
|
194 | - if (!isset($installed['versions'][$packageName]['pretty_version'])) { |
|
195 | - return null; |
|
196 | - } |
|
197 | - |
|
198 | - return $installed['versions'][$packageName]['pretty_version']; |
|
199 | - } |
|
200 | - |
|
201 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * @param string $packageName |
|
206 | - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference |
|
207 | - */ |
|
208 | - public static function getReference($packageName) |
|
209 | - { |
|
210 | - foreach (self::getInstalled() as $installed) { |
|
211 | - if (!isset($installed['versions'][$packageName])) { |
|
212 | - continue; |
|
213 | - } |
|
214 | - |
|
215 | - if (!isset($installed['versions'][$packageName]['reference'])) { |
|
216 | - return null; |
|
217 | - } |
|
218 | - |
|
219 | - return $installed['versions'][$packageName]['reference']; |
|
220 | - } |
|
221 | - |
|
222 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
223 | - } |
|
224 | - |
|
225 | - /** |
|
226 | - * @param string $packageName |
|
227 | - * @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. |
|
228 | - */ |
|
229 | - public static function getInstallPath($packageName) |
|
230 | - { |
|
231 | - foreach (self::getInstalled() as $installed) { |
|
232 | - if (!isset($installed['versions'][$packageName])) { |
|
233 | - continue; |
|
234 | - } |
|
235 | - |
|
236 | - return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; |
|
237 | - } |
|
238 | - |
|
239 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * @return array |
|
244 | - * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} |
|
245 | - */ |
|
246 | - public static function getRootPackage() |
|
247 | - { |
|
248 | - $installed = self::getInstalled(); |
|
249 | - |
|
250 | - return $installed[0]['root']; |
|
251 | - } |
|
252 | - |
|
253 | - /** |
|
254 | - * Returns the raw installed.php data for custom implementations |
|
255 | - * |
|
256 | - * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. |
|
257 | - * @return array[] |
|
258 | - * @psalm-return 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}>} |
|
259 | - */ |
|
260 | - public static function getRawData() |
|
261 | - { |
|
262 | - @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); |
|
263 | - |
|
264 | - if (null === self::$installed) { |
|
265 | - // only require the installed.php file if this file is loaded from its dumped location, |
|
266 | - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 |
|
267 | - if (substr(__DIR__, -8, 1) !== 'C') { |
|
268 | - self::$installed = include __DIR__ . '/installed.php'; |
|
269 | - } else { |
|
270 | - self::$installed = array(); |
|
271 | - } |
|
272 | - } |
|
273 | - |
|
274 | - return self::$installed; |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * Returns the raw data of all installed.php which are currently loaded for custom implementations |
|
279 | - * |
|
280 | - * @return array[] |
|
281 | - * @psalm-return list<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}>}> |
|
282 | - */ |
|
283 | - public static function getAllRawData() |
|
284 | - { |
|
285 | - return self::getInstalled(); |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * Lets you reload the static array from another file |
|
290 | - * |
|
291 | - * This is only useful for complex integrations in which a project needs to use |
|
292 | - * this class but then also needs to execute another project's autoloader in process, |
|
293 | - * and wants to ensure both projects have access to their version of installed.php. |
|
294 | - * |
|
295 | - * A typical case would be PHPUnit, where it would need to make sure it reads all |
|
296 | - * the data it needs from this class, then call reload() with |
|
297 | - * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure |
|
298 | - * the project in which it runs can then also use this class safely, without |
|
299 | - * interference between PHPUnit's dependencies and the project's dependencies. |
|
300 | - * |
|
301 | - * @param array[] $data A vendor/composer/installed.php data set |
|
302 | - * @return void |
|
303 | - * |
|
304 | - * @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 |
|
305 | - */ |
|
306 | - public static function reload($data) |
|
307 | - { |
|
308 | - self::$installed = $data; |
|
309 | - self::$installedByVendor = array(); |
|
310 | - } |
|
311 | - |
|
312 | - /** |
|
313 | - * @return array[] |
|
314 | - * @psalm-return list<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}>}> |
|
315 | - */ |
|
316 | - private static function getInstalled() |
|
317 | - { |
|
318 | - if (null === self::$canGetVendors) { |
|
319 | - self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); |
|
320 | - } |
|
321 | - |
|
322 | - $installed = array(); |
|
323 | - |
|
324 | - if (self::$canGetVendors) { |
|
325 | - foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { |
|
326 | - if (isset(self::$installedByVendor[$vendorDir])) { |
|
327 | - $installed[] = self::$installedByVendor[$vendorDir]; |
|
328 | - } elseif (is_file($vendorDir.'/composer/installed.php')) { |
|
329 | - $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; |
|
330 | - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { |
|
331 | - self::$installed = $installed[count($installed) - 1]; |
|
332 | - } |
|
333 | - } |
|
334 | - } |
|
335 | - } |
|
336 | - |
|
337 | - if (null === self::$installed) { |
|
338 | - // only require the installed.php file if this file is loaded from its dumped location, |
|
339 | - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 |
|
340 | - if (substr(__DIR__, -8, 1) !== 'C') { |
|
341 | - self::$installed = require __DIR__ . '/installed.php'; |
|
342 | - } else { |
|
343 | - self::$installed = array(); |
|
344 | - } |
|
345 | - } |
|
346 | - $installed[] = self::$installed; |
|
347 | - |
|
348 | - return $installed; |
|
349 | - } |
|
27 | + /** |
|
28 | + * @var mixed[]|null |
|
29 | + * @psalm-var 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}>}|array{}|null |
|
30 | + */ |
|
31 | + private static $installed; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var bool|null |
|
35 | + */ |
|
36 | + private static $canGetVendors; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var array[] |
|
40 | + * @psalm-var array<string, 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}>}> |
|
41 | + */ |
|
42 | + private static $installedByVendor = array(); |
|
43 | + |
|
44 | + /** |
|
45 | + * Returns a list of all package names which are present, either by being installed, replaced or provided |
|
46 | + * |
|
47 | + * @return string[] |
|
48 | + * @psalm-return list<string> |
|
49 | + */ |
|
50 | + public static function getInstalledPackages() |
|
51 | + { |
|
52 | + $packages = array(); |
|
53 | + foreach (self::getInstalled() as $installed) { |
|
54 | + $packages[] = array_keys($installed['versions']); |
|
55 | + } |
|
56 | + |
|
57 | + if (1 === \count($packages)) { |
|
58 | + return $packages[0]; |
|
59 | + } |
|
60 | + |
|
61 | + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * Returns a list of all package names with a specific type e.g. 'library' |
|
66 | + * |
|
67 | + * @param string $type |
|
68 | + * @return string[] |
|
69 | + * @psalm-return list<string> |
|
70 | + */ |
|
71 | + public static function getInstalledPackagesByType($type) |
|
72 | + { |
|
73 | + $packagesByType = array(); |
|
74 | + |
|
75 | + foreach (self::getInstalled() as $installed) { |
|
76 | + foreach ($installed['versions'] as $name => $package) { |
|
77 | + if (isset($package['type']) && $package['type'] === $type) { |
|
78 | + $packagesByType[] = $name; |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
82 | + |
|
83 | + return $packagesByType; |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Checks whether the given package is installed |
|
88 | + * |
|
89 | + * This also returns true if the package name is provided or replaced by another package |
|
90 | + * |
|
91 | + * @param string $packageName |
|
92 | + * @param bool $includeDevRequirements |
|
93 | + * @return bool |
|
94 | + */ |
|
95 | + public static function isInstalled($packageName, $includeDevRequirements = true) |
|
96 | + { |
|
97 | + foreach (self::getInstalled() as $installed) { |
|
98 | + if (isset($installed['versions'][$packageName])) { |
|
99 | + return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); |
|
100 | + } |
|
101 | + } |
|
102 | + |
|
103 | + return false; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Checks whether the given package satisfies a version constraint |
|
108 | + * |
|
109 | + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: |
|
110 | + * |
|
111 | + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') |
|
112 | + * |
|
113 | + * @param VersionParser $parser Install composer/semver to have access to this class and functionality |
|
114 | + * @param string $packageName |
|
115 | + * @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 |
|
116 | + * @return bool |
|
117 | + */ |
|
118 | + public static function satisfies(VersionParser $parser, $packageName, $constraint) |
|
119 | + { |
|
120 | + $constraint = $parser->parseConstraints($constraint); |
|
121 | + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); |
|
122 | + |
|
123 | + return $provided->matches($constraint); |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Returns a version constraint representing all the range(s) which are installed for a given package |
|
128 | + * |
|
129 | + * It is easier to use this via isInstalled() with the $constraint argument if you need to check |
|
130 | + * whether a given version of a package is installed, and not just whether it exists |
|
131 | + * |
|
132 | + * @param string $packageName |
|
133 | + * @return string Version constraint usable with composer/semver |
|
134 | + */ |
|
135 | + public static function getVersionRanges($packageName) |
|
136 | + { |
|
137 | + foreach (self::getInstalled() as $installed) { |
|
138 | + if (!isset($installed['versions'][$packageName])) { |
|
139 | + continue; |
|
140 | + } |
|
141 | + |
|
142 | + $ranges = array(); |
|
143 | + if (isset($installed['versions'][$packageName]['pretty_version'])) { |
|
144 | + $ranges[] = $installed['versions'][$packageName]['pretty_version']; |
|
145 | + } |
|
146 | + if (array_key_exists('aliases', $installed['versions'][$packageName])) { |
|
147 | + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); |
|
148 | + } |
|
149 | + if (array_key_exists('replaced', $installed['versions'][$packageName])) { |
|
150 | + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); |
|
151 | + } |
|
152 | + if (array_key_exists('provided', $installed['versions'][$packageName])) { |
|
153 | + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); |
|
154 | + } |
|
155 | + |
|
156 | + return implode(' || ', $ranges); |
|
157 | + } |
|
158 | + |
|
159 | + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * @param string $packageName |
|
164 | + * @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 |
|
165 | + */ |
|
166 | + public static function getVersion($packageName) |
|
167 | + { |
|
168 | + foreach (self::getInstalled() as $installed) { |
|
169 | + if (!isset($installed['versions'][$packageName])) { |
|
170 | + continue; |
|
171 | + } |
|
172 | + |
|
173 | + if (!isset($installed['versions'][$packageName]['version'])) { |
|
174 | + return null; |
|
175 | + } |
|
176 | + |
|
177 | + return $installed['versions'][$packageName]['version']; |
|
178 | + } |
|
179 | + |
|
180 | + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
181 | + } |
|
182 | + |
|
183 | + /** |
|
184 | + * @param string $packageName |
|
185 | + * @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 |
|
186 | + */ |
|
187 | + public static function getPrettyVersion($packageName) |
|
188 | + { |
|
189 | + foreach (self::getInstalled() as $installed) { |
|
190 | + if (!isset($installed['versions'][$packageName])) { |
|
191 | + continue; |
|
192 | + } |
|
193 | + |
|
194 | + if (!isset($installed['versions'][$packageName]['pretty_version'])) { |
|
195 | + return null; |
|
196 | + } |
|
197 | + |
|
198 | + return $installed['versions'][$packageName]['pretty_version']; |
|
199 | + } |
|
200 | + |
|
201 | + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * @param string $packageName |
|
206 | + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference |
|
207 | + */ |
|
208 | + public static function getReference($packageName) |
|
209 | + { |
|
210 | + foreach (self::getInstalled() as $installed) { |
|
211 | + if (!isset($installed['versions'][$packageName])) { |
|
212 | + continue; |
|
213 | + } |
|
214 | + |
|
215 | + if (!isset($installed['versions'][$packageName]['reference'])) { |
|
216 | + return null; |
|
217 | + } |
|
218 | + |
|
219 | + return $installed['versions'][$packageName]['reference']; |
|
220 | + } |
|
221 | + |
|
222 | + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
223 | + } |
|
224 | + |
|
225 | + /** |
|
226 | + * @param string $packageName |
|
227 | + * @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. |
|
228 | + */ |
|
229 | + public static function getInstallPath($packageName) |
|
230 | + { |
|
231 | + foreach (self::getInstalled() as $installed) { |
|
232 | + if (!isset($installed['versions'][$packageName])) { |
|
233 | + continue; |
|
234 | + } |
|
235 | + |
|
236 | + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; |
|
237 | + } |
|
238 | + |
|
239 | + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * @return array |
|
244 | + * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} |
|
245 | + */ |
|
246 | + public static function getRootPackage() |
|
247 | + { |
|
248 | + $installed = self::getInstalled(); |
|
249 | + |
|
250 | + return $installed[0]['root']; |
|
251 | + } |
|
252 | + |
|
253 | + /** |
|
254 | + * Returns the raw installed.php data for custom implementations |
|
255 | + * |
|
256 | + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. |
|
257 | + * @return array[] |
|
258 | + * @psalm-return 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}>} |
|
259 | + */ |
|
260 | + public static function getRawData() |
|
261 | + { |
|
262 | + @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); |
|
263 | + |
|
264 | + if (null === self::$installed) { |
|
265 | + // only require the installed.php file if this file is loaded from its dumped location, |
|
266 | + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 |
|
267 | + if (substr(__DIR__, -8, 1) !== 'C') { |
|
268 | + self::$installed = include __DIR__ . '/installed.php'; |
|
269 | + } else { |
|
270 | + self::$installed = array(); |
|
271 | + } |
|
272 | + } |
|
273 | + |
|
274 | + return self::$installed; |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * Returns the raw data of all installed.php which are currently loaded for custom implementations |
|
279 | + * |
|
280 | + * @return array[] |
|
281 | + * @psalm-return list<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}>}> |
|
282 | + */ |
|
283 | + public static function getAllRawData() |
|
284 | + { |
|
285 | + return self::getInstalled(); |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * Lets you reload the static array from another file |
|
290 | + * |
|
291 | + * This is only useful for complex integrations in which a project needs to use |
|
292 | + * this class but then also needs to execute another project's autoloader in process, |
|
293 | + * and wants to ensure both projects have access to their version of installed.php. |
|
294 | + * |
|
295 | + * A typical case would be PHPUnit, where it would need to make sure it reads all |
|
296 | + * the data it needs from this class, then call reload() with |
|
297 | + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure |
|
298 | + * the project in which it runs can then also use this class safely, without |
|
299 | + * interference between PHPUnit's dependencies and the project's dependencies. |
|
300 | + * |
|
301 | + * @param array[] $data A vendor/composer/installed.php data set |
|
302 | + * @return void |
|
303 | + * |
|
304 | + * @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 |
|
305 | + */ |
|
306 | + public static function reload($data) |
|
307 | + { |
|
308 | + self::$installed = $data; |
|
309 | + self::$installedByVendor = array(); |
|
310 | + } |
|
311 | + |
|
312 | + /** |
|
313 | + * @return array[] |
|
314 | + * @psalm-return list<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}>}> |
|
315 | + */ |
|
316 | + private static function getInstalled() |
|
317 | + { |
|
318 | + if (null === self::$canGetVendors) { |
|
319 | + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); |
|
320 | + } |
|
321 | + |
|
322 | + $installed = array(); |
|
323 | + |
|
324 | + if (self::$canGetVendors) { |
|
325 | + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { |
|
326 | + if (isset(self::$installedByVendor[$vendorDir])) { |
|
327 | + $installed[] = self::$installedByVendor[$vendorDir]; |
|
328 | + } elseif (is_file($vendorDir.'/composer/installed.php')) { |
|
329 | + $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; |
|
330 | + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { |
|
331 | + self::$installed = $installed[count($installed) - 1]; |
|
332 | + } |
|
333 | + } |
|
334 | + } |
|
335 | + } |
|
336 | + |
|
337 | + if (null === self::$installed) { |
|
338 | + // only require the installed.php file if this file is loaded from its dumped location, |
|
339 | + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 |
|
340 | + if (substr(__DIR__, -8, 1) !== 'C') { |
|
341 | + self::$installed = require __DIR__ . '/installed.php'; |
|
342 | + } else { |
|
343 | + self::$installed = array(); |
|
344 | + } |
|
345 | + } |
|
346 | + $installed[] = self::$installed; |
|
347 | + |
|
348 | + return $installed; |
|
349 | + } |
|
350 | 350 | } |
@@ -22,8 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * To require its presence, you can require `composer-runtime-api ^2.0` |
24 | 24 | */ |
25 | -class InstalledVersions |
|
26 | -{ |
|
25 | +class InstalledVersions { |
|
27 | 26 | /** |
28 | 27 | * @var mixed[]|null |
29 | 28 | * @psalm-var 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}>}|array{}|null |
@@ -47,8 +46,7 @@ discard block |
||
47 | 46 | * @return string[] |
48 | 47 | * @psalm-return list<string> |
49 | 48 | */ |
50 | - public static function getInstalledPackages() |
|
51 | - { |
|
49 | + public static function getInstalledPackages() { |
|
52 | 50 | $packages = array(); |
53 | 51 | foreach (self::getInstalled() as $installed) { |
54 | 52 | $packages[] = array_keys($installed['versions']); |
@@ -68,8 +66,7 @@ discard block |
||
68 | 66 | * @return string[] |
69 | 67 | * @psalm-return list<string> |
70 | 68 | */ |
71 | - public static function getInstalledPackagesByType($type) |
|
72 | - { |
|
69 | + public static function getInstalledPackagesByType($type) { |
|
73 | 70 | $packagesByType = array(); |
74 | 71 | |
75 | 72 | foreach (self::getInstalled() as $installed) { |
@@ -92,8 +89,7 @@ discard block |
||
92 | 89 | * @param bool $includeDevRequirements |
93 | 90 | * @return bool |
94 | 91 | */ |
95 | - public static function isInstalled($packageName, $includeDevRequirements = true) |
|
96 | - { |
|
92 | + public static function isInstalled($packageName, $includeDevRequirements = true) { |
|
97 | 93 | foreach (self::getInstalled() as $installed) { |
98 | 94 | if (isset($installed['versions'][$packageName])) { |
99 | 95 | return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); |
@@ -115,8 +111,7 @@ discard block |
||
115 | 111 | * @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 |
116 | 112 | * @return bool |
117 | 113 | */ |
118 | - public static function satisfies(VersionParser $parser, $packageName, $constraint) |
|
119 | - { |
|
114 | + public static function satisfies(VersionParser $parser, $packageName, $constraint) { |
|
120 | 115 | $constraint = $parser->parseConstraints($constraint); |
121 | 116 | $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); |
122 | 117 | |
@@ -132,8 +127,7 @@ discard block |
||
132 | 127 | * @param string $packageName |
133 | 128 | * @return string Version constraint usable with composer/semver |
134 | 129 | */ |
135 | - public static function getVersionRanges($packageName) |
|
136 | - { |
|
130 | + public static function getVersionRanges($packageName) { |
|
137 | 131 | foreach (self::getInstalled() as $installed) { |
138 | 132 | if (!isset($installed['versions'][$packageName])) { |
139 | 133 | continue; |
@@ -163,8 +157,7 @@ discard block |
||
163 | 157 | * @param string $packageName |
164 | 158 | * @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 |
165 | 159 | */ |
166 | - public static function getVersion($packageName) |
|
167 | - { |
|
160 | + public static function getVersion($packageName) { |
|
168 | 161 | foreach (self::getInstalled() as $installed) { |
169 | 162 | if (!isset($installed['versions'][$packageName])) { |
170 | 163 | continue; |
@@ -184,8 +177,7 @@ discard block |
||
184 | 177 | * @param string $packageName |
185 | 178 | * @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 |
186 | 179 | */ |
187 | - public static function getPrettyVersion($packageName) |
|
188 | - { |
|
180 | + public static function getPrettyVersion($packageName) { |
|
189 | 181 | foreach (self::getInstalled() as $installed) { |
190 | 182 | if (!isset($installed['versions'][$packageName])) { |
191 | 183 | continue; |
@@ -205,8 +197,7 @@ discard block |
||
205 | 197 | * @param string $packageName |
206 | 198 | * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference |
207 | 199 | */ |
208 | - public static function getReference($packageName) |
|
209 | - { |
|
200 | + public static function getReference($packageName) { |
|
210 | 201 | foreach (self::getInstalled() as $installed) { |
211 | 202 | if (!isset($installed['versions'][$packageName])) { |
212 | 203 | continue; |
@@ -226,8 +217,7 @@ discard block |
||
226 | 217 | * @param string $packageName |
227 | 218 | * @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. |
228 | 219 | */ |
229 | - public static function getInstallPath($packageName) |
|
230 | - { |
|
220 | + public static function getInstallPath($packageName) { |
|
231 | 221 | foreach (self::getInstalled() as $installed) { |
232 | 222 | if (!isset($installed['versions'][$packageName])) { |
233 | 223 | continue; |
@@ -243,8 +233,7 @@ discard block |
||
243 | 233 | * @return array |
244 | 234 | * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} |
245 | 235 | */ |
246 | - public static function getRootPackage() |
|
247 | - { |
|
236 | + public static function getRootPackage() { |
|
248 | 237 | $installed = self::getInstalled(); |
249 | 238 | |
250 | 239 | return $installed[0]['root']; |
@@ -257,8 +246,7 @@ discard block |
||
257 | 246 | * @return array[] |
258 | 247 | * @psalm-return 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}>} |
259 | 248 | */ |
260 | - public static function getRawData() |
|
261 | - { |
|
249 | + public static function getRawData() { |
|
262 | 250 | @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); |
263 | 251 | |
264 | 252 | if (null === self::$installed) { |
@@ -280,8 +268,7 @@ discard block |
||
280 | 268 | * @return array[] |
281 | 269 | * @psalm-return list<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}>}> |
282 | 270 | */ |
283 | - public static function getAllRawData() |
|
284 | - { |
|
271 | + public static function getAllRawData() { |
|
285 | 272 | return self::getInstalled(); |
286 | 273 | } |
287 | 274 | |
@@ -303,8 +290,7 @@ discard block |
||
303 | 290 | * |
304 | 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 |
305 | 292 | */ |
306 | - public static function reload($data) |
|
307 | - { |
|
293 | + public static function reload($data) { |
|
308 | 294 | self::$installed = $data; |
309 | 295 | self::$installedByVendor = array(); |
310 | 296 | } |
@@ -313,8 +299,7 @@ discard block |
||
313 | 299 | * @return array[] |
314 | 300 | * @psalm-return list<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}>}> |
315 | 301 | */ |
316 | - private static function getInstalled() |
|
317 | - { |
|
302 | + private static function getInstalled() { |
|
318 | 303 | if (null === self::$canGetVendors) { |
319 | 304 | self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); |
320 | 305 | } |
@@ -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' ); |
@@ -52,7 +52,7 @@ |
||
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 | 57 | if( empty( $context ) || $context !== 'edit' ) { |
58 | 58 | return $blocklist; |
@@ -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; |
@@ -62,28 +62,28 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | - * When on the Add/Edit View screen, suggest most popular articles related to that |
|
66 | - * |
|
65 | + * When on the Add/Edit View screen, suggest most popular articles related to that |
|
66 | + * |
|
67 | 67 | * @param array $localization_data Data to be passed to the Support Port JS |
68 | 68 | * |
69 | 69 | * @return array |
70 | 70 | */ |
71 | 71 | function suggest_support_articles( $localization_data = array() ) { |
72 | 72 | |
73 | - if( ! gravityview()->request->is_view() ) { |
|
74 | - return $localization_data; |
|
75 | - } |
|
73 | + if( ! gravityview()->request->is_view() ) { |
|
74 | + return $localization_data; |
|
75 | + } |
|
76 | 76 | |
77 | 77 | $localization_data['suggest'] = array( |
78 | - '57ef23539033602e61d4a560', |
|
79 | - '54c67bb9e4b0512429885513', |
|
80 | - '54c67bb9e4b0512429885512', |
|
81 | - '54c67bbbe4b07997ea3f3f6b', |
|
82 | - '54d1a33ae4b086c0c0964ce9', |
|
83 | - '57ef253c9033602e61d4a563', |
|
84 | - '552355bfe4b0221aadf2572b', |
|
85 | - '54c67bcde4b051242988553e', |
|
86 | - ); |
|
78 | + '57ef23539033602e61d4a560', |
|
79 | + '54c67bb9e4b0512429885513', |
|
80 | + '54c67bb9e4b0512429885512', |
|
81 | + '54c67bbbe4b07997ea3f3f6b', |
|
82 | + '54d1a33ae4b086c0c0964ce9', |
|
83 | + '57ef253c9033602e61d4a563', |
|
84 | + '552355bfe4b0221aadf2572b', |
|
85 | + '54c67bcde4b051242988553e', |
|
86 | + ); |
|
87 | 87 | |
88 | 88 | return $localization_data; |
89 | 89 | } |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | |
230 | 230 | if( 'form_list' === GFForms::get_page() ) { |
231 | 231 | $priority = 790; |
232 | - } |
|
232 | + } |
|
233 | 233 | |
234 | 234 | if( empty( $connected_views ) ) { |
235 | 235 | |
236 | - $menu_items['gravityview'] = array( |
|
236 | + $menu_items['gravityview'] = array( |
|
237 | 237 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
238 | 238 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', // Only appears in GF pre-2.5 |
239 | 239 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -265,13 +265,13 @@ discard block |
||
265 | 265 | // If there were no items added, then let's create the parent menu |
266 | 266 | if( $sub_menu_items ) { |
267 | 267 | |
268 | - $sub_menu_items[] = array( |
|
269 | - 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
270 | - 'icon' => '<span class="dashicons dashicons-plus"></span>', |
|
271 | - 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
272 | - 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
273 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
274 | - ); |
|
268 | + $sub_menu_items[] = array( |
|
269 | + 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
270 | + 'icon' => '<span class="dashicons dashicons-plus"></span>', |
|
271 | + 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
272 | + 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
273 | + 'capabilities' => array( 'edit_gravityviews' ), |
|
274 | + ); |
|
275 | 275 | |
276 | 276 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
277 | 277 | $sub_menu_items[] = array( |
@@ -668,16 +668,16 @@ discard block |
||
668 | 668 | /** |
669 | 669 | * Render html for displaying available fields based on a Form ID |
670 | 670 | * |
671 | - * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
671 | + * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
672 | 672 | * |
673 | 673 | * @param int $form Gravity Forms Form ID (default: '') |
674 | 674 | * @param string $context (default: 'single') |
675 | - * |
|
675 | + * |
|
676 | 676 | * @return void |
677 | 677 | */ |
678 | 678 | function render_available_fields( $form = 0, $context = 'single' ) { |
679 | 679 | |
680 | - // Determine if form is a preset and convert it to an array with fields |
|
680 | + // Determine if form is a preset and convert it to an array with fields |
|
681 | 681 | $form = ( is_string( $form ) && preg_match( '/^preset_/', $form ) ) ? GravityView_Ajax::pre_get_form_fields( $form ) : $form; |
682 | 682 | |
683 | 683 | /** |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | |
696 | 696 | if ( ! is_array( $blocklist_field_types ) ) { |
697 | 697 | |
698 | - gravityview()->log->error( '$blocklist_field_types is not an array', array( 'data' => print_r( $blocklist_field_types, true ) ) ); |
|
698 | + gravityview()->log->error( '$blocklist_field_types is not an array', array( 'data' => print_r( $blocklist_field_types, true ) ) ); |
|
699 | 699 | |
700 | 700 | $blocklist_field_types = array(); |
701 | 701 | } |
@@ -953,9 +953,9 @@ discard block |
||
953 | 953 | |
954 | 954 | $joined_forms = gravityview_get_joined_forms( $post->ID ); |
955 | 955 | |
956 | - foreach ( $joined_forms as $form ) { |
|
957 | - $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
958 | - } |
|
956 | + foreach ( $joined_forms as $form ) { |
|
957 | + $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
958 | + } |
|
959 | 959 | } else { |
960 | 960 | $available_items[ $form ] = \GV\Widget::registered(); |
961 | 961 | } |
@@ -994,9 +994,9 @@ discard block |
||
994 | 994 | |
995 | 995 | if ( $form_id ) { |
996 | 996 | $original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ; |
997 | - } else { |
|
997 | + } else { |
|
998 | 998 | $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
999 | - } |
|
999 | + } |
|
1000 | 1000 | |
1001 | 1001 | if ( !$original_item ) { |
1002 | 1002 | gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array(' data' => array('available_items' => $available_items, 'field' => $field ) ) ); |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | } |
1247 | 1247 | |
1248 | 1248 | // Add the GV font (with the Astronaut) |
1249 | - wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
1249 | + wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
1250 | 1250 | wp_register_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), \GV\Plugin::$version ); |
1251 | 1251 | |
1252 | 1252 | wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), \GV\Plugin::$version, true ); |
@@ -1254,46 +1254,46 @@ discard block |
||
1254 | 1254 | if( GFForms::get_page() === 'form_list' ) { |
1255 | 1255 | wp_enqueue_style( 'gravityview_views_styles' ); |
1256 | 1256 | return; |
1257 | - } |
|
1257 | + } |
|
1258 | 1258 | |
1259 | 1259 | // Don't process any scripts below here if it's not a GravityView page. |
1260 | 1260 | if( ! gravityview()->request->is_admin( $hook, 'single' ) && ! $is_widgets_page ) { |
1261 | - return; |
|
1261 | + return; |
|
1262 | 1262 | } |
1263 | 1263 | |
1264 | 1264 | wp_enqueue_code_editor( array( 'type' => 'text/html' ) ); |
1265 | 1265 | |
1266 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1267 | - |
|
1268 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
1269 | - |
|
1270 | - // Enqueue scripts |
|
1271 | - wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version ); |
|
1272 | - |
|
1273 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1274 | - 'cookiepath' => COOKIEPATH, |
|
1275 | - 'admin_cookiepath' => ADMIN_COOKIE_PATH, |
|
1276 | - 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1277 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1278 | - 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1279 | - 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
|
1280 | - 'label_add_search_field' => __( 'Add Search Field', 'gravityview' ), |
|
1281 | - 'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ), |
|
1282 | - 'label_close' => __( 'Close', 'gravityview' ), |
|
1283 | - 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1284 | - 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1285 | - 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1286 | - 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1287 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1288 | - 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1289 | - 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1290 | - 'remove_all_fields' => __( 'Would you like to remove all fields in this zone?', 'gravityview' ), |
|
1291 | - )); |
|
1266 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1267 | + |
|
1268 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
1269 | + |
|
1270 | + // Enqueue scripts |
|
1271 | + wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version ); |
|
1272 | + |
|
1273 | + wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1274 | + 'cookiepath' => COOKIEPATH, |
|
1275 | + 'admin_cookiepath' => ADMIN_COOKIE_PATH, |
|
1276 | + 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1277 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1278 | + 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1279 | + 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
|
1280 | + 'label_add_search_field' => __( 'Add Search Field', 'gravityview' ), |
|
1281 | + 'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ), |
|
1282 | + 'label_close' => __( 'Close', 'gravityview' ), |
|
1283 | + 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1284 | + 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1285 | + 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1286 | + 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1287 | + 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1288 | + 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1289 | + 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1290 | + 'remove_all_fields' => __( 'Would you like to remove all fields in this zone?', 'gravityview' ), |
|
1291 | + )); |
|
1292 | 1292 | |
1293 | 1293 | wp_enqueue_style( 'gravityview_views_styles' ); |
1294 | 1294 | |
1295 | - // Enqueue scripts needed for merge tags |
|
1296 | - self::enqueue_gravity_forms_scripts(); |
|
1295 | + // Enqueue scripts needed for merge tags |
|
1296 | + self::enqueue_gravity_forms_scripts(); |
|
1297 | 1297 | |
1298 | 1298 | // 2.5 changed how Merge Tags are enqueued |
1299 | 1299 | if ( is_callable( array( 'GFCommon', 'output_hooks_javascript') ) ) { |
@@ -1303,24 +1303,24 @@ discard block |
||
1303 | 1303 | |
1304 | 1304 | /** |
1305 | 1305 | * Enqueue Gravity Forms scripts, needed for Merge Tags |
1306 | - * |
|
1307 | - * @since 1.0.5-beta |
|
1308 | - * |
|
1309 | - * @return void |
|
1306 | + * |
|
1307 | + * @since 1.0.5-beta |
|
1308 | + * |
|
1309 | + * @return void |
|
1310 | 1310 | */ |
1311 | 1311 | static function enqueue_gravity_forms_scripts() { |
1312 | 1312 | GFForms::register_scripts(); |
1313 | 1313 | |
1314 | 1314 | $scripts = array( |
1315 | - 'sack', |
|
1316 | - 'gform_gravityforms', |
|
1317 | - 'gform_forms', |
|
1318 | - 'gform_form_admin', |
|
1319 | - 'jquery-ui-autocomplete' |
|
1315 | + 'sack', |
|
1316 | + 'gform_gravityforms', |
|
1317 | + 'gform_forms', |
|
1318 | + 'gform_form_admin', |
|
1319 | + 'jquery-ui-autocomplete' |
|
1320 | 1320 | ); |
1321 | 1321 | |
1322 | 1322 | if ( wp_is_mobile() ) { |
1323 | - $scripts[] = 'jquery-touch-punch'; |
|
1323 | + $scripts[] = 'jquery-touch-punch'; |
|
1324 | 1324 | } |
1325 | 1325 | |
1326 | 1326 | wp_enqueue_script( $scripts ); |
@@ -27,34 +27,34 @@ discard block |
||
27 | 27 | add_filter( 'gravityview_blocklist_field_types', array( $this, 'default_field_blocklist' ), 10, 2 ); |
28 | 28 | |
29 | 29 | // Tooltips |
30 | - add_filter( 'gform_tooltips', array( $this, 'tooltips') ); |
|
30 | + add_filter( 'gform_tooltips', array( $this, 'tooltips' ) ); |
|
31 | 31 | |
32 | 32 | add_filter( 'admin_body_class', array( $this, 'add_gf_version_css_class' ) ); |
33 | 33 | |
34 | 34 | // adding styles and scripts |
35 | - add_action( 'admin_enqueue_scripts', array( 'GravityView_Admin_Views', 'add_scripts_and_styles'), 999 ); |
|
36 | - add_filter( 'gform_noconflict_styles', array( $this, 'register_no_conflict') ); |
|
37 | - add_filter( 'gform_noconflict_scripts', array( $this, 'register_no_conflict') ); |
|
38 | - add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict') ); |
|
39 | - add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict') ); |
|
40 | - |
|
41 | - add_action( 'gravityview_render_directory_active_areas', array( $this, 'render_directory_active_areas'), 10, 4 ); |
|
42 | - add_action( 'gravityview_render_widgets_active_areas', array( $this, 'render_widgets_active_areas'), 10, 3 ); |
|
43 | - add_action( 'gravityview_render_field_pickers', array( $this, 'render_field_pickers'), 10, 2 ); |
|
44 | - add_action( 'gravityview_render_available_fields', array( $this, 'render_available_fields'), 10, 2 ); |
|
45 | - add_action( 'gravityview_render_available_widgets', array( $this, 'render_available_widgets') ); |
|
46 | - add_action( 'gravityview_render_active_areas', array( $this, 'render_active_areas'), 10, 5 ); |
|
35 | + add_action( 'admin_enqueue_scripts', array( 'GravityView_Admin_Views', 'add_scripts_and_styles' ), 999 ); |
|
36 | + add_filter( 'gform_noconflict_styles', array( $this, 'register_no_conflict' ) ); |
|
37 | + add_filter( 'gform_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
|
38 | + add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict' ) ); |
|
39 | + add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
|
40 | + |
|
41 | + add_action( 'gravityview_render_directory_active_areas', array( $this, 'render_directory_active_areas' ), 10, 4 ); |
|
42 | + add_action( 'gravityview_render_widgets_active_areas', array( $this, 'render_widgets_active_areas' ), 10, 3 ); |
|
43 | + add_action( 'gravityview_render_field_pickers', array( $this, 'render_field_pickers' ), 10, 2 ); |
|
44 | + add_action( 'gravityview_render_available_fields', array( $this, 'render_available_fields' ), 10, 2 ); |
|
45 | + add_action( 'gravityview_render_available_widgets', array( $this, 'render_available_widgets' ) ); |
|
46 | + add_action( 'gravityview_render_active_areas', array( $this, 'render_active_areas' ), 10, 5 ); |
|
47 | 47 | |
48 | 48 | // @todo check if this hook is needed.. |
49 | 49 | //add_action( 'gravityview_render_field_options', array( $this, 'render_field_options'), 10, 9 ); |
50 | 50 | |
51 | 51 | // Add Connected Form column |
52 | - add_filter('manage_gravityview_posts_columns' , array( $this, 'add_post_type_columns' ) ); |
|
52 | + add_filter( 'manage_gravityview_posts_columns', array( $this, 'add_post_type_columns' ) ); |
|
53 | 53 | |
54 | 54 | add_filter( 'gform_toolbar_menu', array( 'GravityView_Admin_Views', 'gform_toolbar_menu' ), 10, 2 ); |
55 | 55 | add_action( 'gform_form_actions', array( 'GravityView_Admin_Views', 'gform_toolbar_menu' ), 10, 2 ); |
56 | 56 | |
57 | - add_action( 'manage_gravityview_posts_custom_column', array( $this, 'add_custom_column_content'), 10, 2 ); |
|
57 | + add_action( 'manage_gravityview_posts_custom_column', array( $this, 'add_custom_column_content' ), 10, 2 ); |
|
58 | 58 | |
59 | 59 | add_action( 'restrict_manage_posts', array( $this, 'add_view_dropdown' ) ); |
60 | 60 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $major_version = explode( '.', GFForms::$version ); |
87 | 87 | |
88 | 88 | if ( 2 <= sizeof( $major_version ) ) { |
89 | - $class .= ' gf-minor-version-' . esc_attr( $major_version[0] . '-' . $major_version[1] ); |
|
89 | + $class .= ' gf-minor-version-' . esc_attr( $major_version[ 0 ] . '-' . $major_version[ 1 ] ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | return $class; |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function suggest_support_articles( $localization_data = array() ) { |
103 | 103 | |
104 | - if( ! gravityview()->request->is_view() ) { |
|
104 | + if ( ! gravityview()->request->is_view() ) { |
|
105 | 105 | return $localization_data; |
106 | 106 | } |
107 | 107 | |
108 | - $localization_data['suggest'] = array( |
|
108 | + $localization_data[ 'suggest' ] = array( |
|
109 | 109 | '57ef23539033602e61d4a560', |
110 | 110 | '54c67bb9e4b0512429885513', |
111 | 111 | '54c67bb9e4b0512429885512', |
@@ -134,20 +134,20 @@ discard block |
||
134 | 134 | return; |
135 | 135 | } |
136 | 136 | |
137 | - if ( ! isset( $query->query_vars['post_type'] ) ) { |
|
137 | + if ( ! isset( $query->query_vars[ 'post_type' ] ) ) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | 140 | |
141 | - if ( 'gravityview' !== $query->query_vars['post_type'] ) { |
|
141 | + if ( 'gravityview' !== $query->query_vars[ 'post_type' ] ) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | - $form_id = (int) \GV\Utils::_GET( 'gravityview_form_id' ); |
|
145 | + $form_id = (int)\GV\Utils::_GET( 'gravityview_form_id' ); |
|
146 | 146 | |
147 | 147 | $meta_query = array(); |
148 | 148 | |
149 | 149 | if ( $form_id ) { |
150 | - $meta_query[] = array( |
|
150 | + $meta_query[ ] = array( |
|
151 | 151 | 'key' => '_gravityview_form_id', |
152 | 152 | 'value' => $form_id, |
153 | 153 | ); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $layout_id = \GV\Utils::_GET( 'gravityview_layout' ); |
157 | 157 | |
158 | 158 | if ( $layout_id ) { |
159 | - $meta_query[] = array( |
|
159 | + $meta_query[ ] = array( |
|
160 | 160 | 'key' => '_gravityview_directory_template', |
161 | 161 | 'value' => esc_attr( $layout_id ), |
162 | 162 | ); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | public function add_view_dropdown() { |
174 | 174 | $current_screen = get_current_screen(); |
175 | 175 | |
176 | - if( 'gravityview' !== $current_screen->post_type ) { |
|
176 | + if ( 'gravityview' !== $current_screen->post_type ) { |
|
177 | 177 | return; |
178 | 178 | } |
179 | 179 | |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | $current_form = \GV\Utils::_GET( 'gravityview_form_id' ); |
182 | 182 | |
183 | 183 | // If there are no forms to select, show no forms. |
184 | - if( ! empty( $forms ) ) { ?> |
|
184 | + if ( ! empty( $forms ) ) { ?> |
|
185 | 185 | <label for="gravityview_form_id" class="screen-reader-text"><?php esc_html_e( 'Filter Views by form', 'gravityview' ); ?></label> |
186 | 186 | <select name="gravityview_form_id" id="gravityview_form_id"> |
187 | 187 | <option value="" <?php selected( '', $current_form, true ); ?>><?php esc_html_e( 'All forms', 'gravityview' ); ?></option> |
188 | - <?php foreach( $forms as $form ) { ?> |
|
189 | - <option value="<?php echo esc_attr( $form['id'] ); ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option> |
|
188 | + <?php foreach ( $forms as $form ) { ?> |
|
189 | + <option value="<?php echo esc_attr( $form[ 'id' ] ); ?>" <?php selected( $form[ 'id' ], $current_form, true ); ?>><?php echo esc_html( $form[ 'title' ] ); ?></option> |
|
190 | 190 | <?php } ?> |
191 | 191 | </select> |
192 | 192 | <?php } |
@@ -195,26 +195,26 @@ discard block |
||
195 | 195 | $current_layout = \GV\Utils::_GET( 'gravityview_layout' ); |
196 | 196 | |
197 | 197 | // If there are no forms to select, show no forms. |
198 | - if( ! empty( $layouts ) ) { ?> |
|
198 | + if ( ! empty( $layouts ) ) { ?> |
|
199 | 199 | <label for="gravityview_layout_name" class="screen-reader-text"><?php esc_html_e( 'Filter Views by layout', 'gravityview' ); ?></label> |
200 | 200 | <select name="gravityview_layout" id="gravityview_layout_name"> |
201 | 201 | <option value="" <?php selected( '', $current_layout, true ); ?>><?php esc_html_e( 'All layouts', 'gravityview' ); ?></option> |
202 | 202 | <optgroup label="<?php esc_html_e( 'Layouts', 'gravityview' ); ?>"> |
203 | - <?php foreach( $layouts as $layout_id => $layout ) { |
|
204 | - if ( in_array( $layout['type'], array( 'preset', 'internal' ), true ) ) { |
|
203 | + <?php foreach ( $layouts as $layout_id => $layout ) { |
|
204 | + if ( in_array( $layout[ 'type' ], array( 'preset', 'internal' ), true ) ) { |
|
205 | 205 | continue; |
206 | 206 | } |
207 | 207 | ?> |
208 | - <option value="<?php echo esc_attr( $layout_id ); ?>" <?php selected( $layout_id, $current_layout, true ); ?>><?php echo esc_html( $layout['label'] ); ?></option> |
|
208 | + <option value="<?php echo esc_attr( $layout_id ); ?>" <?php selected( $layout_id, $current_layout, true ); ?>><?php echo esc_html( $layout[ 'label' ] ); ?></option> |
|
209 | 209 | <?php } ?> |
210 | 210 | </optgroup> |
211 | 211 | <optgroup label="<?php esc_html_e( 'Form Presets', 'gravityview' ); ?>"> |
212 | - <?php foreach( $layouts as $layout_id => $layout ) { |
|
213 | - if ( ! in_array( $layout['type'], array( 'preset' ), true ) ) { |
|
212 | + <?php foreach ( $layouts as $layout_id => $layout ) { |
|
213 | + if ( ! in_array( $layout[ 'type' ], array( 'preset' ), true ) ) { |
|
214 | 214 | continue; |
215 | 215 | } |
216 | 216 | ?> |
217 | - <option value="<?php echo esc_attr( $layout_id ); ?>" <?php selected( $layout_id, $current_layout, true ); ?>><?php echo esc_html( $layout['label'] ); ?></option> |
|
217 | + <option value="<?php echo esc_attr( $layout_id ); ?>" <?php selected( $layout_id, $current_layout, true ); ?>><?php echo esc_html( $layout[ 'label' ] ); ?></option> |
|
218 | 218 | <?php } ?> |
219 | 219 | </optgroup> |
220 | 220 | </select> |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public static function render_setting_row( $key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s' ) { |
230 | 230 | _deprecated_function( 'GravityView_Admin_Views::render_setting_row', '1.1.7', 'GravityView_Render_Settings::render_setting_row' ); |
231 | - GravityView_Render_Settings::render_setting_row( $key, $current_settings, $override_input, $name , $id ); |
|
231 | + GravityView_Render_Settings::render_setting_row( $key, $current_settings, $override_input, $name, $id ); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | |
259 | 259 | $priority = 0; |
260 | 260 | |
261 | - if( 'form_list' === GFForms::get_page() ) { |
|
261 | + if ( 'form_list' === GFForms::get_page() ) { |
|
262 | 262 | $priority = 790; |
263 | 263 | } |
264 | 264 | |
265 | - if( empty( $connected_views ) ) { |
|
265 | + if ( empty( $connected_views ) ) { |
|
266 | 266 | |
267 | - $menu_items['gravityview'] = array( |
|
267 | + $menu_items[ 'gravityview' ] = array( |
|
268 | 268 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
269 | 269 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', // Only appears in GF pre-2.5 |
270 | 270 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -280,23 +280,23 @@ discard block |
||
280 | 280 | $sub_menu_items = array(); |
281 | 281 | foreach ( (array)$connected_views as $view ) { |
282 | 282 | |
283 | - if( ! GVCommon::has_cap( 'edit_gravityview', $view->ID ) ) { |
|
283 | + if ( ! GVCommon::has_cap( 'edit_gravityview', $view->ID ) ) { |
|
284 | 284 | continue; |
285 | 285 | } |
286 | 286 | |
287 | - $label = empty( $view->post_title ) ? sprintf( __('No Title (View #%d)', 'gravityview' ), $view->ID ) : $view->post_title; |
|
287 | + $label = empty( $view->post_title ) ? sprintf( __( 'No Title (View #%d)', 'gravityview' ), $view->ID ) : $view->post_title; |
|
288 | 288 | |
289 | - $sub_menu_items[] = array( |
|
289 | + $sub_menu_items[ ] = array( |
|
290 | 290 | 'label' => esc_attr( $label ), |
291 | - 'url' => admin_url( 'post.php?action=edit&post='.$view->ID ), |
|
291 | + 'url' => admin_url( 'post.php?action=edit&post=' . $view->ID ), |
|
292 | 292 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
293 | 293 | ); |
294 | 294 | } |
295 | 295 | |
296 | 296 | // If there were no items added, then let's create the parent menu |
297 | - if( $sub_menu_items ) { |
|
297 | + if ( $sub_menu_items ) { |
|
298 | 298 | |
299 | - $sub_menu_items[] = array( |
|
299 | + $sub_menu_items[ ] = array( |
|
300 | 300 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
301 | 301 | 'icon' => '<span class="dashicons dashicons-plus"></span>', |
302 | 302 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | ); |
306 | 306 | |
307 | 307 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
308 | - $sub_menu_items[] = array( |
|
308 | + $sub_menu_items[ ] = array( |
|
309 | 309 | 'url' => '#', |
310 | 310 | 'label' => '', |
311 | 311 | 'menu_class' => 'hidden', |
312 | 312 | 'capabilities' => '', |
313 | 313 | ); |
314 | 314 | |
315 | - $menu_items['gravityview'] = array( |
|
315 | + $menu_items[ 'gravityview' ] = array( |
|
316 | 316 | 'label' => __( 'Connected Views', 'gravityview' ), |
317 | 317 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
318 | 318 | 'title' => __( 'GravityView Views using this form as a data source', 'gravityview' ), |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | $add = array( 'captcha', 'page' ); |
344 | 344 | |
345 | 345 | // Don't allowing editing the following values: |
346 | - if( $context === 'edit' ) { |
|
347 | - $add[] = 'post_id'; |
|
346 | + if ( $context === 'edit' ) { |
|
347 | + $add[ ] = 'post_id'; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | $return = array_merge( $array, $add ); |
@@ -375,27 +375,27 @@ discard block |
||
375 | 375 | foreach ( $default_args as $key => $arg ) { |
376 | 376 | |
377 | 377 | // If an arg has `tooltip` defined, but it's false, don't display a tooltip |
378 | - if( isset( $arg['tooltip'] ) && empty( $arg['tooltip'] ) ) { continue; } |
|
378 | + if ( isset( $arg[ 'tooltip' ] ) && empty( $arg[ 'tooltip' ] ) ) { continue; } |
|
379 | 379 | |
380 | 380 | // By default, use `tooltip` if defined. |
381 | - $tooltip = empty( $arg['tooltip'] ) ? NULL : $arg['tooltip']; |
|
381 | + $tooltip = empty( $arg[ 'tooltip' ] ) ? NULL : $arg[ 'tooltip' ]; |
|
382 | 382 | |
383 | 383 | // If there's no tooltip set, continue |
384 | - if( empty( $tooltip ) ) { |
|
384 | + if ( empty( $tooltip ) ) { |
|
385 | 385 | continue; |
386 | 386 | } |
387 | 387 | |
388 | 388 | // Add the tooltip |
389 | - $gv_tooltips[ 'gv_'.$key ] = array( |
|
390 | - 'title' => $arg['label'], |
|
389 | + $gv_tooltips[ 'gv_' . $key ] = array( |
|
390 | + 'title' => $arg[ 'label' ], |
|
391 | 391 | 'value' => $tooltip, |
392 | 392 | ); |
393 | 393 | |
394 | 394 | } |
395 | 395 | |
396 | - $gv_tooltips['gv_css_merge_tags'] = array( |
|
397 | - 'title' => __('CSS Merge Tags', 'gravityview'), |
|
398 | - 'value' => sprintf( __( 'Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview'), '<code>', '</code>' ) |
|
396 | + $gv_tooltips[ 'gv_css_merge_tags' ] = array( |
|
397 | + 'title' => __( 'CSS Merge Tags', 'gravityview' ), |
|
398 | + 'value' => sprintf( __( 'Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview' ), '<code>', '</code>' ) |
|
399 | 399 | ); |
400 | 400 | |
401 | 401 | /** |
@@ -413,9 +413,9 @@ discard block |
||
413 | 413 | |
414 | 414 | foreach ( $gv_tooltips as $key => $tooltip ) { |
415 | 415 | |
416 | - $title = empty( $tooltip['title'] ) ? '' : '<h6>'.esc_html( $tooltip['title'] ) .'</h6>'; |
|
416 | + $title = empty( $tooltip[ 'title' ] ) ? '' : '<h6>' . esc_html( $tooltip[ 'title' ] ) . '</h6>'; |
|
417 | 417 | |
418 | - $tooltips[ $key ] = $title . wpautop( esc_html( $tooltip['value'] ) ); |
|
418 | + $tooltips[ $key ] = $title . wpautop( esc_html( $tooltip[ 'value' ] ) ); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | return $tooltips; |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * |
430 | 430 | * @return void |
431 | 431 | */ |
432 | - public function add_custom_column_content( $column_name = null, $post_id = 0 ) { |
|
432 | + public function add_custom_column_content( $column_name = null, $post_id = 0 ) { |
|
433 | 433 | |
434 | 434 | $output = ''; |
435 | 435 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | // Generate backup if label doesn't exist: `example_name` => `Example Name` |
452 | 452 | $template_id_pretty = ucwords( implode( ' ', explode( '_', $template_id ) ) ); |
453 | 453 | |
454 | - $output = $template ? $template['label'] : $template_id_pretty; |
|
454 | + $output = $template ? $template[ 'label' ] : $template_id_pretty; |
|
455 | 455 | |
456 | 456 | break; |
457 | 457 | |
@@ -492,12 +492,12 @@ discard block |
||
492 | 492 | static public function get_connected_form_links( $form, $include_form_link = true ) { |
493 | 493 | |
494 | 494 | // Either the form is empty or the form ID is 0, not yet set. |
495 | - if( empty( $form ) ) { |
|
495 | + if ( empty( $form ) ) { |
|
496 | 496 | return ''; |
497 | 497 | } |
498 | 498 | |
499 | 499 | // The $form is passed as the form ID |
500 | - if( !is_array( $form ) ) { |
|
500 | + if ( ! is_array( $form ) ) { |
|
501 | 501 | $form = gravityview_get_form( $form ); |
502 | 502 | } |
503 | 503 | |
@@ -505,35 +505,35 @@ discard block |
||
505 | 505 | return ''; |
506 | 506 | } |
507 | 507 | |
508 | - $form_id = $form['id']; |
|
508 | + $form_id = $form[ 'id' ]; |
|
509 | 509 | $links = array(); |
510 | 510 | |
511 | - if( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) { |
|
511 | + if ( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) { |
|
512 | 512 | $form_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&id=%d', $form_id ) ); |
513 | - $form_link = '<strong class="gv-form-title">'.gravityview_get_link( $form_url, $form['title'], 'class=row-title' ).'</strong>'; |
|
514 | - $links[] = '<span>'.gravityview_get_link( $form_url, __('Edit Form', 'gravityview') ).'</span>'; |
|
513 | + $form_link = '<strong class="gv-form-title">' . gravityview_get_link( $form_url, $form[ 'title' ], 'class=row-title' ) . '</strong>'; |
|
514 | + $links[ ] = '<span>' . gravityview_get_link( $form_url, __( 'Edit Form', 'gravityview' ) ) . '</span>'; |
|
515 | 515 | } else { |
516 | - $form_link = '<strong class="gv-form-title">'. esc_html( $form['title'] ). '</strong>'; |
|
516 | + $form_link = '<strong class="gv-form-title">' . esc_html( $form[ 'title' ] ) . '</strong>'; |
|
517 | 517 | } |
518 | 518 | |
519 | - if( GVCommon::has_cap( 'gravityforms_view_entries' ) ) { |
|
519 | + if ( GVCommon::has_cap( 'gravityforms_view_entries' ) ) { |
|
520 | 520 | $entries_url = admin_url( sprintf( 'admin.php?page=gf_entries&id=%d', $form_id ) ); |
521 | - $links[] = '<span>'.gravityview_get_link( $entries_url, __('Entries', 'gravityview') ).'</span>'; |
|
521 | + $links[ ] = '<span>' . gravityview_get_link( $entries_url, __( 'Entries', 'gravityview' ) ) . '</span>'; |
|
522 | 522 | } |
523 | 523 | |
524 | - if( GVCommon::has_cap( array( 'gravityforms_edit_settings', 'gravityview_view_settings' ) ) ) { |
|
524 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_settings', 'gravityview_view_settings' ) ) ) { |
|
525 | 525 | $settings_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&view=settings&id=%d', $form_id ) ); |
526 | - $links[] = '<span>'.gravityview_get_link( $settings_url, __('Settings', 'gravityview'), 'title='.__('Edit settings for this form', 'gravityview') ).'</span>'; |
|
526 | + $links[ ] = '<span>' . gravityview_get_link( $settings_url, __( 'Settings', 'gravityview' ), 'title=' . __( 'Edit settings for this form', 'gravityview' ) ) . '</span>'; |
|
527 | 527 | } |
528 | 528 | |
529 | - if( GVCommon::has_cap( array("gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms") ) ) { |
|
529 | + if ( GVCommon::has_cap( array( "gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms" ) ) ) { |
|
530 | 530 | $preview_url = site_url( sprintf( '?gf_page=preview&id=%d', $form_id ) ); |
531 | - $links[] = '<span>'.gravityview_get_link( $preview_url, __('Preview Form', 'gravityview'), 'title='.__('Preview this form', 'gravityview') ).'</span>'; |
|
531 | + $links[ ] = '<span>' . gravityview_get_link( $preview_url, __( 'Preview Form', 'gravityview' ), 'title=' . __( 'Preview this form', 'gravityview' ) ) . '</span>'; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | $output = ''; |
535 | 535 | |
536 | - if( !empty( $include_form_link ) ) { |
|
536 | + if ( ! empty( $include_form_link ) ) { |
|
537 | 537 | $output .= $form_link; |
538 | 538 | } |
539 | 539 | |
@@ -548,11 +548,11 @@ discard block |
||
548 | 548 | $css_class = 'row-actions'; |
549 | 549 | |
550 | 550 | // Is Screen Options > View mode set to "Extended view"? If so, keep actions visible. |
551 | - if( 'excerpt' === get_user_setting( 'posts_list_mode', 'list' ) ) { |
|
551 | + if ( 'excerpt' === get_user_setting( 'posts_list_mode', 'list' ) ) { |
|
552 | 552 | $css_class = 'row-actions visible'; |
553 | 553 | } |
554 | 554 | |
555 | - $output .= '<div class="' . $css_class . '">'. implode( ' | ', $links ) .'</div>'; |
|
555 | + $output .= '<div class="' . $css_class . '">' . implode( ' | ', $links ) . '</div>'; |
|
556 | 556 | |
557 | 557 | return $output; |
558 | 558 | } |
@@ -566,8 +566,8 @@ discard block |
||
566 | 566 | // Get the date column and save it for later to add back in. |
567 | 567 | // This adds it after the Data Source column. |
568 | 568 | // This way, we don't need to do array_slice, array_merge, etc. |
569 | - $date = $columns['date']; |
|
570 | - unset( $columns['date'] ); |
|
569 | + $date = $columns[ 'date' ]; |
|
570 | + unset( $columns[ 'date' ] ); |
|
571 | 571 | |
572 | 572 | $data_source_required_caps = array( |
573 | 573 | 'gravityforms_edit_forms', |
@@ -578,14 +578,14 @@ discard block |
||
578 | 578 | 'gravityforms_preview_forms', |
579 | 579 | ); |
580 | 580 | |
581 | - if( GVCommon::has_cap( $data_source_required_caps ) ) { |
|
582 | - $columns['gv_connected_form'] = __( 'Data Source', 'gravityview' ); |
|
581 | + if ( GVCommon::has_cap( $data_source_required_caps ) ) { |
|
582 | + $columns[ 'gv_connected_form' ] = __( 'Data Source', 'gravityview' ); |
|
583 | 583 | } |
584 | 584 | |
585 | - $columns['gv_template'] = _x( 'Template', 'Column title that shows what template is being used for Views', 'gravityview' ); |
|
585 | + $columns[ 'gv_template' ] = _x( 'Template', 'Column title that shows what template is being used for Views', 'gravityview' ); |
|
586 | 586 | |
587 | 587 | // Add the date back in. |
588 | - $columns['date'] = $date; |
|
588 | + $columns[ 'date' ] = $date; |
|
589 | 589 | |
590 | 590 | return $columns; |
591 | 591 | } |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | */ |
599 | 599 | function save_postdata( $post_id ) { |
600 | 600 | |
601 | - if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){ |
|
601 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
602 | 602 | return; |
603 | 603 | } |
604 | 604 | |
605 | 605 | // validate post_type |
606 | - if ( ! isset( $_POST['post_type'] ) || 'gravityview' != $_POST['post_type'] ) { |
|
606 | + if ( ! isset( $_POST[ 'post_type' ] ) || 'gravityview' != $_POST[ 'post_type' ] ) { |
|
607 | 607 | return; |
608 | 608 | } |
609 | 609 | |
@@ -618,63 +618,63 @@ discard block |
||
618 | 618 | $statii = array(); |
619 | 619 | |
620 | 620 | // check if this is a start fresh View |
621 | - if ( isset( $_POST['gravityview_select_form_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_form_nonce'], 'gravityview_select_form' ) ) { |
|
621 | + if ( isset( $_POST[ 'gravityview_select_form_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_select_form_nonce' ], 'gravityview_select_form' ) ) { |
|
622 | 622 | |
623 | - $form_id = !empty( $_POST['gravityview_form_id'] ) ? $_POST['gravityview_form_id'] : ''; |
|
623 | + $form_id = ! empty( $_POST[ 'gravityview_form_id' ] ) ? $_POST[ 'gravityview_form_id' ] : ''; |
|
624 | 624 | // save form id |
625 | - $statii['form_id'] = update_post_meta( $post_id, '_gravityview_form_id', $form_id ); |
|
625 | + $statii[ 'form_id' ] = update_post_meta( $post_id, '_gravityview_form_id', $form_id ); |
|
626 | 626 | |
627 | 627 | } |
628 | 628 | |
629 | - if( false === GVCommon::has_cap( 'gravityforms_create_form' ) && empty( $statii['form_id'] ) ) { |
|
629 | + if ( false === GVCommon::has_cap( 'gravityforms_create_form' ) && empty( $statii[ 'form_id' ] ) ) { |
|
630 | 630 | gravityview()->log->error( 'Current user does not have the capability to create a new Form.', array( 'data' => wp_get_current_user() ) ); |
631 | 631 | return; |
632 | 632 | } |
633 | 633 | |
634 | 634 | // Was this a start fresh? |
635 | - if ( ! empty( $_POST['gravityview_form_id_start_fresh'] ) ) { |
|
636 | - $statii['start_fresh'] = add_post_meta( $post_id, '_gravityview_start_fresh', 1 ); |
|
635 | + if ( ! empty( $_POST[ 'gravityview_form_id_start_fresh' ] ) ) { |
|
636 | + $statii[ 'start_fresh' ] = add_post_meta( $post_id, '_gravityview_start_fresh', 1 ); |
|
637 | 637 | } else { |
638 | - $statii['start_fresh'] = delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
638 | + $statii[ 'start_fresh' ] = delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | // Check if we have a template id |
642 | - if ( isset( $_POST['gravityview_select_template_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_template_nonce'], 'gravityview_select_template' ) ) { |
|
642 | + if ( isset( $_POST[ 'gravityview_select_template_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_select_template_nonce' ], 'gravityview_select_template' ) ) { |
|
643 | 643 | |
644 | - $template_id = !empty( $_POST['gravityview_directory_template'] ) ? $_POST['gravityview_directory_template'] : ''; |
|
644 | + $template_id = ! empty( $_POST[ 'gravityview_directory_template' ] ) ? $_POST[ 'gravityview_directory_template' ] : ''; |
|
645 | 645 | |
646 | 646 | // now save template id |
647 | - $statii['directory_template'] = update_post_meta( $post_id, '_gravityview_directory_template', $template_id ); |
|
647 | + $statii[ 'directory_template' ] = update_post_meta( $post_id, '_gravityview_directory_template', $template_id ); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | |
651 | 651 | // save View Configuration metabox |
652 | - if ( isset( $_POST['gravityview_view_configuration_nonce'] ) && wp_verify_nonce( $_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration' ) ) { |
|
652 | + if ( isset( $_POST[ 'gravityview_view_configuration_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_view_configuration_nonce' ], 'gravityview_view_configuration' ) ) { |
|
653 | 653 | |
654 | 654 | // template settings |
655 | - if( empty( $_POST['template_settings'] ) ) { |
|
656 | - $_POST['template_settings'] = array(); |
|
655 | + if ( empty( $_POST[ 'template_settings' ] ) ) { |
|
656 | + $_POST[ 'template_settings' ] = array(); |
|
657 | 657 | } |
658 | - $statii['template_settings'] = update_post_meta( $post_id, '_gravityview_template_settings', $_POST['template_settings'] ); |
|
658 | + $statii[ 'template_settings' ] = update_post_meta( $post_id, '_gravityview_template_settings', $_POST[ 'template_settings' ] ); |
|
659 | 659 | |
660 | 660 | // guard against unloaded View configuration page |
661 | - if ( isset( $_POST['gv_fields'] ) && isset( $_POST['gv_fields_done'] ) ) { |
|
661 | + if ( isset( $_POST[ 'gv_fields' ] ) && isset( $_POST[ 'gv_fields_done' ] ) ) { |
|
662 | 662 | $fields = array(); |
663 | 663 | |
664 | - if ( ! empty( $_POST['gv_fields'] ) ) { |
|
664 | + if ( ! empty( $_POST[ 'gv_fields' ] ) ) { |
|
665 | 665 | $fields = _gravityview_process_posted_fields(); |
666 | 666 | } |
667 | 667 | |
668 | 668 | $fields = wp_slash( $fields ); |
669 | 669 | |
670 | - $statii['directory_fields'] = update_post_meta( $post_id, '_gravityview_directory_fields', $fields ); |
|
670 | + $statii[ 'directory_fields' ] = update_post_meta( $post_id, '_gravityview_directory_fields', $fields ); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | // Directory Visible Widgets |
674 | - if( empty( $_POST['widgets'] ) ) { |
|
675 | - $_POST['widgets'] = array(); |
|
674 | + if ( empty( $_POST[ 'widgets' ] ) ) { |
|
675 | + $_POST[ 'widgets' ] = array(); |
|
676 | 676 | } |
677 | - $statii['directory_widgets'] = gravityview_set_directory_widgets( $post_id, $_POST['widgets'] ); |
|
677 | + $statii[ 'directory_widgets' ] = gravityview_set_directory_widgets( $post_id, $_POST[ 'widgets' ] ); |
|
678 | 678 | |
679 | 679 | } // end save view configuration |
680 | 680 | |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | * @param array $statii Array of statuses of the post meta saving processes. If saving worked, each key should be mapped to a value of the post ID (`directory_widgets` => `124`). If failed (or didn't change), the value will be false. |
685 | 685 | * @since 1.17.2 |
686 | 686 | */ |
687 | - do_action('gravityview_view_saved', $post_id, $statii ); |
|
687 | + do_action( 'gravityview_view_saved', $post_id, $statii ); |
|
688 | 688 | |
689 | 689 | gravityview()->log->debug( '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array( 'data' => array_map( 'intval', $statii ) ) ); |
690 | 690 | } |
@@ -735,20 +735,20 @@ discard block |
||
735 | 735 | |
736 | 736 | $output = ''; |
737 | 737 | |
738 | - if( !empty( $fields ) ) { |
|
738 | + if ( ! empty( $fields ) ) { |
|
739 | 739 | |
740 | - foreach( $fields as $id => $details ) { |
|
740 | + foreach ( $fields as $id => $details ) { |
|
741 | 741 | |
742 | - if( in_array( $details['type'], (array) $blocklist_field_types ) ) { |
|
742 | + if ( in_array( $details[ 'type' ], (array)$blocklist_field_types ) ) { |
|
743 | 743 | continue; |
744 | 744 | } |
745 | 745 | |
746 | 746 | // Edit mode only allows editing the parent fields, not single inputs. |
747 | - if( $context === 'edit' && ! empty( $details['parent'] ) ) { |
|
747 | + if ( $context === 'edit' && ! empty( $details[ 'parent' ] ) ) { |
|
748 | 748 | continue; |
749 | 749 | } |
750 | 750 | |
751 | - $output .= new GravityView_Admin_View_Field( $details['label'], $id, $details, array(), $form ); |
|
751 | + $output .= new GravityView_Admin_View_Field( $details[ 'label' ], $id, $details, array(), $form ); |
|
752 | 752 | |
753 | 753 | } // End foreach |
754 | 754 | } |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | echo $output; |
757 | 757 | |
758 | 758 | // For the EDIT view we only want to allow the form fields. |
759 | - if( $context === 'edit' ) { |
|
759 | + if ( $context === 'edit' ) { |
|
760 | 760 | return; |
761 | 761 | } |
762 | 762 | |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | $additional_fields = array( |
776 | 776 | array( |
777 | 777 | 'label_text' => __( 'Add All Form Fields', 'gravityview' ), |
778 | - 'desc' => __('Insert all the form fields at once.', 'gravityview'), |
|
778 | + 'desc' => __( 'Insert all the form fields at once.', 'gravityview' ), |
|
779 | 779 | 'field_id' => 'all-fields', |
780 | 780 | 'label_type' => 'field', |
781 | 781 | 'input_type' => null, |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | */ |
792 | 792 | $additional_fields = apply_filters( 'gravityview_additional_fields', $additional_fields ); |
793 | 793 | |
794 | - foreach ( (array) $additional_fields as $item ) { |
|
794 | + foreach ( (array)$additional_fields as $item ) { |
|
795 | 795 | |
796 | 796 | // Prevent items from not having index set |
797 | 797 | $item = wp_parse_args( $item, array( |
@@ -802,16 +802,16 @@ discard block |
||
802 | 802 | 'field_options' => null, |
803 | 803 | 'settings_html' => null, |
804 | 804 | 'icon' => null, |
805 | - )); |
|
805 | + ) ); |
|
806 | 806 | |
807 | 807 | // Backward compat. |
808 | - if( !empty( $item['field_options'] ) ) { |
|
808 | + if ( ! empty( $item[ 'field_options' ] ) ) { |
|
809 | 809 | // Use settings_html from now on. |
810 | - $item['settings_html'] = $item['field_options']; |
|
810 | + $item[ 'settings_html' ] = $item[ 'field_options' ]; |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | // Render a label for each of them |
814 | - echo new GravityView_Admin_View_Field( $item['label_text'], $item['field_id'], $item, $settings = array(), $form ); |
|
814 | + echo new GravityView_Admin_View_Field( $item[ 'label_text' ], $item[ 'field_id' ], $item, $settings = array(), $form ); |
|
815 | 815 | |
816 | 816 | } |
817 | 817 | |
@@ -823,12 +823,12 @@ discard block |
||
823 | 823 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
824 | 824 | * @return array |
825 | 825 | */ |
826 | - function get_entry_default_fields($form, $zone) { |
|
826 | + function get_entry_default_fields( $form, $zone ) { |
|
827 | 827 | |
828 | 828 | $entry_default_fields = array(); |
829 | 829 | |
830 | 830 | // if in zone directory or single |
831 | - if( in_array( $zone, array( 'directory', 'single' ), true ) ) { |
|
831 | + if ( in_array( $zone, array( 'directory', 'single' ), true ) ) { |
|
832 | 832 | |
833 | 833 | $meta_fields = GravityView_Fields::get_all( array( 'meta', 'gravityview', 'add-ons' ) ); |
834 | 834 | |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | * @param string|array $form form_ID or form object |
846 | 846 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
847 | 847 | */ |
848 | - return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone); |
|
848 | + return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone ); |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | /** |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | */ |
857 | 857 | function get_available_fields( $form = '', $zone = NULL ) { |
858 | 858 | |
859 | - if( empty( $form ) ) { |
|
859 | + if ( empty( $form ) ) { |
|
860 | 860 | gravityview()->log->error( '$form is empty' ); |
861 | 861 | return array(); |
862 | 862 | } |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | $fields = gravityview_get_form_fields( $form, true ); |
866 | 866 | |
867 | 867 | // get meta fields ( only if form was already created ) |
868 | - if( !is_array( $form ) ) { |
|
868 | + if ( ! is_array( $form ) ) { |
|
869 | 869 | $meta_fields = gravityview_get_entry_meta( $form ); |
870 | 870 | } else { |
871 | 871 | $meta_fields = array(); |
@@ -878,8 +878,8 @@ discard block |
||
878 | 878 | $fields = $fields + $meta_fields + $default_fields; |
879 | 879 | |
880 | 880 | // Move Custom Content to top |
881 | - if ( isset( $fields['custom'] ) ) { |
|
882 | - $fields = array( 'custom' => $fields['custom'] ) + $fields; |
|
881 | + if ( isset( $fields[ 'custom' ] ) ) { |
|
882 | + $fields = array( 'custom' => $fields[ 'custom' ] ) + $fields; |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | $gv_fields = GravityView_Fields::get_all(); |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | foreach ( $fields as &$field ) { |
888 | 888 | foreach ( $gv_fields as $gv_field ) { |
889 | 889 | if ( \GV\Utils::get( $field, 'type' ) === $gv_field->name ) { |
890 | - $field['icon'] = \GV\Utils::get( $gv_field, 'icon' ); |
|
890 | + $field[ 'icon' ] = \GV\Utils::get( $gv_field, 'icon' ); |
|
891 | 891 | } |
892 | 892 | } |
893 | 893 | } |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | } |
916 | 916 | |
917 | 917 | foreach ( $widgets as $id => $details ) { |
918 | - echo new GravityView_Admin_View_Widget( $details['label'], $id, $details ); |
|
918 | + echo new GravityView_Admin_View_Widget( $details[ 'label' ], $id, $details ); |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | } |
@@ -945,7 +945,7 @@ discard block |
||
945 | 945 | function render_active_areas( $template_id, $type, $zone, $rows, $values ) { |
946 | 946 | global $post; |
947 | 947 | |
948 | - if( $type === 'widget' ) { |
|
948 | + if ( $type === 'widget' ) { |
|
949 | 949 | $button_label = __( 'Add Widget', 'gravityview' ); |
950 | 950 | } else { |
951 | 951 | $button_label = __( 'Add Field', 'gravityview' ); |
@@ -971,10 +971,10 @@ discard block |
||
971 | 971 | $form_id = null; |
972 | 972 | |
973 | 973 | // if saved values, get available fields to label everyone |
974 | - if( !empty( $values ) && ( !empty( $post->ID ) || !empty( $_POST['template_id'] ) ) ) { |
|
974 | + if ( ! empty( $values ) && ( ! empty( $post->ID ) || ! empty( $_POST[ 'template_id' ] ) ) ) { |
|
975 | 975 | |
976 | - if( !empty( $_POST['template_id'] ) ) { |
|
977 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
976 | + if ( ! empty( $_POST[ 'template_id' ] ) ) { |
|
977 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
978 | 978 | } else { |
979 | 979 | $form_id = $form = gravityview_get_form_id( $post->ID ); |
980 | 980 | } |
@@ -992,53 +992,53 @@ discard block |
||
992 | 992 | } |
993 | 993 | } |
994 | 994 | |
995 | - foreach( $rows as $row ) : |
|
996 | - foreach( $row as $col => $areas ) : |
|
997 | - $column = ($col == '2-2') ? '1-2' : $col; ?> |
|
995 | + foreach ( $rows as $row ) : |
|
996 | + foreach ( $row as $col => $areas ) : |
|
997 | + $column = ( $col == '2-2' ) ? '1-2' : $col; ?> |
|
998 | 998 | |
999 | 999 | <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
1000 | 1000 | |
1001 | - <?php foreach( $areas as $area ) : ?> |
|
1001 | + <?php foreach ( $areas as $area ) : ?> |
|
1002 | 1002 | |
1003 | - <div class="gv-droppable-area" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>"> |
|
1004 | - <p class="gv-droppable-area-title" <?php if ( 'widget' === $type && empty( $area['subtitle'] ) ) { echo ' style="margin: 0; padding: 0;"'; } ?>> |
|
1005 | - <strong <?php if ( 'widget' === $type ) { echo 'class="screen-reader-text"'; } ?>><?php echo esc_html( $area['title'] ); ?></strong> |
|
1003 | + <div class="gv-droppable-area" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>"> |
|
1004 | + <p class="gv-droppable-area-title" <?php if ( 'widget' === $type && empty( $area[ 'subtitle' ] ) ) { echo ' style="margin: 0; padding: 0;"'; } ?>> |
|
1005 | + <strong <?php if ( 'widget' === $type ) { echo 'class="screen-reader-text"'; } ?>><?php echo esc_html( $area[ 'title' ] ); ?></strong> |
|
1006 | 1006 | |
1007 | 1007 | <?php if ( 'widget' !== $type ) { ?> |
1008 | - <a class="clear-all-fields alignright" role="button" href="#" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>"><?php esc_html_e( 'Clear all fields', 'gravityview' ); ?></a> |
|
1008 | + <a class="clear-all-fields alignright" role="button" href="#" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>"><?php esc_html_e( 'Clear all fields', 'gravityview' ); ?></a> |
|
1009 | 1009 | <?php } ?> |
1010 | 1010 | |
1011 | - <?php if ( ! empty( $area['subtitle'] ) ) { ?> |
|
1012 | - <span class="gv-droppable-area-subtitle"><span class="gf_tooltip gv_tooltip tooltip" title="<?php echo esc_attr( $area['subtitle'] ); ?>"></span></span> |
|
1011 | + <?php if ( ! empty( $area[ 'subtitle' ] ) ) { ?> |
|
1012 | + <span class="gv-droppable-area-subtitle"><span class="gf_tooltip gv_tooltip tooltip" title="<?php echo esc_attr( $area[ 'subtitle' ] ); ?>"></span></span> |
|
1013 | 1013 | <?php } ?> |
1014 | 1014 | </p> |
1015 | 1015 | <div class="active-drop-container active-drop-container-<?php echo esc_attr( $type ); ?>"> |
1016 | - <div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>"><?php // render saved fields |
|
1017 | - if( ! empty( $values[ $zone .'_'. $area['areaid'] ] ) ) { |
|
1016 | + <div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>"><?php // render saved fields |
|
1017 | + if ( ! empty( $values[ $zone . '_' . $area[ 'areaid' ] ] ) ) { |
|
1018 | 1018 | |
1019 | - foreach( $values[ $zone .'_'. $area['areaid'] ] as $uniqid => $field ) { |
|
1019 | + foreach ( $values[ $zone . '_' . $area[ 'areaid' ] ] as $uniqid => $field ) { |
|
1020 | 1020 | |
1021 | 1021 | // Maybe has a form ID |
1022 | - $form_id = empty( $field['form_id'] ) ? $form_id : $field['form_id']; |
|
1022 | + $form_id = empty( $field[ 'form_id' ] ) ? $form_id : $field[ 'form_id' ]; |
|
1023 | 1023 | |
1024 | 1024 | $input_type = NULL; |
1025 | 1025 | |
1026 | 1026 | if ( $form_id ) { |
1027 | - $original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ; |
|
1027 | + $original_item = isset( $available_items[ $form_id ] [ $field[ 'id' ] ] ) ? $available_items[ $form_id ] [ $field[ 'id' ] ] : false; |
|
1028 | 1028 | } else { |
1029 | - $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
|
1029 | + $original_item = isset( $available_items[ $field[ 'id' ] ] ) ? $available_items[ $field[ 'id' ] ] : false; |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | - if ( !$original_item ) { |
|
1033 | - gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array(' data' => array('available_items' => $available_items, 'field' => $field ) ) ); |
|
1032 | + if ( ! $original_item ) { |
|
1033 | + gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array( ' data' => array( 'available_items' => $available_items, 'field' => $field ) ) ); |
|
1034 | 1034 | |
1035 | 1035 | $original_item = $field; |
1036 | 1036 | } else { |
1037 | - $input_type = isset( $original_item['type'] ) ? $original_item['type'] : NULL; |
|
1037 | + $input_type = isset( $original_item[ 'type' ] ) ? $original_item[ 'type' ] : NULL; |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | // Field options dialog box |
1041 | - $field_options = GravityView_Render_Settings::render_field_options( $form_id, $type, $template_id, $field['id'], $original_item['label'], $zone .'_'. $area['areaid'], $input_type, $uniqid, $field, $zone, $original_item ); |
|
1041 | + $field_options = GravityView_Render_Settings::render_field_options( $form_id, $type, $template_id, $field[ 'id' ], $original_item[ 'label' ], $zone . '_' . $area[ 'areaid' ], $input_type, $uniqid, $field, $zone, $original_item ); |
|
1042 | 1042 | |
1043 | 1043 | $item = array( |
1044 | 1044 | 'input_type' => $input_type, |
@@ -1051,12 +1051,12 @@ discard block |
||
1051 | 1051 | $item = wp_parse_args( $item, $original_item ); |
1052 | 1052 | } |
1053 | 1053 | |
1054 | - switch( $type ) { |
|
1054 | + switch ( $type ) { |
|
1055 | 1055 | case 'widget': |
1056 | - echo new GravityView_Admin_View_Widget( $item['label'], $field['id'], $item, $field ); |
|
1056 | + echo new GravityView_Admin_View_Widget( $item[ 'label' ], $field[ 'id' ], $item, $field ); |
|
1057 | 1057 | break; |
1058 | 1058 | default: |
1059 | - echo new GravityView_Admin_View_Field( $field['label'], $field['id'], $item, $field, $form_id ); |
|
1059 | + echo new GravityView_Admin_View_Field( $field[ 'label' ], $field[ 'id' ], $item, $field, $form_id ); |
|
1060 | 1060 | } |
1061 | 1061 | } |
1062 | 1062 | |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | <div class="gv-droppable-area-action"> |
1065 | 1065 | <a href="#" class="gv-add-field button button-link button-hero" title="" |
1066 | 1066 | data-objecttype="<?php echo esc_attr( $type ); ?>" |
1067 | - data-areaid="<?php echo esc_attr( $zone . '_' . $area['areaid'] ); ?>" |
|
1067 | + data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>" |
|
1068 | 1068 | data-context="<?php echo esc_attr( $zone ); ?>" |
1069 | 1069 | data-formid="<?php echo $view ? esc_attr( $view->form ? $view->form->ID : '' ) : ''; ?>"><?php echo '<span class="dashicons dashicons-plus-alt"></span>' . esc_html( $button_label ); ?></a> |
1070 | 1070 | </div> |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | // This is a new View, prefill the widgets |
1098 | 1098 | $widgets = array( |
1099 | 1099 | 'header_top' => array( |
1100 | - substr( md5( microtime( true ) ), 0, 13 ) => array ( |
|
1100 | + substr( md5( microtime( true ) ), 0, 13 ) => array( |
|
1101 | 1101 | 'id' => 'search_bar', |
1102 | 1102 | 'label' => __( 'Search Bar', 'gravityview' ), |
1103 | 1103 | 'search_layout' => 'horizontal', |
@@ -1172,12 +1172,12 @@ discard block |
||
1172 | 1172 | if ( $post ) { |
1173 | 1173 | $source_form_id = gravityview_get_form_id( $post->ID ); |
1174 | 1174 | if ( $source_form_id ) { |
1175 | - $form_ids[] = $source_form_id; |
|
1175 | + $form_ids[ ] = $source_form_id; |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | $joined_forms = \GV\View::get_joined_forms( $post->ID ); |
1179 | 1179 | foreach ( $joined_forms as $joined_form ) { |
1180 | - $form_ids[] = $joined_form->ID; |
|
1180 | + $form_ids[ ] = $joined_form->ID; |
|
1181 | 1181 | } |
1182 | 1182 | } |
1183 | 1183 | foreach ( array_unique( $form_ids ) as $form_id ) { |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | * @return string HTML of the active areas |
1216 | 1216 | */ |
1217 | 1217 | function render_directory_active_areas( $template_id = '', $context = 'single', $post_id = '', $echo = false ) { |
1218 | - if( empty( $template_id ) ) { |
|
1218 | + if ( empty( $template_id ) ) { |
|
1219 | 1219 | gravityview()->log->debug( '[render_directory_active_areas] {template_id} is empty', array( 'template_id' => $template_id ) ); |
1220 | 1220 | return ''; |
1221 | 1221 | } |
@@ -1229,12 +1229,12 @@ discard block |
||
1229 | 1229 | */ |
1230 | 1230 | $template_areas = apply_filters( 'gravityview_template_active_areas', array(), $template_id, $context ); |
1231 | 1231 | |
1232 | - if( empty( $template_areas ) ) { |
|
1232 | + if ( empty( $template_areas ) ) { |
|
1233 | 1233 | |
1234 | 1234 | gravityview()->log->debug( '[render_directory_active_areas] No areas defined. Maybe template {template_id} is disabled.', array( 'data' => $template_id ) ); |
1235 | 1235 | $output = '<div>'; |
1236 | - $output .= '<h2 class="description" style="font-size: 16px; margin:0">'. sprintf( esc_html__( 'This View is configured using the %s View type, which is disabled.', 'gravityview' ), '<em>'.$template_id.'</em>' ) .'</h2>'; |
|
1237 | - $output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">'.esc_html__('The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview').'</p>'; |
|
1236 | + $output .= '<h2 class="description" style="font-size: 16px; margin:0">' . sprintf( esc_html__( 'This View is configured using the %s View type, which is disabled.', 'gravityview' ), '<em>' . $template_id . '</em>' ) . '</h2>'; |
|
1237 | + $output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">' . esc_html__( 'The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview' ) . '</p>'; |
|
1238 | 1238 | $output .= '</div>'; |
1239 | 1239 | } else { |
1240 | 1240 | |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | |
1250 | 1250 | } |
1251 | 1251 | |
1252 | - if( $echo ) { |
|
1252 | + if ( $echo ) { |
|
1253 | 1253 | echo $output; |
1254 | 1254 | } |
1255 | 1255 | |
@@ -1277,18 +1277,18 @@ discard block |
||
1277 | 1277 | } |
1278 | 1278 | |
1279 | 1279 | // Add the GV font (with the Astronaut) |
1280 | - wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
1280 | + wp_enqueue_style( 'gravityview_global', plugins_url( 'assets/css/admin-global.css', GRAVITYVIEW_FILE ), array(), \GV\Plugin::$version ); |
|
1281 | 1281 | wp_register_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), \GV\Plugin::$version ); |
1282 | 1282 | |
1283 | - wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), \GV\Plugin::$version, true ); |
|
1283 | + wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), \GV\Plugin::$version, true ); |
|
1284 | 1284 | |
1285 | - if( GFForms::get_page() === 'form_list' ) { |
|
1285 | + if ( GFForms::get_page() === 'form_list' ) { |
|
1286 | 1286 | wp_enqueue_style( 'gravityview_views_styles' ); |
1287 | 1287 | return; |
1288 | 1288 | } |
1289 | 1289 | |
1290 | 1290 | // Don't process any scripts below here if it's not a GravityView page. |
1291 | - if( ! gravityview()->request->is_admin( $hook, 'single' ) && ! $is_widgets_page ) { |
|
1291 | + if ( ! gravityview()->request->is_admin( $hook, 'single' ) && ! $is_widgets_page ) { |
|
1292 | 1292 | return; |
1293 | 1293 | } |
1294 | 1294 | |
@@ -1296,15 +1296,15 @@ discard block |
||
1296 | 1296 | |
1297 | 1297 | wp_enqueue_script( 'jquery-ui-datepicker' ); |
1298 | 1298 | |
1299 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
1299 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url( 'assets/css/admin-datepicker.css', GRAVITYVIEW_FILE ), \GV\Plugin::$version ); |
|
1300 | 1300 | |
1301 | 1301 | // Enqueue scripts |
1302 | 1302 | wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version ); |
1303 | 1303 | |
1304 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1304 | + wp_localize_script( 'gravityview_views_scripts', 'gvGlobals', array( |
|
1305 | 1305 | 'cookiepath' => COOKIEPATH, |
1306 | 1306 | 'admin_cookiepath' => ADMIN_COOKIE_PATH, |
1307 | - 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1307 | + 'passed_form_id' => (bool)\GV\Utils::_GET( 'form_id' ), |
|
1308 | 1308 | 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
1309 | 1309 | 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
1310 | 1310 | 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
@@ -1319,7 +1319,7 @@ discard block |
||
1319 | 1319 | 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
1320 | 1320 | 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
1321 | 1321 | 'remove_all_fields' => __( 'Would you like to remove all fields in this zone?', 'gravityview' ), |
1322 | - )); |
|
1322 | + ) ); |
|
1323 | 1323 | |
1324 | 1324 | wp_enqueue_style( 'gravityview_views_styles' ); |
1325 | 1325 | |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | self::enqueue_gravity_forms_scripts(); |
1328 | 1328 | |
1329 | 1329 | // 2.5 changed how Merge Tags are enqueued |
1330 | - if ( is_callable( array( 'GFCommon', 'output_hooks_javascript') ) ) { |
|
1330 | + if ( is_callable( array( 'GFCommon', 'output_hooks_javascript' ) ) ) { |
|
1331 | 1331 | GFCommon::output_hooks_javascript(); |
1332 | 1332 | } |
1333 | 1333 | } |
@@ -1351,7 +1351,7 @@ discard block |
||
1351 | 1351 | ); |
1352 | 1352 | |
1353 | 1353 | if ( wp_is_mobile() ) { |
1354 | - $scripts[] = 'jquery-touch-punch'; |
|
1354 | + $scripts[ ] = 'jquery-touch-punch'; |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | wp_enqueue_script( $scripts ); |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * |
430 | 430 | * @return void |
431 | 431 | */ |
432 | - public function add_custom_column_content( $column_name = null, $post_id = 0 ) { |
|
432 | + public function add_custom_column_content( $column_name = null, $post_id = 0 ) { |
|
433 | 433 | |
434 | 434 | $output = ''; |
435 | 435 | |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | */ |
599 | 599 | function save_postdata( $post_id ) { |
600 | 600 | |
601 | - if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){ |
|
601 | + if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
602 | 602 | return; |
603 | 603 | } |
604 | 604 |