@@ -49,17 +49,17 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return string If a custom field label isn't set, return the field label for the password field |
51 | 51 | */ |
52 | - function field_label( $label = '', $field = array(), $form = array(), $entry = array() ){ |
|
52 | + function field_label( $label = '', $field = array(), $form = array(), $entry = array() ) { |
|
53 | 53 | |
54 | 54 | // If using a custom label, no need to fetch the parent label |
55 | - if( ! is_numeric( $field['id'] ) || ! empty( $field['custom_label'] ) ) { |
|
55 | + if ( ! is_numeric( $field[ 'id' ] ) || ! empty( $field[ 'custom_label' ] ) ) { |
|
56 | 56 | return $label; |
57 | 57 | } |
58 | 58 | |
59 | - $field_object = GFFormsModel::get_field( $form, $field['id'] ); |
|
59 | + $field_object = GFFormsModel::get_field( $form, $field[ 'id' ] ); |
|
60 | 60 | |
61 | - if( $field_object && 'password' === $field_object->type ) { |
|
62 | - $label = $field['label']; |
|
61 | + if ( $field_object && 'password' === $field_object->type ) { |
|
62 | + $label = $field[ 'label' ]; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | return $label; |
@@ -79,16 +79,16 @@ discard block |
||
79 | 79 | function add_form_fields( $fields = array(), $form = array(), $include_parent_field = true ) { |
80 | 80 | |
81 | 81 | foreach ( $fields as $key => $field ) { |
82 | - if( 'password' === $field['type'] ) { |
|
82 | + if ( 'password' === $field[ 'type' ] ) { |
|
83 | 83 | |
84 | 84 | // The Enter Password input |
85 | - if( floor( $key ) === floatval( $key ) ) { |
|
86 | - $field['label'] = $field['parent']->label; |
|
87 | - $field['adminOnly'] = $field['parent']->adminOnly; |
|
88 | - $field['adminLabel'] = $field['parent']->adminLabel; |
|
85 | + if ( floor( $key ) === floatval( $key ) ) { |
|
86 | + $field[ 'label' ] = $field[ 'parent' ]->label; |
|
87 | + $field[ 'adminOnly' ] = $field[ 'parent' ]->adminOnly; |
|
88 | + $field[ 'adminLabel' ] = $field[ 'parent' ]->adminLabel; |
|
89 | 89 | |
90 | 90 | // Don't show as a child input |
91 | - unset( $field['parent'] ); |
|
91 | + unset( $field[ 'parent' ] ); |
|
92 | 92 | |
93 | 93 | $fields[ $key ] = $field; |
94 | 94 | } else { |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * |
50 | 50 | * @return string If a custom field label isn't set, return the field label for the password field |
51 | 51 | */ |
52 | - function field_label( $label = '', $field = array(), $form = array(), $entry = array() ){ |
|
52 | + function field_label( $label = '', $field = array(), $form = array(), $entry = array() ) { |
|
53 | 53 | |
54 | 54 | // If using a custom label, no need to fetch the parent label |
55 | 55 | if( ! is_numeric( $field['id'] ) || ! empty( $field['custom_label'] ) ) { |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | /** |
202 | 202 | * Add admin script to the no-conflict scripts whitelist |
203 | 203 | * @param array $allowed Scripts allowed in no-conflict mode |
204 | - * @return array Scripts allowed in no-conflict mode, plus the search widget script |
|
204 | + * @return string[] Scripts allowed in no-conflict mode, plus the search widget script |
|
205 | 205 | */ |
206 | 206 | public function register_no_conflict( $allowed ) { |
207 | 207 | $allowed[] = 'gravityview_searchwidget_admin'; |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | /** |
890 | 890 | * Get the label for a search form field |
891 | 891 | * @param array $field Field setting as sent by the GV configuration - has `field`, `input` (input type), and `label` keys |
892 | - * @param array $form_field Form field data, as fetched by `gravityview_get_field()` |
|
892 | + * @param GF_Field|null $form_field Form field data, as fetched by `gravityview_get_field()` |
|
893 | 893 | * @return string Label for the search form |
894 | 894 | */ |
895 | 895 | private static function get_field_label( $field, $form_field = array() ) { |
@@ -1058,7 +1058,7 @@ discard block |
||
1058 | 1058 | /** |
1059 | 1059 | * Require the datepicker script for the frontend GV script |
1060 | 1060 | * @param array $js_dependencies Array of existing required scripts for the fe-views.js script |
1061 | - * @return array Array required scripts, with `jquery-ui-datepicker` added |
|
1061 | + * @return string[] Array required scripts, with `jquery-ui-datepicker` added |
|
1062 | 1062 | */ |
1063 | 1063 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1064 | 1064 | |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | /** |
1071 | 1071 | * Modify the array passed to wp_localize_script() |
1072 | 1072 | * |
1073 | - * @param array $js_localization The data padded to the Javascript file |
|
1073 | + * @param array $localizations The data padded to the Javascript file |
|
1074 | 1074 | * @param array $view_data View data array with View settings |
1075 | 1075 | * |
1076 | 1076 | * @return array |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | 'type' => 'radio', |
64 | 64 | 'full_width' => true, |
65 | 65 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
66 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
66 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
67 | 67 | 'value' => 'any', |
68 | 68 | 'class' => 'hide-if-js', |
69 | 69 | 'options' => array( |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
87 | 87 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
88 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
88 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
89 | 89 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
90 | 90 | |
91 | 91 | // ajax - get the searchable fields |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
150 | 150 | $script_source = empty( $script_min ) ? '/source' : ''; |
151 | 151 | |
152 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), GravityView_Plugin::version ); |
|
152 | + wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), GravityView_Plugin::version ); |
|
153 | 153 | |
154 | 154 | |
155 | 155 | /** |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
205 | 205 | */ |
206 | 206 | public function register_no_conflict( $allowed ) { |
207 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
207 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
208 | 208 | return $allowed; |
209 | 209 | } |
210 | 210 | |
@@ -217,24 +217,24 @@ discard block |
||
217 | 217 | */ |
218 | 218 | public static function get_searchable_fields() { |
219 | 219 | |
220 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
220 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
221 | 221 | exit( '0' ); |
222 | 222 | } |
223 | 223 | |
224 | 224 | $form = ''; |
225 | 225 | |
226 | 226 | // Fetch the form for the current View |
227 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
227 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
228 | 228 | |
229 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
229 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
230 | 230 | |
231 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
231 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
232 | 232 | |
233 | - $form = (int) $_POST['formid']; |
|
233 | + $form = (int)$_POST[ 'formid' ]; |
|
234 | 234 | |
235 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
235 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
236 | 236 | |
237 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
237 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
238 | 238 | |
239 | 239 | } |
240 | 240 | |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | ) |
280 | 280 | ); |
281 | 281 | |
282 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
283 | - $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] ); |
|
282 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
283 | + $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] ); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | // Get fields with sub-inputs and no parent |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | |
303 | 303 | foreach ( $fields as $id => $field ) { |
304 | 304 | |
305 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
305 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
306 | 306 | continue; |
307 | 307 | } |
308 | 308 | |
309 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
309 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
310 | 310 | |
311 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
311 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | public static function get_search_input_types( $id = '', $field_type = null ) { |
331 | 331 | |
332 | 332 | // @todo - This needs to be improved - many fields have . including products and addresses |
333 | - if ( false !== strpos( (string) $id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
333 | + if ( false !== strpos( (string)$id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
334 | 334 | $input_type = 'boolean'; // on/off checkbox |
335 | 335 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
336 | 336 | $input_type = 'multi'; //multiselect |
@@ -372,19 +372,19 @@ discard block |
||
372 | 372 | $post_id = 0; |
373 | 373 | |
374 | 374 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
375 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
376 | - $post_id = absint( $widget_args['post_id'] ); |
|
375 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
376 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
377 | 377 | } |
378 | 378 | // We're in the WordPress Widget context, and the base View ID should be used |
379 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
380 | - $post_id = absint( $widget_args['view_id'] ); |
|
379 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
380 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | $args = gravityview_get_permalink_query_args( $post_id ); |
384 | 384 | |
385 | 385 | // Add hidden fields to the search form |
386 | 386 | foreach ( $args as $key => $value ) { |
387 | - $search_fields[] = array( |
|
387 | + $search_fields[ ] = array( |
|
388 | 388 | 'name' => $key, |
389 | 389 | 'input' => 'hidden', |
390 | 390 | 'value' => $value, |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | */ |
406 | 406 | public function filter_entries( $search_criteria ) { |
407 | 407 | |
408 | - if( 'post' === $this->search_method ) { |
|
408 | + if ( 'post' === $this->search_method ) { |
|
409 | 409 | $get = $_POST; |
410 | 410 | } else { |
411 | 411 | $get = $_GET; |
@@ -422,15 +422,15 @@ discard block |
||
422 | 422 | $get = gv_map_deep( $get, 'urldecode' ); |
423 | 423 | |
424 | 424 | // add free search |
425 | - if ( ! empty( $get['gv_search'] ) ) { |
|
425 | + if ( ! empty( $get[ 'gv_search' ] ) ) { |
|
426 | 426 | |
427 | 427 | // Search for a piece |
428 | - $words = explode( ' ', $get['gv_search'] ); |
|
428 | + $words = explode( ' ', $get[ 'gv_search' ] ); |
|
429 | 429 | |
430 | 430 | $words = array_filter( $words ); |
431 | 431 | |
432 | 432 | foreach ( $words as $word ) { |
433 | - $search_criteria['field_filters'][] = array( |
|
433 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
434 | 434 | 'key' => null, // The field ID to search |
435 | 435 | 'value' => $word, // The value to search |
436 | 436 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | } |
440 | 440 | |
441 | 441 | //start date & end date |
442 | - $curr_start = !empty( $get['gv_start'] ) ? $get['gv_start'] : ''; |
|
443 | - $curr_end = !empty( $get['gv_start'] ) ? $get['gv_end'] : ''; |
|
442 | + $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : ''; |
|
443 | + $curr_end = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_end' ] : ''; |
|
444 | 444 | |
445 | 445 | /** |
446 | 446 | * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
@@ -455,16 +455,16 @@ discard block |
||
455 | 455 | /** |
456 | 456 | * Don't set $search_criteria['start_date'] if start_date is empty as it may lead to bad query results (GFAPI::get_entries) |
457 | 457 | */ |
458 | - if( !empty( $curr_start ) ) { |
|
459 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
458 | + if ( ! empty( $curr_start ) ) { |
|
459 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
460 | 460 | } |
461 | - if( !empty( $curr_end ) ) { |
|
462 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
461 | + if ( ! empty( $curr_end ) ) { |
|
462 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | // search for a specific entry ID |
466 | 466 | if ( ! empty( $get[ 'gv_id' ] ) ) { |
467 | - $search_criteria['field_filters'][] = array( |
|
467 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
468 | 468 | 'key' => 'id', |
469 | 469 | 'value' => absint( $get[ 'gv_id' ] ), |
470 | 470 | 'operator' => '=', |
@@ -473,36 +473,36 @@ discard block |
||
473 | 473 | |
474 | 474 | // search for a specific Created_by ID |
475 | 475 | if ( ! empty( $get[ 'gv_by' ] ) ) { |
476 | - $search_criteria['field_filters'][] = array( |
|
476 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
477 | 477 | 'key' => 'created_by', |
478 | - 'value' => absint( $get['gv_by'] ), |
|
478 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
479 | 479 | 'operator' => '=', |
480 | 480 | ); |
481 | 481 | } |
482 | 482 | |
483 | 483 | |
484 | 484 | // Get search mode passed in URL |
485 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
485 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
486 | 486 | |
487 | 487 | // get the other search filters |
488 | 488 | foreach ( $get as $key => $value ) { |
489 | 489 | |
490 | - if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[0] ) ) ) { |
|
490 | + if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[ 0 ] ) ) ) { |
|
491 | 491 | continue; |
492 | 492 | } |
493 | 493 | |
494 | 494 | // could return simple filter or multiple filters |
495 | 495 | $filter = $this->prepare_field_filter( $key, $value ); |
496 | 496 | |
497 | - if ( isset( $filter[0]['value'] ) ) { |
|
498 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
497 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
498 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
499 | 499 | |
500 | 500 | // if date range type, set search mode to ALL |
501 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
501 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
502 | 502 | $mode = 'all'; |
503 | 503 | } |
504 | - } elseif( !empty( $filter ) ) { |
|
505 | - $search_criteria['field_filters'][] = $filter; |
|
504 | + } elseif ( ! empty( $filter ) ) { |
|
505 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
506 | 506 | } |
507 | 507 | } |
508 | 508 | |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | * @since 1.5.1 |
512 | 512 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
513 | 513 | */ |
514 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
514 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
515 | 515 | |
516 | 516 | do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria ); |
517 | 517 | |
@@ -549,11 +549,11 @@ discard block |
||
549 | 549 | 'value' => $value, |
550 | 550 | ); |
551 | 551 | |
552 | - switch ( $form_field['type'] ) { |
|
552 | + switch ( $form_field[ 'type' ] ) { |
|
553 | 553 | |
554 | 554 | case 'select': |
555 | 555 | case 'radio': |
556 | - $filter['operator'] = 'is'; |
|
556 | + $filter[ 'operator' ] = 'is'; |
|
557 | 557 | break; |
558 | 558 | |
559 | 559 | case 'post_category': |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | |
568 | 568 | foreach ( $value as $val ) { |
569 | 569 | $cat = get_term( $val, 'category' ); |
570 | - $filter[] = array( |
|
570 | + $filter[ ] = array( |
|
571 | 571 | 'key' => $field_id, |
572 | 572 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
573 | 573 | 'operator' => 'is', |
@@ -586,18 +586,18 @@ discard block |
||
586 | 586 | $filter = array(); |
587 | 587 | |
588 | 588 | foreach ( $value as $val ) { |
589 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
589 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | break; |
593 | 593 | |
594 | 594 | case 'checkbox': |
595 | 595 | // convert checkbox on/off into the correct search filter |
596 | - if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) { |
|
597 | - foreach ( $form_field['inputs'] as $k => $input ) { |
|
598 | - if ( $input['id'] == $field_id ) { |
|
599 | - $filter['value'] = $form_field['choices'][ $k ]['value']; |
|
600 | - $filter['operator'] = 'is'; |
|
596 | + if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field[ 'inputs' ] ) && ! empty( $form_field[ 'choices' ] ) ) { |
|
597 | + foreach ( $form_field[ 'inputs' ] as $k => $input ) { |
|
598 | + if ( $input[ 'id' ] == $field_id ) { |
|
599 | + $filter[ 'value' ] = $form_field[ 'choices' ][ $k ][ 'value' ]; |
|
600 | + $filter[ 'operator' ] = 'is'; |
|
601 | 601 | break; |
602 | 602 | } |
603 | 603 | } |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | $filter = array(); |
608 | 608 | |
609 | 609 | foreach ( $value as $val ) { |
610 | - $filter[] = array( |
|
610 | + $filter[ ] = array( |
|
611 | 611 | 'key' => $field_id, |
612 | 612 | 'value' => $val, |
613 | 613 | 'operator' => 'is', |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | foreach ( $words as $word ) { |
629 | 629 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
630 | 630 | // Keep the same key for each filter |
631 | - $filter['value'] = $word; |
|
631 | + $filter[ 'value' ] = $word; |
|
632 | 632 | // Add a search for the value |
633 | - $filters[] = $filter; |
|
633 | + $filters[ ] = $filter; |
|
634 | 634 | } |
635 | 635 | } |
636 | 636 | |
@@ -657,19 +657,19 @@ discard block |
||
657 | 657 | * @since 1.16.3 |
658 | 658 | * Safeguard until GF implements '<=' operator |
659 | 659 | */ |
660 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
660 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
661 | 661 | $operator = '<'; |
662 | 662 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
663 | 663 | } |
664 | 664 | |
665 | - $filter[] = array( |
|
665 | + $filter[ ] = array( |
|
666 | 666 | 'key' => $field_id, |
667 | 667 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
668 | 668 | 'operator' => $operator, |
669 | 669 | ); |
670 | 670 | } |
671 | 671 | } else { |
672 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
672 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | break; |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | 'ymd_dot' => 'Y.m.d', |
701 | 701 | ); |
702 | 702 | |
703 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
703 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
704 | 704 | $format = $datepicker[ $field->dateFormat ]; |
705 | 705 | } |
706 | 706 | |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | public function add_template_path( $file_paths ) { |
732 | 732 | |
733 | 733 | // Index 100 is the default GravityView template path. |
734 | - $file_paths[102] = self::$file . 'templates/'; |
|
734 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
735 | 735 | |
736 | 736 | return $file_paths; |
737 | 737 | } |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | } |
755 | 755 | |
756 | 756 | // get configured search fields |
757 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
757 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
758 | 758 | |
759 | 759 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
760 | 760 | do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args ); |
@@ -768,24 +768,24 @@ discard block |
||
768 | 768 | |
769 | 769 | $updated_field = $field; |
770 | 770 | |
771 | - if ( in_array( $field['input'], array( 'date', 'date_range' ) ) ) { |
|
771 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range' ) ) ) { |
|
772 | 772 | $has_date = true; |
773 | 773 | } |
774 | 774 | |
775 | 775 | $updated_field = $this->get_search_filter_details( $updated_field ); |
776 | 776 | |
777 | - switch ( $field['field'] ) { |
|
777 | + switch ( $field[ 'field' ] ) { |
|
778 | 778 | |
779 | 779 | case 'search_all': |
780 | - $updated_field['key'] = 'search_all'; |
|
781 | - $updated_field['input'] = 'search_all'; |
|
782 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
780 | + $updated_field[ 'key' ] = 'search_all'; |
|
781 | + $updated_field[ 'input' ] = 'search_all'; |
|
782 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
783 | 783 | break; |
784 | 784 | |
785 | 785 | case 'entry_date': |
786 | - $updated_field['key'] = 'entry_date'; |
|
787 | - $updated_field['input'] = 'entry_date'; |
|
788 | - $updated_field['value'] = array( |
|
786 | + $updated_field[ 'key' ] = 'entry_date'; |
|
787 | + $updated_field[ 'input' ] = 'entry_date'; |
|
788 | + $updated_field[ 'value' ] = array( |
|
789 | 789 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
790 | 790 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
791 | 791 | ); |
@@ -793,16 +793,16 @@ discard block |
||
793 | 793 | break; |
794 | 794 | |
795 | 795 | case 'entry_id': |
796 | - $updated_field['key'] = 'entry_id'; |
|
797 | - $updated_field['input'] = 'entry_id'; |
|
798 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
796 | + $updated_field[ 'key' ] = 'entry_id'; |
|
797 | + $updated_field[ 'input' ] = 'entry_id'; |
|
798 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
799 | 799 | break; |
800 | 800 | |
801 | 801 | case 'created_by': |
802 | - $updated_field['key'] = 'created_by'; |
|
803 | - $updated_field['name'] = 'gv_by'; |
|
804 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
805 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
802 | + $updated_field[ 'key' ] = 'created_by'; |
|
803 | + $updated_field[ 'name' ] = 'gv_by'; |
|
804 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
805 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
806 | 806 | break; |
807 | 807 | } |
808 | 808 | |
@@ -820,16 +820,16 @@ discard block |
||
820 | 820 | */ |
821 | 821 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args ); |
822 | 822 | |
823 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
823 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
824 | 824 | |
825 | 825 | /** @since 1.14 */ |
826 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
826 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
827 | 827 | |
828 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
828 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
829 | 829 | |
830 | 830 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
831 | 831 | |
832 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
832 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
833 | 833 | |
834 | 834 | if ( $has_date ) { |
835 | 835 | // enqueue datepicker stuff only if needed! |
@@ -851,10 +851,10 @@ discard block |
||
851 | 851 | public static function get_search_class( $custom_class = '' ) { |
852 | 852 | $gravityview_view = GravityView_View::getInstance(); |
853 | 853 | |
854 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
854 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
855 | 855 | |
856 | - if ( ! empty( $custom_class ) ) { |
|
857 | - $search_class .= ' '.$custom_class; |
|
856 | + if ( ! empty( $custom_class ) ) { |
|
857 | + $search_class .= ' ' . $custom_class; |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | /** |
@@ -896,11 +896,11 @@ discard block |
||
896 | 896 | |
897 | 897 | $label = rgget( 'label', $field ); |
898 | 898 | |
899 | - if( '' === $label ) { |
|
899 | + if ( '' === $label ) { |
|
900 | 900 | |
901 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
901 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
902 | 902 | |
903 | - switch( $field['field'] ) { |
|
903 | + switch ( $field[ 'field' ] ) { |
|
904 | 904 | case 'search_all': |
905 | 905 | $label = __( 'Search Entries:', 'gravityview' ); |
906 | 906 | break; |
@@ -918,10 +918,10 @@ discard block |
||
918 | 918 | break; |
919 | 919 | default: |
920 | 920 | // If this is a field input, not a field |
921 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
921 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
922 | 922 | |
923 | 923 | // Get the label for the field in question, which returns an array |
924 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
924 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
925 | 925 | |
926 | 926 | // Get the item with the `label` key |
927 | 927 | $values = wp_list_pluck( $items, 'label' ); |
@@ -958,32 +958,32 @@ discard block |
||
958 | 958 | $form = $gravityview_view->getForm(); |
959 | 959 | |
960 | 960 | // for advanced field ids (eg, first name / last name ) |
961 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
961 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
962 | 962 | |
963 | 963 | // get searched value from $_GET/$_POST (string or array) |
964 | 964 | $value = $this->rgget_or_rgpost( $name ); |
965 | 965 | |
966 | 966 | // get form field details |
967 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
967 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
968 | 968 | |
969 | 969 | $filter = array( |
970 | - 'key' => $field['field'], |
|
970 | + 'key' => $field[ 'field' ], |
|
971 | 971 | 'name' => $name, |
972 | 972 | 'label' => self::get_field_label( $field, $form_field ), |
973 | - 'input' => $field['input'], |
|
973 | + 'input' => $field[ 'input' ], |
|
974 | 974 | 'value' => $value, |
975 | - 'type' => $form_field['type'], |
|
975 | + 'type' => $form_field[ 'type' ], |
|
976 | 976 | ); |
977 | 977 | |
978 | 978 | // collect choices |
979 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
980 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
981 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
982 | - $filter['choices'] = $form_field['choices']; |
|
979 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
980 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
981 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
982 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
983 | 983 | } |
984 | 984 | |
985 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
986 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
985 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
986 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | return $filter; |
@@ -1007,7 +1007,7 @@ discard block |
||
1007 | 1007 | |
1008 | 1008 | $choices = array(); |
1009 | 1009 | foreach ( $users as $user ) { |
1010 | - $choices[] = array( |
|
1010 | + $choices[ ] = array( |
|
1011 | 1011 | 'value' => $user->ID, |
1012 | 1012 | 'text' => $user->display_name, |
1013 | 1013 | ); |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | */ |
1063 | 1063 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1064 | 1064 | |
1065 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1065 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1066 | 1066 | |
1067 | 1067 | return $js_dependencies; |
1068 | 1068 | } |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | 'isRTL' => is_rtl(), |
1107 | 1107 | ), $view_data ); |
1108 | 1108 | |
1109 | - $localizations['datepicker'] = $datepicker_settings; |
|
1109 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1110 | 1110 | |
1111 | 1111 | return $localizations; |
1112 | 1112 | |
@@ -1135,7 +1135,7 @@ discard block |
||
1135 | 1135 | * @return void |
1136 | 1136 | */ |
1137 | 1137 | private function maybe_enqueue_flexibility() { |
1138 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1138 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1139 | 1139 | wp_enqueue_script( 'gv-flexibility' ); |
1140 | 1140 | } |
1141 | 1141 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1158 | 1158 | |
1159 | 1159 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1160 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1160 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1161 | 1161 | |
1162 | 1162 | /** |
1163 | 1163 | * @filter `gravityview_search_datepicker_class` |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | 'slug' => 'edit', |
25 | 25 | 'type' => 'internal', |
26 | 26 | 'label' => __( 'Edit Table', 'gravityview' ), |
27 | - 'description' => __('Display items in a table view.', 'gravityview'), |
|
28 | - 'logo' => plugins_url('includes/presets/default-table/logo-default-table.png', GRAVITYVIEW_FILE), |
|
27 | + 'description' => __( 'Display items in a table view.', 'gravityview' ), |
|
28 | + 'logo' => plugins_url( 'includes/presets/default-table/logo-default-table.png', GRAVITYVIEW_FILE ), |
|
29 | 29 | 'css_source' => gravityview_css_url( 'table-view.css', GRAVITYVIEW_DIR . 'templates/css/' ), |
30 | 30 | ); |
31 | 31 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | '1-1' => array( |
43 | 43 | array( |
44 | 44 | 'areaid' => 'edit-fields', |
45 | - 'title' => __('Visible Edit Fields', 'gravityview' ) |
|
45 | + 'title' => __( 'Visible Edit Fields', 'gravityview' ) |
|
46 | 46 | ) |
47 | 47 | ) |
48 | 48 | ) |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | // Add the list columns |
63 | 63 | foreach ( $list_fields as $list_field ) { |
64 | 64 | |
65 | - if( empty( $list_field->enableColumns ) ) { |
|
65 | + if ( empty( $list_field->enableColumns ) ) { |
|
66 | 66 | continue; |
67 | 67 | } |
68 | 68 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | // If there are columns, add them under the parent field |
86 | - if( ! empty( $list_columns ) ) { |
|
86 | + if ( ! empty( $list_columns ) ) { |
|
87 | 87 | |
88 | 88 | $index = array_search( $list_field->id, array_keys( $fields ) ) + 1; |
89 | 89 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * Merge the $list_columns into the $fields array at $index |
92 | 92 | * @see https://stackoverflow.com/a/1783125 |
93 | 93 | */ |
94 | - $fields = array_slice( $fields, 0, $index, true) + $list_columns + array_slice( $fields, $index, null, true); |
|
94 | + $fields = array_slice( $fields, 0, $index, true ) + $list_columns + array_slice( $fields, $index, null, true ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | unset( $list_columns, $index, $input_id ); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | $list_rows = maybe_unserialize( $field_value ); |
120 | 120 | |
121 | - if( ! is_array( $list_rows ) ) { |
|
121 | + if ( ! is_array( $list_rows ) ) { |
|
122 | 122 | do_action( 'gravityview_log_error', __METHOD__ . ' - $field_value did not unserialize', $field_value ); |
123 | 123 | return null; |
124 | 124 | } |
@@ -131,15 +131,15 @@ discard block |
||
131 | 131 | foreach ( $list_row as $column_key => $column_value ) { |
132 | 132 | |
133 | 133 | // If the label of the column matches $column_id, or the numeric key value matches, add the value |
134 | - if( (string)$column_key === (string)$column_id || ( is_numeric( $column_id ) && (int)$column_id === $current_column ) ) { |
|
135 | - $column_values[] = $column_value; |
|
134 | + if ( (string)$column_key === (string)$column_id || ( is_numeric( $column_id ) && (int)$column_id === $current_column ) ) { |
|
135 | + $column_values[ ] = $column_value; |
|
136 | 136 | } |
137 | 137 | $current_column++; |
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | 141 | // Return the array of values |
142 | - if( 'raw' === $format ) { |
|
142 | + if ( 'raw' === $format ) { |
|
143 | 143 | return $column_values; |
144 | 144 | } |
145 | 145 | // Return the Gravity Forms Field output |
@@ -162,22 +162,22 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function _filter_field_label( $label, $field, $form, $entry ) { |
164 | 164 | |
165 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
165 | + $field_object = RGFormsModel::get_field( $form, $field[ 'id' ] ); |
|
166 | 166 | |
167 | 167 | // Not a list field |
168 | - if( ! $field_object || 'list' !== $field_object->type ) { |
|
168 | + if ( ! $field_object || 'list' !== $field_object->type ) { |
|
169 | 169 | return $label; |
170 | 170 | } |
171 | 171 | |
172 | 172 | // Custom label is defined, so use it |
173 | - if( ! empty( $field['custom_label'] ) ) { |
|
173 | + if ( ! empty( $field[ 'custom_label' ] ) ) { |
|
174 | 174 | return $label; |
175 | 175 | } |
176 | 176 | |
177 | - $column_id = gravityview_get_input_id_from_id( $field['id'] ); |
|
177 | + $column_id = gravityview_get_input_id_from_id( $field[ 'id' ] ); |
|
178 | 178 | |
179 | 179 | // Parent field, not column field |
180 | - if( false === $column_id ) { |
|
180 | + if ( false === $column_id ) { |
|
181 | 181 | return $label; |
182 | 182 | } |
183 | 183 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | public static function get_column_label( GF_Field_List $field, $column_id, $backup_label = '' ) { |
199 | 199 | |
200 | 200 | // Doesn't have columns enabled |
201 | - if( ! isset( $field->choices ) || ! $field->enableColumns ) { |
|
201 | + if ( ! isset( $field->choices ) || ! $field->enableColumns ) { |
|
202 | 202 | return $backup_label; |
203 | 203 | } |
204 | 204 |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | |
21 | 21 | function __construct() { |
22 | 22 | |
23 | - add_action( 'media_buttons', array( $this, 'add_shortcode_button'), 30); |
|
23 | + add_action( 'media_buttons', array( $this, 'add_shortcode_button' ), 30 ); |
|
24 | 24 | |
25 | - add_action( 'admin_footer', array( $this, 'add_shortcode_popup') ); |
|
25 | + add_action( 'admin_footer', array( $this, 'add_shortcode_popup' ) ); |
|
26 | 26 | |
27 | 27 | // adding styles and scripts |
28 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') ); |
|
28 | + add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ) ); |
|
29 | 29 | |
30 | 30 | // ajax - populate sort fields based on the selected view |
31 | 31 | add_action( 'wp_ajax_gv_sortable_fields', array( $this, 'get_sortable_fields' ) ); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function is_post_editor_screen() { |
42 | 42 | global $current_screen, $pagenow; |
43 | - return !empty( $current_screen->post_type ) && 'gravityview' != $current_screen->post_type && in_array( $pagenow , array( 'post.php' , 'post-new.php' ) ); |
|
43 | + return ! empty( $current_screen->post_type ) && 'gravityview' != $current_screen->post_type && in_array( $pagenow, array( 'post.php', 'post-new.php' ) ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * @since 1.15.3 |
57 | 57 | */ |
58 | - if( ! GVCommon::has_cap( array( 'publish_gravityviews' ) ) ) { |
|
58 | + if ( ! GVCommon::has_cap( array( 'publish_gravityviews' ) ) ) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | - if( !$this->is_post_editor_screen() ) { |
|
62 | + if ( ! $this->is_post_editor_screen() ) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | ?> |
66 | - <a href="#TB_inline?width=600&height=800&inlineId=select_gravityview_view" class="thickbox hide-if-no-js button gform_media_link" id="add_gravityview" title="<?php esc_attr_e("Insert View", 'gravityview'); ?>"><span class="icon gv-icon-astronaut-head"></span><?php esc_html_e( 'Add View', 'gravityview' ); ?></a> |
|
66 | + <a href="#TB_inline?width=600&height=800&inlineId=select_gravityview_view" class="thickbox hide-if-no-js button gform_media_link" id="add_gravityview" title="<?php esc_attr_e( "Insert View", 'gravityview' ); ?>"><span class="icon gv-icon-astronaut-head"></span><?php esc_html_e( 'Add View', 'gravityview' ); ?></a> |
|
67 | 67 | <?php |
68 | 68 | |
69 | 69 | } |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | function add_shortcode_popup() { |
80 | 80 | global $post; |
81 | 81 | |
82 | - if( !$this->is_post_editor_screen() ) { |
|
82 | + if ( ! $this->is_post_editor_screen() ) { |
|
83 | 83 | return; |
84 | 84 | } |
85 | 85 | |
86 | - $post_type = get_post_type_object($post->post_type); |
|
86 | + $post_type = get_post_type_object( $post->post_type ); |
|
87 | 87 | |
88 | - $views = get_posts( array('post_type' => 'gravityview', 'posts_per_page' => -1 ) ); |
|
88 | + $views = get_posts( array( 'post_type' => 'gravityview', 'posts_per_page' => -1 ) ); |
|
89 | 89 | |
90 | 90 | // If there are no views set up yet, we get outta here. |
91 | - if( empty( $views ) ) { |
|
92 | - echo '<div id="select_gravityview_view"><div class="wrap">'. GravityView_Post_Types::no_views_text() .'</div></div>'; |
|
91 | + if ( empty( $views ) ) { |
|
92 | + echo '<div id="select_gravityview_view"><div class="wrap">' . GravityView_Post_Types::no_views_text() . '</div></div>'; |
|
93 | 93 | return; |
94 | 94 | } |
95 | 95 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | <div class="wrap"> |
100 | 100 | |
101 | 101 | <h2 class=""><?php esc_html_e( 'Embed a View', 'gravityview' ); ?></h2> |
102 | - <p class="subtitle"><?php printf( esc_attr ( __( 'Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s', 'gravityview') ), $post_type->labels->singular_name, '<a href="http://gravityview.co/support/documentation/202934188/" target="_blank">', '</a>' ); ?></p> |
|
102 | + <p class="subtitle"><?php printf( esc_attr( __( 'Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s', 'gravityview' ) ), $post_type->labels->singular_name, '<a href="http://gravityview.co/support/documentation/202934188/" target="_blank">', '</a>' ); ?></p> |
|
103 | 103 | |
104 | 104 | <div> |
105 | 105 | <h3><label for="gravityview_id"><?php esc_html_e( 'Select a View', 'gravityview' ); ?></label></h3> |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | <select name="gravityview_id" id="gravityview_id"> |
108 | 108 | <option value=""><?php esc_html_e( '— Select a View to Insert —', 'gravityview' ); ?></option> |
109 | 109 | <?php |
110 | - foreach( $views as $view ) { |
|
111 | - $title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title; |
|
112 | - echo '<option value="'. $view->ID .'">'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>'; |
|
110 | + foreach ( $views as $view ) { |
|
111 | + $title = empty( $view->post_title ) ? __( '(no title)', 'gravityview' ) : $view->post_title; |
|
112 | + echo '<option value="' . $view->ID . '">' . esc_html( sprintf( '%s #%d', $title, $view->ID ) ) . '</option>'; |
|
113 | 113 | } |
114 | 114 | ?> |
115 | 115 | </select> |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | foreach ( $settings as $key => $setting ) { |
127 | 127 | |
128 | - if( empty( $setting['show_in_shortcode'] ) ) { continue; } |
|
128 | + if ( empty( $setting[ 'show_in_shortcode' ] ) ) { continue; } |
|
129 | 129 | |
130 | 130 | GravityView_Render_Settings::render_setting_row( $key, array(), NULL, 'gravityview_%s', 'gravityview_%s' ); |
131 | 131 | } |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | </table> |
135 | 135 | |
136 | 136 | <div class="submit"> |
137 | - <input type="submit" class="button button-primary button-large alignleft hide-if-js" value="<?php esc_attr_e('Insert View', 'gravityview' ); ?>" id="insert_gravityview_view" /> |
|
138 | - <input class="button button-secondary alignright" type="submit" onclick="tb_remove(); return false;" value="<?php esc_attr_e("Cancel", 'gravityview'); ?>" /> |
|
137 | + <input type="submit" class="button button-primary button-large alignleft hide-if-js" value="<?php esc_attr_e( 'Insert View', 'gravityview' ); ?>" id="insert_gravityview_view" /> |
|
138 | + <input class="button button-secondary alignright" type="submit" onclick="tb_remove(); return false;" value="<?php esc_attr_e( "Cancel", 'gravityview' ); ?>" /> |
|
139 | 139 | </div> |
140 | 140 | |
141 | 141 | </div> |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | function add_scripts_and_styles() { |
158 | 158 | |
159 | - if( ! $this->is_post_editor_screen() ) { |
|
159 | + if ( ! $this->is_post_editor_screen() ) { |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
@@ -167,22 +167,22 @@ discard block |
||
167 | 167 | |
168 | 168 | $protocol = is_ssl() ? 'https://' : 'http://'; |
169 | 169 | |
170 | - wp_enqueue_style( 'jquery-ui-datepicker', $protocol.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(), GravityView_Plugin::version ); |
|
170 | + wp_enqueue_style( 'jquery-ui-datepicker', $protocol . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(), GravityView_Plugin::version ); |
|
171 | 171 | |
172 | 172 | //enqueue styles |
173 | - wp_register_style( 'gravityview_postedit_styles', plugins_url('assets/css/admin-post-edit.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
173 | + wp_register_style( 'gravityview_postedit_styles', plugins_url( 'assets/css/admin-post-edit.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
|
174 | 174 | wp_enqueue_style( 'gravityview_postedit_styles' ); |
175 | 175 | |
176 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
176 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
177 | 177 | |
178 | 178 | // custom js |
179 | - wp_register_script( 'gravityview_postedit_scripts', plugins_url('assets/js/admin-post-edit'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery', 'jquery-ui-datepicker' ), GravityView_Plugin::version ); |
|
179 | + wp_register_script( 'gravityview_postedit_scripts', plugins_url( 'assets/js/admin-post-edit' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery', 'jquery-ui-datepicker' ), GravityView_Plugin::version ); |
|
180 | 180 | wp_enqueue_script( 'gravityview_postedit_scripts' ); |
181 | - wp_localize_script('gravityview_postedit_scripts', 'gvGlobals', array( |
|
182 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxaddshortcode'), |
|
181 | + wp_localize_script( 'gravityview_postedit_scripts', 'gvGlobals', array( |
|
182 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxaddshortcode' ), |
|
183 | 183 | 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
184 | - 'alert_1' => esc_html__( 'Please select a View', 'gravityview'), |
|
185 | - )); |
|
184 | + 'alert_1' => esc_html__( 'Please select a View', 'gravityview' ), |
|
185 | + ) ); |
|
186 | 186 | |
187 | 187 | } |
188 | 188 | |
@@ -198,16 +198,16 @@ discard block |
||
198 | 198 | function get_sortable_fields() { |
199 | 199 | |
200 | 200 | // Not properly formatted request |
201 | - if ( empty( $_POST['viewid'] ) || !is_numeric( $_POST['viewid'] ) ) { |
|
201 | + if ( empty( $_POST[ 'viewid' ] ) || ! is_numeric( $_POST[ 'viewid' ] ) ) { |
|
202 | 202 | exit( false ); |
203 | 203 | } |
204 | 204 | |
205 | 205 | // Not valid request |
206 | - if( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxaddshortcode' ) ) { |
|
206 | + if ( empty( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxaddshortcode' ) ) { |
|
207 | 207 | exit( false ); |
208 | 208 | } |
209 | 209 | |
210 | - $viewid = (int)$_POST['viewid']; |
|
210 | + $viewid = (int)$_POST[ 'viewid' ]; |
|
211 | 211 | |
212 | 212 | // fetch form id assigned to the view |
213 | 213 | $formid = gravityview_get_form_id( $viewid ); |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | /** @var WP_Admin_Bar $wp_admin_bar */ |
39 | 39 | global $wp_admin_bar; |
40 | 40 | |
41 | - if( is_admin() ) { |
|
41 | + if ( is_admin() ) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | |
45 | 45 | $view_data = GravityView_View_Data::getInstance()->get_views(); |
46 | 46 | |
47 | - if( empty( $view_data ) ) { |
|
47 | + if ( empty( $view_data ) ) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | 'parent' => 'gravityview', |
105 | 105 | 'title' => __( 'Edit Entry', 'gravityview' ), |
106 | 106 | 'meta' => array( |
107 | - 'title' => sprintf( __( 'Edit Entry %s', 'gravityview' ), GravityView_API::get_entry_slug( $entry['id'], $entry ) ), |
|
107 | + 'title' => sprintf( __( 'Edit Entry %s', 'gravityview' ), GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ) ), |
|
108 | 108 | ), |
109 | - 'href' => esc_url_raw( admin_url( sprintf( 'admin.php?page=gf_entries&screen_mode=edit&view=entry&id=%d&lid=%d', $entry['form_id'], $entry['id'] ) ) ), |
|
109 | + 'href' => esc_url_raw( admin_url( sprintf( 'admin.php?page=gf_entries&screen_mode=edit&view=entry&id=%d&lid=%d', $entry[ 'form_id' ], $entry[ 'id' ] ) ) ), |
|
110 | 110 | ) ); |
111 | 111 | |
112 | 112 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | /** @var WP_Admin_Bar $wp_admin_bar */ |
123 | 123 | global $wp_admin_bar; |
124 | 124 | |
125 | - if( GVCommon::has_cap( array( 'edit_gravityviews', 'edit_gravityview', 'gravityforms_edit_forms' ) ) ) { |
|
125 | + if ( GVCommon::has_cap( array( 'edit_gravityviews', 'edit_gravityview', 'gravityforms_edit_forms' ) ) ) { |
|
126 | 126 | |
127 | 127 | $view_data = GravityView_View_Data::getInstance(); |
128 | 128 | |
@@ -139,32 +139,32 @@ discard block |
||
139 | 139 | $edit_view_title = __( 'Edit View', 'gravityview' ); |
140 | 140 | $edit_form_title = __( 'Edit Form', 'gravityview' ); |
141 | 141 | |
142 | - if( sizeof( $views ) > 1 ) { |
|
143 | - $edit_view_title = sprintf( _x( 'Edit View #%d', 'Edit View with the ID of %d', 'gravityview' ), $view['id'] ); |
|
144 | - $edit_form_title = sprintf( __( 'Edit Form #%d', 'Edit Form with the ID of %d', 'gravityview' ), $view['form_id'] ); |
|
142 | + if ( sizeof( $views ) > 1 ) { |
|
143 | + $edit_view_title = sprintf( _x( 'Edit View #%d', 'Edit View with the ID of %d', 'gravityview' ), $view[ 'id' ] ); |
|
144 | + $edit_form_title = sprintf( __( 'Edit Form #%d', 'Edit Form with the ID of %d', 'gravityview' ), $view[ 'form_id' ] ); |
|
145 | 145 | } |
146 | 146 | |
147 | - if( GVCommon::has_cap( 'edit_gravityview', $view['id'] ) && ! in_array( $view['id'], $added_views ) ) { |
|
147 | + if ( GVCommon::has_cap( 'edit_gravityview', $view[ 'id' ] ) && ! in_array( $view[ 'id' ], $added_views ) ) { |
|
148 | 148 | |
149 | - $added_views[] = $view['id']; |
|
149 | + $added_views[ ] = $view[ 'id' ]; |
|
150 | 150 | |
151 | 151 | $wp_admin_bar->add_menu( array( |
152 | - 'id' => 'edit-view-' . $view['id'], |
|
152 | + 'id' => 'edit-view-' . $view[ 'id' ], |
|
153 | 153 | 'parent' => 'gravityview', |
154 | 154 | 'title' => $edit_view_title, |
155 | - 'href' => esc_url_raw( admin_url( sprintf( 'post.php?post=%d&action=edit', $view['id'] ) ) ), |
|
155 | + 'href' => esc_url_raw( admin_url( sprintf( 'post.php?post=%d&action=edit', $view[ 'id' ] ) ) ), |
|
156 | 156 | ) ); |
157 | 157 | } |
158 | 158 | |
159 | - if ( ! empty( $view['form_id'] ) && GVCommon::has_cap( array( 'gravityforms_edit_forms' ), $view['form_id'] ) && ! in_array( $view['form_id'], $added_forms ) ) { |
|
159 | + if ( ! empty( $view[ 'form_id' ] ) && GVCommon::has_cap( array( 'gravityforms_edit_forms' ), $view[ 'form_id' ] ) && ! in_array( $view[ 'form_id' ], $added_forms ) ) { |
|
160 | 160 | |
161 | - $added_forms[] = $view['form_id']; |
|
161 | + $added_forms[ ] = $view[ 'form_id' ]; |
|
162 | 162 | |
163 | 163 | $wp_admin_bar->add_menu( array( |
164 | - 'id' => 'edit-form-' . $view['form_id'], |
|
164 | + 'id' => 'edit-form-' . $view[ 'form_id' ], |
|
165 | 165 | 'parent' => 'gravityview', |
166 | 166 | 'title' => $edit_form_title, |
167 | - 'href' => esc_url_raw( admin_url( sprintf( 'admin.php?page=gf_edit_forms&id=%d', $view['form_id'] ) ) ), |
|
167 | + 'href' => esc_url_raw( admin_url( sprintf( 'admin.php?page=gf_edit_forms&id=%d', $view[ 'form_id' ] ) ) ), |
|
168 | 168 | ) ); |
169 | 169 | } |
170 | 170 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return GV_License_Handler |
41 | 41 | */ |
42 | 42 | public static function get_instance( GravityView_Settings $GFAddOn ) { |
43 | - if( empty( self::$instance ) ) { |
|
43 | + if ( empty( self::$instance ) ) { |
|
44 | 44 | self::$instance = new self( $GFAddOn ); |
45 | 45 | } |
46 | 46 | return self::$instance; |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | public function refresh_license_status() { |
71 | 71 | |
72 | 72 | // Only perform on GravityView pages |
73 | - if( ! gravityview_is_admin_page() ) { |
|
73 | + if ( ! gravityview_is_admin_page() ) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
77 | 77 | // The transient is fresh; don't fetch. |
78 | - if( $status = get_transient( self::status_transient_key ) ) { |
|
78 | + if ( $status = get_transient( self::status_transient_key ) ) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
@@ -100,37 +100,37 @@ discard block |
||
100 | 100 | $status = trim( $this->Addon->get_app_setting( 'license_key_status' ) ); |
101 | 101 | $key = trim( $this->Addon->get_app_setting( 'license_key' ) ); |
102 | 102 | |
103 | - if( !empty( $key ) ) { |
|
103 | + if ( ! empty( $key ) ) { |
|
104 | 104 | $response = $this->Addon->get_app_setting( 'license_key_response' ); |
105 | - $response = is_array( $response ) ? (object) $response : json_decode( $response ); |
|
105 | + $response = is_array( $response ) ? (object)$response : json_decode( $response ); |
|
106 | 106 | } else { |
107 | 107 | $response = array(); |
108 | 108 | } |
109 | 109 | |
110 | 110 | wp_localize_script( 'gv-admin-edd-license', 'GVGlobals', array( |
111 | 111 | 'license_box' => $this->get_license_message( $response ) |
112 | - )); |
|
112 | + ) ); |
|
113 | 113 | |
114 | 114 | |
115 | 115 | $fields = array( |
116 | 116 | array( |
117 | 117 | 'name' => 'edd-activate', |
118 | - 'value' => __('Activate License', 'gravityview'), |
|
119 | - 'data-pending_text' => __('Verifying license…', 'gravityview'), |
|
118 | + 'value' => __( 'Activate License', 'gravityview' ), |
|
119 | + 'data-pending_text' => __( 'Verifying license…', 'gravityview' ), |
|
120 | 120 | 'data-edd_action' => 'activate_license', |
121 | 121 | 'class' => 'button-primary', |
122 | 122 | ), |
123 | 123 | array( |
124 | 124 | 'name' => 'edd-deactivate', |
125 | - 'value' => __('Deactivate License', 'gravityview'), |
|
126 | - 'data-pending_text' => __('Deactivating license…', 'gravityview'), |
|
125 | + 'value' => __( 'Deactivate License', 'gravityview' ), |
|
126 | + 'data-pending_text' => __( 'Deactivating license…', 'gravityview' ), |
|
127 | 127 | 'data-edd_action' => 'deactivate_license', |
128 | 128 | 'class' => ( empty( $status ) ? 'button-primary hide' : 'button-primary' ), |
129 | 129 | ), |
130 | 130 | array( |
131 | 131 | 'name' => 'edd-check', |
132 | - 'value' => __('Check License', 'gravityview'), |
|
133 | - 'data-pending_text' => __('Verifying license…', 'gravityview'), |
|
132 | + 'value' => __( 'Check License', 'gravityview' ), |
|
133 | + 'data-pending_text' => __( 'Verifying license…', 'gravityview' ), |
|
134 | 134 | 'title' => 'Check the license before saving it', |
135 | 135 | 'data-edd_action' => 'check_license', |
136 | 136 | 'class' => 'button-secondary', |
@@ -140,17 +140,17 @@ discard block |
||
140 | 140 | |
141 | 141 | $class = 'button gv-edd-action'; |
142 | 142 | |
143 | - $class .= ( !empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
143 | + $class .= ( ! empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
144 | 144 | |
145 | 145 | $disabled_attribute = GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled'; |
146 | 146 | |
147 | 147 | $submit = '<div class="gv-edd-button-wrapper">'; |
148 | 148 | foreach ( $fields as $field ) { |
149 | - $field['type'] = 'button'; |
|
150 | - $field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class; |
|
151 | - $field['style'] = 'margin-left: 10px;'; |
|
152 | - if( $disabled_attribute ) { |
|
153 | - $field['disabled'] = $disabled_attribute; |
|
149 | + $field[ 'type' ] = 'button'; |
|
150 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] . ' ' . $class : $class; |
|
151 | + $field[ 'style' ] = 'margin-left: 10px;'; |
|
152 | + if ( $disabled_attribute ) { |
|
153 | + $field[ 'disabled' ] = $disabled_attribute; |
|
154 | 154 | } |
155 | 155 | $submit .= $this->Addon->settings_submit( $field, $echo ); |
156 | 156 | } |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | */ |
167 | 167 | private function setup_edd() { |
168 | 168 | |
169 | - if( !class_exists('EDD_SL_Plugin_Updater') ) { |
|
170 | - require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php'); |
|
169 | + if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
170 | + require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php' ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // setup the updater |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | 'url' => home_url(), |
205 | 205 | ); |
206 | 206 | |
207 | - if( !empty( $action ) ) { |
|
208 | - $settings['edd_action'] = esc_attr( $action ); |
|
207 | + if ( ! empty( $action ) ) { |
|
208 | + $settings[ 'edd_action' ] = esc_attr( $action ); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | $settings = array_map( 'urlencode', $settings ); |
@@ -219,14 +219,14 @@ discard block |
||
219 | 219 | */ |
220 | 220 | private function _license_get_remote_response( $data, $license = '' ) { |
221 | 221 | |
222 | - $api_params = $this->_get_edd_settings( $data['edd_action'], $license ); |
|
222 | + $api_params = $this->_get_edd_settings( $data[ 'edd_action' ], $license ); |
|
223 | 223 | |
224 | 224 | $url = add_query_arg( $api_params, self::url ); |
225 | 225 | |
226 | 226 | $response = wp_remote_get( $url, array( |
227 | 227 | 'timeout' => 15, |
228 | 228 | 'sslverify' => false, |
229 | - )); |
|
229 | + ) ); |
|
230 | 230 | |
231 | 231 | if ( is_wp_error( $response ) ) { |
232 | 232 | return array(); |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | */ |
260 | 260 | function get_license_message( $license_data ) { |
261 | 261 | |
262 | - if( empty( $license_data ) ) { |
|
262 | + if ( empty( $license_data ) ) { |
|
263 | 263 | $message = ''; |
264 | 264 | } else { |
265 | 265 | |
266 | - if( ! empty( $license_data->error ) ) { |
|
266 | + if ( ! empty( $license_data->error ) ) { |
|
267 | 267 | $class = 'error'; |
268 | 268 | $string_key = $license_data->error; |
269 | 269 | } else { |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $string_key = $license_data->license; |
272 | 272 | } |
273 | 273 | |
274 | - $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings( $string_key, $license_data ) ); |
|
274 | + $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings( 'status' ), $this->strings( $string_key, $license_data ) ); |
|
275 | 275 | |
276 | 276 | $message = $this->generate_license_box( $message, $class ); |
277 | 277 | } |
@@ -308,15 +308,15 @@ discard block |
||
308 | 308 | */ |
309 | 309 | public function license_details( $response = array() ) { |
310 | 310 | |
311 | - $response = (array) $response; |
|
311 | + $response = (array)$response; |
|
312 | 312 | |
313 | 313 | $return = ''; |
314 | 314 | $return .= '<span class="gv-license-details" aria-live="polite" aria-busy="false">'; |
315 | 315 | $return .= '<h3>' . esc_html__( 'License Details:', 'gravityview' ) . '</h3>'; |
316 | 316 | |
317 | - if( in_array( rgar( $response, 'license' ), array( 'invalid', 'deactivated' ) ) ) { |
|
318 | - $return .= $this->strings( $response['license'], $response ); |
|
319 | - } elseif( ! empty( $response['license_name'] ) ) { |
|
317 | + if ( in_array( rgar( $response, 'license' ), array( 'invalid', 'deactivated' ) ) ) { |
|
318 | + $return .= $this->strings( $response[ 'license' ], $response ); |
|
319 | + } elseif ( ! empty( $response[ 'license_name' ] ) ) { |
|
320 | 320 | |
321 | 321 | $response_keys = array( |
322 | 322 | 'license_name' => '', |
@@ -331,19 +331,19 @@ discard block |
||
331 | 331 | // Make sure all the keys are set |
332 | 332 | $response = wp_parse_args( $response, $response_keys ); |
333 | 333 | |
334 | - $login_link = sprintf( '<a href="%s" class="howto" rel="external">%s</a>', esc_url( sprintf( 'https://gravityview.co/wp-login.php?username=%s', $response['customer_email'] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) ); |
|
335 | - $local_text = ( ! empty( $response['is_local'] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
334 | + $login_link = sprintf( '<a href="%s" class="howto" rel="external">%s</a>', esc_url( sprintf( 'https://gravityview.co/wp-login.php?username=%s', $response[ 'customer_email' ] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) ); |
|
335 | + $local_text = ( ! empty( $response[ 'is_local' ] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
336 | 336 | $details = array( |
337 | - 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), esc_html( $response['license_name'] ), esc_html( $response['license_limit'] ) ), |
|
338 | - 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), esc_html__( $response['customer_name'], 'gravityview' ), esc_html__( $response['customer_email'], 'gravityview' ) ) . $login_link, |
|
339 | - 'activations' => sprintf( esc_html__( 'Activations: %d of %s sites', 'gravityview' ), intval( $response['site_count'] ), esc_html( $response['license_limit'] ) ) . $local_text, |
|
340 | - 'expires' => sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response['expires'] ) - DAY_IN_SECONDS ) ), |
|
341 | - 'upgrade' => $this->get_upgrade_html( $response['upgrades'] ), |
|
337 | + 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), esc_html( $response[ 'license_name' ] ), esc_html( $response[ 'license_limit' ] ) ), |
|
338 | + 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), esc_html__( $response[ 'customer_name' ], 'gravityview' ), esc_html__( $response[ 'customer_email' ], 'gravityview' ) ) . $login_link, |
|
339 | + 'activations' => sprintf( esc_html__( 'Activations: %d of %s sites', 'gravityview' ), intval( $response[ 'site_count' ] ), esc_html( $response[ 'license_limit' ] ) ) . $local_text, |
|
340 | + 'expires' => sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response[ 'expires' ] ) - DAY_IN_SECONDS ) ), |
|
341 | + 'upgrade' => $this->get_upgrade_html( $response[ 'upgrades' ] ), |
|
342 | 342 | ); |
343 | 343 | |
344 | - if ( ! empty( $response['error'] ) && 'expired' === $response['error'] ) { |
|
345 | - unset( $details['upgrade'] ); |
|
346 | - $details['expires'] = '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
344 | + if ( ! empty( $response[ 'error' ] ) && 'expired' === $response[ 'error' ] ) { |
|
345 | + unset( $details[ 'upgrade' ] ); |
|
346 | + $details[ 'expires' ] = '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | $return .= '<ul><li>' . implode( '</li><li>', array_filter( $details ) ) . '</li></ul>'; |
@@ -367,11 +367,11 @@ discard block |
||
367 | 367 | |
368 | 368 | $output = ''; |
369 | 369 | |
370 | - if( ! empty( $upgrades ) ) { |
|
370 | + if ( ! empty( $upgrades ) ) { |
|
371 | 371 | |
372 | 372 | $locale_parts = explode( '_', get_locale() ); |
373 | 373 | |
374 | - $is_english = ( 'en' === $locale_parts[0] ); |
|
374 | + $is_english = ( 'en' === $locale_parts[ 0 ] ); |
|
375 | 375 | |
376 | 376 | $output .= '<h4>' . esc_html__( 'Upgrades available:', 'gravityview' ) . '</h4>'; |
377 | 377 | |
@@ -379,14 +379,14 @@ discard block |
||
379 | 379 | |
380 | 380 | foreach ( $upgrades as $upgrade_id => $upgrade ) { |
381 | 381 | |
382 | - $upgrade = (object) $upgrade; |
|
382 | + $upgrade = (object)$upgrade; |
|
383 | 383 | |
384 | 384 | $anchor_text = sprintf( esc_html_x( 'Upgrade to %1$s for %2$s', '1: GravityView upgrade name, 2: Cost of upgrade', 'gravityview' ), esc_attr( $upgrade->name ), esc_attr( $upgrade->price ) ); |
385 | 385 | |
386 | - if( $is_english && isset( $upgrade->description ) ) { |
|
386 | + if ( $is_english && isset( $upgrade->description ) ) { |
|
387 | 387 | $message = esc_html( $upgrade->description ); |
388 | 388 | } else { |
389 | - switch( $upgrade->price_id ) { |
|
389 | + switch ( $upgrade->price_id ) { |
|
390 | 390 | // Interstellar |
391 | 391 | case 1: |
392 | 392 | default: |
@@ -424,16 +424,16 @@ discard block |
||
424 | 424 | */ |
425 | 425 | public function license_call( $array = array() ) { |
426 | 426 | |
427 | - $is_ajax = ( defined('DOING_AJAX') && DOING_AJAX ); |
|
428 | - $data = empty( $array ) ? $_POST['data'] : $array; |
|
427 | + $is_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
428 | + $data = empty( $array ) ? $_POST[ 'data' ] : $array; |
|
429 | 429 | $has_cap = GVCommon::has_cap( 'gravityview_edit_settings' ); |
430 | 430 | |
431 | - if ( $is_ajax && empty( $data['license'] ) ) { |
|
432 | - die( - 1 ); |
|
431 | + if ( $is_ajax && empty( $data[ 'license' ] ) ) { |
|
432 | + die( -1 ); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | // If the user isn't allowed to edit settings, show an error message |
436 | - if( ! $has_cap ) { |
|
436 | + if ( ! $has_cap ) { |
|
437 | 437 | $license_data = new stdClass(); |
438 | 438 | $license_data->error = 'capability'; |
439 | 439 | $license_data->message = $this->get_license_message( $license_data ); |
@@ -457,9 +457,9 @@ discard block |
||
457 | 457 | |
458 | 458 | $json = json_encode( $license_data ); |
459 | 459 | |
460 | - $update_license = ( ! isset( $data['update'] ) || ! empty( $data['update'] ) ); |
|
460 | + $update_license = ( ! isset( $data[ 'update' ] ) || ! empty( $data[ 'update' ] ) ); |
|
461 | 461 | |
462 | - $is_check_action_button = ( 'check_license' === $data['edd_action'] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
462 | + $is_check_action_button = ( 'check_license' === $data[ 'edd_action' ] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
463 | 463 | |
464 | 464 | // Failed is the response from trying to de-activate a license and it didn't work. |
465 | 465 | // This likely happened because people entered in a different key and clicked "Deactivate", |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | // most likely a mistake. |
468 | 468 | if ( $license_data->license !== 'failed' && ! $is_check_action_button && $update_license ) { |
469 | 469 | |
470 | - if ( ! empty( $data['field_id'] ) ) { |
|
470 | + if ( ! empty( $data[ 'field_id' ] ) ) { |
|
471 | 471 | set_transient( self::status_transient_key, $license_data, DAY_IN_SECONDS ); |
472 | 472 | } |
473 | 473 | |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | if ( $is_ajax ) { |
479 | 479 | exit( $json ); |
480 | 480 | } else { // Non-ajax call |
481 | - return ( rgget('format', $data ) === 'object' ) ? $license_data : $json; |
|
481 | + return ( rgget( 'format', $data ) === 'object' ) ? $license_data : $json; |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
@@ -492,9 +492,9 @@ discard block |
||
492 | 492 | // Update option with passed data license |
493 | 493 | $settings = $this->Addon->get_app_settings(); |
494 | 494 | |
495 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
496 | - $settings['license_key_status'] = $license_data->license; |
|
497 | - $settings['license_key_response'] = (array)$license_data; |
|
495 | + $settings[ 'license_key' ] = $license_data->license_key = trim( $data[ 'license' ] ); |
|
496 | + $settings[ 'license_key_status' ] = $license_data->license; |
|
497 | + $settings[ 'license_key_response' ] = (array)$license_data; |
|
498 | 498 | |
499 | 499 | $this->Addon->update_app_settings( $settings ); |
500 | 500 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | */ |
508 | 508 | private function get_license_renewal_url( $license_data ) { |
509 | 509 | $license_data = is_array( $license_data ) ? (object)$license_data : $license_data; |
510 | - $renew_license_url = ( ! empty( $license_data ) && !empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation&force_login=1', $license_data->license_key ) : 'https://gravityview.co/account/'; |
|
510 | + $renew_license_url = ( ! empty( $license_data ) && ! empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation&force_login=1', $license_data->license_key ) : 'https://gravityview.co/account/'; |
|
511 | 511 | return $renew_license_url; |
512 | 512 | } |
513 | 513 | |
@@ -522,31 +522,31 @@ discard block |
||
522 | 522 | |
523 | 523 | |
524 | 524 | $strings = array( |
525 | - 'status' => esc_html__('Status', 'gravityview'), |
|
526 | - 'error' => esc_html__('There was an error processing the request.', 'gravityview'), |
|
527 | - 'failed' => esc_html__('Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview'), |
|
528 | - 'site_inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), |
|
529 | - 'inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), |
|
530 | - 'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview') . ' ' . sprintf( esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
531 | - 'deactivated' => esc_html__('The license has been deactivated.', 'gravityview'), |
|
532 | - 'valid' => esc_html__('The license key is valid and active.', 'gravityview'), |
|
533 | - 'invalid' => esc_html__('The license key entered is invalid.', 'gravityview'), |
|
534 | - 'missing' => esc_html__('Invalid license key.', 'gravityview'), |
|
535 | - 'revoked' => esc_html__('This license key has been revoked.', 'gravityview'), |
|
536 | - 'expired' => sprintf( esc_html__('This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview'), '<a href="'. esc_url( $this->get_license_renewal_url( $license_data ) ) .'">', '</a>' ), |
|
525 | + 'status' => esc_html__( 'Status', 'gravityview' ), |
|
526 | + 'error' => esc_html__( 'There was an error processing the request.', 'gravityview' ), |
|
527 | + 'failed' => esc_html__( 'Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview' ), |
|
528 | + 'site_inactive' => esc_html__( 'The license key is valid, but it has not been activated for this site.', 'gravityview' ), |
|
529 | + 'inactive' => esc_html__( 'The license key is valid, but it has not been activated for this site.', 'gravityview' ), |
|
530 | + 'no_activations_left' => esc_html__( 'Invalid: this license has reached its activation limit.', 'gravityview' ) . ' ' . sprintf( esc_html__( 'You can manage license activations %son your GravityView account page%s.', 'gravityview' ), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
531 | + 'deactivated' => esc_html__( 'The license has been deactivated.', 'gravityview' ), |
|
532 | + 'valid' => esc_html__( 'The license key is valid and active.', 'gravityview' ), |
|
533 | + 'invalid' => esc_html__( 'The license key entered is invalid.', 'gravityview' ), |
|
534 | + 'missing' => esc_html__( 'Invalid license key.', 'gravityview' ), |
|
535 | + 'revoked' => esc_html__( 'This license key has been revoked.', 'gravityview' ), |
|
536 | + 'expired' => sprintf( esc_html__( 'This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview' ), '<a href="' . esc_url( $this->get_license_renewal_url( $license_data ) ) . '">', '</a>' ), |
|
537 | 537 | 'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ), |
538 | 538 | |
539 | - 'verifying_license' => esc_html__('Verifying license…', 'gravityview'), |
|
540 | - 'activate_license' => esc_html__('Activate License', 'gravityview'), |
|
541 | - 'deactivate_license' => esc_html__('Deactivate License', 'gravityview'), |
|
542 | - 'check_license' => esc_html__('Verify License', 'gravityview'), |
|
539 | + 'verifying_license' => esc_html__( 'Verifying license…', 'gravityview' ), |
|
540 | + 'activate_license' => esc_html__( 'Activate License', 'gravityview' ), |
|
541 | + 'deactivate_license' => esc_html__( 'Deactivate License', 'gravityview' ), |
|
542 | + 'check_license' => esc_html__( 'Verify License', 'gravityview' ), |
|
543 | 543 | ); |
544 | 544 | |
545 | - if( empty( $status ) ) { |
|
545 | + if ( empty( $status ) ) { |
|
546 | 546 | return $strings; |
547 | 547 | } |
548 | 548 | |
549 | - if( isset( $strings[ $status ] ) ) { |
|
549 | + if ( isset( $strings[ $status ] ) ) { |
|
550 | 550 | return $strings[ $status ]; |
551 | 551 | } |
552 | 552 |
@@ -36,7 +36,6 @@ |
||
36 | 36 | * @since 1.16.4 |
37 | 37 | * @since 1.17 Moved to GravityView_Plugin_Hooks_Gravity_Forms_Survey class |
38 | 38 | * |
39 | - * @param array $form |
|
40 | 39 | * |
41 | 40 | * @return array Form, with all fields set to `allowsPrepopulate => true` |
42 | 41 | */ |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | public function fix_survey_fields( $fields ) { |
44 | 44 | |
45 | 45 | /** @var GF_Field $field */ |
46 | - foreach( $fields as &$field ) { |
|
47 | - if( 'survey' === $field->type ) { |
|
46 | + foreach ( $fields as &$field ) { |
|
47 | + if ( 'survey' === $field->type ) { |
|
48 | 48 | $field->allowsPrepopulate = true; |
49 | 49 | } |
50 | 50 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return void |
61 | 61 | */ |
62 | 62 | function add_render_hooks() { |
63 | - add_filter( 'gform_field_value', array( $this, 'fix_survey_field_value'), 10, 3 ); |
|
63 | + add_filter( 'gform_field_value', array( $this, 'fix_survey_field_value' ), 10, 3 ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @return void |
74 | 74 | */ |
75 | 75 | function remove_render_hooks() { |
76 | - remove_filter( 'gform_field_value', array( $this, 'fix_survey_field_value'), 10 ); |
|
76 | + remove_filter( 'gform_field_value', array( $this, 'fix_survey_field_value' ), 10 ); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function fix_survey_field_value( $value, $field, $name ) { |
93 | 93 | |
94 | - if( 'survey' === $field->type ) { |
|
94 | + if ( 'survey' === $field->type ) { |
|
95 | 95 | |
96 | - $entry = GravityView_Edit_Entry::getInstance()->instances['render']->get_entry(); |
|
96 | + $entry = GravityView_Edit_Entry::getInstance()->instances[ 'render' ]->get_entry(); |
|
97 | 97 | |
98 | 98 | // We need to run through each survey row until we find a match for expected values |
99 | 99 | foreach ( $entry as $field_id => $field_value ) { |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | continue; |
103 | 103 | } |
104 | 104 | |
105 | - if( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) { |
|
105 | + if ( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) { |
|
106 | 106 | list( $row_val, $col_val ) = explode( ':', $field_value, 2 ); |
107 | 107 | |
108 | 108 | // If the $name matches the $row_val, we are processing the correct row |
109 | - if( $row_val === $name ) { |
|
109 | + if ( $row_val === $name ) { |
|
110 | 110 | $value = $field_value; |
111 | 111 | break; |
112 | 112 | } |
@@ -7,133 +7,133 @@ |
||
7 | 7 | |
8 | 8 | class GravityView_GFFormsModel extends GFFormsModel { |
9 | 9 | |
10 | - /** |
|
11 | - * Given information provided in an entry, get array of media IDs |
|
12 | - * |
|
13 | - * This is necessary because GF doesn't expect to need to update post images, only to create them. |
|
14 | - * |
|
15 | - * @see GFFormsModel::create_post() |
|
16 | - * |
|
17 | - * @since 1.17 |
|
18 | - * |
|
19 | - * @param array $form Gravity Forms form array |
|
20 | - * @param array $entry Gravity Forms entry array |
|
21 | - * |
|
22 | - * @return array Array of "Field ID" => "Media IDs" |
|
23 | - */ |
|
24 | - public static function get_post_field_images( $form, $entry ) { |
|
25 | - |
|
26 | - $post_data = self::get_post_fields( $form, $entry ); |
|
27 | - |
|
28 | - $media = get_attached_media( 'image', $entry['post_id'] ); |
|
29 | - |
|
30 | - $post_images = array(); |
|
31 | - |
|
32 | - foreach ( $media as $media_item ) { |
|
33 | - foreach( (array) $post_data['images'] as $post_data_item ) { |
|
34 | - if( |
|
35 | - rgar( $post_data_item, 'title' ) === $media_item->post_title && |
|
36 | - rgar( $post_data_item, 'description' ) === $media_item->post_content && |
|
37 | - rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
|
38 | - ) { |
|
39 | - $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
40 | - } |
|
41 | - } |
|
42 | - } |
|
43 | - |
|
44 | - return $post_images; |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Alias of GFFormsModel::get_post_fields(); just making it public |
|
49 | - * |
|
50 | - * @see GFFormsModel::get_post_fields() |
|
51 | - * |
|
52 | - * @since 1.17 |
|
53 | - * |
|
54 | - * @param array $form Gravity Forms form array |
|
55 | - * @param array $entry Gravity Forms entry array |
|
56 | - * |
|
57 | - * @return array |
|
58 | - */ |
|
59 | - public static function get_post_fields( $form, $entry ) { |
|
60 | - |
|
61 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'get_post_fields' ); |
|
62 | - |
|
63 | - /** |
|
64 | - * If the method changes to public, use Gravity Forms' method |
|
65 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
66 | - */ |
|
67 | - if( $reflection->isPublic() ) { |
|
68 | - return parent::get_post_fields( $form, $entry ); |
|
69 | - } |
|
70 | - |
|
71 | - // It was private; let's make it public |
|
72 | - $reflection->setAccessible( true ); |
|
73 | - |
|
74 | - return $reflection->invoke( new GFFormsModel, $form, $entry ); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private. |
|
79 | - * |
|
80 | - * @since 1.16.2 |
|
81 | - * |
|
82 | - * @param string $url URL of the post image to update |
|
83 | - * @param int $post_id ID of the post image to update |
|
84 | - * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path. |
|
85 | - */ |
|
86 | - public static function copy_post_image( $url, $post_id ) { |
|
87 | - |
|
88 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' ); |
|
89 | - |
|
90 | - /** |
|
91 | - * If the method changes to public, use Gravity Forms' method |
|
92 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
93 | - */ |
|
94 | - if( $reflection->isPublic() ) { |
|
95 | - return parent::copy_post_image( $url, $post_id ); |
|
96 | - } |
|
97 | - |
|
98 | - // It was private; let's make it public |
|
99 | - $reflection->setAccessible( true ); |
|
100 | - |
|
101 | - return $reflection->invoke( new GFFormsModel, $url, $post_id ); |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private. |
|
106 | - * |
|
107 | - * Note: The method became public in GF 1.9.17.7 |
|
108 | - * |
|
109 | - * @see GFFormsModel::media_handle_upload |
|
110 | - * @see GravityView_Edit_Entry_Render::maybe_update_post_fields |
|
111 | - * |
|
112 | - * @uses copy_post_image |
|
113 | - * @uses wp_insert_attachment |
|
114 | - * @uses wp_update_attachment_metadata |
|
115 | - * |
|
116 | - * @param string $url URL of the post image to update |
|
117 | - * @param int $post_id ID of the post image to update |
|
118 | - * @param array $post_data Array of data for the eventual attachment post type that is created using {@see wp_insert_attachment}. Supports `post_mime_type`, `guid`, `post_parent`, `post_title`, `post_content` keys. |
|
119 | - * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image |
|
120 | - */ |
|
121 | - public static function media_handle_upload( $url, $post_id, $post_data = array() ) { |
|
122 | - |
|
123 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' ); |
|
124 | - |
|
125 | - /** |
|
126 | - * If the method changes to public, use Gravity Forms' method |
|
127 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
128 | - */ |
|
129 | - if( $reflection->isPublic() ) { |
|
130 | - return parent::media_handle_upload( $url, $post_id, $post_data ); |
|
131 | - } |
|
132 | - |
|
133 | - // It was private; let's make it public |
|
134 | - $reflection->setAccessible( true ); |
|
135 | - |
|
136 | - return $reflection->invoke( new GFFormsModel, $url, $post_id, $post_data ); |
|
137 | - } |
|
10 | + /** |
|
11 | + * Given information provided in an entry, get array of media IDs |
|
12 | + * |
|
13 | + * This is necessary because GF doesn't expect to need to update post images, only to create them. |
|
14 | + * |
|
15 | + * @see GFFormsModel::create_post() |
|
16 | + * |
|
17 | + * @since 1.17 |
|
18 | + * |
|
19 | + * @param array $form Gravity Forms form array |
|
20 | + * @param array $entry Gravity Forms entry array |
|
21 | + * |
|
22 | + * @return array Array of "Field ID" => "Media IDs" |
|
23 | + */ |
|
24 | + public static function get_post_field_images( $form, $entry ) { |
|
25 | + |
|
26 | + $post_data = self::get_post_fields( $form, $entry ); |
|
27 | + |
|
28 | + $media = get_attached_media( 'image', $entry['post_id'] ); |
|
29 | + |
|
30 | + $post_images = array(); |
|
31 | + |
|
32 | + foreach ( $media as $media_item ) { |
|
33 | + foreach( (array) $post_data['images'] as $post_data_item ) { |
|
34 | + if( |
|
35 | + rgar( $post_data_item, 'title' ) === $media_item->post_title && |
|
36 | + rgar( $post_data_item, 'description' ) === $media_item->post_content && |
|
37 | + rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
|
38 | + ) { |
|
39 | + $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
40 | + } |
|
41 | + } |
|
42 | + } |
|
43 | + |
|
44 | + return $post_images; |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Alias of GFFormsModel::get_post_fields(); just making it public |
|
49 | + * |
|
50 | + * @see GFFormsModel::get_post_fields() |
|
51 | + * |
|
52 | + * @since 1.17 |
|
53 | + * |
|
54 | + * @param array $form Gravity Forms form array |
|
55 | + * @param array $entry Gravity Forms entry array |
|
56 | + * |
|
57 | + * @return array |
|
58 | + */ |
|
59 | + public static function get_post_fields( $form, $entry ) { |
|
60 | + |
|
61 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'get_post_fields' ); |
|
62 | + |
|
63 | + /** |
|
64 | + * If the method changes to public, use Gravity Forms' method |
|
65 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
66 | + */ |
|
67 | + if( $reflection->isPublic() ) { |
|
68 | + return parent::get_post_fields( $form, $entry ); |
|
69 | + } |
|
70 | + |
|
71 | + // It was private; let's make it public |
|
72 | + $reflection->setAccessible( true ); |
|
73 | + |
|
74 | + return $reflection->invoke( new GFFormsModel, $form, $entry ); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private. |
|
79 | + * |
|
80 | + * @since 1.16.2 |
|
81 | + * |
|
82 | + * @param string $url URL of the post image to update |
|
83 | + * @param int $post_id ID of the post image to update |
|
84 | + * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path. |
|
85 | + */ |
|
86 | + public static function copy_post_image( $url, $post_id ) { |
|
87 | + |
|
88 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' ); |
|
89 | + |
|
90 | + /** |
|
91 | + * If the method changes to public, use Gravity Forms' method |
|
92 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
93 | + */ |
|
94 | + if( $reflection->isPublic() ) { |
|
95 | + return parent::copy_post_image( $url, $post_id ); |
|
96 | + } |
|
97 | + |
|
98 | + // It was private; let's make it public |
|
99 | + $reflection->setAccessible( true ); |
|
100 | + |
|
101 | + return $reflection->invoke( new GFFormsModel, $url, $post_id ); |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private. |
|
106 | + * |
|
107 | + * Note: The method became public in GF 1.9.17.7 |
|
108 | + * |
|
109 | + * @see GFFormsModel::media_handle_upload |
|
110 | + * @see GravityView_Edit_Entry_Render::maybe_update_post_fields |
|
111 | + * |
|
112 | + * @uses copy_post_image |
|
113 | + * @uses wp_insert_attachment |
|
114 | + * @uses wp_update_attachment_metadata |
|
115 | + * |
|
116 | + * @param string $url URL of the post image to update |
|
117 | + * @param int $post_id ID of the post image to update |
|
118 | + * @param array $post_data Array of data for the eventual attachment post type that is created using {@see wp_insert_attachment}. Supports `post_mime_type`, `guid`, `post_parent`, `post_title`, `post_content` keys. |
|
119 | + * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image |
|
120 | + */ |
|
121 | + public static function media_handle_upload( $url, $post_id, $post_data = array() ) { |
|
122 | + |
|
123 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' ); |
|
124 | + |
|
125 | + /** |
|
126 | + * If the method changes to public, use Gravity Forms' method |
|
127 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
128 | + */ |
|
129 | + if( $reflection->isPublic() ) { |
|
130 | + return parent::media_handle_upload( $url, $post_id, $post_data ); |
|
131 | + } |
|
132 | + |
|
133 | + // It was private; let's make it public |
|
134 | + $reflection->setAccessible( true ); |
|
135 | + |
|
136 | + return $reflection->invoke( new GFFormsModel, $url, $post_id, $post_data ); |
|
137 | + } |
|
138 | 138 | |
139 | 139 | } |
140 | 140 | \ No newline at end of file |
@@ -25,18 +25,18 @@ discard block |
||
25 | 25 | |
26 | 26 | $post_data = self::get_post_fields( $form, $entry ); |
27 | 27 | |
28 | - $media = get_attached_media( 'image', $entry['post_id'] ); |
|
28 | + $media = get_attached_media( 'image', $entry[ 'post_id' ] ); |
|
29 | 29 | |
30 | 30 | $post_images = array(); |
31 | 31 | |
32 | 32 | foreach ( $media as $media_item ) { |
33 | - foreach( (array) $post_data['images'] as $post_data_item ) { |
|
34 | - if( |
|
33 | + foreach ( (array)$post_data[ 'images' ] as $post_data_item ) { |
|
34 | + if ( |
|
35 | 35 | rgar( $post_data_item, 'title' ) === $media_item->post_title && |
36 | 36 | rgar( $post_data_item, 'description' ) === $media_item->post_content && |
37 | 37 | rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
38 | 38 | ) { |
39 | - $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
39 | + $post_images[ "{$post_data_item[ 'field_id' ]}" ] = $media_item->ID; |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * If the method changes to public, use Gravity Forms' method |
65 | 65 | * @todo: If/when the method is public, remove the unneeded copied code. |
66 | 66 | */ |
67 | - if( $reflection->isPublic() ) { |
|
67 | + if ( $reflection->isPublic() ) { |
|
68 | 68 | return parent::get_post_fields( $form, $entry ); |
69 | 69 | } |
70 | 70 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * If the method changes to public, use Gravity Forms' method |
92 | 92 | * @todo: If/when the method is public, remove the unneeded copied code. |
93 | 93 | */ |
94 | - if( $reflection->isPublic() ) { |
|
94 | + if ( $reflection->isPublic() ) { |
|
95 | 95 | return parent::copy_post_image( $url, $post_id ); |
96 | 96 | } |
97 | 97 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * If the method changes to public, use Gravity Forms' method |
127 | 127 | * @todo: If/when the method is public, remove the unneeded copied code. |
128 | 128 | */ |
129 | - if( $reflection->isPublic() ) { |
|
129 | + if ( $reflection->isPublic() ) { |
|
130 | 130 | return parent::media_handle_upload( $url, $post_id, $post_data ); |
131 | 131 | } |
132 | 132 |