@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | $search_field = $gravityview_view->search_field; |
11 | 11 | |
12 | 12 | // Make sure that there are choices to display |
13 | -if( empty( $search_field['choices'] ) ) { |
|
13 | +if ( empty( $search_field[ 'choices' ] ) ) { |
|
14 | 14 | gravityview()->log->debug( 'search-field-multiselect.php - No choices for field' ); |
15 | 15 | return; |
16 | 16 | } |
@@ -21,19 +21,19 @@ discard block |
||
21 | 21 | * @param string $default_option Default: `—` (—) |
22 | 22 | * @param string $field_type Field type: "select" or "multiselect" |
23 | 23 | */ |
24 | -$default_option = apply_filters('gravityview/extension/search/select_default', '—', 'multiselect' ); |
|
24 | +$default_option = apply_filters( 'gravityview/extension/search/select_default', '—', 'multiselect' ); |
|
25 | 25 | |
26 | 26 | ?> |
27 | 27 | <div class="gv-search-box gv-search-field-multiselect"> |
28 | - <?php if( ! gv_empty( $search_field['label'], false, false ) ) { ?> |
|
29 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label> |
|
28 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false, false ) ) { ?> |
|
29 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"><?php echo esc_html( $search_field[ 'label' ] ); ?></label> |
|
30 | 30 | <?php } ?> |
31 | 31 | <p> |
32 | - <select name="<?php echo esc_attr( $search_field['name'] ); ?>[]" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" multiple> |
|
33 | - <option value="" <?php gv_selected( '', $search_field['value'], true ); ?>><?php echo esc_html( $default_option ); ?></option> |
|
32 | + <select name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>[]" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" multiple> |
|
33 | + <option value="" <?php gv_selected( '', $search_field[ 'value' ], true ); ?>><?php echo esc_html( $default_option ); ?></option> |
|
34 | 34 | <?php |
35 | - foreach( $search_field['choices'] as $choice ) : ?> |
|
36 | - <option value="<?php echo esc_attr( $choice['value'] ); ?>" <?php gv_selected( $choice['value'], $search_field['value'], true ); ?>><?php echo esc_html( $choice['text'] ); ?></option> |
|
35 | + foreach ( $search_field[ 'choices' ] as $choice ) : ?> |
|
36 | + <option value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" <?php gv_selected( $choice[ 'value' ], $search_field[ 'value' ], true ); ?>><?php echo esc_html( $choice[ 'text' ] ); ?></option> |
|
37 | 37 | <?php endforeach; ?> |
38 | 38 | </select> |
39 | 39 | </p> |
@@ -28,11 +28,11 @@ |
||
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' ) { |
|
32 | - $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
|
33 | - } |
|
34 | - $class .= \GV\Utils::get( $this->field, 'class', 'widefat' ); |
|
35 | - $placeholder = \GV\Utils::get( $this->field, 'placeholder' ); |
|
31 | + if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
32 | + $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
|
33 | + } |
|
34 | + $class .= \GV\Utils::get( $this->field, 'class', 'widefat' ); |
|
35 | + $placeholder = \GV\Utils::get( $this->field, 'placeholder' ); |
|
36 | 36 | ?> |
37 | 37 | <input name="<?php echo esc_attr( $this->name ); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>" id="<?php echo $this->get_field_id(); ?>" type="text" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>"> |
38 | 38 | <?php |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | ?> |
9 | 9 | <label for="<?php echo $this->get_field_id(); ?>" class="<?php echo $this->get_label_class(); ?>"><?php |
10 | 10 | |
11 | - echo '<span class="gv-label">'.$this->get_field_label().'</span>'; |
|
11 | + echo '<span class="gv-label">' . $this->get_field_label() . '</span>'; |
|
12 | 12 | echo $this->get_tooltip() . $this->get_field_desc(); |
13 | 13 | ?><div> |
14 | 14 | <?php $this->render_input(); ?> |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | function render_input( $override_input = null ) { |
21 | 21 | |
22 | - if( isset( $override_input ) ) { |
|
22 | + if ( isset( $override_input ) ) { |
|
23 | 23 | echo $override_input; |
24 | 24 | return; |
25 | 25 | } |
@@ -28,7 +28,7 @@ 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 mt-hide_all_fields '; |
33 | 33 | } |
34 | 34 | $class .= \GV\Utils::get( $this->field, 'class', 'widefat' ); |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * @param array $callback_args Arguments passed to the callback |
98 | 98 | * @return void |
99 | 99 | */ |
100 | - function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = array() ) { |
|
100 | + function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = array() ) { |
|
101 | 101 | |
102 | - $this->id = $this->prefix.$id; |
|
102 | + $this->id = $this->prefix . $id; |
|
103 | 103 | $this->title = $title; |
104 | 104 | $this->render_template_file = $file; |
105 | 105 | $this->callback = $callback; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | function parse_icon_class_name( $icon_class_name = '' ) { |
120 | 120 | |
121 | - if( preg_match( '/dashicon/i', $icon_class_name ) ) { |
|
121 | + if ( preg_match( '/dashicon/i', $icon_class_name ) ) { |
|
122 | 122 | $icon_class_name = 'dashicons ' . $icon_class_name; |
123 | 123 | } |
124 | 124 | |
@@ -142,29 +142,29 @@ discard block |
||
142 | 142 | */ |
143 | 143 | function render( $post ) { |
144 | 144 | |
145 | - if( !empty( $this->render_template_file ) ) { |
|
145 | + if ( ! empty( $this->render_template_file ) ) { |
|
146 | 146 | |
147 | 147 | $file = $this->render_template_file; |
148 | 148 | |
149 | 149 | // If the full path exists, use it |
150 | - if( file_exists( $file ) ) { |
|
150 | + if ( file_exists( $file ) ) { |
|
151 | 151 | $path = $file; |
152 | 152 | } else { |
153 | - $path = GRAVITYVIEW_DIR .'includes/admin/metaboxes/views/'.$file; |
|
153 | + $path = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/views/' . $file; |
|
154 | 154 | } |
155 | 155 | |
156 | - if( file_exists( $path ) ) { |
|
156 | + if ( file_exists( $path ) ) { |
|
157 | 157 | include $path; |
158 | 158 | } else { |
159 | 159 | gravityview()->log->error( 'Metabox template file not found', array( 'data' => $this ) ); |
160 | 160 | } |
161 | 161 | |
162 | - } else if( !empty( $this->callback ) ) { |
|
162 | + } else if ( ! empty( $this->callback ) ) { |
|
163 | 163 | |
164 | - if( is_callable( $this->callback ) ) { |
|
164 | + if ( is_callable( $this->callback ) ) { |
|
165 | 165 | |
166 | 166 | /** @see do_accordion_sections() */ |
167 | - call_user_func( $this->callback, $post, (array) $this ); |
|
167 | + call_user_func( $this->callback, $post, (array)$this ); |
|
168 | 168 | |
169 | 169 | } else { |
170 | 170 | gravityview()->log->error( 'Metabox callback was not callable', array( 'data' => $this ) ); |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @since 1.11 |
53 | 53 | * @param boolean $boolean Whether to trigger update on user registration (default: true) |
54 | 54 | */ |
55 | - if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
55 | + if ( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
56 | 56 | |
57 | - add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
57 | + add_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10, 2 ); |
|
58 | 58 | |
59 | 59 | // last resort in case the current user display name don't match any of the defaults |
60 | 60 | add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function update_user( $form = array(), $entry_id = 0 ) { |
74 | 74 | |
75 | - if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) { |
|
75 | + if ( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) { |
|
76 | 76 | gravityview()->log->error( 'GFAPI or User Registration class not found; not updating the user' ); |
77 | 77 | return; |
78 | - } elseif( empty( $entry_id ) ) { |
|
78 | + } elseif ( empty( $entry_id ) ) { |
|
79 | 79 | gravityview()->log->error( 'Entry ID is empty [{entry_id}]; not updating the user', array( 'entry_id' => $entry_id ) ); |
80 | 80 | return; |
81 | 81 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | // If an Update feed, make sure the conditions are met. |
104 | 104 | if ( \GV\Utils::get( $config, 'meta/feedType' ) === 'update' ) { |
105 | - if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
105 | + if ( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | remove_filter( 'send_email_change_email', '__return_false', 3 ); |
119 | 119 | |
120 | 120 | // Prevent double-triggering by removing the hook |
121 | - remove_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10 ); |
|
121 | + remove_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10 ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -151,17 +151,17 @@ discard block |
||
151 | 151 | */ |
152 | 152 | $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
153 | 153 | |
154 | - if( $preserve_role ) { |
|
155 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
154 | + if ( $preserve_role ) { |
|
155 | + $config[ 'meta' ][ 'role' ] = 'gfur_preserve_role'; |
|
156 | 156 | } |
157 | 157 | |
158 | - $displayname = $this->match_current_display_name( $entry['created_by'] ); |
|
158 | + $displayname = $this->match_current_display_name( $entry[ 'created_by' ] ); |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * Make sure the current display name is not changed with the update user method. |
162 | 162 | * @since 1.15 |
163 | 163 | */ |
164 | - $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname']; |
|
164 | + $config[ 'meta' ][ 'displayname' ] = $displayname ? $displayname : $config[ 'meta' ][ 'displayname' ]; |
|
165 | 165 | |
166 | 166 | /** |
167 | 167 | * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | $user = get_userdata( $user_id ); |
190 | 190 | |
191 | - if( ! $user ) { |
|
191 | + if ( ! $user ) { |
|
192 | 192 | return false; |
193 | 193 | } |
194 | 194 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook |
201 | 201 | * @see restore_display_name |
202 | 202 | */ |
203 | - if( false === $format ) { |
|
203 | + if ( false === $format ) { |
|
204 | 204 | $this->_user_before_update = $user; |
205 | 205 | } |
206 | 206 | |
@@ -218,20 +218,20 @@ discard block |
||
218 | 218 | public function generate_display_names( $profileuser ) { |
219 | 219 | |
220 | 220 | $public_display = array(); |
221 | - $public_display['nickname'] = $profileuser->nickname; |
|
222 | - $public_display['username'] = $profileuser->user_login; |
|
221 | + $public_display[ 'nickname' ] = $profileuser->nickname; |
|
222 | + $public_display[ 'username' ] = $profileuser->user_login; |
|
223 | 223 | |
224 | - if ( !empty($profileuser->first_name) ) { |
|
225 | - $public_display['firstname'] = $profileuser->first_name; |
|
224 | + if ( ! empty( $profileuser->first_name ) ) { |
|
225 | + $public_display[ 'firstname' ] = $profileuser->first_name; |
|
226 | 226 | } |
227 | 227 | |
228 | - if ( !empty($profileuser->last_name) ) { |
|
229 | - $public_display['lastname'] = $profileuser->last_name; |
|
228 | + if ( ! empty( $profileuser->last_name ) ) { |
|
229 | + $public_display[ 'lastname' ] = $profileuser->last_name; |
|
230 | 230 | } |
231 | 231 | |
232 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
233 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
234 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
232 | + if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) { |
|
233 | + $public_display[ 'firstlast' ] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
234 | + $public_display[ 'lastfirst' ] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | $public_display = array_map( 'trim', $public_display ); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * - or we don't need as we found the correct format before updating user. |
271 | 271 | * @since 1.14.4 |
272 | 272 | */ |
273 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
273 | + if ( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
274 | 274 | return null; |
275 | 275 | } |
276 | 276 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | $updated = wp_update_user( $restored_user ); |
304 | 304 | |
305 | - if( is_wp_error( $updated ) ) { |
|
305 | + if ( is_wp_error( $updated ) ) { |
|
306 | 306 | gravityview()->log->error( 'There was an error updating user #{user_id} details', array( 'user_id' => $user_id, 'data' => $updated ) ); |
307 | 307 | } else { |
308 | 308 | gravityview()->log->debug( 'User #{user_id} details restored', array( 'user_id' => $user_id ) ); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | if ( ! defined( 'WPINC' ) ) { |
14 | - die; |
|
14 | + die; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -22,109 +22,109 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @var GravityView_Edit_Entry $loader |
24 | 24 | */ |
25 | - protected $loader; |
|
25 | + protected $loader; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @var WP_User|null Temporary storage used by restore_user_details() |
|
29 | - */ |
|
30 | - private $_user_before_update = null; |
|
27 | + /** |
|
28 | + * @var WP_User|null Temporary storage used by restore_user_details() |
|
29 | + */ |
|
30 | + private $_user_before_update = null; |
|
31 | 31 | |
32 | - function __construct( GravityView_Edit_Entry $loader ) { |
|
33 | - $this->loader = $loader; |
|
34 | - } |
|
32 | + function __construct( GravityView_Edit_Entry $loader ) { |
|
33 | + $this->loader = $loader; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @since 1.11 |
38 | 38 | */ |
39 | 39 | public function load() { |
40 | 40 | add_action( 'wp', array( $this, 'add_hooks' ), 10 ); |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Add hooks to trigger updating the user |
45 | 45 | * |
46 | 46 | * @since 1.18 |
47 | 47 | */ |
48 | - public function add_hooks() { |
|
49 | - |
|
50 | - /** |
|
51 | - * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated? |
|
52 | - * @since 1.11 |
|
53 | - * @param boolean $boolean Whether to trigger update on user registration (default: true) |
|
54 | - */ |
|
55 | - if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
56 | - |
|
57 | - add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
58 | - |
|
59 | - // last resort in case the current user display name don't match any of the defaults |
|
60 | - add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
|
61 | - } |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * Update the WordPress user profile based on the GF User Registration create feed |
|
66 | - * |
|
67 | - * @since 1.11 |
|
68 | - * |
|
69 | - * @param array $form Gravity Forms form array |
|
70 | - * @param string $entry_id Gravity Forms entry ID |
|
71 | - * @return void |
|
72 | - */ |
|
73 | - public function update_user( $form = array(), $entry_id = 0 ) { |
|
74 | - |
|
75 | - if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) { |
|
76 | - gravityview()->log->error( 'GFAPI or User Registration class not found; not updating the user' ); |
|
77 | - return; |
|
78 | - } elseif( empty( $entry_id ) ) { |
|
79 | - gravityview()->log->error( 'Entry ID is empty [{entry_id}]; not updating the user', array( 'entry_id' => $entry_id ) ); |
|
80 | - return; |
|
81 | - } |
|
82 | - |
|
83 | - $gf_user_registration = GF_User_Registration::get_instance(); |
|
84 | - |
|
85 | - $entry = GFAPI::get_entry( $entry_id ); |
|
86 | - |
|
87 | - /** |
|
88 | - * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
|
89 | - * @since 1.11 |
|
90 | - * @param array $entry Gravity Forms entry |
|
91 | - * @param array $form Gravity Forms form |
|
92 | - */ |
|
93 | - $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
94 | - |
|
95 | - $config = $this->get_feed_configuration( $entry, $form ); |
|
96 | - |
|
97 | - // Make sure the feed is active |
|
98 | - if ( ! \GV\Utils::get( $config, 'is_active', false ) ) { |
|
48 | + public function add_hooks() { |
|
49 | + |
|
50 | + /** |
|
51 | + * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated? |
|
52 | + * @since 1.11 |
|
53 | + * @param boolean $boolean Whether to trigger update on user registration (default: true) |
|
54 | + */ |
|
55 | + if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
56 | + |
|
57 | + add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
58 | + |
|
59 | + // last resort in case the current user display name don't match any of the defaults |
|
60 | + add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
|
61 | + } |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * Update the WordPress user profile based on the GF User Registration create feed |
|
66 | + * |
|
67 | + * @since 1.11 |
|
68 | + * |
|
69 | + * @param array $form Gravity Forms form array |
|
70 | + * @param string $entry_id Gravity Forms entry ID |
|
71 | + * @return void |
|
72 | + */ |
|
73 | + public function update_user( $form = array(), $entry_id = 0 ) { |
|
74 | + |
|
75 | + if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) { |
|
76 | + gravityview()->log->error( 'GFAPI or User Registration class not found; not updating the user' ); |
|
99 | 77 | return; |
100 | - } |
|
78 | + } elseif( empty( $entry_id ) ) { |
|
79 | + gravityview()->log->error( 'Entry ID is empty [{entry_id}]; not updating the user', array( 'entry_id' => $entry_id ) ); |
|
80 | + return; |
|
81 | + } |
|
82 | + |
|
83 | + $gf_user_registration = GF_User_Registration::get_instance(); |
|
84 | + |
|
85 | + $entry = GFAPI::get_entry( $entry_id ); |
|
101 | 86 | |
102 | - // If an Update feed, make sure the conditions are met. |
|
103 | - if ( \GV\Utils::get( $config, 'meta/feedType' ) === 'update' ) { |
|
104 | - if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
105 | - return; |
|
106 | - } |
|
107 | - } |
|
87 | + /** |
|
88 | + * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
|
89 | + * @since 1.11 |
|
90 | + * @param array $entry Gravity Forms entry |
|
91 | + * @param array $form Gravity Forms form |
|
92 | + */ |
|
93 | + $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
108 | 94 | |
109 | - // Do not update user if the user hasn't been registered (happens when manual activation is enabled in User Registration feed) |
|
110 | - $username = \GV\Utils::get( $config, 'meta/username', null ); |
|
111 | - if ( ! isset( $entry[ $username ] ) || ! get_user_by( 'login', $entry[ $username ] ) ) { |
|
112 | - return; |
|
113 | - } |
|
95 | + $config = $this->get_feed_configuration( $entry, $form ); |
|
96 | + |
|
97 | + // Make sure the feed is active |
|
98 | + if ( ! \GV\Utils::get( $config, 'is_active', false ) ) { |
|
99 | + return; |
|
100 | + } |
|
101 | + |
|
102 | + // If an Update feed, make sure the conditions are met. |
|
103 | + if ( \GV\Utils::get( $config, 'meta/feedType' ) === 'update' ) { |
|
104 | + if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
105 | + return; |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + // Do not update user if the user hasn't been registered (happens when manual activation is enabled in User Registration feed) |
|
110 | + $username = \GV\Utils::get( $config, 'meta/username', null ); |
|
111 | + if ( ! isset( $entry[ $username ] ) || ! get_user_by( 'login', $entry[ $username ] ) ) { |
|
112 | + return; |
|
113 | + } |
|
114 | 114 | |
115 | - // The priority is set to 3 so that default priority (10) will still override it |
|
116 | - add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
117 | - add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
115 | + // The priority is set to 3 so that default priority (10) will still override it |
|
116 | + add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
117 | + add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
118 | 118 | |
119 | - // Trigger the User Registration update user method |
|
120 | - $gf_user_registration->update_user( $entry, $form, $config ); |
|
119 | + // Trigger the User Registration update user method |
|
120 | + $gf_user_registration->update_user( $entry, $form, $config ); |
|
121 | 121 | |
122 | - remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
123 | - remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
122 | + remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
123 | + remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
124 | 124 | |
125 | - // Prevent double-triggering by removing the hook |
|
126 | - remove_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10 ); |
|
127 | - } |
|
125 | + // Prevent double-triggering by removing the hook |
|
126 | + remove_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10 ); |
|
127 | + } |
|
128 | 128 | |
129 | 129 | /** |
130 | 130 | * Get the User Registration feed configuration for the entry & form |
@@ -139,184 +139,184 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return array |
141 | 141 | */ |
142 | - public function get_feed_configuration( $entry, $form ) { |
|
143 | - |
|
144 | - $gf_user_registration = GF_User_Registration::get_instance(); |
|
145 | - |
|
146 | - $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
147 | - |
|
148 | - /** |
|
149 | - * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
150 | - * @since 1.15 |
|
151 | - * @param boolean $preserve_role Preserve current user role Default: true |
|
152 | - * @param array $config Gravity Forms User Registration feed configuration for the form |
|
153 | - * @param array $form Gravity Forms form array |
|
154 | - * @param array $entry Gravity Forms entry being edited |
|
155 | - */ |
|
156 | - $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
157 | - |
|
158 | - if( $preserve_role ) { |
|
159 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
160 | - } |
|
161 | - |
|
162 | - $displayname = $this->match_current_display_name( $entry['created_by'] ); |
|
163 | - |
|
164 | - /** |
|
165 | - * Make sure the current display name is not changed with the update user method. |
|
166 | - * @since 1.15 |
|
167 | - */ |
|
168 | - $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname']; |
|
169 | - |
|
170 | - /** |
|
171 | - * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
172 | - * @since 1.14 |
|
173 | - * @param array $config Gravity Forms User Registration feed configuration for the form |
|
174 | - * @param array $form Gravity Forms form array |
|
175 | - * @param array $entry Gravity Forms entry being edited |
|
176 | - */ |
|
177 | - $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
178 | - |
|
179 | - return $config; |
|
180 | - } |
|
181 | - |
|
182 | - /** |
|
183 | - * Calculate the user display name format |
|
184 | - * |
|
185 | - * @since 1.15 |
|
186 | - * @since 1.20 Returns false if user not found at $user_id |
|
187 | - * |
|
188 | - * @param int $user_id WP User ID |
|
189 | - * @return false|string Display name format as used inside Gravity Forms User Registration. Returns false if user not found. |
|
190 | - */ |
|
191 | - public function match_current_display_name( $user_id ) { |
|
192 | - |
|
193 | - $user = get_userdata( $user_id ); |
|
194 | - |
|
195 | - if( ! $user ) { |
|
196 | - return false; |
|
197 | - } |
|
198 | - |
|
199 | - $names = $this->generate_display_names( $user ); |
|
200 | - |
|
201 | - $format = array_search( $user->display_name, $names, true ); |
|
202 | - |
|
203 | - /** |
|
204 | - * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook |
|
205 | - * @see restore_display_name |
|
206 | - */ |
|
207 | - if( false === $format ) { |
|
208 | - $this->_user_before_update = $user; |
|
209 | - } |
|
210 | - |
|
211 | - return $format; |
|
212 | - } |
|
213 | - |
|
214 | - /** |
|
215 | - * Generate an array of all the user display names possibilities |
|
216 | - * |
|
217 | - * @since 1.15 |
|
218 | - * |
|
219 | - * @param object $profileuser WP_User object |
|
220 | - * @return array List all the possible display names for a certain User object |
|
221 | - */ |
|
222 | - public function generate_display_names( $profileuser ) { |
|
223 | - |
|
224 | - $public_display = array(); |
|
225 | - $public_display['nickname'] = $profileuser->nickname; |
|
226 | - $public_display['username'] = $profileuser->user_login; |
|
227 | - |
|
228 | - if ( !empty($profileuser->first_name) ) { |
|
229 | - $public_display['firstname'] = $profileuser->first_name; |
|
230 | - } |
|
231 | - |
|
232 | - if ( !empty($profileuser->last_name) ) { |
|
233 | - $public_display['lastname'] = $profileuser->last_name; |
|
234 | - } |
|
235 | - |
|
236 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
237 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
238 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
239 | - } |
|
240 | - |
|
241 | - $public_display = array_map( 'trim', $public_display ); |
|
242 | - $public_display = array_unique( $public_display ); |
|
243 | - |
|
244 | - return $public_display; |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
250 | - * |
|
251 | - * @see GFUser::update_user() |
|
252 | - * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
253 | - * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
254 | - * @param array $entry The Gravity Forms entry that was just updated |
|
255 | - * @param string $password User password |
|
256 | - * @return int|false|WP_Error|null True: User updated; False: $user_id not a valid User ID; WP_Error: User update error; Null: Method didn't process |
|
257 | - */ |
|
258 | - public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
259 | - |
|
260 | - /** |
|
261 | - * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
262 | - * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
263 | - * @since 1.14.4 |
|
264 | - * @param boolean $restore_display_name Restore Display Name? Default: true |
|
265 | - */ |
|
266 | - $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
267 | - |
|
268 | - $is_update_feed = ( $config && \GV\Utils::get( $config, 'meta/feed_type' ) === 'update' ); |
|
269 | - |
|
270 | - /** |
|
271 | - * Don't restore display name: |
|
272 | - * - either disabled, |
|
273 | - * - or it is an Update feed (we only care about Create feed) |
|
274 | - * - or we don't need as we found the correct format before updating user. |
|
275 | - * @since 1.14.4 |
|
276 | - */ |
|
277 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
278 | - return null; |
|
279 | - } |
|
280 | - |
|
281 | - $user_after_update = get_userdata( $user_id ); |
|
282 | - |
|
283 | - // User not found |
|
284 | - if ( ! $user_after_update ) { |
|
285 | - gravityview()->log->error( 'User not found at $user_id #{user_id}', array( 'user_id' => $user_id ) ); |
|
286 | - return false; |
|
287 | - } |
|
288 | - |
|
289 | - $restored_user = $user_after_update; |
|
290 | - |
|
291 | - // Restore previous display_name |
|
292 | - $restored_user->display_name = $this->_user_before_update->display_name; |
|
293 | - |
|
294 | - // Don't have WP update the password. |
|
295 | - unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
296 | - |
|
297 | - /** |
|
298 | - * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
299 | - * @since 1.14 |
|
300 | - * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
301 | - * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
302 | - * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
303 | - * @param array $entry The Gravity Forms entry that was just updated |
|
304 | - */ |
|
305 | - $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
306 | - |
|
307 | - $updated = wp_update_user( $restored_user ); |
|
308 | - |
|
309 | - if( is_wp_error( $updated ) ) { |
|
310 | - gravityview()->log->error( 'There was an error updating user #{user_id} details', array( 'user_id' => $user_id, 'data' => $updated ) ); |
|
311 | - } else { |
|
312 | - gravityview()->log->debug( 'User #{user_id} details restored', array( 'user_id' => $user_id ) ); |
|
313 | - } |
|
314 | - |
|
315 | - $this->_user_before_update = null; |
|
316 | - |
|
317 | - unset( $restored_user, $user_after_update ); |
|
318 | - |
|
319 | - return $updated; |
|
320 | - } |
|
142 | + public function get_feed_configuration( $entry, $form ) { |
|
143 | + |
|
144 | + $gf_user_registration = GF_User_Registration::get_instance(); |
|
145 | + |
|
146 | + $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
147 | + |
|
148 | + /** |
|
149 | + * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
150 | + * @since 1.15 |
|
151 | + * @param boolean $preserve_role Preserve current user role Default: true |
|
152 | + * @param array $config Gravity Forms User Registration feed configuration for the form |
|
153 | + * @param array $form Gravity Forms form array |
|
154 | + * @param array $entry Gravity Forms entry being edited |
|
155 | + */ |
|
156 | + $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
157 | + |
|
158 | + if( $preserve_role ) { |
|
159 | + $config['meta']['role'] = 'gfur_preserve_role'; |
|
160 | + } |
|
161 | + |
|
162 | + $displayname = $this->match_current_display_name( $entry['created_by'] ); |
|
163 | + |
|
164 | + /** |
|
165 | + * Make sure the current display name is not changed with the update user method. |
|
166 | + * @since 1.15 |
|
167 | + */ |
|
168 | + $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname']; |
|
169 | + |
|
170 | + /** |
|
171 | + * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
172 | + * @since 1.14 |
|
173 | + * @param array $config Gravity Forms User Registration feed configuration for the form |
|
174 | + * @param array $form Gravity Forms form array |
|
175 | + * @param array $entry Gravity Forms entry being edited |
|
176 | + */ |
|
177 | + $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
178 | + |
|
179 | + return $config; |
|
180 | + } |
|
181 | + |
|
182 | + /** |
|
183 | + * Calculate the user display name format |
|
184 | + * |
|
185 | + * @since 1.15 |
|
186 | + * @since 1.20 Returns false if user not found at $user_id |
|
187 | + * |
|
188 | + * @param int $user_id WP User ID |
|
189 | + * @return false|string Display name format as used inside Gravity Forms User Registration. Returns false if user not found. |
|
190 | + */ |
|
191 | + public function match_current_display_name( $user_id ) { |
|
192 | + |
|
193 | + $user = get_userdata( $user_id ); |
|
194 | + |
|
195 | + if( ! $user ) { |
|
196 | + return false; |
|
197 | + } |
|
198 | + |
|
199 | + $names = $this->generate_display_names( $user ); |
|
200 | + |
|
201 | + $format = array_search( $user->display_name, $names, true ); |
|
202 | + |
|
203 | + /** |
|
204 | + * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook |
|
205 | + * @see restore_display_name |
|
206 | + */ |
|
207 | + if( false === $format ) { |
|
208 | + $this->_user_before_update = $user; |
|
209 | + } |
|
210 | + |
|
211 | + return $format; |
|
212 | + } |
|
213 | + |
|
214 | + /** |
|
215 | + * Generate an array of all the user display names possibilities |
|
216 | + * |
|
217 | + * @since 1.15 |
|
218 | + * |
|
219 | + * @param object $profileuser WP_User object |
|
220 | + * @return array List all the possible display names for a certain User object |
|
221 | + */ |
|
222 | + public function generate_display_names( $profileuser ) { |
|
223 | + |
|
224 | + $public_display = array(); |
|
225 | + $public_display['nickname'] = $profileuser->nickname; |
|
226 | + $public_display['username'] = $profileuser->user_login; |
|
227 | + |
|
228 | + if ( !empty($profileuser->first_name) ) { |
|
229 | + $public_display['firstname'] = $profileuser->first_name; |
|
230 | + } |
|
231 | + |
|
232 | + if ( !empty($profileuser->last_name) ) { |
|
233 | + $public_display['lastname'] = $profileuser->last_name; |
|
234 | + } |
|
235 | + |
|
236 | + if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
237 | + $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
238 | + $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
239 | + } |
|
240 | + |
|
241 | + $public_display = array_map( 'trim', $public_display ); |
|
242 | + $public_display = array_unique( $public_display ); |
|
243 | + |
|
244 | + return $public_display; |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
250 | + * |
|
251 | + * @see GFUser::update_user() |
|
252 | + * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
253 | + * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
254 | + * @param array $entry The Gravity Forms entry that was just updated |
|
255 | + * @param string $password User password |
|
256 | + * @return int|false|WP_Error|null True: User updated; False: $user_id not a valid User ID; WP_Error: User update error; Null: Method didn't process |
|
257 | + */ |
|
258 | + public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
259 | + |
|
260 | + /** |
|
261 | + * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
262 | + * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
263 | + * @since 1.14.4 |
|
264 | + * @param boolean $restore_display_name Restore Display Name? Default: true |
|
265 | + */ |
|
266 | + $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
267 | + |
|
268 | + $is_update_feed = ( $config && \GV\Utils::get( $config, 'meta/feed_type' ) === 'update' ); |
|
269 | + |
|
270 | + /** |
|
271 | + * Don't restore display name: |
|
272 | + * - either disabled, |
|
273 | + * - or it is an Update feed (we only care about Create feed) |
|
274 | + * - or we don't need as we found the correct format before updating user. |
|
275 | + * @since 1.14.4 |
|
276 | + */ |
|
277 | + if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
278 | + return null; |
|
279 | + } |
|
280 | + |
|
281 | + $user_after_update = get_userdata( $user_id ); |
|
282 | + |
|
283 | + // User not found |
|
284 | + if ( ! $user_after_update ) { |
|
285 | + gravityview()->log->error( 'User not found at $user_id #{user_id}', array( 'user_id' => $user_id ) ); |
|
286 | + return false; |
|
287 | + } |
|
288 | + |
|
289 | + $restored_user = $user_after_update; |
|
290 | + |
|
291 | + // Restore previous display_name |
|
292 | + $restored_user->display_name = $this->_user_before_update->display_name; |
|
293 | + |
|
294 | + // Don't have WP update the password. |
|
295 | + unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
296 | + |
|
297 | + /** |
|
298 | + * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
299 | + * @since 1.14 |
|
300 | + * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
301 | + * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
302 | + * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
303 | + * @param array $entry The Gravity Forms entry that was just updated |
|
304 | + */ |
|
305 | + $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
306 | + |
|
307 | + $updated = wp_update_user( $restored_user ); |
|
308 | + |
|
309 | + if( is_wp_error( $updated ) ) { |
|
310 | + gravityview()->log->error( 'There was an error updating user #{user_id} details', array( 'user_id' => $user_id, 'data' => $updated ) ); |
|
311 | + } else { |
|
312 | + gravityview()->log->debug( 'User #{user_id} details restored', array( 'user_id' => $user_id ) ); |
|
313 | + } |
|
314 | + |
|
315 | + $this->_user_before_update = null; |
|
316 | + |
|
317 | + unset( $restored_user, $user_after_update ); |
|
318 | + |
|
319 | + return $updated; |
|
320 | + } |
|
321 | 321 | |
322 | 322 | } //end class |
@@ -42,7 +42,7 @@ |
||
42 | 42 | static function getInstance() { |
43 | 43 | gravityview()->log->notice( '\GravityView_oEmbed is deprecated. Use \GV\oEmbed instead.' ); |
44 | 44 | |
45 | - if( empty( self::$instance ) ) { |
|
45 | + if ( empty( self::$instance ) ) { |
|
46 | 46 | self::$instance = new self; |
47 | 47 | self::$instance->initialize(); |
48 | 48 | } |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | * @param mixed $field_id Field ID or Field array |
334 | 334 | * @return string field type |
335 | 335 | */ |
336 | -function gravityview_get_field_type( $form = null , $field_id = '' ) { |
|
337 | - return GVCommon::get_field_type( $form, $field_id ); |
|
336 | +function gravityview_get_field_type( $form = null, $field_id = '' ) { |
|
337 | + return GVCommon::get_field_type( $form, $field_id ); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | * @return string HTML of the output. Empty string if $view_id is empty. |
348 | 348 | */ |
349 | 349 | function get_gravityview( $view_id = '', $atts = array() ) { |
350 | - if( !empty( $view_id ) ) { |
|
351 | - $atts['id'] = $view_id; |
|
350 | + if ( ! empty( $view_id ) ) { |
|
351 | + $atts[ 'id' ] = $view_id; |
|
352 | 352 | $args = wp_parse_args( $atts, \GV\View_Settings::defaults() ); |
353 | 353 | $GravityView_frontend = GravityView_frontend::getInstance(); |
354 | 354 | $GravityView_frontend->setGvOutputData( GravityView_View_Data::getInstance( $view_id ) ); |
@@ -391,19 +391,19 @@ discard block |
||
391 | 391 | */ |
392 | 392 | function gravityview_view_has_single_checkbox_or_radio( $form, $view_fields ) { |
393 | 393 | |
394 | - if( class_exists('GFFormsModel') && $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) { |
|
394 | + if ( class_exists( 'GFFormsModel' ) && $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) { |
|
395 | 395 | |
396 | 396 | /** @var GF_Field_Radio|GF_Field_Checkbox $form_field */ |
397 | - foreach( $form_fields as $form_field ) { |
|
397 | + foreach ( $form_fields as $form_field ) { |
|
398 | 398 | $field_id = $form_field->id; |
399 | - foreach( $view_fields as $zone ) { |
|
399 | + foreach ( $view_fields as $zone ) { |
|
400 | 400 | |
401 | 401 | // ACF compatibility; ACF-added fields aren't arrays |
402 | 402 | if ( ! is_array( $zone ) ) { continue; } |
403 | 403 | |
404 | - foreach( $zone as $field ) { |
|
404 | + foreach ( $zone as $field ) { |
|
405 | 405 | // If it's an input, not the parent and the parent ID matches a checkbox or radio |
406 | - if( ( strpos( $field['id'], '.' ) > 0 ) && floor( $field['id'] ) === floor( $field_id ) ) { |
|
406 | + if ( ( strpos( $field[ 'id' ], '.' ) > 0 ) && floor( $field[ 'id' ] ) === floor( $field_id ) ) { |
|
407 | 407 | return true; |
408 | 408 | } |
409 | 409 | } |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | // matching regex => the value is the method to call to replace the value. |
53 | 53 | $gv_modifiers = array( |
54 | 54 | 'maxwords:(\d+)' => 'modifier_maxwords', /** @see modifier_maxwords */ |
55 | - 'timestamp' => 'modifier_timestamp', /** @see modifier_timestamp */ |
|
55 | + 'timestamp' => 'modifier_timestamp', /** @see modifier_timestamp */ |
|
56 | 56 | 'explode' => 'modifier_explode', /** @see modifier_explode */ |
57 | 57 | |
58 | 58 | /** @see modifier_strings */ |
59 | 59 | 'urlencode' => 'modifier_strings', |
60 | 60 | 'wpautop' => 'modifier_strings', |
61 | - 'esc_html' => 'modifier_strings', |
|
62 | - 'sanitize_html_class' => 'modifier_strings', |
|
61 | + 'esc_html' => 'modifier_strings', |
|
62 | + 'sanitize_html_class' => 'modifier_strings', |
|
63 | 63 | 'sanitize_title' => 'modifier_strings', |
64 | 64 | 'strtolower' => 'modifier_strings', |
65 | 65 | 'strtoupper' => 'modifier_strings', |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | |
458 | 458 | $atts = array( |
459 | 459 | 'format' => self::get_format_from_modifiers( $exploded, false ), |
460 | - 'human' => in_array( 'human', $exploded ), // {date_created:human} |
|
460 | + 'human' => in_array( 'human', $exploded ), // {date_created:human} |
|
461 | 461 | 'diff' => in_array( 'diff', $exploded ), // {date_created:diff} |
462 | 462 | 'raw' => in_array( 'raw', $exploded ), // {date_created:raw} |
463 | 463 | 'timestamp' => in_array( 'timestamp', $exploded ), // {date_created:timestamp} |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | |
79 | 79 | $non_gv_modifiers = array_diff( $modifiers, array_keys( $gv_modifiers ) ); |
80 | 80 | |
81 | - $return = $field->get_value_merge_tag( $value, '', array( 'currency' => '' ), array(), implode( '', $non_gv_modifiers ), $raw_value, false, false, 'text', false); |
|
81 | + $return = $field->get_value_merge_tag( $value, '', array( 'currency' => '' ), array(), implode( '', $non_gv_modifiers ), $raw_value, false, false, 'text', false ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | foreach ( $modifiers as $passed_modifier ) { |
85 | 85 | |
86 | - foreach( $gv_modifiers as $gv_modifier => $method ) { |
|
86 | + foreach ( $gv_modifiers as $gv_modifier => $method ) { |
|
87 | 87 | |
88 | 88 | // Uses ^ to only match the first modifier, to enforce same order as passed by GF |
89 | 89 | preg_match( '/^' . $gv_modifier . '/ism', $passed_modifier, $matches ); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | private static function modifier_timestamp( $raw_value, $matches ) { |
134 | 134 | |
135 | - if( empty( $matches[0] ) ) { |
|
135 | + if ( empty( $matches[ 0 ] ) ) { |
|
136 | 136 | return $raw_value; |
137 | 137 | } |
138 | 138 | |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | */ |
162 | 162 | private static function modifier_maxwords( $raw_value, $matches, $field = null ) { |
163 | 163 | |
164 | - if( ! is_string( $raw_value ) || empty( $matches[1] ) || ! function_exists( 'wp_trim_words' ) ) { |
|
164 | + if ( ! is_string( $raw_value ) || empty( $matches[ 1 ] ) || ! function_exists( 'wp_trim_words' ) ) { |
|
165 | 165 | return $raw_value; |
166 | 166 | } |
167 | 167 | |
168 | - $max = intval( $matches[1] ); |
|
168 | + $max = intval( $matches[ 1 ] ); |
|
169 | 169 | |
170 | 170 | $more_placeholder = '[GVMORE]'; |
171 | 171 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | private static function modifier_explode( $raw_value, $matches, $value, $field = null ) { |
235 | 235 | |
236 | 236 | // For JSON-encoded arrays |
237 | - if( $json_array = json_decode( $raw_value, true ) ) { |
|
237 | + if ( $json_array = json_decode( $raw_value, true ) ) { |
|
238 | 238 | return implode( ' ', $json_array ); |
239 | 239 | } |
240 | 240 | |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | */ |
256 | 256 | private static function modifier_strings( $raw_value, $matches, $value = '', $field = null ) { |
257 | 257 | |
258 | - if( empty( $matches[0] ) ) { |
|
258 | + if ( empty( $matches[ 0 ] ) ) { |
|
259 | 259 | return $raw_value; |
260 | 260 | } |
261 | 261 | |
262 | 262 | $return = $raw_value; |
263 | 263 | |
264 | - switch( $matches[0] ) { |
|
264 | + switch ( $matches[ 0 ] ) { |
|
265 | 265 | case 'urlencode': |
266 | 266 | $return = urlencode( $raw_value ); |
267 | 267 | break; |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | * @internal Fixed $form['title'] in Gravity Forms |
349 | 349 | * @see https://github.com/gravityforms/gravityforms/pull/27/files |
350 | 350 | */ |
351 | - $form['title'] = isset( $form['title'] ) ? $form['title'] : ''; |
|
352 | - $form['id'] = isset( $form['id'] ) ? $form['id'] : ''; |
|
353 | - $form['fields'] = isset( $form['fields'] ) ? $form['fields'] : array(); |
|
351 | + $form[ 'title' ] = isset( $form[ 'title' ] ) ? $form[ 'title' ] : ''; |
|
352 | + $form[ 'id' ] = isset( $form[ 'id' ] ) ? $form[ 'id' ] : ''; |
|
353 | + $form[ 'fields' ] = isset( $form[ 'fields' ] ) ? $form[ 'fields' ] : array(); |
|
354 | 354 | |
355 | 355 | return GFCommon::replace_variables( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format, $aux_data ); |
356 | 356 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | |
443 | 443 | $site_url = get_site_url(); |
444 | 444 | |
445 | - if( $url_encode ) { |
|
445 | + if ( $url_encode ) { |
|
446 | 446 | $site_url = urlencode( $site_url ); |
447 | 447 | } |
448 | 448 | |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | // Is there is {gv_entry_link} or {gv_entry_link:[post id]} or {gv_entry_link:[post id]:[action]} merge tag? |
470 | 470 | preg_match_all( "/{gv_entry_link(?:\:(\d+)\:?(.*?))?}/ism", $original_text, $matches, PREG_SET_ORDER ); |
471 | 471 | |
472 | - if( empty( $matches ) ) { |
|
472 | + if ( empty( $matches ) ) { |
|
473 | 473 | return $original_text; |
474 | 474 | } |
475 | 475 | |
@@ -490,18 +490,18 @@ discard block |
||
490 | 490 | * } |
491 | 491 | */ |
492 | 492 | foreach ( $matches as $match ) { |
493 | - $full_tag = $match[0]; |
|
493 | + $full_tag = $match[ 0 ]; |
|
494 | 494 | |
495 | 495 | $link_args = array( |
496 | 496 | 'return' => 'url', |
497 | - 'entry_id' => $entry['id'], |
|
497 | + 'entry_id' => $entry[ 'id' ], |
|
498 | 498 | 'post_id' => \GV\Utils::get( $match, 1, null ), |
499 | 499 | 'action' => \GV\Utils::get( $match, 2, 'read' ), |
500 | 500 | ); |
501 | 501 | |
502 | 502 | $entry_link = $Shortcode->read_shortcode( $link_args, null, 'gv_entry_link_merge_tag' ); |
503 | 503 | |
504 | - if( $url_encode ) { |
|
504 | + if ( $url_encode ) { |
|
505 | 505 | $entry_link = urlencode( $entry_link ); |
506 | 506 | } |
507 | 507 | |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | 'diff' => in_array( 'diff', $exploded ), // {date_created:diff} |
540 | 540 | 'raw' => in_array( 'raw', $exploded ), // {date_created:raw} |
541 | 541 | 'timestamp' => in_array( 'timestamp', $exploded ), // {date_created:timestamp} |
542 | - 'time' => in_array( 'time', $exploded ), // {date_created:time} |
|
542 | + 'time' => in_array( 'time', $exploded ), // {date_created:time} |
|
543 | 543 | ); |
544 | 544 | |
545 | 545 | $formatted_date = GVCommon::format_date( $date_created, $atts ); |
@@ -616,8 +616,8 @@ discard block |
||
616 | 616 | return $original_text; |
617 | 617 | } |
618 | 618 | |
619 | - foreach ( (array) $matches as $match ) { |
|
620 | - $full_tag = $match[0]; |
|
619 | + foreach ( (array)$matches as $match ) { |
|
620 | + $full_tag = $match[ 0 ]; |
|
621 | 621 | $modifier = \GV\Utils::get( $match, 2, 'permalink' ); |
622 | 622 | |
623 | 623 | $replacement = false; |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | $replacement = esc_html( $replacement ); |
636 | 636 | } |
637 | 637 | |
638 | - if( $url_encode ) { |
|
638 | + if ( $url_encode ) { |
|
639 | 639 | $replacement = urlencode( $replacement ); |
640 | 640 | } |
641 | 641 | |
@@ -675,14 +675,14 @@ discard block |
||
675 | 675 | preg_match_all( "/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER ); |
676 | 676 | |
677 | 677 | // If there are no matches OR the Entry `created_by` isn't set or is 0 (no user) |
678 | - if( empty( $matches ) ) { |
|
678 | + if ( empty( $matches ) ) { |
|
679 | 679 | return $text; |
680 | 680 | } |
681 | 681 | |
682 | 682 | foreach ( $matches as $match ) { |
683 | 683 | |
684 | - $full_tag = $match[0]; |
|
685 | - $property = $match[1]; |
|
684 | + $full_tag = $match[ 0 ]; |
|
685 | + $property = $match[ 1 ]; |
|
686 | 686 | |
687 | 687 | $value = stripslashes_deep( \GV\Utils::_GET( $property ) ); |
688 | 688 | |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | * @since 1.15 |
707 | 707 | * @param bool $esc_html Whether to esc_html() the value. Default: `true` |
708 | 708 | */ |
709 | - $esc_html = apply_filters('gravityview/merge_tags/get/esc_html/' . $property, true ); |
|
709 | + $esc_html = apply_filters( 'gravityview/merge_tags/get/esc_html/' . $property, true ); |
|
710 | 710 | |
711 | 711 | $value = $esc_html ? esc_html( $value ) : $value; |
712 | 712 | |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | * @param array $form Gravity Forms form array |
718 | 718 | * @param array $entry Entry array |
719 | 719 | */ |
720 | - $value = apply_filters('gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry ); |
|
720 | + $value = apply_filters( 'gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry ); |
|
721 | 721 | |
722 | 722 | $text = str_replace( $full_tag, $value, $text ); |
723 | 723 | } |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | |
21 | 21 | function __construct() { |
22 | 22 | |
23 | - add_action( 'media_buttons', array( $this, 'add_shortcode_button'), 30); |
|
23 | + add_action( 'media_buttons', array( $this, 'add_shortcode_button' ), 30 ); |
|
24 | 24 | |
25 | - add_action( 'admin_footer', array( $this, 'add_shortcode_popup') ); |
|
25 | + add_action( 'admin_footer', array( $this, 'add_shortcode_popup' ) ); |
|
26 | 26 | |
27 | 27 | // adding styles and scripts |
28 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') ); |
|
28 | + add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ) ); |
|
29 | 29 | |
30 | 30 | // ajax - populate sort fields based on the selected view |
31 | 31 | add_action( 'wp_ajax_gv_sortable_fields', array( $this, 'get_sortable_fields' ) ); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function is_post_editor_screen() { |
42 | 42 | global $current_screen, $pagenow; |
43 | - return !empty( $current_screen->post_type ) && 'gravityview' != $current_screen->post_type && in_array( $pagenow , array( 'post.php' , 'post-new.php' ) ); |
|
43 | + return ! empty( $current_screen->post_type ) && 'gravityview' != $current_screen->post_type && in_array( $pagenow, array( 'post.php', 'post-new.php' ) ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * @since 1.15.3 |
57 | 57 | */ |
58 | - if( ! GVCommon::has_cap( array( 'publish_gravityviews' ) ) ) { |
|
58 | + if ( ! GVCommon::has_cap( array( 'publish_gravityviews' ) ) ) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | - if( !$this->is_post_editor_screen() ) { |
|
62 | + if ( ! $this->is_post_editor_screen() ) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | ?> |
66 | - <a href="#TB_inline?width=600&height=800&inlineId=select_gravityview_view" class="thickbox hide-if-no-js button gform_media_link" id="add_gravityview" title="<?php esc_attr_e("Insert View", 'gravityview'); ?>"><span class="icon gv-icon-astronaut-head"></span><?php esc_html_e( 'Add View', 'gravityview' ); ?></a> |
|
66 | + <a href="#TB_inline?width=600&height=800&inlineId=select_gravityview_view" class="thickbox hide-if-no-js button gform_media_link" id="add_gravityview" title="<?php esc_attr_e( "Insert View", 'gravityview' ); ?>"><span class="icon gv-icon-astronaut-head"></span><?php esc_html_e( 'Add View', 'gravityview' ); ?></a> |
|
67 | 67 | <?php |
68 | 68 | |
69 | 69 | } |
@@ -79,16 +79,16 @@ discard block |
||
79 | 79 | function add_shortcode_popup() { |
80 | 80 | global $post; |
81 | 81 | |
82 | - if( !$this->is_post_editor_screen() ) { |
|
82 | + if ( ! $this->is_post_editor_screen() ) { |
|
83 | 83 | return; |
84 | 84 | } |
85 | 85 | |
86 | - $post_type = get_post_type_object($post->post_type); |
|
86 | + $post_type = get_post_type_object( $post->post_type ); |
|
87 | 87 | |
88 | - $views = get_posts( array('post_type' => 'gravityview', 'posts_per_page' => -1 ) ); |
|
88 | + $views = get_posts( array( 'post_type' => 'gravityview', 'posts_per_page' => -1 ) ); |
|
89 | 89 | |
90 | 90 | // If there are no views set up yet, we get outta here. |
91 | - if( empty( $views ) ) { |
|
91 | + if ( empty( $views ) ) { |
|
92 | 92 | echo '<div id="select_gravityview_view"><div class="wrap">' . GravityView_Admin::no_views_text() . '</div></div>'; |
93 | 93 | return; |
94 | 94 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | <div class="wrap"> |
100 | 100 | |
101 | 101 | <h2 class=""><?php esc_html_e( 'Embed a View', 'gravityview' ); ?></h2> |
102 | - <p class="subtitle"><?php printf( esc_attr ( __( 'Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s', 'gravityview') ), $post_type->labels->singular_name, '<a href="https://docs.gravityview.co/article/73-using-the-shortcode" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></p> |
|
102 | + <p class="subtitle"><?php printf( esc_attr( __( 'Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s', 'gravityview' ) ), $post_type->labels->singular_name, '<a href="https://docs.gravityview.co/article/73-using-the-shortcode" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></p> |
|
103 | 103 | |
104 | 104 | <div> |
105 | 105 | <h3><label for="gravityview_id"><?php esc_html_e( 'Select a View', 'gravityview' ); ?></label></h3> |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | <select name="gravityview_id" id="gravityview_id"> |
108 | 108 | <option value=""><?php esc_html_e( '— Select a View to Insert —', 'gravityview' ); ?></option> |
109 | 109 | <?php |
110 | - foreach( $views as $view ) { |
|
111 | - $title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title; |
|
112 | - echo '<option value="'. $view->ID .'">'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>'; |
|
110 | + foreach ( $views as $view ) { |
|
111 | + $title = empty( $view->post_title ) ? __( '(no title)', 'gravityview' ) : $view->post_title; |
|
112 | + echo '<option value="' . $view->ID . '">' . esc_html( sprintf( '%s #%d', $title, $view->ID ) ) . '</option>'; |
|
113 | 113 | } |
114 | 114 | ?> |
115 | 115 | </select> |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | foreach ( $settings as $key => $setting ) { |
127 | 127 | |
128 | - if( empty( $setting['show_in_shortcode'] ) ) { continue; } |
|
128 | + if ( empty( $setting[ 'show_in_shortcode' ] ) ) { continue; } |
|
129 | 129 | |
130 | 130 | GravityView_Render_Settings::render_setting_row( $key, array(), NULL, 'gravityview_%s', 'gravityview_%s' ); |
131 | 131 | } |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | </table> |
135 | 135 | |
136 | 136 | <div class="submit"> |
137 | - <input type="submit" class="button button-primary button-large alignleft hide-if-js" value="<?php esc_attr_e('Insert View', 'gravityview' ); ?>" id="insert_gravityview_view" /> |
|
138 | - <input class="button button-secondary alignright" type="submit" onclick="tb_remove(); return false;" value="<?php esc_attr_e("Cancel", 'gravityview'); ?>" /> |
|
137 | + <input type="submit" class="button button-primary button-large alignleft hide-if-js" value="<?php esc_attr_e( 'Insert View', 'gravityview' ); ?>" id="insert_gravityview_view" /> |
|
138 | + <input class="button button-secondary alignright" type="submit" onclick="tb_remove(); return false;" value="<?php esc_attr_e( "Cancel", 'gravityview' ); ?>" /> |
|
139 | 139 | </div> |
140 | 140 | |
141 | 141 | </div> |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | function add_scripts_and_styles() { |
158 | 158 | |
159 | - if( ! $this->is_post_editor_screen() ) { |
|
159 | + if ( ! $this->is_post_editor_screen() ) { |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
@@ -167,22 +167,22 @@ discard block |
||
167 | 167 | |
168 | 168 | $protocol = is_ssl() ? 'https://' : 'http://'; |
169 | 169 | |
170 | - wp_enqueue_style( 'jquery-ui-datepicker', $protocol.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(), GravityView_Plugin::version ); |
|
170 | + wp_enqueue_style( 'jquery-ui-datepicker', $protocol . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(), GravityView_Plugin::version ); |
|
171 | 171 | |
172 | 172 | //enqueue styles |
173 | - wp_register_style( 'gravityview_postedit_styles', plugins_url('assets/css/admin-post-edit.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
173 | + wp_register_style( 'gravityview_postedit_styles', plugins_url( 'assets/css/admin-post-edit.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
|
174 | 174 | wp_enqueue_style( 'gravityview_postedit_styles' ); |
175 | 175 | |
176 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
176 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
177 | 177 | |
178 | 178 | // custom js |
179 | - wp_register_script( 'gravityview_postedit_scripts', plugins_url('assets/js/admin-post-edit'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery', 'jquery-ui-datepicker' ), GravityView_Plugin::version ); |
|
179 | + wp_register_script( 'gravityview_postedit_scripts', plugins_url( 'assets/js/admin-post-edit' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery', 'jquery-ui-datepicker' ), GravityView_Plugin::version ); |
|
180 | 180 | wp_enqueue_script( 'gravityview_postedit_scripts' ); |
181 | - wp_localize_script('gravityview_postedit_scripts', 'gvGlobals', array( |
|
182 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxaddshortcode'), |
|
181 | + wp_localize_script( 'gravityview_postedit_scripts', 'gvGlobals', array( |
|
182 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxaddshortcode' ), |
|
183 | 183 | 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
184 | - 'alert_1' => esc_html__( 'Please select a View', 'gravityview'), |
|
185 | - )); |
|
184 | + 'alert_1' => esc_html__( 'Please select a View', 'gravityview' ), |
|
185 | + ) ); |
|
186 | 186 | |
187 | 187 | } |
188 | 188 | |
@@ -198,16 +198,16 @@ discard block |
||
198 | 198 | function get_sortable_fields() { |
199 | 199 | |
200 | 200 | // Not properly formatted request |
201 | - if ( empty( $_POST['viewid'] ) || !is_numeric( $_POST['viewid'] ) ) { |
|
201 | + if ( empty( $_POST[ 'viewid' ] ) || ! is_numeric( $_POST[ 'viewid' ] ) ) { |
|
202 | 202 | exit( false ); |
203 | 203 | } |
204 | 204 | |
205 | 205 | // Not valid request |
206 | - if( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxaddshortcode' ) ) { |
|
206 | + if ( empty( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxaddshortcode' ) ) { |
|
207 | 207 | exit( false ); |
208 | 208 | } |
209 | 209 | |
210 | - $viewid = (int)$_POST['viewid']; |
|
210 | + $viewid = (int)$_POST[ 'viewid' ]; |
|
211 | 211 | |
212 | 212 | // fetch form id assigned to the view |
213 | 213 | $formid = gravityview_get_form_id( $viewid ); |
@@ -109,7 +109,7 @@ |
||
109 | 109 | $field_data = array( |
110 | 110 | 'label' => \GV\Utils::get( $edit_field, 'custom_label' ), |
111 | 111 | 'customLabel' => \GV\Utils::get( $edit_field, 'custom_label' ), |
112 | - 'content' => \GV\Utils::get( $edit_field, 'content' ), |
|
112 | + 'content' => \GV\Utils::get( $edit_field, 'content' ), |
|
113 | 113 | ); |
114 | 114 | |
115 | 115 | // Replace merge tags in the content |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
58 | 58 | |
59 | - $entry_default_fields['custom'] = array( |
|
59 | + $entry_default_fields[ 'custom' ] = array( |
|
60 | 60 | 'label' => $this->label, |
61 | 61 | 'type' => $this->name, |
62 | 62 | 'desc' => $this->description, |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
71 | 71 | |
72 | - unset ( $field_options['search_filter'], $field_options['show_as_link'], $field_options['new_window'] ); |
|
72 | + unset ( $field_options[ 'search_filter' ], $field_options[ 'show_as_link' ], $field_options[ 'new_window' ] ); |
|
73 | 73 | |
74 | 74 | $new_fields = array( |
75 | 75 | 'content' => array( |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | ); |
113 | 113 | |
114 | 114 | if ( 'edit' === $context ) { |
115 | - unset( $field_options['custom_label'], $field_options['show_label'], $field_options['allow_edit_cap'], $new_fields['wpautop'], $new_fields['oembed'] ); |
|
115 | + unset( $field_options[ 'custom_label' ], $field_options[ 'show_label' ], $field_options[ 'allow_edit_cap' ], $new_fields[ 'wpautop' ], $new_fields[ 'oembed' ] ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | return $new_fields + $field_options; |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | |
147 | 147 | // Loop through the configured Edit Entry fields and add Custom Content fields if there are any |
148 | 148 | // TODO: Make this available to other custom GV field types |
149 | - foreach ( (array) $edit_fields as $edit_field ) { |
|
149 | + foreach ( (array)$edit_fields as $edit_field ) { |
|
150 | 150 | |
151 | - if( 'custom' === \GV\Utils::get( $edit_field, 'id') ) { |
|
151 | + if ( 'custom' === \GV\Utils::get( $edit_field, 'id' ) ) { |
|
152 | 152 | |
153 | 153 | $field_data = array( |
154 | 154 | 'label' => \GV\Utils::get( $edit_field, 'custom_label' ), |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | $field_data[ $key ] = GravityView_Merge_Tags::replace_variables( $field_datum, $form, $entry_data, false, false ); |
163 | 163 | } |
164 | 164 | |
165 | - $field_data['cssClass'] = \GV\Utils::get( $edit_field, 'custom_class' ); |
|
165 | + $field_data[ 'cssClass' ] = \GV\Utils::get( $edit_field, 'custom_class' ); |
|
166 | 166 | |
167 | - $new_fields[] = new GF_Field_HTML( $field_data ); |
|
167 | + $new_fields[ ] = new GF_Field_HTML( $field_data ); |
|
168 | 168 | |
169 | 169 | } else { |
170 | - if( isset( $fields[ $i ] ) ) { |
|
171 | - $new_fields[] = $fields[ $i ]; |
|
170 | + if ( isset( $fields[ $i ] ) ) { |
|
171 | + $new_fields[ ] = $fields[ $i ]; |
|
172 | 172 | } |
173 | 173 | $i++; |
174 | 174 | } |