@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public static function get_duplicate_link( $entry, $view_id, $post_id = null ) { |
248 | 248 | |
249 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
249 | + $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
250 | 250 | |
251 | 251 | if ( empty( $base ) ) { |
252 | 252 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | 'action' => 'duplicate', |
258 | 258 | 'entry_id' => $entry['id'], |
259 | 259 | 'gvid' => $view_id, |
260 | - 'view_id' => $view_id, |
|
260 | + 'view_id' => $view_id, |
|
261 | 261 | ), $base ); |
262 | 262 | |
263 | 263 | return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry['id'] ) ), $actionurl ); |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @since 2.5 |
461 | 461 | * @param array $duplicated_entry The duplicated entry |
462 | 462 | * @param array $entry The original entry |
463 | - */ |
|
463 | + */ |
|
464 | 464 | do_action( 'gravityview/duplicate-entry/duplicated', $duplicated_entry, $entry ); |
465 | 465 | |
466 | 466 | gravityview()->log->debug( 'Duplicate response: {duplicate_response}', array( 'duplicate_response' => $duplicate_response ) ); |
@@ -18,82 +18,82 @@ 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 | add_filter( 'gravityview/field/is_visible', array( $this, 'maybe_not_visible' ), 10, 3 ); |
95 | 95 | |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Trigger hooks that are normally run in the admin for Addons, but need to be triggered manually because we're not in the admin |
@@ -151,74 +151,74 @@ discard block |
||
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | |
154 | - /** |
|
155 | - * Include this extension templates path |
|
156 | - * @param array $file_paths List of template paths ordered |
|
157 | - */ |
|
158 | - public function add_template_path( $file_paths ) { |
|
159 | - |
|
160 | - // Index 100 is the default GravityView template path. |
|
161 | - $file_paths[ 110 ] = self::$file; |
|
162 | - |
|
163 | - return $file_paths; |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * |
|
168 | - * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
169 | - * |
|
170 | - * @param $view_id int GravityView view id |
|
171 | - * @param $form_id int Gravity Forms form id |
|
172 | - * @param $entry_id int Gravity Forms entry id |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
176 | - return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * The edit entry link creates a secure link with a nonce |
|
182 | - * |
|
183 | - * It also mimics the URL structure Gravity Forms expects to have so that |
|
184 | - * it formats the display of the edit form like it does in the backend, like |
|
185 | - * "You can edit this post from the post page" fields, for example. |
|
186 | - * |
|
187 | - * @param $entry array Gravity Forms entry object |
|
188 | - * @param $view_id int GravityView view id |
|
189 | - * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
190 | - * @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/ } |
|
191 | - * @return string |
|
192 | - */ |
|
193 | - public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
194 | - |
|
195 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
196 | - |
|
197 | - $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
198 | - |
|
199 | - $url = add_query_arg( array( |
|
200 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
201 | - ), $base ); |
|
202 | - |
|
203 | - if( $post_id ) { |
|
204 | - $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * Allow passing params to dynamically populate entry with values |
|
209 | - * @since 1.9.2 |
|
210 | - */ |
|
211 | - if( !empty( $field_values ) ) { |
|
212 | - |
|
213 | - if( is_array( $field_values ) ) { |
|
214 | - // If already an array, no parse_str() needed |
|
215 | - $params = $field_values; |
|
216 | - } else { |
|
217 | - parse_str( $field_values, $params ); |
|
218 | - } |
|
219 | - |
|
220 | - $url = add_query_arg( $params, $url ); |
|
221 | - } |
|
154 | + /** |
|
155 | + * Include this extension templates path |
|
156 | + * @param array $file_paths List of template paths ordered |
|
157 | + */ |
|
158 | + public function add_template_path( $file_paths ) { |
|
159 | + |
|
160 | + // Index 100 is the default GravityView template path. |
|
161 | + $file_paths[ 110 ] = self::$file; |
|
162 | + |
|
163 | + return $file_paths; |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * |
|
168 | + * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
169 | + * |
|
170 | + * @param $view_id int GravityView view id |
|
171 | + * @param $form_id int Gravity Forms form id |
|
172 | + * @param $entry_id int Gravity Forms entry id |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
176 | + return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * The edit entry link creates a secure link with a nonce |
|
182 | + * |
|
183 | + * It also mimics the URL structure Gravity Forms expects to have so that |
|
184 | + * it formats the display of the edit form like it does in the backend, like |
|
185 | + * "You can edit this post from the post page" fields, for example. |
|
186 | + * |
|
187 | + * @param $entry array Gravity Forms entry object |
|
188 | + * @param $view_id int GravityView view id |
|
189 | + * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
190 | + * @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/ } |
|
191 | + * @return string |
|
192 | + */ |
|
193 | + public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
194 | + |
|
195 | + $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
196 | + |
|
197 | + $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
198 | + |
|
199 | + $url = add_query_arg( array( |
|
200 | + 'edit' => wp_create_nonce( $nonce_key ) |
|
201 | + ), $base ); |
|
202 | + |
|
203 | + if( $post_id ) { |
|
204 | + $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * Allow passing params to dynamically populate entry with values |
|
209 | + * @since 1.9.2 |
|
210 | + */ |
|
211 | + if( !empty( $field_values ) ) { |
|
212 | + |
|
213 | + if( is_array( $field_values ) ) { |
|
214 | + // If already an array, no parse_str() needed |
|
215 | + $params = $field_values; |
|
216 | + } else { |
|
217 | + parse_str( $field_values, $params ); |
|
218 | + } |
|
219 | + |
|
220 | + $url = add_query_arg( $params, $url ); |
|
221 | + } |
|
222 | 222 | |
223 | 223 | /** |
224 | 224 | * @filter `gravityview/edit/link` Filter the edit URL link. |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @param \GV\View $view The View. |
228 | 228 | */ |
229 | 229 | return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id ) ); |
230 | - } |
|
230 | + } |
|
231 | 231 | |
232 | 232 | /** |
233 | 233 | * Edit mode doesn't allow certain field types. |
@@ -282,19 +282,19 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | |
285 | - /** |
|
286 | - * checks if user has permissions to edit a specific entry |
|
287 | - * |
|
288 | - * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
289 | - * |
|
290 | - * @param array $entry Gravity Forms entry array |
|
291 | - * @param \GV\View int $view_id ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
292 | - * @return bool |
|
293 | - */ |
|
294 | - public static function check_user_cap_edit_entry( $entry, $view = 0 ) { |
|
285 | + /** |
|
286 | + * checks if user has permissions to edit a specific entry |
|
287 | + * |
|
288 | + * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
289 | + * |
|
290 | + * @param array $entry Gravity Forms entry array |
|
291 | + * @param \GV\View int $view_id ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
292 | + * @return bool |
|
293 | + */ |
|
294 | + public static function check_user_cap_edit_entry( $entry, $view = 0 ) { |
|
295 | 295 | |
296 | - // No permission by default |
|
297 | - $user_can_edit = false; |
|
296 | + // No permission by default |
|
297 | + $user_can_edit = false; |
|
298 | 298 | |
299 | 299 | // get user_edit setting |
300 | 300 | if ( empty( $view ) ) { |
@@ -312,59 +312,59 @@ discard block |
||
312 | 312 | $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
313 | 313 | } |
314 | 314 | |
315 | - // If they can edit any entries (as defined in Gravity Forms) |
|
316 | - // Or if they can edit other people's entries |
|
317 | - // Then we're good. |
|
318 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
315 | + // If they can edit any entries (as defined in Gravity Forms) |
|
316 | + // Or if they can edit other people's entries |
|
317 | + // Then we're good. |
|
318 | + if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
319 | 319 | |
320 | - gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
320 | + gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
321 | 321 | |
322 | - $user_can_edit = true; |
|
322 | + $user_can_edit = true; |
|
323 | 323 | |
324 | - } else if( !isset( $entry['created_by'] ) ) { |
|
324 | + } else if( !isset( $entry['created_by'] ) ) { |
|
325 | 325 | |
326 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
326 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
327 | 327 | |
328 | - $user_can_edit = false; |
|
328 | + $user_can_edit = false; |
|
329 | 329 | |
330 | - } else { |
|
330 | + } else { |
|
331 | 331 | |
332 | 332 | |
333 | - $current_user = wp_get_current_user(); |
|
333 | + $current_user = wp_get_current_user(); |
|
334 | 334 | |
335 | - // User edit is disabled |
|
336 | - if( empty( $user_edit ) ) { |
|
335 | + // User edit is disabled |
|
336 | + if( empty( $user_edit ) ) { |
|
337 | 337 | |
338 | - gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
338 | + gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
339 | 339 | |
340 | - $user_can_edit = false; |
|
341 | - } |
|
340 | + $user_can_edit = false; |
|
341 | + } |
|
342 | 342 | |
343 | - // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
344 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
343 | + // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
344 | + else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
345 | 345 | |
346 | - gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
346 | + gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
347 | 347 | |
348 | - $user_can_edit = true; |
|
348 | + $user_can_edit = true; |
|
349 | 349 | |
350 | - } else if( ! is_user_logged_in() ) { |
|
350 | + } else if( ! is_user_logged_in() ) { |
|
351 | 351 | |
352 | - gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
353 | - } |
|
352 | + gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
353 | + } |
|
354 | 354 | |
355 | - } |
|
355 | + } |
|
356 | 356 | |
357 | - /** |
|
358 | - * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
359 | - * @since 1.15 Added `$entry` and `$view_id` parameters |
|
360 | - * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
361 | - * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
362 | - * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
363 | - */ |
|
364 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
357 | + /** |
|
358 | + * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
359 | + * @since 1.15 Added `$entry` and `$view_id` parameters |
|
360 | + * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
361 | + * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
362 | + * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
363 | + */ |
|
364 | + $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
365 | 365 | |
366 | - return (bool)$user_can_edit; |
|
367 | - } |
|
366 | + return (bool)$user_can_edit; |
|
367 | + } |
|
368 | 368 | |
369 | 369 | |
370 | 370 |
@@ -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 | } |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | |
176 | 176 | if( 'form_list' === GFForms::get_page() ) { |
177 | 177 | $priority = 790; |
178 | - } |
|
178 | + } |
|
179 | 179 | |
180 | 180 | if( empty( $connected_views ) ) { |
181 | 181 | |
182 | - $menu_items['gravityview'] = array( |
|
182 | + $menu_items['gravityview'] = array( |
|
183 | 183 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
184 | 184 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
185 | 185 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -210,13 +210,13 @@ discard block |
||
210 | 210 | // If there were no items added, then let's create the parent menu |
211 | 211 | if( $sub_menu_items ) { |
212 | 212 | |
213 | - $sub_menu_items[] = array( |
|
214 | - 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
215 | - 'link_class' => 'gv-create-view', |
|
216 | - 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
217 | - 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
218 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
219 | - ); |
|
213 | + $sub_menu_items[] = array( |
|
214 | + 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
215 | + 'link_class' => 'gv-create-view', |
|
216 | + 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
217 | + 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
218 | + 'capabilities' => array( 'edit_gravityviews' ), |
|
219 | + ); |
|
220 | 220 | |
221 | 221 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
222 | 222 | $sub_menu_items[] = array( |
@@ -599,17 +599,17 @@ discard block |
||
599 | 599 | * Render html for displaying available fields based on a Form ID |
600 | 600 | * $blacklist_field_types - contains the field types which are not proper to be shown in a directory. |
601 | 601 | * |
602 | - * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
602 | + * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
603 | 603 | * @access public |
604 | - * |
|
604 | + * |
|
605 | 605 | * @param int $form Gravity Forms Form ID (default: '') |
606 | 606 | * @param string $context (default: 'single') |
607 | - * |
|
607 | + * |
|
608 | 608 | * @return void |
609 | 609 | */ |
610 | 610 | function render_available_fields( $form = 0, $context = 'single' ) { |
611 | 611 | |
612 | - // Determine if form is a preset and convert it to an array with fields |
|
612 | + // Determine if form is a preset and convert it to an array with fields |
|
613 | 613 | $form = ( is_string( $form ) && preg_match( '/^preset_/', $form ) ) ? GravityView_Ajax::pre_get_form_fields( $form ) : $form; |
614 | 614 | |
615 | 615 | /** |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | |
622 | 622 | if ( ! is_array( $blacklist_field_types ) ) { |
623 | 623 | |
624 | - gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
624 | + gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
625 | 625 | |
626 | 626 | $blacklist_field_types = array(); |
627 | 627 | } |
@@ -753,12 +753,12 @@ discard block |
||
753 | 753 | /** |
754 | 754 | * @since 1.7.2 |
755 | 755 | */ |
756 | - 'other_entries' => array( |
|
757 | - 'label' => __('Other Entries', 'gravityview'), |
|
758 | - 'type' => 'other_entries', |
|
759 | - 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
760 | - ), |
|
761 | - ); |
|
756 | + 'other_entries' => array( |
|
757 | + 'label' => __('Other Entries', 'gravityview'), |
|
758 | + 'type' => 'other_entries', |
|
759 | + 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
760 | + ), |
|
761 | + ); |
|
762 | 762 | |
763 | 763 | if( 'single' !== $zone) { |
764 | 764 | |
@@ -906,9 +906,9 @@ discard block |
||
906 | 906 | |
907 | 907 | $joined_forms = gravityview_get_joined_forms( $post->ID ); |
908 | 908 | |
909 | - foreach ( $joined_forms as $form ) { |
|
910 | - $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
911 | - } |
|
909 | + foreach ( $joined_forms as $form ) { |
|
910 | + $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
911 | + } |
|
912 | 912 | } else { |
913 | 913 | $available_items[ $form ] = \GV\Widget::registered(); |
914 | 914 | } |
@@ -936,9 +936,9 @@ discard block |
||
936 | 936 | |
937 | 937 | if ( $form_id ) { |
938 | 938 | $original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ; |
939 | - } else { |
|
939 | + } else { |
|
940 | 940 | $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
941 | - } |
|
941 | + } |
|
942 | 942 | |
943 | 943 | if ( !$original_item ) { |
944 | 944 | 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 ) ) ); |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | |
991 | 991 | /** |
992 | 992 | * Render the widget active areas |
993 | - * @param string $template_id The current slug of the selected View template |
|
993 | + * @param string $template_id The current slug of the selected View template |
|
994 | 994 | * @param string $zone Either 'header' or 'footer' |
995 | 995 | * @param string $post_id Current Post ID (view) |
996 | 996 | * @return string html |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | $is_widgets_page = ( $pagenow === 'widgets.php' ); |
1175 | 1175 | |
1176 | 1176 | // Add the GV font (with the Astronaut) |
1177 | - wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
1177 | + wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
1178 | 1178 | wp_register_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), \GV\Plugin::$version ); |
1179 | 1179 | |
1180 | 1180 | wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), \GV\Plugin::$version, true ); |
@@ -1182,66 +1182,66 @@ discard block |
||
1182 | 1182 | if( GFForms::get_page() === 'form_list' ) { |
1183 | 1183 | wp_enqueue_style( 'gravityview_views_styles' ); |
1184 | 1184 | return; |
1185 | - } |
|
1185 | + } |
|
1186 | 1186 | |
1187 | 1187 | // Don't process any scripts below here if it's not a GravityView page. |
1188 | 1188 | if( ! gravityview()->request->is_admin( $hook, 'single' ) && ! $is_widgets_page ) { |
1189 | - return; |
|
1189 | + return; |
|
1190 | 1190 | } |
1191 | 1191 | |
1192 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1193 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
1194 | - |
|
1195 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
1196 | - |
|
1197 | - //enqueue scripts |
|
1198 | - 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' ), \GV\Plugin::$version ); |
|
1199 | - |
|
1200 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1201 | - 'cookiepath' => COOKIEPATH, |
|
1202 | - 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1203 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1204 | - 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1205 | - 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
|
1206 | - 'label_add_search_field' => __( 'Add Search Field', 'gravityview' ), |
|
1207 | - 'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ), |
|
1208 | - 'label_close' => __( 'Close', 'gravityview' ), |
|
1209 | - 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1210 | - 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1211 | - 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1212 | - 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1213 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1214 | - 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1215 | - 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1216 | - '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' ), |
|
1217 | - )); |
|
1192 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1193 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
1194 | + |
|
1195 | + $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
1196 | + |
|
1197 | + //enqueue scripts |
|
1198 | + 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' ), \GV\Plugin::$version ); |
|
1199 | + |
|
1200 | + wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1201 | + 'cookiepath' => COOKIEPATH, |
|
1202 | + 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1203 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1204 | + 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1205 | + 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
|
1206 | + 'label_add_search_field' => __( 'Add Search Field', 'gravityview' ), |
|
1207 | + 'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ), |
|
1208 | + 'label_close' => __( 'Close', 'gravityview' ), |
|
1209 | + 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1210 | + 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1211 | + 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1212 | + 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1213 | + 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1214 | + 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1215 | + 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1216 | + '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' ), |
|
1217 | + )); |
|
1218 | 1218 | |
1219 | 1219 | wp_enqueue_style( 'gravityview_views_styles' ); |
1220 | 1220 | |
1221 | - // Enqueue scripts needed for merge tags |
|
1222 | - self::enqueue_gravity_forms_scripts(); |
|
1221 | + // Enqueue scripts needed for merge tags |
|
1222 | + self::enqueue_gravity_forms_scripts(); |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | /** |
1226 | 1226 | * Enqueue Gravity Forms scripts, needed for Merge Tags |
1227 | - * |
|
1228 | - * @since 1.0.5-beta |
|
1229 | - * |
|
1230 | - * @return void |
|
1227 | + * |
|
1228 | + * @since 1.0.5-beta |
|
1229 | + * |
|
1230 | + * @return void |
|
1231 | 1231 | */ |
1232 | 1232 | static function enqueue_gravity_forms_scripts() { |
1233 | 1233 | GFForms::register_scripts(); |
1234 | 1234 | |
1235 | 1235 | $scripts = array( |
1236 | - 'sack', |
|
1237 | - 'gform_gravityforms', |
|
1238 | - 'gform_forms', |
|
1239 | - 'gform_form_admin', |
|
1240 | - 'jquery-ui-autocomplete' |
|
1236 | + 'sack', |
|
1237 | + 'gform_gravityforms', |
|
1238 | + 'gform_forms', |
|
1239 | + 'gform_form_admin', |
|
1240 | + 'jquery-ui-autocomplete' |
|
1241 | 1241 | ); |
1242 | 1242 | |
1243 | 1243 | if ( wp_is_mobile() ) { |
1244 | - $scripts[] = 'jquery-touch-punch'; |
|
1244 | + $scripts[] = 'jquery-touch-punch'; |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | wp_enqueue_script( $scripts ); |