@@ -18,80 +18,80 @@ discard block |
||
18 | 18 | |
19 | 19 | class GravityView_Edit_Entry { |
20 | 20 | |
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | 24 | static $file; |
25 | 25 | |
26 | 26 | static $instance; |
27 | 27 | |
28 | - /** |
|
29 | - * Component instances. |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - public $instances = array(); |
|
28 | + /** |
|
29 | + * Component instances. |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + public $instances = array(); |
|
33 | 33 | |
34 | 34 | |
35 | 35 | function __construct() { |
36 | 36 | |
37 | - self::$file = plugin_dir_path( __FILE__ ); |
|
37 | + self::$file = plugin_dir_path( __FILE__ ); |
|
38 | 38 | |
39 | - if( is_admin() ) { |
|
40 | - $this->load_components( 'admin' ); |
|
41 | - } |
|
39 | + if( is_admin() ) { |
|
40 | + $this->load_components( 'admin' ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - $this->load_components( 'render' ); |
|
44 | + $this->load_components( 'render' ); |
|
45 | 45 | |
46 | - // If GF User Registration Add-on exists |
|
47 | - $this->load_components( 'user-registration' ); |
|
46 | + // If GF User Registration Add-on exists |
|
47 | + $this->load_components( 'user-registration' ); |
|
48 | 48 | |
49 | - $this->add_hooks(); |
|
49 | + $this->add_hooks(); |
|
50 | 50 | |
51 | 51 | // Process hooks for addons that may or may not be present |
52 | 52 | $this->addon_specific_hooks(); |
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | - static function getInstance() { |
|
56 | + static function getInstance() { |
|
57 | 57 | |
58 | - if( empty( self::$instance ) ) { |
|
59 | - self::$instance = new GravityView_Edit_Entry; |
|
60 | - } |
|
58 | + if( empty( self::$instance ) ) { |
|
59 | + self::$instance = new GravityView_Edit_Entry; |
|
60 | + } |
|
61 | 61 | |
62 | - return self::$instance; |
|
63 | - } |
|
62 | + return self::$instance; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - private function load_components( $component ) { |
|
66 | + private function load_components( $component ) { |
|
67 | 67 | |
68 | - $dir = trailingslashit( self::$file ); |
|
68 | + $dir = trailingslashit( self::$file ); |
|
69 | 69 | |
70 | - $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
71 | - $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
70 | + $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
71 | + $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
72 | 72 | |
73 | - // Loads component and pass extension's instance so that component can |
|
74 | - // talk each other. |
|
75 | - require_once $filename; |
|
76 | - $this->instances[ $component ] = new $classname( $this ); |
|
77 | - $this->instances[ $component ]->load(); |
|
73 | + // Loads component and pass extension's instance so that component can |
|
74 | + // talk each other. |
|
75 | + require_once $filename; |
|
76 | + $this->instances[ $component ] = new $classname( $this ); |
|
77 | + $this->instances[ $component ]->load(); |
|
78 | 78 | |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | - private function add_hooks() { |
|
81 | + private function add_hooks() { |
|
82 | 82 | |
83 | - // Add front-end access to Gravity Forms delete file action |
|
84 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
83 | + // Add front-end access to Gravity Forms delete file action |
|
84 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
85 | 85 | |
86 | - // Make sure this hook is run for non-admins |
|
87 | - add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
86 | + // Make sure this hook is run for non-admins |
|
87 | + add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
88 | 88 | |
89 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
89 | + add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
90 | 90 | |
91 | - // add template path to check for field |
|
92 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
91 | + // add template path to check for field |
|
92 | + add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
93 | 93 | |
94 | - } |
|
94 | + } |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Trigger hooks that are normally run in the admin for Addons, but need to be triggered manually because we're not in the admin |
@@ -105,77 +105,77 @@ discard block |
||
105 | 105 | |
106 | 106 | } |
107 | 107 | |
108 | - /** |
|
109 | - * Include this extension templates path |
|
110 | - * @param array $file_paths List of template paths ordered |
|
111 | - */ |
|
112 | - public function add_template_path( $file_paths ) { |
|
113 | - |
|
114 | - // Index 100 is the default GravityView template path. |
|
115 | - $file_paths[ 110 ] = self::$file; |
|
116 | - |
|
117 | - return $file_paths; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * |
|
122 | - * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
123 | - * |
|
124 | - * @param $view_id int GravityView view id |
|
125 | - * @param $form_id int Gravity Forms form id |
|
126 | - * @param $entry_id int Gravity Forms entry id |
|
127 | - * @return string |
|
128 | - */ |
|
129 | - public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
130 | - return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * The edit entry link creates a secure link with a nonce |
|
136 | - * |
|
137 | - * It also mimics the URL structure Gravity Forms expects to have so that |
|
138 | - * it formats the display of the edit form like it does in the backend, like |
|
139 | - * "You can edit this post from the post page" fields, for example. |
|
140 | - * |
|
141 | - * @param $entry array Gravity Forms entry object |
|
142 | - * @param $view_id int GravityView view id |
|
143 | - * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
144 | - * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
148 | - |
|
149 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
150 | - |
|
151 | - $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
152 | - |
|
153 | - $url = add_query_arg( array( |
|
154 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
155 | - ), $base ); |
|
156 | - |
|
157 | - if( $post_id ) { |
|
158 | - $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * Allow passing params to dynamically populate entry with values |
|
163 | - * @since 1.9.2 |
|
164 | - */ |
|
165 | - if( !empty( $field_values ) ) { |
|
166 | - |
|
167 | - if( is_array( $field_values ) ) { |
|
168 | - // If already an array, no parse_str() needed |
|
169 | - $params = $field_values; |
|
170 | - } else { |
|
171 | - parse_str( $field_values, $params ); |
|
172 | - } |
|
173 | - |
|
174 | - $url = add_query_arg( $params, $url ); |
|
175 | - } |
|
176 | - |
|
177 | - return $url; |
|
178 | - } |
|
108 | + /** |
|
109 | + * Include this extension templates path |
|
110 | + * @param array $file_paths List of template paths ordered |
|
111 | + */ |
|
112 | + public function add_template_path( $file_paths ) { |
|
113 | + |
|
114 | + // Index 100 is the default GravityView template path. |
|
115 | + $file_paths[ 110 ] = self::$file; |
|
116 | + |
|
117 | + return $file_paths; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * |
|
122 | + * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
123 | + * |
|
124 | + * @param $view_id int GravityView view id |
|
125 | + * @param $form_id int Gravity Forms form id |
|
126 | + * @param $entry_id int Gravity Forms entry id |
|
127 | + * @return string |
|
128 | + */ |
|
129 | + public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
130 | + return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * The edit entry link creates a secure link with a nonce |
|
136 | + * |
|
137 | + * It also mimics the URL structure Gravity Forms expects to have so that |
|
138 | + * it formats the display of the edit form like it does in the backend, like |
|
139 | + * "You can edit this post from the post page" fields, for example. |
|
140 | + * |
|
141 | + * @param $entry array Gravity Forms entry object |
|
142 | + * @param $view_id int GravityView view id |
|
143 | + * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
144 | + * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
148 | + |
|
149 | + $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
150 | + |
|
151 | + $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
152 | + |
|
153 | + $url = add_query_arg( array( |
|
154 | + 'edit' => wp_create_nonce( $nonce_key ) |
|
155 | + ), $base ); |
|
156 | + |
|
157 | + if( $post_id ) { |
|
158 | + $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * Allow passing params to dynamically populate entry with values |
|
163 | + * @since 1.9.2 |
|
164 | + */ |
|
165 | + if( !empty( $field_values ) ) { |
|
166 | + |
|
167 | + if( is_array( $field_values ) ) { |
|
168 | + // If already an array, no parse_str() needed |
|
169 | + $params = $field_values; |
|
170 | + } else { |
|
171 | + parse_str( $field_values, $params ); |
|
172 | + } |
|
173 | + |
|
174 | + $url = add_query_arg( $params, $url ); |
|
175 | + } |
|
176 | + |
|
177 | + return $url; |
|
178 | + } |
|
179 | 179 | |
180 | 180 | /** |
181 | 181 | * Edit mode doesn't allow certain field types. |
@@ -229,82 +229,82 @@ discard block |
||
229 | 229 | } |
230 | 230 | |
231 | 231 | |
232 | - /** |
|
233 | - * checks if user has permissions to edit a specific entry |
|
234 | - * |
|
235 | - * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
236 | - * |
|
237 | - * @param array $entry Gravity Forms entry array |
|
238 | - * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
239 | - * @return bool |
|
240 | - */ |
|
241 | - public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
232 | + /** |
|
233 | + * checks if user has permissions to edit a specific entry |
|
234 | + * |
|
235 | + * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
236 | + * |
|
237 | + * @param array $entry Gravity Forms entry array |
|
238 | + * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
239 | + * @return bool |
|
240 | + */ |
|
241 | + public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
242 | 242 | |
243 | - // No permission by default |
|
244 | - $user_can_edit = false; |
|
243 | + // No permission by default |
|
244 | + $user_can_edit = false; |
|
245 | 245 | |
246 | - // If they can edit any entries (as defined in Gravity Forms) |
|
247 | - // Or if they can edit other people's entries |
|
248 | - // Then we're good. |
|
249 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
246 | + // If they can edit any entries (as defined in Gravity Forms) |
|
247 | + // Or if they can edit other people's entries |
|
248 | + // Then we're good. |
|
249 | + if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
250 | 250 | |
251 | - gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
251 | + gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
252 | 252 | |
253 | - $user_can_edit = true; |
|
253 | + $user_can_edit = true; |
|
254 | 254 | |
255 | - } else if( !isset( $entry['created_by'] ) ) { |
|
255 | + } else if( !isset( $entry['created_by'] ) ) { |
|
256 | 256 | |
257 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
257 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
258 | 258 | |
259 | - $user_can_edit = false; |
|
259 | + $user_can_edit = false; |
|
260 | 260 | |
261 | - } else { |
|
261 | + } else { |
|
262 | 262 | |
263 | - // get user_edit setting |
|
264 | - if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
265 | - // if View ID not specified or is the current view |
|
263 | + // get user_edit setting |
|
264 | + if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
265 | + // if View ID not specified or is the current view |
|
266 | 266 | // @deprecated path |
267 | - $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
268 | - } else { |
|
269 | - // in case is specified and not the current view |
|
270 | - $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
271 | - } |
|
267 | + $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
268 | + } else { |
|
269 | + // in case is specified and not the current view |
|
270 | + $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
271 | + } |
|
272 | 272 | |
273 | - $current_user = wp_get_current_user(); |
|
273 | + $current_user = wp_get_current_user(); |
|
274 | 274 | |
275 | - // User edit is disabled |
|
276 | - if( empty( $user_edit ) ) { |
|
275 | + // User edit is disabled |
|
276 | + if( empty( $user_edit ) ) { |
|
277 | 277 | |
278 | - gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
278 | + gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
279 | 279 | |
280 | - $user_can_edit = false; |
|
281 | - } |
|
280 | + $user_can_edit = false; |
|
281 | + } |
|
282 | 282 | |
283 | - // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
284 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
283 | + // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
284 | + else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
285 | 285 | |
286 | - gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
286 | + gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
287 | 287 | |
288 | - $user_can_edit = true; |
|
288 | + $user_can_edit = true; |
|
289 | 289 | |
290 | - } else if( ! is_user_logged_in() ) { |
|
290 | + } else if( ! is_user_logged_in() ) { |
|
291 | 291 | |
292 | - gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
293 | - } |
|
292 | + gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
293 | + } |
|
294 | 294 | |
295 | - } |
|
295 | + } |
|
296 | 296 | |
297 | - /** |
|
298 | - * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
299 | - * @since 1.15 Added `$entry` and `$view_id` parameters |
|
300 | - * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
301 | - * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
302 | - * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
303 | - */ |
|
304 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
297 | + /** |
|
298 | + * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
299 | + * @since 1.15 Added `$entry` and `$view_id` parameters |
|
300 | + * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
301 | + * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
302 | + * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
303 | + */ |
|
304 | + $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
305 | 305 | |
306 | - return (bool)$user_can_edit; |
|
307 | - } |
|
306 | + return (bool)$user_can_edit; |
|
307 | + } |
|
308 | 308 | |
309 | 309 | |
310 | 310 |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | public function prevent_maybe_process_form() { |
161 | 161 | |
162 | 162 | if( ! empty( $_POST ) ) { |
163 | - gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
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 | 166 | if( $this->is_edit_entry_submission() ) { |
167 | 167 | remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
168 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
168 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -197,8 +197,8 @@ 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(); |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | |
320 | 320 | GFFormsModel::save_lead( $form, $this->entry ); |
321 | 321 | |
322 | - // Delete the values for hidden inputs |
|
323 | - $this->unset_hidden_field_values(); |
|
322 | + // Delete the values for hidden inputs |
|
323 | + $this->unset_hidden_field_values(); |
|
324 | 324 | |
325 | 325 | $this->entry['date_created'] = $date_created; |
326 | 326 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | // Perform actions normally performed after updating a lead |
331 | 331 | $this->after_update(); |
332 | 332 | |
333 | - /** |
|
333 | + /** |
|
334 | 334 | * Must be AFTER after_update()! |
335 | 335 | * @see https://github.com/gravityview/GravityView/issues/764 |
336 | 336 | */ |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @return void |
361 | 361 | */ |
362 | 362 | private function unset_hidden_field_values() { |
363 | - global $wpdb; |
|
363 | + global $wpdb; |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -382,27 +382,27 @@ discard block |
||
382 | 382 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
383 | 383 | } |
384 | 384 | |
385 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
385 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
386 | 386 | |
387 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
387 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
388 | 388 | |
389 | - // Reset fields that are hidden |
|
390 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
391 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
389 | + // Reset fields that are hidden |
|
390 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
391 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
392 | 392 | |
393 | - // List fields are stored as empty arrays when empty |
|
394 | - $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
393 | + // List fields are stored as empty arrays when empty |
|
394 | + $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
395 | 395 | |
396 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
396 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
397 | 397 | |
398 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
398 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
399 | 399 | |
400 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
400 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
401 | 401 | // after submission |
402 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
403 | - $_POST[ $post_input_id ] = ''; |
|
404 | - } |
|
405 | - } |
|
402 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
403 | + $_POST[ $post_input_id ] = ''; |
|
404 | + } |
|
405 | + } |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | |
497 | 497 | $form = $this->form; |
498 | 498 | |
499 | - /** @var GF_Field $field */ |
|
499 | + /** @var GF_Field $field */ |
|
500 | 500 | foreach( $form['fields'] as $k => &$field ) { |
501 | 501 | |
502 | 502 | /** |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | |
513 | 513 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
514 | 514 | foreach( $field->inputs as $key => $input ) { |
515 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
515 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | } |
@@ -533,13 +533,13 @@ discard block |
||
533 | 533 | foreach ( $this->fields_with_calculation as $calc_field ) { |
534 | 534 | $inputs = $calc_field->get_entry_inputs(); |
535 | 535 | if ( is_array( $inputs ) ) { |
536 | - foreach ( $inputs as $input ) { |
|
537 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
538 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
539 | - } |
|
536 | + foreach ( $inputs as $input ) { |
|
537 | + $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
538 | + $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
539 | + } |
|
540 | 540 | } else { |
541 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
542 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
541 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
542 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
543 | 543 | } |
544 | 544 | } |
545 | 545 | |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
588 | 588 | |
589 | 589 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
590 | - $ary = stripslashes_deep( $ary ); |
|
590 | + $ary = stripslashes_deep( $ary ); |
|
591 | 591 | $img_url = \GV\Utils::get( $ary, 0 ); |
592 | 592 | |
593 | 593 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | private function maybe_update_post_fields( $form ) { |
661 | 661 | |
662 | 662 | if( empty( $this->entry['post_id'] ) ) { |
663 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
663 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
664 | 664 | return; |
665 | 665 | } |
666 | 666 | |
@@ -695,51 +695,51 @@ discard block |
||
695 | 695 | |
696 | 696 | switch( $field->type ) { |
697 | 697 | |
698 | - case 'post_title': |
|
699 | - $post_title = $value; |
|
700 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
701 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
702 | - } |
|
703 | - $updated_post->post_title = $post_title; |
|
704 | - $updated_post->post_name = $post_title; |
|
705 | - unset( $post_title ); |
|
706 | - break; |
|
707 | - |
|
708 | - case 'post_content': |
|
709 | - $post_content = $value; |
|
710 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
711 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
712 | - } |
|
713 | - $updated_post->post_content = $post_content; |
|
714 | - unset( $post_content ); |
|
715 | - break; |
|
716 | - case 'post_excerpt': |
|
717 | - $updated_post->post_excerpt = $value; |
|
718 | - break; |
|
719 | - case 'post_tags': |
|
720 | - wp_set_post_tags( $post_id, $value, false ); |
|
721 | - break; |
|
722 | - case 'post_category': |
|
723 | - break; |
|
724 | - case 'post_custom_field': |
|
698 | + case 'post_title': |
|
699 | + $post_title = $value; |
|
700 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
701 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
702 | + } |
|
703 | + $updated_post->post_title = $post_title; |
|
704 | + $updated_post->post_name = $post_title; |
|
705 | + unset( $post_title ); |
|
706 | + break; |
|
707 | + |
|
708 | + case 'post_content': |
|
709 | + $post_content = $value; |
|
710 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
711 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
712 | + } |
|
713 | + $updated_post->post_content = $post_content; |
|
714 | + unset( $post_content ); |
|
715 | + break; |
|
716 | + case 'post_excerpt': |
|
717 | + $updated_post->post_excerpt = $value; |
|
718 | + break; |
|
719 | + case 'post_tags': |
|
720 | + wp_set_post_tags( $post_id, $value, false ); |
|
721 | + break; |
|
722 | + case 'post_category': |
|
723 | + break; |
|
724 | + case 'post_custom_field': |
|
725 | 725 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
726 | 726 | $value = $value[ $field_id ]; |
727 | 727 | } |
728 | 728 | |
729 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
730 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
731 | - } |
|
729 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
730 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
731 | + } |
|
732 | 732 | |
733 | - if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
734 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
735 | - } |
|
733 | + if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
734 | + $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
735 | + } |
|
736 | 736 | |
737 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
738 | - break; |
|
737 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
738 | + break; |
|
739 | 739 | |
740 | - case 'post_image': |
|
741 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
742 | - break; |
|
740 | + case 'post_image': |
|
741 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
742 | + break; |
|
743 | 743 | |
744 | 744 | } |
745 | 745 | |
@@ -784,20 +784,20 @@ discard block |
||
784 | 784 | */ |
785 | 785 | private function is_field_json_encoded( $field ) { |
786 | 786 | |
787 | - $json_encoded = false; |
|
787 | + $json_encoded = false; |
|
788 | 788 | |
789 | 789 | $input_type = RGFormsModel::get_input_type( $field ); |
790 | 790 | |
791 | - // Only certain custom field types are supported |
|
792 | - switch( $input_type ) { |
|
793 | - case 'fileupload': |
|
794 | - case 'list': |
|
795 | - case 'multiselect': |
|
796 | - $json_encoded = true; |
|
797 | - break; |
|
798 | - } |
|
791 | + // Only certain custom field types are supported |
|
792 | + switch( $input_type ) { |
|
793 | + case 'fileupload': |
|
794 | + case 'list': |
|
795 | + case 'multiselect': |
|
796 | + $json_encoded = true; |
|
797 | + break; |
|
798 | + } |
|
799 | 799 | |
800 | - return $json_encoded; |
|
800 | + return $json_encoded; |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | /** |
@@ -887,14 +887,14 @@ discard block |
||
887 | 887 | ?><h2 class="gv-edit-entry-title"> |
888 | 888 | <span><?php |
889 | 889 | |
890 | - /** |
|
891 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
892 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
893 | - * @param GravityView_Edit_Entry_Render $this This object |
|
894 | - */ |
|
895 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
890 | + /** |
|
891 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
892 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
893 | + * @param GravityView_Edit_Entry_Render $this This object |
|
894 | + */ |
|
895 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
896 | 896 | |
897 | - echo esc_attr( $edit_entry_title ); |
|
897 | + echo esc_attr( $edit_entry_title ); |
|
898 | 898 | ?></span> |
899 | 899 | </h2> |
900 | 900 | |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | |
1004 | 1004 | ob_get_clean(); |
1005 | 1005 | |
1006 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1006 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1007 | 1007 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1008 | 1008 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
1009 | 1009 | remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 ); |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | |
1058 | 1058 | // for now we don't support Save and Continue feature. |
1059 | 1059 | if( ! self::$supports_save_and_continue ) { |
1060 | - unset( $form['save'] ); |
|
1060 | + unset( $form['save'] ); |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | return $form; |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | || ! empty( $field_content ) |
1133 | 1133 | || in_array( $field->type, array( 'honeypot' ) ) |
1134 | 1134 | ) { |
1135 | - return $field_content; |
|
1135 | + return $field_content; |
|
1136 | 1136 | } |
1137 | 1137 | |
1138 | 1138 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1140,24 +1140,24 @@ discard block |
||
1140 | 1140 | |
1141 | 1141 | $field_value = $this->get_field_value( $field ); |
1142 | 1142 | |
1143 | - // Prevent any PHP warnings, like undefined index |
|
1144 | - ob_start(); |
|
1143 | + // Prevent any PHP warnings, like undefined index |
|
1144 | + ob_start(); |
|
1145 | 1145 | |
1146 | - $return = null; |
|
1146 | + $return = null; |
|
1147 | 1147 | |
1148 | 1148 | /** @var GravityView_Field $gv_field */ |
1149 | 1149 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1150 | 1150 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1151 | 1151 | } else { |
1152 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1153 | - } |
|
1152 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1153 | + } |
|
1154 | 1154 | |
1155 | - // If there was output, it's an error |
|
1156 | - $warnings = ob_get_clean(); |
|
1155 | + // If there was output, it's an error |
|
1156 | + $warnings = ob_get_clean(); |
|
1157 | 1157 | |
1158 | - if( !empty( $warnings ) ) { |
|
1159 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1160 | - } |
|
1158 | + if( !empty( $warnings ) ) { |
|
1159 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1160 | + } |
|
1161 | 1161 | |
1162 | 1162 | return $return; |
1163 | 1163 | } |
@@ -1192,8 +1192,8 @@ discard block |
||
1192 | 1192 | $input_id = strval( $input['id'] ); |
1193 | 1193 | |
1194 | 1194 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1195 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1196 | - $allow_pre_populated = false; |
|
1195 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1196 | + $allow_pre_populated = false; |
|
1197 | 1197 | } |
1198 | 1198 | |
1199 | 1199 | } |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1218 | 1218 | $categories = array(); |
1219 | 1219 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1220 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1220 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1221 | 1221 | } |
1222 | 1222 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1223 | 1223 | } |
@@ -1227,25 +1227,25 @@ discard block |
||
1227 | 1227 | // if value is empty get the default value if defined |
1228 | 1228 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1229 | 1229 | |
1230 | - /** |
|
1231 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1232 | - * @since 1.11 |
|
1233 | - * @since 1.20 Added third param |
|
1234 | - * @param mixed $field_value field value used to populate the input |
|
1235 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1236 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1237 | - */ |
|
1238 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1239 | - |
|
1240 | - /** |
|
1241 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1242 | - * @since 1.17 |
|
1243 | - * @since 1.20 Added third param |
|
1244 | - * @param mixed $field_value field value used to populate the input |
|
1245 | - * @param GF_Field $field Gravity Forms field object |
|
1246 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1247 | - */ |
|
1248 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1230 | + /** |
|
1231 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1232 | + * @since 1.11 |
|
1233 | + * @since 1.20 Added third param |
|
1234 | + * @param mixed $field_value field value used to populate the input |
|
1235 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1236 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1237 | + */ |
|
1238 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1239 | + |
|
1240 | + /** |
|
1241 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1242 | + * @since 1.17 |
|
1243 | + * @since 1.20 Added third param |
|
1244 | + * @param mixed $field_value field value used to populate the input |
|
1245 | + * @param GF_Field $field Gravity Forms field object |
|
1246 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1247 | + */ |
|
1248 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1249 | 1249 | |
1250 | 1250 | return $field_value; |
1251 | 1251 | } |
@@ -1272,7 +1272,7 @@ discard block |
||
1272 | 1272 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1273 | 1273 | // expects certain field array items to be set. |
1274 | 1274 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1275 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1275 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1276 | 1276 | } |
1277 | 1277 | |
1278 | 1278 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1286,61 +1286,61 @@ discard block |
||
1286 | 1286 | */ |
1287 | 1287 | case 'fileupload': |
1288 | 1288 | |
1289 | - // Set the previous value |
|
1290 | - $entry = $this->get_entry(); |
|
1289 | + // Set the previous value |
|
1290 | + $entry = $this->get_entry(); |
|
1291 | 1291 | |
1292 | - $input_name = 'input_'.$field->id; |
|
1293 | - $form_id = $form['id']; |
|
1292 | + $input_name = 'input_'.$field->id; |
|
1293 | + $form_id = $form['id']; |
|
1294 | 1294 | |
1295 | - $value = NULL; |
|
1295 | + $value = NULL; |
|
1296 | 1296 | |
1297 | - // Use the previous entry value as the default. |
|
1298 | - if( isset( $entry[ $field->id ] ) ) { |
|
1299 | - $value = $entry[ $field->id ]; |
|
1300 | - } |
|
1297 | + // Use the previous entry value as the default. |
|
1298 | + if( isset( $entry[ $field->id ] ) ) { |
|
1299 | + $value = $entry[ $field->id ]; |
|
1300 | + } |
|
1301 | 1301 | |
1302 | - // If this is a single upload file |
|
1303 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1304 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1305 | - $value = $file_path['url']; |
|
1302 | + // If this is a single upload file |
|
1303 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1304 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1305 | + $value = $file_path['url']; |
|
1306 | 1306 | |
1307 | - } else { |
|
1307 | + } else { |
|
1308 | 1308 | |
1309 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1310 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1311 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1309 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1310 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1311 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1312 | 1312 | |
1313 | - } |
|
1313 | + } |
|
1314 | 1314 | |
1315 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1315 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1316 | 1316 | |
1317 | - // If there are fresh uploads, process and merge them. |
|
1318 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1319 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1320 | - $value = empty( $value ) ? '[]' : $value; |
|
1321 | - $value = stripslashes_deep( $value ); |
|
1322 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1323 | - } |
|
1317 | + // If there are fresh uploads, process and merge them. |
|
1318 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1319 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1320 | + $value = empty( $value ) ? '[]' : $value; |
|
1321 | + $value = stripslashes_deep( $value ); |
|
1322 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1323 | + } |
|
1324 | 1324 | |
1325 | - } else { |
|
1325 | + } else { |
|
1326 | 1326 | |
1327 | - // A file already exists when editing an entry |
|
1328 | - // We set this to solve issue when file upload fields are required. |
|
1329 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1327 | + // A file already exists when editing an entry |
|
1328 | + // We set this to solve issue when file upload fields are required. |
|
1329 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1330 | 1330 | |
1331 | - } |
|
1331 | + } |
|
1332 | 1332 | |
1333 | - $this->entry[ $input_name ] = $value; |
|
1334 | - $_POST[ $input_name ] = $value; |
|
1333 | + $this->entry[ $input_name ] = $value; |
|
1334 | + $_POST[ $input_name ] = $value; |
|
1335 | 1335 | |
1336 | - break; |
|
1336 | + break; |
|
1337 | 1337 | |
1338 | 1338 | case 'number': |
1339 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1340 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1341 | - $_POST['input_'.$field->id ] = NULL; |
|
1342 | - } |
|
1343 | - break; |
|
1339 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1340 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1341 | + $_POST['input_'.$field->id ] = NULL; |
|
1342 | + } |
|
1343 | + break; |
|
1344 | 1344 | } |
1345 | 1345 | |
1346 | 1346 | } |
@@ -1425,42 +1425,42 @@ discard block |
||
1425 | 1425 | case 'fileupload' : |
1426 | 1426 | case 'post_image': |
1427 | 1427 | |
1428 | - // in case nothing is uploaded but there are already files saved |
|
1429 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1430 | - $field->failed_validation = false; |
|
1431 | - unset( $field->validation_message ); |
|
1432 | - } |
|
1428 | + // in case nothing is uploaded but there are already files saved |
|
1429 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1430 | + $field->failed_validation = false; |
|
1431 | + unset( $field->validation_message ); |
|
1432 | + } |
|
1433 | 1433 | |
1434 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1435 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1434 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1435 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1436 | 1436 | |
1437 | - $input_name = 'input_' . $field->id; |
|
1438 | - //uploaded |
|
1439 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1437 | + $input_name = 'input_' . $field->id; |
|
1438 | + //uploaded |
|
1439 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1440 | 1440 | |
1441 | - //existent |
|
1442 | - $entry = $this->get_entry(); |
|
1443 | - $value = NULL; |
|
1444 | - if( isset( $entry[ $field->id ] ) ) { |
|
1445 | - $value = json_decode( $entry[ $field->id ], true ); |
|
1446 | - } |
|
1441 | + //existent |
|
1442 | + $entry = $this->get_entry(); |
|
1443 | + $value = NULL; |
|
1444 | + if( isset( $entry[ $field->id ] ) ) { |
|
1445 | + $value = json_decode( $entry[ $field->id ], true ); |
|
1446 | + } |
|
1447 | 1447 | |
1448 | - // count uploaded files and existent entry files |
|
1449 | - $count_files = count( $file_names ) + count( $value ); |
|
1448 | + // count uploaded files and existent entry files |
|
1449 | + $count_files = count( $file_names ) + count( $value ); |
|
1450 | 1450 | |
1451 | - if( $count_files > $field->maxFiles ) { |
|
1452 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1453 | - $field->failed_validation = 1; |
|
1454 | - $gv_valid = false; |
|
1451 | + if( $count_files > $field->maxFiles ) { |
|
1452 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1453 | + $field->failed_validation = 1; |
|
1454 | + $gv_valid = false; |
|
1455 | 1455 | |
1456 | - // in case of error make sure the newest upload files are removed from the upload input |
|
1457 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1458 | - } |
|
1456 | + // in case of error make sure the newest upload files are removed from the upload input |
|
1457 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1458 | + } |
|
1459 | 1459 | |
1460 | - } |
|
1460 | + } |
|
1461 | 1461 | |
1462 | 1462 | |
1463 | - break; |
|
1463 | + break; |
|
1464 | 1464 | |
1465 | 1465 | } |
1466 | 1466 | |
@@ -1471,47 +1471,47 @@ discard block |
||
1471 | 1471 | |
1472 | 1472 | switch ( $field_type ) { |
1473 | 1473 | |
1474 | - // Captchas don't need to be re-entered. |
|
1475 | - case 'captcha': |
|
1474 | + // Captchas don't need to be re-entered. |
|
1475 | + case 'captcha': |
|
1476 | 1476 | |
1477 | - // Post Image fields aren't editable, so we un-fail them. |
|
1478 | - case 'post_image': |
|
1479 | - $field->failed_validation = false; |
|
1480 | - unset( $field->validation_message ); |
|
1481 | - break; |
|
1477 | + // Post Image fields aren't editable, so we un-fail them. |
|
1478 | + case 'post_image': |
|
1479 | + $field->failed_validation = false; |
|
1480 | + unset( $field->validation_message ); |
|
1481 | + break; |
|
1482 | 1482 | |
1483 | 1483 | } |
1484 | 1484 | |
1485 | 1485 | // You can't continue inside a switch, so we do it after. |
1486 | 1486 | if( empty( $field->failed_validation ) ) { |
1487 | - continue; |
|
1487 | + continue; |
|
1488 | 1488 | } |
1489 | 1489 | |
1490 | 1490 | // checks if the No Duplicates option is not validating entry against itself, since |
1491 | 1491 | // we're editing a stored entry, it would also assume it's a duplicate. |
1492 | 1492 | if( !empty( $field->noDuplicates ) ) { |
1493 | 1493 | |
1494 | - $entry = $this->get_entry(); |
|
1494 | + $entry = $this->get_entry(); |
|
1495 | 1495 | |
1496 | - // If the value of the entry is the same as the stored value |
|
1497 | - // Then we can assume it's not a duplicate, it's the same. |
|
1498 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1499 | - //if value submitted was not changed, then don't validate |
|
1500 | - $field->failed_validation = false; |
|
1496 | + // If the value of the entry is the same as the stored value |
|
1497 | + // Then we can assume it's not a duplicate, it's the same. |
|
1498 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1499 | + //if value submitted was not changed, then don't validate |
|
1500 | + $field->failed_validation = false; |
|
1501 | 1501 | |
1502 | - unset( $field->validation_message ); |
|
1502 | + unset( $field->validation_message ); |
|
1503 | 1503 | |
1504 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1504 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1505 | 1505 | |
1506 | - continue; |
|
1507 | - } |
|
1506 | + continue; |
|
1507 | + } |
|
1508 | 1508 | } |
1509 | 1509 | |
1510 | 1510 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1511 | 1511 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1512 | - unset( $field->validation_message ); |
|
1513 | - $field->validation_message = false; |
|
1514 | - continue; |
|
1512 | + unset( $field->validation_message ); |
|
1513 | + $field->validation_message = false; |
|
1514 | + continue; |
|
1515 | 1515 | } |
1516 | 1516 | |
1517 | 1517 | $gv_valid = false; |
@@ -1575,8 +1575,8 @@ discard block |
||
1575 | 1575 | // Hide fields depending on admin settings |
1576 | 1576 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1577 | 1577 | |
1578 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1579 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1578 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1579 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1580 | 1580 | |
1581 | 1581 | /** |
1582 | 1582 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1636,11 +1636,11 @@ discard block |
||
1636 | 1636 | // The edit tab has been configured, so we loop through to configured settings |
1637 | 1637 | foreach ( $configured_fields as $configured_field ) { |
1638 | 1638 | |
1639 | - /** @var GF_Field $field */ |
|
1640 | - foreach ( $fields as $field ) { |
|
1639 | + /** @var GF_Field $field */ |
|
1640 | + foreach ( $fields as $field ) { |
|
1641 | 1641 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
1642 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1643 | - break; |
|
1642 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1643 | + break; |
|
1644 | 1644 | } |
1645 | 1645 | |
1646 | 1646 | } |
@@ -1696,28 +1696,28 @@ discard block |
||
1696 | 1696 | */ |
1697 | 1697 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
1698 | 1698 | |
1699 | - /** |
|
1699 | + /** |
|
1700 | 1700 | * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true |
1701 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1702 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1703 | - * @since 1.9.1 |
|
1704 | - * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
1705 | - * @param array $form GF Form array |
|
1706 | - * @param int $view_id View ID |
|
1707 | - */ |
|
1708 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1709 | - |
|
1710 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1701 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1702 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1703 | + * @since 1.9.1 |
|
1704 | + * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
1705 | + * @param array $form GF Form array |
|
1706 | + * @param int $view_id View ID |
|
1707 | + */ |
|
1708 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1709 | + |
|
1710 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1711 | 1711 | foreach( $fields as $k => $field ) { |
1712 | 1712 | if( $field->adminOnly ) { |
1713 | - unset( $fields[ $k ] ); |
|
1713 | + unset( $fields[ $k ] ); |
|
1714 | 1714 | } |
1715 | 1715 | } |
1716 | 1716 | return $fields; |
1717 | 1717 | } |
1718 | 1718 | |
1719 | - foreach( $fields as &$field ) { |
|
1720 | - $field->adminOnly = false; |
|
1719 | + foreach( $fields as &$field ) { |
|
1720 | + $field->adminOnly = false; |
|
1721 | 1721 | } |
1722 | 1722 | |
1723 | 1723 | return $fields; |
@@ -1750,36 +1750,36 @@ discard block |
||
1750 | 1750 | |
1751 | 1751 | if( 'checkbox' === $field->type ) { |
1752 | 1752 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1753 | - $input_id = $input['id']; |
|
1754 | - $choice = $field->choices[ $key ]; |
|
1755 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1756 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1757 | - if( $match ) { |
|
1758 | - $field->choices[ $key ]['isSelected'] = true; |
|
1759 | - } |
|
1753 | + $input_id = $input['id']; |
|
1754 | + $choice = $field->choices[ $key ]; |
|
1755 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1756 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1757 | + if( $match ) { |
|
1758 | + $field->choices[ $key ]['isSelected'] = true; |
|
1759 | + } |
|
1760 | 1760 | } |
1761 | 1761 | } else { |
1762 | 1762 | |
1763 | 1763 | // We need to run through each field to set the default values |
1764 | 1764 | foreach ( $this->entry as $field_id => $field_value ) { |
1765 | 1765 | |
1766 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1766 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1767 | 1767 | |
1768 | - if( 'list' === $field->type ) { |
|
1769 | - $list_rows = maybe_unserialize( $field_value ); |
|
1768 | + if( 'list' === $field->type ) { |
|
1769 | + $list_rows = maybe_unserialize( $field_value ); |
|
1770 | 1770 | |
1771 | - $list_field_value = array(); |
|
1772 | - foreach ( (array) $list_rows as $row ) { |
|
1773 | - foreach ( (array) $row as $column ) { |
|
1774 | - $list_field_value[] = $column; |
|
1775 | - } |
|
1776 | - } |
|
1771 | + $list_field_value = array(); |
|
1772 | + foreach ( (array) $list_rows as $row ) { |
|
1773 | + foreach ( (array) $row as $column ) { |
|
1774 | + $list_field_value[] = $column; |
|
1775 | + } |
|
1776 | + } |
|
1777 | 1777 | |
1778 | - $field->defaultValue = serialize( $list_field_value ); |
|
1779 | - } else { |
|
1780 | - $field->defaultValue = $field_value; |
|
1781 | - } |
|
1782 | - } |
|
1778 | + $field->defaultValue = serialize( $list_field_value ); |
|
1779 | + } else { |
|
1780 | + $field->defaultValue = $field_value; |
|
1781 | + } |
|
1782 | + } |
|
1783 | 1783 | } |
1784 | 1784 | } |
1785 | 1785 | } |
@@ -1836,7 +1836,7 @@ discard block |
||
1836 | 1836 | return $has_conditional_logic; |
1837 | 1837 | } |
1838 | 1838 | |
1839 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
1839 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
1840 | 1840 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
1841 | 1841 | } |
1842 | 1842 | |
@@ -1903,14 +1903,14 @@ discard block |
||
1903 | 1903 | |
1904 | 1904 | if( $echo && $error !== true ) { |
1905 | 1905 | |
1906 | - $error = esc_html( $error ); |
|
1906 | + $error = esc_html( $error ); |
|
1907 | 1907 | |
1908 | - /** |
|
1909 | - * @since 1.9 |
|
1910 | - */ |
|
1911 | - if ( ! empty( $this->entry ) ) { |
|
1912 | - $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;" ) ); |
|
1913 | - } |
|
1908 | + /** |
|
1909 | + * @since 1.9 |
|
1910 | + */ |
|
1911 | + if ( ! empty( $this->entry ) ) { |
|
1912 | + $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;" ) ); |
|
1913 | + } |
|
1914 | 1914 | |
1915 | 1915 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
1916 | 1916 | } |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | |
27 | 27 | <?php |
28 | 28 | |
29 | - do_action('gravityview_render_widgets_active_areas', $curr_template, 'footer', $post->ID ); |
|
29 | + do_action('gravityview_render_widgets_active_areas', $curr_template, 'footer', $post->ID ); |
|
30 | 30 | |
31 | - do_action('gravityview_render_field_pickers', 'directory' ); |
|
31 | + do_action('gravityview_render_field_pickers', 'directory' ); |
|
32 | 32 | |
33 | - ?> |
|
33 | + ?> |
|
34 | 34 | |
35 | 35 | <?php // list of available widgets to be shown in the popup ?> |
36 | 36 | <div id="directory-available-widgets" class="hide-if-js gv-tooltip"> |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | |
56 | 56 | <div id="single-active-fields" class="gv-grid gv-grid-pad gv-grid-border"> |
57 | 57 | <?php |
58 | - if(!empty( $curr_template ) ) { |
|
59 | - do_action('gravityview_render_directory_active_areas', $curr_template, 'single', $post->ID, true ); |
|
60 | - } |
|
61 | - ?> |
|
58 | + if(!empty( $curr_template ) ) { |
|
59 | + do_action('gravityview_render_directory_active_areas', $curr_template, 'single', $post->ID, true ); |
|
60 | + } |
|
61 | + ?> |
|
62 | 62 | </div> |
63 | 63 | <?php |
64 | - do_action('gravityview_render_field_pickers', 'single' ); |
|
64 | + do_action('gravityview_render_field_pickers', 'single' ); |
|
65 | 65 | ?> |
66 | 66 | </div> |
67 | 67 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | </div> |
81 | 81 | |
82 | 82 | <?php |
83 | - do_action('gravityview_render_field_pickers', 'edit' ); |
|
83 | + do_action('gravityview_render_field_pickers', 'edit' ); |
|
84 | 84 | ?> |
85 | 85 | |
86 | 86 | </div> |
@@ -63,28 +63,28 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | - * When on the Add/Edit View screen, suggest most popular articles related to that |
|
67 | - * |
|
66 | + * When on the Add/Edit View screen, suggest most popular articles related to that |
|
67 | + * |
|
68 | 68 | * @param array $localization_data Data to be passed to the Support Port JS |
69 | 69 | * |
70 | 70 | * @return array |
71 | 71 | */ |
72 | 72 | function suggest_support_articles( $localization_data = array() ) { |
73 | 73 | |
74 | - if( ! gravityview()->request->is_view() ) { |
|
75 | - return $localization_data; |
|
76 | - } |
|
74 | + if( ! gravityview()->request->is_view() ) { |
|
75 | + return $localization_data; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | $localization_data['suggest'] = array( |
79 | - '57ef23539033602e61d4a560', |
|
80 | - '54c67bb9e4b0512429885513', |
|
81 | - '54c67bb9e4b0512429885512', |
|
82 | - '54c67bbbe4b07997ea3f3f6b', |
|
83 | - '54d1a33ae4b086c0c0964ce9', |
|
84 | - '57ef253c9033602e61d4a563', |
|
85 | - '552355bfe4b0221aadf2572b', |
|
86 | - '54c67bcde4b051242988553e', |
|
87 | - ); |
|
79 | + '57ef23539033602e61d4a560', |
|
80 | + '54c67bb9e4b0512429885513', |
|
81 | + '54c67bb9e4b0512429885512', |
|
82 | + '54c67bbbe4b07997ea3f3f6b', |
|
83 | + '54d1a33ae4b086c0c0964ce9', |
|
84 | + '57ef253c9033602e61d4a563', |
|
85 | + '552355bfe4b0221aadf2572b', |
|
86 | + '54c67bcde4b051242988553e', |
|
87 | + ); |
|
88 | 88 | |
89 | 89 | return $localization_data; |
90 | 90 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | if( empty( $connected_views ) ) { |
170 | 170 | |
171 | - $menu_items['gravityview'] = array( |
|
171 | + $menu_items['gravityview'] = array( |
|
172 | 172 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
173 | 173 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
174 | 174 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | // If there were no items added, then let's create the parent menu |
200 | 200 | if( $sub_menu_items ) { |
201 | 201 | |
202 | - $sub_menu_items[] = array( |
|
203 | - 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
204 | - 'link_class' => 'gv-create-view', |
|
205 | - 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
206 | - 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
207 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
208 | - ); |
|
202 | + $sub_menu_items[] = array( |
|
203 | + 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
204 | + 'link_class' => 'gv-create-view', |
|
205 | + 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
206 | + 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
207 | + 'capabilities' => array( 'edit_gravityviews' ), |
|
208 | + ); |
|
209 | 209 | |
210 | 210 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
211 | 211 | $sub_menu_items[] = array( |
@@ -588,12 +588,12 @@ discard block |
||
588 | 588 | * Render html for displaying available fields based on a Form ID |
589 | 589 | * $blacklist_field_types - contains the field types which are not proper to be shown in a directory. |
590 | 590 | * |
591 | - * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
591 | + * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
592 | 592 | * @access public |
593 | - * |
|
593 | + * |
|
594 | 594 | * @param int $form Gravity Forms Form ID (default: '') |
595 | 595 | * @param string $context (default: 'single') |
596 | - * |
|
596 | + * |
|
597 | 597 | * @return void |
598 | 598 | */ |
599 | 599 | function render_available_fields( $form = 0, $context = 'single' ) { |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | |
608 | 608 | if ( ! is_array( $blacklist_field_types ) ) { |
609 | 609 | |
610 | - gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
610 | + gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
611 | 611 | |
612 | 612 | $blacklist_field_types = array(); |
613 | 613 | } |
@@ -739,12 +739,12 @@ discard block |
||
739 | 739 | /** |
740 | 740 | * @since 1.7.2 |
741 | 741 | */ |
742 | - 'other_entries' => array( |
|
743 | - 'label' => __('Other Entries', 'gravityview'), |
|
744 | - 'type' => 'other_entries', |
|
745 | - 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
746 | - ), |
|
747 | - ); |
|
742 | + 'other_entries' => array( |
|
743 | + 'label' => __('Other Entries', 'gravityview'), |
|
744 | + 'type' => 'other_entries', |
|
745 | + 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
746 | + ), |
|
747 | + ); |
|
748 | 748 | |
749 | 749 | if( 'single' !== $zone) { |
750 | 750 | |
@@ -910,9 +910,9 @@ discard block |
||
910 | 910 | |
911 | 911 | if ($form_id) { |
912 | 912 | $original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ; |
913 | - } else { |
|
913 | + } else { |
|
914 | 914 | $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
915 | - } |
|
915 | + } |
|
916 | 916 | |
917 | 917 | if( !$original_item ) { |
918 | 918 | gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array(' data' => array('available_items' => $available_items, 'field' => $field ) ) ); |
@@ -994,13 +994,13 @@ discard block |
||
994 | 994 | } |
995 | 995 | |
996 | 996 | /** |
997 | - * Renders "Add Field" tooltips |
|
998 | - * |
|
999 | - * @since 2.0.11 |
|
1000 | - * |
|
997 | + * Renders "Add Field" tooltips |
|
998 | + * |
|
999 | + * @since 2.0.11 |
|
1000 | + * |
|
1001 | 1001 | * @param string $context "directory", "single", or "edit" |
1002 | - * |
|
1003 | - * @return void |
|
1002 | + * |
|
1003 | + * @return void |
|
1004 | 1004 | */ |
1005 | 1005 | function render_field_pickers( $context = 'directory' ) { |
1006 | 1006 | |
@@ -1027,7 +1027,7 @@ discard block |
||
1027 | 1027 | </div> |
1028 | 1028 | <?php |
1029 | 1029 | } |
1030 | - } |
|
1030 | + } |
|
1031 | 1031 | |
1032 | 1032 | /** |
1033 | 1033 | * Render the Template Active Areas and configured active fields for a given template id and post id |
@@ -1099,59 +1099,59 @@ discard block |
||
1099 | 1099 | |
1100 | 1100 | // Don't process any scripts below here if it's not a GravityView page. |
1101 | 1101 | if( ! gravityview_is_admin_page( $hook, 'single' ) && ! $is_widgets_page ) { |
1102 | - return; |
|
1102 | + return; |
|
1103 | 1103 | } |
1104 | 1104 | |
1105 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1106 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version ); |
|
1107 | - |
|
1108 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
1109 | - |
|
1110 | - //enqueue scripts |
|
1111 | - wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), GravityView_Plugin::version ); |
|
1112 | - |
|
1113 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1114 | - 'cookiepath' => COOKIEPATH, |
|
1115 | - 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1116 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1117 | - 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1118 | - 'label_close' => __( 'Close', 'gravityview' ), |
|
1119 | - 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1120 | - 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1121 | - 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1122 | - 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1123 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1124 | - 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1125 | - 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1126 | - 'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ), |
|
1127 | - )); |
|
1128 | - |
|
1129 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
1130 | - |
|
1131 | - // Enqueue scripts needed for merge tags |
|
1132 | - self::enqueue_gravity_forms_scripts(); |
|
1105 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1106 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version ); |
|
1107 | + |
|
1108 | + $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
1109 | + |
|
1110 | + //enqueue scripts |
|
1111 | + wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), GravityView_Plugin::version ); |
|
1112 | + |
|
1113 | + wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1114 | + 'cookiepath' => COOKIEPATH, |
|
1115 | + 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1116 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1117 | + 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1118 | + 'label_close' => __( 'Close', 'gravityview' ), |
|
1119 | + 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1120 | + 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1121 | + 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1122 | + 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1123 | + 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1124 | + 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1125 | + 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1126 | + 'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ), |
|
1127 | + )); |
|
1128 | + |
|
1129 | + wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
1130 | + |
|
1131 | + // Enqueue scripts needed for merge tags |
|
1132 | + self::enqueue_gravity_forms_scripts(); |
|
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | /** |
1136 | 1136 | * Enqueue Gravity Forms scripts, needed for Merge Tags |
1137 | - * |
|
1138 | - * @since 1.0.5-beta |
|
1139 | - * |
|
1140 | - * @return void |
|
1137 | + * |
|
1138 | + * @since 1.0.5-beta |
|
1139 | + * |
|
1140 | + * @return void |
|
1141 | 1141 | */ |
1142 | 1142 | static function enqueue_gravity_forms_scripts() { |
1143 | 1143 | GFForms::register_scripts(); |
1144 | 1144 | |
1145 | 1145 | $scripts = array( |
1146 | - 'sack', |
|
1147 | - 'gform_gravityforms', |
|
1148 | - 'gform_forms', |
|
1149 | - 'gform_form_admin', |
|
1150 | - 'jquery-ui-autocomplete' |
|
1146 | + 'sack', |
|
1147 | + 'gform_gravityforms', |
|
1148 | + 'gform_forms', |
|
1149 | + 'gform_form_admin', |
|
1150 | + 'jquery-ui-autocomplete' |
|
1151 | 1151 | ); |
1152 | 1152 | |
1153 | 1153 | if ( wp_is_mobile() ) { |
1154 | - $scripts[] = 'jquery-touch-punch'; |
|
1154 | + $scripts[] = 'jquery-touch-punch'; |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | wp_enqueue_script( $scripts ); |