@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @return GravityView_Field | bool |
43 | 43 | */ |
44 | 44 | public static function create( $properties ) { |
45 | - $type = isset( $properties['type'] ) ? $properties['type'] : ''; |
|
46 | - $type = empty( $properties['inputType'] ) ? $type : $properties['inputType']; |
|
45 | + $type = isset( $properties[ 'type' ] ) ? $properties[ 'type' ] : ''; |
|
46 | + $type = empty( $properties[ 'inputType' ] ) ? $type : $properties[ 'inputType' ]; |
|
47 | 47 | if ( empty( $type ) || ! isset( self::$_fields[ $type ] ) ) { |
48 | 48 | return new GravityView_Field( $properties ); |
49 | 49 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @return bool True: yes, it exists; False: nope |
63 | 63 | */ |
64 | 64 | public static function exists( $field_name ) { |
65 | - return isset( self::$_fields["{$field_name}"] ); |
|
65 | + return isset( self::$_fields[ "{$field_name}" ] ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | |
97 | 97 | $field_type = is_a( $gf_field, 'GF_Field' ) ? get_class( $gf_field ) : $gf_field; |
98 | 98 | |
99 | - foreach( self::$_fields as $field ) { |
|
100 | - if( $field_type === $field->_gf_field_class_name ) { |
|
99 | + foreach ( self::$_fields as $field ) { |
|
100 | + if ( $field_type === $field->_gf_field_class_name ) { |
|
101 | 101 | return $field; |
102 | 102 | } |
103 | 103 | } |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public static function get_all( $groups = '' ) { |
118 | 118 | |
119 | - if( '' !== $groups ) { |
|
119 | + if ( '' !== $groups ) { |
|
120 | 120 | $return_fields = self::$_fields; |
121 | 121 | |
122 | - $groups = (array) $groups; |
|
122 | + $groups = (array)$groups; |
|
123 | 123 | |
124 | 124 | foreach ( $return_fields as $key => $field ) { |
125 | - if( ! in_array( $field->group, $groups, true ) ) { |
|
125 | + if ( ! in_array( $field->group, $groups, true ) ) { |
|
126 | 126 | unset( $return_fields[ $key ] ); |
127 | 127 | } |
128 | 128 | } |
@@ -21,8 +21,8 @@ |
||
21 | 21 | var $is_numeric = true; |
22 | 22 | |
23 | 23 | public function __construct() { |
24 | - $this->label = __('User IP', 'gravityview'); |
|
25 | - $this->description = __('The IP Address of the user who created the entry.', 'gravityview'); |
|
24 | + $this->label = __( 'User IP', 'gravityview' ); |
|
25 | + $this->description = __( 'The IP Address of the user who created the entry.', 'gravityview' ); |
|
26 | 26 | parent::__construct(); |
27 | 27 | } |
28 | 28 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | |
23 | 23 | public function __construct() { |
24 | 24 | $this->label = esc_html__( 'Entry ID', 'gravityview' ); |
25 | - $this->description = __('The unique ID of the entry.', 'gravityview'); |
|
25 | + $this->description = __( 'The unique ID of the entry.', 'gravityview' ); |
|
26 | 26 | parent::__construct(); |
27 | 27 | } |
28 | 28 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | public function __construct() { |
23 | 23 | $this->label = esc_html__( 'Created By (User)', 'gravityview' ); |
24 | - $this->description = __('Details of the logged-in user who created the entry (if any).', 'gravityview'); |
|
24 | + $this->description = __( 'Details of the logged-in user who created the entry (if any).', 'gravityview' ); |
|
25 | 25 | $this->default_search_label = __( 'Submitted by:', 'gravityview' ); |
26 | 26 | parent::__construct(); |
27 | 27 | } |
@@ -40,23 +40,23 @@ discard block |
||
40 | 40 | |
41 | 41 | $merge_tags = array( |
42 | 42 | array( |
43 | - 'label' => __('Entry Creator: Display Name', 'gravityview'), |
|
43 | + 'label' => __( 'Entry Creator: Display Name', 'gravityview' ), |
|
44 | 44 | 'tag' => '{created_by:display_name}' |
45 | 45 | ), |
46 | 46 | array( |
47 | - 'label' => __('Entry Creator: Email', 'gravityview'), |
|
47 | + 'label' => __( 'Entry Creator: Email', 'gravityview' ), |
|
48 | 48 | 'tag' => '{created_by:user_email}' |
49 | 49 | ), |
50 | 50 | array( |
51 | - 'label' => __('Entry Creator: Username', 'gravityview'), |
|
51 | + 'label' => __( 'Entry Creator: Username', 'gravityview' ), |
|
52 | 52 | 'tag' => '{created_by:user_login}' |
53 | 53 | ), |
54 | 54 | array( |
55 | - 'label' => __('Entry Creator: User ID', 'gravityview'), |
|
55 | + 'label' => __( 'Entry Creator: User ID', 'gravityview' ), |
|
56 | 56 | 'tag' => '{created_by:ID}' |
57 | 57 | ), |
58 | 58 | array( |
59 | - 'label' => __('Entry Creator: Roles', 'gravityview'), |
|
59 | + 'label' => __( 'Entry Creator: Roles', 'gravityview' ), |
|
60 | 60 | 'tag' => '{created_by:roles}' |
61 | 61 | ), |
62 | 62 | ); |
@@ -84,19 +84,19 @@ discard block |
||
84 | 84 | public function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
85 | 85 | |
86 | 86 | // If there are no matches OR the Entry `created_by` isn't set or is 0 (no user) |
87 | - if( empty( $matches ) || empty( $entry['created_by'] ) ) { |
|
87 | + if ( empty( $matches ) || empty( $entry[ 'created_by' ] ) ) { |
|
88 | 88 | return $text; |
89 | 89 | } |
90 | 90 | |
91 | 91 | // Get the creator of the entry |
92 | - $entry_creator = new WP_User( $entry['created_by'] ); |
|
92 | + $entry_creator = new WP_User( $entry[ 'created_by' ] ); |
|
93 | 93 | |
94 | 94 | foreach ( $matches as $match ) { |
95 | 95 | |
96 | - $full_tag = $match[0]; |
|
97 | - $property = $match[1]; |
|
96 | + $full_tag = $match[ 0 ]; |
|
97 | + $property = $match[ 1 ]; |
|
98 | 98 | |
99 | - switch( $property ) { |
|
99 | + switch ( $property ) { |
|
100 | 100 | case '': |
101 | 101 | $value = $entry_creator->ID; |
102 | 102 | break; |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | |
123 | 123 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
124 | 124 | |
125 | - if( 'edit' === $context ) { |
|
125 | + if ( 'edit' === $context ) { |
|
126 | 126 | return $field_options; |
127 | 127 | } |
128 | 128 | |
129 | - $field_options['name_display'] = array( |
|
129 | + $field_options[ 'name_display' ] = array( |
|
130 | 130 | 'type' => 'select', |
131 | 131 | 'label' => __( 'User Format', 'gravityview' ), |
132 | 132 | 'desc' => __( 'How should the User information be displayed?', 'gravityview' ), |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | |
66 | 66 | add_shortcode( 'gv_note_add', array( 'GravityView_Field_Notes', 'get_add_note_part' ) ); |
67 | 67 | |
68 | - add_action( 'wp', array( $this, 'maybe_delete_notes'), 1000 ); |
|
69 | - add_action( 'wp_ajax_nopriv_gv_delete_notes', array( $this, 'maybe_delete_notes') ); |
|
70 | - add_action( 'wp_ajax_gv_delete_notes', array( $this, 'maybe_delete_notes') ); |
|
68 | + add_action( 'wp', array( $this, 'maybe_delete_notes' ), 1000 ); |
|
69 | + add_action( 'wp_ajax_nopriv_gv_delete_notes', array( $this, 'maybe_delete_notes' ) ); |
|
70 | + add_action( 'wp_ajax_gv_delete_notes', array( $this, 'maybe_delete_notes' ) ); |
|
71 | 71 | |
72 | - add_action( 'wp', array( $this, 'maybe_add_note'), 1000 ); |
|
73 | - add_action( 'wp_ajax_nopriv_gv_note_add', array( $this, 'maybe_add_note') ); |
|
74 | - add_action( 'wp_ajax_gv_note_add', array( $this, 'maybe_add_note') ); |
|
72 | + add_action( 'wp', array( $this, 'maybe_add_note' ), 1000 ); |
|
73 | + add_action( 'wp_ajax_nopriv_gv_note_add', array( $this, 'maybe_add_note' ) ); |
|
74 | + add_action( 'wp_ajax_gv_note_add', array( $this, 'maybe_add_note' ) ); |
|
75 | 75 | |
76 | 76 | // add template path to check for field |
77 | 77 | add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
78 | 78 | add_filter( 'gravityview/template/fields_template_paths', array( $this, 'add_template_path' ) ); |
79 | 79 | |
80 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
80 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
81 | 81 | add_action( 'gravityview/field/notes/scripts', array( $this, 'enqueue_scripts' ) ); |
82 | 82 | |
83 | 83 | add_filter( 'gravityview_entry_default_fields', array( $this, 'add_entry_default_field' ), 10, 3 ); |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function add_entry_default_field( $entry_default_fields, $form, $zone ) { |
101 | 101 | |
102 | - if( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
103 | - $entry_default_fields['notes'] = array( |
|
102 | + if ( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
103 | + $entry_default_fields[ 'notes' ] = array( |
|
104 | 104 | 'label' => __( 'Entry Notes', 'gravityview' ), |
105 | 105 | 'type' => 'notes', |
106 | 106 | 'desc' => __( 'Display, add, and delete notes for an entry.', 'gravityview' ), |
@@ -134,23 +134,23 @@ discard block |
||
134 | 134 | public function enqueue_scripts() { |
135 | 135 | global $wp_actions; |
136 | 136 | |
137 | - if( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) { |
|
137 | + if ( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) { |
|
138 | 138 | wp_enqueue_style( 'gravityview-notes' ); |
139 | 139 | wp_enqueue_script( 'gravityview-notes' ); |
140 | 140 | } |
141 | 141 | |
142 | - if( ! wp_script_is( 'gravityview-notes', 'done' ) ) { |
|
142 | + if ( ! wp_script_is( 'gravityview-notes', 'done' ) ) { |
|
143 | 143 | |
144 | 144 | $strings = self::strings(); |
145 | 145 | |
146 | 146 | wp_localize_script( 'gravityview-notes', 'GVNotes', array( |
147 | 147 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
148 | 148 | 'text' => array( |
149 | - 'processing' => $strings['processing'], |
|
150 | - 'delete_confirm' => $strings['delete-confirm'], |
|
151 | - 'note_added' => $strings['added-note'], |
|
152 | - 'error_invalid' => $strings['error-invalid'], |
|
153 | - 'error_empty_note' => $strings['error-empty-note'], |
|
149 | + 'processing' => $strings[ 'processing' ], |
|
150 | + 'delete_confirm' => $strings[ 'delete-confirm' ], |
|
151 | + 'note_added' => $strings[ 'added-note' ], |
|
152 | + 'error_invalid' => $strings[ 'error-invalid' ], |
|
153 | + 'error_empty_note' => $strings[ 'error-empty-note' ], |
|
154 | 154 | ), |
155 | 155 | ) ); |
156 | 156 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return void |
167 | 167 | */ |
168 | 168 | function maybe_add_note() { |
169 | - if ( ! isset( $_POST['action'] ) || 'gv_note_add' !== $_POST['action'] ) { |
|
169 | + if ( ! isset( $_POST[ 'action' ] ) || 'gv_note_add' !== $_POST[ 'action' ] ) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | $post = wp_unslash( $_POST ); |
180 | 180 | |
181 | 181 | if ( $this->doing_ajax ) { |
182 | - parse_str( $post['data'], $data ); |
|
182 | + parse_str( $post[ 'data' ], $data ); |
|
183 | 183 | } else { |
184 | 184 | $data = $post; |
185 | 185 | } |
186 | 186 | |
187 | - $this->process_add_note( (array) $data ); |
|
187 | + $this->process_add_note( (array)$data ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -210,23 +210,23 @@ discard block |
||
210 | 210 | $error = false; |
211 | 211 | $success = false; |
212 | 212 | |
213 | - if( empty( $data['entry-slug'] ) ) { |
|
213 | + if ( empty( $data[ 'entry-slug' ] ) ) { |
|
214 | 214 | |
215 | - $error = self::strings('error-invalid'); |
|
215 | + $error = self::strings( 'error-invalid' ); |
|
216 | 216 | gravityview()->log->error( 'The note is missing an Entry ID.' ); |
217 | 217 | |
218 | 218 | } else { |
219 | 219 | |
220 | - $valid = wp_verify_nonce( $data['gv_note_add'], 'gv_note_add_' . $data['entry-slug'] ); |
|
220 | + $valid = wp_verify_nonce( $data[ 'gv_note_add' ], 'gv_note_add_' . $data[ 'entry-slug' ] ); |
|
221 | 221 | |
222 | 222 | $has_cap = GVCommon::has_cap( 'gravityview_add_entry_notes' ); |
223 | 223 | |
224 | - if( ! $has_cap ) { |
|
224 | + if ( ! $has_cap ) { |
|
225 | 225 | $error = self::strings( 'error-cap-add' ); |
226 | 226 | gravityview()->log->error( 'Adding a note failed: the user does not have the "gravityview_add_entry_notes" capability.' ); |
227 | 227 | } elseif ( $valid ) { |
228 | 228 | |
229 | - $entry = gravityview_get_entry( $data['entry-slug'], true, false ); |
|
229 | + $entry = gravityview_get_entry( $data[ 'entry-slug' ], true, false ); |
|
230 | 230 | |
231 | 231 | $added = $this->add_note( $entry, $data ); |
232 | 232 | |
@@ -244,22 +244,22 @@ discard block |
||
244 | 244 | $this->maybe_send_entry_notes( $note, $entry, $data ); |
245 | 245 | |
246 | 246 | if ( $note ) { |
247 | - $success = self::display_note( $note, ! empty( $data['show-delete'] ) ); |
|
247 | + $success = self::display_note( $note, ! empty( $data[ 'show-delete' ] ) ); |
|
248 | 248 | gravityview()->log->debug( 'The note was successfully created', array( 'data' => compact( 'note', 'data' ) ) ); |
249 | 249 | } else { |
250 | - $error = self::strings('error-add-note'); |
|
250 | + $error = self::strings( 'error-add-note' ); |
|
251 | 251 | gravityview()->log->error( 'The note was not successfully created', array( 'data' => compact( 'note', 'data' ) ) ); |
252 | 252 | } |
253 | 253 | } |
254 | 254 | } else { |
255 | - $error = self::strings('error-invalid'); |
|
255 | + $error = self::strings( 'error-invalid' ); |
|
256 | 256 | gravityview()->log->error( 'Nonce validation failed; the note was not created' ); |
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | 260 | |
261 | - if( $this->doing_ajax ) { |
|
262 | - if( $success ) { |
|
261 | + if ( $this->doing_ajax ) { |
|
262 | + if ( $success ) { |
|
263 | 263 | wp_send_json_success( array( 'html' => $success ) ); |
264 | 264 | } else { |
265 | 265 | $error = $error ? $error : self::strings( 'error-invalid' ); |
@@ -285,11 +285,11 @@ discard block |
||
285 | 285 | return; |
286 | 286 | } |
287 | 287 | |
288 | - if ( isset( $_POST['action'] ) && 'gv_delete_notes' === $_POST['action'] ) { |
|
288 | + if ( isset( $_POST[ 'action' ] ) && 'gv_delete_notes' === $_POST[ 'action' ] ) { |
|
289 | 289 | |
290 | 290 | $post = wp_unslash( $_POST ); |
291 | 291 | if ( $this->doing_ajax ) { |
292 | - parse_str( $post['data'], $data ); |
|
292 | + parse_str( $post[ 'data' ], $data ); |
|
293 | 293 | } else { |
294 | 294 | $data = $post; |
295 | 295 | } |
@@ -320,18 +320,18 @@ discard block |
||
320 | 320 | */ |
321 | 321 | function process_delete_notes( $data ) { |
322 | 322 | |
323 | - $valid = wp_verify_nonce( $data['gv_delete_notes'], 'gv_delete_notes_' . $data['entry-slug'] ); |
|
323 | + $valid = wp_verify_nonce( $data[ 'gv_delete_notes' ], 'gv_delete_notes_' . $data[ 'entry-slug' ] ); |
|
324 | 324 | $has_cap = GVCommon::has_cap( 'gravityview_delete_entry_notes' ); |
325 | 325 | $success = false; |
326 | 326 | |
327 | 327 | if ( $valid && $has_cap ) { |
328 | - GravityView_Entry_Notes::delete_notes( $data['note'] ); |
|
328 | + GravityView_Entry_Notes::delete_notes( $data[ 'note' ] ); |
|
329 | 329 | $success = true; |
330 | 330 | } |
331 | 331 | |
332 | - if( $this->doing_ajax ) { |
|
332 | + if ( $this->doing_ajax ) { |
|
333 | 333 | |
334 | - if( $success ) { |
|
334 | + if ( $success ) { |
|
335 | 335 | wp_send_json_success(); |
336 | 336 | } else { |
337 | 337 | if ( ! $valid ) { |
@@ -364,13 +364,13 @@ discard block |
||
364 | 364 | |
365 | 365 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
366 | 366 | |
367 | - unset( $field_options['show_as_link'] ); |
|
367 | + unset( $field_options[ 'show_as_link' ] ); |
|
368 | 368 | |
369 | 369 | $notes_options = array( |
370 | 370 | 'notes' => array( |
371 | 371 | 'type' => 'checkboxes', |
372 | - 'label' => __('Note Settings', 'gravityview'), |
|
373 | - 'desc' => sprintf( _x('Only users with specific capabilities will be able to view, add and delete notes. %sRead more%s.', '%s is opening and closing HTML link', 'gravityview' ), '<a href="https://docs.gravityview.co/article/311-gravityview-capabilities">', '</a>' ), |
|
372 | + 'label' => __( 'Note Settings', 'gravityview' ), |
|
373 | + 'desc' => sprintf( _x( 'Only users with specific capabilities will be able to view, add and delete notes. %sRead more%s.', '%s is opening and closing HTML link', 'gravityview' ), '<a href="https://docs.gravityview.co/article/311-gravityview-capabilities">', '</a>' ), |
|
374 | 374 | 'options' => array( |
375 | 375 | 'view' => array( |
376 | 376 | 'label' => __( 'Display notes?', 'gravityview' ), |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | 'processing' => __( 'Processing…', 'gravityview' ), |
423 | 423 | 'other-email' => __( 'Other email address', 'gravityview' ), |
424 | 424 | 'email-label' => __( 'Email address', 'gravityview' ), |
425 | - 'email-placeholder' => _x('[email protected]', 'Example email address used as a placeholder', 'gravityview'), |
|
425 | + 'email-placeholder' => _x( '[email protected]', 'Example email address used as a placeholder', 'gravityview' ), |
|
426 | 426 | 'subject-label' => __( 'Subject', 'gravityview' ), |
427 | 427 | 'subject' => __( 'Email subject', 'gravityview' ), |
428 | 428 | 'default-email-subject' => __( 'New entry note', 'gravityview' ), |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | */ |
443 | 443 | $strings = gv_map_deep( apply_filters( 'gravityview/field/notes/strings', $strings ), 'esc_html' ); |
444 | 444 | |
445 | - if( $key ) { |
|
445 | + if ( $key ) { |
|
446 | 446 | return isset( $strings[ $key ] ) ? $strings[ $key ] : ''; |
447 | 447 | } |
448 | 448 | |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | */ |
465 | 465 | static public function display_note( $note, $show_delete = false, $context = null ) { |
466 | 466 | |
467 | - if( ! is_object( $note ) ) { |
|
467 | + if ( ! is_object( $note ) ) { |
|
468 | 468 | return ''; |
469 | 469 | } |
470 | 470 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | } |
520 | 520 | |
521 | 521 | $replacements = array( |
522 | - '{note_id}' => $note_content['note_id'], |
|
522 | + '{note_id}' => $note_content[ 'note_id' ], |
|
523 | 523 | '{row_class}' => 'gv-note', |
524 | 524 | '{note_detail}' => $note_detail_html |
525 | 525 | ); |
@@ -551,13 +551,13 @@ discard block |
||
551 | 551 | |
552 | 552 | $user_data = get_userdata( $current_user->ID ); |
553 | 553 | |
554 | - $note_content = trim( $data['gv-note-content'] ); |
|
554 | + $note_content = trim( $data[ 'gv-note-content' ] ); |
|
555 | 555 | |
556 | - if( empty( $note_content ) ) { |
|
556 | + if ( empty( $note_content ) ) { |
|
557 | 557 | return new WP_Error( 'gv-add-note-empty', __( 'The note is empty.', 'gravityview' ) ); |
558 | 558 | } |
559 | 559 | |
560 | - $return = GravityView_Entry_Notes::add_note( $entry['id'], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' ); |
|
560 | + $return = GravityView_Entry_Notes::add_note( $entry[ 'id' ], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' ); |
|
561 | 561 | |
562 | 562 | return $return; |
563 | 563 | } |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | |
578 | 578 | $atts = shortcode_atts( array( 'entry' => null ), $atts ); |
579 | 579 | |
580 | - if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
580 | + if ( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
581 | 581 | gravityview()->log->error( 'User does not have permission to add entry notes ("gravityview_add_entry_notes").' ); |
582 | 582 | return ''; |
583 | 583 | } |
@@ -599,8 +599,8 @@ discard block |
||
599 | 599 | |
600 | 600 | $visibility_settings = $gravityview_view->getCurrentFieldSetting( 'notes' ); |
601 | 601 | |
602 | - if ( $atts['entry'] ) { |
|
603 | - $entry = GFAPI::get_entry( $atts['entry'] ); |
|
602 | + if ( $atts[ 'entry' ] ) { |
|
603 | + $entry = GFAPI::get_entry( $atts[ 'entry' ] ); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | if ( ! isset( $entry ) || ! $entry ) { |
@@ -618,14 +618,14 @@ discard block |
||
618 | 618 | |
619 | 619 | // Only generate the dropdown if the field settings allow it |
620 | 620 | $email_fields = ''; |
621 | - if( ! empty( $visibility_settings['email'] ) ) { |
|
621 | + if ( ! empty( $visibility_settings[ 'email' ] ) ) { |
|
622 | 622 | $email_fields = self::get_note_email_fields( $entry_slug ); |
623 | 623 | } |
624 | 624 | |
625 | 625 | $add_note_html = str_replace( '{entry_slug}', $entry_slug, $add_note_html ); |
626 | 626 | $add_note_html = str_replace( '{nonce_field}', $nonce_field, $add_note_html ); |
627 | - $add_note_html = str_replace( '{show_delete}', intval( empty( $visibility_settings['delete'] ) ? 0 : $visibility_settings['delete'] ), $add_note_html ); |
|
628 | - $add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html ); |
|
627 | + $add_note_html = str_replace( '{show_delete}', intval( empty( $visibility_settings[ 'delete' ] ) ? 0 : $visibility_settings[ 'delete' ] ), $add_note_html ); |
|
628 | + $add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html ); |
|
629 | 629 | $add_note_html = str_replace( '{url}', esc_url_raw( add_query_arg( array() ) ), $add_note_html ); |
630 | 630 | |
631 | 631 | return $add_note_html; |
@@ -650,8 +650,8 @@ discard block |
||
650 | 650 | $note_emails = array(); |
651 | 651 | |
652 | 652 | foreach ( $email_fields as $email_field ) { |
653 | - if ( ! empty( $entry["{$email_field->id}"] ) && is_email( $entry["{$email_field->id}"] ) ) { |
|
654 | - $note_emails[] = $entry["{$email_field->id}"]; |
|
653 | + if ( ! empty( $entry[ "{$email_field->id}" ] ) && is_email( $entry[ "{$email_field->id}" ] ) ) { |
|
654 | + $note_emails[ ] = $entry[ "{$email_field->id}" ]; |
|
655 | 655 | } |
656 | 656 | } |
657 | 657 | |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | */ |
664 | 664 | $note_emails = apply_filters( 'gravityview/field/notes/emails', $note_emails, $entry ); |
665 | 665 | |
666 | - return (array) $note_emails; |
|
666 | + return (array)$note_emails; |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | /** |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | */ |
680 | 680 | private static function get_note_email_fields( $entry_slug = '' ) { |
681 | 681 | |
682 | - if( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
682 | + if ( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
683 | 683 | gravityview()->log->error( 'User does not have permission to email entry notes ("gravityview_email_entry_notes").' ); |
684 | 684 | return ''; |
685 | 685 | } |
@@ -701,27 +701,27 @@ discard block |
||
701 | 701 | |
702 | 702 | if ( ! empty( $note_emails ) || $include_custom ) { ?> |
703 | 703 | <div class="gv-note-email-container"> |
704 | - <label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings['also-email']; ?></label> |
|
704 | + <label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings[ 'also-email' ]; ?></label> |
|
705 | 705 | <select class="gv-note-email-to" name="gv-note-to" id="gv-note-email-to-<?php echo $entry_slug_esc; ?>"> |
706 | - <option value=""><?php echo $strings['also-email']; ?></option> |
|
706 | + <option value=""><?php echo $strings[ 'also-email' ]; ?></option> |
|
707 | 707 | <?php foreach ( $note_emails as $email ) { |
708 | 708 | ?> |
709 | 709 | <option value="<?php echo esc_attr( $email ); ?>"><?php echo esc_html( $email ); ?></option> |
710 | 710 | <?php } |
711 | - if( $include_custom ) { ?> |
|
712 | - <option value="custom"><?php echo self::strings('other-email'); ?></option> |
|
711 | + if ( $include_custom ) { ?> |
|
712 | + <option value="custom"><?php echo self::strings( 'other-email' ); ?></option> |
|
713 | 713 | <?php } ?> |
714 | 714 | </select> |
715 | 715 | <fieldset class="gv-note-to-container"> |
716 | - <?php if( $include_custom ) { ?> |
|
716 | + <?php if ( $include_custom ) { ?> |
|
717 | 717 | <div class='gv-note-to-custom-container'> |
718 | - <label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings['email-label']; ?></label> |
|
719 | - <input type="text" name="gv-note-to-custom" placeholder="<?php echo $strings['email-placeholder']; ?>" id="gv-note-to-custom-<?php echo $entry_slug_esc; ?>" value="" /> |
|
718 | + <label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'email-label' ]; ?></label> |
|
719 | + <input type="text" name="gv-note-to-custom" placeholder="<?php echo $strings[ 'email-placeholder' ]; ?>" id="gv-note-to-custom-<?php echo $entry_slug_esc; ?>" value="" /> |
|
720 | 720 | </div> |
721 | 721 | <?php } ?> |
722 | 722 | <div class='gv-note-subject-container'> |
723 | - <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings['subject-label']; ?></label> |
|
724 | - <input type="text" name="gv-note-subject" placeholder="<?php echo $strings['subject']; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" /> |
|
723 | + <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'subject-label' ]; ?></label> |
|
724 | + <input type="text" name="gv-note-subject" placeholder="<?php echo $strings[ 'subject' ]; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" /> |
|
725 | 725 | </div> |
726 | 726 | </fieldset> |
727 | 727 | </div> |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | */ |
745 | 745 | private function maybe_send_entry_notes( $note = false, $entry, $data ) { |
746 | 746 | |
747 | - if( ! $note || ! GVCommon::has_cap('gravityview_email_entry_notes') ) { |
|
747 | + if ( ! $note || ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
748 | 748 | gravityview()->log->debug( 'User doesn\'t have "gravityview_email_entry_notes" cap, or $note is empty', array( 'data' => $note ) ); |
749 | 749 | return; |
750 | 750 | } |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | gravityview()->log->debug( '$data', array( 'data' => $data ) ); |
753 | 753 | |
754 | 754 | //emailing notes if configured |
755 | - if ( ! empty( $data['gv-note-to'] ) ) { |
|
755 | + if ( ! empty( $data[ 'gv-note-to' ] ) ) { |
|
756 | 756 | |
757 | 757 | $default_data = array( |
758 | 758 | 'gv-note-to' => '', |
@@ -762,11 +762,11 @@ discard block |
||
762 | 762 | 'current-url' => '', |
763 | 763 | ); |
764 | 764 | |
765 | - $current_user = wp_get_current_user(); |
|
765 | + $current_user = wp_get_current_user(); |
|
766 | 766 | $email_data = wp_parse_args( $data, $default_data ); |
767 | 767 | |
768 | - $from = $current_user->user_email; |
|
769 | - $to = $email_data['gv-note-to']; |
|
768 | + $from = $current_user->user_email; |
|
769 | + $to = $email_data[ 'gv-note-to' ]; |
|
770 | 770 | |
771 | 771 | /** |
772 | 772 | * Documented in get_note_email_fields |
@@ -774,8 +774,8 @@ discard block |
||
774 | 774 | */ |
775 | 775 | $include_custom = apply_filters( 'gravityview/field/notes/custom-email', true ); |
776 | 776 | |
777 | - if( 'custom' === $to && $include_custom ) { |
|
778 | - $to = $email_data['gv-note-to-custom']; |
|
777 | + if ( 'custom' === $to && $include_custom ) { |
|
778 | + $to = $email_data[ 'gv-note-to-custom' ]; |
|
779 | 779 | gravityview()->log->debug( 'Sending note to a custom email address: {to}' . array( 'to' => $to ) ); |
780 | 780 | } |
781 | 781 | |
@@ -786,13 +786,13 @@ discard block |
||
786 | 786 | |
787 | 787 | $bcc = false; |
788 | 788 | $reply_to = $from; |
789 | - $subject = trim( $email_data['gv-note-subject'] ); |
|
789 | + $subject = trim( $email_data[ 'gv-note-subject' ] ); |
|
790 | 790 | |
791 | 791 | // We use empty() here because GF uses empty to check against, too. `0` isn't a valid subject to GF |
792 | 792 | $subject = empty( $subject ) ? self::strings( 'default-email-subject' ) : $subject; |
793 | - $message = $email_data['gv-note-content']; |
|
793 | + $message = $email_data[ 'gv-note-content' ]; |
|
794 | 794 | $email_footer = self::strings( 'email-footer' ); |
795 | - $from_name = $current_user->display_name; |
|
795 | + $from_name = $current_user->display_name; |
|
796 | 796 | $message_format = 'html'; |
797 | 797 | |
798 | 798 | /** |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | |
824 | 824 | GVCommon::send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name, $message_format, '', $entry, false ); |
825 | 825 | |
826 | - $form = isset( $entry['form_id'] ) ? GFAPI::get_form( $entry['form_id'] ) : array(); |
|
826 | + $form = isset( $entry[ 'form_id' ] ) ? GFAPI::get_form( $entry[ 'form_id' ] ) : array(); |
|
827 | 827 | |
828 | 828 | /** |
829 | 829 | * @see https://www.gravityhelp.com/documentation/article/10146-2/ It's here for compatibility with Gravity Forms |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | |
850 | 850 | $output = ''; |
851 | 851 | |
852 | - if( ! empty( $email_footer ) ) { |
|
852 | + if ( ! empty( $email_footer ) ) { |
|
853 | 853 | $url = \GV\Utils::get( $email_data, 'current-url' ); |
854 | 854 | $url = html_entity_decode( $url ); |
855 | 855 | $url = site_url( $url ); |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | |
125 | 125 | $form = false; |
126 | 126 | |
127 | - if( $entry ) { |
|
128 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
127 | + if ( $entry ) { |
|
128 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | return $form; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - return (bool) $has_transaction_data; |
|
204 | + return (bool)$has_transaction_data; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | |
240 | 240 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
241 | 241 | |
242 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
242 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
243 | 243 | |
244 | 244 | return $result; |
245 | 245 | } |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
261 | 261 | */ |
262 | - public static function get_forms( $active = true, $trash = false, $order_by = 'id', $order = 'ASC' ) { |
|
262 | + public static function get_forms( $active = true, $trash = false, $order_by = 'id', $order = 'ASC' ) { |
|
263 | 263 | $forms = array(); |
264 | 264 | if ( ! class_exists( 'GFAPI' ) ) { |
265 | 265 | return array(); |
266 | 266 | } |
267 | 267 | |
268 | - if( 'any' === $active ) { |
|
268 | + if ( 'any' === $active ) { |
|
269 | 269 | $active_forms = GFAPI::get_forms( true, $trash ); |
270 | 270 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
271 | 271 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | $has_post_fields = false; |
298 | 298 | |
299 | 299 | if ( $form ) { |
300 | - foreach ( $form['fields'] as $field ) { |
|
301 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
302 | - $fields["{$field['id']}"] = array( |
|
300 | + foreach ( $form[ 'fields' ] as $field ) { |
|
301 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
302 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
303 | 303 | 'label' => \GV\Utils::get( $field, 'label' ), |
304 | 304 | 'parent' => null, |
305 | 305 | 'type' => \GV\Utils::get( $field, 'type' ), |
@@ -308,10 +308,10 @@ discard block |
||
308 | 308 | ); |
309 | 309 | } |
310 | 310 | |
311 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
312 | - foreach ( $field['inputs'] as $input ) { |
|
311 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
312 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
313 | 313 | |
314 | - if( ! empty( $input['isHidden'] ) ) { |
|
314 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
315 | 315 | continue; |
316 | 316 | } |
317 | 317 | |
@@ -319,10 +319,10 @@ discard block |
||
319 | 319 | * @hack |
320 | 320 | * In case of email/email confirmation, the input for email has the same id as the parent field |
321 | 321 | */ |
322 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
322 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
323 | 323 | continue; |
324 | 324 | } |
325 | - $fields["{$input['id']}"] = array( |
|
325 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
326 | 326 | 'label' => \GV\Utils::get( $input, 'label' ), |
327 | 327 | 'customLabel' => \GV\Utils::get( $input, 'customLabel' ), |
328 | 328 | 'parent' => $field, |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | } |
335 | 335 | |
336 | 336 | |
337 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
337 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
338 | 338 | $has_product_fields = true; |
339 | 339 | } |
340 | 340 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @since 1.7 |
349 | 349 | */ |
350 | 350 | if ( $has_post_fields ) { |
351 | - $fields['post_id'] = array( |
|
351 | + $fields[ 'post_id' ] = array( |
|
352 | 352 | 'label' => __( 'Post ID', 'gravityview' ), |
353 | 353 | 'type' => 'post_id', |
354 | 354 | ); |
@@ -361,11 +361,11 @@ discard block |
||
361 | 361 | foreach ( $payment_fields as $payment_field ) { |
362 | 362 | |
363 | 363 | // Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key |
364 | - if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
364 | + if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
365 | 365 | continue; |
366 | 366 | } |
367 | 367 | |
368 | - $fields["{$payment_field->name}"] = array( |
|
368 | + $fields[ "{$payment_field->name}" ] = array( |
|
369 | 369 | 'label' => $payment_field->label, |
370 | 370 | 'desc' => $payment_field->description, |
371 | 371 | 'type' => $payment_field->name, |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | |
398 | 398 | $fields = array(); |
399 | 399 | |
400 | - foreach ( $extra_fields as $key => $field ){ |
|
401 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
402 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
400 | + foreach ( $extra_fields as $key => $field ) { |
|
401 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
402 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
@@ -439,33 +439,33 @@ discard block |
||
439 | 439 | 'search_criteria' => null, |
440 | 440 | 'sorting' => null, |
441 | 441 | 'paging' => null, |
442 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
442 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
443 | 443 | 'context_view_id' => null, |
444 | 444 | ); |
445 | 445 | |
446 | 446 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
447 | 447 | |
448 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) && is_array( $criteria['search_criteria']['field_filters'] ) ) { |
|
449 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
448 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) && is_array( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
449 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
450 | 450 | |
451 | 451 | if ( ! is_array( $filter ) ) { |
452 | 452 | continue; |
453 | 453 | } |
454 | 454 | |
455 | 455 | // By default, we want searches to be wildcard for each field. |
456 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
456 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
457 | 457 | |
458 | 458 | /** |
459 | 459 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
460 | 460 | * @param string $operator Existing search operator |
461 | 461 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
462 | 462 | */ |
463 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
463 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | // don't send just the [mode] without any field filter. |
467 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
468 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
467 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
468 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | } |
@@ -476,33 +476,33 @@ discard block |
||
476 | 476 | * Prepare date formats to be in Gravity Forms DB format; |
477 | 477 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
478 | 478 | */ |
479 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
479 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
480 | 480 | |
481 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
481 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
482 | 482 | |
483 | 483 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
484 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
484 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
485 | 485 | |
486 | 486 | if ( $date ) { |
487 | 487 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
488 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
488 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
489 | 489 | } else { |
490 | - gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria['search_criteria'][ $key ] ) ); |
|
490 | + gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria[ 'search_criteria' ][ $key ] ) ); |
|
491 | 491 | |
492 | 492 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
493 | - unset( $criteria['search_criteria'][ $key ] ); |
|
493 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | } |
497 | 497 | |
498 | - if ( empty( $criteria['context_view_id'] ) ) { |
|
498 | + if ( empty( $criteria[ 'context_view_id' ] ) ) { |
|
499 | 499 | // Calculate the context view id and send it to the advanced filter |
500 | 500 | if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
501 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
501 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
502 | 502 | } else if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
503 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
503 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
504 | 504 | } else if ( 'delete' === GFForms::get( 'action' ) ) { |
505 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
505 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
506 | 506 | } |
507 | 507 | } |
508 | 508 | |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | * @param array $form_ids Forms to search |
513 | 513 | * @param int $view_id ID of the view being used to search |
514 | 514 | */ |
515 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
515 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
516 | 516 | |
517 | 517 | return (array)$criteria; |
518 | 518 | } |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | /** Reduce # of database calls */ |
547 | 547 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
548 | 548 | |
549 | - if ( ! empty( $criteria['cache'] ) ) { |
|
549 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
550 | 550 | |
551 | 551 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
552 | 552 | |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | |
555 | 555 | // Still update the total count when using cached results |
556 | 556 | if ( ! is_null( $total ) ) { |
557 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
557 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | $return = $entries; |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | $entries = apply_filters_ref_array( 'gravityview_before_get_entries', array( null, $criteria, $passed_criteria, &$total ) ); |
577 | 577 | |
578 | 578 | // No entries returned from gravityview_before_get_entries |
579 | - if( is_null( $entries ) ) { |
|
579 | + if ( is_null( $entries ) ) { |
|
580 | 580 | |
581 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
581 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
582 | 582 | |
583 | 583 | if ( is_wp_error( $entries ) ) { |
584 | 584 | gravityview()->log->error( '{error}', array( 'error' => $entries->get_error_message(), 'data' => $entries ) ); |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | } |
590 | 590 | } |
591 | 591 | |
592 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
592 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
593 | 593 | |
594 | 594 | // Cache results |
595 | 595 | $Cache->set( $entries, 'entries' ); |
@@ -702,18 +702,18 @@ discard block |
||
702 | 702 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry, $view ); |
703 | 703 | |
704 | 704 | // Is the entry allowed |
705 | - if( $check_entry_display ) { |
|
705 | + if ( $check_entry_display ) { |
|
706 | 706 | |
707 | 707 | $gvid = \GV\Utils::_GET( 'gvid' ); |
708 | 708 | |
709 | - if( $gvid ) { |
|
709 | + if ( $gvid ) { |
|
710 | 710 | $view = \GV\View::by_id( $gvid ); |
711 | 711 | } |
712 | 712 | |
713 | 713 | $entry = self::check_entry_display( $entry, $view ); |
714 | 714 | } |
715 | 715 | |
716 | - if( is_wp_error( $entry ) ) { |
|
716 | + if ( is_wp_error( $entry ) ) { |
|
717 | 717 | gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) ); |
718 | 718 | return false; |
719 | 719 | } |
@@ -747,12 +747,12 @@ discard block |
||
747 | 747 | |
748 | 748 | $value = false; |
749 | 749 | |
750 | - if( 'context' === $val1 ) { |
|
750 | + if ( 'context' === $val1 ) { |
|
751 | 751 | |
752 | 752 | $matching_contexts = array( $val2 ); |
753 | 753 | |
754 | 754 | // We allow for non-standard contexts. |
755 | - switch( $val2 ) { |
|
755 | + switch ( $val2 ) { |
|
756 | 756 | // Check for either single or edit |
757 | 757 | case 'singular': |
758 | 758 | $matching_contexts = array( 'single', 'edit' ); |
@@ -795,18 +795,18 @@ discard block |
||
795 | 795 | $json_val_1 = json_decode( $val1, true ); |
796 | 796 | $json_val_2 = json_decode( $val2, true ); |
797 | 797 | |
798 | - if( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
798 | + if ( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
799 | 799 | |
800 | 800 | $json_in = false; |
801 | - $json_val_1 = $json_val_1 ? (array) $json_val_1 : array( $val1 ); |
|
802 | - $json_val_2 = $json_val_2 ? (array) $json_val_2 : array( $val2 ); |
|
801 | + $json_val_1 = $json_val_1 ? (array)$json_val_1 : array( $val1 ); |
|
802 | + $json_val_2 = $json_val_2 ? (array)$json_val_2 : array( $val2 ); |
|
803 | 803 | |
804 | 804 | // For JSON, we want to compare as "in" or "not in" rather than "contains" |
805 | 805 | foreach ( $json_val_1 as $item_1 ) { |
806 | 806 | foreach ( $json_val_2 as $item_2 ) { |
807 | 807 | $json_in = self::matches_operation( $item_1, $item_2, 'is' ); |
808 | 808 | |
809 | - if( $json_in ) { |
|
809 | + if ( $json_in ) { |
|
810 | 810 | break 2; |
811 | 811 | } |
812 | 812 | } |
@@ -857,10 +857,10 @@ discard block |
||
857 | 857 | public static function check_entry_display( $entry, $view = null ) { |
858 | 858 | |
859 | 859 | if ( ! $entry || is_wp_error( $entry ) ) { |
860 | - return new WP_Error('entry_not_found', 'Entry was not found.', $entry ); |
|
860 | + return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry ); |
|
861 | 861 | } |
862 | 862 | |
863 | - if ( empty( $entry['form_id'] ) ) { |
|
863 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
864 | 864 | return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry ); |
865 | 865 | } |
866 | 866 | |
@@ -875,19 +875,19 @@ discard block |
||
875 | 875 | |
876 | 876 | $_gvid = \GV\Utils::_GET( 'gvid' ); |
877 | 877 | |
878 | - if ( $_gvid && $view->ID !== (int) $_gvid ) { |
|
878 | + if ( $_gvid && $view->ID !== (int)$_gvid ) { |
|
879 | 879 | return new WP_Error( 'view_id_not_match_gvid', 'View does not match passed $_GET["gvid"].', $view->ID ); |
880 | 880 | } |
881 | 881 | |
882 | 882 | $view_form_id = $view->form->ID; |
883 | 883 | |
884 | 884 | if ( $view->joins ) { |
885 | - if ( in_array( (int) $entry['form_id'], array_keys( $view::get_joined_forms( $view->ID ) ), true ) ) { |
|
886 | - $view_form_id = $entry['form_id']; |
|
885 | + if ( in_array( (int)$entry[ 'form_id' ], array_keys( $view::get_joined_forms( $view->ID ) ), true ) ) { |
|
886 | + $view_form_id = $entry[ 'form_id' ]; |
|
887 | 887 | } |
888 | 888 | } |
889 | 889 | |
890 | - if ( (int) $view_form_id !== (int) $entry['form_id'] ) { |
|
890 | + if ( (int)$view_form_id !== (int)$entry[ 'form_id' ] ) { |
|
891 | 891 | return new WP_Error( 'view_id_not_match', 'View form source does not match entry form source ID.', $entry ); |
892 | 892 | } |
893 | 893 | |
@@ -895,13 +895,13 @@ discard block |
||
895 | 895 | * Check whether the entry is in the entries subset by running a modified query. |
896 | 896 | */ |
897 | 897 | add_action( 'gravityview/view/query', $entry_subset_callback = function( &$query, $view, $request ) use ( $entry, $view_form_id ) { |
898 | - $_tmp_query = new \GF_Query( $view_form_id, array( |
|
898 | + $_tmp_query = new \GF_Query( $view_form_id, array( |
|
899 | 899 | 'field_filters' => array( |
900 | 900 | 'mode' => 'all', |
901 | 901 | array( |
902 | 902 | 'key' => 'id', |
903 | 903 | 'operation' => 'is', |
904 | - 'value' => $entry['id'] |
|
904 | + 'value' => $entry[ 'id' ] |
|
905 | 905 | ) |
906 | 906 | ) |
907 | 907 | ) ); |
@@ -911,14 +911,14 @@ discard block |
||
911 | 911 | /** @type \GF_Query $query */ |
912 | 912 | $query_parts = $query->_introspect(); |
913 | 913 | |
914 | - $query->where( \GF_Query_Condition::_and( $_tmp_query_parts['where'], $query_parts['where'] ) ); |
|
914 | + $query->where( \GF_Query_Condition::_and( $_tmp_query_parts[ 'where' ], $query_parts[ 'where' ] ) ); |
|
915 | 915 | |
916 | 916 | }, 10, 3 ); |
917 | 917 | |
918 | 918 | // Prevent page offset from being applied to the single entry query; it's used to return to the referring page number |
919 | 919 | add_filter( 'gravityview_search_criteria', $remove_pagenum = function( $criteria ) { |
920 | 920 | |
921 | - $criteria['paging'] = array( |
|
921 | + $criteria[ 'paging' ] = array( |
|
922 | 922 | 'offset' => 0, |
923 | 923 | 'page_size' => 25 |
924 | 924 | ); |
@@ -937,20 +937,20 @@ discard block |
||
937 | 937 | } |
938 | 938 | |
939 | 939 | // This entry is on a View with joins |
940 | - if ( $entries[0]->is_multi() ) { |
|
940 | + if ( $entries[ 0 ]->is_multi() ) { |
|
941 | 941 | |
942 | 942 | $multi_entry_ids = array(); |
943 | 943 | |
944 | - foreach ( $entries[0]->entries as $multi_entry ) { |
|
945 | - $multi_entry_ids[] = (int) $multi_entry->ID; |
|
944 | + foreach ( $entries[ 0 ]->entries as $multi_entry ) { |
|
945 | + $multi_entry_ids[ ] = (int)$multi_entry->ID; |
|
946 | 946 | } |
947 | 947 | |
948 | - if ( ! in_array( (int) $entry['id'], $multi_entry_ids, true ) ) { |
|
948 | + if ( ! in_array( (int)$entry[ 'id' ], $multi_entry_ids, true ) ) { |
|
949 | 949 | remove_action( 'gravityview/view/query', $entry_subset_callback ); |
950 | 950 | return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' ); |
951 | 951 | } |
952 | 952 | |
953 | - } elseif ( (int) $entries[0]->ID !== (int) $entry['id'] ) { |
|
953 | + } elseif ( (int)$entries[ 0 ]->ID !== (int)$entry[ 'id' ] ) { |
|
954 | 954 | remove_action( 'gravityview/view/query', $entry_subset_callback ); |
955 | 955 | return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' ); |
956 | 956 | } |
@@ -995,18 +995,18 @@ discard block |
||
995 | 995 | * Gravity Forms code to adjust date to locally-configured Time Zone |
996 | 996 | * @see GFCommon::format_date() for original code |
997 | 997 | */ |
998 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
998 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
999 | 999 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
1000 | 1000 | |
1001 | - $format = \GV\Utils::get( $atts, 'format' ); |
|
1002 | - $is_human = ! empty( $atts['human'] ); |
|
1003 | - $is_diff = ! empty( $atts['diff'] ); |
|
1004 | - $is_raw = ! empty( $atts['raw'] ); |
|
1005 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
1006 | - $include_time = ! empty( $atts['time'] ); |
|
1001 | + $format = \GV\Utils::get( $atts, 'format' ); |
|
1002 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
1003 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
1004 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
1005 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
1006 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
1007 | 1007 | |
1008 | 1008 | // If we're using time diff, we want to have a different default format |
1009 | - if( empty( $format ) ) { |
|
1009 | + if ( empty( $format ) ) { |
|
1010 | 1010 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
1011 | 1011 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
1012 | 1012 | } |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | // If raw was specified, don't modify the stored value |
1015 | 1015 | if ( $is_raw ) { |
1016 | 1016 | $formatted_date = $date_string; |
1017 | - } elseif( $is_timestamp ) { |
|
1017 | + } elseif ( $is_timestamp ) { |
|
1018 | 1018 | $formatted_date = $date_local_timestamp; |
1019 | 1019 | } elseif ( $is_diff ) { |
1020 | 1020 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | |
1048 | 1048 | $label = \GV\Utils::get( $field, 'label' ); |
1049 | 1049 | |
1050 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
1050 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
1051 | 1051 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
1052 | 1052 | } |
1053 | 1053 | |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | $form = GFAPI::get_form( $form ); |
1075 | 1075 | } |
1076 | 1076 | |
1077 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
1077 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
1078 | 1078 | return GFFormsModel::get_field( $form, $field_id ); |
1079 | 1079 | } else { |
1080 | 1080 | return null; |
@@ -1121,19 +1121,19 @@ discard block |
||
1121 | 1121 | $shortcodes = array(); |
1122 | 1122 | |
1123 | 1123 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
1124 | - if ( empty( $matches ) ){ |
|
1124 | + if ( empty( $matches ) ) { |
|
1125 | 1125 | return false; |
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | foreach ( $matches as $shortcode ) { |
1129 | - if ( $tag === $shortcode[2] ) { |
|
1129 | + if ( $tag === $shortcode[ 2 ] ) { |
|
1130 | 1130 | |
1131 | 1131 | // Changed this to $shortcode instead of true so we get the parsed atts. |
1132 | - $shortcodes[] = $shortcode; |
|
1132 | + $shortcodes[ ] = $shortcode; |
|
1133 | 1133 | |
1134 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
1135 | - foreach( $results as $result ) { |
|
1136 | - $shortcodes[] = $result; |
|
1134 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
1135 | + foreach ( $results as $result ) { |
|
1136 | + $shortcodes[ ] = $result; |
|
1137 | 1137 | } |
1138 | 1138 | } |
1139 | 1139 | } |
@@ -1165,7 +1165,7 @@ discard block |
||
1165 | 1165 | 'post_type' => 'gravityview', |
1166 | 1166 | 'posts_per_page' => 100, |
1167 | 1167 | 'meta_key' => '_gravityview_form_id', |
1168 | - 'meta_value' => (int) $form_id, |
|
1168 | + 'meta_value' => (int)$form_id, |
|
1169 | 1169 | ); |
1170 | 1170 | $args = wp_parse_args( $args, $defaults ); |
1171 | 1171 | $views = get_posts( $args ); |
@@ -1177,21 +1177,21 @@ discard block |
||
1177 | 1177 | |
1178 | 1178 | $data = unserialize( $view->meta_value ); |
1179 | 1179 | |
1180 | - if( ! $data || ! is_array( $data ) ) { |
|
1180 | + if ( ! $data || ! is_array( $data ) ) { |
|
1181 | 1181 | continue; |
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | foreach ( $data as $datum ) { |
1185 | - if ( ! empty( $datum[2] ) && (int) $datum[2] === (int) $form_id ) { |
|
1186 | - $joined_forms[] = $view->post_id; |
|
1185 | + if ( ! empty( $datum[ 2 ] ) && (int)$datum[ 2 ] === (int)$form_id ) { |
|
1186 | + $joined_forms[ ] = $view->post_id; |
|
1187 | 1187 | } |
1188 | 1188 | } |
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | if ( $joined_forms ) { |
1192 | - $joined_args = array( |
|
1192 | + $joined_args = array( |
|
1193 | 1193 | 'post_type' => 'gravityview', |
1194 | - 'posts_per_page' => $args['posts_per_page'], |
|
1194 | + 'posts_per_page' => $args[ 'posts_per_page' ], |
|
1195 | 1195 | 'post__in' => $joined_forms, |
1196 | 1196 | ); |
1197 | 1197 | $views = array_merge( $views, get_posts( $joined_args ) ); |
@@ -1347,7 +1347,7 @@ discard block |
||
1347 | 1347 | |
1348 | 1348 | $directory_widgets = wp_parse_args( $view_widgets, $defaults ); |
1349 | 1349 | |
1350 | - if( $json_decode ) { |
|
1350 | + if ( $json_decode ) { |
|
1351 | 1351 | $directory_widgets = gv_map_deep( $directory_widgets, 'gv_maybe_json_decode' ); |
1352 | 1352 | } |
1353 | 1353 | |
@@ -1362,7 +1362,7 @@ discard block |
||
1362 | 1362 | * @return string html |
1363 | 1363 | */ |
1364 | 1364 | public static function get_sortable_fields( $formid, $current = '' ) { |
1365 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default (Entry ID)', 'gravityview' ) .'</option>'; |
|
1365 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default (Entry ID)', 'gravityview' ) . '</option>'; |
|
1366 | 1366 | |
1367 | 1367 | if ( empty( $formid ) ) { |
1368 | 1368 | return $output; |
@@ -1375,11 +1375,11 @@ discard block |
||
1375 | 1375 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
1376 | 1376 | |
1377 | 1377 | foreach ( $fields as $id => $field ) { |
1378 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1378 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1379 | 1379 | continue; |
1380 | 1380 | } |
1381 | 1381 | |
1382 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1382 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
1383 | 1383 | } |
1384 | 1384 | } |
1385 | 1385 | |
@@ -1418,16 +1418,16 @@ discard block |
||
1418 | 1418 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1419 | 1419 | |
1420 | 1420 | // TODO: Convert to using array_filter |
1421 | - foreach( $fields as $id => $field ) { |
|
1421 | + foreach ( $fields as $id => $field ) { |
|
1422 | 1422 | |
1423 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1423 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1424 | 1424 | unset( $fields[ $id ] ); |
1425 | 1425 | } |
1426 | 1426 | |
1427 | 1427 | /** |
1428 | 1428 | * Merge date and time subfields. |
1429 | 1429 | */ |
1430 | - if ( in_array( $field['type'], array( 'date', 'time' ) ) && ! empty( $field['parent'] ) ) { |
|
1430 | + if ( in_array( $field[ 'type' ], array( 'date', 'time' ) ) && ! empty( $field[ 'parent' ] ) ) { |
|
1431 | 1431 | $fields[ intval( $id ) ] = array( |
1432 | 1432 | 'label' => \GV\Utils::get( $field, 'parent/label' ), |
1433 | 1433 | 'parent' => null, |
@@ -1477,14 +1477,14 @@ discard block |
||
1477 | 1477 | * @param int|array $field field key or field array |
1478 | 1478 | * @return boolean |
1479 | 1479 | */ |
1480 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1480 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
1481 | 1481 | |
1482 | 1482 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
1483 | 1483 | $form = self::get_form( $form ); |
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | // If entry meta, it's a string. Otherwise, numeric |
1487 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1487 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1488 | 1488 | $type = $field; |
1489 | 1489 | } else { |
1490 | 1490 | $type = self::get_field_type( $form, $field ); |
@@ -1498,9 +1498,9 @@ discard block |
||
1498 | 1498 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
1499 | 1499 | |
1500 | 1500 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1501 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1502 | - if( true === $gv_field->is_numeric ) { |
|
1503 | - $numeric_types[] = $gv_field->is_numeric; |
|
1501 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1502 | + if ( true === $gv_field->is_numeric ) { |
|
1503 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
1504 | 1504 | } |
1505 | 1505 | } |
1506 | 1506 | |
@@ -1651,18 +1651,18 @@ discard block |
||
1651 | 1651 | $final_atts = array_filter( $final_atts ); |
1652 | 1652 | |
1653 | 1653 | // If the href wasn't passed as an attribute, use the value passed to the function |
1654 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1655 | - $final_atts['href'] = $href; |
|
1654 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
1655 | + $final_atts[ 'href' ] = $href; |
|
1656 | 1656 | } |
1657 | 1657 | |
1658 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1658 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
1659 | 1659 | |
1660 | 1660 | /** |
1661 | 1661 | * Fix potential security issue with target=_blank |
1662 | 1662 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
1663 | 1663 | */ |
1664 | - if( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
1665 | - $final_atts['rel'] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1664 | + if ( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
1665 | + $final_atts[ 'rel' ] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1666 | 1666 | } |
1667 | 1667 | |
1668 | 1668 | // Sort the attributes alphabetically, to help testing |
@@ -1674,7 +1674,7 @@ discard block |
||
1674 | 1674 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
1675 | 1675 | } |
1676 | 1676 | |
1677 | - if( '' !== $output ) { |
|
1677 | + if ( '' !== $output ) { |
|
1678 | 1678 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
1679 | 1679 | } |
1680 | 1680 | |
@@ -1701,7 +1701,7 @@ discard block |
||
1701 | 1701 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
1702 | 1702 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
1703 | 1703 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
1704 | - $merged[] = $value; |
|
1704 | + $merged[ ] = $value; |
|
1705 | 1705 | } else { |
1706 | 1706 | $merged[ $key ] = $value; |
1707 | 1707 | } |
@@ -1734,7 +1734,7 @@ discard block |
||
1734 | 1734 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1735 | 1735 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1736 | 1736 | */ |
1737 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1737 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1738 | 1738 | |
1739 | 1739 | return get_users( $get_users_settings ); |
1740 | 1740 | } |
@@ -1754,11 +1754,11 @@ discard block |
||
1754 | 1754 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
1755 | 1755 | |
1756 | 1756 | // If $cap is defined, only show notice if user has capability |
1757 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1757 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1758 | 1758 | return ''; |
1759 | 1759 | } |
1760 | 1760 | |
1761 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1761 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
1762 | 1762 | } |
1763 | 1763 | |
1764 | 1764 | /** |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | ?> |
10 | 10 | <label for="<?php echo $this->get_field_id(); ?>" class="<?php echo $this->get_label_class(); ?>"><?php |
11 | 11 | |
12 | - echo '<span class="gv-label">'.$this->get_field_label().'</span>'; |
|
12 | + echo '<span class="gv-label">' . $this->get_field_label() . '</span>'; |
|
13 | 13 | echo $this->get_tooltip() . $this->get_field_desc(); |
14 | 14 | ?><div> |
15 | 15 | <?php $this->render_input(); ?> |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | function render_input( $override_input = null ) { |
22 | - if( isset( $override_input ) ) { |
|
22 | + if ( isset( $override_input ) ) { |
|
23 | 23 | echo $override_input; |
24 | 24 | return; |
25 | 25 | } |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | |
29 | 29 | $show_mt = $this->show_merge_tags(); |
30 | 30 | |
31 | - if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
31 | + if ( $show_mt && $this->field[ 'merge_tags' ] !== false || $this->field[ 'merge_tags' ] === 'force' ) { |
|
32 | 32 | $class .= ' merge-tag-support mt-position-right '; |
33 | 33 | |
34 | - if( empty( $this->field['show_all_fields'] ) ) { |
|
34 | + if ( empty( $this->field[ 'show_all_fields' ] ) ) { |
|
35 | 35 | $class .= ' mt-hide_all_fields '; |
36 | 36 | } |
37 | 37 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | # $this->codemirror( $this->get_field_id() ); |
50 | 50 | |
51 | 51 | ?> |
52 | - <textarea name="<?php echo esc_attr( $this->name ); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>" id="<?php echo $this->get_field_id(); ?>" class="<?php echo gravityview_sanitize_html_class( $class ); ?>" rows="<?php echo absint( $rows ); ?>"><?php echo esc_textarea( $this->value ); ?></textarea> |
|
52 | + <textarea name="<?php echo esc_attr( $this->name ); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>" id="<?php echo $this->get_field_id(); ?>" class="<?php echo gravityview_sanitize_html_class( $class ); ?>" rows="<?php echo absint( $rows ); ?>"><?php echo esc_textarea( $this->value ); ?></textarea> |
|
53 | 53 | <?php |
54 | 54 | } |
55 | 55 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | ?> |
67 | 67 | |
68 | 68 | <script> |
69 | - wp.codeEditor.initialize( "<?php echo $field_id;?>", {}); |
|
69 | + wp.codeEditor.initialize( "<?php echo $field_id; ?>", {}); |
|
70 | 70 | </script> |
71 | 71 | <?php |
72 | 72 | } |
@@ -32,25 +32,25 @@ |
||
32 | 32 | |
33 | 33 | public function __construct() { |
34 | 34 | $this->label = esc_html__( 'Link to Single Entry', 'gravityview' ); |
35 | - $this->description = esc_html__('A dedicated link to the single entry with customizable text.', 'gravityview'); |
|
35 | + $this->description = esc_html__( 'A dedicated link to the single entry with customizable text.', 'gravityview' ); |
|
36 | 36 | parent::__construct(); |
37 | 37 | } |
38 | 38 | |
39 | 39 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
40 | 40 | |
41 | 41 | // Always a link! |
42 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
42 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] ); |
|
43 | 43 | |
44 | - if( 'edit' === $context ) { |
|
44 | + if ( 'edit' === $context ) { |
|
45 | 45 | return $field_options; |
46 | 46 | } |
47 | 47 | |
48 | 48 | $add_options = array(); |
49 | - $add_options['entry_link_text'] = array( |
|
49 | + $add_options[ 'entry_link_text' ] = array( |
|
50 | 50 | 'type' => 'text', |
51 | 51 | 'label' => __( 'Link Text:', 'gravityview' ), |
52 | 52 | 'desc' => NULL, |
53 | - 'value' => __('View Details', 'gravityview'), |
|
53 | + 'value' => __( 'View Details', 'gravityview' ), |
|
54 | 54 | 'merge_tags' => true, |
55 | 55 | ); |
56 | 56 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | function load() { |
26 | 26 | |
27 | - if( !is_admin() ) { |
|
27 | + if ( ! is_admin() ) { |
|
28 | 28 | return; |
29 | 29 | } |
30 | 30 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 ); |
39 | 39 | |
40 | 40 | // add tooltips |
41 | - add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'tooltips') ); |
|
41 | + add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'tooltips' ) ); |
|
42 | 42 | |
43 | 43 | // custom fields' options for zone EDIT |
44 | 44 | add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 6 ); |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | */ |
78 | 78 | function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
79 | 79 | |
80 | - if( $zone !== 'edit' ) { |
|
80 | + if ( $zone !== 'edit' ) { |
|
81 | 81 | |
82 | - $entry_default_fields['edit_link'] = array( |
|
83 | - 'label' => __('Link to Edit Entry', 'gravityview'), |
|
82 | + $entry_default_fields[ 'edit_link' ] = array( |
|
83 | + 'label' => __( 'Link to Edit Entry', 'gravityview' ), |
|
84 | 84 | 'type' => 'edit_link', |
85 | - 'desc' => __('A link to edit the entry. Visible based on View settings.', 'gravityview'), |
|
85 | + 'desc' => __( 'A link to edit the entry. Visible based on View settings.', 'gravityview' ), |
|
86 | 86 | 'icon' => 'dashicons-welcome-write-blog', |
87 | 87 | ); |
88 | 88 | |
@@ -107,12 +107,12 @@ discard block |
||
107 | 107 | $caps = $visibility_caps; |
108 | 108 | |
109 | 109 | // If we're configuring fields in the edit context, we want a limited selection |
110 | - if( $context === 'edit' ) { |
|
110 | + if ( $context === 'edit' ) { |
|
111 | 111 | |
112 | 112 | // Remove other built-in caps. |
113 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); |
|
113 | + unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] ); |
|
114 | 114 | |
115 | - $caps['read'] = _x('Entry Creator','User capability', 'gravityview'); |
|
115 | + $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | return $caps; |
@@ -132,16 +132,16 @@ discard block |
||
132 | 132 | function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
133 | 133 | |
134 | 134 | // Always a link, never a filter |
135 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
135 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] ); |
|
136 | 136 | |
137 | 137 | // Edit Entry link should only appear to visitors capable of editing entries |
138 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
138 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
139 | 139 | |
140 | - $add_option['edit_link'] = array( |
|
140 | + $add_option[ 'edit_link' ] = array( |
|
141 | 141 | 'type' => 'text', |
142 | 142 | 'label' => __( 'Edit Link Text', 'gravityview' ), |
143 | 143 | 'desc' => NULL, |
144 | - 'value' => __('Link to Edit Entry', 'gravityview'), |
|
144 | + 'value' => __( 'Link to Edit Entry', 'gravityview' ), |
|
145 | 145 | 'merge_tags' => true, |
146 | 146 | ); |
147 | 147 | |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | |
158 | 158 | $return = $tooltips; |
159 | 159 | |
160 | - $return['allow_edit_cap'] = array( |
|
161 | - 'title' => __('Limiting Edit Access', 'gravityview'), |
|
162 | - 'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'), |
|
160 | + $return[ 'allow_edit_cap' ] = array( |
|
161 | + 'title' => __( 'Limiting Edit Access', 'gravityview' ), |
|
162 | + 'value' => __( 'Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview' ), |
|
163 | 163 | ); |
164 | 164 | |
165 | 165 | return $return; |
@@ -180,12 +180,12 @@ discard block |
||
180 | 180 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
181 | 181 | |
182 | 182 | // We only want to modify the settings for the edit context |
183 | - if( 'edit' !== $context ) { |
|
183 | + if ( 'edit' !== $context ) { |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * @since 1.8.4 |
187 | 187 | */ |
188 | - $field_options['new_window'] = array( |
|
188 | + $field_options[ 'new_window' ] = array( |
|
189 | 189 | 'type' => 'checkbox', |
190 | 190 | 'label' => __( 'Open link in a new tab or window?', 'gravityview' ), |
191 | 191 | 'value' => false, |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | // Entry field is only for logged in users |
198 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
198 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
199 | 199 | |
200 | 200 | $add_options = array( |
201 | 201 | 'allow_edit_cap' => array( |