@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | type="' . $field['type'] . '" |
419 | 419 | name="' . esc_attr( $name ) . '" |
420 | 420 | value="' . $value . '" ' . |
421 | - implode( ' ', $attributes ) . |
|
422 | - ' />'; |
|
421 | + implode( ' ', $attributes ) . |
|
422 | + ' />'; |
|
423 | 423 | |
424 | 424 | if ( $echo ) { |
425 | 425 | echo $html; |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | array( |
649 | 649 | 'label' => _x( 'Permanently Delete', 'Setting: what to do when uninstalling plugin', 'gravityview' ), |
650 | 650 | 'value' => 'delete', |
651 | - 'tooltip' => sprintf( '<h6>%s</h6><p><span class="howto">%s</span></p><p>%s</p>', __( 'Delete all GravityView content and settings', 'gravityview' ), __( 'If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview' ), __( 'When GravityView is uninstalled and deleted, delete all Views, GravityView entry approvals, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings. No Gravity Forms data will be touched.', 'gravityview' ) ), |
|
651 | + 'tooltip' => sprintf( '<h6>%s</h6><p><span class="howto">%s</span></p><p>%s</p>', __( 'Delete all GravityView content and settings', 'gravityview' ), __( 'If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview' ), __( 'When GravityView is uninstalled and deleted, delete all Views, GravityView entry approvals, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings. No Gravity Forms data will be touched.', 'gravityview' ) ), |
|
652 | 652 | ), |
653 | 653 | ), |
654 | 654 | 'description' => sprintf( __( 'Should GravityView content and entry approval status be removed from the site when the GravityView plugin is deleted?', 'gravityview' ), __( 'Permanently Delete', 'gravityview' ) ), |
@@ -674,36 +674,36 @@ discard block |
||
674 | 674 | } |
675 | 675 | |
676 | 676 | |
677 | - $sections = array( |
|
678 | - array( |
|
679 | - 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ), |
|
680 | - 'fields' => $fields, |
|
681 | - ) |
|
682 | - ); |
|
677 | + $sections = array( |
|
678 | + array( |
|
679 | + 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ), |
|
680 | + 'fields' => $fields, |
|
681 | + ) |
|
682 | + ); |
|
683 | 683 | |
684 | - // custom 'update settings' button |
|
685 | - $button = array( |
|
686 | - 'class' => 'button button-primary button-hero', |
|
687 | - 'type' => 'save', |
|
688 | - ); |
|
684 | + // custom 'update settings' button |
|
685 | + $button = array( |
|
686 | + 'class' => 'button button-primary button-hero', |
|
687 | + 'type' => 'save', |
|
688 | + ); |
|
689 | 689 | |
690 | 690 | if( $disabled_attribute ) { |
691 | 691 | $button['disabled'] = $disabled_attribute; |
692 | 692 | } |
693 | 693 | |
694 | 694 | |
695 | - /** |
|
696 | - * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page |
|
697 | - * Extensions can tap in here to insert their own section and settings. |
|
698 | - * <code> |
|
699 | - * $sections[] = array( |
|
700 | - * 'title' => __( 'GravityView My Extension Settings', 'gravityview' ), |
|
701 | - * 'fields' => $settings, |
|
702 | - * ); |
|
703 | - * </code> |
|
704 | - * @param array $extension_settings Empty array, ready for extension settings! |
|
705 | - */ |
|
706 | - $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() ); |
|
695 | + /** |
|
696 | + * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page |
|
697 | + * Extensions can tap in here to insert their own section and settings. |
|
698 | + * <code> |
|
699 | + * $sections[] = array( |
|
700 | + * 'title' => __( 'GravityView My Extension Settings', 'gravityview' ), |
|
701 | + * 'fields' => $settings, |
|
702 | + * ); |
|
703 | + * </code> |
|
704 | + * @param array $extension_settings Empty array, ready for extension settings! |
|
705 | + */ |
|
706 | + $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() ); |
|
707 | 707 | |
708 | 708 | // If there are extensions, add a section for them |
709 | 709 | if ( ! empty( $extension_sections ) ) { |
@@ -716,13 +716,13 @@ discard block |
||
716 | 716 | } |
717 | 717 | } |
718 | 718 | |
719 | - $k = count( $extension_sections ) - 1 ; |
|
720 | - $extension_sections[ $k ]['fields'][] = $button; |
|
719 | + $k = count( $extension_sections ) - 1 ; |
|
720 | + $extension_sections[ $k ]['fields'][] = $button; |
|
721 | 721 | $sections = array_merge( $sections, $extension_sections ); |
722 | 722 | } else { |
723 | - // add the 'update settings' button to the general section |
|
724 | - $sections[0]['fields'][] = $button; |
|
725 | - } |
|
723 | + // add the 'update settings' button to the general section |
|
724 | + $sections[0]['fields'][] = $button; |
|
725 | + } |
|
726 | 726 | |
727 | 727 | return $sections; |
728 | 728 | } |
@@ -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( 'RGForms', 'delete_file') ); |
|
83 | + // Add front-end access to Gravity Forms delete file action |
|
84 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
85 | 85 | |
86 | - // Make sure this hook is run for non-admins |
|
87 | - add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
86 | + // Make sure this hook is run for non-admins |
|
87 | + add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', '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,75 +105,75 @@ 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 ); |
|
152 | - |
|
153 | - $url = add_query_arg( array( |
|
154 | - 'page' => 'gf_entries', // Needed for GFForms::get_page() |
|
155 | - 'view' => 'entry', // Needed for GFForms::get_page() |
|
156 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
157 | - ), $base ); |
|
158 | - |
|
159 | - /** |
|
160 | - * Allow passing params to dynamically populate entry with values |
|
161 | - * @since 1.9.2 |
|
162 | - */ |
|
163 | - if( !empty( $field_values ) ) { |
|
164 | - |
|
165 | - if( is_array( $field_values ) ) { |
|
166 | - // If already an array, no parse_str() needed |
|
167 | - $params = $field_values; |
|
168 | - } else { |
|
169 | - parse_str( $field_values, $params ); |
|
170 | - } |
|
171 | - |
|
172 | - $url = add_query_arg( $params, $url ); |
|
173 | - } |
|
174 | - |
|
175 | - return $url; |
|
176 | - } |
|
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 ); |
|
152 | + |
|
153 | + $url = add_query_arg( array( |
|
154 | + 'page' => 'gf_entries', // Needed for GFForms::get_page() |
|
155 | + 'view' => 'entry', // Needed for GFForms::get_page() |
|
156 | + 'edit' => wp_create_nonce( $nonce_key ) |
|
157 | + ), $base ); |
|
158 | + |
|
159 | + /** |
|
160 | + * Allow passing params to dynamically populate entry with values |
|
161 | + * @since 1.9.2 |
|
162 | + */ |
|
163 | + if( !empty( $field_values ) ) { |
|
164 | + |
|
165 | + if( is_array( $field_values ) ) { |
|
166 | + // If already an array, no parse_str() needed |
|
167 | + $params = $field_values; |
|
168 | + } else { |
|
169 | + parse_str( $field_values, $params ); |
|
170 | + } |
|
171 | + |
|
172 | + $url = add_query_arg( $params, $url ); |
|
173 | + } |
|
174 | + |
|
175 | + return $url; |
|
176 | + } |
|
177 | 177 | |
178 | 178 | |
179 | 179 | /** |
@@ -209,81 +209,81 @@ discard block |
||
209 | 209 | } |
210 | 210 | |
211 | 211 | |
212 | - /** |
|
213 | - * checks if user has permissions to edit a specific entry |
|
214 | - * |
|
215 | - * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
216 | - * |
|
217 | - * @param array $entry Gravity Forms entry array |
|
218 | - * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2} |
|
219 | - * @return bool |
|
220 | - */ |
|
221 | - public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
212 | + /** |
|
213 | + * checks if user has permissions to edit a specific entry |
|
214 | + * |
|
215 | + * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
216 | + * |
|
217 | + * @param array $entry Gravity Forms entry array |
|
218 | + * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2} |
|
219 | + * @return bool |
|
220 | + */ |
|
221 | + public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
222 | 222 | |
223 | - // No permission by default |
|
224 | - $user_can_edit = false; |
|
223 | + // No permission by default |
|
224 | + $user_can_edit = false; |
|
225 | 225 | |
226 | - // If they can edit any entries (as defined in Gravity Forms) |
|
227 | - // Or if they can edit other people's entries |
|
228 | - // Then we're good. |
|
229 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
226 | + // If they can edit any entries (as defined in Gravity Forms) |
|
227 | + // Or if they can edit other people's entries |
|
228 | + // Then we're good. |
|
229 | + if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
230 | 230 | |
231 | - do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.'); |
|
231 | + do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.'); |
|
232 | 232 | |
233 | - $user_can_edit = true; |
|
233 | + $user_can_edit = true; |
|
234 | 234 | |
235 | - } else if( !isset( $entry['created_by'] ) ) { |
|
235 | + } else if( !isset( $entry['created_by'] ) ) { |
|
236 | 236 | |
237 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.'); |
|
237 | + do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.'); |
|
238 | 238 | |
239 | - $user_can_edit = false; |
|
239 | + $user_can_edit = false; |
|
240 | 240 | |
241 | - } else { |
|
241 | + } else { |
|
242 | 242 | |
243 | - // get user_edit setting |
|
244 | - if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
245 | - // if View ID not specified or is the current view |
|
246 | - $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
247 | - } else { |
|
248 | - // in case is specified and not the current view |
|
249 | - $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
250 | - } |
|
243 | + // get user_edit setting |
|
244 | + if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
245 | + // if View ID not specified or is the current view |
|
246 | + $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
247 | + } else { |
|
248 | + // in case is specified and not the current view |
|
249 | + $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
250 | + } |
|
251 | 251 | |
252 | - $current_user = wp_get_current_user(); |
|
252 | + $current_user = wp_get_current_user(); |
|
253 | 253 | |
254 | - // User edit is disabled |
|
255 | - if( empty( $user_edit ) ) { |
|
254 | + // User edit is disabled |
|
255 | + if( empty( $user_edit ) ) { |
|
256 | 256 | |
257 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
257 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
258 | 258 | |
259 | - $user_can_edit = false; |
|
260 | - } |
|
259 | + $user_can_edit = false; |
|
260 | + } |
|
261 | 261 | |
262 | - // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
263 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
262 | + // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
263 | + else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
264 | 264 | |
265 | - do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
265 | + do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
266 | 266 | |
267 | - $user_can_edit = true; |
|
267 | + $user_can_edit = true; |
|
268 | 268 | |
269 | - } else if( ! is_user_logged_in() ) { |
|
269 | + } else if( ! is_user_logged_in() ) { |
|
270 | 270 | |
271 | - do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' ); |
|
272 | - } |
|
271 | + do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' ); |
|
272 | + } |
|
273 | 273 | |
274 | - } |
|
274 | + } |
|
275 | 275 | |
276 | - /** |
|
277 | - * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
278 | - * @since 1.15 Added `$entry` and `$view_id` parameters |
|
279 | - * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
280 | - * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
281 | - * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
282 | - */ |
|
283 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
276 | + /** |
|
277 | + * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
278 | + * @since 1.15 Added `$entry` and `$view_id` parameters |
|
279 | + * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
280 | + * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
281 | + * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
282 | + */ |
|
283 | + $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
284 | 284 | |
285 | - return (bool)$user_can_edit; |
|
286 | - } |
|
285 | + return (bool)$user_can_edit; |
|
286 | + } |
|
287 | 287 | |
288 | 288 | |
289 | 289 |
@@ -1,17 +1,17 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * GravityView Edit Entry - Sync User Registration (when using the GF User Registration Add-on) |
|
4 | - * |
|
5 | - * @since 1.11 |
|
6 | - * @package GravityView |
|
7 | - * @license GPL2+ |
|
8 | - * @author Katz Web Services, Inc. |
|
9 | - * @link http://gravityview.co |
|
10 | - * @copyright Copyright 2015, Katz Web Services, Inc. |
|
11 | - */ |
|
3 | + * GravityView Edit Entry - Sync User Registration (when using the GF User Registration Add-on) |
|
4 | + * |
|
5 | + * @since 1.11 |
|
6 | + * @package GravityView |
|
7 | + * @license GPL2+ |
|
8 | + * @author Katz Web Services, Inc. |
|
9 | + * @link http://gravityview.co |
|
10 | + * @copyright Copyright 2015, Katz Web Services, Inc. |
|
11 | + */ |
|
12 | 12 | |
13 | 13 | if ( ! defined( 'WPINC' ) ) { |
14 | - die; |
|
14 | + die; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -22,255 +22,255 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @var GravityView_Edit_Entry |
24 | 24 | */ |
25 | - protected $loader; |
|
25 | + protected $loader; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @var WP_User|null Temporary storage used by restore_user_details() |
|
29 | - */ |
|
30 | - private $_user_before_update = null; |
|
27 | + /** |
|
28 | + * @var WP_User|null Temporary storage used by restore_user_details() |
|
29 | + */ |
|
30 | + private $_user_before_update = null; |
|
31 | 31 | |
32 | - function __construct( GravityView_Edit_Entry $loader ) { |
|
33 | - $this->loader = $loader; |
|
34 | - } |
|
32 | + function __construct( GravityView_Edit_Entry $loader ) { |
|
33 | + $this->loader = $loader; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @since 1.11 |
38 | 38 | */ |
39 | 39 | public function load() { |
40 | 40 | |
41 | - /** |
|
42 | - * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated? |
|
43 | - * @since 1.11 |
|
44 | - * @param boolean $boolean Whether to trigger update on user registration (default: true) |
|
45 | - */ |
|
46 | - if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
47 | - add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
48 | - |
|
49 | - // last resort in case the current user display name don't match any of the defaults |
|
50 | - add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
|
51 | - } |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Update the WordPress user profile based on the GF User Registration create feed |
|
56 | - * |
|
57 | - * @since 1.11 |
|
58 | - * |
|
59 | - * @param array $form Gravity Forms form array |
|
60 | - * @param string $entry_id Gravity Forms entry ID |
|
61 | - * @return void |
|
62 | - */ |
|
63 | - public function update_user( $form = array(), $entry_id = 0 ) { |
|
64 | - |
|
65 | - if( !class_exists( 'GFAPI' ) || !class_exists( 'GFUser' ) || empty( $entry_id ) ) { |
|
66 | - return; |
|
67 | - } |
|
68 | - |
|
69 | - // support for GF User Registration 3.x |
|
70 | - $gf_user_3 = class_exists('GF_User_Registration') ? true : false; |
|
71 | - |
|
72 | - if( $gf_user_3 ) { |
|
73 | - $gf_user_registration = GF_User_Registration::get_instance(); |
|
74 | - } |
|
75 | - |
|
76 | - $entry = GFAPI::get_entry( $entry_id ); |
|
77 | - |
|
78 | - /** |
|
79 | - * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
|
80 | - * @since 1.11 |
|
81 | - * @param array $entry Gravity Forms entry |
|
82 | - * @param array $form Gravity Forms form |
|
83 | - */ |
|
84 | - $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
85 | - |
|
86 | - /** |
|
87 | - * @since 1.14 |
|
88 | - */ |
|
89 | - if( $gf_user_3 ) { |
|
90 | - $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
91 | - } else { |
|
92 | - $config = GFUser::get_active_config( $form, $entry ); |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
97 | - * @since 1.15 |
|
98 | - * @param[in,out] boolean $preserve_role Preserve current user role Default: true |
|
99 | - * @param[in] array $config Gravity Forms User Registration feed configuration for the form |
|
100 | - * @param[in] array $form Gravity Forms form array |
|
101 | - * @param[in] array $entry Gravity Forms entry being edited |
|
102 | - */ |
|
103 | - $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
104 | - |
|
105 | - if( $preserve_role ) { |
|
106 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Make sure the current display name is not changed with the update user method. |
|
111 | - * @since 1.15 |
|
112 | - */ |
|
113 | - $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] ); |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
118 | - * @since 1.14 |
|
119 | - * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form |
|
120 | - * @param[in] array $form Gravity Forms form array |
|
121 | - * @param[in] array $entry Gravity Forms entry being edited |
|
122 | - */ |
|
123 | - $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
124 | - |
|
125 | - |
|
126 | - $feed_pos = $gf_user_3 ? 'meta/feedType' : 'meta/feed_type'; |
|
127 | - $is_create_feed = ( $config && rgars( $config, $feed_pos ) === 'create' ); |
|
128 | - |
|
129 | - // Only update if it's a create feed |
|
130 | - if( ! $is_create_feed ) { |
|
131 | - return; |
|
132 | - } |
|
133 | - |
|
134 | - // The priority is set to 3 so that default priority (10) will still override it |
|
135 | - add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
136 | - add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
137 | - |
|
138 | - // Trigger the User Registration update user method |
|
139 | - if( $gf_user_3 ) { |
|
140 | - $gf_user_registration->update_user( $entry, $form, $config ); |
|
141 | - } else { |
|
142 | - GFUser::update_user( $entry, $form, $config ); |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
147 | - remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
148 | - |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * Calculate the user display name format |
|
153 | - * |
|
154 | - * @since 1.15 |
|
155 | - * |
|
156 | - * @param int $user_id WP User ID |
|
157 | - * @return string Display name format as used inside Gravity Forms User Registration |
|
158 | - */ |
|
159 | - public function match_current_display_name( $user_id ) { |
|
160 | - |
|
161 | - $user = get_userdata( $user_id ); |
|
162 | - |
|
163 | - $names = $this->generate_display_names( $user ); |
|
164 | - |
|
165 | - $format = array_search( $user->display_name, $names, true ); |
|
166 | - |
|
167 | - // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support) |
|
168 | - // trigger last resort method at the 'gform_user_updated' hook |
|
169 | - if( false === $format || 'nickname' === $format ) { |
|
170 | - $this->_user_before_update = $user; |
|
171 | - $format = 'nickname'; |
|
172 | - } |
|
173 | - |
|
174 | - return $format; |
|
175 | - |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * Generate an array of all the user display names possibilities |
|
180 | - * |
|
181 | - * @since 1.15 |
|
182 | - * |
|
183 | - * @param object $profileuser WP_User object |
|
184 | - * @return array List all the possible display names for a certain User object |
|
185 | - */ |
|
186 | - public function generate_display_names( $profileuser ) { |
|
187 | - |
|
188 | - $public_display = array(); |
|
189 | - $public_display['nickname'] = $profileuser->nickname; |
|
190 | - $public_display['username'] = $profileuser->user_login; |
|
191 | - |
|
192 | - if ( !empty($profileuser->first_name) ) |
|
193 | - $public_display['firstname'] = $profileuser->first_name; |
|
194 | - |
|
195 | - if ( !empty($profileuser->last_name) ) |
|
196 | - $public_display['lastname'] = $profileuser->last_name; |
|
197 | - |
|
198 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
199 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
200 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
201 | - } |
|
202 | - |
|
203 | - $public_display = array_map( 'trim', $public_display ); |
|
204 | - $public_display = array_unique( $public_display ); |
|
205 | - |
|
206 | - return $public_display; |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
212 | - * |
|
213 | - * @see GFUser::update_user() |
|
214 | - * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
215 | - * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
216 | - * @param array $entry The Gravity Forms entry that was just updated |
|
217 | - * @param string $password User password |
|
218 | - * @return void |
|
219 | - */ |
|
220 | - public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
221 | - |
|
222 | - /** |
|
223 | - * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
224 | - * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
225 | - * @since 1.14.4 |
|
226 | - * @param boolean $restore_display_name Restore Display Name? Default: true |
|
227 | - */ |
|
228 | - $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
229 | - |
|
230 | - $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
231 | - |
|
232 | - /** |
|
233 | - * Don't restore display name: |
|
234 | - * - either disabled, |
|
235 | - * - or it is an Update feed (we only care about Create feed) |
|
236 | - * - or we don't need as we found the correct format before updating user. |
|
237 | - * @since 1.14.4 |
|
238 | - */ |
|
239 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
240 | - return; |
|
241 | - } |
|
242 | - |
|
243 | - $user_after_update = get_userdata( $user_id ); |
|
244 | - |
|
245 | - $restored_user = $user_after_update; |
|
246 | - |
|
247 | - // Restore previous display_name |
|
248 | - $restored_user->display_name = $this->_user_before_update->display_name; |
|
249 | - |
|
250 | - // Don't have WP update the password. |
|
251 | - unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
252 | - |
|
253 | - /** |
|
254 | - * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
255 | - * @since 1.14 |
|
256 | - * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
257 | - * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
258 | - * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
259 | - * @param array $entry The Gravity Forms entry that was just updated |
|
260 | - */ |
|
261 | - $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
262 | - |
|
263 | - $updated = wp_update_user( $restored_user ); |
|
264 | - |
|
265 | - if( is_wp_error( $updated ) ) { |
|
266 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
267 | - } else { |
|
268 | - do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
269 | - } |
|
270 | - |
|
271 | - $this->_user_before_update = null; |
|
272 | - |
|
273 | - unset( $updated, $restored_user, $user_after_update ); |
|
274 | - } |
|
41 | + /** |
|
42 | + * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated? |
|
43 | + * @since 1.11 |
|
44 | + * @param boolean $boolean Whether to trigger update on user registration (default: true) |
|
45 | + */ |
|
46 | + if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
47 | + add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
48 | + |
|
49 | + // last resort in case the current user display name don't match any of the defaults |
|
50 | + add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
|
51 | + } |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Update the WordPress user profile based on the GF User Registration create feed |
|
56 | + * |
|
57 | + * @since 1.11 |
|
58 | + * |
|
59 | + * @param array $form Gravity Forms form array |
|
60 | + * @param string $entry_id Gravity Forms entry ID |
|
61 | + * @return void |
|
62 | + */ |
|
63 | + public function update_user( $form = array(), $entry_id = 0 ) { |
|
64 | + |
|
65 | + if( !class_exists( 'GFAPI' ) || !class_exists( 'GFUser' ) || empty( $entry_id ) ) { |
|
66 | + return; |
|
67 | + } |
|
68 | + |
|
69 | + // support for GF User Registration 3.x |
|
70 | + $gf_user_3 = class_exists('GF_User_Registration') ? true : false; |
|
71 | + |
|
72 | + if( $gf_user_3 ) { |
|
73 | + $gf_user_registration = GF_User_Registration::get_instance(); |
|
74 | + } |
|
75 | + |
|
76 | + $entry = GFAPI::get_entry( $entry_id ); |
|
77 | + |
|
78 | + /** |
|
79 | + * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
|
80 | + * @since 1.11 |
|
81 | + * @param array $entry Gravity Forms entry |
|
82 | + * @param array $form Gravity Forms form |
|
83 | + */ |
|
84 | + $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
85 | + |
|
86 | + /** |
|
87 | + * @since 1.14 |
|
88 | + */ |
|
89 | + if( $gf_user_3 ) { |
|
90 | + $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
91 | + } else { |
|
92 | + $config = GFUser::get_active_config( $form, $entry ); |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
97 | + * @since 1.15 |
|
98 | + * @param[in,out] boolean $preserve_role Preserve current user role Default: true |
|
99 | + * @param[in] array $config Gravity Forms User Registration feed configuration for the form |
|
100 | + * @param[in] array $form Gravity Forms form array |
|
101 | + * @param[in] array $entry Gravity Forms entry being edited |
|
102 | + */ |
|
103 | + $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
104 | + |
|
105 | + if( $preserve_role ) { |
|
106 | + $config['meta']['role'] = 'gfur_preserve_role'; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Make sure the current display name is not changed with the update user method. |
|
111 | + * @since 1.15 |
|
112 | + */ |
|
113 | + $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] ); |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
118 | + * @since 1.14 |
|
119 | + * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form |
|
120 | + * @param[in] array $form Gravity Forms form array |
|
121 | + * @param[in] array $entry Gravity Forms entry being edited |
|
122 | + */ |
|
123 | + $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
124 | + |
|
125 | + |
|
126 | + $feed_pos = $gf_user_3 ? 'meta/feedType' : 'meta/feed_type'; |
|
127 | + $is_create_feed = ( $config && rgars( $config, $feed_pos ) === 'create' ); |
|
128 | + |
|
129 | + // Only update if it's a create feed |
|
130 | + if( ! $is_create_feed ) { |
|
131 | + return; |
|
132 | + } |
|
133 | + |
|
134 | + // The priority is set to 3 so that default priority (10) will still override it |
|
135 | + add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
136 | + add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
137 | + |
|
138 | + // Trigger the User Registration update user method |
|
139 | + if( $gf_user_3 ) { |
|
140 | + $gf_user_registration->update_user( $entry, $form, $config ); |
|
141 | + } else { |
|
142 | + GFUser::update_user( $entry, $form, $config ); |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
147 | + remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
148 | + |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * Calculate the user display name format |
|
153 | + * |
|
154 | + * @since 1.15 |
|
155 | + * |
|
156 | + * @param int $user_id WP User ID |
|
157 | + * @return string Display name format as used inside Gravity Forms User Registration |
|
158 | + */ |
|
159 | + public function match_current_display_name( $user_id ) { |
|
160 | + |
|
161 | + $user = get_userdata( $user_id ); |
|
162 | + |
|
163 | + $names = $this->generate_display_names( $user ); |
|
164 | + |
|
165 | + $format = array_search( $user->display_name, $names, true ); |
|
166 | + |
|
167 | + // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support) |
|
168 | + // trigger last resort method at the 'gform_user_updated' hook |
|
169 | + if( false === $format || 'nickname' === $format ) { |
|
170 | + $this->_user_before_update = $user; |
|
171 | + $format = 'nickname'; |
|
172 | + } |
|
173 | + |
|
174 | + return $format; |
|
175 | + |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Generate an array of all the user display names possibilities |
|
180 | + * |
|
181 | + * @since 1.15 |
|
182 | + * |
|
183 | + * @param object $profileuser WP_User object |
|
184 | + * @return array List all the possible display names for a certain User object |
|
185 | + */ |
|
186 | + public function generate_display_names( $profileuser ) { |
|
187 | + |
|
188 | + $public_display = array(); |
|
189 | + $public_display['nickname'] = $profileuser->nickname; |
|
190 | + $public_display['username'] = $profileuser->user_login; |
|
191 | + |
|
192 | + if ( !empty($profileuser->first_name) ) |
|
193 | + $public_display['firstname'] = $profileuser->first_name; |
|
194 | + |
|
195 | + if ( !empty($profileuser->last_name) ) |
|
196 | + $public_display['lastname'] = $profileuser->last_name; |
|
197 | + |
|
198 | + if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
199 | + $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
200 | + $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
201 | + } |
|
202 | + |
|
203 | + $public_display = array_map( 'trim', $public_display ); |
|
204 | + $public_display = array_unique( $public_display ); |
|
205 | + |
|
206 | + return $public_display; |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
212 | + * |
|
213 | + * @see GFUser::update_user() |
|
214 | + * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
215 | + * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
216 | + * @param array $entry The Gravity Forms entry that was just updated |
|
217 | + * @param string $password User password |
|
218 | + * @return void |
|
219 | + */ |
|
220 | + public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
221 | + |
|
222 | + /** |
|
223 | + * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
224 | + * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
225 | + * @since 1.14.4 |
|
226 | + * @param boolean $restore_display_name Restore Display Name? Default: true |
|
227 | + */ |
|
228 | + $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
229 | + |
|
230 | + $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
231 | + |
|
232 | + /** |
|
233 | + * Don't restore display name: |
|
234 | + * - either disabled, |
|
235 | + * - or it is an Update feed (we only care about Create feed) |
|
236 | + * - or we don't need as we found the correct format before updating user. |
|
237 | + * @since 1.14.4 |
|
238 | + */ |
|
239 | + if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
240 | + return; |
|
241 | + } |
|
242 | + |
|
243 | + $user_after_update = get_userdata( $user_id ); |
|
244 | + |
|
245 | + $restored_user = $user_after_update; |
|
246 | + |
|
247 | + // Restore previous display_name |
|
248 | + $restored_user->display_name = $this->_user_before_update->display_name; |
|
249 | + |
|
250 | + // Don't have WP update the password. |
|
251 | + unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
252 | + |
|
253 | + /** |
|
254 | + * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
255 | + * @since 1.14 |
|
256 | + * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
257 | + * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
258 | + * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
259 | + * @param array $entry The Gravity Forms entry that was just updated |
|
260 | + */ |
|
261 | + $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
262 | + |
|
263 | + $updated = wp_update_user( $restored_user ); |
|
264 | + |
|
265 | + if( is_wp_error( $updated ) ) { |
|
266 | + do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
267 | + } else { |
|
268 | + do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
269 | + } |
|
270 | + |
|
271 | + $this->_user_before_update = null; |
|
272 | + |
|
273 | + unset( $updated, $restored_user, $user_after_update ); |
|
274 | + } |
|
275 | 275 | |
276 | 276 | } //end class |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * The GravityView New Search widget |
|
4 | - * |
|
5 | - * @package GravityView-DataTables-Ext |
|
6 | - * @license GPL2+ |
|
7 | - * @author Katz Web Services, Inc. |
|
8 | - * @link http://gravityview.co |
|
9 | - * @copyright Copyright 2014, Katz Web Services, Inc. |
|
10 | - */ |
|
3 | + * The GravityView New Search widget |
|
4 | + * |
|
5 | + * @package GravityView-DataTables-Ext |
|
6 | + * @license GPL2+ |
|
7 | + * @author Katz Web Services, Inc. |
|
8 | + * @link http://gravityview.co |
|
9 | + * @copyright Copyright 2014, Katz Web Services, Inc. |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | if ( ! defined( 'WPINC' ) ) { |
13 | 13 | die; |
@@ -385,14 +385,14 @@ discard block |
||
385 | 385 | $curr_start = esc_attr( rgget( 'gv_start' ) ); |
386 | 386 | $curr_end = esc_attr( rgget( 'gv_end' ) ); |
387 | 387 | |
388 | - /** |
|
389 | - * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
|
390 | - * date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php) |
|
391 | - * @since 1.12 |
|
392 | - * @param[out,in] boolean $adjust_tz Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true |
|
393 | - * @param[in] string $context Where the filter is being called from. `search` in this case. |
|
394 | - */ |
|
395 | - $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' ); |
|
388 | + /** |
|
389 | + * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
|
390 | + * date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php) |
|
391 | + * @since 1.12 |
|
392 | + * @param[out,in] boolean $adjust_tz Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true |
|
393 | + * @param[in] string $context Where the filter is being called from. `search` in this case. |
|
394 | + */ |
|
395 | + $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' ); |
|
396 | 396 | |
397 | 397 | |
398 | 398 | /** |
@@ -1,187 +1,187 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Make some GFFormsModel public available. |
|
4 | - * @since 1.16.2 |
|
5 | - */ |
|
3 | + * Make some GFFormsModel public available. |
|
4 | + * @since 1.16.2 |
|
5 | + */ |
|
6 | 6 | |
7 | 7 | |
8 | 8 | class GravityView_GFFormsModel extends GFFormsModel { |
9 | 9 | |
10 | - /** |
|
11 | - * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private. |
|
12 | - * |
|
13 | - * @since 1.16.2 |
|
14 | - * |
|
15 | - * @param string $url URL of the post image to update |
|
16 | - * @param int $post_id ID of the post image to update |
|
17 | - * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path. |
|
18 | - */ |
|
19 | - public static function copy_post_image( $url, $post_id ) { |
|
20 | - |
|
21 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' ); |
|
22 | - |
|
23 | - /** |
|
24 | - * If the method changes to public, use Gravity Forms' method |
|
25 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
26 | - */ |
|
27 | - if( $reflection->isPublic() ) { |
|
28 | - return parent::copy_post_image( $url, $post_id ); |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * Original Gravity Forms code below: |
|
33 | - * ================================== |
|
34 | - */ |
|
35 | - |
|
36 | - $time = current_time( 'mysql' ); |
|
37 | - |
|
38 | - if ( $post = get_post( $post_id ) ) { |
|
39 | - if ( substr( $post->post_date, 0, 4 ) > 0 ) { |
|
40 | - $time = $post->post_date; |
|
41 | - } |
|
42 | - } |
|
43 | - |
|
44 | - //making sure there is a valid upload folder |
|
45 | - if ( ! ( ( $upload_dir = wp_upload_dir( $time ) ) && false === $upload_dir['error'] ) ) { |
|
46 | - return false; |
|
47 | - } |
|
48 | - |
|
49 | - $form_id = get_post_meta( $post_id, '_gform-form-id', true ); |
|
50 | - |
|
51 | - /** |
|
52 | - * Filter the media upload location. |
|
53 | - * |
|
54 | - * @param array $upload_dir The current upload directory’s path and url. |
|
55 | - * @param int $form_id The ID of the form currently being processed. |
|
56 | - * @param int $post_id The ID of the post created from the entry currently being processed. |
|
57 | - */ |
|
58 | - $upload_dir = gf_apply_filters( 'gform_media_upload_path', $form_id, $upload_dir, $form_id, $post_id ); |
|
59 | - |
|
60 | - if ( ! file_exists( $upload_dir['path'] ) ) { |
|
61 | - if ( ! wp_mkdir_p( $upload_dir['path'] ) ) { |
|
62 | - return false; |
|
63 | - } |
|
64 | - } |
|
65 | - |
|
66 | - $name = basename( $url ); |
|
67 | - $filename = wp_unique_filename( $upload_dir['path'], $name ); |
|
68 | - |
|
69 | - // the destination path |
|
70 | - $new_file = $upload_dir['path'] . "/$filename"; |
|
71 | - |
|
72 | - // the source path |
|
73 | - $y = substr( $time, 0, 4 ); |
|
74 | - $m = substr( $time, 5, 2 ); |
|
75 | - $target_root = RGFormsModel::get_upload_path( $form_id ) . "/$y/$m/"; |
|
76 | - $target_root_url = RGFormsModel::get_upload_url( $form_id ) . "/$y/$m/"; |
|
77 | - $upload_root_info = array( 'path' => $target_root, 'url' => $target_root_url ); |
|
78 | - $upload_root_info = gf_apply_filters( 'gform_upload_path', $form_id, $upload_root_info, $form_id ); |
|
79 | - $path = str_replace( $upload_root_info['url'], $upload_root_info['path'], $url ); |
|
80 | - |
|
81 | - // copy the file to the destination path |
|
82 | - if ( ! copy( $path, $new_file ) ) { |
|
83 | - return false; |
|
84 | - } |
|
85 | - |
|
86 | - // Set correct file permissions |
|
87 | - $stat = stat( dirname( $new_file ) ); |
|
88 | - $perms = $stat['mode'] & 0000666; |
|
89 | - @ chmod( $new_file, $perms ); |
|
90 | - |
|
91 | - // Compute the URL |
|
92 | - $url = $upload_dir['url'] . "/$filename"; |
|
93 | - |
|
94 | - if ( is_multisite() ) { |
|
95 | - delete_transient( 'dirsize_cache' ); |
|
96 | - } |
|
97 | - |
|
98 | - $type = wp_check_filetype( $new_file ); |
|
99 | - |
|
100 | - return array( 'file' => $new_file, 'url' => $url, 'type' => $type['type'] ); |
|
101 | - |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private. |
|
106 | - * |
|
107 | - * @see GFFormsModel::media_handle_upload |
|
108 | - * @see GravityView_Edit_Entry_Render::maybe_update_post_fields |
|
109 | - * |
|
110 | - * @uses copy_post_image |
|
111 | - * @uses wp_insert_attachment |
|
112 | - * @uses wp_update_attachment_metadata |
|
113 | - * |
|
114 | - * @param string $url URL of the post image to update |
|
115 | - * @param int $post_id ID of the post image to update |
|
116 | - * @param array $post_data Array of data for the eventual attachment post type that is created using {@see wp_insert_attachment}. Supports `post_mime_type`, `guid`, `post_parent`, `post_title`, `post_content` keys. |
|
117 | - * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image |
|
118 | - */ |
|
119 | - public static function media_handle_upload( $url, $post_id, $post_data = array() ) { |
|
120 | - |
|
121 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' ); |
|
122 | - |
|
123 | - /** |
|
124 | - * If the method changes to public, use Gravity Forms' method |
|
125 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
126 | - */ |
|
127 | - if( $reflection->isPublic() ) { |
|
128 | - return parent::media_handle_upload( $url, $post_id, $post_data ); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Original Gravity Forms code below: |
|
133 | - * ================================== |
|
134 | - */ |
|
135 | - |
|
136 | - //WordPress Administration API required for the media_handle_upload() function |
|
137 | - require_once( ABSPATH . 'wp-admin/includes/image.php' ); |
|
138 | - |
|
139 | - $name = basename( $url ); |
|
140 | - |
|
141 | - $file = self::copy_post_image( $url, $post_id ); |
|
142 | - |
|
143 | - if ( ! $file ) { |
|
144 | - return false; |
|
145 | - } |
|
146 | - |
|
147 | - $name_parts = pathinfo( $name ); |
|
148 | - $name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) ); |
|
149 | - |
|
150 | - $url = $file['url']; |
|
151 | - $type = $file['type']; |
|
152 | - $file = $file['file']; |
|
153 | - $title = $name; |
|
154 | - $content = ''; |
|
155 | - |
|
156 | - // use image exif/iptc data for title and caption defaults if possible |
|
157 | - if ( $image_meta = @wp_read_image_metadata( $file ) ) { |
|
158 | - if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { |
|
159 | - $title = $image_meta['title']; |
|
160 | - } |
|
161 | - if ( trim( $image_meta['caption'] ) ) { |
|
162 | - $content = $image_meta['caption']; |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - // Construct the attachment array |
|
167 | - $attachment = array_merge( |
|
168 | - array( |
|
169 | - 'post_mime_type' => $type, |
|
170 | - 'guid' => $url, |
|
171 | - 'post_parent' => $post_id, |
|
172 | - 'post_title' => $title, |
|
173 | - 'post_content' => $content, |
|
174 | - ), $post_data |
|
175 | - ); |
|
176 | - |
|
177 | - // Save the data |
|
178 | - $id = wp_insert_attachment( $attachment, $file, $post_id ); |
|
179 | - if ( ! is_wp_error( $id ) ) { |
|
180 | - wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); |
|
181 | - } |
|
182 | - |
|
183 | - return $id; |
|
184 | - } |
|
10 | + /** |
|
11 | + * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private. |
|
12 | + * |
|
13 | + * @since 1.16.2 |
|
14 | + * |
|
15 | + * @param string $url URL of the post image to update |
|
16 | + * @param int $post_id ID of the post image to update |
|
17 | + * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path. |
|
18 | + */ |
|
19 | + public static function copy_post_image( $url, $post_id ) { |
|
20 | + |
|
21 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' ); |
|
22 | + |
|
23 | + /** |
|
24 | + * If the method changes to public, use Gravity Forms' method |
|
25 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
26 | + */ |
|
27 | + if( $reflection->isPublic() ) { |
|
28 | + return parent::copy_post_image( $url, $post_id ); |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * Original Gravity Forms code below: |
|
33 | + * ================================== |
|
34 | + */ |
|
35 | + |
|
36 | + $time = current_time( 'mysql' ); |
|
37 | + |
|
38 | + if ( $post = get_post( $post_id ) ) { |
|
39 | + if ( substr( $post->post_date, 0, 4 ) > 0 ) { |
|
40 | + $time = $post->post_date; |
|
41 | + } |
|
42 | + } |
|
43 | + |
|
44 | + //making sure there is a valid upload folder |
|
45 | + if ( ! ( ( $upload_dir = wp_upload_dir( $time ) ) && false === $upload_dir['error'] ) ) { |
|
46 | + return false; |
|
47 | + } |
|
48 | + |
|
49 | + $form_id = get_post_meta( $post_id, '_gform-form-id', true ); |
|
50 | + |
|
51 | + /** |
|
52 | + * Filter the media upload location. |
|
53 | + * |
|
54 | + * @param array $upload_dir The current upload directory’s path and url. |
|
55 | + * @param int $form_id The ID of the form currently being processed. |
|
56 | + * @param int $post_id The ID of the post created from the entry currently being processed. |
|
57 | + */ |
|
58 | + $upload_dir = gf_apply_filters( 'gform_media_upload_path', $form_id, $upload_dir, $form_id, $post_id ); |
|
59 | + |
|
60 | + if ( ! file_exists( $upload_dir['path'] ) ) { |
|
61 | + if ( ! wp_mkdir_p( $upload_dir['path'] ) ) { |
|
62 | + return false; |
|
63 | + } |
|
64 | + } |
|
65 | + |
|
66 | + $name = basename( $url ); |
|
67 | + $filename = wp_unique_filename( $upload_dir['path'], $name ); |
|
68 | + |
|
69 | + // the destination path |
|
70 | + $new_file = $upload_dir['path'] . "/$filename"; |
|
71 | + |
|
72 | + // the source path |
|
73 | + $y = substr( $time, 0, 4 ); |
|
74 | + $m = substr( $time, 5, 2 ); |
|
75 | + $target_root = RGFormsModel::get_upload_path( $form_id ) . "/$y/$m/"; |
|
76 | + $target_root_url = RGFormsModel::get_upload_url( $form_id ) . "/$y/$m/"; |
|
77 | + $upload_root_info = array( 'path' => $target_root, 'url' => $target_root_url ); |
|
78 | + $upload_root_info = gf_apply_filters( 'gform_upload_path', $form_id, $upload_root_info, $form_id ); |
|
79 | + $path = str_replace( $upload_root_info['url'], $upload_root_info['path'], $url ); |
|
80 | + |
|
81 | + // copy the file to the destination path |
|
82 | + if ( ! copy( $path, $new_file ) ) { |
|
83 | + return false; |
|
84 | + } |
|
85 | + |
|
86 | + // Set correct file permissions |
|
87 | + $stat = stat( dirname( $new_file ) ); |
|
88 | + $perms = $stat['mode'] & 0000666; |
|
89 | + @ chmod( $new_file, $perms ); |
|
90 | + |
|
91 | + // Compute the URL |
|
92 | + $url = $upload_dir['url'] . "/$filename"; |
|
93 | + |
|
94 | + if ( is_multisite() ) { |
|
95 | + delete_transient( 'dirsize_cache' ); |
|
96 | + } |
|
97 | + |
|
98 | + $type = wp_check_filetype( $new_file ); |
|
99 | + |
|
100 | + return array( 'file' => $new_file, 'url' => $url, 'type' => $type['type'] ); |
|
101 | + |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private. |
|
106 | + * |
|
107 | + * @see GFFormsModel::media_handle_upload |
|
108 | + * @see GravityView_Edit_Entry_Render::maybe_update_post_fields |
|
109 | + * |
|
110 | + * @uses copy_post_image |
|
111 | + * @uses wp_insert_attachment |
|
112 | + * @uses wp_update_attachment_metadata |
|
113 | + * |
|
114 | + * @param string $url URL of the post image to update |
|
115 | + * @param int $post_id ID of the post image to update |
|
116 | + * @param array $post_data Array of data for the eventual attachment post type that is created using {@see wp_insert_attachment}. Supports `post_mime_type`, `guid`, `post_parent`, `post_title`, `post_content` keys. |
|
117 | + * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image |
|
118 | + */ |
|
119 | + public static function media_handle_upload( $url, $post_id, $post_data = array() ) { |
|
120 | + |
|
121 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' ); |
|
122 | + |
|
123 | + /** |
|
124 | + * If the method changes to public, use Gravity Forms' method |
|
125 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
126 | + */ |
|
127 | + if( $reflection->isPublic() ) { |
|
128 | + return parent::media_handle_upload( $url, $post_id, $post_data ); |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Original Gravity Forms code below: |
|
133 | + * ================================== |
|
134 | + */ |
|
135 | + |
|
136 | + //WordPress Administration API required for the media_handle_upload() function |
|
137 | + require_once( ABSPATH . 'wp-admin/includes/image.php' ); |
|
138 | + |
|
139 | + $name = basename( $url ); |
|
140 | + |
|
141 | + $file = self::copy_post_image( $url, $post_id ); |
|
142 | + |
|
143 | + if ( ! $file ) { |
|
144 | + return false; |
|
145 | + } |
|
146 | + |
|
147 | + $name_parts = pathinfo( $name ); |
|
148 | + $name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) ); |
|
149 | + |
|
150 | + $url = $file['url']; |
|
151 | + $type = $file['type']; |
|
152 | + $file = $file['file']; |
|
153 | + $title = $name; |
|
154 | + $content = ''; |
|
155 | + |
|
156 | + // use image exif/iptc data for title and caption defaults if possible |
|
157 | + if ( $image_meta = @wp_read_image_metadata( $file ) ) { |
|
158 | + if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { |
|
159 | + $title = $image_meta['title']; |
|
160 | + } |
|
161 | + if ( trim( $image_meta['caption'] ) ) { |
|
162 | + $content = $image_meta['caption']; |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + // Construct the attachment array |
|
167 | + $attachment = array_merge( |
|
168 | + array( |
|
169 | + 'post_mime_type' => $type, |
|
170 | + 'guid' => $url, |
|
171 | + 'post_parent' => $post_id, |
|
172 | + 'post_title' => $title, |
|
173 | + 'post_content' => $content, |
|
174 | + ), $post_data |
|
175 | + ); |
|
176 | + |
|
177 | + // Save the data |
|
178 | + $id = wp_insert_attachment( $attachment, $file, $post_id ); |
|
179 | + if ( ! is_wp_error( $id ) ) { |
|
180 | + wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); |
|
181 | + } |
|
182 | + |
|
183 | + return $id; |
|
184 | + } |
|
185 | 185 | |
186 | 186 | |
187 | 187 | } |
188 | 188 | \ No newline at end of file |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @package GravityView |
|
4 | - * @subpackage Gravityview/admin/metaboxes/views |
|
5 | - * @since 1.8 |
|
6 | - * @global WP_Post $post |
|
7 | - */ |
|
3 | + * @package GravityView |
|
4 | + * @subpackage Gravityview/admin/metaboxes/views |
|
5 | + * @since 1.8 |
|
6 | + * @global WP_Post $post |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | |
10 | 10 | // Use nonce for verification |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | self::getInstance()->set_entry( $entry ); |
230 | 230 | |
231 | - $base = GravityView_API::directory_link( $post_id, true ); |
|
231 | + $base = GravityView_API::directory_link( $post_id, true ); |
|
232 | 232 | |
233 | 233 | if( empty( $base ) ) { |
234 | 234 | do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: '.$post_id ); |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | // Use the slug instead of the ID for consistent security |
239 | 239 | $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
240 | 240 | |
241 | - $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id; |
|
241 | + $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id; |
|
242 | 242 | |
243 | 243 | $actionurl = add_query_arg( array( |
244 | 244 | 'action' => 'delete', |
245 | 245 | 'entry_id' => $entry_slug, |
246 | 246 | 'gvid' => $view_id, |
247 | - 'view_id' => $view_id, |
|
247 | + 'view_id' => $view_id, |
|
248 | 248 | ), $base ); |
249 | 249 | |
250 | 250 | $url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' ); |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | * @action `gravityview/delete-entry/deleted` Triggered when an entry is deleted |
416 | 416 | * @since 1.16.4 |
417 | 417 | * @param int $entry_id ID of the Gravity Forms entry |
418 | - */ |
|
418 | + */ |
|
419 | 419 | do_action( 'gravityview/delete-entry/deleted', $entry_id ); |
420 | 420 | } |
421 | 421 |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | 7 => sprintf(__( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
183 | 183 | 8 => __( 'View submitted.', 'gravityview' ), |
184 | 184 | 9 => sprintf( |
185 | - /* translators: Date and time the View is scheduled to be published */ |
|
185 | + /* translators: Date and time the View is scheduled to be published */ |
|
186 | 186 | __( 'View scheduled for: %1$s.', 'gravityview' ), |
187 | 187 | // translators: Publish box date format, see http://php.net/date |
188 | 188 | date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
@@ -222,39 +222,39 @@ discard block |
||
222 | 222 | } |
223 | 223 | |
224 | 224 | $wp_allowed_scripts = array( |
225 | - 'common', |
|
226 | - 'admin-bar', |
|
227 | - 'autosave', |
|
228 | - 'post', |
|
225 | + 'common', |
|
226 | + 'admin-bar', |
|
227 | + 'autosave', |
|
228 | + 'post', |
|
229 | 229 | 'inline-edit-post', |
230 | - 'utils', |
|
231 | - 'svg-painter', |
|
232 | - 'wp-auth-check', |
|
233 | - 'heartbeat', |
|
230 | + 'utils', |
|
231 | + 'svg-painter', |
|
232 | + 'wp-auth-check', |
|
233 | + 'heartbeat', |
|
234 | 234 | 'media-editor', |
235 | 235 | 'media-upload', |
236 | - 'thickbox', |
|
236 | + 'thickbox', |
|
237 | 237 | 'wp-color-picker', |
238 | 238 | |
239 | - // Settings |
|
239 | + // Settings |
|
240 | 240 | 'gv-admin-edd-license', |
241 | 241 | |
242 | - // Common |
|
243 | - 'select2-js', |
|
244 | - 'qtip-js', |
|
242 | + // Common |
|
243 | + 'select2-js', |
|
244 | + 'qtip-js', |
|
245 | 245 | |
246 | - // jQuery |
|
246 | + // jQuery |
|
247 | 247 | 'jquery', |
248 | - 'jquery-ui-core', |
|
249 | - 'jquery-ui-sortable', |
|
250 | - 'jquery-ui-datepicker', |
|
251 | - 'jquery-ui-dialog', |
|
252 | - 'jquery-ui-slider', |
|
248 | + 'jquery-ui-core', |
|
249 | + 'jquery-ui-sortable', |
|
250 | + 'jquery-ui-datepicker', |
|
251 | + 'jquery-ui-dialog', |
|
252 | + 'jquery-ui-slider', |
|
253 | 253 | 'jquery-ui-dialog', |
254 | 254 | 'jquery-ui-tabs', |
255 | 255 | 'jquery-ui-draggable', |
256 | 256 | 'jquery-ui-droppable', |
257 | - 'jquery-ui-accordion', |
|
257 | + 'jquery-ui-accordion', |
|
258 | 258 | ); |
259 | 259 | |
260 | 260 | $this->remove_conflicts( $wp_scripts, $wp_allowed_scripts, 'scripts' ); |
@@ -288,23 +288,23 @@ discard block |
||
288 | 288 | return; |
289 | 289 | } |
290 | 290 | |
291 | - $wp_allowed_styles = array( |
|
292 | - 'admin-bar', |
|
293 | - 'colors', |
|
294 | - 'ie', |
|
295 | - 'wp-auth-check', |
|
296 | - 'media-views', |
|
291 | + $wp_allowed_styles = array( |
|
292 | + 'admin-bar', |
|
293 | + 'colors', |
|
294 | + 'ie', |
|
295 | + 'wp-auth-check', |
|
296 | + 'media-views', |
|
297 | 297 | 'thickbox', |
298 | 298 | 'dashicons', |
299 | - 'wp-jquery-ui-dialog', |
|
300 | - 'jquery-ui-sortable', |
|
299 | + 'wp-jquery-ui-dialog', |
|
300 | + 'jquery-ui-sortable', |
|
301 | 301 | |
302 | - // Settings |
|
303 | - 'gravityview_settings', |
|
302 | + // Settings |
|
303 | + 'gravityview_settings', |
|
304 | 304 | |
305 | - // @todo qTip styles not loading for some reason! |
|
306 | - 'jquery-qtip.js', |
|
307 | - ); |
|
305 | + // @todo qTip styles not loading for some reason! |
|
306 | + 'jquery-qtip.js', |
|
307 | + ); |
|
308 | 308 | |
309 | 309 | $this->remove_conflicts( $wp_styles, $wp_allowed_styles, 'styles' ); |
310 | 310 | |
@@ -324,32 +324,32 @@ discard block |
||
324 | 324 | */ |
325 | 325 | private function remove_conflicts( &$wp_objects, $required_objects, $type = 'scripts' ) { |
326 | 326 | |
327 | - /** |
|
328 | - * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n |
|
329 | - * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles` |
|
330 | - * @param array $required_objects |
|
331 | - */ |
|
332 | - $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects ); |
|
333 | - |
|
334 | - //reset queue |
|
335 | - $queue = array(); |
|
336 | - foreach( $wp_objects->queue as $object ) { |
|
337 | - if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
338 | - $queue[] = $object; |
|
339 | - } |
|
340 | - } |
|
341 | - $wp_objects->queue = $queue; |
|
342 | - |
|
343 | - $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects ); |
|
344 | - |
|
345 | - //unregistering scripts |
|
346 | - $registered = array(); |
|
347 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
348 | - if( in_array( $handle, $required_objects ) ){ |
|
349 | - $registered[ $handle ] = $script_registration; |
|
350 | - } |
|
351 | - } |
|
352 | - $wp_objects->registered = $registered; |
|
327 | + /** |
|
328 | + * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n |
|
329 | + * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles` |
|
330 | + * @param array $required_objects |
|
331 | + */ |
|
332 | + $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects ); |
|
333 | + |
|
334 | + //reset queue |
|
335 | + $queue = array(); |
|
336 | + foreach( $wp_objects->queue as $object ) { |
|
337 | + if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
338 | + $queue[] = $object; |
|
339 | + } |
|
340 | + } |
|
341 | + $wp_objects->queue = $queue; |
|
342 | + |
|
343 | + $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects ); |
|
344 | + |
|
345 | + //unregistering scripts |
|
346 | + $registered = array(); |
|
347 | + foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
348 | + if( in_array( $handle, $required_objects ) ){ |
|
349 | + $registered[ $handle ] = $script_registration; |
|
350 | + } |
|
351 | + } |
|
352 | + $wp_objects->registered = $registered; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -412,7 +412,6 @@ discard block |
||
412 | 412 | * |
413 | 413 | * @deprecated since 1.12 |
414 | 414 | * @see GravityView_Compatibility::get_plugin_status() |
415 | - |
|
416 | 415 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
417 | 416 | */ |
418 | 417 | static function get_plugin_status( $location = '' ) { |
@@ -363,12 +363,12 @@ discard block |
||
363 | 363 | |
364 | 364 | $approvedcolumn = self::get_approved_column( $form['id'] ); |
365 | 365 | |
366 | - /** |
|
367 | - * If the form doesn't contain the approve field, don't assume anything. |
|
368 | - */ |
|
369 | - if( empty( $approvedcolumn ) ) { |
|
370 | - return; |
|
371 | - } |
|
366 | + /** |
|
367 | + * If the form doesn't contain the approve field, don't assume anything. |
|
368 | + */ |
|
369 | + if( empty( $approvedcolumn ) ) { |
|
370 | + return; |
|
371 | + } |
|
372 | 372 | |
373 | 373 | $entry = GFAPI::get_entry( $entry_id ); |
374 | 374 | |
@@ -481,17 +481,17 @@ discard block |
||
481 | 481 | */ |
482 | 482 | static public function get_approved_column( $form ) { |
483 | 483 | |
484 | - if( empty( $form ) ) { |
|
485 | - return null; |
|
486 | - } |
|
484 | + if( empty( $form ) ) { |
|
485 | + return null; |
|
486 | + } |
|
487 | 487 | |
488 | - if( !is_array( $form ) ) { |
|
489 | - $form = GVCommon::get_form( $form ); |
|
490 | - } |
|
488 | + if( !is_array( $form ) ) { |
|
489 | + $form = GVCommon::get_form( $form ); |
|
490 | + } |
|
491 | 491 | |
492 | 492 | foreach( $form['fields'] as $key => $field ) { |
493 | 493 | |
494 | - $field = (array) $field; |
|
494 | + $field = (array) $field; |
|
495 | 495 | |
496 | 496 | if( !empty( $field['gravityview_approved'] ) ) { |
497 | 497 | if( !empty($field['inputs'][0]['id']) ) { |
@@ -499,14 +499,14 @@ discard block |
||
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
502 | - // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
|
503 | - if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) { |
|
504 | - foreach ( $field['inputs'] as $key2 => $input ) { |
|
505 | - if ( strtolower( $input['label'] ) == 'approved' ) { |
|
506 | - return $input['id']; |
|
507 | - } |
|
508 | - } |
|
509 | - } |
|
502 | + // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
|
503 | + if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) { |
|
504 | + foreach ( $field['inputs'] as $key2 => $input ) { |
|
505 | + if ( strtolower( $input['label'] ) == 'approved' ) { |
|
506 | + return $input['id']; |
|
507 | + } |
|
508 | + } |
|
509 | + } |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | return null; |