@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | self::$file = plugin_dir_path( __FILE__ ); |
38 | 38 | |
39 | - if( is_admin() ) { |
|
39 | + if ( is_admin() ) { |
|
40 | 40 | $this->load_components( 'admin' ); |
41 | 41 | } |
42 | 42 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | static function getInstance() { |
57 | 57 | |
58 | - if( empty( self::$instance ) ) { |
|
58 | + if ( empty( self::$instance ) ) { |
|
59 | 59 | self::$instance = new GravityView_Edit_Entry; |
60 | 60 | } |
61 | 61 | |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | private function add_hooks() { |
82 | 82 | |
83 | 83 | // Add front-end access to Gravity Forms delete file action |
84 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
84 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file' ) ); |
|
85 | 85 | |
86 | 86 | // Make sure this hook is run for non-admins |
87 | - add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
87 | + add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file' ) ); |
|
88 | 88 | |
89 | 89 | add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
90 | 90 | |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | */ |
100 | 100 | private function addon_specific_hooks() { |
101 | 101 | |
102 | - if( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
103 | - add_filter('gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script')); |
|
102 | + if ( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
103 | + add_filter( 'gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script' ) ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | } |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
148 | 148 | |
149 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
149 | + $nonce_key = self::get_nonce_key( $view_id, $entry[ 'form_id' ], $entry[ 'id' ] ); |
|
150 | 150 | |
151 | - $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
151 | + $base = gv_entry_link( $entry, $post_id ?: $view_id ); |
|
152 | 152 | |
153 | 153 | $url = add_query_arg( array( |
154 | 154 | 'edit' => wp_create_nonce( $nonce_key ) |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | * Allow passing params to dynamically populate entry with values |
159 | 159 | * @since 1.9.2 |
160 | 160 | */ |
161 | - if( !empty( $field_values ) ) { |
|
161 | + if ( ! empty( $field_values ) ) { |
|
162 | 162 | |
163 | - if( is_array( $field_values ) ) { |
|
163 | + if ( is_array( $field_values ) ) { |
|
164 | 164 | // If already an array, no parse_str() needed |
165 | 165 | $params = $field_values; |
166 | 166 | } else { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function modify_field_blacklist( $fields = array(), $context = NULL ) { |
183 | 183 | |
184 | - if( empty( $context ) || $context !== 'edit' ) { |
|
184 | + if ( empty( $context ) || $context !== 'edit' ) { |
|
185 | 185 | return $fields; |
186 | 186 | } |
187 | 187 | |
@@ -242,25 +242,25 @@ discard block |
||
242 | 242 | // If they can edit any entries (as defined in Gravity Forms) |
243 | 243 | // Or if they can edit other people's entries |
244 | 244 | // Then we're good. |
245 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
245 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry[ 'id' ] ) ) { |
|
246 | 246 | |
247 | 247 | gravityview()->log->debug( 'User has ability to edit all entries.' ); |
248 | 248 | |
249 | 249 | $user_can_edit = true; |
250 | 250 | |
251 | - } else if( !isset( $entry['created_by'] ) ) { |
|
251 | + } else if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
252 | 252 | |
253 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
253 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.' ); |
|
254 | 254 | |
255 | 255 | $user_can_edit = false; |
256 | 256 | |
257 | 257 | } else { |
258 | 258 | |
259 | 259 | // get user_edit setting |
260 | - if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
260 | + if ( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
261 | 261 | // if View ID not specified or is the current view |
262 | 262 | // @deprecated path |
263 | - $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
263 | + $user_edit = GravityView_View::getInstance()->getAtts( 'user_edit' ); |
|
264 | 264 | } else { |
265 | 265 | // in case is specified and not the current view |
266 | 266 | $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | $current_user = wp_get_current_user(); |
270 | 270 | |
271 | 271 | // User edit is disabled |
272 | - if( empty( $user_edit ) ) { |
|
272 | + if ( empty( $user_edit ) ) { |
|
273 | 273 | |
274 | 274 | gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
275 | 275 | |
@@ -277,13 +277,13 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
280 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
280 | + else if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
281 | 281 | |
282 | 282 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
283 | 283 | |
284 | 284 | $user_can_edit = true; |
285 | 285 | |
286 | - } else if( ! is_user_logged_in() ) { |
|
286 | + } else if ( ! is_user_logged_in() ) { |
|
287 | 287 | |
288 | 288 | gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
289 | 289 | } |
@@ -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 ) ); |
@@ -106,16 +106,16 @@ discard block |
||
106 | 106 | function load() { |
107 | 107 | |
108 | 108 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
109 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
109 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
110 | 110 | |
111 | 111 | // Don't display an embedded form when editing an entry |
112 | 112 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
113 | 113 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
114 | 114 | |
115 | 115 | // Stop Gravity Forms processing what is ours! |
116 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
116 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
117 | 117 | |
118 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
118 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
119 | 119 | |
120 | 120 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
121 | 121 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
127 | 127 | |
128 | 128 | // Add fields expected by GFFormDisplay::validate() |
129 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
129 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
130 | 130 | |
131 | 131 | // Fix multiselect value for GF 2.2 |
132 | 132 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * @return void |
144 | 144 | */ |
145 | 145 | public function prevent_render_form() { |
146 | - if( $this->is_edit_entry() ) { |
|
147 | - if( 'wp_head' === current_filter() ) { |
|
146 | + if ( $this->is_edit_entry() ) { |
|
147 | + if ( 'wp_head' === current_filter() ) { |
|
148 | 148 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
149 | 149 | } else { |
150 | 150 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -159,13 +159,13 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function prevent_maybe_process_form() { |
161 | 161 | |
162 | - if( ! empty( $_POST ) ) { |
|
162 | + if ( ! empty( $_POST ) ) { |
|
163 | 163 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
164 | 164 | } |
165 | 165 | |
166 | - if( $this->is_edit_entry_submission() ) { |
|
167 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
168 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
166 | + if ( $this->is_edit_entry_submission() ) { |
|
167 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
168 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function is_edit_entry() { |
177 | 177 | |
178 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
178 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
179 | 179 | |
180 | 180 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
181 | 181 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @return boolean |
187 | 187 | */ |
188 | 188 | public function is_edit_entry_submission() { |
189 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
189 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -197,15 +197,15 @@ discard block |
||
197 | 197 | |
198 | 198 | |
199 | 199 | $entries = $gravityview_view->getEntries(); |
200 | - self::$original_entry = $entries[0]; |
|
201 | - $this->entry = $entries[0]; |
|
200 | + self::$original_entry = $entries[ 0 ]; |
|
201 | + $this->entry = $entries[ 0 ]; |
|
202 | 202 | |
203 | 203 | self::$original_form = $gravityview_view->getForm(); |
204 | 204 | $this->form = $gravityview_view->getForm(); |
205 | 205 | $this->form_id = $gravityview_view->getFormId(); |
206 | 206 | $this->view_id = $gravityview_view->getViewId(); |
207 | 207 | |
208 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
208 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -229,13 +229,13 @@ discard block |
||
229 | 229 | } |
230 | 230 | |
231 | 231 | // Multiple Views embedded, don't proceed if nonce fails |
232 | - if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) { |
|
232 | + if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) { |
|
233 | 233 | gravityview()->log->error( 'Nonce validation failed for the Edit Entry request; returning' ); |
234 | 234 | return; |
235 | 235 | } |
236 | 236 | |
237 | 237 | // Sorry, you're not allowed here. |
238 | - if( false === $this->user_can_edit_entry( true ) ) { |
|
238 | + if ( false === $this->user_can_edit_entry( true ) ) { |
|
239 | 239 | gravityview()->log->error( 'User is not allowed to edit this entry; returning', array( 'data' => $this->entry ) ); |
240 | 240 | return; |
241 | 241 | } |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | private function print_scripts() { |
257 | 257 | $gravityview_view = GravityView_View::getInstance(); |
258 | 258 | |
259 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
259 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
260 | 260 | |
261 | - GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false); |
|
261 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
262 | 262 | |
263 | 263 | // Sack is required for images |
264 | 264 | wp_print_scripts( array( 'sack', 'gform_gravityforms' ) ); |
@@ -270,19 +270,19 @@ discard block |
||
270 | 270 | */ |
271 | 271 | private function process_save() { |
272 | 272 | |
273 | - if( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
273 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
274 | 274 | return; |
275 | 275 | } |
276 | 276 | |
277 | 277 | // Make sure the entry, view, and form IDs are all correct |
278 | 278 | $valid = $this->verify_nonce(); |
279 | 279 | |
280 | - if( !$valid ) { |
|
280 | + if ( ! $valid ) { |
|
281 | 281 | gravityview()->log->error( 'Nonce validation failed.' ); |
282 | 282 | return; |
283 | 283 | } |
284 | 284 | |
285 | - if( $this->entry['id'] !== $_POST['lid'] ) { |
|
285 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
286 | 286 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
287 | 287 | return; |
288 | 288 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | |
294 | 294 | $this->validate(); |
295 | 295 | |
296 | - if( $this->is_valid ) { |
|
296 | + if ( $this->is_valid ) { |
|
297 | 297 | |
298 | 298 | gravityview()->log->debug( 'Submission is valid.' ); |
299 | 299 | |
@@ -310,22 +310,22 @@ discard block |
||
310 | 310 | /** |
311 | 311 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
312 | 312 | */ |
313 | - unset( $_GET['page'] ); |
|
313 | + unset( $_GET[ 'page' ] ); |
|
314 | 314 | |
315 | - $date_created = $this->entry['date_created']; |
|
315 | + $date_created = $this->entry[ 'date_created' ]; |
|
316 | 316 | |
317 | 317 | /** |
318 | 318 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
319 | 319 | * @since 1.17.2 |
320 | 320 | */ |
321 | - unset( $this->entry['date_created'] ); |
|
321 | + unset( $this->entry[ 'date_created' ] ); |
|
322 | 322 | |
323 | 323 | GFFormsModel::save_lead( $form, $this->entry ); |
324 | 324 | |
325 | 325 | // Delete the values for hidden inputs |
326 | 326 | $this->unset_hidden_field_values(); |
327 | 327 | |
328 | - $this->entry['date_created'] = $date_created; |
|
328 | + $this->entry[ 'date_created' ] = $date_created; |
|
329 | 329 | |
330 | 330 | // Process calculation fields |
331 | 331 | $this->update_calculation_fields(); |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @param string $entry_id Numeric ID of the entry that was updated |
346 | 346 | * @param GravityView_Edit_Entry_Render $this This object |
347 | 347 | */ |
348 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this ); |
|
348 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this ); |
|
349 | 349 | |
350 | 350 | } else { |
351 | 351 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -373,16 +373,16 @@ discard block |
||
373 | 373 | */ |
374 | 374 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
375 | 375 | |
376 | - if( ! $unset_hidden_field_values ) { |
|
376 | + if ( ! $unset_hidden_field_values ) { |
|
377 | 377 | return; |
378 | 378 | } |
379 | 379 | |
380 | 380 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
381 | 381 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
382 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
382 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
383 | 383 | } else { |
384 | 384 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
385 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
385 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | } |
464 | 464 | |
465 | 465 | /** No file is being uploaded. */ |
466 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
466 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
467 | 467 | /** So return the original upload */ |
468 | 468 | return $entry[ $input_id ]; |
469 | 469 | } |
@@ -481,11 +481,11 @@ discard block |
||
481 | 481 | * @return mixed |
482 | 482 | */ |
483 | 483 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
484 | - if( ! $this->is_edit_entry() ) { |
|
484 | + if ( ! $this->is_edit_entry() ) { |
|
485 | 485 | return $plupload_init; |
486 | 486 | } |
487 | 487 | |
488 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
488 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
489 | 489 | |
490 | 490 | return $plupload_init; |
491 | 491 | } |
@@ -500,22 +500,22 @@ discard block |
||
500 | 500 | $form = $this->form; |
501 | 501 | |
502 | 502 | /** @var GF_Field $field */ |
503 | - foreach( $form['fields'] as $k => &$field ) { |
|
503 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
504 | 504 | |
505 | 505 | /** |
506 | 506 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
507 | 507 | * @since 1.16.3 |
508 | 508 | * @var GF_Field $field |
509 | 509 | */ |
510 | - if( $field->has_calculation() ) { |
|
511 | - unset( $form['fields'][ $k ] ); |
|
510 | + if ( $field->has_calculation() ) { |
|
511 | + unset( $form[ 'fields' ][ $k ] ); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | $field->adminOnly = false; |
515 | 515 | |
516 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
517 | - foreach( $field->inputs as $key => $input ) { |
|
518 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
516 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
517 | + foreach ( $field->inputs as $key => $input ) { |
|
518 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
519 | 519 | } |
520 | 520 | } |
521 | 521 | } |
@@ -529,30 +529,30 @@ discard block |
||
529 | 529 | $update = false; |
530 | 530 | |
531 | 531 | // get the most up to date entry values |
532 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
532 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
533 | 533 | |
534 | - if( !empty( $this->fields_with_calculation ) ) { |
|
534 | + if ( ! empty( $this->fields_with_calculation ) ) { |
|
535 | 535 | $update = true; |
536 | 536 | foreach ( $this->fields_with_calculation as $calc_field ) { |
537 | 537 | $inputs = $calc_field->get_entry_inputs(); |
538 | 538 | if ( is_array( $inputs ) ) { |
539 | 539 | foreach ( $inputs as $input ) { |
540 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
541 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
540 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
541 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
542 | 542 | } |
543 | 543 | } else { |
544 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
545 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
544 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id ); |
|
545 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | |
549 | 549 | } |
550 | 550 | |
551 | - if( $update ) { |
|
551 | + if ( $update ) { |
|
552 | 552 | |
553 | 553 | $return_entry = GFAPI::update_entry( $entry ); |
554 | 554 | |
555 | - if( is_wp_error( $return_entry ) ) { |
|
555 | + if ( is_wp_error( $return_entry ) ) { |
|
556 | 556 | gravityview()->log->error( 'Updating the entry calculation fields failed', array( 'data' => $return_entry ) ); |
557 | 557 | } else { |
558 | 558 | gravityview()->log->debug( 'Updating the entry calculation fields succeeded' ); |
@@ -583,19 +583,19 @@ discard block |
||
583 | 583 | |
584 | 584 | $input_name = 'input_' . $field_id; |
585 | 585 | |
586 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
586 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
587 | 587 | |
588 | 588 | // We have a new image |
589 | 589 | |
590 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
590 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
591 | 591 | |
592 | 592 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
593 | 593 | $ary = stripslashes_deep( $ary ); |
594 | 594 | $img_url = \GV\Utils::get( $ary, 0 ); |
595 | 595 | |
596 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
597 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
598 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
596 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
597 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
598 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
599 | 599 | |
600 | 600 | $image_meta = array( |
601 | 601 | 'post_excerpt' => $img_caption, |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | |
605 | 605 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
606 | 606 | if ( ! empty( $img_title ) ) { |
607 | - $image_meta['post_title'] = $img_title; |
|
607 | + $image_meta[ 'post_title' ] = $img_title; |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
@@ -662,15 +662,15 @@ discard block |
||
662 | 662 | */ |
663 | 663 | private function maybe_update_post_fields( $form ) { |
664 | 664 | |
665 | - if( empty( $this->entry['post_id'] ) ) { |
|
665 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
666 | 666 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
667 | 667 | return; |
668 | 668 | } |
669 | 669 | |
670 | - $post_id = $this->entry['post_id']; |
|
670 | + $post_id = $this->entry[ 'post_id' ]; |
|
671 | 671 | |
672 | 672 | // Security check |
673 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
673 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
674 | 674 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
675 | 675 | return; |
676 | 676 | } |
@@ -683,25 +683,25 @@ discard block |
||
683 | 683 | |
684 | 684 | $field = RGFormsModel::get_field( $form, $field_id ); |
685 | 685 | |
686 | - if( ! $field ) { |
|
686 | + if ( ! $field ) { |
|
687 | 687 | continue; |
688 | 688 | } |
689 | 689 | |
690 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
690 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
691 | 691 | |
692 | 692 | // Get the value of the field, including $_POSTed value |
693 | 693 | $value = RGFormsModel::get_field_value( $field ); |
694 | 694 | |
695 | 695 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
696 | 696 | $entry_tmp = $this->entry; |
697 | - $entry_tmp["{$field_id}"] = $value; |
|
697 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
698 | 698 | |
699 | - switch( $field->type ) { |
|
699 | + switch ( $field->type ) { |
|
700 | 700 | |
701 | 701 | case 'post_title': |
702 | 702 | $post_title = $value; |
703 | 703 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
704 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
704 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
705 | 705 | } |
706 | 706 | $updated_post->post_title = $post_title; |
707 | 707 | $updated_post->post_name = $post_title; |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | case 'post_content': |
712 | 712 | $post_content = $value; |
713 | 713 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
714 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
714 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
715 | 715 | } |
716 | 716 | $updated_post->post_content = $post_content; |
717 | 717 | unset( $post_content ); |
@@ -729,12 +729,12 @@ discard block |
||
729 | 729 | $value = $value[ $field_id ]; |
730 | 730 | } |
731 | 731 | |
732 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
732 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
733 | 733 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
734 | 734 | } |
735 | 735 | |
736 | 736 | if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
737 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
737 | + $value = function_exists( 'wp_json_encode' ) ? wp_json_encode( $value ) : json_encode( $value ); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | } |
748 | 748 | |
749 | 749 | // update entry after |
750 | - $this->entry["{$field_id}"] = $value; |
|
750 | + $this->entry[ "{$field_id}" ] = $value; |
|
751 | 751 | |
752 | 752 | $update_entry = true; |
753 | 753 | |
@@ -756,11 +756,11 @@ discard block |
||
756 | 756 | |
757 | 757 | } |
758 | 758 | |
759 | - if( $update_entry ) { |
|
759 | + if ( $update_entry ) { |
|
760 | 760 | |
761 | 761 | $return_entry = GFAPI::update_entry( $this->entry ); |
762 | 762 | |
763 | - if( is_wp_error( $return_entry ) ) { |
|
763 | + if ( is_wp_error( $return_entry ) ) { |
|
764 | 764 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
765 | 765 | } else { |
766 | 766 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | |
771 | 771 | $return_post = wp_update_post( $updated_post, true ); |
772 | 772 | |
773 | - if( is_wp_error( $return_post ) ) { |
|
773 | + if ( is_wp_error( $return_post ) ) { |
|
774 | 774 | $return_post->add_data( $updated_post, '$updated_post' ); |
775 | 775 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
776 | 776 | } else { |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | $input_type = RGFormsModel::get_input_type( $field ); |
793 | 793 | |
794 | 794 | // Only certain custom field types are supported |
795 | - switch( $input_type ) { |
|
795 | + switch ( $input_type ) { |
|
796 | 796 | case 'fileupload': |
797 | 797 | case 'list': |
798 | 798 | case 'multiselect': |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
830 | 830 | |
831 | 831 | // replace conditional shortcodes |
832 | - if( $do_shortcode ) { |
|
832 | + if ( $do_shortcode ) { |
|
833 | 833 | $output = do_shortcode( $output ); |
834 | 834 | } |
835 | 835 | |
@@ -848,19 +848,19 @@ discard block |
||
848 | 848 | */ |
849 | 849 | private function after_update() { |
850 | 850 | |
851 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
852 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
851 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
852 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
853 | 853 | |
854 | 854 | // Re-define the entry now that we've updated it. |
855 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
855 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
856 | 856 | |
857 | 857 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
858 | 858 | |
859 | 859 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
860 | 860 | // We need to clear the cache because Gravity Forms caches the field values, which |
861 | 861 | // we have just updated. |
862 | - foreach ($this->form['fields'] as $key => $field) { |
|
863 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
862 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
863 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
864 | 864 | } |
865 | 865 | } |
866 | 866 | |
@@ -879,7 +879,7 @@ discard block |
||
879 | 879 | |
880 | 880 | <div class="gv-edit-entry-wrapper"><?php |
881 | 881 | |
882 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
882 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
883 | 883 | |
884 | 884 | /** |
885 | 885 | * Fixes weird wpautop() issue |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | * @param string $edit_entry_title Modify the "Edit Entry" title |
896 | 896 | * @param GravityView_Edit_Entry_Render $this This object |
897 | 897 | */ |
898 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
898 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
899 | 899 | |
900 | 900 | echo esc_attr( $edit_entry_title ); |
901 | 901 | ?></span> |
@@ -945,16 +945,16 @@ discard block |
||
945 | 945 | |
946 | 946 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
947 | 947 | |
948 | - if( ! $this->is_valid ){ |
|
948 | + if ( ! $this->is_valid ) { |
|
949 | 949 | |
950 | 950 | // Keeping this compatible with Gravity Forms. |
951 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
952 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
951 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
952 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
953 | 953 | |
954 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
954 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
955 | 955 | |
956 | 956 | } else { |
957 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
957 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' ); |
|
958 | 958 | |
959 | 959 | /** |
960 | 960 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | * @param array $entry Gravity Forms entry array |
965 | 965 | * @param string $back_link URL to return to the original entry. @since 1.6 |
966 | 966 | */ |
967 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
967 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
968 | 968 | |
969 | 969 | echo GVCommon::generate_notice( $message ); |
970 | 970 | } |
@@ -988,21 +988,21 @@ discard block |
||
988 | 988 | */ |
989 | 989 | do_action( 'gravityview/edit-entry/render/before', $this ); |
990 | 990 | |
991 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
992 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
991 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
992 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
993 | 993 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
994 | 994 | |
995 | 995 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
996 | 996 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
997 | 997 | |
998 | 998 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
999 | - unset( $_GET['page'] ); |
|
999 | + unset( $_GET[ 'page' ] ); |
|
1000 | 1000 | |
1001 | 1001 | // TODO: Verify multiple-page forms |
1002 | 1002 | |
1003 | 1003 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
1004 | 1004 | |
1005 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
1005 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1006 | 1006 | |
1007 | 1007 | ob_get_clean(); |
1008 | 1008 | |
@@ -1028,7 +1028,7 @@ discard block |
||
1028 | 1028 | * @return string |
1029 | 1029 | */ |
1030 | 1030 | public function render_form_buttons() { |
1031 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
1031 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | |
@@ -1048,10 +1048,10 @@ discard block |
||
1048 | 1048 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1049 | 1049 | |
1050 | 1050 | // In case we have validated the form, use it to inject the validation results into the form render |
1051 | - if( isset( $this->form_after_validation ) ) { |
|
1051 | + if ( isset( $this->form_after_validation ) ) { |
|
1052 | 1052 | $form = $this->form_after_validation; |
1053 | 1053 | } else { |
1054 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1054 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | $form = $this->filter_conditional_logic( $form ); |
@@ -1059,8 +1059,8 @@ discard block |
||
1059 | 1059 | $form = $this->prefill_conditional_logic( $form ); |
1060 | 1060 | |
1061 | 1061 | // for now we don't support Save and Continue feature. |
1062 | - if( ! self::$supports_save_and_continue ) { |
|
1063 | - unset( $form['save'] ); |
|
1062 | + if ( ! self::$supports_save_and_continue ) { |
|
1063 | + unset( $form[ 'save' ] ); |
|
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | return $form; |
@@ -1081,29 +1081,29 @@ discard block |
||
1081 | 1081 | */ |
1082 | 1082 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
1083 | 1083 | |
1084 | - if( GFCommon::is_post_field( $field ) ) { |
|
1084 | + if ( GFCommon::is_post_field( $field ) ) { |
|
1085 | 1085 | |
1086 | 1086 | $message = null; |
1087 | 1087 | |
1088 | 1088 | // First, make sure they have the capability to edit the post. |
1089 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1089 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1090 | 1090 | |
1091 | 1091 | /** |
1092 | 1092 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1093 | 1093 | * @param string $message The existing "You don't have permission..." text |
1094 | 1094 | */ |
1095 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1095 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1096 | 1096 | |
1097 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1097 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1098 | 1098 | /** |
1099 | 1099 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1100 | 1100 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1101 | 1101 | */ |
1102 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1102 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1103 | 1103 | } |
1104 | 1104 | |
1105 | - if( $message ) { |
|
1106 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1105 | + if ( $message ) { |
|
1106 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1107 | 1107 | } |
1108 | 1108 | } |
1109 | 1109 | |
@@ -1128,8 +1128,8 @@ discard block |
||
1128 | 1128 | |
1129 | 1129 | // If the form has been submitted, then we don't need to pre-fill the values, |
1130 | 1130 | // Except for fileupload type and when a field input is overridden- run always!! |
1131 | - if( |
|
1132 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1131 | + if ( |
|
1132 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1133 | 1133 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1134 | 1134 | && ! GFCommon::is_product_field( $field->type ) |
1135 | 1135 | || ! empty( $field_content ) |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | $return = null; |
1150 | 1150 | |
1151 | 1151 | /** @var GravityView_Field $gv_field */ |
1152 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1152 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1153 | 1153 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1154 | 1154 | } else { |
1155 | 1155 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | // If there was output, it's an error |
1159 | 1159 | $warnings = ob_get_clean(); |
1160 | 1160 | |
1161 | - if( !empty( $warnings ) ) { |
|
1161 | + if ( ! empty( $warnings ) ) { |
|
1162 | 1162 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
1163 | 1163 | } |
1164 | 1164 | |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1184 | 1184 | |
1185 | 1185 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1186 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1186 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1187 | 1187 | |
1188 | 1188 | $field_value = array(); |
1189 | 1189 | |
@@ -1192,10 +1192,10 @@ discard block |
||
1192 | 1192 | |
1193 | 1193 | foreach ( (array)$field->inputs as $input ) { |
1194 | 1194 | |
1195 | - $input_id = strval( $input['id'] ); |
|
1195 | + $input_id = strval( $input[ 'id' ] ); |
|
1196 | 1196 | |
1197 | 1197 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1198 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1198 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1199 | 1199 | $allow_pre_populated = false; |
1200 | 1200 | } |
1201 | 1201 | |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | |
1204 | 1204 | $pre_value = $field->get_value_submission( array(), false ); |
1205 | 1205 | |
1206 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1206 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1207 | 1207 | |
1208 | 1208 | } else { |
1209 | 1209 | |
@@ -1214,13 +1214,13 @@ discard block |
||
1214 | 1214 | |
1215 | 1215 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1216 | 1216 | // or pre-populated value if not empty and set to override saved value |
1217 | - $field_value = !gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1217 | + $field_value = ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1218 | 1218 | |
1219 | 1219 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1220 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1220 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1221 | 1221 | $categories = array(); |
1222 | 1222 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1223 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1223 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1224 | 1224 | } |
1225 | 1225 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1226 | 1226 | } |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | * @param GF_Field $field Gravity Forms field object |
1249 | 1249 | * @param GravityView_Edit_Entry_Render $this Current object |
1250 | 1250 | */ |
1251 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1251 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1252 | 1252 | |
1253 | 1253 | return $field_value; |
1254 | 1254 | } |
@@ -1265,12 +1265,12 @@ discard block |
||
1265 | 1265 | */ |
1266 | 1266 | public function gform_pre_validation( $form ) { |
1267 | 1267 | |
1268 | - if( ! $this->verify_nonce() ) { |
|
1268 | + if ( ! $this->verify_nonce() ) { |
|
1269 | 1269 | return $form; |
1270 | 1270 | } |
1271 | 1271 | |
1272 | 1272 | // Fix PHP warning regarding undefined index. |
1273 | - foreach ( $form['fields'] as &$field) { |
|
1273 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1274 | 1274 | |
1275 | 1275 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1276 | 1276 | // expects certain field array items to be set. |
@@ -1278,7 +1278,7 @@ discard block |
||
1278 | 1278 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
1279 | 1279 | } |
1280 | 1280 | |
1281 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1281 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1282 | 1282 | |
1283 | 1283 | /** |
1284 | 1284 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1292,26 +1292,26 @@ discard block |
||
1292 | 1292 | // Set the previous value |
1293 | 1293 | $entry = $this->get_entry(); |
1294 | 1294 | |
1295 | - $input_name = 'input_'.$field->id; |
|
1296 | - $form_id = $form['id']; |
|
1295 | + $input_name = 'input_' . $field->id; |
|
1296 | + $form_id = $form[ 'id' ]; |
|
1297 | 1297 | |
1298 | 1298 | $value = NULL; |
1299 | 1299 | |
1300 | 1300 | // Use the previous entry value as the default. |
1301 | - if( isset( $entry[ $field->id ] ) ) { |
|
1301 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1302 | 1302 | $value = $entry[ $field->id ]; |
1303 | 1303 | } |
1304 | 1304 | |
1305 | 1305 | // If this is a single upload file |
1306 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1307 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1308 | - $value = $file_path['url']; |
|
1306 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1307 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1308 | + $value = $file_path[ 'url' ]; |
|
1309 | 1309 | |
1310 | 1310 | } else { |
1311 | 1311 | |
1312 | 1312 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1313 | 1313 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1314 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1314 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1315 | 1315 | |
1316 | 1316 | } |
1317 | 1317 | |
@@ -1319,10 +1319,10 @@ discard block |
||
1319 | 1319 | |
1320 | 1320 | // If there are fresh uploads, process and merge them. |
1321 | 1321 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1322 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1322 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1323 | 1323 | $value = empty( $value ) ? '[]' : $value; |
1324 | 1324 | $value = stripslashes_deep( $value ); |
1325 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1325 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1326 | 1326 | } |
1327 | 1327 | |
1328 | 1328 | } else { |
@@ -1340,8 +1340,8 @@ discard block |
||
1340 | 1340 | |
1341 | 1341 | case 'number': |
1342 | 1342 | // Fix "undefined index" issue at line 1286 in form_display.php |
1343 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1344 | - $_POST['input_'.$field->id ] = NULL; |
|
1343 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1344 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1345 | 1345 | } |
1346 | 1346 | break; |
1347 | 1347 | } |
@@ -1378,7 +1378,7 @@ discard block |
||
1378 | 1378 | * You can enter whatever you want! |
1379 | 1379 | * We try validating, and customize the results using `self::custom_validation()` |
1380 | 1380 | */ |
1381 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1381 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1382 | 1382 | |
1383 | 1383 | // Needed by the validate funtion |
1384 | 1384 | $failed_validation_page = NULL; |
@@ -1386,14 +1386,14 @@ discard block |
||
1386 | 1386 | |
1387 | 1387 | // Prevent entry limit from running when editing an entry, also |
1388 | 1388 | // prevent form scheduling from preventing editing |
1389 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1389 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1390 | 1390 | |
1391 | 1391 | // Hide fields depending on Edit Entry settings |
1392 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1392 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1393 | 1393 | |
1394 | 1394 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1395 | 1395 | |
1396 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1396 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1397 | 1397 | } |
1398 | 1398 | |
1399 | 1399 | |
@@ -1416,7 +1416,7 @@ discard block |
||
1416 | 1416 | |
1417 | 1417 | $gv_valid = true; |
1418 | 1418 | |
1419 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1419 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1420 | 1420 | |
1421 | 1421 | $value = RGFormsModel::get_field_value( $field ); |
1422 | 1422 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1429,35 +1429,35 @@ discard block |
||
1429 | 1429 | case 'post_image': |
1430 | 1430 | |
1431 | 1431 | // in case nothing is uploaded but there are already files saved |
1432 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1432 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1433 | 1433 | $field->failed_validation = false; |
1434 | 1434 | unset( $field->validation_message ); |
1435 | 1435 | } |
1436 | 1436 | |
1437 | 1437 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1438 | - if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) { |
|
1438 | + if ( rgobj( $field, 'maxFiles' ) && rgobj( $field, 'multipleFiles' ) ) { |
|
1439 | 1439 | |
1440 | 1440 | $input_name = 'input_' . $field->id; |
1441 | 1441 | //uploaded |
1442 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1442 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1443 | 1443 | |
1444 | 1444 | //existent |
1445 | 1445 | $entry = $this->get_entry(); |
1446 | 1446 | $value = NULL; |
1447 | - if( isset( $entry[ $field->id ] ) ) { |
|
1447 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1448 | 1448 | $value = json_decode( $entry[ $field->id ], true ); |
1449 | 1449 | } |
1450 | 1450 | |
1451 | 1451 | // count uploaded files and existent entry files |
1452 | 1452 | $count_files = count( $file_names ) + count( $value ); |
1453 | 1453 | |
1454 | - if( $count_files > $field->maxFiles ) { |
|
1454 | + if ( $count_files > $field->maxFiles ) { |
|
1455 | 1455 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1456 | 1456 | $field->failed_validation = 1; |
1457 | 1457 | $gv_valid = false; |
1458 | 1458 | |
1459 | 1459 | // in case of error make sure the newest upload files are removed from the upload input |
1460 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1460 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1461 | 1461 | } |
1462 | 1462 | |
1463 | 1463 | } |
@@ -1468,7 +1468,7 @@ discard block |
||
1468 | 1468 | } |
1469 | 1469 | |
1470 | 1470 | // This field has failed validation. |
1471 | - if( !empty( $field->failed_validation ) ) { |
|
1471 | + if ( ! empty( $field->failed_validation ) ) { |
|
1472 | 1472 | |
1473 | 1473 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
1474 | 1474 | |
@@ -1486,19 +1486,19 @@ discard block |
||
1486 | 1486 | } |
1487 | 1487 | |
1488 | 1488 | // You can't continue inside a switch, so we do it after. |
1489 | - if( empty( $field->failed_validation ) ) { |
|
1489 | + if ( empty( $field->failed_validation ) ) { |
|
1490 | 1490 | continue; |
1491 | 1491 | } |
1492 | 1492 | |
1493 | 1493 | // checks if the No Duplicates option is not validating entry against itself, since |
1494 | 1494 | // we're editing a stored entry, it would also assume it's a duplicate. |
1495 | - if( !empty( $field->noDuplicates ) ) { |
|
1495 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1496 | 1496 | |
1497 | 1497 | $entry = $this->get_entry(); |
1498 | 1498 | |
1499 | 1499 | // If the value of the entry is the same as the stored value |
1500 | 1500 | // Then we can assume it's not a duplicate, it's the same. |
1501 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1501 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1502 | 1502 | //if value submitted was not changed, then don't validate |
1503 | 1503 | $field->failed_validation = false; |
1504 | 1504 | |
@@ -1511,7 +1511,7 @@ discard block |
||
1511 | 1511 | } |
1512 | 1512 | |
1513 | 1513 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1514 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1514 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1515 | 1515 | unset( $field->validation_message ); |
1516 | 1516 | $field->validation_message = false; |
1517 | 1517 | continue; |
@@ -1523,12 +1523,12 @@ discard block |
||
1523 | 1523 | |
1524 | 1524 | } |
1525 | 1525 | |
1526 | - $validation_results['is_valid'] = $gv_valid; |
|
1526 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1527 | 1527 | |
1528 | 1528 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
1529 | 1529 | |
1530 | 1530 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1531 | - $this->form_after_validation = $validation_results['form']; |
|
1531 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1532 | 1532 | |
1533 | 1533 | return $validation_results; |
1534 | 1534 | } |
@@ -1541,7 +1541,7 @@ discard block |
||
1541 | 1541 | */ |
1542 | 1542 | public function get_entry() { |
1543 | 1543 | |
1544 | - if( empty( $this->entry ) ) { |
|
1544 | + if ( empty( $this->entry ) ) { |
|
1545 | 1545 | // Get the database value of the entry that's being edited |
1546 | 1546 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1547 | 1547 | } |
@@ -1573,10 +1573,10 @@ discard block |
||
1573 | 1573 | } |
1574 | 1574 | |
1575 | 1575 | // If edit tab not yet configured, show all fields |
1576 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1576 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1577 | 1577 | |
1578 | 1578 | // Hide fields depending on admin settings |
1579 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1579 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1580 | 1580 | |
1581 | 1581 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1582 | 1582 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1608,7 +1608,7 @@ discard block |
||
1608 | 1608 | */ |
1609 | 1609 | private function filter_fields( $fields, $configured_fields ) { |
1610 | 1610 | |
1611 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1611 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1612 | 1612 | return $fields; |
1613 | 1613 | } |
1614 | 1614 | |
@@ -1621,18 +1621,18 @@ discard block |
||
1621 | 1621 | |
1622 | 1622 | // Remove the fields that have calculation properties and keep them to be used later |
1623 | 1623 | // @since 1.16.2 |
1624 | - if( $field->has_calculation() ) { |
|
1625 | - $this->fields_with_calculation[] = $field; |
|
1624 | + if ( $field->has_calculation() ) { |
|
1625 | + $this->fields_with_calculation[ ] = $field; |
|
1626 | 1626 | // don't remove the calculation fields on form render. |
1627 | 1627 | } |
1628 | 1628 | |
1629 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1629 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1630 | 1630 | unset( $fields[ $key ] ); |
1631 | 1631 | } |
1632 | 1632 | } |
1633 | 1633 | |
1634 | 1634 | // The Edit tab has not been configured, so we return all fields by default. |
1635 | - if( empty( $configured_fields ) ) { |
|
1635 | + if ( empty( $configured_fields ) ) { |
|
1636 | 1636 | return $fields; |
1637 | 1637 | } |
1638 | 1638 | |
@@ -1642,8 +1642,8 @@ discard block |
||
1642 | 1642 | /** @var GF_Field $field */ |
1643 | 1643 | foreach ( $fields as $field ) { |
1644 | 1644 | |
1645 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1646 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1645 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1646 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1647 | 1647 | break; |
1648 | 1648 | } |
1649 | 1649 | |
@@ -1666,14 +1666,14 @@ discard block |
||
1666 | 1666 | |
1667 | 1667 | $return_field = $field; |
1668 | 1668 | |
1669 | - if( empty( $field_setting['show_label'] ) ) { |
|
1669 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1670 | 1670 | $return_field->label = ''; |
1671 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1672 | - $return_field->label = $field_setting['custom_label']; |
|
1671 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1672 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1673 | 1673 | } |
1674 | 1674 | |
1675 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1676 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1675 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1676 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1677 | 1677 | } |
1678 | 1678 | |
1679 | 1679 | /** |
@@ -1711,16 +1711,16 @@ discard block |
||
1711 | 1711 | */ |
1712 | 1712 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
1713 | 1713 | |
1714 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1715 | - foreach( $fields as $k => $field ) { |
|
1716 | - if( $field->adminOnly ) { |
|
1714 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
1715 | + foreach ( $fields as $k => $field ) { |
|
1716 | + if ( $field->adminOnly ) { |
|
1717 | 1717 | unset( $fields[ $k ] ); |
1718 | 1718 | } |
1719 | 1719 | } |
1720 | 1720 | return $fields; |
1721 | 1721 | } |
1722 | 1722 | |
1723 | - foreach( $fields as &$field ) { |
|
1723 | + foreach ( $fields as &$field ) { |
|
1724 | 1724 | $field->adminOnly = false; |
1725 | 1725 | } |
1726 | 1726 | |
@@ -1744,22 +1744,22 @@ discard block |
||
1744 | 1744 | */ |
1745 | 1745 | function prefill_conditional_logic( $form ) { |
1746 | 1746 | |
1747 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1747 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1748 | 1748 | return $form; |
1749 | 1749 | } |
1750 | 1750 | |
1751 | 1751 | // Have Conditional Logic pre-fill fields as if the data were default values |
1752 | 1752 | /** @var GF_Field $field */ |
1753 | - foreach ( $form['fields'] as &$field ) { |
|
1753 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1754 | 1754 | |
1755 | - if( 'checkbox' === $field->type ) { |
|
1755 | + if ( 'checkbox' === $field->type ) { |
|
1756 | 1756 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1757 | - $input_id = $input['id']; |
|
1757 | + $input_id = $input[ 'id' ]; |
|
1758 | 1758 | $choice = $field->choices[ $key ]; |
1759 | 1759 | $value = \GV\Utils::get( $this->entry, $input_id ); |
1760 | 1760 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
1761 | - if( $match ) { |
|
1762 | - $field->choices[ $key ]['isSelected'] = true; |
|
1761 | + if ( $match ) { |
|
1762 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
1763 | 1763 | } |
1764 | 1764 | } |
1765 | 1765 | } else { |
@@ -1767,15 +1767,15 @@ discard block |
||
1767 | 1767 | // We need to run through each field to set the default values |
1768 | 1768 | foreach ( $this->entry as $field_id => $field_value ) { |
1769 | 1769 | |
1770 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1770 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1771 | 1771 | |
1772 | - if( 'list' === $field->type ) { |
|
1772 | + if ( 'list' === $field->type ) { |
|
1773 | 1773 | $list_rows = maybe_unserialize( $field_value ); |
1774 | 1774 | |
1775 | 1775 | $list_field_value = array(); |
1776 | - foreach ( (array) $list_rows as $row ) { |
|
1777 | - foreach ( (array) $row as $column ) { |
|
1778 | - $list_field_value[] = $column; |
|
1776 | + foreach ( (array)$list_rows as $row ) { |
|
1777 | + foreach ( (array)$row as $column ) { |
|
1778 | + $list_field_value[ ] = $column; |
|
1779 | 1779 | } |
1780 | 1780 | } |
1781 | 1781 | |
@@ -1810,16 +1810,16 @@ discard block |
||
1810 | 1810 | */ |
1811 | 1811 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
1812 | 1812 | |
1813 | - if( $use_conditional_logic ) { |
|
1813 | + if ( $use_conditional_logic ) { |
|
1814 | 1814 | return $form; |
1815 | 1815 | } |
1816 | 1816 | |
1817 | - foreach( $form['fields'] as &$field ) { |
|
1817 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1818 | 1818 | /* @var GF_Field $field */ |
1819 | 1819 | $field->conditionalLogic = null; |
1820 | 1820 | } |
1821 | 1821 | |
1822 | - unset( $form['button']['conditionalLogic'] ); |
|
1822 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
1823 | 1823 | |
1824 | 1824 | return $form; |
1825 | 1825 | |
@@ -1836,7 +1836,7 @@ discard block |
||
1836 | 1836 | */ |
1837 | 1837 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
1838 | 1838 | |
1839 | - if( ! $this->is_edit_entry() ) { |
|
1839 | + if ( ! $this->is_edit_entry() ) { |
|
1840 | 1840 | return $has_conditional_logic; |
1841 | 1841 | } |
1842 | 1842 | |
@@ -1868,44 +1868,44 @@ discard block |
||
1868 | 1868 | * 2. There are two entries embedded using oEmbed |
1869 | 1869 | * 3. One of the entries has just been saved |
1870 | 1870 | */ |
1871 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
1871 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
1872 | 1872 | |
1873 | 1873 | $error = true; |
1874 | 1874 | |
1875 | 1875 | } |
1876 | 1876 | |
1877 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
1877 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
1878 | 1878 | |
1879 | 1879 | $error = true; |
1880 | 1880 | |
1881 | - } elseif( ! $this->verify_nonce() ) { |
|
1881 | + } elseif ( ! $this->verify_nonce() ) { |
|
1882 | 1882 | |
1883 | 1883 | /** |
1884 | 1884 | * If the Entry is embedded, there may be two entries on the same page. |
1885 | 1885 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
1886 | 1886 | */ |
1887 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1887 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1888 | 1888 | $error = true; |
1889 | 1889 | } else { |
1890 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
1890 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
1891 | 1891 | } |
1892 | 1892 | |
1893 | 1893 | } |
1894 | 1894 | |
1895 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1896 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
1895 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1896 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
1897 | 1897 | } |
1898 | 1898 | |
1899 | - if( $this->entry['status'] === 'trash' ) { |
|
1900 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1899 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
1900 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1901 | 1901 | } |
1902 | 1902 | |
1903 | 1903 | // No errors; everything's fine here! |
1904 | - if( empty( $error ) ) { |
|
1904 | + if ( empty( $error ) ) { |
|
1905 | 1905 | return true; |
1906 | 1906 | } |
1907 | 1907 | |
1908 | - if( $echo && $error !== true ) { |
|
1908 | + if ( $echo && $error !== true ) { |
|
1909 | 1909 | |
1910 | 1910 | $error = esc_html( $error ); |
1911 | 1911 | |
@@ -1913,10 +1913,10 @@ discard block |
||
1913 | 1913 | * @since 1.9 |
1914 | 1914 | */ |
1915 | 1915 | if ( ! empty( $this->entry ) ) { |
1916 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1916 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1917 | 1917 | } |
1918 | 1918 | |
1919 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
1919 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
1920 | 1920 | } |
1921 | 1921 | |
1922 | 1922 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1936,17 +1936,17 @@ discard block |
||
1936 | 1936 | |
1937 | 1937 | $error = NULL; |
1938 | 1938 | |
1939 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1940 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
1939 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1940 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
1941 | 1941 | } |
1942 | 1942 | |
1943 | 1943 | // No errors; everything's fine here! |
1944 | - if( empty( $error ) ) { |
|
1944 | + if ( empty( $error ) ) { |
|
1945 | 1945 | return true; |
1946 | 1946 | } |
1947 | 1947 | |
1948 | - if( $echo ) { |
|
1949 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
1948 | + if ( $echo ) { |
|
1949 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
1950 | 1950 | } |
1951 | 1951 | |
1952 | 1952 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1967,14 +1967,14 @@ discard block |
||
1967 | 1967 | private function check_user_cap_edit_field( $field ) { |
1968 | 1968 | |
1969 | 1969 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
1970 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1970 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1971 | 1971 | return true; |
1972 | 1972 | } |
1973 | 1973 | |
1974 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
1974 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
1975 | 1975 | |
1976 | - if( $field_cap ) { |
|
1977 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
1976 | + if ( $field_cap ) { |
|
1977 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
1978 | 1978 | } |
1979 | 1979 | |
1980 | 1980 | return false; |
@@ -1988,17 +1988,17 @@ discard block |
||
1988 | 1988 | public function verify_nonce() { |
1989 | 1989 | |
1990 | 1990 | // Verify form submitted for editing single |
1991 | - if( $this->is_edit_entry_submission() ) { |
|
1991 | + if ( $this->is_edit_entry_submission() ) { |
|
1992 | 1992 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
1993 | 1993 | } |
1994 | 1994 | |
1995 | 1995 | // Verify |
1996 | - else if( ! $this->is_edit_entry() ) { |
|
1996 | + else if ( ! $this->is_edit_entry() ) { |
|
1997 | 1997 | $valid = false; |
1998 | 1998 | } |
1999 | 1999 | |
2000 | 2000 | else { |
2001 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
2001 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2002 | 2002 | } |
2003 | 2003 | |
2004 | 2004 | /** |
@@ -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, 5 ); |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | */ |
53 | 53 | function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
54 | 54 | |
55 | - if( $zone !== 'edit' ) { |
|
55 | + if ( $zone !== 'edit' ) { |
|
56 | 56 | |
57 | - $entry_default_fields['edit_link'] = array( |
|
58 | - 'label' => __('Edit Entry', 'gravityview'), |
|
57 | + $entry_default_fields[ 'edit_link' ] = array( |
|
58 | + 'label' => __( 'Edit Entry', 'gravityview' ), |
|
59 | 59 | 'type' => 'edit_link', |
60 | - 'desc' => __('A link to edit the entry. Visible based on View settings.', 'gravityview'), |
|
60 | + 'desc' => __( 'A link to edit the entry. Visible based on View settings.', 'gravityview' ), |
|
61 | 61 | ); |
62 | 62 | |
63 | 63 | } |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | $caps = $visibility_caps; |
82 | 82 | |
83 | 83 | // If we're configuring fields in the edit context, we want a limited selection |
84 | - if( $context === 'edit' ) { |
|
84 | + if ( $context === 'edit' ) { |
|
85 | 85 | |
86 | 86 | // Remove other built-in caps. |
87 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); |
|
87 | + unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] ); |
|
88 | 88 | |
89 | - $caps['read'] = _x('Entry Creator','User capability', 'gravityview'); |
|
89 | + $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | return $caps; |
@@ -104,16 +104,16 @@ discard block |
||
104 | 104 | function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
105 | 105 | |
106 | 106 | // Always a link, never a filter |
107 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
107 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] ); |
|
108 | 108 | |
109 | 109 | // Edit Entry link should only appear to visitors capable of editing entries |
110 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
110 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
111 | 111 | |
112 | - $add_option['edit_link'] = array( |
|
112 | + $add_option[ 'edit_link' ] = array( |
|
113 | 113 | 'type' => 'text', |
114 | 114 | 'label' => __( 'Edit Link Text', 'gravityview' ), |
115 | 115 | 'desc' => NULL, |
116 | - 'value' => __('Edit Entry', 'gravityview'), |
|
116 | + 'value' => __( 'Edit Entry', 'gravityview' ), |
|
117 | 117 | 'merge_tags' => true, |
118 | 118 | ); |
119 | 119 | |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | |
130 | 130 | $return = $tooltips; |
131 | 131 | |
132 | - $return['allow_edit_cap'] = array( |
|
133 | - 'title' => __('Limiting Edit Access', 'gravityview'), |
|
134 | - 'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'), |
|
132 | + $return[ 'allow_edit_cap' ] = array( |
|
133 | + 'title' => __( 'Limiting Edit Access', 'gravityview' ), |
|
134 | + 'value' => __( 'Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview' ), |
|
135 | 135 | ); |
136 | 136 | |
137 | 137 | return $return; |
@@ -149,12 +149,12 @@ discard block |
||
149 | 149 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
150 | 150 | |
151 | 151 | // We only want to modify the settings for the edit context |
152 | - if( 'edit' !== $context ) { |
|
152 | + if ( 'edit' !== $context ) { |
|
153 | 153 | |
154 | 154 | /** |
155 | 155 | * @since 1.8.4 |
156 | 156 | */ |
157 | - $field_options['new_window'] = array( |
|
157 | + $field_options[ 'new_window' ] = array( |
|
158 | 158 | 'type' => 'checkbox', |
159 | 159 | 'label' => __( 'Open link in a new tab or window?', 'gravityview' ), |
160 | 160 | 'value' => false, |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | // Entry field is only for logged in users |
167 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
167 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
168 | 168 | |
169 | 169 | $add_options = array( |
170 | 170 | 'allow_edit_cap' => array( |
@@ -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 | } |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | private function add_hooks() { |
40 | 40 | |
41 | 41 | // in case entry is edited (on admin or frontend) |
42 | - add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2); |
|
42 | + add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2 ); |
|
43 | 43 | |
44 | 44 | // when using the User opt-in field, check on entry submission |
45 | 45 | add_action( 'gform_after_submission', array( $this, 'after_submission' ), 10, 2 ); |
46 | 46 | |
47 | 47 | // process ajax approve entry requests |
48 | - add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved')); |
|
48 | + add_action( 'wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved' ) ); |
|
49 | 49 | |
50 | 50 | } |
51 | 51 | |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public static function get_entry_status( $entry, $value_or_label = 'label' ) { |
64 | 64 | |
65 | - $entry_id = is_array( $entry ) ? $entry['id'] : GVCommon::get_entry_id( $entry, true ); |
|
65 | + $entry_id = is_array( $entry ) ? $entry[ 'id' ] : GVCommon::get_entry_id( $entry, true ); |
|
66 | 66 | |
67 | 67 | $status = gform_get_meta( $entry_id, self::meta_key ); |
68 | 68 | |
69 | 69 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
70 | 70 | |
71 | - if( 'value' === $value_or_label ) { |
|
71 | + if ( 'value' === $value_or_label ) { |
|
72 | 72 | return $status; |
73 | 73 | } |
74 | 74 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $nonce = \GV\Utils::_POST( 'nonce' ); |
107 | 107 | |
108 | 108 | // Valid status |
109 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
109 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
110 | 110 | |
111 | 111 | gravityview()->log->error( 'Invalid approval status', array( 'data' => $_POST ) ); |
112 | 112 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
139 | 139 | |
140 | - $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview') ); |
|
140 | + $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview' ) ); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param $form array Gravity Forms form object |
171 | 171 | */ |
172 | 172 | public function after_submission( $entry, $form ) { |
173 | - $this->after_update_entry_update_approved_meta( $form , $entry['id'] ); |
|
173 | + $this->after_update_entry_update_approved_meta( $form, $entry[ 'id' ] ); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
186 | 186 | |
187 | - $approved_column = self::get_approved_column( $form['id'] ); |
|
187 | + $approved_column = self::get_approved_column( $form[ 'id' ] ); |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * If the form doesn't contain the approve field, don't assume anything. |
191 | 191 | */ |
192 | - if( empty( $approved_column ) ) { |
|
192 | + if ( empty( $approved_column ) ) { |
|
193 | 193 | return; |
194 | 194 | } |
195 | 195 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $value = GravityView_Entry_Approval_Status::APPROVED; |
204 | 204 | } |
205 | 205 | |
206 | - self::update_approved_meta( $entry_id, $value, $form['id'] ); |
|
206 | + self::update_approved_meta( $entry_id, $value, $form[ 'id' ] ); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -221,12 +221,12 @@ discard block |
||
221 | 221 | */ |
222 | 222 | public static function update_bulk( $entries = array(), $approved, $form_id ) { |
223 | 223 | |
224 | - if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) { |
|
224 | + if ( empty( $entries ) || ( $entries !== true && ! is_array( $entries ) ) ) { |
|
225 | 225 | gravityview()->log->error( 'Entries were empty or malformed.', array( 'data' => $entries ) ); |
226 | 226 | return NULL; |
227 | 227 | } |
228 | 228 | |
229 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
229 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
230 | 230 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
231 | 231 | return NULL; |
232 | 232 | } |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | $approved_column_id = self::get_approved_column( $form_id ); |
242 | 242 | |
243 | 243 | $success = true; |
244 | - foreach( $entries as $entry_id ) { |
|
244 | + foreach ( $entries as $entry_id ) { |
|
245 | 245 | $update_success = self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
246 | 246 | |
247 | - if( ! $update_success ) { |
|
247 | + if ( ! $update_success ) { |
|
248 | 248 | $success = false; |
249 | 249 | } |
250 | 250 | } |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | */ |
269 | 269 | public static function update_approved( $entry_id = 0, $approved = 2, $form_id = 0, $approvedcolumn = 0 ) { |
270 | 270 | |
271 | - if( !class_exists( 'GFAPI' ) ) { |
|
271 | + if ( ! class_exists( 'GFAPI' ) ) { |
|
272 | 272 | gravityview()->log->error( 'GFAPI does not exist' ); |
273 | 273 | return false; |
274 | 274 | } |
275 | 275 | |
276 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
276 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
277 | 277 | gravityview()->log->error( 'Not a valid approval value.' ); |
278 | 278 | return false; |
279 | 279 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | // If the form has an Approve/Reject field, update that value |
291 | 291 | $result = self::update_approved_column( $entry_id, $approved, $form_id, $approvedcolumn ); |
292 | 292 | |
293 | - if( is_wp_error( $result ) ) { |
|
293 | + if ( is_wp_error( $result ) ) { |
|
294 | 294 | gravityview()->log->error( 'Entry approval not updated: {error}', array( 'error' => $result->get_error_message() ) ); |
295 | 295 | return false; |
296 | 296 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | // add note to entry if approval field updating worked or there was no approved field |
304 | 304 | // There's no validation for the meta |
305 | - if( true === $result ) { |
|
305 | + if ( true === $result ) { |
|
306 | 306 | |
307 | 307 | // Add an entry note |
308 | 308 | self::add_approval_status_updated_note( $entry_id, $approved ); |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | |
356 | 356 | $note_id = false; |
357 | 357 | |
358 | - if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
358 | + if ( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
359 | 359 | |
360 | 360 | $current_user = wp_get_current_user(); |
361 | 361 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | */ |
378 | 378 | private static function update_approved_column( $entry_id = 0, $status = '0', $form_id = 0, $approvedcolumn = 0 ) { |
379 | 379 | |
380 | - if( empty( $approvedcolumn ) ) { |
|
380 | + if ( empty( $approvedcolumn ) ) { |
|
381 | 381 | $approvedcolumn = self::get_approved_column( $form_id ); |
382 | 382 | } |
383 | 383 | |
@@ -400,12 +400,12 @@ discard block |
||
400 | 400 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
401 | 401 | |
402 | 402 | $new_value = ''; |
403 | - if( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
403 | + if ( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
404 | 404 | $new_value = self::get_approved_column_input_label( $form_id, $approvedcolumn ); |
405 | 405 | } |
406 | 406 | |
407 | 407 | //update entry |
408 | - $entry["{$approvedcolumn}"] = $new_value; |
|
408 | + $entry[ "{$approvedcolumn}" ] = $new_value; |
|
409 | 409 | |
410 | 410 | /** |
411 | 411 | * Note: GFAPI::update_entry() doesn't trigger `gform_after_update_entry`, so we trigger updating the meta ourselves |
@@ -436,12 +436,12 @@ discard block |
||
436 | 436 | // If the user has enabled a different value than the label (for some reason), use it. |
437 | 437 | // This is highly unlikely |
438 | 438 | if ( is_array( $field->choices ) && ! empty( $field->choices ) ) { |
439 | - return isset( $field->choices[0]['value'] ) ? $field->choices[0]['value'] : $field->choices[0]['text']; |
|
439 | + return isset( $field->choices[ 0 ][ 'value' ] ) ? $field->choices[ 0 ][ 'value' ] : $field->choices[ 0 ][ 'text' ]; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | // Otherwise, fall back on the inputs array |
443 | 443 | if ( is_array( $field->inputs ) && ! empty( $field->inputs ) ) { |
444 | - return $field->inputs[0]['label']; |
|
444 | + return $field->inputs[ 0 ][ 'label' ]; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | return null; |
@@ -469,9 +469,9 @@ discard block |
||
469 | 469 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
470 | 470 | |
471 | 471 | // update entry meta |
472 | - if( function_exists('gform_update_meta') ) { |
|
472 | + if ( function_exists( 'gform_update_meta' ) ) { |
|
473 | 473 | |
474 | - if( GravityView_Entry_Approval_Status::is_unapproved( $status ) ) { |
|
474 | + if ( GravityView_Entry_Approval_Status::is_unapproved( $status ) ) { |
|
475 | 475 | gform_delete_meta( $entry_id, self::meta_key ); |
476 | 476 | } else { |
477 | 477 | gform_update_meta( $entry_id, self::meta_key, $status, $form_id ); |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | * @since 1.18 Added "unapproved" |
495 | 495 | * @param int $entry_id ID of the Gravity Forms entry |
496 | 496 | */ |
497 | - do_action( 'gravityview/approve_entries/' . $action , $entry_id ); |
|
497 | + do_action( 'gravityview/approve_entries/' . $action, $entry_id ); |
|
498 | 498 | |
499 | 499 | } else { |
500 | 500 | |
@@ -513,11 +513,11 @@ discard block |
||
513 | 513 | */ |
514 | 514 | static public function get_approved_column( $form ) { |
515 | 515 | |
516 | - if( empty( $form ) ) { |
|
516 | + if ( empty( $form ) ) { |
|
517 | 517 | return null; |
518 | 518 | } |
519 | 519 | |
520 | - if( !is_array( $form ) ) { |
|
520 | + if ( ! is_array( $form ) ) { |
|
521 | 521 | $form = GVCommon::get_form( $form ); |
522 | 522 | } |
523 | 523 | |
@@ -527,22 +527,22 @@ discard block |
||
527 | 527 | * @var string $key |
528 | 528 | * @var GF_Field $field |
529 | 529 | */ |
530 | - foreach( $form['fields'] as $key => $field ) { |
|
530 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
531 | 531 | |
532 | 532 | $inputs = $field->get_entry_inputs(); |
533 | 533 | |
534 | - if( !empty( $field->gravityview_approved ) ) { |
|
535 | - if ( ! empty( $inputs ) && !empty( $inputs[0]['id'] ) ) { |
|
536 | - $approved_column_id = $inputs[0]['id']; |
|
534 | + if ( ! empty( $field->gravityview_approved ) ) { |
|
535 | + if ( ! empty( $inputs ) && ! empty( $inputs[ 0 ][ 'id' ] ) ) { |
|
536 | + $approved_column_id = $inputs[ 0 ][ 'id' ]; |
|
537 | 537 | break; |
538 | 538 | } |
539 | 539 | } |
540 | 540 | |
541 | 541 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
542 | - if( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
542 | + if ( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
543 | 543 | foreach ( $inputs as $input ) { |
544 | - if ( 'approved' === strtolower( $input['label'] ) ) { |
|
545 | - $approved_column_id = $input['id']; |
|
544 | + if ( 'approved' === strtolower( $input[ 'label' ] ) ) { |
|
545 | + $approved_column_id = $input[ 'id' ]; |
|
546 | 546 | break; |
547 | 547 | } |
548 | 548 | } |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | public function get_output() { |
180 | 180 | |
181 | 181 | // No Entries |
182 | - if( empty( $this->entries ) ) { |
|
183 | - return '<div class="gv-no-results">'.$this->empty_message.'</div>'; |
|
182 | + if ( empty( $this->entries ) ) { |
|
183 | + return '<div class="gv-no-results">' . $this->empty_message . '</div>'; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | $output = ''; |
@@ -191,18 +191,18 @@ discard block |
||
191 | 191 | $current_entry = GravityView_View::getInstance()->getCurrentEntry(); |
192 | 192 | } |
193 | 193 | |
194 | - $output .= '<'. $this->wrapper_tag .'>'; |
|
194 | + $output .= '<' . $this->wrapper_tag . '>'; |
|
195 | 195 | |
196 | - foreach( $this->entries as $entry ) { |
|
196 | + foreach ( $this->entries as $entry ) { |
|
197 | 197 | |
198 | - if( $this->skip_entry( $entry, $current_entry ) ) { |
|
198 | + if ( $this->skip_entry( $entry, $current_entry ) ) { |
|
199 | 199 | continue; |
200 | 200 | } |
201 | 201 | |
202 | 202 | $output .= $this->get_item_output( $entry ); |
203 | 203 | } |
204 | 204 | |
205 | - $output .= '</'. $this->wrapper_tag .'>'; |
|
205 | + $output .= '</' . $this->wrapper_tag . '>'; |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * @filter `gravityview/widget/recent-entries/output` Modify the HTML of the Recent Entries widget output |
@@ -225,15 +225,15 @@ discard block |
||
225 | 225 | private function skip_entry( $entry, $current_entry ) { |
226 | 226 | |
227 | 227 | // If skip entry is off, or there's no current entry, return false |
228 | - if( empty( $this->skip_current_entry ) || empty( $current_entry ) ) { |
|
228 | + if ( empty( $this->skip_current_entry ) || empty( $current_entry ) ) { |
|
229 | 229 | return false; |
230 | 230 | } |
231 | 231 | |
232 | 232 | // If in Single or Edit mode, $current_entry will be an array. |
233 | - $current_entry_id = is_array( $current_entry ) ? $current_entry['id'] : $current_entry; |
|
233 | + $current_entry_id = is_array( $current_entry ) ? $current_entry[ 'id' ] : $current_entry; |
|
234 | 234 | |
235 | 235 | // If the entry ID matches the current entry, yes: skip |
236 | - if( $entry['id'] === $current_entry_id ) { |
|
236 | + if ( $entry[ 'id' ] === $current_entry_id ) { |
|
237 | 237 | return true; |
238 | 238 | } |
239 | 239 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | |
261 | 261 | $item_output = gravityview_get_link( $link, $this->link_format ); |
262 | 262 | |
263 | - if( !empty( $this->after_link ) ) { |
|
263 | + if ( ! empty( $this->after_link ) ) { |
|
264 | 264 | |
265 | 265 | /** |
266 | 266 | * @filter `gravityview/entry-list/after-link` Modify the content displayed after the entry link in an entry list |
@@ -269,14 +269,14 @@ discard block |
||
269 | 269 | * @param array $entry Gravity Forms entry array |
270 | 270 | * @param GravityView_Entry_List $this The current class instance |
271 | 271 | */ |
272 | - $after_link = apply_filters( 'gravityview/entry-list/after-link', '<div>'.$this->after_link.'</div>', $entry, $this ); |
|
272 | + $after_link = apply_filters( 'gravityview/entry-list/after-link', '<div>' . $this->after_link . '</div>', $entry, $this ); |
|
273 | 273 | |
274 | 274 | $item_output .= $after_link; |
275 | 275 | } |
276 | 276 | |
277 | 277 | $item_output = GravityView_API::replace_variables( $item_output, $this->form, $entry ); |
278 | 278 | |
279 | - $item_output = '<'. $this->item_tag .'>'. $item_output .'</'. $this->item_tag .'>'; |
|
279 | + $item_output = '<' . $this->item_tag . '>' . $item_output . '</' . $this->item_tag . '>'; |
|
280 | 280 | |
281 | 281 | /** |
282 | 282 | * @filter `gravityview/entry-list/item` Modify each item's output in an entry list |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | private function __construct() {} |
86 | 86 | |
87 | 87 | private function initialize() { |
88 | - add_action( 'wp', array( $this, 'parse_content'), 11 ); |
|
88 | + add_action( 'wp', array( $this, 'parse_content' ), 11 ); |
|
89 | 89 | add_filter( 'parse_query', array( $this, 'parse_query_fix_frontpage' ), 10 ); |
90 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 ); |
|
90 | + add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 ); |
|
91 | 91 | |
92 | 92 | // Enqueue scripts and styles after GravityView_Template::register_styles() |
93 | 93 | add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 ); |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | |
237 | 237 | $this->context_view_id = $view_id; |
238 | 238 | |
239 | - } elseif ( isset( $_GET['gvid'] ) && $multiple_views ) { |
|
239 | + } elseif ( isset( $_GET[ 'gvid' ] ) && $multiple_views ) { |
|
240 | 240 | /** |
241 | 241 | * used on a has_multiple_views context |
242 | 242 | * @see GravityView_API::entry_link |
243 | 243 | */ |
244 | - $this->context_view_id = $_GET['gvid']; |
|
244 | + $this->context_view_id = $_GET[ 'gvid' ]; |
|
245 | 245 | |
246 | 246 | } elseif ( ! $multiple_views ) { |
247 | 247 | $array_keys = array_keys( $this->getGvOutputData()->get_views() ); |
@@ -278,25 +278,25 @@ discard block |
||
278 | 278 | global $wp_rewrite; |
279 | 279 | |
280 | 280 | $is_front_page = ( $query->is_home || $query->is_page ); |
281 | - $show_on_front = ( 'page' === get_option('show_on_front') ); |
|
282 | - $front_page_id = get_option('page_on_front'); |
|
281 | + $show_on_front = ( 'page' === get_option( 'show_on_front' ) ); |
|
282 | + $front_page_id = get_option( 'page_on_front' ); |
|
283 | 283 | |
284 | - if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
284 | + if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
285 | 285 | |
286 | 286 | // Force to be an array, potentially a query string ( entry=16 ) |
287 | 287 | $_query = wp_parse_args( $query->query ); |
288 | 288 | |
289 | 289 | // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. |
290 | - if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { |
|
291 | - unset( $_query['pagename'] ); |
|
290 | + if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) { |
|
291 | + unset( $_query[ 'pagename' ] ); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | // this is where will break from core wordpress |
295 | 295 | /** @internal Don't use this filter; it will be unnecessary soon - it's just a patch for specific use case */ |
296 | 296 | $ignore = apply_filters( 'gravityview/internal/ignored_endpoints', array( 'preview', 'page', 'paged', 'cpage' ), $query ); |
297 | 297 | $endpoints = rgobj( $wp_rewrite, 'endpoints' ); |
298 | - foreach ( (array) $endpoints as $endpoint ) { |
|
299 | - $ignore[] = $endpoint[1]; |
|
298 | + foreach ( (array)$endpoints as $endpoint ) { |
|
299 | + $ignore[ ] = $endpoint[ 1 ]; |
|
300 | 300 | } |
301 | 301 | unset( $endpoints ); |
302 | 302 | |
@@ -306,21 +306,21 @@ discard block |
||
306 | 306 | // - The query includes keys that are associated with registered endpoints. `entry`, for example. |
307 | 307 | if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) { |
308 | 308 | |
309 | - $qv =& $query->query_vars; |
|
309 | + $qv = & $query->query_vars; |
|
310 | 310 | |
311 | 311 | // Prevent redirect when on the single entry endpoint |
312 | - if( self::is_single_entry() ) { |
|
312 | + if ( self::is_single_entry() ) { |
|
313 | 313 | add_filter( 'redirect_canonical', '__return_false' ); |
314 | 314 | } |
315 | 315 | |
316 | 316 | $query->is_page = true; |
317 | 317 | $query->is_home = false; |
318 | - $qv['page_id'] = $front_page_id; |
|
318 | + $qv[ 'page_id' ] = $front_page_id; |
|
319 | 319 | |
320 | 320 | // Correct <!--nextpage--> for page_on_front |
321 | - if ( ! empty( $qv['paged'] ) ) { |
|
322 | - $qv['page'] = $qv['paged']; |
|
323 | - unset( $qv['paged'] ); |
|
321 | + if ( ! empty( $qv[ 'paged' ] ) ) { |
|
322 | + $qv[ 'page' ] = $qv[ 'paged' ]; |
|
323 | + unset( $qv[ 'paged' ] ); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | |
351 | 351 | $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' ); |
352 | 352 | |
353 | - $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null ); |
|
353 | + $post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null ); |
|
354 | 354 | $this->setPostId( $post_id ); |
355 | 355 | $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false; |
356 | 356 | $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) ); |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | |
387 | 387 | $search_method = GravityView_Widget_Search::getInstance()->get_search_method(); |
388 | 388 | |
389 | - if( 'post' === $search_method ) { |
|
389 | + if ( 'post' === $search_method ) { |
|
390 | 390 | $get = $_POST; |
391 | 391 | } else { |
392 | 392 | $get = $_GET; |
@@ -443,20 +443,20 @@ discard block |
||
443 | 443 | * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop |
444 | 444 | * @param array $entry Current entry |
445 | 445 | */ |
446 | - $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry ); |
|
446 | + $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry ); |
|
447 | 447 | |
448 | 448 | if ( ! $apply_outside_loop ) { |
449 | 449 | return $title; |
450 | 450 | } |
451 | 451 | |
452 | 452 | // User reported WooCommerce doesn't pass two args. |
453 | - if ( empty( $passed_post_id ) ) { |
|
453 | + if ( empty( $passed_post_id ) ) { |
|
454 | 454 | return $title; |
455 | 455 | } |
456 | 456 | |
457 | 457 | // Don't modify the title for anything other than the current view/post. |
458 | 458 | // This is true for embedded shortcodes and Views. |
459 | - if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { |
|
459 | + if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) { |
|
460 | 460 | return $title; |
461 | 461 | } |
462 | 462 | |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | $view_meta = $this->getGvOutputData()->get_view( $context_view_id ); |
469 | 469 | } else { |
470 | 470 | foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { |
471 | - if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) { |
|
471 | + if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) { |
|
472 | 472 | $view_meta = $view_data; |
473 | 473 | break; |
474 | 474 | } |
@@ -476,12 +476,12 @@ discard block |
||
476 | 476 | } |
477 | 477 | |
478 | 478 | /** Deprecated stuff in the future. See the branch above. */ |
479 | - if ( ! empty( $view_meta['atts']['single_title'] ) ) { |
|
479 | + if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) { |
|
480 | 480 | |
481 | - $title = $view_meta['atts']['single_title']; |
|
481 | + $title = $view_meta[ 'atts' ][ 'single_title' ]; |
|
482 | 482 | |
483 | 483 | // We are allowing HTML in the fields, so no escaping the output |
484 | - $title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry ); |
|
484 | + $title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry ); |
|
485 | 485 | |
486 | 486 | $title = do_shortcode( $title ); |
487 | 487 | } |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | |
553 | 553 | $context = GravityView_View::getInstance()->getContext(); |
554 | 554 | |
555 | - switch( $context ) { |
|
555 | + switch ( $context ) { |
|
556 | 556 | case 'directory': |
557 | 557 | $tab = __( 'Multiple Entries', 'gravityview' ); |
558 | 558 | break; |
@@ -566,12 +566,12 @@ discard block |
||
566 | 566 | } |
567 | 567 | |
568 | 568 | |
569 | - $title = sprintf( esc_html_x('The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
569 | + $title = sprintf( esc_html_x( 'The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
570 | 570 | $edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $view_id, $context ) ); |
571 | - $action_text = sprintf( esc_html__('Add fields to %s', 'gravityview' ), $tab ); |
|
571 | + $action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab ); |
|
572 | 572 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
573 | 573 | |
574 | - $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url(plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
574 | + $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
575 | 575 | $output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message ); |
576 | 576 | |
577 | 577 | echo GVCommon::generate_notice( $output . $image, 'gv-error error', 'edit_gravityview', $view_id ); |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | $direct_access = apply_filters( 'gravityview_direct_access', true, $view->ID ); |
620 | 620 | $embed_only = $view->settings->get( 'embed_only' ); |
621 | 621 | |
622 | - if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
622 | + if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
623 | 623 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
624 | 624 | } |
625 | 625 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | $datetime_format = 'Y-m-d H:i:s'; |
667 | 667 | $search_is_outside_view_bounds = false; |
668 | 668 | |
669 | - if( ! empty( $search_criteria[ $key ] ) ) { |
|
669 | + if ( ! empty( $search_criteria[ $key ] ) ) { |
|
670 | 670 | |
671 | 671 | $search_date = strtotime( $search_criteria[ $key ] ); |
672 | 672 | |
@@ -694,14 +694,14 @@ discard block |
||
694 | 694 | if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { |
695 | 695 | |
696 | 696 | // Then we override the search and re-set the start date |
697 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true ); |
|
697 | + $return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true ); |
|
698 | 698 | } |
699 | 699 | } |
700 | 700 | } |
701 | 701 | |
702 | - if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { |
|
702 | + if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) { |
|
703 | 703 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue. |
704 | - if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { |
|
704 | + if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) { |
|
705 | 705 | gravityview()->log->error( 'Invalid search: the start date is after the end date.', array( 'data' => $return_search_criteria ) ); |
706 | 706 | } |
707 | 707 | } |
@@ -720,19 +720,19 @@ discard block |
||
720 | 720 | public static function process_search_only_approved( $args, $search_criteria ) { |
721 | 721 | |
722 | 722 | /** @since 1.19 */ |
723 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
723 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
724 | 724 | gravityview()->log->debug( 'User can moderate entries; showing all approval statuses' ); |
725 | 725 | return $search_criteria; |
726 | 726 | } |
727 | 727 | |
728 | - if ( ! empty( $args['show_only_approved'] ) ) { |
|
728 | + if ( ! empty( $args[ 'show_only_approved' ] ) ) { |
|
729 | 729 | |
730 | - $search_criteria['field_filters'][] = array( |
|
730 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
731 | 731 | 'key' => GravityView_Entry_Approval::meta_key, |
732 | 732 | 'value' => GravityView_Entry_Approval_Status::APPROVED |
733 | 733 | ); |
734 | 734 | |
735 | - $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met |
|
735 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met |
|
736 | 736 | |
737 | 737 | gravityview()->log->debug( '[process_search_only_approved] Search Criteria if show only approved: ', array( 'data' => $search_criteria ) ); |
738 | 738 | } |
@@ -759,18 +759,18 @@ discard block |
||
759 | 759 | */ |
760 | 760 | public static function is_entry_approved( $entry, $args = array() ) { |
761 | 761 | |
762 | - if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { |
|
762 | + if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) { |
|
763 | 763 | // is implicitly approved if entry is null or View settings doesn't require to check for approval |
764 | 764 | return true; |
765 | 765 | } |
766 | 766 | |
767 | 767 | /** @since 1.19 */ |
768 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
768 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
769 | 769 | gravityview()->log->debug( 'User can moderate entries, so entry is approved for viewing' ); |
770 | 770 | return true; |
771 | 771 | } |
772 | 772 | |
773 | - $is_approved = gform_get_meta( $entry['id'], GravityView_Entry_Approval::meta_key ); |
|
773 | + $is_approved = gform_get_meta( $entry[ 'id' ], GravityView_Entry_Approval::meta_key ); |
|
774 | 774 | |
775 | 775 | return GravityView_Entry_Approval_Status::is_approved( $is_approved ); |
776 | 776 | } |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | * Compatibility with filters hooking in `gravityview_search_criteria` instead of `gravityview_fe_search_criteria`. |
795 | 795 | */ |
796 | 796 | $criteria = apply_filters( 'gravityview_search_criteria', array(), array( $form_id ), \GV\Utils::get( $args, 'id' ) ); |
797 | - $search_criteria = isset( $criteria['search_criteria'] ) ? $criteria['search_criteria'] : array( 'field_filters' => array() ); |
|
797 | + $search_criteria = isset( $criteria[ 'search_criteria' ] ) ? $criteria[ 'search_criteria' ] : array( 'field_filters' => array() ); |
|
798 | 798 | |
799 | 799 | /** |
800 | 800 | * @filter `gravityview_fe_search_criteria` Modify the search criteria |
@@ -810,29 +810,29 @@ discard block |
||
810 | 810 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', array( 'data' =>$search_criteria ) ); |
811 | 811 | |
812 | 812 | // implicity search |
813 | - if ( ! empty( $args['search_value'] ) ) { |
|
813 | + if ( ! empty( $args[ 'search_value' ] ) ) { |
|
814 | 814 | |
815 | 815 | // Search operator options. Options: `is` or `contains` |
816 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains'; |
|
816 | + $operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains'; |
|
817 | 817 | |
818 | - $search_criteria['field_filters'][] = array( |
|
818 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
819 | 819 | 'key' => \GV\Utils::_GET( 'search_field', \GV\Utils::get( $args, 'search_field' ) ), // The field ID to search |
820 | - 'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes. |
|
820 | + 'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes. |
|
821 | 821 | 'operator' => $operator, |
822 | 822 | ); |
823 | 823 | |
824 | 824 | // Lock search mode to "all" with implicit presearch filter. |
825 | - $search_criteria['field_filters']['mode'] = 'all'; |
|
825 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; |
|
826 | 826 | } |
827 | 827 | |
828 | - if( $search_criteria !== $original_search_criteria ) { |
|
828 | + if ( $search_criteria !== $original_search_criteria ) { |
|
829 | 829 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after implicity search: ', array( 'data' => $search_criteria ) ); |
830 | 830 | } |
831 | 831 | |
832 | 832 | // Handle setting date range |
833 | 833 | $search_criteria = self::process_search_dates( $args, $search_criteria ); |
834 | 834 | |
835 | - if( $search_criteria !== $original_search_criteria ) { |
|
835 | + if ( $search_criteria !== $original_search_criteria ) { |
|
836 | 836 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after date params: ', array( 'data' => $search_criteria ) ); |
837 | 837 | } |
838 | 838 | |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | * @filter `gravityview_status` Modify entry status requirements to be included in search results. |
844 | 844 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash` |
845 | 845 | */ |
846 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args ); |
|
846 | + $search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args ); |
|
847 | 847 | |
848 | 848 | return $search_criteria; |
849 | 849 | } |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | 'search_criteria' => $search_criteria, |
957 | 957 | 'sorting' => self::updateViewSorting( $args, $form_id ), |
958 | 958 | 'paging' => $paging, |
959 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true, |
|
959 | + 'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true, |
|
960 | 960 | ); |
961 | 961 | |
962 | 962 | /** |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. |
982 | 982 | * @param array $args View configuration args. |
983 | 983 | */ |
984 | - $parameters = apply_filters( 'gravityview_get_entries_'.\GV\Utils::get( $args, 'id' ), $parameters, $args, $form_id ); |
|
984 | + $parameters = apply_filters( 'gravityview_get_entries_' . \GV\Utils::get( $args, 'id' ), $parameters, $args, $form_id ); |
|
985 | 985 | |
986 | 986 | gravityview()->log->debug( '$parameters passed to gravityview_get_entries(): ', array( 'data' => $parameters ) ); |
987 | 987 | |
@@ -1006,17 +1006,17 @@ discard block |
||
1006 | 1006 | $default_page_size = apply_filters( 'gravityview_default_page_size', 25 ); |
1007 | 1007 | |
1008 | 1008 | // Paging & offset |
1009 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : $default_page_size; |
|
1009 | + $page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : $default_page_size; |
|
1010 | 1010 | |
1011 | 1011 | if ( -1 === $page_size ) { |
1012 | 1012 | $page_size = PHP_INT_MAX; |
1013 | 1013 | } |
1014 | 1014 | |
1015 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
1015 | + $curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] ); |
|
1016 | 1016 | $offset = ( $curr_page - 1 ) * $page_size; |
1017 | 1017 | |
1018 | - if ( ! empty( $args['offset'] ) ) { |
|
1019 | - $offset += intval( $args['offset'] ); |
|
1018 | + if ( ! empty( $args[ 'offset' ] ) ) { |
|
1019 | + $offset += intval( $args[ 'offset' ] ); |
|
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | $paging = array( |
@@ -1040,8 +1040,8 @@ discard block |
||
1040 | 1040 | */ |
1041 | 1041 | public static function updateViewSorting( $args, $form_id ) { |
1042 | 1042 | $sorting = array(); |
1043 | - $sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : \GV\Utils::get( $args, 'sort_field' ); |
|
1044 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : \GV\Utils::get( $args, 'sort_direction' ); |
|
1043 | + $sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : \GV\Utils::get( $args, 'sort_field' ); |
|
1044 | + $sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : \GV\Utils::get( $args, 'sort_direction' ); |
|
1045 | 1045 | |
1046 | 1046 | $sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id ); |
1047 | 1047 | |
@@ -1058,12 +1058,12 @@ discard block |
||
1058 | 1058 | $form = GFAPI::get_form( $form_id ); |
1059 | 1059 | |
1060 | 1060 | // Get the first GF_Field field ID, set as the key for entry randomization |
1061 | - if( ! empty( $form['fields'] ) ) { |
|
1061 | + if ( ! empty( $form[ 'fields' ] ) ) { |
|
1062 | 1062 | |
1063 | 1063 | /** @var GF_Field $field */ |
1064 | - foreach ( $form['fields'] as $field ) { |
|
1064 | + foreach ( $form[ 'fields' ] as $field ) { |
|
1065 | 1065 | |
1066 | - if( ! is_a( $field, 'GF_Field' ) ) { |
|
1066 | + if ( ! is_a( $field, 'GF_Field' ) ) { |
|
1067 | 1067 | continue; |
1068 | 1068 | } |
1069 | 1069 | |
@@ -1106,11 +1106,11 @@ discard block |
||
1106 | 1106 | |
1107 | 1107 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
1108 | 1108 | |
1109 | - if( ! $sort_field ) { |
|
1109 | + if ( ! $sort_field ) { |
|
1110 | 1110 | return $sort_field_id; |
1111 | 1111 | } |
1112 | 1112 | |
1113 | - switch ( $sort_field['type'] ) { |
|
1113 | + switch ( $sort_field[ 'type' ] ) { |
|
1114 | 1114 | |
1115 | 1115 | case 'address': |
1116 | 1116 | // Sorting by full address |
@@ -1127,7 +1127,7 @@ discard block |
||
1127 | 1127 | */ |
1128 | 1128 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
1129 | 1129 | |
1130 | - switch( strtolower( $address_part ) ){ |
|
1130 | + switch ( strtolower( $address_part ) ) { |
|
1131 | 1131 | case 'street': |
1132 | 1132 | $sort_field_id .= '.1'; |
1133 | 1133 | break; |
@@ -1207,7 +1207,7 @@ discard block |
||
1207 | 1207 | */ |
1208 | 1208 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
1209 | 1209 | |
1210 | - if ( empty( $single_entry ) ){ |
|
1210 | + if ( empty( $single_entry ) ) { |
|
1211 | 1211 | return false; |
1212 | 1212 | } else { |
1213 | 1213 | return $single_entry; |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | $views = $this->getGvOutputData()->get_views(); |
1230 | 1230 | |
1231 | 1231 | foreach ( $views as $view_id => $data ) { |
1232 | - $view = \GV\View::by_id( $data['id'] ); |
|
1232 | + $view = \GV\View::by_id( $data[ 'id' ] ); |
|
1233 | 1233 | $view_id = $view->ID; |
1234 | 1234 | $template_id = gravityview_get_template_id( $view->ID ); |
1235 | 1235 | $data = $view->as_data(); |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | * Don't enqueue the scripts or styles if it's not going to be displayed. |
1239 | 1239 | * @since 1.15 |
1240 | 1240 | */ |
1241 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1241 | + if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1242 | 1242 | continue; |
1243 | 1243 | } |
1244 | 1244 | |
@@ -1255,13 +1255,13 @@ discard block |
||
1255 | 1255 | * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox` |
1256 | 1256 | * @param string $script_slug If you want to use a different lightbox script, return the name of it here. |
1257 | 1257 | */ |
1258 | - $js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1258 | + $js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1259 | 1259 | |
1260 | 1260 | /** |
1261 | 1261 | * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox` |
1262 | 1262 | * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here. |
1263 | 1263 | */ |
1264 | - $css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1264 | + $css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | /** |
@@ -1269,19 +1269,19 @@ discard block |
||
1269 | 1269 | * @see https://github.com/katzwebservices/GravityView/issues/536 |
1270 | 1270 | * @since 1.15 |
1271 | 1271 | */ |
1272 | - if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { |
|
1273 | - $css_dependencies[] = 'dashicons'; |
|
1272 | + if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) { |
|
1273 | + $css_dependencies[ ] = 'dashicons'; |
|
1274 | 1274 | } |
1275 | 1275 | |
1276 | 1276 | wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
1277 | 1277 | |
1278 | 1278 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
1279 | 1279 | |
1280 | - wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true ); |
|
1280 | + wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ), GravityView_Plugin::version, true ); |
|
1281 | 1281 | |
1282 | 1282 | wp_enqueue_script( 'gravityview-fe-view' ); |
1283 | 1283 | |
1284 | - if ( ! empty( $data['atts']['sort_columns'] ) ) { |
|
1284 | + if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) { |
|
1285 | 1285 | wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
1286 | 1286 | } |
1287 | 1287 | |
@@ -1344,7 +1344,7 @@ discard block |
||
1344 | 1344 | public static function add_style( $template_id ) { |
1345 | 1345 | |
1346 | 1346 | if ( ! empty( $template_id ) && wp_style_is( 'gravityview_style_' . $template_id, 'registered' ) ) { |
1347 | - gravityview()->log->debug( 'Adding extra template style for {template_id}', array( 'template_id' => $template_id ) ); |
|
1347 | + gravityview()->log->debug( 'Adding extra template style for {template_id}', array( 'template_id' => $template_id ) ); |
|
1348 | 1348 | wp_enqueue_style( 'gravityview_style_' . $template_id ); |
1349 | 1349 | } elseif ( empty( $template_id ) ) { |
1350 | 1350 | gravityview()->log->error( 'Cannot add template style; template_id is empty' ); |
@@ -1375,11 +1375,11 @@ discard block |
||
1375 | 1375 | * Not a table-based template; don't add sort icons |
1376 | 1376 | * @since 1.12 |
1377 | 1377 | */ |
1378 | - if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1378 | + if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1379 | 1379 | return $label; |
1380 | 1380 | } |
1381 | 1381 | |
1382 | - if ( ! $this->is_field_sortable( $field['id'], $form ) ) { |
|
1382 | + if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) { |
|
1383 | 1383 | return $label; |
1384 | 1384 | } |
1385 | 1385 | |
@@ -1387,29 +1387,29 @@ discard block |
||
1387 | 1387 | |
1388 | 1388 | $class = 'gv-sort'; |
1389 | 1389 | |
1390 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] ); |
|
1390 | + $sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] ); |
|
1391 | 1391 | |
1392 | 1392 | $sort_args = array( |
1393 | - 'sort' => $field['id'], |
|
1393 | + 'sort' => $field[ 'id' ], |
|
1394 | 1394 | 'dir' => 'asc', |
1395 | 1395 | ); |
1396 | 1396 | |
1397 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
1397 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
1398 | 1398 | //toggle sorting direction. |
1399 | - if ( 'asc' === $sorting['direction'] ) { |
|
1400 | - $sort_args['dir'] = 'desc'; |
|
1399 | + if ( 'asc' === $sorting[ 'direction' ] ) { |
|
1400 | + $sort_args[ 'dir' ] = 'desc'; |
|
1401 | 1401 | $class .= ' gv-icon-sort-desc'; |
1402 | 1402 | } else { |
1403 | - $sort_args['dir'] = 'asc'; |
|
1403 | + $sort_args[ 'dir' ] = 'asc'; |
|
1404 | 1404 | $class .= ' gv-icon-sort-asc'; |
1405 | 1405 | } |
1406 | 1406 | } else { |
1407 | 1407 | $class .= ' gv-icon-caret-up-down'; |
1408 | 1408 | } |
1409 | 1409 | |
1410 | - $url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); |
|
1410 | + $url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) ); |
|
1411 | 1411 | |
1412 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label; |
|
1412 | + return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a> ' . $label; |
|
1413 | 1413 | |
1414 | 1414 | } |
1415 | 1415 | |
@@ -1427,7 +1427,7 @@ discard block |
||
1427 | 1427 | |
1428 | 1428 | $field_type = $field_id; |
1429 | 1429 | |
1430 | - if( is_numeric( $field_id ) ) { |
|
1430 | + if ( is_numeric( $field_id ) ) { |
|
1431 | 1431 | $field = GFFormsModel::get_field( $form, $field_id ); |
1432 | 1432 | $field_type = $field->type; |
1433 | 1433 | } |
@@ -1450,7 +1450,7 @@ discard block |
||
1450 | 1450 | return false; |
1451 | 1451 | } |
1452 | 1452 | |
1453 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1453 | + return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1454 | 1454 | |
1455 | 1455 | } |
1456 | 1456 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | function __construct( ) { |
14 | 14 | |
15 | - $name = __('GravityView Recent Entries', 'gravityview'); |
|
15 | + $name = __( 'GravityView Recent Entries', 'gravityview' ); |
|
16 | 16 | |
17 | 17 | $widget_options = array( |
18 | 18 | 'description' => __( 'Display the most recent entries for a View', 'gravityview' ), |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | private function initialize() { |
27 | 27 | |
28 | - add_action('admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts') ); |
|
28 | + add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
|
29 | 29 | |
30 | 30 | add_action( 'wp_ajax_gv_get_view_merge_tag_data', array( $this, 'ajax_get_view_merge_tag_data' ) ); |
31 | 31 | |
@@ -38,21 +38,21 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function ajax_get_view_merge_tag_data() { |
40 | 40 | |
41 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajax_widget' ) ) { |
|
41 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajax_widget' ) ) { |
|
42 | 42 | exit( false ); |
43 | 43 | } |
44 | 44 | |
45 | - $form_id = gravityview_get_form_id( $_POST['view_id'] ); |
|
45 | + $form_id = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
46 | 46 | |
47 | 47 | $form = RGFormsModel::get_form_meta( $form_id ); |
48 | 48 | |
49 | 49 | $output = array( |
50 | 50 | 'form' => array( |
51 | - 'id' => $form['id'], |
|
52 | - 'title' => $form['title'], |
|
53 | - 'fields' => $form['fields'], |
|
51 | + 'id' => $form[ 'id' ], |
|
52 | + 'title' => $form[ 'title' ], |
|
53 | + 'fields' => $form[ 'fields' ], |
|
54 | 54 | ), |
55 | - 'mergeTags' => GFCommon::get_merge_tags( $form['fields'], '', false ), |
|
55 | + 'mergeTags' => GFCommon::get_merge_tags( $form[ 'fields' ], '', false ), |
|
56 | 56 | ); |
57 | 57 | |
58 | 58 | echo json_encode( $output ); |
@@ -68,17 +68,17 @@ discard block |
||
68 | 68 | function admin_enqueue_scripts() { |
69 | 69 | global $pagenow; |
70 | 70 | |
71 | - if( $pagenow === 'widgets.php' ) { |
|
71 | + if ( $pagenow === 'widgets.php' ) { |
|
72 | 72 | |
73 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
73 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
74 | 74 | |
75 | - wp_enqueue_script( 'gravityview_widgets', plugins_url('assets/js/admin-widgets'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery', 'gform_gravityforms' ), GravityView_Plugin::version ); |
|
75 | + wp_enqueue_script( 'gravityview_widgets', plugins_url( 'assets/js/admin-widgets' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery', 'gform_gravityforms' ), GravityView_Plugin::version ); |
|
76 | 76 | |
77 | 77 | wp_localize_script( 'gravityview_widgets', 'GVWidgets', array( |
78 | 78 | 'nonce' => wp_create_nonce( 'gravityview_ajax_widget' ) |
79 | - )); |
|
79 | + ) ); |
|
80 | 80 | |
81 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url('assets/css/admin-views.css', GRAVITYVIEW_FILE), array('dashicons' ), GravityView_Plugin::version ); |
|
81 | + wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons' ), GravityView_Plugin::version ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | } |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | function widget( $args, $instance ) { |
94 | 94 | |
95 | 95 | // Don't have the Customizer render too soon. |
96 | - if( empty( $instance['view_id'] ) ) { |
|
96 | + if ( empty( $instance[ 'view_id' ] ) ) { |
|
97 | 97 | return; |
98 | 98 | } |
99 | 99 | |
100 | - $args['id'] = ( isset( $args['id'] ) ) ? $args['id'] : 'gv_recent_entries'; |
|
101 | - $instance['title'] = ( isset( $instance['title'] ) ) ? $instance['title'] : ''; |
|
100 | + $args[ 'id' ] = ( isset( $args[ 'id' ] ) ) ? $args[ 'id' ] : 'gv_recent_entries'; |
|
101 | + $instance[ 'title' ] = ( isset( $instance[ 'title' ] ) ) ? $instance[ 'title' ] : ''; |
|
102 | 102 | |
103 | - $title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $args['id'] ); |
|
103 | + $title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $args[ 'id' ] ); |
|
104 | 104 | |
105 | - echo $args['before_widget']; |
|
105 | + echo $args[ 'before_widget' ]; |
|
106 | 106 | |
107 | - if ( !empty( $title ) ) { |
|
108 | - echo $args['before_title'] . $title . $args['after_title']; |
|
107 | + if ( ! empty( $title ) ) { |
|
108 | + echo $args[ 'before_title' ] . $title . $args[ 'after_title' ]; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | do_action( 'gravityview/widget/recent-entries/after_widget', $args, $instance ); |
127 | 127 | |
128 | - echo $args['after_widget']; |
|
128 | + echo $args[ 'after_widget' ]; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | private function get_output( $instance ) { |
141 | 141 | |
142 | - $form_id = gravityview_get_form_id( $instance['view_id'] ); |
|
142 | + $form_id = gravityview_get_form_id( $instance[ 'view_id' ] ); |
|
143 | 143 | |
144 | 144 | $form = gravityview_get_form( $form_id ); |
145 | 145 | |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | * @since 1.6.1 |
150 | 150 | * @var int $entry_link_post_id The ID to use as the parent post for the entry |
151 | 151 | */ |
152 | - $entry_link_post_id = ( empty( $instance['error_post_id'] ) && !empty( $instance['post_id'] ) ) ? $instance['post_id'] : $instance['view_id']; |
|
152 | + $entry_link_post_id = ( empty( $instance[ 'error_post_id' ] ) && ! empty( $instance[ 'post_id' ] ) ) ? $instance[ 'post_id' ] : $instance[ 'view_id' ]; |
|
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Generate list output |
156 | 156 | * @since 1.7.2 |
157 | 157 | */ |
158 | - $List = new GravityView_Entry_List( $entries, $entry_link_post_id, $form, $instance['link_format'], $instance['after_link'], 'recent-entries-widget' ); |
|
158 | + $List = new GravityView_Entry_List( $entries, $entry_link_post_id, $form, $instance[ 'link_format' ], $instance[ 'after_link' ], 'recent-entries-widget' ); |
|
159 | 159 | |
160 | 160 | $output = $List->get_output(); |
161 | 161 | |
@@ -180,30 +180,30 @@ discard block |
||
180 | 180 | private function get_entries( $instance, $form_id ) { |
181 | 181 | |
182 | 182 | // Get the settings for the View ID |
183 | - $view_settings = gravityview_get_template_settings( $instance['view_id'] ); |
|
183 | + $view_settings = gravityview_get_template_settings( $instance[ 'view_id' ] ); |
|
184 | 184 | |
185 | 185 | // Set the context view ID to avoid conflicts with the Advanced Filter extension. |
186 | - $criteria['context_view_id'] = $instance['view_id']; |
|
186 | + $criteria[ 'context_view_id' ] = $instance[ 'view_id' ]; |
|
187 | 187 | |
188 | - $instance['limit'] = isset( $instance['limit'] ) ? $instance['limit'] : 10; |
|
189 | - $view_settings['id'] = $instance['view_id']; |
|
190 | - $view_settings['page_size'] = $instance['limit']; |
|
188 | + $instance[ 'limit' ] = isset( $instance[ 'limit' ] ) ? $instance[ 'limit' ] : 10; |
|
189 | + $view_settings[ 'id' ] = $instance[ 'view_id' ]; |
|
190 | + $view_settings[ 'page_size' ] = $instance[ 'limit' ]; |
|
191 | 191 | |
192 | 192 | // Prepare paging criteria |
193 | - $criteria['paging'] = array( |
|
193 | + $criteria[ 'paging' ] = array( |
|
194 | 194 | 'offset' => 0, |
195 | - 'page_size' => $instance['limit'] |
|
195 | + 'page_size' => $instance[ 'limit' ] |
|
196 | 196 | ); |
197 | 197 | |
198 | 198 | // Prepare Search Criteria |
199 | - $criteria['search_criteria'] = array( 'field_filters' => array() ); |
|
200 | - $criteria['search_criteria'] = GravityView_frontend::process_search_only_approved( $view_settings, $criteria['search_criteria']); |
|
201 | - $criteria['search_criteria']['status'] = apply_filters( 'gravityview_status', 'active', $view_settings ); |
|
199 | + $criteria[ 'search_criteria' ] = array( 'field_filters' => array() ); |
|
200 | + $criteria[ 'search_criteria' ] = GravityView_frontend::process_search_only_approved( $view_settings, $criteria[ 'search_criteria' ] ); |
|
201 | + $criteria[ 'search_criteria' ][ 'status' ] = apply_filters( 'gravityview_status', 'active', $view_settings ); |
|
202 | 202 | |
203 | 203 | /** |
204 | 204 | * Modify the search parameters before the entries are fetched |
205 | 205 | */ |
206 | - $criteria = apply_filters('gravityview/widget/recent-entries/criteria', $criteria, $instance, $form_id ); |
|
206 | + $criteria = apply_filters( 'gravityview/widget/recent-entries/criteria', $criteria, $instance, $form_id ); |
|
207 | 207 | |
208 | 208 | $results = GVCommon::get_entries( $form_id, $criteria ); |
209 | 209 | |
@@ -224,23 +224,23 @@ discard block |
||
224 | 224 | $instance = $new_instance; |
225 | 225 | |
226 | 226 | // Force positive number |
227 | - $instance['limit'] = empty( $instance['limit'] ) ? 10 : absint( $instance['limit'] ); |
|
227 | + $instance[ 'limit' ] = empty( $instance[ 'limit' ] ) ? 10 : absint( $instance[ 'limit' ] ); |
|
228 | 228 | |
229 | - $instance['view_id'] = intval( $instance['view_id'] ); |
|
229 | + $instance[ 'view_id' ] = intval( $instance[ 'view_id' ] ); |
|
230 | 230 | |
231 | - $instance['link_format'] = trim( rtrim( $instance['link_format'] ) ); |
|
231 | + $instance[ 'link_format' ] = trim( rtrim( $instance[ 'link_format' ] ) ); |
|
232 | 232 | |
233 | - $instance['link_format'] = empty( $instance['link_format'] ) ? $old_instance['link_format'] : $instance['link_format']; |
|
233 | + $instance[ 'link_format' ] = empty( $instance[ 'link_format' ] ) ? $old_instance[ 'link_format' ] : $instance[ 'link_format' ]; |
|
234 | 234 | |
235 | - $instance['post_id'] = empty( $instance['post_id'] ) ? '' : intval( $instance['post_id'] ); |
|
235 | + $instance[ 'post_id' ] = empty( $instance[ 'post_id' ] ) ? '' : intval( $instance[ 'post_id' ] ); |
|
236 | 236 | |
237 | - $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance['post_id'], $instance['view_id'] ); |
|
237 | + $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance[ 'post_id' ], $instance[ 'view_id' ] ); |
|
238 | 238 | |
239 | 239 | //check if post_id is a valid post with embedded View |
240 | - $instance['error_post_id'] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
240 | + $instance[ 'error_post_id' ] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
241 | 241 | |
242 | 242 | // Share that the widget isn't brand new |
243 | - $instance['updated'] = 1; |
|
243 | + $instance[ 'updated' ] = 1; |
|
244 | 244 | |
245 | 245 | /** |
246 | 246 | * Modify the updated instance. This will allow for validating any added instance settings externally. |
@@ -262,22 +262,22 @@ discard block |
||
262 | 262 | |
263 | 263 | // Set up some default widget settings. |
264 | 264 | $defaults = array( |
265 | - 'title' => __('Recent Entries', 'gravityview'), |
|
265 | + 'title' => __( 'Recent Entries', 'gravityview' ), |
|
266 | 266 | 'view_id' => NULL, |
267 | 267 | 'post_id' => NULL, |
268 | 268 | 'limit' => 10, |
269 | - 'link_format' => __('Entry #{entry_id}', 'gravityview'), |
|
269 | + 'link_format' => __( 'Entry #{entry_id}', 'gravityview' ), |
|
270 | 270 | 'after_link' => '' |
271 | 271 | ); |
272 | 272 | |
273 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
273 | + $instance = wp_parse_args( (array)$instance, $defaults ); |
|
274 | 274 | |
275 | 275 | ?> |
276 | 276 | |
277 | 277 | <!-- Title --> |
278 | 278 | <p> |
279 | 279 | <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:', 'gravityview' ) ?></label> |
280 | - <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /> |
|
280 | + <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'title' ] ); ?>" /> |
|
281 | 281 | </p> |
282 | 282 | |
283 | 283 | <!-- Download --> |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $views = get_posts( $args ); |
291 | 291 | |
292 | 292 | // If there are no views set up yet, we get outta here. |
293 | - if( empty( $views ) ) { |
|
293 | + if ( empty( $views ) ) { |
|
294 | 294 | echo '<div id="select_gravityview_view"><div class="wrap">' . GravityView_Admin::no_views_text() . '</div></div>'; |
295 | 295 | return; |
296 | 296 | } |
@@ -302,10 +302,10 @@ discard block |
||
302 | 302 | * Display errors generated for invalid embed IDs |
303 | 303 | * @see GravityView_View_Data::is_valid_embed_id |
304 | 304 | */ |
305 | - if( isset( $instance['updated'] ) && empty( $instance['view_id'] ) ) { |
|
305 | + if ( isset( $instance[ 'updated' ] ) && empty( $instance[ 'view_id' ] ) ) { |
|
306 | 306 | ?> |
307 | 307 | <div class="error inline hide-on-view-change"> |
308 | - <p><?php esc_html_e('Please select a View to search.', 'gravityview'); ?></p> |
|
308 | + <p><?php esc_html_e( 'Please select a View to search.', 'gravityview' ); ?></p> |
|
309 | 309 | </div> |
310 | 310 | <?php |
311 | 311 | unset ( $error ); |
@@ -313,14 +313,14 @@ discard block |
||
313 | 313 | ?> |
314 | 314 | |
315 | 315 | <p> |
316 | - <label for="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"><?php esc_html_e('Select a View', 'gravityview'); ?></label> |
|
316 | + <label for="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"><?php esc_html_e( 'Select a View', 'gravityview' ); ?></label> |
|
317 | 317 | <select class="widefat gv-recent-entries-select-view" name="<?php echo esc_attr( $this->get_field_name( 'view_id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"> |
318 | 318 | <option value=""><?php esc_html_e( '— Select a View as Entries Source —', 'gravityview' ); ?></option> |
319 | 319 | <?php |
320 | 320 | |
321 | - foreach( $views as $view ) { |
|
322 | - $title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title; |
|
323 | - echo '<option value="'. $view->ID .'"'.selected( absint( $instance['view_id'] ), $view->ID ).'>'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>'; |
|
321 | + foreach ( $views as $view ) { |
|
322 | + $title = empty( $view->post_title ) ? __( '(no title)', 'gravityview' ) : $view->post_title; |
|
323 | + echo '<option value="' . $view->ID . '"' . selected( absint( $instance[ 'view_id' ] ), $view->ID ) . '>' . esc_html( sprintf( '%s #%d', $title, $view->ID ) ) . '</option>'; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | ?> |
@@ -332,10 +332,10 @@ discard block |
||
332 | 332 | * Display errors generated for invalid embed IDs |
333 | 333 | * @see GravityView_View_Data::is_valid_embed_id |
334 | 334 | */ |
335 | - if( !empty( $instance['error_post_id'] ) ) { |
|
335 | + if ( ! empty( $instance[ 'error_post_id' ] ) ) { |
|
336 | 336 | ?> |
337 | 337 | <div class="error inline"> |
338 | - <p><?php echo $instance['error_post_id']; ?></p> |
|
338 | + <p><?php echo $instance[ 'error_post_id' ]; ?></p> |
|
339 | 339 | </div> |
340 | 340 | <?php |
341 | 341 | unset ( $error ); |
@@ -343,11 +343,11 @@ discard block |
||
343 | 343 | ?> |
344 | 344 | |
345 | 345 | <p> |
346 | - <label for="<?php echo $this->get_field_id('post_id'); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
347 | - <input class="code" size="3" id="<?php echo $this->get_field_id('post_id'); ?>" name="<?php echo $this->get_field_name('post_id'); ?>" type="text" value="<?php echo esc_attr( $instance['post_id'] ); ?>" /> |
|
346 | + <label for="<?php echo $this->get_field_id( 'post_id' ); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
347 | + <input class="code" size="3" id="<?php echo $this->get_field_id( 'post_id' ); ?>" name="<?php echo $this->get_field_name( 'post_id' ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'post_id' ] ); ?>" /> |
|
348 | 348 | <span class="howto"><?php |
349 | - esc_html_e('To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' ); |
|
350 | - echo ' '.gravityview_get_link('https://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview' ), 'target=_blank' ); |
|
349 | + esc_html_e( 'To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' ); |
|
350 | + echo ' ' . gravityview_get_link( 'https://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more…', 'gravityview' ), 'target=_blank' ); |
|
351 | 351 | ?></span> |
352 | 352 | </p> |
353 | 353 | |
@@ -355,21 +355,21 @@ discard block |
||
355 | 355 | <label for="<?php echo $this->get_field_id( 'limit' ); ?>"> |
356 | 356 | <span><?php _e( 'Number of entries to show:', 'gravityview' ); ?></span> |
357 | 357 | </label> |
358 | - <input class="code" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" value="<?php echo intval( $instance['limit'] ); ?>" size="3" /> |
|
358 | + <input class="code" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" value="<?php echo intval( $instance[ 'limit' ] ); ?>" size="3" /> |
|
359 | 359 | </p> |
360 | 360 | |
361 | 361 | <p> |
362 | 362 | <label for="<?php echo $this->get_field_id( 'link_format' ); ?>"> |
363 | 363 | <span><?php _e( 'Entry link text (required)', 'gravityview' ); ?></span> |
364 | 364 | </label> |
365 | - <input id="<?php echo $this->get_field_id( 'link_format' ); ?>" name="<?php echo $this->get_field_name( 'link_format' ); ?>" type="text" value="<?php echo esc_attr( $instance['link_format'] ); ?>" class="widefat merge-tag-support mt-position-right mt-hide_all_fields" /> |
|
365 | + <input id="<?php echo $this->get_field_id( 'link_format' ); ?>" name="<?php echo $this->get_field_name( 'link_format' ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'link_format' ] ); ?>" class="widefat merge-tag-support mt-position-right mt-hide_all_fields" /> |
|
366 | 366 | </p> |
367 | 367 | |
368 | 368 | <p> |
369 | 369 | <label for="<?php echo $this->get_field_id( 'after_link' ); ?>"> |
370 | 370 | <span><?php _e( 'Text or HTML to display after the link (optional)', 'gravityview' ); ?></span> |
371 | 371 | </label> |
372 | - <textarea id="<?php echo $this->get_field_id( 'after_link' ); ?>" name="<?php echo $this->get_field_name( 'after_link' ); ?>" rows="5" class="widefat code merge-tag-support mt-position-right mt-hide_all_fields"><?php echo esc_textarea( $instance['after_link'] ); ?></textarea> |
|
372 | + <textarea id="<?php echo $this->get_field_id( 'after_link' ); ?>" name="<?php echo $this->get_field_name( 'after_link' ); ?>" rows="5" class="widefat code merge-tag-support mt-position-right mt-hide_all_fields"><?php echo esc_textarea( $instance[ 'after_link' ] ); ?></textarea> |
|
373 | 373 | </p> |
374 | 374 | |
375 | 375 | <?php |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | * @param GravityView_Recent_Entries_Widget $this WP_Widget object |
380 | 380 | * @param array $instance Current widget instance |
381 | 381 | */ |
382 | - do_action( 'gravityview_recent_entries_widget_form' , $this, $instance ); |
|
382 | + do_action( 'gravityview_recent_entries_widget_form', $this, $instance ); |
|
383 | 383 | |
384 | 384 | ?> |
385 | 385 |