@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | private function add_hooks() { |
| 40 | 40 | |
| 41 | 41 | // in case entry is edited (on admin or frontend) |
| 42 | - add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2); |
|
| 42 | + add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2 ); |
|
| 43 | 43 | |
| 44 | 44 | // when using the User opt-in field, check on entry submission |
| 45 | 45 | add_action( 'gform_after_submission', array( $this, 'after_submission' ), 10, 2 ); |
| 46 | 46 | |
| 47 | 47 | // process ajax approve entry requests |
| 48 | - add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved')); |
|
| 48 | + add_action( 'wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved' ) ); |
|
| 49 | 49 | |
| 50 | 50 | } |
| 51 | 51 | |
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public static function get_entry_status( $entry, $value_or_label = 'label' ) { |
| 64 | 64 | |
| 65 | - $entry_id = is_array( $entry ) ? $entry['id'] : GVCommon::get_entry_id( $entry, true ); |
|
| 65 | + $entry_id = is_array( $entry ) ? $entry[ 'id' ] : GVCommon::get_entry_id( $entry, true ); |
|
| 66 | 66 | |
| 67 | 67 | $status = gform_get_meta( $entry_id, self::meta_key ); |
| 68 | 68 | |
| 69 | 69 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
| 70 | 70 | |
| 71 | - if( 'value' === $value_or_label ) { |
|
| 71 | + if ( 'value' === $value_or_label ) { |
|
| 72 | 72 | return $status; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -93,20 +93,20 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function ajax_update_approved() { |
| 95 | 95 | |
| 96 | - $form_id = intval( rgpost('form_id') ); |
|
| 96 | + $form_id = intval( rgpost( 'form_id' ) ); |
|
| 97 | 97 | |
| 98 | 98 | // We always want requests from the admin to allow entry IDs, but not from the frontend |
| 99 | 99 | // There's another nonce sent when approving entries in the admin that we check |
| 100 | 100 | $force_entry_ids = rgpost( 'admin_nonce' ) && wp_verify_nonce( rgpost( 'admin_nonce' ), 'gravityview_admin_entry_approval' ); |
| 101 | 101 | |
| 102 | - $entry_id = GVCommon::get_entry_id( rgpost('entry_slug'), $force_entry_ids ); |
|
| 102 | + $entry_id = GVCommon::get_entry_id( rgpost( 'entry_slug' ), $force_entry_ids ); |
|
| 103 | 103 | |
| 104 | - $approval_status = rgpost('approved'); |
|
| 104 | + $approval_status = rgpost( 'approved' ); |
|
| 105 | 105 | |
| 106 | - $nonce = rgpost('nonce'); |
|
| 106 | + $nonce = rgpost( 'nonce' ); |
|
| 107 | 107 | |
| 108 | 108 | // Valid status |
| 109 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
| 109 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
| 110 | 110 | |
| 111 | 111 | do_action( 'gravityview_log_error', __METHOD__ . ': Invalid approval status', $_POST ); |
| 112 | 112 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
| 139 | 139 | |
| 140 | - $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview') ); |
|
| 140 | + $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview' ) ); |
|
| 141 | 141 | |
| 142 | 142 | } |
| 143 | 143 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @param $form array Gravity Forms form object |
| 171 | 171 | */ |
| 172 | 172 | public function after_submission( $entry, $form ) { |
| 173 | - $this->after_update_entry_update_approved_meta( $form , $entry['id'] ); |
|
| 173 | + $this->after_update_entry_update_approved_meta( $form, $entry[ 'id' ] ); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -184,12 +184,12 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
| 186 | 186 | |
| 187 | - $approved_column = self::get_approved_column( $form['id'] ); |
|
| 187 | + $approved_column = self::get_approved_column( $form[ 'id' ] ); |
|
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | 190 | * If the form doesn't contain the approve field, don't assume anything. |
| 191 | 191 | */ |
| 192 | - if( empty( $approved_column ) ) { |
|
| 192 | + if ( empty( $approved_column ) ) { |
|
| 193 | 193 | return; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $value = GravityView_Entry_Approval_Status::APPROVED; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - self::update_approved_meta( $entry_id, $value, $form['id'] ); |
|
| 206 | + self::update_approved_meta( $entry_id, $value, $form[ 'id' ] ); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -221,12 +221,12 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | public static function update_bulk( $entries = array(), $approved, $form_id ) { |
| 223 | 223 | |
| 224 | - if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) { |
|
| 224 | + if ( empty( $entries ) || ( $entries !== true && ! is_array( $entries ) ) ) { |
|
| 225 | 225 | do_action( 'gravityview_log_error', __METHOD__ . ' Entries were empty or malformed.', $entries ); |
| 226 | 226 | return NULL; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
| 229 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
| 230 | 230 | do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
| 231 | 231 | return NULL; |
| 232 | 232 | } |
@@ -241,10 +241,10 @@ discard block |
||
| 241 | 241 | $approved_column_id = self::get_approved_column( $form_id ); |
| 242 | 242 | |
| 243 | 243 | $success = true; |
| 244 | - foreach( $entries as $entry_id ) { |
|
| 244 | + foreach ( $entries as $entry_id ) { |
|
| 245 | 245 | $update_success = self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
| 246 | 246 | |
| 247 | - if( ! $update_success ) { |
|
| 247 | + if ( ! $update_success ) { |
|
| 248 | 248 | $success = false; |
| 249 | 249 | } |
| 250 | 250 | } |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | public static function update_approved( $entry_id = 0, $approved = 2, $form_id = 0, $approvedcolumn = 0 ) { |
| 270 | 270 | |
| 271 | - if( !class_exists( 'GFAPI' ) ) { |
|
| 271 | + if ( ! class_exists( 'GFAPI' ) ) { |
|
| 272 | 272 | do_action( 'gravityview_log_error', __METHOD__ . 'GFAPI does not exist' ); |
| 273 | 273 | return false; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
| 276 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
| 277 | 277 | do_action( 'gravityview_log_error', __METHOD__ . ': Not a valid approval value.' ); |
| 278 | 278 | return false; |
| 279 | 279 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | // If the form has an Approve/Reject field, update that value |
| 291 | 291 | $result = self::update_approved_column( $entry_id, $approved, $form_id, $approvedcolumn ); |
| 292 | 292 | |
| 293 | - if( is_wp_error( $result ) ) { |
|
| 293 | + if ( is_wp_error( $result ) ) { |
|
| 294 | 294 | do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - Entry approval not updated: %s', $result->get_error_message() ) ); |
| 295 | 295 | return false; |
| 296 | 296 | } |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | // add note to entry if approval field updating worked or there was no approved field |
| 304 | 304 | // There's no validation for the meta |
| 305 | - if( true === $result ) { |
|
| 305 | + if ( true === $result ) { |
|
| 306 | 306 | |
| 307 | 307 | // Add an entry note |
| 308 | 308 | self::add_approval_status_updated_note( $entry_id, $approved ); |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | $note_id = false; |
| 357 | 357 | |
| 358 | - if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
| 358 | + if ( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
| 359 | 359 | |
| 360 | 360 | $current_user = wp_get_current_user(); |
| 361 | 361 | |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | */ |
| 378 | 378 | private static function update_approved_column( $entry_id = 0, $status = '0', $form_id = 0, $approvedcolumn = 0 ) { |
| 379 | 379 | |
| 380 | - if( empty( $approvedcolumn ) ) { |
|
| 380 | + if ( empty( $approvedcolumn ) ) { |
|
| 381 | 381 | $approvedcolumn = self::get_approved_column( $form_id ); |
| 382 | 382 | } |
| 383 | 383 | |
@@ -400,12 +400,12 @@ discard block |
||
| 400 | 400 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
| 401 | 401 | |
| 402 | 402 | $new_value = ''; |
| 403 | - if( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
| 403 | + if ( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
| 404 | 404 | $new_value = self::get_approved_column_input_label( $form_id, $approvedcolumn ); |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | //update entry |
| 408 | - $entry["{$approvedcolumn}"] = $new_value; |
|
| 408 | + $entry[ "{$approvedcolumn}" ] = $new_value; |
|
| 409 | 409 | |
| 410 | 410 | /** |
| 411 | 411 | * Note: GFAPI::update_entry() doesn't trigger `gform_after_update_entry`, so we trigger updating the meta ourselves |
@@ -434,12 +434,12 @@ discard block |
||
| 434 | 434 | // If the user has enabled a different value than the label (for some reason), use it. |
| 435 | 435 | // This is highly unlikely |
| 436 | 436 | if ( is_array( $field->choices ) && ! empty( $field->choices ) ) { |
| 437 | - return isset( $field->choices[0]['value'] ) ? $field->choices[0]['value'] : $field->choices[0]['text']; |
|
| 437 | + return isset( $field->choices[ 0 ][ 'value' ] ) ? $field->choices[ 0 ][ 'value' ] : $field->choices[ 0 ][ 'text' ]; |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | // Otherwise, fall back on the inputs array |
| 441 | 441 | if ( is_array( $field->inputs ) && ! empty( $field->inputs ) ) { |
| 442 | - return $field->inputs[0]['label']; |
|
| 442 | + return $field->inputs[ 0 ][ 'label' ]; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | return null; |
@@ -460,16 +460,16 @@ discard block |
||
| 460 | 460 | private static function update_approved_meta( $entry_id, $status, $form_id = 0 ) { |
| 461 | 461 | |
| 462 | 462 | if ( ! GravityView_Entry_Approval_Status::is_valid( $status ) ) { |
| 463 | - do_action('gravityview_log_error', __METHOD__ . ': $is_approved not valid value', $status ); |
|
| 463 | + do_action( 'gravityview_log_error', __METHOD__ . ': $is_approved not valid value', $status ); |
|
| 464 | 464 | return; |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
| 468 | 468 | |
| 469 | 469 | // update entry meta |
| 470 | - if( function_exists('gform_update_meta') ) { |
|
| 470 | + if ( function_exists( 'gform_update_meta' ) ) { |
|
| 471 | 471 | |
| 472 | - if( GravityView_Entry_Approval_Status::is_unapproved( $status ) ) { |
|
| 472 | + if ( GravityView_Entry_Approval_Status::is_unapproved( $status ) ) { |
|
| 473 | 473 | gform_delete_meta( $entry_id, self::meta_key ); |
| 474 | 474 | } else { |
| 475 | 475 | gform_update_meta( $entry_id, self::meta_key, $status, $form_id ); |
@@ -492,11 +492,11 @@ discard block |
||
| 492 | 492 | * @since 1.18 Added "unapproved" |
| 493 | 493 | * @param int $entry_id ID of the Gravity Forms entry |
| 494 | 494 | */ |
| 495 | - do_action( 'gravityview/approve_entries/' . $action , $entry_id ); |
|
| 495 | + do_action( 'gravityview/approve_entries/' . $action, $entry_id ); |
|
| 496 | 496 | |
| 497 | 497 | } else { |
| 498 | 498 | |
| 499 | - do_action('gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' ); |
|
| 499 | + do_action( 'gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' ); |
|
| 500 | 500 | |
| 501 | 501 | } |
| 502 | 502 | } |
@@ -511,11 +511,11 @@ discard block |
||
| 511 | 511 | */ |
| 512 | 512 | static public function get_approved_column( $form ) { |
| 513 | 513 | |
| 514 | - if( empty( $form ) ) { |
|
| 514 | + if ( empty( $form ) ) { |
|
| 515 | 515 | return null; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - if( !is_array( $form ) ) { |
|
| 518 | + if ( ! is_array( $form ) ) { |
|
| 519 | 519 | $form = GVCommon::get_form( $form ); |
| 520 | 520 | } |
| 521 | 521 | |
@@ -525,22 +525,22 @@ discard block |
||
| 525 | 525 | * @var string $key |
| 526 | 526 | * @var GF_Field $field |
| 527 | 527 | */ |
| 528 | - foreach( $form['fields'] as $key => $field ) { |
|
| 528 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
| 529 | 529 | |
| 530 | 530 | $inputs = $field->get_entry_inputs(); |
| 531 | 531 | |
| 532 | - if( !empty( $field->gravityview_approved ) ) { |
|
| 533 | - if ( ! empty( $inputs ) && !empty( $inputs[0]['id'] ) ) { |
|
| 534 | - $approved_column_id = $inputs[0]['id']; |
|
| 532 | + if ( ! empty( $field->gravityview_approved ) ) { |
|
| 533 | + if ( ! empty( $inputs ) && ! empty( $inputs[ 0 ][ 'id' ] ) ) { |
|
| 534 | + $approved_column_id = $inputs[ 0 ][ 'id' ]; |
|
| 535 | 535 | break; |
| 536 | 536 | } |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
| 540 | - if( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
| 540 | + if ( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
| 541 | 541 | foreach ( $inputs as $input ) { |
| 542 | - if ( 'approved' === strtolower( $input['label'] ) ) { |
|
| 543 | - $approved_column_id = $input['id']; |
|
| 542 | + if ( 'approved' === strtolower( $input[ 'label' ] ) ) { |
|
| 543 | + $approved_column_id = $input[ 'id' ]; |
|
| 544 | 544 | break; |
| 545 | 545 | } |
| 546 | 546 | } |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | * @param int $entry_id ID of the Gravity Forms entry |
| 372 | 372 | * @param string $status String whether entry is approved or not. `0` for not approved, `Approved` for approved. |
| 373 | 373 | * @param int $form_id ID of the form of the entry being updated. Improves query performance. |
| 374 | - * @param string $approvedcolumn Gravity Forms Field ID |
|
| 374 | + * @param integer $approvedcolumn Gravity Forms Field ID |
|
| 375 | 375 | * |
| 376 | 376 | * @return true|WP_Error |
| 377 | 377 | */ |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * |
| 425 | 425 | * @since 1.19 |
| 426 | 426 | * |
| 427 | - * @param array|int $form Form ID or form array |
|
| 427 | + * @param integer $form Form ID or form array |
|
| 428 | 428 | * @param string $approved_column Approved column field ID |
| 429 | 429 | * |
| 430 | 430 | * @return string|null |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @return void |
| 97 | 97 | */ |
| 98 | 98 | public static function connected_form_warning( $form_id = 0 ) { |
| 99 | - global $pagenow; |
|
| 99 | + global $pagenow; |
|
| 100 | 100 | |
| 101 | 101 | if ( ! is_int( $form_id ) || $pagenow === 'post-new.php' ) { |
| 102 | 102 | return; |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | 7 => sprintf(__( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
| 243 | 243 | 8 => __( 'View submitted.', 'gravityview' ), |
| 244 | 244 | 9 => sprintf( |
| 245 | - /* translators: Date and time the View is scheduled to be published */ |
|
| 245 | + /* translators: Date and time the View is scheduled to be published */ |
|
| 246 | 246 | __( 'View scheduled for: %1$s.', 'gravityview' ), |
| 247 | 247 | // translators: Publish box date format, see http://php.net/date |
| 248 | 248 | date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
@@ -299,7 +299,6 @@ discard block |
||
| 299 | 299 | * |
| 300 | 300 | * @deprecated since 1.12 |
| 301 | 301 | * @see GravityView_Compatibility::get_plugin_status() |
| 302 | - |
|
| 303 | 302 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
| 304 | 303 | */ |
| 305 | 304 | static function get_plugin_status( $location = '' ) { |
@@ -4,10 +4,10 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | function __construct() { |
| 6 | 6 | |
| 7 | - if( ! is_admin() ) { return; } |
|
| 7 | + if ( ! is_admin() ) { return; } |
|
| 8 | 8 | |
| 9 | 9 | // If Gravity Forms isn't active or compatibile, stop loading |
| 10 | - if( false === GravityView_Compatibility::is_valid() ) { |
|
| 10 | + if ( false === GravityView_Compatibility::is_valid() ) { |
|
| 11 | 11 | return; |
| 12 | 12 | } |
| 13 | 13 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-migrate.php' ); |
| 26 | 26 | |
| 27 | 27 | // Don't load tooltips if on Gravity Forms, otherwise it overrides translations |
| 28 | - if( class_exists( 'GFCommon' ) && class_exists( 'GFForms' ) && !GFForms::is_gravity_page() ) { |
|
| 28 | + if ( class_exists( 'GFCommon' ) && class_exists( 'GFForms' ) && ! GFForms::is_gravity_page() ) { |
|
| 29 | 29 | require_once( GFCommon::get_base_path() . '/tooltips.php' ); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) ); |
| 54 | 54 | add_filter( 'bulk_post_updated_messages', array( $this, 'post_updated_messages' ) ); |
| 55 | 55 | |
| 56 | - add_filter( 'plugin_action_links_'. plugin_basename( GRAVITYVIEW_FILE ) , array( $this, 'plugin_action_links' ) ); |
|
| 56 | + add_filter( 'plugin_action_links_' . plugin_basename( GRAVITYVIEW_FILE ), array( $this, 'plugin_action_links' ) ); |
|
| 57 | 57 | |
| 58 | 58 | add_action( 'plugins_loaded', array( $this, 'backend_actions' ), 100 ); |
| 59 | 59 | |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public static function no_views_text() { |
| 70 | 70 | |
| 71 | - if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { |
|
| 71 | + if ( isset( $_REQUEST[ 'post_status' ] ) && 'trash' === $_REQUEST[ 'post_status' ] ) { |
|
| 72 | 72 | return __( 'No Views found in Trash', 'gravityview' ); |
| 73 | - } elseif( ! empty( $_GET['s'] ) ) { |
|
| 73 | + } elseif ( ! empty( $_GET[ 's' ] ) ) { |
|
| 74 | 74 | return __( 'No Views found.', 'gravityview' ); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $error .= ' ' . esc_html__( 'or select another form.', 'gravityview' ); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if( $error ) { |
|
| 117 | + if ( $error ) { |
|
| 118 | 118 | ?> |
| 119 | 119 | <div class="wp-dialog notice-warning inline error wp-clearfix"> |
| 120 | 120 | <?php echo gravityview_get_floaty(); ?> |
@@ -133,22 +133,22 @@ discard block |
||
| 133 | 133 | public function backend_actions() { |
| 134 | 134 | |
| 135 | 135 | /** @define "GRAVITYVIEW_DIR" "../" */ |
| 136 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class.field.type.php' ); |
|
| 137 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class.render.settings.php' ); |
|
| 138 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class-gravityview-admin-view-item.php' ); |
|
| 139 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class-gravityview-admin-view-field.php' ); |
|
| 140 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class-gravityview-admin-view-widget.php' ); |
|
| 141 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-views.php' ); |
|
| 142 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-welcome.php' ); |
|
| 143 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-add-shortcode.php' ); |
|
| 144 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 136 | + include_once( GRAVITYVIEW_DIR . 'includes/admin/class.field.type.php' ); |
|
| 137 | + include_once( GRAVITYVIEW_DIR . 'includes/admin/class.render.settings.php' ); |
|
| 138 | + include_once( GRAVITYVIEW_DIR . 'includes/admin/class-gravityview-admin-view-item.php' ); |
|
| 139 | + include_once( GRAVITYVIEW_DIR . 'includes/admin/class-gravityview-admin-view-field.php' ); |
|
| 140 | + include_once( GRAVITYVIEW_DIR . 'includes/admin/class-gravityview-admin-view-widget.php' ); |
|
| 141 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-views.php' ); |
|
| 142 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-welcome.php' ); |
|
| 143 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-add-shortcode.php' ); |
|
| 144 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | 147 | * @action `gravityview_include_backend_actions` Triggered after all GravityView admin files are loaded |
| 148 | 148 | * |
| 149 | 149 | * Nice place to insert extensions' backend stuff |
| 150 | 150 | */ |
| 151 | - do_action('gravityview_include_backend_actions'); |
|
| 151 | + do_action( 'gravityview_include_backend_actions' ); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -164,12 +164,12 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | $actions = array(); |
| 166 | 166 | |
| 167 | - if( GVCommon::has_cap( 'gravityview_view_settings' ) ) { |
|
| 168 | - $actions[] = sprintf( '<a href="%s">%s</a>', admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ), esc_html__( 'Settings', 'gravityview' ) ); |
|
| 167 | + if ( GVCommon::has_cap( 'gravityview_view_settings' ) ) { |
|
| 168 | + $actions[ ] = sprintf( '<a href="%s">%s</a>', admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ), esc_html__( 'Settings', 'gravityview' ) ); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if( GVCommon::has_cap( 'gravityview_support_port' ) ) { |
|
| 172 | - $actions[] = '<a href="http://docs.gravityview.co">' . esc_html__( 'Support', 'gravityview' ) . '</a>'; |
|
| 171 | + if ( GVCommon::has_cap( 'gravityview_support_port' ) ) { |
|
| 172 | + $actions[ ] = '<a href="http://docs.gravityview.co">' . esc_html__( 'Support', 'gravityview' ) . '</a>'; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | return array_merge( $actions, $links ); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | // By default, there will only be one item being modified. |
| 198 | 198 | // When in the `bulk_post_updated_messages` filter, there will be passed a number |
| 199 | 199 | // of modified items that will override this array. |
| 200 | - $bulk_counts = is_null( $bulk_counts ) ? array( 'updated' => 1 , 'locked' => 1 , 'deleted' => 1 , 'trashed' => 1, 'untrashed' => 1 ) : $bulk_counts; |
|
| 200 | + $bulk_counts = is_null( $bulk_counts ) ? array( 'updated' => 1, 'locked' => 1, 'deleted' => 1, 'trashed' => 1, 'untrashed' => 1 ) : $bulk_counts; |
|
| 201 | 201 | |
| 202 | 202 | // If we're starting fresh, a new form was created. |
| 203 | 203 | // We should let the user know this is the case. |
@@ -205,60 +205,60 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | $new_form_text = ''; |
| 207 | 207 | |
| 208 | - if( !empty( $start_fresh ) ) { |
|
| 208 | + if ( ! empty( $start_fresh ) ) { |
|
| 209 | 209 | |
| 210 | 210 | // Get the form that was created |
| 211 | 211 | $connected_form = gravityview_get_form_id( $post_id ); |
| 212 | 212 | |
| 213 | - if( !empty( $connected_form ) ) { |
|
| 213 | + if ( ! empty( $connected_form ) ) { |
|
| 214 | 214 | $form = gravityview_get_form( $connected_form ); |
| 215 | - $form_name = esc_attr( $form['title'] ); |
|
| 215 | + $form_name = esc_attr( $form[ 'title' ] ); |
|
| 216 | 216 | $image = self::get_floaty(); |
| 217 | - $new_form_text .= '<h3>'.$image.sprintf( __( 'A new form was created for this View: "%s"', 'gravityview' ), $form_name ).'</h3>'; |
|
| 218 | - $new_form_text .= sprintf( __( '%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s |
|
| 217 | + $new_form_text .= '<h3>' . $image . sprintf( __( 'A new form was created for this View: "%s"', 'gravityview' ), $form_name ) . '</h3>'; |
|
| 218 | + $new_form_text .= sprintf( __( '%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s |
|
| 219 | 219 | |
| 220 | 220 | You can %sedit the form%s in Gravity Forms and the updated fields will be available here. Don’t forget to %scustomize the form settings%s. |
| 221 | - ', 'gravityview' ), '<strong>', '</strong>', '<a href="'.site_url( '?gf_page=preview&id='.$connected_form ).'">', '</a>', '<code>[gravityform id="'.$connected_form.'" name="'.$form_name.'"]</code>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&id='.$connected_form ).'">', '</a>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&view=settings&id='.$connected_form ).'">', '</a>'); |
|
| 221 | + ', 'gravityview' ), '<strong>', '</strong>', '<a href="' . site_url( '?gf_page=preview&id=' . $connected_form ) . '">', '</a>', '<code>[gravityform id="' . $connected_form . '" name="' . $form_name . '"]</code>', '<a href="' . admin_url( 'admin.php?page=gf_edit_forms&id=' . $connected_form ) . '">', '</a>', '<a href="' . admin_url( 'admin.php?page=gf_edit_forms&view=settings&id=' . $connected_form ) . '">', '</a>' ); |
|
| 222 | 222 | $new_form_text = wpautop( $new_form_text ); |
| 223 | 223 | |
| 224 | 224 | delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - $messages['gravityview'] = array( |
|
| 228 | + $messages[ 'gravityview' ] = array( |
|
| 229 | 229 | 0 => '', // Unused. Messages start at index 1. |
| 230 | 230 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
| 231 | - 1 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
| 231 | + 1 => sprintf( __( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ), |
|
| 232 | 232 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
| 233 | - 2 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
| 233 | + 2 => sprintf( __( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ), |
|
| 234 | 234 | 3 => __( 'View deleted.', 'gravityview' ), |
| 235 | 235 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
| 236 | - 4 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
| 236 | + 4 => sprintf( __( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ), |
|
| 237 | 237 | /* translators: %s: date and time of the revision */ |
| 238 | - 5 => isset( $_GET['revision'] ) ? sprintf( __( 'View restored to revision from %s', 'gravityview' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 238 | + 5 => isset( $_GET[ 'revision' ] ) ? sprintf( __( 'View restored to revision from %s', 'gravityview' ), wp_post_revision_title( (int)$_GET[ 'revision' ], false ) ) : false, |
|
| 239 | 239 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
| 240 | - 6 => sprintf(__( 'View published. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
| 240 | + 6 => sprintf( __( 'View published. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ) . $new_form_text, |
|
| 241 | 241 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
| 242 | - 7 => sprintf(__( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
| 242 | + 7 => sprintf( __( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ) . $new_form_text, |
|
| 243 | 243 | 8 => __( 'View submitted.', 'gravityview' ), |
| 244 | 244 | 9 => sprintf( |
| 245 | 245 | /* translators: Date and time the View is scheduled to be published */ |
| 246 | 246 | __( 'View scheduled for: %1$s.', 'gravityview' ), |
| 247 | 247 | // translators: Publish box date format, see http://php.net/date |
| 248 | - date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
|
| 248 | + date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
|
| 249 | 249 | ) . $new_form_text, |
| 250 | 250 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
| 251 | - 10 => sprintf(__( 'View draft updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
| 251 | + 10 => sprintf( __( 'View draft updated. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ) . $new_form_text, |
|
| 252 | 252 | |
| 253 | 253 | /** |
| 254 | 254 | * These apply to `bulk_post_updated_messages` |
| 255 | 255 | * @file wp-admin/edit.php |
| 256 | 256 | */ |
| 257 | - 'updated' => _n( '%s View updated.', '%s Views updated.', $bulk_counts['updated'], 'gravityview' ), |
|
| 258 | - 'locked' => _n( '%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts['locked'], 'gravityview' ), |
|
| 259 | - 'deleted' => _n( '%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts['deleted'], 'gravityview' ), |
|
| 260 | - 'trashed' => _n( '%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts['trashed'], 'gravityview' ), |
|
| 261 | - 'untrashed' => _n( '%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts['untrashed'], 'gravityview' ), |
|
| 257 | + 'updated' => _n( '%s View updated.', '%s Views updated.', $bulk_counts[ 'updated' ], 'gravityview' ), |
|
| 258 | + 'locked' => _n( '%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts[ 'locked' ], 'gravityview' ), |
|
| 259 | + 'deleted' => _n( '%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts[ 'deleted' ], 'gravityview' ), |
|
| 260 | + 'trashed' => _n( '%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts[ 'trashed' ], 'gravityview' ), |
|
| 261 | + 'untrashed' => _n( '%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts[ 'untrashed' ], 'gravityview' ), |
|
| 262 | 262 | ); |
| 263 | 263 | |
| 264 | 264 | return $messages; |
@@ -318,29 +318,29 @@ discard block |
||
| 318 | 318 | static function is_admin_page( $hook = '', $page = NULL ) { |
| 319 | 319 | global $current_screen, $plugin_page, $pagenow, $post; |
| 320 | 320 | |
| 321 | - if( ! is_admin() ) { return false; } |
|
| 321 | + if ( ! is_admin() ) { return false; } |
|
| 322 | 322 | |
| 323 | 323 | $is_page = false; |
| 324 | 324 | |
| 325 | - $is_gv_screen = (!empty($current_screen) && isset($current_screen->post_type) && $current_screen->post_type === 'gravityview'); |
|
| 325 | + $is_gv_screen = ( ! empty( $current_screen ) && isset( $current_screen->post_type ) && $current_screen->post_type === 'gravityview' ); |
|
| 326 | 326 | |
| 327 | - $is_gv_post_type_get = (isset($_GET['post_type']) && $_GET['post_type'] === 'gravityview'); |
|
| 327 | + $is_gv_post_type_get = ( isset( $_GET[ 'post_type' ] ) && $_GET[ 'post_type' ] === 'gravityview' ); |
|
| 328 | 328 | |
| 329 | - $is_gv_settings_get = isset( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings'; |
|
| 329 | + $is_gv_settings_get = isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] === 'gravityview_settings'; |
|
| 330 | 330 | |
| 331 | - if( empty( $post ) && $pagenow === 'post.php' && !empty( $_GET['post'] ) ) { |
|
| 332 | - $gv_post = get_post( intval( $_GET['post'] ) ); |
|
| 333 | - $is_gv_post_type = (!empty($gv_post) && !empty($gv_post->post_type) && $gv_post->post_type === 'gravityview'); |
|
| 331 | + if ( empty( $post ) && $pagenow === 'post.php' && ! empty( $_GET[ 'post' ] ) ) { |
|
| 332 | + $gv_post = get_post( intval( $_GET[ 'post' ] ) ); |
|
| 333 | + $is_gv_post_type = ( ! empty( $gv_post ) && ! empty( $gv_post->post_type ) && $gv_post->post_type === 'gravityview' ); |
|
| 334 | 334 | } else { |
| 335 | - $is_gv_post_type = (!empty($post) && !empty($post->post_type) && $post->post_type === 'gravityview'); |
|
| 335 | + $is_gv_post_type = ( ! empty( $post ) && ! empty( $post->post_type ) && $post->post_type === 'gravityview' ); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - if( $is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get ) { |
|
| 338 | + if ( $is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get ) { |
|
| 339 | 339 | |
| 340 | 340 | // $_GET `post_type` variable |
| 341 | - if(in_array($pagenow, array( 'post.php' , 'post-new.php' )) ) { |
|
| 341 | + if ( in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) { |
|
| 342 | 342 | $is_page = 'single'; |
| 343 | - } else if ( in_array( $plugin_page, array( 'gravityview_settings', 'gravityview_page_gravityview_settings' ) ) || ( !empty( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings' ) ) { |
|
| 343 | + } else if ( in_array( $plugin_page, array( 'gravityview_settings', 'gravityview_page_gravityview_settings' ) ) || ( ! empty( $_GET[ 'page' ] ) && $_GET[ 'page' ] === 'gravityview_settings' ) ) { |
|
| 344 | 344 | $is_page = 'settings'; |
| 345 | 345 | } else { |
| 346 | 346 | $is_page = 'views'; |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | $is_page = apply_filters( 'gravityview_is_admin_page', $is_page, $hook ); |
| 356 | 356 | |
| 357 | 357 | // If the current page is the same as the compared page |
| 358 | - if( !empty( $page ) ) { |
|
| 358 | + if ( ! empty( $page ) ) { |
|
| 359 | 359 | return $is_page === $page; |
| 360 | 360 | } |
| 361 | 361 | |
@@ -376,6 +376,6 @@ discard block |
||
| 376 | 376 | * |
| 377 | 377 | * @return bool|string|void If `false`, not a GravityView page. `true` if $page is passed and is the same as current page. Otherwise, the name of the page (`single`, `settings`, or `views`) |
| 378 | 378 | */ |
| 379 | -function gravityview_is_admin_page($hook = '', $page = NULL) { |
|
| 379 | +function gravityview_is_admin_page( $hook = '', $page = NULL ) { |
|
| 380 | 380 | return GravityView_Admin::is_admin_page( $hook, $page ); |
| 381 | 381 | } |
@@ -11,35 +11,35 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | function __construct() { |
| 13 | 13 | |
| 14 | - $this->widget_description = __('Links to multiple pages of results.', 'gravityview' ); |
|
| 14 | + $this->widget_description = __( 'Links to multiple pages of results.', 'gravityview' ); |
|
| 15 | 15 | |
| 16 | 16 | $default_values = array( 'header' => 1, 'footer' => 1 ); |
| 17 | 17 | $settings = array( 'show_all' => array( |
| 18 | 18 | 'type' => 'checkbox', |
| 19 | 19 | 'label' => __( 'Show each page number', 'gravityview' ), |
| 20 | - 'desc' => __('Show every page number instead of summary (eg: 1 2 3 ... 8 »)', 'gravityview'), |
|
| 20 | + 'desc' => __( 'Show every page number instead of summary (eg: 1 2 3 ... 8 »)', 'gravityview' ), |
|
| 21 | 21 | 'value' => false |
| 22 | - )); |
|
| 23 | - parent::__construct( __( 'Page Links', 'gravityview' ) , 'page_links', $default_values, $settings ); |
|
| 22 | + ) ); |
|
| 23 | + parent::__construct( __( 'Page Links', 'gravityview' ), 'page_links', $default_values, $settings ); |
|
| 24 | 24 | |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function render_frontend( $widget_args, $content = '', $context = '') { |
|
| 27 | + public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
| 28 | 28 | $gravityview_view = GravityView_View::getInstance(); |
| 29 | 29 | |
| 30 | - if( !$this->pre_render_frontend() ) { |
|
| 30 | + if ( ! $this->pre_render_frontend() ) { |
|
| 31 | 31 | return; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | $atts = shortcode_atts( array( |
| 35 | 35 | 'page_size' => rgar( $gravityview_view->paging, 'page_size' ), |
| 36 | 36 | 'total' => $gravityview_view->total_entries, |
| 37 | - 'show_all' => !empty( $this->settings['show_all']['default'] ), |
|
| 38 | - 'current' => (int) rgar( $_GET, 'pagenum', 1 ), |
|
| 37 | + 'show_all' => ! empty( $this->settings[ 'show_all' ][ 'default' ] ), |
|
| 38 | + 'current' => (int)rgar( $_GET, 'pagenum', 1 ), |
|
| 39 | 39 | ), $widget_args, 'gravityview_widget_page_links' ); |
| 40 | 40 | |
| 41 | 41 | $page_link_args = array( |
| 42 | - 'base' => add_query_arg('pagenum','%#%', gv_directory_link() ), |
|
| 42 | + 'base' => add_query_arg( 'pagenum', '%#%', gv_directory_link() ), |
|
| 43 | 43 | 'format' => '&pagenum=%#%', |
| 44 | 44 | 'add_args' => array(), // |
| 45 | 45 | 'prev_text' => '«', |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | 'type' => 'list', |
| 48 | 48 | 'end_size' => 1, |
| 49 | 49 | 'mid_size' => 2, |
| 50 | - 'total' => empty( $atts['page_size'] ) ? 0 : ceil( $atts['total'] / $atts['page_size'] ), |
|
| 51 | - 'current' => $atts['current'], |
|
| 52 | - 'show_all' => !empty( $atts['show_all'] ), // to be available at backoffice |
|
| 50 | + 'total' => empty( $atts[ 'page_size' ] ) ? 0 : ceil( $atts[ 'total' ] / $atts[ 'page_size' ] ), |
|
| 51 | + 'current' => $atts[ 'current' ], |
|
| 52 | + 'show_all' => ! empty( $atts[ 'show_all' ] ), // to be available at backoffice |
|
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | * @since 1.1.4 |
| 58 | 58 | * @param array $page_link_args Array of arguments for the `paginate_links()` function. [Read more about `paginate_links()`](http://developer.wordpress.org/reference/functions/paginate_links/) |
| 59 | 59 | */ |
| 60 | - $page_link_args = apply_filters('gravityview_page_links_args', $page_link_args ); |
|
| 60 | + $page_link_args = apply_filters( 'gravityview_page_links_args', $page_link_args ); |
|
| 61 | 61 | |
| 62 | 62 | $page_links = paginate_links( $page_link_args ); |
| 63 | 63 | |
| 64 | - if( !empty( $page_links )) { |
|
| 65 | - $class = !empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
| 64 | + if ( ! empty( $page_links ) ) { |
|
| 65 | + $class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
| 66 | 66 | $class = gravityview_sanitize_html_class( 'gv-widget-page-links ' . $class ); |
| 67 | - echo '<div class="'.$class.'">'. $page_links .'</div>'; |
|
| 67 | + echo '<div class="' . $class . '">' . $page_links . '</div>'; |
|
| 68 | 68 | } else { |
| 69 | 69 | do_action( 'gravityview_log_debug', 'GravityView_Widget_Page_Links[render_frontend] No page links; paginate_links() returned empty response.' ); |
| 70 | 70 | } |
@@ -102,7 +102,7 @@ |
||
| 102 | 102 | $field_data = array( |
| 103 | 103 | 'label' => rgar( $edit_field, 'custom_label' ), |
| 104 | 104 | 'customLabel' => rgar( $edit_field, 'custom_label' ), |
| 105 | - 'content' => rgar( $edit_field, 'content' ), |
|
| 105 | + 'content' => rgar( $edit_field, 'content' ), |
|
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | 108 | // Replace merge tags in the content |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
| 42 | 42 | |
| 43 | - unset ( $field_options['search_filter'], $field_options['show_as_link'] ); |
|
| 43 | + unset ( $field_options[ 'search_filter' ], $field_options[ 'show_as_link' ] ); |
|
| 44 | 44 | |
| 45 | 45 | $new_fields = array( |
| 46 | 46 | 'content' => array( |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | ), |
| 61 | 61 | ); |
| 62 | 62 | |
| 63 | - if( 'edit' === $context ) { |
|
| 64 | - unset( $field_options['custom_label'], $field_options['show_label'], $field_options['allow_edit_cap'], $new_fields['wpautop'] ); |
|
| 63 | + if ( 'edit' === $context ) { |
|
| 64 | + unset( $field_options[ 'custom_label' ], $field_options[ 'show_label' ], $field_options[ 'allow_edit_cap' ], $new_fields[ 'wpautop' ] ); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | return $new_fields + $field_options; |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | // Loop through the configured Edit Entry fields and add Custom Content fields if there are any |
| 97 | 97 | // TODO: Make this available to other custom GV field types |
| 98 | - foreach ( (array) $edit_fields as $edit_field ) { |
|
| 98 | + foreach ( (array)$edit_fields as $edit_field ) { |
|
| 99 | 99 | |
| 100 | - if( 'custom' === rgar( $edit_field, 'id') ) { |
|
| 100 | + if ( 'custom' === rgar( $edit_field, 'id' ) ) { |
|
| 101 | 101 | |
| 102 | 102 | $field_data = array( |
| 103 | 103 | 'label' => rgar( $edit_field, 'custom_label' ), |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | $field_data[ $key ] = GravityView_Merge_Tags::replace_variables( $field_datum, $form, $entry, false, false ); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $field_data['cssClass'] = rgar( $edit_field, 'custom_class' ); |
|
| 113 | + $field_data[ 'cssClass' ] = rgar( $edit_field, 'custom_class' ); |
|
| 114 | 114 | |
| 115 | - $new_fields[] = new GF_Field_HTML( $field_data ); |
|
| 115 | + $new_fields[ ] = new GF_Field_HTML( $field_data ); |
|
| 116 | 116 | |
| 117 | 117 | } else { |
| 118 | - if( isset( $fields[ $i ] ) ) { |
|
| 119 | - $new_fields[] = $fields[ $i ]; |
|
| 118 | + if ( isset( $fields[ $i ] ) ) { |
|
| 119 | + $new_fields[ ] = $fields[ $i ]; |
|
| 120 | 120 | } |
| 121 | 121 | $i++; |
| 122 | 122 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * Return array of fields' id and label, for a given Form ID |
| 218 | 218 | * |
| 219 | 219 | * @access public |
| 220 | - * @param string|array $form_id (default: '') or $form object |
|
| 220 | + * @param string|array $form (default: '') or $form object |
|
| 221 | 221 | * @param bool $add_default_properties |
| 222 | 222 | * @param bool $include_parent_field |
| 223 | 223 | * @return array |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | * |
| 883 | 883 | * @param array $form Gravity Forms form array |
| 884 | 884 | * @param string $field_id ID of the field. If an input, full input ID (like `1.3`) |
| 885 | - * @param string|array $field_value Raw value of the field. |
|
| 885 | + * @param string $field_value Raw value of the field. |
|
| 886 | 886 | * @return string |
| 887 | 887 | */ |
| 888 | 888 | public static function get_field_label( $form = array(), $field_id = '', $field_value = '' ) { |
@@ -1514,6 +1514,7 @@ discard block |
||
| 1514 | 1514 | * @param string $notice text/HTML of notice |
| 1515 | 1515 | * @param string $class CSS class for notice (`updated` or `error`) |
| 1516 | 1516 | * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
| 1517 | + * @param integer $object_id |
|
| 1517 | 1518 | * |
| 1518 | 1519 | * @return string |
| 1519 | 1520 | */ |
@@ -1557,9 +1558,9 @@ discard block |
||
| 1557 | 1558 | * @param string $message Message body (required) |
| 1558 | 1559 | * @param string $from_name Displayed name of the sender |
| 1559 | 1560 | * @param string $message_format If "html", sent text as `text/html`. Otherwise, `text/plain`. Default: "html". |
| 1560 | - * @param string|array $attachments Optional. Files to attach. {@see wp_mail()} for usage. Default: "". |
|
| 1561 | + * @param string $attachments Optional. Files to attach. {@see wp_mail()} for usage. Default: "". |
|
| 1561 | 1562 | * @param array|false $entry Gravity Forms entry array, related to the email. Default: false. |
| 1562 | - * @param array|false $notification Gravity Forms notification that triggered the email. {@see GFCommon::send_notification}. Default:false. |
|
| 1563 | + * @param boolean $notification Gravity Forms notification that triggered the email. {@see GFCommon::send_notification}. Default:false. |
|
| 1563 | 1564 | */ |
| 1564 | 1565 | public static function send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name = '', $message_format = 'html', $attachments = '', $entry = false, $notification = false ) { |
| 1565 | 1566 | |
@@ -306,12 +306,12 @@ discard block |
||
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
| 309 | - * @hack |
|
| 310 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
| 311 | - */ |
|
| 309 | + * @hack |
|
| 310 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
| 311 | + */ |
|
| 312 | 312 | if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
| 313 | - continue; |
|
| 314 | - } |
|
| 313 | + continue; |
|
| 314 | + } |
|
| 315 | 315 | $fields["{$input['id']}"] = array( |
| 316 | 316 | 'label' => rgar( $input, 'label' ), |
| 317 | 317 | 'customLabel' => rgar( $input, 'customLabel' ), |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | } elseif ( 'delete' === GFForms::get( 'action' ) ) { |
| 489 | 489 | $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
| 490 | 490 | } elseif( !isset( $criteria['context_view_id'] ) ) { |
| 491 | - // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
| 491 | + // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
| 492 | 492 | $criteria['context_view_id'] = null; |
| 493 | 493 | } |
| 494 | 494 | |
@@ -1251,7 +1251,7 @@ discard block |
||
| 1251 | 1251 | ), |
| 1252 | 1252 | ); |
| 1253 | 1253 | |
| 1254 | - $fields = $date_created + $fields; |
|
| 1254 | + $fields = $date_created + $fields; |
|
| 1255 | 1255 | |
| 1256 | 1256 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
| 1257 | 1257 | |
@@ -1263,13 +1263,13 @@ discard block |
||
| 1263 | 1263 | } |
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | - /** |
|
| 1267 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
| 1268 | - * @since 1.12 |
|
| 1269 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
| 1270 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
| 1271 | - */ |
|
| 1272 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
| 1266 | + /** |
|
| 1267 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
| 1268 | + * @since 1.12 |
|
| 1269 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
| 1270 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
| 1271 | + */ |
|
| 1272 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
| 1273 | 1273 | |
| 1274 | 1274 | return $fields; |
| 1275 | 1275 | } |
@@ -1561,26 +1561,26 @@ discard block |
||
| 1561 | 1561 | } |
| 1562 | 1562 | |
| 1563 | 1563 | |
| 1564 | - /** |
|
| 1565 | - * Display updated/error notice |
|
| 1566 | - * |
|
| 1567 | - * @since 1.19.2 Added $cap and $object_id parameters |
|
| 1568 | - * |
|
| 1569 | - * @param string $notice text/HTML of notice |
|
| 1570 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
| 1571 | - * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
| 1572 | - * |
|
| 1573 | - * @return string |
|
| 1574 | - */ |
|
| 1575 | - public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
| 1576 | - |
|
| 1577 | - // If $cap is defined, only show notice if user has capability |
|
| 1578 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1579 | - return ''; |
|
| 1580 | - } |
|
| 1581 | - |
|
| 1582 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1583 | - } |
|
| 1564 | + /** |
|
| 1565 | + * Display updated/error notice |
|
| 1566 | + * |
|
| 1567 | + * @since 1.19.2 Added $cap and $object_id parameters |
|
| 1568 | + * |
|
| 1569 | + * @param string $notice text/HTML of notice |
|
| 1570 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
| 1571 | + * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
| 1572 | + * |
|
| 1573 | + * @return string |
|
| 1574 | + */ |
|
| 1575 | + public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
| 1576 | + |
|
| 1577 | + // If $cap is defined, only show notice if user has capability |
|
| 1578 | + if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1579 | + return ''; |
|
| 1580 | + } |
|
| 1581 | + |
|
| 1582 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1583 | + } |
|
| 1584 | 1584 | |
| 1585 | 1585 | /** |
| 1586 | 1586 | * Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
| 327 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
| 327 | + if( GFCommon::is_product_field( $field['type'] ) ) { |
|
| 328 | 328 | $has_product_fields = true; |
| 329 | 329 | } |
| 330 | 330 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | |
| 385 | 385 | $fields = array(); |
| 386 | 386 | |
| 387 | - foreach ( $extra_fields as $key => $field ){ |
|
| 387 | + foreach ( $extra_fields as $key => $field ) { |
|
| 388 | 388 | if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
| 389 | 389 | $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
| 390 | 390 | } |
@@ -978,7 +978,7 @@ discard block |
||
| 978 | 978 | $form = GFAPI::get_form( $form ); |
| 979 | 979 | } |
| 980 | 980 | |
| 981 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
| 981 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
| 982 | 982 | return GFFormsModel::get_field( $form, $field_id ); |
| 983 | 983 | } else { |
| 984 | 984 | return null; |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | $shortcodes = array(); |
| 1026 | 1026 | |
| 1027 | 1027 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
| 1028 | - if ( empty( $matches ) ){ |
|
| 1028 | + if ( empty( $matches ) ) { |
|
| 1029 | 1029 | return false; |
| 1030 | 1030 | } |
| 1031 | 1031 | |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $form = false; |
| 128 | 128 | |
| 129 | - if( $entry ) { |
|
| 130 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
| 129 | + if ( $entry ) { |
|
| 130 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | return $form; |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | $has_transaction_data = rgar( $entry, $meta, false ); |
| 195 | 195 | |
| 196 | - if( ! empty( $has_transaction_data ) ) { |
|
| 196 | + if ( ! empty( $has_transaction_data ) ) { |
|
| 197 | 197 | break; |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - return (bool) $has_transaction_data; |
|
| 201 | + return (bool)$has_transaction_data; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
| 238 | 238 | |
| 239 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
| 239 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
| 240 | 240 | |
| 241 | 241 | return $result; |
| 242 | 242 | } |
@@ -253,10 +253,10 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
| 255 | 255 | */ |
| 256 | - public static function get_forms( $active = true, $trash = false ) { |
|
| 256 | + public static function get_forms( $active = true, $trash = false ) { |
|
| 257 | 257 | $forms = array(); |
| 258 | 258 | if ( class_exists( 'GFAPI' ) ) { |
| 259 | - if( 'any' === $active ) { |
|
| 259 | + if ( 'any' === $active ) { |
|
| 260 | 260 | $active_forms = GFAPI::get_forms( true, $trash ); |
| 261 | 261 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
| 262 | 262 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -287,9 +287,9 @@ discard block |
||
| 287 | 287 | $has_post_fields = false; |
| 288 | 288 | |
| 289 | 289 | if ( $form ) { |
| 290 | - foreach ( $form['fields'] as $field ) { |
|
| 291 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
| 292 | - $fields["{$field['id']}"] = array( |
|
| 290 | + foreach ( $form[ 'fields' ] as $field ) { |
|
| 291 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
| 292 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
| 293 | 293 | 'label' => rgar( $field, 'label' ), |
| 294 | 294 | 'parent' => null, |
| 295 | 295 | 'type' => rgar( $field, 'type' ), |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | ); |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
| 302 | - foreach ( $field['inputs'] as $input ) { |
|
| 301 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
| 302 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
| 303 | 303 | |
| 304 | - if( ! empty( $input['isHidden'] ) ) { |
|
| 304 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
| 305 | 305 | continue; |
| 306 | 306 | } |
| 307 | 307 | |
@@ -309,10 +309,10 @@ discard block |
||
| 309 | 309 | * @hack |
| 310 | 310 | * In case of email/email confirmation, the input for email has the same id as the parent field |
| 311 | 311 | */ |
| 312 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
| 312 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
| 313 | 313 | continue; |
| 314 | 314 | } |
| 315 | - $fields["{$input['id']}"] = array( |
|
| 315 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
| 316 | 316 | 'label' => rgar( $input, 'label' ), |
| 317 | 317 | 'customLabel' => rgar( $input, 'customLabel' ), |
| 318 | 318 | 'parent' => $field, |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
| 327 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
| 327 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
| 328 | 328 | $has_product_fields = true; |
| 329 | 329 | } |
| 330 | 330 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | * @since 1.7 |
| 339 | 339 | */ |
| 340 | 340 | if ( $has_post_fields ) { |
| 341 | - $fields['post_id'] = array( |
|
| 341 | + $fields[ 'post_id' ] = array( |
|
| 342 | 342 | 'label' => __( 'Post ID', 'gravityview' ), |
| 343 | 343 | 'type' => 'post_id', |
| 344 | 344 | ); |
@@ -351,11 +351,11 @@ discard block |
||
| 351 | 351 | foreach ( $payment_fields as $payment_field ) { |
| 352 | 352 | |
| 353 | 353 | // Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key |
| 354 | - if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
| 354 | + if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
| 355 | 355 | continue; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - $fields["{$payment_field->name}"] = array( |
|
| 358 | + $fields[ "{$payment_field->name}" ] = array( |
|
| 359 | 359 | 'label' => $payment_field->label, |
| 360 | 360 | 'desc' => $payment_field->description, |
| 361 | 361 | 'type' => $payment_field->name, |
@@ -387,9 +387,9 @@ discard block |
||
| 387 | 387 | |
| 388 | 388 | $fields = array(); |
| 389 | 389 | |
| 390 | - foreach ( $extra_fields as $key => $field ){ |
|
| 391 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
| 392 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
| 390 | + foreach ( $extra_fields as $key => $field ) { |
|
| 391 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
| 392 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
| 393 | 393 | } |
| 394 | 394 | } |
| 395 | 395 | |
@@ -429,32 +429,32 @@ discard block |
||
| 429 | 429 | 'search_criteria' => null, |
| 430 | 430 | 'sorting' => null, |
| 431 | 431 | 'paging' => null, |
| 432 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
| 432 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
| 433 | 433 | ); |
| 434 | 434 | |
| 435 | 435 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
| 436 | 436 | |
| 437 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
| 438 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
| 437 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 438 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
| 439 | 439 | |
| 440 | 440 | if ( ! is_array( $filter ) ) { |
| 441 | 441 | continue; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | // By default, we want searches to be wildcard for each field. |
| 445 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
| 445 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
| 446 | 446 | |
| 447 | 447 | /** |
| 448 | 448 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
| 449 | 449 | * @param string $operator Existing search operator |
| 450 | 450 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
| 451 | 451 | */ |
| 452 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
| 452 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | // don't send just the [mode] without any field filter. |
| 456 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
| 457 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
| 456 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 457 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | } |
@@ -465,36 +465,36 @@ discard block |
||
| 465 | 465 | * Prepare date formats to be in Gravity Forms DB format; |
| 466 | 466 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
| 467 | 467 | */ |
| 468 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
| 468 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
| 469 | 469 | |
| 470 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
| 470 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
| 471 | 471 | |
| 472 | 472 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
| 473 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
| 473 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 474 | 474 | |
| 475 | 475 | if ( $date ) { |
| 476 | 476 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
| 477 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 477 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 478 | 478 | } else { |
| 479 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
| 479 | + do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] ); |
|
| 480 | 480 | |
| 481 | 481 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
| 482 | - unset( $criteria['search_criteria'][ $key ] ); |
|
| 482 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | |
| 488 | 488 | // Calculate the context view id and send it to the advanced filter |
| 489 | - if( GravityView_frontend::getInstance()->getSingleEntry() ) { |
|
| 490 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 489 | + if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
|
| 490 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 491 | 491 | } elseif ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
| 492 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 492 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 493 | 493 | } elseif ( 'delete' === GFForms::get( 'action' ) ) { |
| 494 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
| 495 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
| 494 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
| 495 | + } elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) { |
|
| 496 | 496 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
| 497 | - $criteria['context_view_id'] = null; |
|
| 497 | + $criteria[ 'context_view_id' ] = null; |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | * @param array $form_ids Forms to search |
| 504 | 504 | * @param int $view_id ID of the view being used to search |
| 505 | 505 | */ |
| 506 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
| 506 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
| 507 | 507 | |
| 508 | 508 | return (array)$criteria; |
| 509 | 509 | } |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | /** Reduce # of database calls */ |
| 534 | 534 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
| 535 | 535 | |
| 536 | - if ( ! empty( $criteria['cache'] ) ) { |
|
| 536 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
| 537 | 537 | |
| 538 | 538 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
| 539 | 539 | |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | |
| 542 | 542 | // Still update the total count when using cached results |
| 543 | 543 | if ( ! is_null( $total ) ) { |
| 544 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
| 544 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | $return = $entries; |
@@ -561,9 +561,9 @@ discard block |
||
| 561 | 561 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
| 562 | 562 | |
| 563 | 563 | // No entries returned from gravityview_before_get_entries |
| 564 | - if( is_null( $entries ) ) { |
|
| 564 | + if ( is_null( $entries ) ) { |
|
| 565 | 565 | |
| 566 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
| 566 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
| 567 | 567 | |
| 568 | 568 | if ( is_wp_error( $entries ) ) { |
| 569 | 569 | do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | } |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
| 575 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
| 576 | 576 | |
| 577 | 577 | // Cache results |
| 578 | 578 | $Cache->set( $entries, 'entries' ); |
@@ -677,12 +677,12 @@ discard block |
||
| 677 | 677 | */ |
| 678 | 678 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
| 679 | 679 | |
| 680 | - if( $check_entry_display ) { |
|
| 680 | + if ( $check_entry_display ) { |
|
| 681 | 681 | // Is the entry allowed |
| 682 | 682 | $entry = self::check_entry_display( $entry ); |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | - if( is_wp_error( $entry ) ) { |
|
| 685 | + if ( is_wp_error( $entry ) ) { |
|
| 686 | 686 | do_action( 'gravityview_log_error', __METHOD__ . ': ' . $entry->get_error_message() ); |
| 687 | 687 | return false; |
| 688 | 688 | } |
@@ -714,12 +714,12 @@ discard block |
||
| 714 | 714 | |
| 715 | 715 | $value = false; |
| 716 | 716 | |
| 717 | - if( 'context' === $val1 ) { |
|
| 717 | + if ( 'context' === $val1 ) { |
|
| 718 | 718 | |
| 719 | 719 | $matching_contexts = array( $val2 ); |
| 720 | 720 | |
| 721 | 721 | // We allow for non-standard contexts. |
| 722 | - switch( $val2 ) { |
|
| 722 | + switch ( $val2 ) { |
|
| 723 | 723 | // Check for either single or edit |
| 724 | 724 | case 'singular': |
| 725 | 725 | $matching_contexts = array( 'single', 'edit' ); |
@@ -775,73 +775,73 @@ discard block |
||
| 775 | 775 | public static function check_entry_display( $entry ) { |
| 776 | 776 | |
| 777 | 777 | if ( ! $entry || is_wp_error( $entry ) ) { |
| 778 | - return new WP_Error('entry_not_found', 'Entry was not found.', $entry ); |
|
| 778 | + return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry ); |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | - if ( empty( $entry['form_id'] ) ) { |
|
| 781 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
| 782 | 782 | return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry ); |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | $criteria = self::calculate_get_entries_criteria(); |
| 786 | 786 | |
| 787 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
| 787 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
| 788 | 788 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
| 789 | 789 | return $entry; |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | // Make sure the current View is connected to the same form as the Entry |
| 793 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
| 794 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
| 793 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
| 794 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
| 795 | 795 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
| 796 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
| 797 | - return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
| 796 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
| 797 | + return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
| 798 | 798 | } |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | - $search_criteria = $criteria['search_criteria']; |
|
| 801 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
| 802 | 802 | |
| 803 | 803 | // check entry status |
| 804 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
| 805 | - return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
| 804 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
| 805 | + return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | // check entry date |
| 809 | 809 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
| 810 | 810 | |
| 811 | 811 | // field_filters |
| 812 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
| 812 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
| 813 | 813 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
| 814 | 814 | return $entry; |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - $filters = $search_criteria['field_filters']; |
|
| 817 | + $filters = $search_criteria[ 'field_filters' ]; |
|
| 818 | 818 | |
| 819 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
| 819 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
| 820 | 820 | |
| 821 | - $form = self::get_form( $entry['form_id'] ); |
|
| 821 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
| 822 | 822 | |
| 823 | 823 | foreach ( $filters as $filter ) { |
| 824 | 824 | |
| 825 | - if ( ! isset( $filter['key'] ) ) { |
|
| 825 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
| 826 | 826 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Filter key not set', $filter ); |
| 827 | 827 | continue; |
| 828 | 828 | } |
| 829 | 829 | |
| 830 | - $k = $filter['key']; |
|
| 830 | + $k = $filter[ 'key' ]; |
|
| 831 | 831 | |
| 832 | 832 | $field = self::get_field( $form, $k ); |
| 833 | 833 | |
| 834 | 834 | if ( is_null( $field ) ) { |
| 835 | 835 | $field_value = isset( $entry[ $k ] ) ? $entry[ $k ] : null; |
| 836 | 836 | } else { |
| 837 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 837 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 838 | 838 | // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it |
| 839 | 839 | $field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? rgar( $field_value, $k ) : $field_value; |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
| 842 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
| 843 | 843 | |
| 844 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
| 844 | + $is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
| 845 | 845 | |
| 846 | 846 | // Any match is all we need to know |
| 847 | 847 | if ( $is_value_match && 'any' === $mode ) { |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | |
| 851 | 851 | // Any failed match is a total fail |
| 852 | 852 | if ( ! $is_value_match && 'all' === $mode ) { |
| 853 | - return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
| 853 | + return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
| 854 | 854 | } |
| 855 | 855 | } |
| 856 | 856 | |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved: all conditions were met' ); |
| 861 | 861 | return $entry; |
| 862 | 862 | } else { |
| 863 | - return new WP_Error('failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
| 863 | + return new WP_Error( 'failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | } |
@@ -901,18 +901,18 @@ discard block |
||
| 901 | 901 | * Gravity Forms code to adjust date to locally-configured Time Zone |
| 902 | 902 | * @see GFCommon::format_date() for original code |
| 903 | 903 | */ |
| 904 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 904 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 905 | 905 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
| 906 | 906 | |
| 907 | - $format = rgar( $atts, 'format' ); |
|
| 908 | - $is_human = ! empty( $atts['human'] ); |
|
| 909 | - $is_diff = ! empty( $atts['diff'] ); |
|
| 910 | - $is_raw = ! empty( $atts['raw'] ); |
|
| 911 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
| 912 | - $include_time = ! empty( $atts['time'] ); |
|
| 907 | + $format = rgar( $atts, 'format' ); |
|
| 908 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
| 909 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
| 910 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
| 911 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
| 912 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
| 913 | 913 | |
| 914 | 914 | // If we're using time diff, we want to have a different default format |
| 915 | - if( empty( $format ) ) { |
|
| 915 | + if ( empty( $format ) ) { |
|
| 916 | 916 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
| 917 | 917 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
| 918 | 918 | } |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | // If raw was specified, don't modify the stored value |
| 921 | 921 | if ( $is_raw ) { |
| 922 | 922 | $formatted_date = $date_string; |
| 923 | - } elseif( $is_timestamp ) { |
|
| 923 | + } elseif ( $is_timestamp ) { |
|
| 924 | 924 | $formatted_date = $date_local_timestamp; |
| 925 | 925 | } elseif ( $is_diff ) { |
| 926 | 926 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | |
| 955 | 955 | $label = rgar( $field, 'label' ); |
| 956 | 956 | |
| 957 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 957 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 958 | 958 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
| 959 | 959 | } |
| 960 | 960 | |
@@ -982,7 +982,7 @@ discard block |
||
| 982 | 982 | $form = GFAPI::get_form( $form ); |
| 983 | 983 | } |
| 984 | 984 | |
| 985 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
| 985 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
| 986 | 986 | return GFFormsModel::get_field( $form, $field_id ); |
| 987 | 987 | } else { |
| 988 | 988 | return null; |
@@ -1029,19 +1029,19 @@ discard block |
||
| 1029 | 1029 | $shortcodes = array(); |
| 1030 | 1030 | |
| 1031 | 1031 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
| 1032 | - if ( empty( $matches ) ){ |
|
| 1032 | + if ( empty( $matches ) ) { |
|
| 1033 | 1033 | return false; |
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | foreach ( $matches as $shortcode ) { |
| 1037 | - if ( $tag === $shortcode[2] ) { |
|
| 1037 | + if ( $tag === $shortcode[ 2 ] ) { |
|
| 1038 | 1038 | |
| 1039 | 1039 | // Changed this to $shortcode instead of true so we get the parsed atts. |
| 1040 | - $shortcodes[] = $shortcode; |
|
| 1040 | + $shortcodes[ ] = $shortcode; |
|
| 1041 | 1041 | |
| 1042 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
| 1043 | - foreach( $results as $result ) { |
|
| 1044 | - $shortcodes[] = $result; |
|
| 1042 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
| 1043 | + foreach ( $results as $result ) { |
|
| 1044 | + $shortcodes[ ] = $result; |
|
| 1045 | 1045 | } |
| 1046 | 1046 | } |
| 1047 | 1047 | } |
@@ -1185,7 +1185,7 @@ discard block |
||
| 1185 | 1185 | public static function get_directory_fields( $post_id, $apply_filter = true ) { |
| 1186 | 1186 | $fields = get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
| 1187 | 1187 | |
| 1188 | - if( $apply_filter ) { |
|
| 1188 | + if ( $apply_filter ) { |
|
| 1189 | 1189 | /** |
| 1190 | 1190 | * @filter `gravityview/configuration/fields` Filter the View fields' configuration array |
| 1191 | 1191 | * @since 1.6.5 |
@@ -1208,7 +1208,7 @@ discard block |
||
| 1208 | 1208 | * @return string html |
| 1209 | 1209 | */ |
| 1210 | 1210 | public static function get_sortable_fields( $formid, $current = '' ) { |
| 1211 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
| 1211 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
| 1212 | 1212 | |
| 1213 | 1213 | if ( empty( $formid ) ) { |
| 1214 | 1214 | return $output; |
@@ -1221,11 +1221,11 @@ discard block |
||
| 1221 | 1221 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
| 1222 | 1222 | |
| 1223 | 1223 | foreach ( $fields as $id => $field ) { |
| 1224 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1224 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1225 | 1225 | continue; |
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
| 1228 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
| 1229 | 1229 | } |
| 1230 | 1230 | } |
| 1231 | 1231 | |
@@ -1260,9 +1260,9 @@ discard block |
||
| 1260 | 1260 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
| 1261 | 1261 | |
| 1262 | 1262 | // TODO: Convert to using array_filter |
| 1263 | - foreach( $fields as $id => $field ) { |
|
| 1263 | + foreach ( $fields as $id => $field ) { |
|
| 1264 | 1264 | |
| 1265 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1265 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1266 | 1266 | unset( $fields[ $id ] ); |
| 1267 | 1267 | } |
| 1268 | 1268 | } |
@@ -1303,14 +1303,14 @@ discard block |
||
| 1303 | 1303 | * @param int|array $field field key or field array |
| 1304 | 1304 | * @return boolean |
| 1305 | 1305 | */ |
| 1306 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1306 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1307 | 1307 | |
| 1308 | 1308 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
| 1309 | 1309 | $form = self::get_form( $form ); |
| 1310 | 1310 | } |
| 1311 | 1311 | |
| 1312 | 1312 | // If entry meta, it's a string. Otherwise, numeric |
| 1313 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1313 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1314 | 1314 | $type = $field; |
| 1315 | 1315 | } else { |
| 1316 | 1316 | $type = self::get_field_type( $form, $field ); |
@@ -1324,9 +1324,9 @@ discard block |
||
| 1324 | 1324 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
| 1325 | 1325 | |
| 1326 | 1326 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
| 1327 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1328 | - if( true === $gv_field->is_numeric ) { |
|
| 1329 | - $numeric_types[] = $gv_field->is_numeric; |
|
| 1327 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1328 | + if ( true === $gv_field->is_numeric ) { |
|
| 1329 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
| 1330 | 1330 | } |
| 1331 | 1331 | } |
| 1332 | 1332 | |
@@ -1476,18 +1476,18 @@ discard block |
||
| 1476 | 1476 | $final_atts = array_filter( $final_atts ); |
| 1477 | 1477 | |
| 1478 | 1478 | // If the href wasn't passed as an attribute, use the value passed to the function |
| 1479 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
| 1480 | - $final_atts['href'] = $href; |
|
| 1479 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
| 1480 | + $final_atts[ 'href' ] = $href; |
|
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | - $final_atts['href'] = esc_url_raw( $href ); |
|
| 1483 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
| 1484 | 1484 | |
| 1485 | 1485 | /** |
| 1486 | 1486 | * Fix potential security issue with target=_blank |
| 1487 | 1487 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
| 1488 | 1488 | */ |
| 1489 | - if( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
| 1490 | - $final_atts['rel'] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1489 | + if ( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
| 1490 | + $final_atts[ 'rel' ] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1491 | 1491 | } |
| 1492 | 1492 | |
| 1493 | 1493 | // Sort the attributes alphabetically, to help testing |
@@ -1499,7 +1499,7 @@ discard block |
||
| 1499 | 1499 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
| 1500 | 1500 | } |
| 1501 | 1501 | |
| 1502 | - if( '' !== $output ) { |
|
| 1502 | + if ( '' !== $output ) { |
|
| 1503 | 1503 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
| 1504 | 1504 | } |
| 1505 | 1505 | |
@@ -1526,7 +1526,7 @@ discard block |
||
| 1526 | 1526 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
| 1527 | 1527 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
| 1528 | 1528 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
| 1529 | - $merged[] = $value; |
|
| 1529 | + $merged[ ] = $value; |
|
| 1530 | 1530 | } else { |
| 1531 | 1531 | $merged[ $key ] = $value; |
| 1532 | 1532 | } |
@@ -1559,7 +1559,7 @@ discard block |
||
| 1559 | 1559 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
| 1560 | 1560 | * @param array $settings Settings array, with `number` key defining the # of users to display |
| 1561 | 1561 | */ |
| 1562 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1562 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1563 | 1563 | |
| 1564 | 1564 | return get_users( $get_users_settings ); |
| 1565 | 1565 | } |
@@ -1579,11 +1579,11 @@ discard block |
||
| 1579 | 1579 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
| 1580 | 1580 | |
| 1581 | 1581 | // If $cap is defined, only show notice if user has capability |
| 1582 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1582 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1583 | 1583 | return ''; |
| 1584 | 1584 | } |
| 1585 | 1585 | |
| 1586 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1586 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
| 1587 | 1587 | } |
| 1588 | 1588 | |
| 1589 | 1589 | /** |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | $this->label = esc_attr__( 'Approve Entries', 'gravityview' ); |
| 24 | 24 | |
| 25 | - $this->description = esc_attr__( 'Approve and reject entries from the View.', 'gravityview' ); |
|
| 25 | + $this->description = esc_attr__( 'Approve and reject entries from the View.', 'gravityview' ); |
|
| 26 | 26 | |
| 27 | 27 | $this->add_hooks(); |
| 28 | 28 | |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
| 46 | 46 | |
| 47 | - unset( $field_options['only_loggedin'] ); |
|
| 47 | + unset( $field_options[ 'only_loggedin' ] ); |
|
| 48 | 48 | |
| 49 | - unset( $field_options['new_window'] ); |
|
| 49 | + unset( $field_options[ 'new_window' ] ); |
|
| 50 | 50 | |
| 51 | - unset( $field_options['show_as_link'] ); |
|
| 51 | + unset( $field_options[ 'show_as_link' ] ); |
|
| 52 | 52 | |
| 53 | 53 | return $field_options; |
| 54 | 54 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | add_action( 'gravityview/field/approval/load_scripts', array( $this, 'enqueue_and_localize_script' ) ); |
| 70 | 70 | |
| 71 | - add_action( 'gravityview_datatables_scripts_styles', array( $this, 'enqueue_and_localize_script' ) ); |
|
| 71 | + add_action( 'gravityview_datatables_scripts_styles', array( $this, 'enqueue_and_localize_script' ) ); |
|
| 72 | 72 | |
| 73 | 73 | add_filter( 'gravityview_get_entries', array( $this, 'modify_search_parameters' ), 1000 ); |
| 74 | 74 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | public function maybe_prevent_field_render( $html, $args ) { |
| 89 | 89 | |
| 90 | 90 | // If the field is `entry_approval` type but the user doesn't have the moderate entries cap, don't render. |
| 91 | - if( $this->name === rgar( $args['field'], 'id' ) && ! GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
| 91 | + if ( $this->name === rgar( $args[ 'field' ], 'id' ) && ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
| 92 | 92 | return ''; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function modify_search_parameters( $parameters ) { |
| 106 | 106 | |
| 107 | - if( $this->name === rgars( $parameters, 'sorting/key' ) ) { |
|
| 108 | - $parameters['sorting']['key'] = 'is_approved'; |
|
| 107 | + if ( $this->name === rgars( $parameters, 'sorting/key' ) ) { |
|
| 108 | + $parameters[ 'sorting' ][ 'key' ] = 'is_approved'; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | return $parameters; |
@@ -121,18 +121,18 @@ discard block |
||
| 121 | 121 | function register_scripts_and_styles() { |
| 122 | 122 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 123 | 123 | |
| 124 | - wp_register_script( 'gravityview-field-approval', GRAVITYVIEW_URL . 'assets/js/field-approval'.$script_debug.'.js', array( 'jquery' ), GravityView_Plugin::version, true ); |
|
| 124 | + wp_register_script( 'gravityview-field-approval', GRAVITYVIEW_URL . 'assets/js/field-approval' . $script_debug . '.js', array( 'jquery' ), GravityView_Plugin::version, true ); |
|
| 125 | 125 | |
| 126 | 126 | $style_path = GRAVITYVIEW_DIR . 'templates/css/field-approval.css'; |
| 127 | 127 | |
| 128 | - if( class_exists( 'GravityView_View' ) ) { |
|
| 128 | + if ( class_exists( 'GravityView_View' ) ) { |
|
| 129 | 129 | /** |
| 130 | 130 | * Override CSS file by placing in your theme's /gravityview/css/ sub-directory. |
| 131 | 131 | */ |
| 132 | 132 | $style_path = GravityView_View::getInstance()->locate_template( 'css/field-approval.css', false ); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $style_url = plugins_url( 'css/field-approval.css', trailingslashit( dirname( $style_path ) ) ); |
|
| 135 | + $style_url = plugins_url( 'css/field-approval.css', trailingslashit( dirname( $style_path ) ) ); |
|
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * @filter `gravityview/field/approval/css_url` URL to the Approval field CSS file. |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | $style_url = apply_filters( 'gravityview/field/approval/css_url', $style_url ); |
| 143 | 143 | |
| 144 | - if( ! empty( $style_url ) ) { |
|
| 144 | + if ( ! empty( $style_url ) ) { |
|
| 145 | 145 | wp_register_style( 'gravityview-field-approval', $style_url, array( 'dashicons' ), GravityView_Plugin::version, 'screen' ); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | public function enqueue_and_localize_script() { |
| 157 | 157 | |
| 158 | 158 | // The script is already registered and enqueued |
| 159 | - if( wp_script_is( 'gravityview-field-approval', 'enqueued' ) ) { |
|
| 159 | + if ( wp_script_is( 'gravityview-field-approval', 'enqueued' ) ) { |
|
| 160 | 160 | return; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | wp_localize_script( 'gravityview-field-approval', 'gvApproval', array( |
| 168 | 168 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 169 | - 'nonce' => wp_create_nonce('gravityview_entry_approval'), |
|
| 169 | + 'nonce' => wp_create_nonce( 'gravityview_entry_approval' ), |
|
| 170 | 170 | 'status' => GravityView_Entry_Approval_Status::get_all(), |
| 171 | - )); |
|
| 171 | + ) ); |
|
| 172 | 172 | |
| 173 | 173 | } |
| 174 | 174 | |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | public function filter_gravityview_entry_default_field( $entry_default_fields, $form, $context ) { |
| 187 | 187 | |
| 188 | - if ( ! isset( $entry_default_fields["{$this->name}"] ) && 'edit' !== $context ) { |
|
| 189 | - $entry_default_fields["{$this->name}"] = array( |
|
| 188 | + if ( ! isset( $entry_default_fields[ "{$this->name}" ] ) && 'edit' !== $context ) { |
|
| 189 | + $entry_default_fields[ "{$this->name}" ] = array( |
|
| 190 | 190 | 'label' => $this->label, |
| 191 | 191 | 'desc' => $this->description, |
| 192 | 192 | 'type' => $this->name, |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public static function get_instance() { |
| 87 | 87 | |
| 88 | - if( empty( self::$instance ) ) { |
|
| 88 | + if ( empty( self::$instance ) ) { |
|
| 89 | 89 | self::$instance = new self; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS ); |
| 120 | 120 | |
| 121 | - if( $with_values ) { |
|
| 121 | + if ( $with_values ) { |
|
| 122 | 122 | $operators_with_values = array(); |
| 123 | - foreach( $operators as $key ) { |
|
| 123 | + foreach ( $operators as $key ) { |
|
| 124 | 124 | $operators_with_values[ $key ] = ''; |
| 125 | 125 | } |
| 126 | 126 | return $operators_with_values; |
@@ -137,14 +137,14 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | function set_operation( $operation = '' ) { |
| 139 | 139 | |
| 140 | - if( empty( $operation ) ) { |
|
| 140 | + if ( empty( $operation ) ) { |
|
| 141 | 141 | return false; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | $operators = $this->get_operators( false ); |
| 145 | 145 | |
| 146 | - if( !in_array( $operation, $operators ) ) { |
|
| 147 | - do_action( 'gravityview_log_debug', __METHOD__ .' Attempted to add invalid operation type.', $operation ); |
|
| 146 | + if ( ! in_array( $operation, $operators ) ) { |
|
| 147 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Attempted to add invalid operation type.', $operation ); |
|
| 148 | 148 | return false; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -164,11 +164,11 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | private function setup_operation_and_comparison() { |
| 166 | 166 | |
| 167 | - foreach( $this->atts as $key => $value ) { |
|
| 167 | + foreach ( $this->atts as $key => $value ) { |
|
| 168 | 168 | |
| 169 | 169 | $valid = $this->set_operation( $key ); |
| 170 | 170 | |
| 171 | - if( $valid ) { |
|
| 171 | + if ( $valid ) { |
|
| 172 | 172 | $this->comparison = $value; |
| 173 | 173 | return true; |
| 174 | 174 | } |
@@ -191,8 +191,8 @@ discard block |
||
| 191 | 191 | return null; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if( empty( $atts ) ) { |
|
| 195 | - do_action( 'gravityview_log_error', __METHOD__.' $atts are empty.', $atts ); |
|
| 194 | + if ( empty( $atts ) ) { |
|
| 195 | + do_action( 'gravityview_log_error', __METHOD__ . ' $atts are empty.', $atts ); |
|
| 196 | 196 | return null; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -203,16 +203,16 @@ discard block |
||
| 203 | 203 | $this->parse_atts(); |
| 204 | 204 | |
| 205 | 205 | // We need an "if" |
| 206 | - if( false === $this->if ) { |
|
| 207 | - do_action( 'gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->passed_atts ); |
|
| 206 | + if ( false === $this->if ) { |
|
| 207 | + do_action( 'gravityview_log_error', __METHOD__ . ' $atts->if is empty.', $this->passed_atts ); |
|
| 208 | 208 | return null; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | $setup = $this->setup_operation_and_comparison(); |
| 212 | 212 | |
| 213 | 213 | // We need an operation and comparison value |
| 214 | - if( ! $setup ) { |
|
| 215 | - do_action( 'gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts ); |
|
| 214 | + if ( ! $setup ) { |
|
| 215 | + do_action( 'gravityview_log_error', __METHOD__ . ' No valid operators were passed.', $this->atts ); |
|
| 216 | 216 | return null; |
| 217 | 217 | } |
| 218 | 218 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | private function get_output() { |
| 247 | 247 | |
| 248 | - if( $this->is_match ) { |
|
| 248 | + if ( $this->is_match ) { |
|
| 249 | 249 | $output = $this->content; |
| 250 | 250 | } else { |
| 251 | 251 | $output = $this->else_content; |
@@ -259,9 +259,9 @@ discard block |
||
| 259 | 259 | * @param string $output HTML/text output |
| 260 | 260 | * @param GVLogic_Shortcode $this This class |
| 261 | 261 | */ |
| 262 | - $output = apply_filters('gravityview/gvlogic/output', $output, $this ); |
|
| 262 | + $output = apply_filters( 'gravityview/gvlogic/output', $output, $this ); |
|
| 263 | 263 | |
| 264 | - do_action( 'gravityview_log_debug', __METHOD__ .' Output: ', $output ); |
|
| 264 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Output: ', $output ); |
|
| 265 | 265 | |
| 266 | 266 | return $output; |
| 267 | 267 | } |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | |
| 278 | 278 | $content = explode( '[else]', $this->passed_content ); |
| 279 | 279 | |
| 280 | - $this->content = $content[0]; |
|
| 280 | + $this->content = $content[ 0 ]; |
|
| 281 | 281 | |
| 282 | - $else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL; |
|
| 282 | + $else_attr = isset( $this->atts[ 'else' ] ) ? $this->atts[ 'else' ] : NULL; |
|
| 283 | 283 | |
| 284 | - $this->else_content = isset( $content[1] ) ? $content[1] : $else_attr; |
|
| 284 | + $this->else_content = isset( $content[ 1 ] ) ? $content[ 1 ] : $else_attr; |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -304,10 +304,10 @@ discard block |
||
| 304 | 304 | $this->atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( $this->passed_atts, $this->atts ) : $this->atts; |
| 305 | 305 | |
| 306 | 306 | // Strip whitespace if it's not default false |
| 307 | - $this->if = ( isset( $this->atts['if'] ) && is_string( $this->atts['if'] ) ) ? trim( $this->atts['if'] ) : false; |
|
| 307 | + $this->if = ( isset( $this->atts[ 'if' ] ) && is_string( $this->atts[ 'if' ] ) ) ? trim( $this->atts[ 'if' ] ) : false; |
|
| 308 | 308 | |
| 309 | 309 | // Make sure the "if" isn't processed in self::setup_operation_and_comparison() |
| 310 | - unset( $this->atts['if'] ); |
|
| 310 | + unset( $this->atts[ 'if' ] ); |
|
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
@@ -232,7 +232,7 @@ |
||
| 232 | 232 | * Does the if and the comparison match? |
| 233 | 233 | * @uses GVCommon::matches_operation |
| 234 | 234 | * |
| 235 | - * @return boolean True: yep; false: nope |
|
| 235 | + * @return boolean|null True: yep; false: nope |
|
| 236 | 236 | */ |
| 237 | 237 | private function set_is_match() { |
| 238 | 238 | $this->is_match = GVCommon::matches_operation( $this->if, $this->comparison, $this->operation ); |
@@ -2,8 +2,9 @@ discard block |
||
| 2 | 2 | namespace GV; |
| 3 | 3 | |
| 4 | 4 | /** If this file is called directly, abort. */ |
| 5 | -if ( ! defined( 'GRAVITYVIEW_DIR' ) ) |
|
| 5 | +if ( ! defined( 'GRAVITYVIEW_DIR' ) ) { |
|
| 6 | 6 | die(); |
| 7 | +} |
|
| 7 | 8 | |
| 8 | 9 | /** |
| 9 | 10 | * The core GravityView API. |
@@ -45,8 +46,9 @@ discard block |
||
| 45 | 46 | * @return \GV\Core The global instance of GravityView Core. |
| 46 | 47 | */ |
| 47 | 48 | public static function get() { |
| 48 | - if ( ! self::$__instance instanceof self ) |
|
| 49 | - self::$__instance = new self; |
|
| 49 | + if ( ! self::$__instance instanceof self ) { |
|
| 50 | + self::$__instance = new self; |
|
| 51 | + } |
|
| 50 | 52 | return self::$__instance; |
| 51 | 53 | } |
| 52 | 54 | |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | if ( 'address' === rgar( $search_field, 'type' ) ) { |
| 60 | 60 | |
| 61 | - $field_id = intval( floor( $search_field['key'] ) ); |
|
| 62 | - $input_id = gravityview_get_input_id_from_id( $search_field['key'] ); |
|
| 61 | + $field_id = intval( floor( $search_field[ 'key' ] ) ); |
|
| 62 | + $input_id = gravityview_get_input_id_from_id( $search_field[ 'key' ] ); |
|
| 63 | 63 | $form = GravityView_View::getInstance()->getForm(); |
| 64 | 64 | |
| 65 | 65 | /** @var GF_Field_Address $address_field */ |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $choices = array(); |
| 69 | 69 | |
| 70 | 70 | $method_name = 'get_choices_' . self::get_input_type_from_input_id( $input_id ); |
| 71 | - if( method_exists( $this, $method_name ) ) { |
|
| 71 | + if ( method_exists( $this, $method_name ) ) { |
|
| 72 | 72 | /** |
| 73 | 73 | * @uses GravityView_Field_Address::get_choices_country() |
| 74 | 74 | * @uses GravityView_Field_Address::get_choices_state() |
@@ -76,12 +76,12 @@ discard block |
||
| 76 | 76 | $choices = $this->{$method_name}( $address_field ); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if( ! empty( $choices ) ) { |
|
| 80 | - $search_field['choices'] = $choices; |
|
| 81 | - $search_field['type'] = rgar( $search_field, 'input'); |
|
| 79 | + if ( ! empty( $choices ) ) { |
|
| 80 | + $search_field[ 'choices' ] = $choices; |
|
| 81 | + $search_field[ 'type' ] = rgar( $search_field, 'input' ); |
|
| 82 | 82 | } else { |
| 83 | - $search_field['type'] = 'text'; |
|
| 84 | - $search_field['input'] = 'input_text'; |
|
| 83 | + $search_field[ 'type' ] = 'text'; |
|
| 84 | + $search_field[ 'input' ] = 'input_text'; |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | $country_choices = array(); |
| 108 | 108 | |
| 109 | 109 | foreach ( $countries as $key => $country ) { |
| 110 | - $country_choices[] = array( |
|
| 110 | + $country_choices[ ] = array( |
|
| 111 | 111 | 'value' => $country, |
| 112 | 112 | 'text' => $country, |
| 113 | 113 | ); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | private function get_choices_state( $address_field ) { |
| 133 | 133 | |
| 134 | - $address_type = empty( $address_field->addressType ) ? $address_field->get_default_address_type( $form['id'] ) : $address_field->addressType; |
|
| 134 | + $address_type = empty( $address_field->addressType ) ? $address_field->get_default_address_type( $form[ 'id' ] ) : $address_field->addressType; |
|
| 135 | 135 | |
| 136 | 136 | $state_choices = array(); |
| 137 | 137 | |
@@ -143,12 +143,12 @@ discard block |
||
| 143 | 143 | $states = GFCommon::get_canadian_provinces(); |
| 144 | 144 | break; |
| 145 | 145 | default: |
| 146 | - $states = empty( $address_types[ $address_type ]['states'] ) ? array() : $address_types[ $address_type ]['states']; |
|
| 146 | + $states = empty( $address_types[ $address_type ][ 'states' ] ) ? array() : $address_types[ $address_type ][ 'states' ]; |
|
| 147 | 147 | break; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | foreach ( $states as $key => $state ) { |
| 151 | - $state_choices[] = array( |
|
| 151 | + $state_choices[ ] = array( |
|
| 152 | 152 | 'value' => $state, |
| 153 | 153 | 'text' => $state, |
| 154 | 154 | ); |
@@ -171,13 +171,13 @@ discard block |
||
| 171 | 171 | // Use the same inputs as the "text" input type allows |
| 172 | 172 | $text_inputs = rgar( $input_types, 'text' ); |
| 173 | 173 | |
| 174 | - $input_types['street'] = $text_inputs; |
|
| 175 | - $input_types['street2'] = $text_inputs; |
|
| 176 | - $input_types['city'] = $text_inputs; |
|
| 174 | + $input_types[ 'street' ] = $text_inputs; |
|
| 175 | + $input_types[ 'street2' ] = $text_inputs; |
|
| 176 | + $input_types[ 'city' ] = $text_inputs; |
|
| 177 | 177 | |
| 178 | - $input_types['state'] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
| 179 | - $input_types['zip'] = array( 'input_text' ); |
|
| 180 | - $input_types['country'] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
| 178 | + $input_types[ 'state' ] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
| 179 | + $input_types[ 'zip' ] = array( 'input_text' ); |
|
| 180 | + $input_types[ 'country' ] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
| 181 | 181 | |
| 182 | 182 | return $input_types; |
| 183 | 183 | } |
@@ -198,10 +198,10 @@ discard block |
||
| 198 | 198 | // Is this search field for an input (eg: 4.2) or the whole address field (eg: 4)? |
| 199 | 199 | $input_id = gravityview_get_input_id_from_id( $field_id ); |
| 200 | 200 | |
| 201 | - if( 'address' === $field_type && $input_id ) { |
|
| 201 | + if ( 'address' === $field_type && $input_id ) { |
|
| 202 | 202 | |
| 203 | 203 | // If the input ID matches an expected address input, set to that. Otherwise, keep existing input type. |
| 204 | - if( $address_field_name = self::get_input_type_from_input_id( $input_id ) ) { |
|
| 204 | + if ( $address_field_name = self::get_input_type_from_input_id( $input_id ) ) { |
|
| 205 | 205 | $input_type = $address_field_name; |
| 206 | 206 | } |
| 207 | 207 | } |
@@ -250,20 +250,20 @@ discard block |
||
| 250 | 250 | function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
| 251 | 251 | |
| 252 | 252 | // If this is NOT the full address field, return default options. |
| 253 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 253 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 254 | 254 | return $field_options; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - if( 'edit' === $context ) { |
|
| 257 | + if ( 'edit' === $context ) { |
|
| 258 | 258 | return $field_options; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | $add_options = array(); |
| 262 | 262 | |
| 263 | - $add_options['show_map_link'] = array( |
|
| 263 | + $add_options[ 'show_map_link' ] = array( |
|
| 264 | 264 | 'type' => 'checkbox', |
| 265 | 265 | 'label' => __( 'Show Map Link:', 'gravityview' ), |
| 266 | - 'desc' => __('Display a "Map It" link below the address', 'gravityview'), |
|
| 266 | + 'desc' => __( 'Display a "Map It" link below the address', 'gravityview' ), |
|
| 267 | 267 | 'value' => true, |
| 268 | 268 | 'merge_tags' => false, |
| 269 | 269 | ); |