@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | public function __destruct() { |
95 | - remove_filter( $this->filter_prefix . '_get_template_part', $this->_add_id_specific_templates_callback );; |
|
95 | + remove_filter( $this->filter_prefix . '_get_template_part', $this->_add_id_specific_templates_callback ); ; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -175,55 +175,55 @@ discard block |
||
175 | 175 | |
176 | 176 | if ( $is_view && $post ) { |
177 | 177 | if ( $field_type ) { |
178 | - $specifics []= sprintf( '%spost-%d-view-%d-field-%s-%s.php', $slug_dir, $post->ID, $view_id, $field_type, $slug_name ); |
|
179 | - $inputType && $specifics []= sprintf( '%spost-%d-view-%d-field-%s-%s.php', $slug_dir, $post->ID, $view_id, $inputType, $slug_name ); |
|
180 | - $specifics []= sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $field_type ); |
|
181 | - $inputType && $specifics []= sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $inputType ); |
|
182 | - $specifics []= sprintf( '%spost-%d-field-%s-%s.php', $slug_dir, $post->ID, $field_type, $slug_name ); |
|
183 | - $inputType && $specifics []= sprintf( '%spost-%d-field-%s-%s.php', $slug_dir, $post->ID, $inputType, $slug_name ); |
|
184 | - $specifics []= sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $field_type ); |
|
185 | - $inputType && $specifics []= sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $inputType ); |
|
178 | + $specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s-%s.php', $slug_dir, $post->ID, $view_id, $field_type, $slug_name ); |
|
179 | + $inputType && $specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s-%s.php', $slug_dir, $post->ID, $view_id, $inputType, $slug_name ); |
|
180 | + $specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $field_type ); |
|
181 | + $inputType && $specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $inputType ); |
|
182 | + $specifics [ ] = sprintf( '%spost-%d-field-%s-%s.php', $slug_dir, $post->ID, $field_type, $slug_name ); |
|
183 | + $inputType && $specifics [ ] = sprintf( '%spost-%d-field-%s-%s.php', $slug_dir, $post->ID, $inputType, $slug_name ); |
|
184 | + $specifics [ ] = sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $field_type ); |
|
185 | + $inputType && $specifics [ ] = sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $inputType ); |
|
186 | 186 | } |
187 | 187 | |
188 | - $specifics []= sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $slug_name ); |
|
189 | - $specifics []= sprintf( '%spost-%d-view-%d-field.php', $slug_dir, $post->ID, $view_id ); |
|
190 | - $specifics []= sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $slug_name ); |
|
191 | - $specifics []= sprintf( '%spost-%d-field.php', $slug_dir, $post->ID ); |
|
188 | + $specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $slug_name ); |
|
189 | + $specifics [ ] = sprintf( '%spost-%d-view-%d-field.php', $slug_dir, $post->ID, $view_id ); |
|
190 | + $specifics [ ] = sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $slug_name ); |
|
191 | + $specifics [ ] = sprintf( '%spost-%d-field.php', $slug_dir, $post->ID ); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** Field-specific */ |
195 | 195 | if ( $field_id && $form_id ) { |
196 | 196 | |
197 | 197 | if ( $field_id ) { |
198 | - $specifics []= sprintf( '%sform-%d-field-%d-%s.php', $slug_dir, $form_id, $field_id, $slug_name ); |
|
199 | - $specifics []= sprintf( '%sform-%d-field-%d.php', $slug_dir, $form_id, $field_id ); |
|
198 | + $specifics [ ] = sprintf( '%sform-%d-field-%d-%s.php', $slug_dir, $form_id, $field_id, $slug_name ); |
|
199 | + $specifics [ ] = sprintf( '%sform-%d-field-%d.php', $slug_dir, $form_id, $field_id ); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | if ( $field_type ) { |
203 | - $specifics []= sprintf( '%sform-%d-field-%s-%s.php', $slug_dir, $form_id, $field_type, $slug_name ); |
|
204 | - $inputType && $specifics []= sprintf( '%sform-%d-field-%s-%s.php', $slug_dir, $form_id, $inputType, $slug_name ); |
|
205 | - $specifics []= sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $field_type ); |
|
206 | - $inputType && $specifics []= sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $inputType ); |
|
207 | - |
|
208 | - $specifics []= sprintf( '%sview-%d-field-%s-%s.php', $slug_dir, $view_id, $field_type, $slug_name ); |
|
209 | - $inputType && $specifics []= sprintf( '%sview-%d-field-%s-%s.php', $slug_dir, $view_id, $inputType, $slug_name ); |
|
210 | - $specifics []= sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $field_type ); |
|
211 | - $inputType && $specifics []= sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $inputType ); |
|
212 | - |
|
213 | - $specifics []= sprintf( '%sfield-%s-%s.php', $slug_dir, $field_type, $slug_name ); |
|
214 | - $inputType && $specifics []= sprintf( '%sfield-%s-%s.php', $slug_dir, $inputType, $slug_name ); |
|
215 | - $specifics []= sprintf( '%sfield-%s.php', $slug_dir, $field_type ); |
|
216 | - $inputType && $specifics []= sprintf( '%sfield-%s.php', $slug_dir, $inputType ); |
|
203 | + $specifics [ ] = sprintf( '%sform-%d-field-%s-%s.php', $slug_dir, $form_id, $field_type, $slug_name ); |
|
204 | + $inputType && $specifics [ ] = sprintf( '%sform-%d-field-%s-%s.php', $slug_dir, $form_id, $inputType, $slug_name ); |
|
205 | + $specifics [ ] = sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $field_type ); |
|
206 | + $inputType && $specifics [ ] = sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $inputType ); |
|
207 | + |
|
208 | + $specifics [ ] = sprintf( '%sview-%d-field-%s-%s.php', $slug_dir, $view_id, $field_type, $slug_name ); |
|
209 | + $inputType && $specifics [ ] = sprintf( '%sview-%d-field-%s-%s.php', $slug_dir, $view_id, $inputType, $slug_name ); |
|
210 | + $specifics [ ] = sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $field_type ); |
|
211 | + $inputType && $specifics [ ] = sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $inputType ); |
|
212 | + |
|
213 | + $specifics [ ] = sprintf( '%sfield-%s-%s.php', $slug_dir, $field_type, $slug_name ); |
|
214 | + $inputType && $specifics [ ] = sprintf( '%sfield-%s-%s.php', $slug_dir, $inputType, $slug_name ); |
|
215 | + $specifics [ ] = sprintf( '%sfield-%s.php', $slug_dir, $field_type ); |
|
216 | + $inputType && $specifics [ ] = sprintf( '%sfield-%s.php', $slug_dir, $inputType ); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | 220 | if ( $form_id ) { |
221 | 221 | /** Generic field templates */ |
222 | - $specifics []= sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $slug_name ); |
|
223 | - $specifics []= sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $slug_name ); |
|
222 | + $specifics [ ] = sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $slug_name ); |
|
223 | + $specifics [ ] = sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $slug_name ); |
|
224 | 224 | |
225 | - $specifics []= sprintf( '%sview-%d-field.php', $slug_dir, $view_id ); |
|
226 | - $specifics []= sprintf( '%sform-%d-field.php', $slug_dir, $form_id ); |
|
225 | + $specifics [ ] = sprintf( '%sview-%d-field.php', $slug_dir, $view_id ); |
|
226 | + $specifics [ ] = sprintf( '%sform-%d-field.php', $slug_dir, $form_id ); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | * Ignore some types that conflict. |
232 | 232 | */ |
233 | 233 | if ( ! in_array( $field_type, array( 'notes' ) ) ) { |
234 | - $specifics []= sprintf( '%s.php', $field_type ); |
|
235 | - $specifics []= sprintf( 'fields/%s.php', $field_type ); |
|
234 | + $specifics [ ] = sprintf( '%s.php', $field_type ); |
|
235 | + $specifics [ ] = sprintf( 'fields/%s.php', $field_type ); |
|
236 | 236 | } |
237 | 237 | |
238 | - $specifics []= sprintf( '%sfield-%s.php', $slug_dir, $slug_name ); |
|
239 | - $specifics []= sprintf( '%sfield.php', $slug_dir ); |
|
238 | + $specifics [ ] = sprintf( '%sfield-%s.php', $slug_dir, $slug_name ); |
|
239 | + $specifics [ ] = sprintf( '%sfield.php', $slug_dir ); |
|
240 | 240 | |
241 | 241 | return array_merge( $specifics, $templates ); |
242 | 242 | }; |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | /** Prevent any PHP warnings that may be generated. */ |
267 | 267 | ob_start(); |
268 | 268 | |
269 | - $display_value = \GFCommon::get_lead_field_display( $this->field->field, $value, $this->entry['currency'], false, 'html' ); |
|
269 | + $display_value = \GFCommon::get_lead_field_display( $this->field->field, $value, $this->entry[ 'currency' ], false, 'html' ); |
|
270 | 270 | |
271 | 271 | if ( $errors = ob_get_clean() ) { |
272 | 272 | gravityview()->log->error( 'Errors when calling GFCommon::get_lead_field_display()', array( 'data' => $errors ) ); |
@@ -18,80 +18,80 @@ discard block |
||
18 | 18 | |
19 | 19 | class GravityView_Edit_Entry { |
20 | 20 | |
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | 24 | static $file; |
25 | 25 | |
26 | 26 | static $instance; |
27 | 27 | |
28 | - /** |
|
29 | - * Component instances. |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - public $instances = array(); |
|
28 | + /** |
|
29 | + * Component instances. |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + public $instances = array(); |
|
33 | 33 | |
34 | 34 | |
35 | 35 | function __construct() { |
36 | 36 | |
37 | - self::$file = plugin_dir_path( __FILE__ ); |
|
37 | + self::$file = plugin_dir_path( __FILE__ ); |
|
38 | 38 | |
39 | - if( is_admin() ) { |
|
40 | - $this->load_components( 'admin' ); |
|
41 | - } |
|
39 | + if( is_admin() ) { |
|
40 | + $this->load_components( 'admin' ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - $this->load_components( 'render' ); |
|
44 | + $this->load_components( 'render' ); |
|
45 | 45 | |
46 | - // If GF User Registration Add-on exists |
|
47 | - $this->load_components( 'user-registration' ); |
|
46 | + // If GF User Registration Add-on exists |
|
47 | + $this->load_components( 'user-registration' ); |
|
48 | 48 | |
49 | - $this->add_hooks(); |
|
49 | + $this->add_hooks(); |
|
50 | 50 | |
51 | 51 | // Process hooks for addons that may or may not be present |
52 | 52 | $this->addon_specific_hooks(); |
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | - static function getInstance() { |
|
56 | + static function getInstance() { |
|
57 | 57 | |
58 | - if( empty( self::$instance ) ) { |
|
59 | - self::$instance = new GravityView_Edit_Entry; |
|
60 | - } |
|
58 | + if( empty( self::$instance ) ) { |
|
59 | + self::$instance = new GravityView_Edit_Entry; |
|
60 | + } |
|
61 | 61 | |
62 | - return self::$instance; |
|
63 | - } |
|
62 | + return self::$instance; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - private function load_components( $component ) { |
|
66 | + private function load_components( $component ) { |
|
67 | 67 | |
68 | - $dir = trailingslashit( self::$file ); |
|
68 | + $dir = trailingslashit( self::$file ); |
|
69 | 69 | |
70 | - $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
71 | - $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
70 | + $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
71 | + $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
72 | 72 | |
73 | - // Loads component and pass extension's instance so that component can |
|
74 | - // talk each other. |
|
75 | - require_once $filename; |
|
76 | - $this->instances[ $component ] = new $classname( $this ); |
|
77 | - $this->instances[ $component ]->load(); |
|
73 | + // Loads component and pass extension's instance so that component can |
|
74 | + // talk each other. |
|
75 | + require_once $filename; |
|
76 | + $this->instances[ $component ] = new $classname( $this ); |
|
77 | + $this->instances[ $component ]->load(); |
|
78 | 78 | |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | - private function add_hooks() { |
|
81 | + private function add_hooks() { |
|
82 | 82 | |
83 | - // Add front-end access to Gravity Forms delete file action |
|
84 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
83 | + // Add front-end access to Gravity Forms delete file action |
|
84 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
85 | 85 | |
86 | - // Make sure this hook is run for non-admins |
|
87 | - add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
86 | + // Make sure this hook is run for non-admins |
|
87 | + add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
88 | 88 | |
89 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
89 | + add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
90 | 90 | |
91 | - // add template path to check for field |
|
92 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
91 | + // add template path to check for field |
|
92 | + add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
93 | 93 | |
94 | - } |
|
94 | + } |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Trigger hooks that are normally run in the admin for Addons, but need to be triggered manually because we're not in the admin |
@@ -105,77 +105,77 @@ discard block |
||
105 | 105 | |
106 | 106 | } |
107 | 107 | |
108 | - /** |
|
109 | - * Include this extension templates path |
|
110 | - * @param array $file_paths List of template paths ordered |
|
111 | - */ |
|
112 | - public function add_template_path( $file_paths ) { |
|
113 | - |
|
114 | - // Index 100 is the default GravityView template path. |
|
115 | - $file_paths[ 110 ] = self::$file; |
|
116 | - |
|
117 | - return $file_paths; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * |
|
122 | - * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
123 | - * |
|
124 | - * @param $view_id int GravityView view id |
|
125 | - * @param $form_id int Gravity Forms form id |
|
126 | - * @param $entry_id int Gravity Forms entry id |
|
127 | - * @return string |
|
128 | - */ |
|
129 | - public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
130 | - return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * The edit entry link creates a secure link with a nonce |
|
136 | - * |
|
137 | - * It also mimics the URL structure Gravity Forms expects to have so that |
|
138 | - * it formats the display of the edit form like it does in the backend, like |
|
139 | - * "You can edit this post from the post page" fields, for example. |
|
140 | - * |
|
141 | - * @param $entry array Gravity Forms entry object |
|
142 | - * @param $view_id int GravityView view id |
|
143 | - * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
144 | - * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
148 | - |
|
149 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
150 | - |
|
151 | - $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
152 | - |
|
153 | - $url = add_query_arg( array( |
|
154 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
155 | - ), $base ); |
|
156 | - |
|
157 | - if( $post_id ) { |
|
158 | - $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * Allow passing params to dynamically populate entry with values |
|
163 | - * @since 1.9.2 |
|
164 | - */ |
|
165 | - if( !empty( $field_values ) ) { |
|
166 | - |
|
167 | - if( is_array( $field_values ) ) { |
|
168 | - // If already an array, no parse_str() needed |
|
169 | - $params = $field_values; |
|
170 | - } else { |
|
171 | - parse_str( $field_values, $params ); |
|
172 | - } |
|
173 | - |
|
174 | - $url = add_query_arg( $params, $url ); |
|
175 | - } |
|
176 | - |
|
177 | - return $url; |
|
178 | - } |
|
108 | + /** |
|
109 | + * Include this extension templates path |
|
110 | + * @param array $file_paths List of template paths ordered |
|
111 | + */ |
|
112 | + public function add_template_path( $file_paths ) { |
|
113 | + |
|
114 | + // Index 100 is the default GravityView template path. |
|
115 | + $file_paths[ 110 ] = self::$file; |
|
116 | + |
|
117 | + return $file_paths; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * |
|
122 | + * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
123 | + * |
|
124 | + * @param $view_id int GravityView view id |
|
125 | + * @param $form_id int Gravity Forms form id |
|
126 | + * @param $entry_id int Gravity Forms entry id |
|
127 | + * @return string |
|
128 | + */ |
|
129 | + public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
130 | + return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * The edit entry link creates a secure link with a nonce |
|
136 | + * |
|
137 | + * It also mimics the URL structure Gravity Forms expects to have so that |
|
138 | + * it formats the display of the edit form like it does in the backend, like |
|
139 | + * "You can edit this post from the post page" fields, for example. |
|
140 | + * |
|
141 | + * @param $entry array Gravity Forms entry object |
|
142 | + * @param $view_id int GravityView view id |
|
143 | + * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
144 | + * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
148 | + |
|
149 | + $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
150 | + |
|
151 | + $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
152 | + |
|
153 | + $url = add_query_arg( array( |
|
154 | + 'edit' => wp_create_nonce( $nonce_key ) |
|
155 | + ), $base ); |
|
156 | + |
|
157 | + if( $post_id ) { |
|
158 | + $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * Allow passing params to dynamically populate entry with values |
|
163 | + * @since 1.9.2 |
|
164 | + */ |
|
165 | + if( !empty( $field_values ) ) { |
|
166 | + |
|
167 | + if( is_array( $field_values ) ) { |
|
168 | + // If already an array, no parse_str() needed |
|
169 | + $params = $field_values; |
|
170 | + } else { |
|
171 | + parse_str( $field_values, $params ); |
|
172 | + } |
|
173 | + |
|
174 | + $url = add_query_arg( $params, $url ); |
|
175 | + } |
|
176 | + |
|
177 | + return $url; |
|
178 | + } |
|
179 | 179 | |
180 | 180 | /** |
181 | 181 | * Edit mode doesn't allow certain field types. |
@@ -229,82 +229,82 @@ discard block |
||
229 | 229 | } |
230 | 230 | |
231 | 231 | |
232 | - /** |
|
233 | - * checks if user has permissions to edit a specific entry |
|
234 | - * |
|
235 | - * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
236 | - * |
|
237 | - * @param array $entry Gravity Forms entry array |
|
238 | - * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
239 | - * @return bool |
|
240 | - */ |
|
241 | - public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
232 | + /** |
|
233 | + * checks if user has permissions to edit a specific entry |
|
234 | + * |
|
235 | + * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
236 | + * |
|
237 | + * @param array $entry Gravity Forms entry array |
|
238 | + * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
239 | + * @return bool |
|
240 | + */ |
|
241 | + public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
242 | 242 | |
243 | - // No permission by default |
|
244 | - $user_can_edit = false; |
|
243 | + // No permission by default |
|
244 | + $user_can_edit = false; |
|
245 | 245 | |
246 | - // If they can edit any entries (as defined in Gravity Forms) |
|
247 | - // Or if they can edit other people's entries |
|
248 | - // Then we're good. |
|
249 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
246 | + // If they can edit any entries (as defined in Gravity Forms) |
|
247 | + // Or if they can edit other people's entries |
|
248 | + // Then we're good. |
|
249 | + if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
250 | 250 | |
251 | - gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
251 | + gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
252 | 252 | |
253 | - $user_can_edit = true; |
|
253 | + $user_can_edit = true; |
|
254 | 254 | |
255 | - } else if( !isset( $entry['created_by'] ) ) { |
|
255 | + } else if( !isset( $entry['created_by'] ) ) { |
|
256 | 256 | |
257 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
257 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
258 | 258 | |
259 | - $user_can_edit = false; |
|
259 | + $user_can_edit = false; |
|
260 | 260 | |
261 | - } else { |
|
261 | + } else { |
|
262 | 262 | |
263 | - // get user_edit setting |
|
264 | - if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
265 | - // if View ID not specified or is the current view |
|
263 | + // get user_edit setting |
|
264 | + if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
265 | + // if View ID not specified or is the current view |
|
266 | 266 | // @deprecated path |
267 | - $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
268 | - } else { |
|
269 | - // in case is specified and not the current view |
|
270 | - $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
271 | - } |
|
267 | + $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
268 | + } else { |
|
269 | + // in case is specified and not the current view |
|
270 | + $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
271 | + } |
|
272 | 272 | |
273 | - $current_user = wp_get_current_user(); |
|
273 | + $current_user = wp_get_current_user(); |
|
274 | 274 | |
275 | - // User edit is disabled |
|
276 | - if( empty( $user_edit ) ) { |
|
275 | + // User edit is disabled |
|
276 | + if( empty( $user_edit ) ) { |
|
277 | 277 | |
278 | - gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
278 | + gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
279 | 279 | |
280 | - $user_can_edit = false; |
|
281 | - } |
|
280 | + $user_can_edit = false; |
|
281 | + } |
|
282 | 282 | |
283 | - // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
284 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
283 | + // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
284 | + else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
285 | 285 | |
286 | - gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
286 | + gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
287 | 287 | |
288 | - $user_can_edit = true; |
|
288 | + $user_can_edit = true; |
|
289 | 289 | |
290 | - } else if( ! is_user_logged_in() ) { |
|
290 | + } else if( ! is_user_logged_in() ) { |
|
291 | 291 | |
292 | - gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
293 | - } |
|
292 | + gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
293 | + } |
|
294 | 294 | |
295 | - } |
|
295 | + } |
|
296 | 296 | |
297 | - /** |
|
298 | - * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
299 | - * @since 1.15 Added `$entry` and `$view_id` parameters |
|
300 | - * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
301 | - * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
302 | - * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
303 | - */ |
|
304 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
297 | + /** |
|
298 | + * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
299 | + * @since 1.15 Added `$entry` and `$view_id` parameters |
|
300 | + * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
301 | + * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
302 | + * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
303 | + */ |
|
304 | + $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
305 | 305 | |
306 | - return (bool)$user_can_edit; |
|
307 | - } |
|
306 | + return (bool)$user_can_edit; |
|
307 | + } |
|
308 | 308 | |
309 | 309 | |
310 | 310 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | self::$file = plugin_dir_path( __FILE__ ); |
38 | 38 | |
39 | - if( is_admin() ) { |
|
39 | + if ( is_admin() ) { |
|
40 | 40 | $this->load_components( 'admin' ); |
41 | 41 | } |
42 | 42 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | static function getInstance() { |
57 | 57 | |
58 | - if( empty( self::$instance ) ) { |
|
58 | + if ( empty( self::$instance ) ) { |
|
59 | 59 | self::$instance = new GravityView_Edit_Entry; |
60 | 60 | } |
61 | 61 | |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | private function add_hooks() { |
82 | 82 | |
83 | 83 | // Add front-end access to Gravity Forms delete file action |
84 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
84 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file' ) ); |
|
85 | 85 | |
86 | 86 | // Make sure this hook is run for non-admins |
87 | - add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
87 | + add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file' ) ); |
|
88 | 88 | |
89 | 89 | add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
90 | 90 | |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | */ |
100 | 100 | private function addon_specific_hooks() { |
101 | 101 | |
102 | - if( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
103 | - add_filter('gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script')); |
|
102 | + if ( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
103 | + add_filter( 'gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script' ) ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | } |
@@ -146,15 +146,15 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
148 | 148 | |
149 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
149 | + $nonce_key = self::get_nonce_key( $view_id, $entry[ 'form_id' ], $entry[ 'id' ] ); |
|
150 | 150 | |
151 | - $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
151 | + $base = gv_entry_link( $entry, $post_id ?: $view_id ); |
|
152 | 152 | |
153 | 153 | $url = add_query_arg( array( |
154 | 154 | 'edit' => wp_create_nonce( $nonce_key ) |
155 | 155 | ), $base ); |
156 | 156 | |
157 | - if( $post_id ) { |
|
157 | + if ( $post_id ) { |
|
158 | 158 | $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
159 | 159 | } |
160 | 160 | |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | * Allow passing params to dynamically populate entry with values |
163 | 163 | * @since 1.9.2 |
164 | 164 | */ |
165 | - if( !empty( $field_values ) ) { |
|
165 | + if ( ! empty( $field_values ) ) { |
|
166 | 166 | |
167 | - if( is_array( $field_values ) ) { |
|
167 | + if ( is_array( $field_values ) ) { |
|
168 | 168 | // If already an array, no parse_str() needed |
169 | 169 | $params = $field_values; |
170 | 170 | } else { |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function modify_field_blacklist( $fields = array(), $context = NULL ) { |
187 | 187 | |
188 | - if( empty( $context ) || $context !== 'edit' ) { |
|
188 | + if ( empty( $context ) || $context !== 'edit' ) { |
|
189 | 189 | return $fields; |
190 | 190 | } |
191 | 191 | |
@@ -246,25 +246,25 @@ discard block |
||
246 | 246 | // If they can edit any entries (as defined in Gravity Forms) |
247 | 247 | // Or if they can edit other people's entries |
248 | 248 | // Then we're good. |
249 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
249 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry[ 'id' ] ) ) { |
|
250 | 250 | |
251 | 251 | gravityview()->log->debug( 'User has ability to edit all entries.' ); |
252 | 252 | |
253 | 253 | $user_can_edit = true; |
254 | 254 | |
255 | - } else if( !isset( $entry['created_by'] ) ) { |
|
255 | + } else if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
256 | 256 | |
257 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
257 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.' ); |
|
258 | 258 | |
259 | 259 | $user_can_edit = false; |
260 | 260 | |
261 | 261 | } else { |
262 | 262 | |
263 | 263 | // get user_edit setting |
264 | - if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
264 | + if ( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
265 | 265 | // if View ID not specified or is the current view |
266 | 266 | // @deprecated path |
267 | - $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
267 | + $user_edit = GravityView_View::getInstance()->getAtts( 'user_edit' ); |
|
268 | 268 | } else { |
269 | 269 | // in case is specified and not the current view |
270 | 270 | $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $current_user = wp_get_current_user(); |
274 | 274 | |
275 | 275 | // User edit is disabled |
276 | - if( empty( $user_edit ) ) { |
|
276 | + if ( empty( $user_edit ) ) { |
|
277 | 277 | |
278 | 278 | gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
279 | 279 | |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
284 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
284 | + else if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
285 | 285 | |
286 | 286 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
287 | 287 | |
288 | 288 | $user_can_edit = true; |
289 | 289 | |
290 | - } else if( ! is_user_logged_in() ) { |
|
290 | + } else if ( ! is_user_logged_in() ) { |
|
291 | 291 | |
292 | 292 | gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
293 | 293 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | private function __construct() {} |
86 | 86 | |
87 | 87 | private function initialize() { |
88 | - add_action( 'wp', array( $this, 'parse_content'), 11 ); |
|
88 | + add_action( 'wp', array( $this, 'parse_content' ), 11 ); |
|
89 | 89 | add_filter( 'parse_query', array( $this, 'parse_query_fix_frontpage' ), 10 ); |
90 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 ); |
|
90 | + add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 ); |
|
91 | 91 | |
92 | 92 | // Enqueue scripts and styles after GravityView_Template::register_styles() |
93 | 93 | add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 ); |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | |
237 | 237 | $this->context_view_id = $view_id; |
238 | 238 | |
239 | - } elseif ( isset( $_GET['gvid'] ) && $multiple_views ) { |
|
239 | + } elseif ( isset( $_GET[ 'gvid' ] ) && $multiple_views ) { |
|
240 | 240 | /** |
241 | 241 | * used on a has_multiple_views context |
242 | 242 | * @see GravityView_API::entry_link |
243 | 243 | */ |
244 | - $this->context_view_id = $_GET['gvid']; |
|
244 | + $this->context_view_id = $_GET[ 'gvid' ]; |
|
245 | 245 | |
246 | 246 | } elseif ( ! $multiple_views ) { |
247 | 247 | $array_keys = array_keys( $this->getGvOutputData()->get_views() ); |
@@ -278,25 +278,25 @@ discard block |
||
278 | 278 | global $wp_rewrite; |
279 | 279 | |
280 | 280 | $is_front_page = ( $query->is_home || $query->is_page ); |
281 | - $show_on_front = ( 'page' === get_option('show_on_front') ); |
|
282 | - $front_page_id = get_option('page_on_front'); |
|
281 | + $show_on_front = ( 'page' === get_option( 'show_on_front' ) ); |
|
282 | + $front_page_id = get_option( 'page_on_front' ); |
|
283 | 283 | |
284 | - if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
284 | + if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
285 | 285 | |
286 | 286 | // Force to be an array, potentially a query string ( entry=16 ) |
287 | 287 | $_query = wp_parse_args( $query->query ); |
288 | 288 | |
289 | 289 | // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. |
290 | - if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { |
|
291 | - unset( $_query['pagename'] ); |
|
290 | + if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) { |
|
291 | + unset( $_query[ 'pagename' ] ); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | // this is where will break from core wordpress |
295 | 295 | /** @internal Don't use this filter; it will be unnecessary soon - it's just a patch for specific use case */ |
296 | 296 | $ignore = apply_filters( 'gravityview/internal/ignored_endpoints', array( 'preview', 'page', 'paged', 'cpage' ), $query ); |
297 | 297 | $endpoints = \GV\Utils::get( $wp_rewrite, 'endpoints' ); |
298 | - foreach ( (array) $endpoints as $endpoint ) { |
|
299 | - $ignore[] = $endpoint[1]; |
|
298 | + foreach ( (array)$endpoints as $endpoint ) { |
|
299 | + $ignore[ ] = $endpoint[ 1 ]; |
|
300 | 300 | } |
301 | 301 | unset( $endpoints ); |
302 | 302 | |
@@ -306,21 +306,21 @@ discard block |
||
306 | 306 | // - The query includes keys that are associated with registered endpoints. `entry`, for example. |
307 | 307 | if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) { |
308 | 308 | |
309 | - $qv =& $query->query_vars; |
|
309 | + $qv = & $query->query_vars; |
|
310 | 310 | |
311 | 311 | // Prevent redirect when on the single entry endpoint |
312 | - if( self::is_single_entry() ) { |
|
312 | + if ( self::is_single_entry() ) { |
|
313 | 313 | add_filter( 'redirect_canonical', '__return_false' ); |
314 | 314 | } |
315 | 315 | |
316 | 316 | $query->is_page = true; |
317 | 317 | $query->is_home = false; |
318 | - $qv['page_id'] = $front_page_id; |
|
318 | + $qv[ 'page_id' ] = $front_page_id; |
|
319 | 319 | |
320 | 320 | // Correct <!--nextpage--> for page_on_front |
321 | - if ( ! empty( $qv['paged'] ) ) { |
|
322 | - $qv['page'] = $qv['paged']; |
|
323 | - unset( $qv['paged'] ); |
|
321 | + if ( ! empty( $qv[ 'paged' ] ) ) { |
|
322 | + $qv[ 'page' ] = $qv[ 'paged' ]; |
|
323 | + unset( $qv[ 'paged' ] ); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | |
351 | 351 | $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' ); |
352 | 352 | |
353 | - $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null ); |
|
353 | + $post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null ); |
|
354 | 354 | $this->setPostId( $post_id ); |
355 | 355 | $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false; |
356 | 356 | $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) ); |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | |
387 | 387 | $search_method = GravityView_Widget_Search::getInstance()->get_search_method(); |
388 | 388 | |
389 | - if( 'post' === $search_method ) { |
|
389 | + if ( 'post' === $search_method ) { |
|
390 | 390 | $get = $_POST; |
391 | 391 | } else { |
392 | 392 | $get = $_GET; |
@@ -443,20 +443,20 @@ discard block |
||
443 | 443 | * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop |
444 | 444 | * @param array $entry Current entry |
445 | 445 | */ |
446 | - $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry ); |
|
446 | + $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry ); |
|
447 | 447 | |
448 | 448 | if ( ! $apply_outside_loop ) { |
449 | 449 | return $title; |
450 | 450 | } |
451 | 451 | |
452 | 452 | // User reported WooCommerce doesn't pass two args. |
453 | - if ( empty( $passed_post_id ) ) { |
|
453 | + if ( empty( $passed_post_id ) ) { |
|
454 | 454 | return $title; |
455 | 455 | } |
456 | 456 | |
457 | 457 | // Don't modify the title for anything other than the current view/post. |
458 | 458 | // This is true for embedded shortcodes and Views. |
459 | - if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { |
|
459 | + if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) { |
|
460 | 460 | return $title; |
461 | 461 | } |
462 | 462 | |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | $view_meta = $this->getGvOutputData()->get_view( $context_view_id ); |
469 | 469 | } else { |
470 | 470 | foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { |
471 | - if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) { |
|
471 | + if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) { |
|
472 | 472 | $view_meta = $view_data; |
473 | 473 | break; |
474 | 474 | } |
@@ -476,12 +476,12 @@ discard block |
||
476 | 476 | } |
477 | 477 | |
478 | 478 | /** Deprecated stuff in the future. See the branch above. */ |
479 | - if ( ! empty( $view_meta['atts']['single_title'] ) ) { |
|
479 | + if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) { |
|
480 | 480 | |
481 | - $title = $view_meta['atts']['single_title']; |
|
481 | + $title = $view_meta[ 'atts' ][ 'single_title' ]; |
|
482 | 482 | |
483 | 483 | // We are allowing HTML in the fields, so no escaping the output |
484 | - $title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry ); |
|
484 | + $title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry ); |
|
485 | 485 | |
486 | 486 | $title = do_shortcode( $title ); |
487 | 487 | } |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | |
553 | 553 | $context = GravityView_View::getInstance()->getContext(); |
554 | 554 | |
555 | - switch( $context ) { |
|
555 | + switch ( $context ) { |
|
556 | 556 | case 'directory': |
557 | 557 | $tab = __( 'Multiple Entries', 'gravityview' ); |
558 | 558 | break; |
@@ -566,12 +566,12 @@ discard block |
||
566 | 566 | } |
567 | 567 | |
568 | 568 | |
569 | - $title = sprintf( esc_html_x('The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
569 | + $title = sprintf( esc_html_x( 'The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
570 | 570 | $edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $view_id, $context ) ); |
571 | - $action_text = sprintf( esc_html__('Add fields to %s', 'gravityview' ), $tab ); |
|
571 | + $action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab ); |
|
572 | 572 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
573 | 573 | |
574 | - $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url(plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
574 | + $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
575 | 575 | $output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message ); |
576 | 576 | |
577 | 577 | echo GVCommon::generate_notice( $output . $image, 'gv-error error', 'edit_gravityview', $view_id ); |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | $direct_access = apply_filters( 'gravityview_direct_access', true, $view->ID ); |
620 | 620 | $embed_only = $view->settings->get( 'embed_only' ); |
621 | 621 | |
622 | - if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
622 | + if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
623 | 623 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
624 | 624 | } |
625 | 625 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | $datetime_format = 'Y-m-d H:i:s'; |
667 | 667 | $search_is_outside_view_bounds = false; |
668 | 668 | |
669 | - if( ! empty( $search_criteria[ $key ] ) ) { |
|
669 | + if ( ! empty( $search_criteria[ $key ] ) ) { |
|
670 | 670 | |
671 | 671 | $search_date = strtotime( $search_criteria[ $key ] ); |
672 | 672 | |
@@ -694,14 +694,14 @@ discard block |
||
694 | 694 | if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { |
695 | 695 | |
696 | 696 | // Then we override the search and re-set the start date |
697 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true ); |
|
697 | + $return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true ); |
|
698 | 698 | } |
699 | 699 | } |
700 | 700 | } |
701 | 701 | |
702 | - if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { |
|
702 | + if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) { |
|
703 | 703 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue. |
704 | - if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { |
|
704 | + if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) { |
|
705 | 705 | gravityview()->log->error( 'Invalid search: the start date is after the end date.', array( 'data' => $return_search_criteria ) ); |
706 | 706 | } |
707 | 707 | } |
@@ -720,19 +720,19 @@ discard block |
||
720 | 720 | public static function process_search_only_approved( $args, $search_criteria ) { |
721 | 721 | |
722 | 722 | /** @since 1.19 */ |
723 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
723 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
724 | 724 | gravityview()->log->debug( 'User can moderate entries; showing all approval statuses' ); |
725 | 725 | return $search_criteria; |
726 | 726 | } |
727 | 727 | |
728 | - if ( ! empty( $args['show_only_approved'] ) ) { |
|
728 | + if ( ! empty( $args[ 'show_only_approved' ] ) ) { |
|
729 | 729 | |
730 | - $search_criteria['field_filters'][] = array( |
|
730 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
731 | 731 | 'key' => GravityView_Entry_Approval::meta_key, |
732 | 732 | 'value' => GravityView_Entry_Approval_Status::APPROVED |
733 | 733 | ); |
734 | 734 | |
735 | - $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met |
|
735 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met |
|
736 | 736 | |
737 | 737 | gravityview()->log->debug( '[process_search_only_approved] Search Criteria if show only approved: ', array( 'data' => $search_criteria ) ); |
738 | 738 | } |
@@ -759,18 +759,18 @@ discard block |
||
759 | 759 | */ |
760 | 760 | public static function is_entry_approved( $entry, $args = array() ) { |
761 | 761 | |
762 | - if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { |
|
762 | + if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) { |
|
763 | 763 | // is implicitly approved if entry is null or View settings doesn't require to check for approval |
764 | 764 | return true; |
765 | 765 | } |
766 | 766 | |
767 | 767 | /** @since 1.19 */ |
768 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
768 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
769 | 769 | gravityview()->log->debug( 'User can moderate entries, so entry is approved for viewing' ); |
770 | 770 | return true; |
771 | 771 | } |
772 | 772 | |
773 | - $is_approved = gform_get_meta( $entry['id'], GravityView_Entry_Approval::meta_key ); |
|
773 | + $is_approved = gform_get_meta( $entry[ 'id' ], GravityView_Entry_Approval::meta_key ); |
|
774 | 774 | |
775 | 775 | return GravityView_Entry_Approval_Status::is_approved( $is_approved ); |
776 | 776 | } |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | * Compatibility with filters hooking in `gravityview_search_criteria` instead of `gravityview_fe_search_criteria`. |
795 | 795 | */ |
796 | 796 | $criteria = apply_filters( 'gravityview_search_criteria', array(), array( $form_id ), \GV\Utils::get( $args, 'id' ) ); |
797 | - $search_criteria = isset( $criteria['search_criteria'] ) ? $criteria['search_criteria'] : array( 'field_filters' => array() ); |
|
797 | + $search_criteria = isset( $criteria[ 'search_criteria' ] ) ? $criteria[ 'search_criteria' ] : array( 'field_filters' => array() ); |
|
798 | 798 | |
799 | 799 | /** |
800 | 800 | * @filter `gravityview_fe_search_criteria` Modify the search criteria |
@@ -810,29 +810,29 @@ discard block |
||
810 | 810 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', array( 'data' =>$search_criteria ) ); |
811 | 811 | |
812 | 812 | // implicity search |
813 | - if ( ! empty( $args['search_value'] ) ) { |
|
813 | + if ( ! empty( $args[ 'search_value' ] ) ) { |
|
814 | 814 | |
815 | 815 | // Search operator options. Options: `is` or `contains` |
816 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains'; |
|
816 | + $operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains'; |
|
817 | 817 | |
818 | - $search_criteria['field_filters'][] = array( |
|
818 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
819 | 819 | 'key' => \GV\Utils::_GET( 'search_field', \GV\Utils::get( $args, 'search_field' ) ), // The field ID to search |
820 | - 'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes. |
|
820 | + 'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes. |
|
821 | 821 | 'operator' => $operator, |
822 | 822 | ); |
823 | 823 | |
824 | 824 | // Lock search mode to "all" with implicit presearch filter. |
825 | - $search_criteria['field_filters']['mode'] = 'all'; |
|
825 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; |
|
826 | 826 | } |
827 | 827 | |
828 | - if( $search_criteria !== $original_search_criteria ) { |
|
828 | + if ( $search_criteria !== $original_search_criteria ) { |
|
829 | 829 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after implicity search: ', array( 'data' => $search_criteria ) ); |
830 | 830 | } |
831 | 831 | |
832 | 832 | // Handle setting date range |
833 | 833 | $search_criteria = self::process_search_dates( $args, $search_criteria ); |
834 | 834 | |
835 | - if( $search_criteria !== $original_search_criteria ) { |
|
835 | + if ( $search_criteria !== $original_search_criteria ) { |
|
836 | 836 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after date params: ', array( 'data' => $search_criteria ) ); |
837 | 837 | } |
838 | 838 | |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | * @filter `gravityview_status` Modify entry status requirements to be included in search results. |
844 | 844 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash` |
845 | 845 | */ |
846 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args ); |
|
846 | + $search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args ); |
|
847 | 847 | |
848 | 848 | return $search_criteria; |
849 | 849 | } |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | 'search_criteria' => $search_criteria, |
957 | 957 | 'sorting' => self::updateViewSorting( $args, $form_id ), |
958 | 958 | 'paging' => $paging, |
959 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true, |
|
959 | + 'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true, |
|
960 | 960 | ); |
961 | 961 | |
962 | 962 | /** |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. |
982 | 982 | * @param array $args View configuration args. |
983 | 983 | */ |
984 | - $parameters = apply_filters( 'gravityview_get_entries_'.\GV\Utils::get( $args, 'id' ), $parameters, $args, $form_id ); |
|
984 | + $parameters = apply_filters( 'gravityview_get_entries_' . \GV\Utils::get( $args, 'id' ), $parameters, $args, $form_id ); |
|
985 | 985 | |
986 | 986 | gravityview()->log->debug( '$parameters passed to gravityview_get_entries(): ', array( 'data' => $parameters ) ); |
987 | 987 | |
@@ -1006,17 +1006,17 @@ discard block |
||
1006 | 1006 | $default_page_size = apply_filters( 'gravityview_default_page_size', 25 ); |
1007 | 1007 | |
1008 | 1008 | // Paging & offset |
1009 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : $default_page_size; |
|
1009 | + $page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : $default_page_size; |
|
1010 | 1010 | |
1011 | 1011 | if ( -1 === $page_size ) { |
1012 | 1012 | $page_size = PHP_INT_MAX; |
1013 | 1013 | } |
1014 | 1014 | |
1015 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
1015 | + $curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] ); |
|
1016 | 1016 | $offset = ( $curr_page - 1 ) * $page_size; |
1017 | 1017 | |
1018 | - if ( ! empty( $args['offset'] ) ) { |
|
1019 | - $offset += intval( $args['offset'] ); |
|
1018 | + if ( ! empty( $args[ 'offset' ] ) ) { |
|
1019 | + $offset += intval( $args[ 'offset' ] ); |
|
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | $paging = array( |
@@ -1040,8 +1040,8 @@ discard block |
||
1040 | 1040 | */ |
1041 | 1041 | public static function updateViewSorting( $args, $form_id ) { |
1042 | 1042 | $sorting = array(); |
1043 | - $sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : \GV\Utils::get( $args, 'sort_field' ); |
|
1044 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : \GV\Utils::get( $args, 'sort_direction' ); |
|
1043 | + $sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : \GV\Utils::get( $args, 'sort_field' ); |
|
1044 | + $sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : \GV\Utils::get( $args, 'sort_direction' ); |
|
1045 | 1045 | |
1046 | 1046 | $sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id ); |
1047 | 1047 | |
@@ -1058,12 +1058,12 @@ discard block |
||
1058 | 1058 | $form = GFAPI::get_form( $form_id ); |
1059 | 1059 | |
1060 | 1060 | // Get the first GF_Field field ID, set as the key for entry randomization |
1061 | - if( ! empty( $form['fields'] ) ) { |
|
1061 | + if ( ! empty( $form[ 'fields' ] ) ) { |
|
1062 | 1062 | |
1063 | 1063 | /** @var GF_Field $field */ |
1064 | - foreach ( $form['fields'] as $field ) { |
|
1064 | + foreach ( $form[ 'fields' ] as $field ) { |
|
1065 | 1065 | |
1066 | - if( ! is_a( $field, 'GF_Field' ) ) { |
|
1066 | + if ( ! is_a( $field, 'GF_Field' ) ) { |
|
1067 | 1067 | continue; |
1068 | 1068 | } |
1069 | 1069 | |
@@ -1107,11 +1107,11 @@ discard block |
||
1107 | 1107 | |
1108 | 1108 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
1109 | 1109 | |
1110 | - if( ! $sort_field ) { |
|
1110 | + if ( ! $sort_field ) { |
|
1111 | 1111 | return $sort_field_id; |
1112 | 1112 | } |
1113 | 1113 | |
1114 | - switch ( $sort_field['type'] ) { |
|
1114 | + switch ( $sort_field[ 'type' ] ) { |
|
1115 | 1115 | |
1116 | 1116 | case 'address': |
1117 | 1117 | // Sorting by full address |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | */ |
1129 | 1129 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
1130 | 1130 | |
1131 | - switch( strtolower( $address_part ) ){ |
|
1131 | + switch ( strtolower( $address_part ) ) { |
|
1132 | 1132 | case 'street': |
1133 | 1133 | $sort_field_id .= '.1'; |
1134 | 1134 | break; |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | */ |
1209 | 1209 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
1210 | 1210 | |
1211 | - if ( empty( $single_entry ) ){ |
|
1211 | + if ( empty( $single_entry ) ) { |
|
1212 | 1212 | return false; |
1213 | 1213 | } else { |
1214 | 1214 | return $single_entry; |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | $views = $this->getGvOutputData()->get_views(); |
1231 | 1231 | |
1232 | 1232 | foreach ( $views as $view_id => $data ) { |
1233 | - $view = \GV\View::by_id( $data['id'] ); |
|
1233 | + $view = \GV\View::by_id( $data[ 'id' ] ); |
|
1234 | 1234 | $view_id = $view->ID; |
1235 | 1235 | $template_id = gravityview_get_template_id( $view->ID ); |
1236 | 1236 | $data = $view->as_data(); |
@@ -1239,7 +1239,7 @@ discard block |
||
1239 | 1239 | * Don't enqueue the scripts or styles if it's not going to be displayed. |
1240 | 1240 | * @since 1.15 |
1241 | 1241 | */ |
1242 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1242 | + if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1243 | 1243 | continue; |
1244 | 1244 | } |
1245 | 1245 | |
@@ -1256,13 +1256,13 @@ discard block |
||
1256 | 1256 | * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox` |
1257 | 1257 | * @param string $script_slug If you want to use a different lightbox script, return the name of it here. |
1258 | 1258 | */ |
1259 | - $js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1259 | + $js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1260 | 1260 | |
1261 | 1261 | /** |
1262 | 1262 | * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox` |
1263 | 1263 | * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here. |
1264 | 1264 | */ |
1265 | - $css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1265 | + $css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1266 | 1266 | } |
1267 | 1267 | |
1268 | 1268 | /** |
@@ -1270,19 +1270,19 @@ discard block |
||
1270 | 1270 | * @see https://github.com/katzwebservices/GravityView/issues/536 |
1271 | 1271 | * @since 1.15 |
1272 | 1272 | */ |
1273 | - if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { |
|
1274 | - $css_dependencies[] = 'dashicons'; |
|
1273 | + if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) { |
|
1274 | + $css_dependencies[ ] = 'dashicons'; |
|
1275 | 1275 | } |
1276 | 1276 | |
1277 | 1277 | wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
1278 | 1278 | |
1279 | 1279 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
1280 | 1280 | |
1281 | - wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true ); |
|
1281 | + wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ), GravityView_Plugin::version, true ); |
|
1282 | 1282 | |
1283 | 1283 | wp_enqueue_script( 'gravityview-fe-view' ); |
1284 | 1284 | |
1285 | - if ( ! empty( $data['atts']['sort_columns'] ) ) { |
|
1285 | + if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) { |
|
1286 | 1286 | wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
1287 | 1287 | } |
1288 | 1288 | |
@@ -1345,7 +1345,7 @@ discard block |
||
1345 | 1345 | public static function add_style( $template_id ) { |
1346 | 1346 | |
1347 | 1347 | if ( ! empty( $template_id ) && wp_style_is( 'gravityview_style_' . $template_id, 'registered' ) ) { |
1348 | - gravityview()->log->debug( 'Adding extra template style for {template_id}', array( 'template_id' => $template_id ) ); |
|
1348 | + gravityview()->log->debug( 'Adding extra template style for {template_id}', array( 'template_id' => $template_id ) ); |
|
1349 | 1349 | wp_enqueue_style( 'gravityview_style_' . $template_id ); |
1350 | 1350 | } elseif ( empty( $template_id ) ) { |
1351 | 1351 | gravityview()->log->error( 'Cannot add template style; template_id is empty' ); |
@@ -1376,11 +1376,11 @@ discard block |
||
1376 | 1376 | * Not a table-based template; don't add sort icons |
1377 | 1377 | * @since 1.12 |
1378 | 1378 | */ |
1379 | - if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1379 | + if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1380 | 1380 | return $label; |
1381 | 1381 | } |
1382 | 1382 | |
1383 | - if ( ! $this->is_field_sortable( $field['id'], $form ) ) { |
|
1383 | + if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) { |
|
1384 | 1384 | return $label; |
1385 | 1385 | } |
1386 | 1386 | |
@@ -1388,29 +1388,29 @@ discard block |
||
1388 | 1388 | |
1389 | 1389 | $class = 'gv-sort'; |
1390 | 1390 | |
1391 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] ); |
|
1391 | + $sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] ); |
|
1392 | 1392 | |
1393 | 1393 | $sort_args = array( |
1394 | - 'sort' => $field['id'], |
|
1394 | + 'sort' => $field[ 'id' ], |
|
1395 | 1395 | 'dir' => 'asc', |
1396 | 1396 | ); |
1397 | 1397 | |
1398 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
1398 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
1399 | 1399 | //toggle sorting direction. |
1400 | - if ( 'asc' === $sorting['direction'] ) { |
|
1401 | - $sort_args['dir'] = 'desc'; |
|
1400 | + if ( 'asc' === $sorting[ 'direction' ] ) { |
|
1401 | + $sort_args[ 'dir' ] = 'desc'; |
|
1402 | 1402 | $class .= ' gv-icon-sort-desc'; |
1403 | 1403 | } else { |
1404 | - $sort_args['dir'] = 'asc'; |
|
1404 | + $sort_args[ 'dir' ] = 'asc'; |
|
1405 | 1405 | $class .= ' gv-icon-sort-asc'; |
1406 | 1406 | } |
1407 | 1407 | } else { |
1408 | 1408 | $class .= ' gv-icon-caret-up-down'; |
1409 | 1409 | } |
1410 | 1410 | |
1411 | - $url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); |
|
1411 | + $url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) ); |
|
1412 | 1412 | |
1413 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label; |
|
1413 | + return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a> ' . $label; |
|
1414 | 1414 | |
1415 | 1415 | } |
1416 | 1416 | |
@@ -1428,7 +1428,7 @@ discard block |
||
1428 | 1428 | |
1429 | 1429 | $field_type = $field_id; |
1430 | 1430 | |
1431 | - if( is_numeric( $field_id ) ) { |
|
1431 | + if ( is_numeric( $field_id ) ) { |
|
1432 | 1432 | $field = GFFormsModel::get_field( $form, $field_id ); |
1433 | 1433 | $field_type = $field->type; |
1434 | 1434 | } |
@@ -1451,7 +1451,7 @@ discard block |
||
1451 | 1451 | return false; |
1452 | 1452 | } |
1453 | 1453 | |
1454 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1454 | + return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1455 | 1455 | |
1456 | 1456 | } |
1457 | 1457 |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | public function prevent_maybe_process_form() { |
161 | 161 | |
162 | 162 | if( ! empty( $_POST ) ) { |
163 | - gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
163 | + gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | if( $this->is_edit_entry_submission() ) { |
167 | 167 | remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
168 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
168 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | |
198 | 198 | |
199 | 199 | $entries = $gravityview_view->getEntries(); |
200 | - self::$original_entry = $entries[0]; |
|
201 | - $this->entry = $entries[0]; |
|
200 | + self::$original_entry = $entries[0]; |
|
201 | + $this->entry = $entries[0]; |
|
202 | 202 | |
203 | 203 | self::$original_form = $gravityview_view->getForm(); |
204 | 204 | $this->form = $gravityview_view->getForm(); |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | |
320 | 320 | GFFormsModel::save_lead( $form, $this->entry ); |
321 | 321 | |
322 | - // Delete the values for hidden inputs |
|
323 | - $this->unset_hidden_field_values(); |
|
322 | + // Delete the values for hidden inputs |
|
323 | + $this->unset_hidden_field_values(); |
|
324 | 324 | |
325 | 325 | $this->entry['date_created'] = $date_created; |
326 | 326 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | // Perform actions normally performed after updating a lead |
331 | 331 | $this->after_update(); |
332 | 332 | |
333 | - /** |
|
333 | + /** |
|
334 | 334 | * Must be AFTER after_update()! |
335 | 335 | * @see https://github.com/gravityview/GravityView/issues/764 |
336 | 336 | */ |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @return void |
361 | 361 | */ |
362 | 362 | private function unset_hidden_field_values() { |
363 | - global $wpdb; |
|
363 | + global $wpdb; |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -382,27 +382,27 @@ discard block |
||
382 | 382 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
383 | 383 | } |
384 | 384 | |
385 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
385 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
386 | 386 | |
387 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
387 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
388 | 388 | |
389 | - // Reset fields that are hidden |
|
390 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
391 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
389 | + // Reset fields that are hidden |
|
390 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
391 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
392 | 392 | |
393 | - // List fields are stored as empty arrays when empty |
|
394 | - $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
393 | + // List fields are stored as empty arrays when empty |
|
394 | + $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
395 | 395 | |
396 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
396 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
397 | 397 | |
398 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
398 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
399 | 399 | |
400 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
400 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
401 | 401 | // after submission |
402 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
403 | - $_POST[ $post_input_id ] = ''; |
|
404 | - } |
|
405 | - } |
|
402 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
403 | + $_POST[ $post_input_id ] = ''; |
|
404 | + } |
|
405 | + } |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | |
497 | 497 | $form = $this->form; |
498 | 498 | |
499 | - /** @var GF_Field $field */ |
|
499 | + /** @var GF_Field $field */ |
|
500 | 500 | foreach( $form['fields'] as $k => &$field ) { |
501 | 501 | |
502 | 502 | /** |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | |
513 | 513 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
514 | 514 | foreach( $field->inputs as $key => $input ) { |
515 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
515 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | } |
@@ -533,13 +533,13 @@ discard block |
||
533 | 533 | foreach ( $this->fields_with_calculation as $calc_field ) { |
534 | 534 | $inputs = $calc_field->get_entry_inputs(); |
535 | 535 | if ( is_array( $inputs ) ) { |
536 | - foreach ( $inputs as $input ) { |
|
537 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
538 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
539 | - } |
|
536 | + foreach ( $inputs as $input ) { |
|
537 | + $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
538 | + $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
539 | + } |
|
540 | 540 | } else { |
541 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
542 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
541 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
542 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
543 | 543 | } |
544 | 544 | } |
545 | 545 | |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
588 | 588 | |
589 | 589 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
590 | - $ary = stripslashes_deep( $ary ); |
|
590 | + $ary = stripslashes_deep( $ary ); |
|
591 | 591 | $img_url = \GV\Utils::get( $ary, 0 ); |
592 | 592 | |
593 | 593 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | private function maybe_update_post_fields( $form ) { |
661 | 661 | |
662 | 662 | if( empty( $this->entry['post_id'] ) ) { |
663 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
663 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
664 | 664 | return; |
665 | 665 | } |
666 | 666 | |
@@ -695,51 +695,51 @@ discard block |
||
695 | 695 | |
696 | 696 | switch( $field->type ) { |
697 | 697 | |
698 | - case 'post_title': |
|
699 | - $post_title = $value; |
|
700 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
701 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
702 | - } |
|
703 | - $updated_post->post_title = $post_title; |
|
704 | - $updated_post->post_name = $post_title; |
|
705 | - unset( $post_title ); |
|
706 | - break; |
|
707 | - |
|
708 | - case 'post_content': |
|
709 | - $post_content = $value; |
|
710 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
711 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
712 | - } |
|
713 | - $updated_post->post_content = $post_content; |
|
714 | - unset( $post_content ); |
|
715 | - break; |
|
716 | - case 'post_excerpt': |
|
717 | - $updated_post->post_excerpt = $value; |
|
718 | - break; |
|
719 | - case 'post_tags': |
|
720 | - wp_set_post_tags( $post_id, $value, false ); |
|
721 | - break; |
|
722 | - case 'post_category': |
|
723 | - break; |
|
724 | - case 'post_custom_field': |
|
698 | + case 'post_title': |
|
699 | + $post_title = $value; |
|
700 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
701 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
702 | + } |
|
703 | + $updated_post->post_title = $post_title; |
|
704 | + $updated_post->post_name = $post_title; |
|
705 | + unset( $post_title ); |
|
706 | + break; |
|
707 | + |
|
708 | + case 'post_content': |
|
709 | + $post_content = $value; |
|
710 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
711 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
712 | + } |
|
713 | + $updated_post->post_content = $post_content; |
|
714 | + unset( $post_content ); |
|
715 | + break; |
|
716 | + case 'post_excerpt': |
|
717 | + $updated_post->post_excerpt = $value; |
|
718 | + break; |
|
719 | + case 'post_tags': |
|
720 | + wp_set_post_tags( $post_id, $value, false ); |
|
721 | + break; |
|
722 | + case 'post_category': |
|
723 | + break; |
|
724 | + case 'post_custom_field': |
|
725 | 725 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
726 | 726 | $value = $value[ $field_id ]; |
727 | 727 | } |
728 | 728 | |
729 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
730 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
731 | - } |
|
729 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
730 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
731 | + } |
|
732 | 732 | |
733 | - if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
734 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
735 | - } |
|
733 | + if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
734 | + $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
735 | + } |
|
736 | 736 | |
737 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
738 | - break; |
|
737 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
738 | + break; |
|
739 | 739 | |
740 | - case 'post_image': |
|
741 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
742 | - break; |
|
740 | + case 'post_image': |
|
741 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
742 | + break; |
|
743 | 743 | |
744 | 744 | } |
745 | 745 | |
@@ -784,20 +784,20 @@ discard block |
||
784 | 784 | */ |
785 | 785 | private function is_field_json_encoded( $field ) { |
786 | 786 | |
787 | - $json_encoded = false; |
|
787 | + $json_encoded = false; |
|
788 | 788 | |
789 | 789 | $input_type = RGFormsModel::get_input_type( $field ); |
790 | 790 | |
791 | - // Only certain custom field types are supported |
|
792 | - switch( $input_type ) { |
|
793 | - case 'fileupload': |
|
794 | - case 'list': |
|
795 | - case 'multiselect': |
|
796 | - $json_encoded = true; |
|
797 | - break; |
|
798 | - } |
|
791 | + // Only certain custom field types are supported |
|
792 | + switch( $input_type ) { |
|
793 | + case 'fileupload': |
|
794 | + case 'list': |
|
795 | + case 'multiselect': |
|
796 | + $json_encoded = true; |
|
797 | + break; |
|
798 | + } |
|
799 | 799 | |
800 | - return $json_encoded; |
|
800 | + return $json_encoded; |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | /** |
@@ -887,14 +887,14 @@ discard block |
||
887 | 887 | ?><h2 class="gv-edit-entry-title"> |
888 | 888 | <span><?php |
889 | 889 | |
890 | - /** |
|
891 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
892 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
893 | - * @param GravityView_Edit_Entry_Render $this This object |
|
894 | - */ |
|
895 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
890 | + /** |
|
891 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
892 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
893 | + * @param GravityView_Edit_Entry_Render $this This object |
|
894 | + */ |
|
895 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
896 | 896 | |
897 | - echo esc_attr( $edit_entry_title ); |
|
897 | + echo esc_attr( $edit_entry_title ); |
|
898 | 898 | ?></span> |
899 | 899 | </h2> |
900 | 900 | |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | |
1004 | 1004 | ob_get_clean(); |
1005 | 1005 | |
1006 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1006 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1007 | 1007 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1008 | 1008 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
1009 | 1009 | remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 ); |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | |
1058 | 1058 | // for now we don't support Save and Continue feature. |
1059 | 1059 | if( ! self::$supports_save_and_continue ) { |
1060 | - unset( $form['save'] ); |
|
1060 | + unset( $form['save'] ); |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | return $form; |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | || ! empty( $field_content ) |
1133 | 1133 | || in_array( $field->type, array( 'honeypot' ) ) |
1134 | 1134 | ) { |
1135 | - return $field_content; |
|
1135 | + return $field_content; |
|
1136 | 1136 | } |
1137 | 1137 | |
1138 | 1138 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1140,24 +1140,24 @@ discard block |
||
1140 | 1140 | |
1141 | 1141 | $field_value = $this->get_field_value( $field ); |
1142 | 1142 | |
1143 | - // Prevent any PHP warnings, like undefined index |
|
1144 | - ob_start(); |
|
1143 | + // Prevent any PHP warnings, like undefined index |
|
1144 | + ob_start(); |
|
1145 | 1145 | |
1146 | - $return = null; |
|
1146 | + $return = null; |
|
1147 | 1147 | |
1148 | 1148 | /** @var GravityView_Field $gv_field */ |
1149 | 1149 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1150 | 1150 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1151 | 1151 | } else { |
1152 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1153 | - } |
|
1152 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1153 | + } |
|
1154 | 1154 | |
1155 | - // If there was output, it's an error |
|
1156 | - $warnings = ob_get_clean(); |
|
1155 | + // If there was output, it's an error |
|
1156 | + $warnings = ob_get_clean(); |
|
1157 | 1157 | |
1158 | - if( !empty( $warnings ) ) { |
|
1159 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1160 | - } |
|
1158 | + if( !empty( $warnings ) ) { |
|
1159 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1160 | + } |
|
1161 | 1161 | |
1162 | 1162 | return $return; |
1163 | 1163 | } |
@@ -1192,8 +1192,8 @@ discard block |
||
1192 | 1192 | $input_id = strval( $input['id'] ); |
1193 | 1193 | |
1194 | 1194 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1195 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1196 | - $allow_pre_populated = false; |
|
1195 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1196 | + $allow_pre_populated = false; |
|
1197 | 1197 | } |
1198 | 1198 | |
1199 | 1199 | } |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1218 | 1218 | $categories = array(); |
1219 | 1219 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1220 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1220 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1221 | 1221 | } |
1222 | 1222 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1223 | 1223 | } |
@@ -1227,25 +1227,25 @@ discard block |
||
1227 | 1227 | // if value is empty get the default value if defined |
1228 | 1228 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1229 | 1229 | |
1230 | - /** |
|
1231 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1232 | - * @since 1.11 |
|
1233 | - * @since 1.20 Added third param |
|
1234 | - * @param mixed $field_value field value used to populate the input |
|
1235 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1236 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1237 | - */ |
|
1238 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1239 | - |
|
1240 | - /** |
|
1241 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1242 | - * @since 1.17 |
|
1243 | - * @since 1.20 Added third param |
|
1244 | - * @param mixed $field_value field value used to populate the input |
|
1245 | - * @param GF_Field $field Gravity Forms field object |
|
1246 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1247 | - */ |
|
1248 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1230 | + /** |
|
1231 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1232 | + * @since 1.11 |
|
1233 | + * @since 1.20 Added third param |
|
1234 | + * @param mixed $field_value field value used to populate the input |
|
1235 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1236 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1237 | + */ |
|
1238 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1239 | + |
|
1240 | + /** |
|
1241 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1242 | + * @since 1.17 |
|
1243 | + * @since 1.20 Added third param |
|
1244 | + * @param mixed $field_value field value used to populate the input |
|
1245 | + * @param GF_Field $field Gravity Forms field object |
|
1246 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1247 | + */ |
|
1248 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1249 | 1249 | |
1250 | 1250 | return $field_value; |
1251 | 1251 | } |
@@ -1272,7 +1272,7 @@ discard block |
||
1272 | 1272 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1273 | 1273 | // expects certain field array items to be set. |
1274 | 1274 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1275 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1275 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1276 | 1276 | } |
1277 | 1277 | |
1278 | 1278 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1286,61 +1286,61 @@ discard block |
||
1286 | 1286 | */ |
1287 | 1287 | case 'fileupload': |
1288 | 1288 | |
1289 | - // Set the previous value |
|
1290 | - $entry = $this->get_entry(); |
|
1289 | + // Set the previous value |
|
1290 | + $entry = $this->get_entry(); |
|
1291 | 1291 | |
1292 | - $input_name = 'input_'.$field->id; |
|
1293 | - $form_id = $form['id']; |
|
1292 | + $input_name = 'input_'.$field->id; |
|
1293 | + $form_id = $form['id']; |
|
1294 | 1294 | |
1295 | - $value = NULL; |
|
1295 | + $value = NULL; |
|
1296 | 1296 | |
1297 | - // Use the previous entry value as the default. |
|
1298 | - if( isset( $entry[ $field->id ] ) ) { |
|
1299 | - $value = $entry[ $field->id ]; |
|
1300 | - } |
|
1297 | + // Use the previous entry value as the default. |
|
1298 | + if( isset( $entry[ $field->id ] ) ) { |
|
1299 | + $value = $entry[ $field->id ]; |
|
1300 | + } |
|
1301 | 1301 | |
1302 | - // If this is a single upload file |
|
1303 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1304 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1305 | - $value = $file_path['url']; |
|
1302 | + // If this is a single upload file |
|
1303 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1304 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1305 | + $value = $file_path['url']; |
|
1306 | 1306 | |
1307 | - } else { |
|
1307 | + } else { |
|
1308 | 1308 | |
1309 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1310 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1311 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1309 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1310 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1311 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1312 | 1312 | |
1313 | - } |
|
1313 | + } |
|
1314 | 1314 | |
1315 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1315 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1316 | 1316 | |
1317 | - // If there are fresh uploads, process and merge them. |
|
1318 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1319 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1320 | - $value = empty( $value ) ? '[]' : $value; |
|
1321 | - $value = stripslashes_deep( $value ); |
|
1322 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1323 | - } |
|
1317 | + // If there are fresh uploads, process and merge them. |
|
1318 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1319 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1320 | + $value = empty( $value ) ? '[]' : $value; |
|
1321 | + $value = stripslashes_deep( $value ); |
|
1322 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1323 | + } |
|
1324 | 1324 | |
1325 | - } else { |
|
1325 | + } else { |
|
1326 | 1326 | |
1327 | - // A file already exists when editing an entry |
|
1328 | - // We set this to solve issue when file upload fields are required. |
|
1329 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1327 | + // A file already exists when editing an entry |
|
1328 | + // We set this to solve issue when file upload fields are required. |
|
1329 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1330 | 1330 | |
1331 | - } |
|
1331 | + } |
|
1332 | 1332 | |
1333 | - $this->entry[ $input_name ] = $value; |
|
1334 | - $_POST[ $input_name ] = $value; |
|
1333 | + $this->entry[ $input_name ] = $value; |
|
1334 | + $_POST[ $input_name ] = $value; |
|
1335 | 1335 | |
1336 | - break; |
|
1336 | + break; |
|
1337 | 1337 | |
1338 | 1338 | case 'number': |
1339 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1340 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1341 | - $_POST['input_'.$field->id ] = NULL; |
|
1342 | - } |
|
1343 | - break; |
|
1339 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1340 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1341 | + $_POST['input_'.$field->id ] = NULL; |
|
1342 | + } |
|
1343 | + break; |
|
1344 | 1344 | } |
1345 | 1345 | |
1346 | 1346 | } |
@@ -1425,42 +1425,42 @@ discard block |
||
1425 | 1425 | case 'fileupload' : |
1426 | 1426 | case 'post_image': |
1427 | 1427 | |
1428 | - // in case nothing is uploaded but there are already files saved |
|
1429 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1430 | - $field->failed_validation = false; |
|
1431 | - unset( $field->validation_message ); |
|
1432 | - } |
|
1428 | + // in case nothing is uploaded but there are already files saved |
|
1429 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1430 | + $field->failed_validation = false; |
|
1431 | + unset( $field->validation_message ); |
|
1432 | + } |
|
1433 | 1433 | |
1434 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1435 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1434 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1435 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1436 | 1436 | |
1437 | - $input_name = 'input_' . $field->id; |
|
1438 | - //uploaded |
|
1439 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1437 | + $input_name = 'input_' . $field->id; |
|
1438 | + //uploaded |
|
1439 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1440 | 1440 | |
1441 | - //existent |
|
1442 | - $entry = $this->get_entry(); |
|
1443 | - $value = NULL; |
|
1444 | - if( isset( $entry[ $field->id ] ) ) { |
|
1445 | - $value = json_decode( $entry[ $field->id ], true ); |
|
1446 | - } |
|
1441 | + //existent |
|
1442 | + $entry = $this->get_entry(); |
|
1443 | + $value = NULL; |
|
1444 | + if( isset( $entry[ $field->id ] ) ) { |
|
1445 | + $value = json_decode( $entry[ $field->id ], true ); |
|
1446 | + } |
|
1447 | 1447 | |
1448 | - // count uploaded files and existent entry files |
|
1449 | - $count_files = count( $file_names ) + count( $value ); |
|
1448 | + // count uploaded files and existent entry files |
|
1449 | + $count_files = count( $file_names ) + count( $value ); |
|
1450 | 1450 | |
1451 | - if( $count_files > $field->maxFiles ) { |
|
1452 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1453 | - $field->failed_validation = 1; |
|
1454 | - $gv_valid = false; |
|
1451 | + if( $count_files > $field->maxFiles ) { |
|
1452 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1453 | + $field->failed_validation = 1; |
|
1454 | + $gv_valid = false; |
|
1455 | 1455 | |
1456 | - // in case of error make sure the newest upload files are removed from the upload input |
|
1457 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1458 | - } |
|
1456 | + // in case of error make sure the newest upload files are removed from the upload input |
|
1457 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1458 | + } |
|
1459 | 1459 | |
1460 | - } |
|
1460 | + } |
|
1461 | 1461 | |
1462 | 1462 | |
1463 | - break; |
|
1463 | + break; |
|
1464 | 1464 | |
1465 | 1465 | } |
1466 | 1466 | |
@@ -1471,47 +1471,47 @@ discard block |
||
1471 | 1471 | |
1472 | 1472 | switch ( $field_type ) { |
1473 | 1473 | |
1474 | - // Captchas don't need to be re-entered. |
|
1475 | - case 'captcha': |
|
1474 | + // Captchas don't need to be re-entered. |
|
1475 | + case 'captcha': |
|
1476 | 1476 | |
1477 | - // Post Image fields aren't editable, so we un-fail them. |
|
1478 | - case 'post_image': |
|
1479 | - $field->failed_validation = false; |
|
1480 | - unset( $field->validation_message ); |
|
1481 | - break; |
|
1477 | + // Post Image fields aren't editable, so we un-fail them. |
|
1478 | + case 'post_image': |
|
1479 | + $field->failed_validation = false; |
|
1480 | + unset( $field->validation_message ); |
|
1481 | + break; |
|
1482 | 1482 | |
1483 | 1483 | } |
1484 | 1484 | |
1485 | 1485 | // You can't continue inside a switch, so we do it after. |
1486 | 1486 | if( empty( $field->failed_validation ) ) { |
1487 | - continue; |
|
1487 | + continue; |
|
1488 | 1488 | } |
1489 | 1489 | |
1490 | 1490 | // checks if the No Duplicates option is not validating entry against itself, since |
1491 | 1491 | // we're editing a stored entry, it would also assume it's a duplicate. |
1492 | 1492 | if( !empty( $field->noDuplicates ) ) { |
1493 | 1493 | |
1494 | - $entry = $this->get_entry(); |
|
1494 | + $entry = $this->get_entry(); |
|
1495 | 1495 | |
1496 | - // If the value of the entry is the same as the stored value |
|
1497 | - // Then we can assume it's not a duplicate, it's the same. |
|
1498 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1499 | - //if value submitted was not changed, then don't validate |
|
1500 | - $field->failed_validation = false; |
|
1496 | + // If the value of the entry is the same as the stored value |
|
1497 | + // Then we can assume it's not a duplicate, it's the same. |
|
1498 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1499 | + //if value submitted was not changed, then don't validate |
|
1500 | + $field->failed_validation = false; |
|
1501 | 1501 | |
1502 | - unset( $field->validation_message ); |
|
1502 | + unset( $field->validation_message ); |
|
1503 | 1503 | |
1504 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1504 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1505 | 1505 | |
1506 | - continue; |
|
1507 | - } |
|
1506 | + continue; |
|
1507 | + } |
|
1508 | 1508 | } |
1509 | 1509 | |
1510 | 1510 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1511 | 1511 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1512 | - unset( $field->validation_message ); |
|
1513 | - $field->validation_message = false; |
|
1514 | - continue; |
|
1512 | + unset( $field->validation_message ); |
|
1513 | + $field->validation_message = false; |
|
1514 | + continue; |
|
1515 | 1515 | } |
1516 | 1516 | |
1517 | 1517 | $gv_valid = false; |
@@ -1575,8 +1575,8 @@ discard block |
||
1575 | 1575 | // Hide fields depending on admin settings |
1576 | 1576 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1577 | 1577 | |
1578 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1579 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1578 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1579 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1580 | 1580 | |
1581 | 1581 | /** |
1582 | 1582 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1636,11 +1636,11 @@ discard block |
||
1636 | 1636 | // The edit tab has been configured, so we loop through to configured settings |
1637 | 1637 | foreach ( $configured_fields as $configured_field ) { |
1638 | 1638 | |
1639 | - /** @var GF_Field $field */ |
|
1640 | - foreach ( $fields as $field ) { |
|
1639 | + /** @var GF_Field $field */ |
|
1640 | + foreach ( $fields as $field ) { |
|
1641 | 1641 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
1642 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1643 | - break; |
|
1642 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1643 | + break; |
|
1644 | 1644 | } |
1645 | 1645 | |
1646 | 1646 | } |
@@ -1696,28 +1696,28 @@ discard block |
||
1696 | 1696 | */ |
1697 | 1697 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
1698 | 1698 | |
1699 | - /** |
|
1699 | + /** |
|
1700 | 1700 | * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true |
1701 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1702 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1703 | - * @since 1.9.1 |
|
1704 | - * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
1705 | - * @param array $form GF Form array |
|
1706 | - * @param int $view_id View ID |
|
1707 | - */ |
|
1708 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1709 | - |
|
1710 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1701 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1702 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1703 | + * @since 1.9.1 |
|
1704 | + * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
1705 | + * @param array $form GF Form array |
|
1706 | + * @param int $view_id View ID |
|
1707 | + */ |
|
1708 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1709 | + |
|
1710 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1711 | 1711 | foreach( $fields as $k => $field ) { |
1712 | 1712 | if( $field->adminOnly ) { |
1713 | - unset( $fields[ $k ] ); |
|
1713 | + unset( $fields[ $k ] ); |
|
1714 | 1714 | } |
1715 | 1715 | } |
1716 | 1716 | return $fields; |
1717 | 1717 | } |
1718 | 1718 | |
1719 | - foreach( $fields as &$field ) { |
|
1720 | - $field->adminOnly = false; |
|
1719 | + foreach( $fields as &$field ) { |
|
1720 | + $field->adminOnly = false; |
|
1721 | 1721 | } |
1722 | 1722 | |
1723 | 1723 | return $fields; |
@@ -1750,36 +1750,36 @@ discard block |
||
1750 | 1750 | |
1751 | 1751 | if( 'checkbox' === $field->type ) { |
1752 | 1752 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1753 | - $input_id = $input['id']; |
|
1754 | - $choice = $field->choices[ $key ]; |
|
1755 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1756 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1757 | - if( $match ) { |
|
1758 | - $field->choices[ $key ]['isSelected'] = true; |
|
1759 | - } |
|
1753 | + $input_id = $input['id']; |
|
1754 | + $choice = $field->choices[ $key ]; |
|
1755 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1756 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1757 | + if( $match ) { |
|
1758 | + $field->choices[ $key ]['isSelected'] = true; |
|
1759 | + } |
|
1760 | 1760 | } |
1761 | 1761 | } else { |
1762 | 1762 | |
1763 | 1763 | // We need to run through each field to set the default values |
1764 | 1764 | foreach ( $this->entry as $field_id => $field_value ) { |
1765 | 1765 | |
1766 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1766 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1767 | 1767 | |
1768 | - if( 'list' === $field->type ) { |
|
1769 | - $list_rows = maybe_unserialize( $field_value ); |
|
1768 | + if( 'list' === $field->type ) { |
|
1769 | + $list_rows = maybe_unserialize( $field_value ); |
|
1770 | 1770 | |
1771 | - $list_field_value = array(); |
|
1772 | - foreach ( (array) $list_rows as $row ) { |
|
1773 | - foreach ( (array) $row as $column ) { |
|
1774 | - $list_field_value[] = $column; |
|
1775 | - } |
|
1776 | - } |
|
1771 | + $list_field_value = array(); |
|
1772 | + foreach ( (array) $list_rows as $row ) { |
|
1773 | + foreach ( (array) $row as $column ) { |
|
1774 | + $list_field_value[] = $column; |
|
1775 | + } |
|
1776 | + } |
|
1777 | 1777 | |
1778 | - $field->defaultValue = serialize( $list_field_value ); |
|
1779 | - } else { |
|
1780 | - $field->defaultValue = $field_value; |
|
1781 | - } |
|
1782 | - } |
|
1778 | + $field->defaultValue = serialize( $list_field_value ); |
|
1779 | + } else { |
|
1780 | + $field->defaultValue = $field_value; |
|
1781 | + } |
|
1782 | + } |
|
1783 | 1783 | } |
1784 | 1784 | } |
1785 | 1785 | } |
@@ -1836,7 +1836,7 @@ discard block |
||
1836 | 1836 | return $has_conditional_logic; |
1837 | 1837 | } |
1838 | 1838 | |
1839 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
1839 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
1840 | 1840 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
1841 | 1841 | } |
1842 | 1842 | |
@@ -1903,14 +1903,14 @@ discard block |
||
1903 | 1903 | |
1904 | 1904 | if( $echo && $error !== true ) { |
1905 | 1905 | |
1906 | - $error = esc_html( $error ); |
|
1906 | + $error = esc_html( $error ); |
|
1907 | 1907 | |
1908 | - /** |
|
1909 | - * @since 1.9 |
|
1910 | - */ |
|
1911 | - if ( ! empty( $this->entry ) ) { |
|
1912 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1913 | - } |
|
1908 | + /** |
|
1909 | + * @since 1.9 |
|
1910 | + */ |
|
1911 | + if ( ! empty( $this->entry ) ) { |
|
1912 | + $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1913 | + } |
|
1914 | 1914 | |
1915 | 1915 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
1916 | 1916 | } |
@@ -106,16 +106,16 @@ discard block |
||
106 | 106 | function load() { |
107 | 107 | |
108 | 108 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
109 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
109 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
110 | 110 | |
111 | 111 | // Don't display an embedded form when editing an entry |
112 | 112 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
113 | 113 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
114 | 114 | |
115 | 115 | // Stop Gravity Forms processing what is ours! |
116 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
116 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
117 | 117 | |
118 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
118 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
119 | 119 | |
120 | 120 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
121 | 121 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
127 | 127 | |
128 | 128 | // Add fields expected by GFFormDisplay::validate() |
129 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
129 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
130 | 130 | |
131 | 131 | // Fix multiselect value for GF 2.2 |
132 | 132 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * @return void |
144 | 144 | */ |
145 | 145 | public function prevent_render_form() { |
146 | - if( $this->is_edit_entry() ) { |
|
147 | - if( 'wp_head' === current_filter() ) { |
|
146 | + if ( $this->is_edit_entry() ) { |
|
147 | + if ( 'wp_head' === current_filter() ) { |
|
148 | 148 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
149 | 149 | } else { |
150 | 150 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -159,13 +159,13 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function prevent_maybe_process_form() { |
161 | 161 | |
162 | - if( ! empty( $_POST ) ) { |
|
162 | + if ( ! empty( $_POST ) ) { |
|
163 | 163 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
164 | 164 | } |
165 | 165 | |
166 | - if( $this->is_edit_entry_submission() ) { |
|
167 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
168 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
166 | + if ( $this->is_edit_entry_submission() ) { |
|
167 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
168 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function is_edit_entry() { |
177 | 177 | |
178 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
178 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
179 | 179 | |
180 | 180 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
181 | 181 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @return boolean |
187 | 187 | */ |
188 | 188 | public function is_edit_entry_submission() { |
189 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
189 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -197,15 +197,15 @@ discard block |
||
197 | 197 | |
198 | 198 | |
199 | 199 | $entries = $gravityview_view->getEntries(); |
200 | - self::$original_entry = $entries[0]; |
|
201 | - $this->entry = $entries[0]; |
|
200 | + self::$original_entry = $entries[ 0 ]; |
|
201 | + $this->entry = $entries[ 0 ]; |
|
202 | 202 | |
203 | 203 | self::$original_form = $gravityview_view->getForm(); |
204 | 204 | $this->form = $gravityview_view->getForm(); |
205 | 205 | $this->form_id = $gravityview_view->getFormId(); |
206 | 206 | $this->view_id = $gravityview_view->getViewId(); |
207 | 207 | |
208 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
208 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -229,13 +229,13 @@ discard block |
||
229 | 229 | } |
230 | 230 | |
231 | 231 | // Multiple Views embedded, don't proceed if nonce fails |
232 | - if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) { |
|
232 | + if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) { |
|
233 | 233 | gravityview()->log->error( 'Nonce validation failed for the Edit Entry request; returning' ); |
234 | 234 | return; |
235 | 235 | } |
236 | 236 | |
237 | 237 | // Sorry, you're not allowed here. |
238 | - if( false === $this->user_can_edit_entry( true ) ) { |
|
238 | + if ( false === $this->user_can_edit_entry( true ) ) { |
|
239 | 239 | gravityview()->log->error( 'User is not allowed to edit this entry; returning', array( 'data' => $this->entry ) ); |
240 | 240 | return; |
241 | 241 | } |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | private function print_scripts() { |
257 | 257 | $gravityview_view = GravityView_View::getInstance(); |
258 | 258 | |
259 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
259 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
260 | 260 | |
261 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
261 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
262 | 262 | |
263 | 263 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
264 | 264 | |
@@ -272,19 +272,19 @@ discard block |
||
272 | 272 | */ |
273 | 273 | private function process_save() { |
274 | 274 | |
275 | - if( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
275 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
276 | 276 | return; |
277 | 277 | } |
278 | 278 | |
279 | 279 | // Make sure the entry, view, and form IDs are all correct |
280 | 280 | $valid = $this->verify_nonce(); |
281 | 281 | |
282 | - if( !$valid ) { |
|
282 | + if ( ! $valid ) { |
|
283 | 283 | gravityview()->log->error( 'Nonce validation failed.' ); |
284 | 284 | return; |
285 | 285 | } |
286 | 286 | |
287 | - if( $this->entry['id'] !== $_POST['lid'] ) { |
|
287 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
288 | 288 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
289 | 289 | return; |
290 | 290 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | $this->validate(); |
297 | 297 | |
298 | - if( $this->is_valid ) { |
|
298 | + if ( $this->is_valid ) { |
|
299 | 299 | |
300 | 300 | gravityview()->log->debug( 'Submission is valid.' ); |
301 | 301 | |
@@ -307,22 +307,22 @@ discard block |
||
307 | 307 | /** |
308 | 308 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
309 | 309 | */ |
310 | - unset( $_GET['page'] ); |
|
310 | + unset( $_GET[ 'page' ] ); |
|
311 | 311 | |
312 | - $date_created = $this->entry['date_created']; |
|
312 | + $date_created = $this->entry[ 'date_created' ]; |
|
313 | 313 | |
314 | 314 | /** |
315 | 315 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
316 | 316 | * @since 1.17.2 |
317 | 317 | */ |
318 | - unset( $this->entry['date_created'] ); |
|
318 | + unset( $this->entry[ 'date_created' ] ); |
|
319 | 319 | |
320 | 320 | GFFormsModel::save_lead( $form, $this->entry ); |
321 | 321 | |
322 | 322 | // Delete the values for hidden inputs |
323 | 323 | $this->unset_hidden_field_values(); |
324 | 324 | |
325 | - $this->entry['date_created'] = $date_created; |
|
325 | + $this->entry[ 'date_created' ] = $date_created; |
|
326 | 326 | |
327 | 327 | // Process calculation fields |
328 | 328 | $this->update_calculation_fields(); |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * @param string $entry_id Numeric ID of the entry that was updated |
343 | 343 | * @param GravityView_Edit_Entry_Render $this This object |
344 | 344 | */ |
345 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this ); |
|
345 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this ); |
|
346 | 346 | |
347 | 347 | } else { |
348 | 348 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -370,16 +370,16 @@ discard block |
||
370 | 370 | */ |
371 | 371 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
372 | 372 | |
373 | - if( ! $unset_hidden_field_values ) { |
|
373 | + if ( ! $unset_hidden_field_values ) { |
|
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | 377 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
378 | 378 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
379 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
379 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
380 | 380 | } else { |
381 | 381 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
382 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
382 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | } |
461 | 461 | |
462 | 462 | /** No file is being uploaded. */ |
463 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
463 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
464 | 464 | /** So return the original upload */ |
465 | 465 | return $entry[ $input_id ]; |
466 | 466 | } |
@@ -478,11 +478,11 @@ discard block |
||
478 | 478 | * @return mixed |
479 | 479 | */ |
480 | 480 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
481 | - if( ! $this->is_edit_entry() ) { |
|
481 | + if ( ! $this->is_edit_entry() ) { |
|
482 | 482 | return $plupload_init; |
483 | 483 | } |
484 | 484 | |
485 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
485 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
486 | 486 | |
487 | 487 | return $plupload_init; |
488 | 488 | } |
@@ -497,22 +497,22 @@ discard block |
||
497 | 497 | $form = $this->form; |
498 | 498 | |
499 | 499 | /** @var GF_Field $field */ |
500 | - foreach( $form['fields'] as $k => &$field ) { |
|
500 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
501 | 501 | |
502 | 502 | /** |
503 | 503 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
504 | 504 | * @since 1.16.3 |
505 | 505 | * @var GF_Field $field |
506 | 506 | */ |
507 | - if( $field->has_calculation() ) { |
|
508 | - unset( $form['fields'][ $k ] ); |
|
507 | + if ( $field->has_calculation() ) { |
|
508 | + unset( $form[ 'fields' ][ $k ] ); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | $field->adminOnly = false; |
512 | 512 | |
513 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
514 | - foreach( $field->inputs as $key => $input ) { |
|
515 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
513 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
514 | + foreach ( $field->inputs as $key => $input ) { |
|
515 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | } |
@@ -526,30 +526,30 @@ discard block |
||
526 | 526 | $update = false; |
527 | 527 | |
528 | 528 | // get the most up to date entry values |
529 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
529 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
530 | 530 | |
531 | - if( !empty( $this->fields_with_calculation ) ) { |
|
531 | + if ( ! empty( $this->fields_with_calculation ) ) { |
|
532 | 532 | $update = true; |
533 | 533 | foreach ( $this->fields_with_calculation as $calc_field ) { |
534 | 534 | $inputs = $calc_field->get_entry_inputs(); |
535 | 535 | if ( is_array( $inputs ) ) { |
536 | 536 | foreach ( $inputs as $input ) { |
537 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
538 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
537 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
538 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
539 | 539 | } |
540 | 540 | } else { |
541 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
542 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
541 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id ); |
|
542 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
543 | 543 | } |
544 | 544 | } |
545 | 545 | |
546 | 546 | } |
547 | 547 | |
548 | - if( $update ) { |
|
548 | + if ( $update ) { |
|
549 | 549 | |
550 | 550 | $return_entry = GFAPI::update_entry( $entry ); |
551 | 551 | |
552 | - if( is_wp_error( $return_entry ) ) { |
|
552 | + if ( is_wp_error( $return_entry ) ) { |
|
553 | 553 | gravityview()->log->error( 'Updating the entry calculation fields failed', array( 'data' => $return_entry ) ); |
554 | 554 | } else { |
555 | 555 | gravityview()->log->debug( 'Updating the entry calculation fields succeeded' ); |
@@ -580,19 +580,19 @@ discard block |
||
580 | 580 | |
581 | 581 | $input_name = 'input_' . $field_id; |
582 | 582 | |
583 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
583 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
584 | 584 | |
585 | 585 | // We have a new image |
586 | 586 | |
587 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
587 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
588 | 588 | |
589 | 589 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
590 | 590 | $ary = stripslashes_deep( $ary ); |
591 | 591 | $img_url = \GV\Utils::get( $ary, 0 ); |
592 | 592 | |
593 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
594 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
595 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
593 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
594 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
595 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
596 | 596 | |
597 | 597 | $image_meta = array( |
598 | 598 | 'post_excerpt' => $img_caption, |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | |
602 | 602 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
603 | 603 | if ( ! empty( $img_title ) ) { |
604 | - $image_meta['post_title'] = $img_title; |
|
604 | + $image_meta[ 'post_title' ] = $img_title; |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -659,15 +659,15 @@ discard block |
||
659 | 659 | */ |
660 | 660 | private function maybe_update_post_fields( $form ) { |
661 | 661 | |
662 | - if( empty( $this->entry['post_id'] ) ) { |
|
662 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
663 | 663 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
664 | 664 | return; |
665 | 665 | } |
666 | 666 | |
667 | - $post_id = $this->entry['post_id']; |
|
667 | + $post_id = $this->entry[ 'post_id' ]; |
|
668 | 668 | |
669 | 669 | // Security check |
670 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
670 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
671 | 671 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
672 | 672 | return; |
673 | 673 | } |
@@ -680,25 +680,25 @@ discard block |
||
680 | 680 | |
681 | 681 | $field = RGFormsModel::get_field( $form, $field_id ); |
682 | 682 | |
683 | - if( ! $field ) { |
|
683 | + if ( ! $field ) { |
|
684 | 684 | continue; |
685 | 685 | } |
686 | 686 | |
687 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
687 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
688 | 688 | |
689 | 689 | // Get the value of the field, including $_POSTed value |
690 | 690 | $value = RGFormsModel::get_field_value( $field ); |
691 | 691 | |
692 | 692 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
693 | 693 | $entry_tmp = $this->entry; |
694 | - $entry_tmp["{$field_id}"] = $value; |
|
694 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
695 | 695 | |
696 | - switch( $field->type ) { |
|
696 | + switch ( $field->type ) { |
|
697 | 697 | |
698 | 698 | case 'post_title': |
699 | 699 | $post_title = $value; |
700 | 700 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
701 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
701 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
702 | 702 | } |
703 | 703 | $updated_post->post_title = $post_title; |
704 | 704 | $updated_post->post_name = $post_title; |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | case 'post_content': |
709 | 709 | $post_content = $value; |
710 | 710 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
711 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
711 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
712 | 712 | } |
713 | 713 | $updated_post->post_content = $post_content; |
714 | 714 | unset( $post_content ); |
@@ -726,12 +726,12 @@ discard block |
||
726 | 726 | $value = $value[ $field_id ]; |
727 | 727 | } |
728 | 728 | |
729 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
729 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
730 | 730 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
731 | 731 | } |
732 | 732 | |
733 | 733 | if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
734 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
734 | + $value = function_exists( 'wp_json_encode' ) ? wp_json_encode( $value ) : json_encode( $value ); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | } |
745 | 745 | |
746 | 746 | // update entry after |
747 | - $this->entry["{$field_id}"] = $value; |
|
747 | + $this->entry[ "{$field_id}" ] = $value; |
|
748 | 748 | |
749 | 749 | $update_entry = true; |
750 | 750 | |
@@ -753,11 +753,11 @@ discard block |
||
753 | 753 | |
754 | 754 | } |
755 | 755 | |
756 | - if( $update_entry ) { |
|
756 | + if ( $update_entry ) { |
|
757 | 757 | |
758 | 758 | $return_entry = GFAPI::update_entry( $this->entry ); |
759 | 759 | |
760 | - if( is_wp_error( $return_entry ) ) { |
|
760 | + if ( is_wp_error( $return_entry ) ) { |
|
761 | 761 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
762 | 762 | } else { |
763 | 763 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | |
768 | 768 | $return_post = wp_update_post( $updated_post, true ); |
769 | 769 | |
770 | - if( is_wp_error( $return_post ) ) { |
|
770 | + if ( is_wp_error( $return_post ) ) { |
|
771 | 771 | $return_post->add_data( $updated_post, '$updated_post' ); |
772 | 772 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
773 | 773 | } else { |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | $input_type = RGFormsModel::get_input_type( $field ); |
790 | 790 | |
791 | 791 | // Only certain custom field types are supported |
792 | - switch( $input_type ) { |
|
792 | + switch ( $input_type ) { |
|
793 | 793 | case 'fileupload': |
794 | 794 | case 'list': |
795 | 795 | case 'multiselect': |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
827 | 827 | |
828 | 828 | // replace conditional shortcodes |
829 | - if( $do_shortcode ) { |
|
829 | + if ( $do_shortcode ) { |
|
830 | 830 | $output = do_shortcode( $output ); |
831 | 831 | } |
832 | 832 | |
@@ -845,19 +845,19 @@ discard block |
||
845 | 845 | */ |
846 | 846 | private function after_update() { |
847 | 847 | |
848 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
849 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
848 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
849 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
850 | 850 | |
851 | 851 | // Re-define the entry now that we've updated it. |
852 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
852 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
853 | 853 | |
854 | 854 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
855 | 855 | |
856 | 856 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
857 | 857 | // We need to clear the cache because Gravity Forms caches the field values, which |
858 | 858 | // we have just updated. |
859 | - foreach ($this->form['fields'] as $key => $field) { |
|
860 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
859 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
860 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
861 | 861 | } |
862 | 862 | } |
863 | 863 | |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | |
877 | 877 | <div class="gv-edit-entry-wrapper"><?php |
878 | 878 | |
879 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
879 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
880 | 880 | |
881 | 881 | /** |
882 | 882 | * Fixes weird wpautop() issue |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | * @param string $edit_entry_title Modify the "Edit Entry" title |
893 | 893 | * @param GravityView_Edit_Entry_Render $this This object |
894 | 894 | */ |
895 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
895 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
896 | 896 | |
897 | 897 | echo esc_attr( $edit_entry_title ); |
898 | 898 | ?></span> |
@@ -942,16 +942,16 @@ discard block |
||
942 | 942 | |
943 | 943 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
944 | 944 | |
945 | - if( ! $this->is_valid ){ |
|
945 | + if ( ! $this->is_valid ) { |
|
946 | 946 | |
947 | 947 | // Keeping this compatible with Gravity Forms. |
948 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
949 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
948 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
949 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
950 | 950 | |
951 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
951 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
952 | 952 | |
953 | 953 | } else { |
954 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
954 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' ); |
|
955 | 955 | |
956 | 956 | /** |
957 | 957 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | * @param array $entry Gravity Forms entry array |
962 | 962 | * @param string $back_link URL to return to the original entry. @since 1.6 |
963 | 963 | */ |
964 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
964 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
965 | 965 | |
966 | 966 | echo GVCommon::generate_notice( $message ); |
967 | 967 | } |
@@ -985,21 +985,21 @@ discard block |
||
985 | 985 | */ |
986 | 986 | do_action( 'gravityview/edit-entry/render/before', $this ); |
987 | 987 | |
988 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
989 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
988 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
989 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
990 | 990 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
991 | 991 | |
992 | 992 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
993 | 993 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
994 | 994 | |
995 | 995 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
996 | - unset( $_GET['page'] ); |
|
996 | + unset( $_GET[ 'page' ] ); |
|
997 | 997 | |
998 | 998 | // TODO: Verify multiple-page forms |
999 | 999 | |
1000 | 1000 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
1001 | 1001 | |
1002 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
1002 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1003 | 1003 | |
1004 | 1004 | ob_get_clean(); |
1005 | 1005 | |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | * @return string |
1026 | 1026 | */ |
1027 | 1027 | public function render_form_buttons() { |
1028 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
1028 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | |
@@ -1045,10 +1045,10 @@ discard block |
||
1045 | 1045 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1046 | 1046 | |
1047 | 1047 | // In case we have validated the form, use it to inject the validation results into the form render |
1048 | - if( isset( $this->form_after_validation ) ) { |
|
1048 | + if ( isset( $this->form_after_validation ) ) { |
|
1049 | 1049 | $form = $this->form_after_validation; |
1050 | 1050 | } else { |
1051 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1051 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | $form = $this->filter_conditional_logic( $form ); |
@@ -1056,8 +1056,8 @@ discard block |
||
1056 | 1056 | $form = $this->prefill_conditional_logic( $form ); |
1057 | 1057 | |
1058 | 1058 | // for now we don't support Save and Continue feature. |
1059 | - if( ! self::$supports_save_and_continue ) { |
|
1060 | - unset( $form['save'] ); |
|
1059 | + if ( ! self::$supports_save_and_continue ) { |
|
1060 | + unset( $form[ 'save' ] ); |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | return $form; |
@@ -1078,29 +1078,29 @@ discard block |
||
1078 | 1078 | */ |
1079 | 1079 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
1080 | 1080 | |
1081 | - if( GFCommon::is_post_field( $field ) ) { |
|
1081 | + if ( GFCommon::is_post_field( $field ) ) { |
|
1082 | 1082 | |
1083 | 1083 | $message = null; |
1084 | 1084 | |
1085 | 1085 | // First, make sure they have the capability to edit the post. |
1086 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1086 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1087 | 1087 | |
1088 | 1088 | /** |
1089 | 1089 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1090 | 1090 | * @param string $message The existing "You don't have permission..." text |
1091 | 1091 | */ |
1092 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1092 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1093 | 1093 | |
1094 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1094 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1095 | 1095 | /** |
1096 | 1096 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1097 | 1097 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1098 | 1098 | */ |
1099 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1099 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | - if( $message ) { |
|
1103 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1102 | + if ( $message ) { |
|
1103 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1104 | 1104 | } |
1105 | 1105 | } |
1106 | 1106 | |
@@ -1125,8 +1125,8 @@ discard block |
||
1125 | 1125 | |
1126 | 1126 | // If the form has been submitted, then we don't need to pre-fill the values, |
1127 | 1127 | // Except for fileupload type and when a field input is overridden- run always!! |
1128 | - if( |
|
1129 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1128 | + if ( |
|
1129 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1130 | 1130 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1131 | 1131 | && ! GFCommon::is_product_field( $field->type ) |
1132 | 1132 | || ! empty( $field_content ) |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | $return = null; |
1147 | 1147 | |
1148 | 1148 | /** @var GravityView_Field $gv_field */ |
1149 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1149 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1150 | 1150 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1151 | 1151 | } else { |
1152 | 1152 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1155,7 +1155,7 @@ discard block |
||
1155 | 1155 | // If there was output, it's an error |
1156 | 1156 | $warnings = ob_get_clean(); |
1157 | 1157 | |
1158 | - if( !empty( $warnings ) ) { |
|
1158 | + if ( ! empty( $warnings ) ) { |
|
1159 | 1159 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
1160 | 1160 | } |
1161 | 1161 | |
@@ -1180,7 +1180,7 @@ discard block |
||
1180 | 1180 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1181 | 1181 | |
1182 | 1182 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1183 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1183 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1184 | 1184 | |
1185 | 1185 | $field_value = array(); |
1186 | 1186 | |
@@ -1189,10 +1189,10 @@ discard block |
||
1189 | 1189 | |
1190 | 1190 | foreach ( (array)$field->inputs as $input ) { |
1191 | 1191 | |
1192 | - $input_id = strval( $input['id'] ); |
|
1192 | + $input_id = strval( $input[ 'id' ] ); |
|
1193 | 1193 | |
1194 | 1194 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1195 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1195 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1196 | 1196 | $allow_pre_populated = false; |
1197 | 1197 | } |
1198 | 1198 | |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | |
1201 | 1201 | $pre_value = $field->get_value_submission( array(), false ); |
1202 | 1202 | |
1203 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1203 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1204 | 1204 | |
1205 | 1205 | } else { |
1206 | 1206 | |
@@ -1211,13 +1211,13 @@ discard block |
||
1211 | 1211 | |
1212 | 1212 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1213 | 1213 | // or pre-populated value if not empty and set to override saved value |
1214 | - $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1214 | + $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1215 | 1215 | |
1216 | 1216 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1217 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1217 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1218 | 1218 | $categories = array(); |
1219 | 1219 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1220 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1220 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1221 | 1221 | } |
1222 | 1222 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1223 | 1223 | } |
@@ -1245,7 +1245,7 @@ discard block |
||
1245 | 1245 | * @param GF_Field $field Gravity Forms field object |
1246 | 1246 | * @param GravityView_Edit_Entry_Render $this Current object |
1247 | 1247 | */ |
1248 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1248 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1249 | 1249 | |
1250 | 1250 | return $field_value; |
1251 | 1251 | } |
@@ -1262,12 +1262,12 @@ discard block |
||
1262 | 1262 | */ |
1263 | 1263 | public function gform_pre_validation( $form ) { |
1264 | 1264 | |
1265 | - if( ! $this->verify_nonce() ) { |
|
1265 | + if ( ! $this->verify_nonce() ) { |
|
1266 | 1266 | return $form; |
1267 | 1267 | } |
1268 | 1268 | |
1269 | 1269 | // Fix PHP warning regarding undefined index. |
1270 | - foreach ( $form['fields'] as &$field) { |
|
1270 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1271 | 1271 | |
1272 | 1272 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1273 | 1273 | // expects certain field array items to be set. |
@@ -1275,7 +1275,7 @@ discard block |
||
1275 | 1275 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
1276 | 1276 | } |
1277 | 1277 | |
1278 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1278 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1279 | 1279 | |
1280 | 1280 | /** |
1281 | 1281 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1289,26 +1289,26 @@ discard block |
||
1289 | 1289 | // Set the previous value |
1290 | 1290 | $entry = $this->get_entry(); |
1291 | 1291 | |
1292 | - $input_name = 'input_'.$field->id; |
|
1293 | - $form_id = $form['id']; |
|
1292 | + $input_name = 'input_' . $field->id; |
|
1293 | + $form_id = $form[ 'id' ]; |
|
1294 | 1294 | |
1295 | 1295 | $value = NULL; |
1296 | 1296 | |
1297 | 1297 | // Use the previous entry value as the default. |
1298 | - if( isset( $entry[ $field->id ] ) ) { |
|
1298 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1299 | 1299 | $value = $entry[ $field->id ]; |
1300 | 1300 | } |
1301 | 1301 | |
1302 | 1302 | // If this is a single upload file |
1303 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1304 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1305 | - $value = $file_path['url']; |
|
1303 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1304 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1305 | + $value = $file_path[ 'url' ]; |
|
1306 | 1306 | |
1307 | 1307 | } else { |
1308 | 1308 | |
1309 | 1309 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1310 | 1310 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1311 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1311 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1312 | 1312 | |
1313 | 1313 | } |
1314 | 1314 | |
@@ -1316,10 +1316,10 @@ discard block |
||
1316 | 1316 | |
1317 | 1317 | // If there are fresh uploads, process and merge them. |
1318 | 1318 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1319 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1319 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1320 | 1320 | $value = empty( $value ) ? '[]' : $value; |
1321 | 1321 | $value = stripslashes_deep( $value ); |
1322 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1322 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1323 | 1323 | } |
1324 | 1324 | |
1325 | 1325 | } else { |
@@ -1337,8 +1337,8 @@ discard block |
||
1337 | 1337 | |
1338 | 1338 | case 'number': |
1339 | 1339 | // Fix "undefined index" issue at line 1286 in form_display.php |
1340 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1341 | - $_POST['input_'.$field->id ] = NULL; |
|
1340 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1341 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1342 | 1342 | } |
1343 | 1343 | break; |
1344 | 1344 | } |
@@ -1375,7 +1375,7 @@ discard block |
||
1375 | 1375 | * You can enter whatever you want! |
1376 | 1376 | * We try validating, and customize the results using `self::custom_validation()` |
1377 | 1377 | */ |
1378 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1378 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1379 | 1379 | |
1380 | 1380 | // Needed by the validate funtion |
1381 | 1381 | $failed_validation_page = NULL; |
@@ -1383,14 +1383,14 @@ discard block |
||
1383 | 1383 | |
1384 | 1384 | // Prevent entry limit from running when editing an entry, also |
1385 | 1385 | // prevent form scheduling from preventing editing |
1386 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1386 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1387 | 1387 | |
1388 | 1388 | // Hide fields depending on Edit Entry settings |
1389 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1389 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1390 | 1390 | |
1391 | 1391 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1392 | 1392 | |
1393 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1393 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 | |
@@ -1413,7 +1413,7 @@ discard block |
||
1413 | 1413 | |
1414 | 1414 | $gv_valid = true; |
1415 | 1415 | |
1416 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1416 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1417 | 1417 | |
1418 | 1418 | $value = RGFormsModel::get_field_value( $field ); |
1419 | 1419 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1426,35 +1426,35 @@ discard block |
||
1426 | 1426 | case 'post_image': |
1427 | 1427 | |
1428 | 1428 | // in case nothing is uploaded but there are already files saved |
1429 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1429 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1430 | 1430 | $field->failed_validation = false; |
1431 | 1431 | unset( $field->validation_message ); |
1432 | 1432 | } |
1433 | 1433 | |
1434 | 1434 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1435 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1435 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
1436 | 1436 | |
1437 | 1437 | $input_name = 'input_' . $field->id; |
1438 | 1438 | //uploaded |
1439 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1439 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1440 | 1440 | |
1441 | 1441 | //existent |
1442 | 1442 | $entry = $this->get_entry(); |
1443 | 1443 | $value = NULL; |
1444 | - if( isset( $entry[ $field->id ] ) ) { |
|
1444 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1445 | 1445 | $value = json_decode( $entry[ $field->id ], true ); |
1446 | 1446 | } |
1447 | 1447 | |
1448 | 1448 | // count uploaded files and existent entry files |
1449 | 1449 | $count_files = count( $file_names ) + count( $value ); |
1450 | 1450 | |
1451 | - if( $count_files > $field->maxFiles ) { |
|
1451 | + if ( $count_files > $field->maxFiles ) { |
|
1452 | 1452 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1453 | 1453 | $field->failed_validation = 1; |
1454 | 1454 | $gv_valid = false; |
1455 | 1455 | |
1456 | 1456 | // in case of error make sure the newest upload files are removed from the upload input |
1457 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1457 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1458 | 1458 | } |
1459 | 1459 | |
1460 | 1460 | } |
@@ -1465,7 +1465,7 @@ discard block |
||
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | // This field has failed validation. |
1468 | - if( !empty( $field->failed_validation ) ) { |
|
1468 | + if ( ! empty( $field->failed_validation ) ) { |
|
1469 | 1469 | |
1470 | 1470 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
1471 | 1471 | |
@@ -1483,19 +1483,19 @@ discard block |
||
1483 | 1483 | } |
1484 | 1484 | |
1485 | 1485 | // You can't continue inside a switch, so we do it after. |
1486 | - if( empty( $field->failed_validation ) ) { |
|
1486 | + if ( empty( $field->failed_validation ) ) { |
|
1487 | 1487 | continue; |
1488 | 1488 | } |
1489 | 1489 | |
1490 | 1490 | // checks if the No Duplicates option is not validating entry against itself, since |
1491 | 1491 | // we're editing a stored entry, it would also assume it's a duplicate. |
1492 | - if( !empty( $field->noDuplicates ) ) { |
|
1492 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1493 | 1493 | |
1494 | 1494 | $entry = $this->get_entry(); |
1495 | 1495 | |
1496 | 1496 | // If the value of the entry is the same as the stored value |
1497 | 1497 | // Then we can assume it's not a duplicate, it's the same. |
1498 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1498 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1499 | 1499 | //if value submitted was not changed, then don't validate |
1500 | 1500 | $field->failed_validation = false; |
1501 | 1501 | |
@@ -1508,7 +1508,7 @@ discard block |
||
1508 | 1508 | } |
1509 | 1509 | |
1510 | 1510 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1511 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1511 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1512 | 1512 | unset( $field->validation_message ); |
1513 | 1513 | $field->validation_message = false; |
1514 | 1514 | continue; |
@@ -1520,12 +1520,12 @@ discard block |
||
1520 | 1520 | |
1521 | 1521 | } |
1522 | 1522 | |
1523 | - $validation_results['is_valid'] = $gv_valid; |
|
1523 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1524 | 1524 | |
1525 | 1525 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
1526 | 1526 | |
1527 | 1527 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1528 | - $this->form_after_validation = $validation_results['form']; |
|
1528 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1529 | 1529 | |
1530 | 1530 | return $validation_results; |
1531 | 1531 | } |
@@ -1538,7 +1538,7 @@ discard block |
||
1538 | 1538 | */ |
1539 | 1539 | public function get_entry() { |
1540 | 1540 | |
1541 | - if( empty( $this->entry ) ) { |
|
1541 | + if ( empty( $this->entry ) ) { |
|
1542 | 1542 | // Get the database value of the entry that's being edited |
1543 | 1543 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1544 | 1544 | } |
@@ -1570,10 +1570,10 @@ discard block |
||
1570 | 1570 | } |
1571 | 1571 | |
1572 | 1572 | // If edit tab not yet configured, show all fields |
1573 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1573 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1574 | 1574 | |
1575 | 1575 | // Hide fields depending on admin settings |
1576 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1576 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1577 | 1577 | |
1578 | 1578 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1579 | 1579 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1605,7 +1605,7 @@ discard block |
||
1605 | 1605 | */ |
1606 | 1606 | private function filter_fields( $fields, $configured_fields ) { |
1607 | 1607 | |
1608 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1608 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1609 | 1609 | return $fields; |
1610 | 1610 | } |
1611 | 1611 | |
@@ -1618,18 +1618,18 @@ discard block |
||
1618 | 1618 | |
1619 | 1619 | // Remove the fields that have calculation properties and keep them to be used later |
1620 | 1620 | // @since 1.16.2 |
1621 | - if( $field->has_calculation() ) { |
|
1622 | - $this->fields_with_calculation[] = $field; |
|
1621 | + if ( $field->has_calculation() ) { |
|
1622 | + $this->fields_with_calculation[ ] = $field; |
|
1623 | 1623 | // don't remove the calculation fields on form render. |
1624 | 1624 | } |
1625 | 1625 | |
1626 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1626 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1627 | 1627 | unset( $fields[ $key ] ); |
1628 | 1628 | } |
1629 | 1629 | } |
1630 | 1630 | |
1631 | 1631 | // The Edit tab has not been configured, so we return all fields by default. |
1632 | - if( empty( $configured_fields ) ) { |
|
1632 | + if ( empty( $configured_fields ) ) { |
|
1633 | 1633 | return $fields; |
1634 | 1634 | } |
1635 | 1635 | |
@@ -1638,8 +1638,8 @@ discard block |
||
1638 | 1638 | |
1639 | 1639 | /** @var GF_Field $field */ |
1640 | 1640 | foreach ( $fields as $field ) { |
1641 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1642 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1641 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1642 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1643 | 1643 | break; |
1644 | 1644 | } |
1645 | 1645 | |
@@ -1662,14 +1662,14 @@ discard block |
||
1662 | 1662 | |
1663 | 1663 | $return_field = $field; |
1664 | 1664 | |
1665 | - if( empty( $field_setting['show_label'] ) ) { |
|
1665 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1666 | 1666 | $return_field->label = ''; |
1667 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1668 | - $return_field->label = $field_setting['custom_label']; |
|
1667 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1668 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1669 | 1669 | } |
1670 | 1670 | |
1671 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1672 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1671 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1672 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1673 | 1673 | } |
1674 | 1674 | |
1675 | 1675 | /** |
@@ -1707,16 +1707,16 @@ discard block |
||
1707 | 1707 | */ |
1708 | 1708 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
1709 | 1709 | |
1710 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1711 | - foreach( $fields as $k => $field ) { |
|
1712 | - if( $field->adminOnly ) { |
|
1710 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
1711 | + foreach ( $fields as $k => $field ) { |
|
1712 | + if ( $field->adminOnly ) { |
|
1713 | 1713 | unset( $fields[ $k ] ); |
1714 | 1714 | } |
1715 | 1715 | } |
1716 | 1716 | return $fields; |
1717 | 1717 | } |
1718 | 1718 | |
1719 | - foreach( $fields as &$field ) { |
|
1719 | + foreach ( $fields as &$field ) { |
|
1720 | 1720 | $field->adminOnly = false; |
1721 | 1721 | } |
1722 | 1722 | |
@@ -1740,22 +1740,22 @@ discard block |
||
1740 | 1740 | */ |
1741 | 1741 | function prefill_conditional_logic( $form ) { |
1742 | 1742 | |
1743 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1743 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1744 | 1744 | return $form; |
1745 | 1745 | } |
1746 | 1746 | |
1747 | 1747 | // Have Conditional Logic pre-fill fields as if the data were default values |
1748 | 1748 | /** @var GF_Field $field */ |
1749 | - foreach ( $form['fields'] as &$field ) { |
|
1749 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1750 | 1750 | |
1751 | - if( 'checkbox' === $field->type ) { |
|
1751 | + if ( 'checkbox' === $field->type ) { |
|
1752 | 1752 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1753 | - $input_id = $input['id']; |
|
1753 | + $input_id = $input[ 'id' ]; |
|
1754 | 1754 | $choice = $field->choices[ $key ]; |
1755 | 1755 | $value = \GV\Utils::get( $this->entry, $input_id ); |
1756 | 1756 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
1757 | - if( $match ) { |
|
1758 | - $field->choices[ $key ]['isSelected'] = true; |
|
1757 | + if ( $match ) { |
|
1758 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
1759 | 1759 | } |
1760 | 1760 | } |
1761 | 1761 | } else { |
@@ -1763,15 +1763,15 @@ discard block |
||
1763 | 1763 | // We need to run through each field to set the default values |
1764 | 1764 | foreach ( $this->entry as $field_id => $field_value ) { |
1765 | 1765 | |
1766 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1766 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1767 | 1767 | |
1768 | - if( 'list' === $field->type ) { |
|
1768 | + if ( 'list' === $field->type ) { |
|
1769 | 1769 | $list_rows = maybe_unserialize( $field_value ); |
1770 | 1770 | |
1771 | 1771 | $list_field_value = array(); |
1772 | - foreach ( (array) $list_rows as $row ) { |
|
1773 | - foreach ( (array) $row as $column ) { |
|
1774 | - $list_field_value[] = $column; |
|
1772 | + foreach ( (array)$list_rows as $row ) { |
|
1773 | + foreach ( (array)$row as $column ) { |
|
1774 | + $list_field_value[ ] = $column; |
|
1775 | 1775 | } |
1776 | 1776 | } |
1777 | 1777 | |
@@ -1806,16 +1806,16 @@ discard block |
||
1806 | 1806 | */ |
1807 | 1807 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
1808 | 1808 | |
1809 | - if( $use_conditional_logic ) { |
|
1809 | + if ( $use_conditional_logic ) { |
|
1810 | 1810 | return $form; |
1811 | 1811 | } |
1812 | 1812 | |
1813 | - foreach( $form['fields'] as &$field ) { |
|
1813 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1814 | 1814 | /* @var GF_Field $field */ |
1815 | 1815 | $field->conditionalLogic = null; |
1816 | 1816 | } |
1817 | 1817 | |
1818 | - unset( $form['button']['conditionalLogic'] ); |
|
1818 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
1819 | 1819 | |
1820 | 1820 | return $form; |
1821 | 1821 | |
@@ -1832,7 +1832,7 @@ discard block |
||
1832 | 1832 | */ |
1833 | 1833 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
1834 | 1834 | |
1835 | - if( ! $this->is_edit_entry() ) { |
|
1835 | + if ( ! $this->is_edit_entry() ) { |
|
1836 | 1836 | return $has_conditional_logic; |
1837 | 1837 | } |
1838 | 1838 | |
@@ -1864,44 +1864,44 @@ discard block |
||
1864 | 1864 | * 2. There are two entries embedded using oEmbed |
1865 | 1865 | * 3. One of the entries has just been saved |
1866 | 1866 | */ |
1867 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
1867 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
1868 | 1868 | |
1869 | 1869 | $error = true; |
1870 | 1870 | |
1871 | 1871 | } |
1872 | 1872 | |
1873 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
1873 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
1874 | 1874 | |
1875 | 1875 | $error = true; |
1876 | 1876 | |
1877 | - } elseif( ! $this->verify_nonce() ) { |
|
1877 | + } elseif ( ! $this->verify_nonce() ) { |
|
1878 | 1878 | |
1879 | 1879 | /** |
1880 | 1880 | * If the Entry is embedded, there may be two entries on the same page. |
1881 | 1881 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
1882 | 1882 | */ |
1883 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1883 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1884 | 1884 | $error = true; |
1885 | 1885 | } else { |
1886 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
1886 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
1887 | 1887 | } |
1888 | 1888 | |
1889 | 1889 | } |
1890 | 1890 | |
1891 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1892 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
1891 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1892 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
1893 | 1893 | } |
1894 | 1894 | |
1895 | - if( $this->entry['status'] === 'trash' ) { |
|
1896 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1895 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
1896 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1897 | 1897 | } |
1898 | 1898 | |
1899 | 1899 | // No errors; everything's fine here! |
1900 | - if( empty( $error ) ) { |
|
1900 | + if ( empty( $error ) ) { |
|
1901 | 1901 | return true; |
1902 | 1902 | } |
1903 | 1903 | |
1904 | - if( $echo && $error !== true ) { |
|
1904 | + if ( $echo && $error !== true ) { |
|
1905 | 1905 | |
1906 | 1906 | $error = esc_html( $error ); |
1907 | 1907 | |
@@ -1909,10 +1909,10 @@ discard block |
||
1909 | 1909 | * @since 1.9 |
1910 | 1910 | */ |
1911 | 1911 | if ( ! empty( $this->entry ) ) { |
1912 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1912 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1913 | 1913 | } |
1914 | 1914 | |
1915 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
1915 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
1916 | 1916 | } |
1917 | 1917 | |
1918 | 1918 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1932,17 +1932,17 @@ discard block |
||
1932 | 1932 | |
1933 | 1933 | $error = NULL; |
1934 | 1934 | |
1935 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1936 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
1935 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1936 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
1937 | 1937 | } |
1938 | 1938 | |
1939 | 1939 | // No errors; everything's fine here! |
1940 | - if( empty( $error ) ) { |
|
1940 | + if ( empty( $error ) ) { |
|
1941 | 1941 | return true; |
1942 | 1942 | } |
1943 | 1943 | |
1944 | - if( $echo ) { |
|
1945 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
1944 | + if ( $echo ) { |
|
1945 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
1946 | 1946 | } |
1947 | 1947 | |
1948 | 1948 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1963,14 +1963,14 @@ discard block |
||
1963 | 1963 | private function check_user_cap_edit_field( $field ) { |
1964 | 1964 | |
1965 | 1965 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
1966 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1966 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1967 | 1967 | return true; |
1968 | 1968 | } |
1969 | 1969 | |
1970 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
1970 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
1971 | 1971 | |
1972 | - if( $field_cap ) { |
|
1973 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
1972 | + if ( $field_cap ) { |
|
1973 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
1974 | 1974 | } |
1975 | 1975 | |
1976 | 1976 | return false; |
@@ -1984,17 +1984,17 @@ discard block |
||
1984 | 1984 | public function verify_nonce() { |
1985 | 1985 | |
1986 | 1986 | // Verify form submitted for editing single |
1987 | - if( $this->is_edit_entry_submission() ) { |
|
1987 | + if ( $this->is_edit_entry_submission() ) { |
|
1988 | 1988 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
1989 | 1989 | } |
1990 | 1990 | |
1991 | 1991 | // Verify |
1992 | - else if( ! $this->is_edit_entry() ) { |
|
1992 | + else if ( ! $this->is_edit_entry() ) { |
|
1993 | 1993 | $valid = false; |
1994 | 1994 | } |
1995 | 1995 | |
1996 | 1996 | else { |
1997 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
1997 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
1998 | 1998 | } |
1999 | 1999 | |
2000 | 2000 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | 'type' => 'radio', |
65 | 65 | 'full_width' => true, |
66 | 66 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
67 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
67 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
68 | 68 | 'value' => 'any', |
69 | 69 | 'class' => 'hide-if-js', |
70 | 70 | 'options' => array( |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
88 | 88 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
89 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
89 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
90 | 90 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
91 | 91 | |
92 | 92 | // ajax - get the searchable fields |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
225 | 225 | $script_source = empty( $script_min ) ? '/source' : ''; |
226 | 226 | |
227 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
227 | + wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
228 | 228 | |
229 | 229 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
230 | 230 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
247 | 247 | */ |
248 | 248 | public function register_no_conflict( $allowed ) { |
249 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
249 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
250 | 250 | return $allowed; |
251 | 251 | } |
252 | 252 | |
@@ -259,24 +259,24 @@ discard block |
||
259 | 259 | */ |
260 | 260 | public static function get_searchable_fields() { |
261 | 261 | |
262 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
262 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
263 | 263 | exit( '0' ); |
264 | 264 | } |
265 | 265 | |
266 | 266 | $form = ''; |
267 | 267 | |
268 | 268 | // Fetch the form for the current View |
269 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
269 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
270 | 270 | |
271 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
271 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
272 | 272 | |
273 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
273 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
274 | 274 | |
275 | - $form = (int) $_POST['formid']; |
|
275 | + $form = (int)$_POST[ 'formid' ]; |
|
276 | 276 | |
277 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
277 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
278 | 278 | |
279 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
279 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
280 | 280 | |
281 | 281 | } |
282 | 282 | |
@@ -325,8 +325,8 @@ discard block |
||
325 | 325 | ), |
326 | 326 | ); |
327 | 327 | |
328 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
329 | - $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] ); |
|
328 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
329 | + $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] ); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | // Get fields with sub-inputs and no parent |
@@ -348,13 +348,13 @@ discard block |
||
348 | 348 | |
349 | 349 | foreach ( $fields as $id => $field ) { |
350 | 350 | |
351 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
351 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
352 | 352 | continue; |
353 | 353 | } |
354 | 354 | |
355 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
355 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
356 | 356 | |
357 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
357 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
378 | 378 | |
379 | 379 | // @todo - This needs to be improved - many fields have . including products and addresses |
380 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
380 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
381 | 381 | $input_type = 'boolean'; // on/off checkbox |
382 | 382 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
383 | 383 | $input_type = 'multi'; //multiselect |
@@ -421,19 +421,19 @@ discard block |
||
421 | 421 | $post_id = 0; |
422 | 422 | |
423 | 423 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
424 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
425 | - $post_id = absint( $widget_args['post_id'] ); |
|
424 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
425 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
426 | 426 | } |
427 | 427 | // We're in the WordPress Widget context, and the base View ID should be used |
428 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
429 | - $post_id = absint( $widget_args['view_id'] ); |
|
428 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
429 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | $args = gravityview_get_permalink_query_args( $post_id ); |
433 | 433 | |
434 | 434 | // Add hidden fields to the search form |
435 | 435 | foreach ( $args as $key => $value ) { |
436 | - $search_fields[] = array( |
|
436 | + $search_fields[ ] = array( |
|
437 | 437 | 'name' => $key, |
438 | 438 | 'input' => 'hidden', |
439 | 439 | 'value' => $value, |
@@ -472,22 +472,22 @@ discard block |
||
472 | 472 | /** |
473 | 473 | * Include the sidebar Widgets. |
474 | 474 | */ |
475 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
475 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
476 | 476 | |
477 | 477 | foreach ( $widgets as $widget ) { |
478 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
479 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
478 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
479 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
480 | 480 | foreach ( $_fields as $field ) { |
481 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
481 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
487 | 487 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
488 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
488 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
489 | 489 | foreach ( $_fields as $field ) { |
490 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
490 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
491 | 491 | } |
492 | 492 | } |
493 | 493 | } |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | */ |
505 | 505 | public function filter_entries( $search_criteria, $form_id = null, $args = array() ) { |
506 | 506 | |
507 | - if( 'post' === $this->search_method ) { |
|
507 | + if ( 'post' === $this->search_method ) { |
|
508 | 508 | $get = $_POST; |
509 | 509 | } else { |
510 | 510 | $get = $_GET; |
@@ -523,14 +523,14 @@ discard block |
||
523 | 523 | $get = gv_map_deep( $get, 'rawurldecode' ); |
524 | 524 | |
525 | 525 | // Make sure array key is set up |
526 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
526 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
527 | 527 | |
528 | 528 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
529 | 529 | |
530 | 530 | // add free search |
531 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
531 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
532 | 532 | |
533 | - $search_all_value = trim( $get['gv_search'] ); |
|
533 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
534 | 534 | |
535 | 535 | /** |
536 | 536 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | } |
556 | 556 | |
557 | 557 | foreach ( $words as $word ) { |
558 | - $search_criteria['field_filters'][] = array( |
|
558 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
559 | 559 | 'key' => null, // The field ID to search |
560 | 560 | 'value' => $word, // The value to search |
561 | 561 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -565,19 +565,19 @@ discard block |
||
565 | 565 | |
566 | 566 | // start date & end date |
567 | 567 | if ( in_array( 'entry_date', $searchable_fields ) ) { |
568 | - $curr_start = !empty( $get['gv_start'] ) ? $get['gv_start'] : ''; |
|
569 | - $curr_end = !empty( $get['gv_start'] ) ? $get['gv_end'] : ''; |
|
568 | + $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : ''; |
|
569 | + $curr_end = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_end' ] : ''; |
|
570 | 570 | |
571 | 571 | if ( $view ) { |
572 | 572 | /** |
573 | 573 | * Override start and end dates if View is limited to some already. |
574 | 574 | */ |
575 | - if ( $start_date =$view->settings->get( 'start_date' ) ) { |
|
575 | + if ( $start_date = $view->settings->get( 'start_date' ) ) { |
|
576 | 576 | if ( $start_timestamp = strtotime( $curr_start ) ) { |
577 | 577 | $curr_start = $start_timestamp < strtotime( $start_date ) ? $start_date : $curr_start; |
578 | 578 | } |
579 | 579 | } |
580 | - if ( $end_date =$view->settings->get( 'end_date' ) ) { |
|
580 | + if ( $end_date = $view->settings->get( 'end_date' ) ) { |
|
581 | 581 | if ( $end_timestamp = strtotime( $curr_end ) ) { |
582 | 582 | $curr_end = $end_timestamp > strtotime( $end_date ) ? $end_date : $curr_end; |
583 | 583 | } |
@@ -598,22 +598,22 @@ discard block |
||
598 | 598 | */ |
599 | 599 | if ( ! empty( $curr_start ) ) { |
600 | 600 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
601 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
601 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | if ( ! empty( $curr_end ) ) { |
605 | 605 | // Fast-forward 24 hour on the end time |
606 | 606 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
607 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
608 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
609 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
607 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
608 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
609 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
610 | 610 | } |
611 | 611 | } |
612 | 612 | } |
613 | 613 | |
614 | 614 | // search for a specific entry ID |
615 | 615 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
616 | - $search_criteria['field_filters'][] = array( |
|
616 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
617 | 617 | 'key' => 'id', |
618 | 618 | 'value' => absint( $get[ 'gv_id' ] ), |
619 | 619 | 'operator' => '=', |
@@ -622,42 +622,42 @@ discard block |
||
622 | 622 | |
623 | 623 | // search for a specific Created_by ID |
624 | 624 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
625 | - $search_criteria['field_filters'][] = array( |
|
625 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
626 | 626 | 'key' => 'created_by', |
627 | - 'value' => absint( $get['gv_by'] ), |
|
627 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
628 | 628 | 'operator' => '=', |
629 | 629 | ); |
630 | 630 | } |
631 | 631 | |
632 | 632 | |
633 | 633 | // Get search mode passed in URL |
634 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
634 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
635 | 635 | |
636 | 636 | // get the other search filters |
637 | 637 | foreach ( $get as $key => $value ) { |
638 | 638 | |
639 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
639 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
640 | 640 | continue; |
641 | 641 | } |
642 | 642 | |
643 | 643 | $filter_key = $this->convert_request_key_to_filter_key( $key ); |
644 | 644 | |
645 | 645 | // could return simple filter or multiple filters |
646 | - if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key , $searchable_fields ) ) { |
|
646 | + if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key, $searchable_fields ) ) { |
|
647 | 647 | continue; |
648 | 648 | } |
649 | 649 | |
650 | 650 | $filter = $this->prepare_field_filter( $filter_key, $value, $view ); |
651 | 651 | |
652 | - if ( isset( $filter[0]['value'] ) ) { |
|
653 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
652 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
653 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
654 | 654 | |
655 | 655 | // if date range type, set search mode to ALL |
656 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
656 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
657 | 657 | $mode = 'all'; |
658 | 658 | } |
659 | - } elseif( !empty( $filter ) ) { |
|
660 | - $search_criteria['field_filters'][] = $filter; |
|
659 | + } elseif ( ! empty( $filter ) ) { |
|
660 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
661 | 661 | } |
662 | 662 | } |
663 | 663 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | * @since 1.5.1 |
667 | 667 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
668 | 668 | */ |
669 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
669 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
670 | 670 | |
671 | 671 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
672 | 672 | |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | $field_id = str_replace( 'filter_', '', $key ); |
695 | 695 | |
696 | 696 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
697 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
697 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
698 | 698 | $field_id = str_replace( '_', '.', $field_id ); |
699 | 699 | } |
700 | 700 | |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | |
730 | 730 | case 'select': |
731 | 731 | case 'radio': |
732 | - $filter['operator'] = 'is'; |
|
732 | + $filter[ 'operator' ] = 'is'; |
|
733 | 733 | break; |
734 | 734 | |
735 | 735 | case 'post_category': |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | |
744 | 744 | foreach ( $value as $val ) { |
745 | 745 | $cat = get_term( $val, 'category' ); |
746 | - $filter[] = array( |
|
746 | + $filter[ ] = array( |
|
747 | 747 | 'key' => $filter_key, |
748 | 748 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
749 | 749 | 'operator' => 'is', |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | $filter = array(); |
763 | 763 | |
764 | 764 | foreach ( $value as $val ) { |
765 | - $filter[] = array( 'key' => $filter_key, 'value' => $val ); |
|
765 | + $filter[ ] = array( 'key' => $filter_key, 'value' => $val ); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | break; |
@@ -771,9 +771,9 @@ discard block |
||
771 | 771 | // convert checkbox on/off into the correct search filter |
772 | 772 | if ( false !== strpos( $filter_key, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
773 | 773 | foreach ( $form_field->inputs as $k => $input ) { |
774 | - if ( $input['id'] == $filter_key ) { |
|
775 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
776 | - $filter['operator'] = 'is'; |
|
774 | + if ( $input[ 'id' ] == $filter_key ) { |
|
775 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
776 | + $filter[ 'operator' ] = 'is'; |
|
777 | 777 | break; |
778 | 778 | } |
779 | 779 | } |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | $filter = array(); |
784 | 784 | |
785 | 785 | foreach ( $value as $val ) { |
786 | - $filter[] = array( |
|
786 | + $filter[ ] = array( |
|
787 | 787 | 'key' => $filter_key, |
788 | 788 | 'value' => $val, |
789 | 789 | 'operator' => 'is', |
@@ -804,9 +804,9 @@ discard block |
||
804 | 804 | foreach ( $words as $word ) { |
805 | 805 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
806 | 806 | // Keep the same key for each filter |
807 | - $filter['value'] = $word; |
|
807 | + $filter[ 'value' ] = $word; |
|
808 | 808 | // Add a search for the value |
809 | - $filters[] = $filter; |
|
809 | + $filters[ ] = $filter; |
|
810 | 810 | } |
811 | 811 | } |
812 | 812 | |
@@ -820,19 +820,19 @@ discard block |
||
820 | 820 | |
821 | 821 | foreach ( $searchable_fields as $searchable_field ) { |
822 | 822 | |
823 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
823 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
824 | 824 | continue; |
825 | 825 | } |
826 | 826 | |
827 | 827 | // Only exact-match dropdowns, not text search |
828 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
828 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
829 | 829 | continue; |
830 | 830 | } |
831 | 831 | |
832 | 832 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
833 | 833 | |
834 | 834 | if ( 4 === $input_id ) { |
835 | - $filter['operator'] = 'is'; |
|
835 | + $filter[ 'operator' ] = 'is'; |
|
836 | 836 | }; |
837 | 837 | } |
838 | 838 | } |
@@ -857,19 +857,19 @@ discard block |
||
857 | 857 | * @since 1.16.3 |
858 | 858 | * Safeguard until GF implements '<=' operator |
859 | 859 | */ |
860 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
860 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
861 | 861 | $operator = '<'; |
862 | 862 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
863 | 863 | } |
864 | 864 | |
865 | - $filter[] = array( |
|
865 | + $filter[ ] = array( |
|
866 | 866 | 'key' => $filter_key, |
867 | 867 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
868 | 868 | 'operator' => $operator, |
869 | 869 | ); |
870 | 870 | } |
871 | 871 | } else { |
872 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
872 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | break; |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | 'ymd_dot' => 'Y.m.d', |
901 | 901 | ); |
902 | 902 | |
903 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
903 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
904 | 904 | $format = $datepicker[ $field->dateFormat ]; |
905 | 905 | } |
906 | 906 | |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | public function add_template_path( $file_paths ) { |
932 | 932 | |
933 | 933 | // Index 100 is the default GravityView template path. |
934 | - $file_paths[102] = self::$file . 'templates/'; |
|
934 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
935 | 935 | |
936 | 936 | return $file_paths; |
937 | 937 | } |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | $has_date = false; |
951 | 951 | |
952 | 952 | foreach ( $search_fields as $k => $field ) { |
953 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
953 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
954 | 954 | $has_date = true; |
955 | 955 | break; |
956 | 956 | } |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | } |
978 | 978 | |
979 | 979 | // get configured search fields |
980 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
980 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
981 | 981 | |
982 | 982 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
983 | 983 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -992,34 +992,34 @@ discard block |
||
992 | 992 | |
993 | 993 | $updated_field = $this->get_search_filter_details( $updated_field ); |
994 | 994 | |
995 | - switch ( $field['field'] ) { |
|
995 | + switch ( $field[ 'field' ] ) { |
|
996 | 996 | |
997 | 997 | case 'search_all': |
998 | - $updated_field['key'] = 'search_all'; |
|
999 | - $updated_field['input'] = 'search_all'; |
|
1000 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
998 | + $updated_field[ 'key' ] = 'search_all'; |
|
999 | + $updated_field[ 'input' ] = 'search_all'; |
|
1000 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1001 | 1001 | break; |
1002 | 1002 | |
1003 | 1003 | case 'entry_date': |
1004 | - $updated_field['key'] = 'entry_date'; |
|
1005 | - $updated_field['input'] = 'entry_date'; |
|
1006 | - $updated_field['value'] = array( |
|
1004 | + $updated_field[ 'key' ] = 'entry_date'; |
|
1005 | + $updated_field[ 'input' ] = 'entry_date'; |
|
1006 | + $updated_field[ 'value' ] = array( |
|
1007 | 1007 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
1008 | 1008 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
1009 | 1009 | ); |
1010 | 1010 | break; |
1011 | 1011 | |
1012 | 1012 | case 'entry_id': |
1013 | - $updated_field['key'] = 'entry_id'; |
|
1014 | - $updated_field['input'] = 'entry_id'; |
|
1015 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1013 | + $updated_field[ 'key' ] = 'entry_id'; |
|
1014 | + $updated_field[ 'input' ] = 'entry_id'; |
|
1015 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1016 | 1016 | break; |
1017 | 1017 | |
1018 | 1018 | case 'created_by': |
1019 | - $updated_field['key'] = 'created_by'; |
|
1020 | - $updated_field['name'] = 'gv_by'; |
|
1021 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1022 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
1019 | + $updated_field[ 'key' ] = 'created_by'; |
|
1020 | + $updated_field[ 'name' ] = 'gv_by'; |
|
1021 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1022 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
1023 | 1023 | break; |
1024 | 1024 | } |
1025 | 1025 | |
@@ -1038,16 +1038,16 @@ discard block |
||
1038 | 1038 | */ |
1039 | 1039 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context ); |
1040 | 1040 | |
1041 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1041 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1042 | 1042 | |
1043 | 1043 | /** @since 1.14 */ |
1044 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1044 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1045 | 1045 | |
1046 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1046 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1047 | 1047 | |
1048 | 1048 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1049 | 1049 | |
1050 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1050 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1051 | 1051 | |
1052 | 1052 | if ( $this->has_date_field( $search_fields ) ) { |
1053 | 1053 | // enqueue datepicker stuff only if needed! |
@@ -1069,10 +1069,10 @@ discard block |
||
1069 | 1069 | public static function get_search_class( $custom_class = '' ) { |
1070 | 1070 | $gravityview_view = GravityView_View::getInstance(); |
1071 | 1071 | |
1072 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1072 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1073 | 1073 | |
1074 | - if ( ! empty( $custom_class ) ) { |
|
1075 | - $search_class .= ' '.$custom_class; |
|
1074 | + if ( ! empty( $custom_class ) ) { |
|
1075 | + $search_class .= ' ' . $custom_class; |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | /** |
@@ -1116,9 +1116,9 @@ discard block |
||
1116 | 1116 | |
1117 | 1117 | if ( ! $label ) { |
1118 | 1118 | |
1119 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1119 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1120 | 1120 | |
1121 | - switch( $field['field'] ) { |
|
1121 | + switch ( $field[ 'field' ] ) { |
|
1122 | 1122 | case 'search_all': |
1123 | 1123 | $label = __( 'Search Entries:', 'gravityview' ); |
1124 | 1124 | break; |
@@ -1130,10 +1130,10 @@ discard block |
||
1130 | 1130 | break; |
1131 | 1131 | default: |
1132 | 1132 | // If this is a field input, not a field |
1133 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1133 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1134 | 1134 | |
1135 | 1135 | // Get the label for the field in question, which returns an array |
1136 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1136 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1137 | 1137 | |
1138 | 1138 | // Get the item with the `label` key |
1139 | 1139 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1172,32 +1172,32 @@ discard block |
||
1172 | 1172 | $form = $gravityview_view->getForm(); |
1173 | 1173 | |
1174 | 1174 | // for advanced field ids (eg, first name / last name ) |
1175 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1175 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1176 | 1176 | |
1177 | 1177 | // get searched value from $_GET/$_POST (string or array) |
1178 | 1178 | $value = $this->rgget_or_rgpost( $name ); |
1179 | 1179 | |
1180 | 1180 | // get form field details |
1181 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1181 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1182 | 1182 | |
1183 | 1183 | $filter = array( |
1184 | - 'key' => $field['field'], |
|
1184 | + 'key' => $field[ 'field' ], |
|
1185 | 1185 | 'name' => $name, |
1186 | 1186 | 'label' => self::get_field_label( $field, $form_field ), |
1187 | - 'input' => $field['input'], |
|
1187 | + 'input' => $field[ 'input' ], |
|
1188 | 1188 | 'value' => $value, |
1189 | - 'type' => $form_field['type'], |
|
1189 | + 'type' => $form_field[ 'type' ], |
|
1190 | 1190 | ); |
1191 | 1191 | |
1192 | 1192 | // collect choices |
1193 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1194 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1195 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1196 | - $filter['choices'] = $form_field['choices']; |
|
1193 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1194 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1195 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1196 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1197 | 1197 | } |
1198 | 1198 | |
1199 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1200 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1199 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1200 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1201 | 1201 | } |
1202 | 1202 | |
1203 | 1203 | return $filter; |
@@ -1221,7 +1221,7 @@ discard block |
||
1221 | 1221 | |
1222 | 1222 | $choices = array(); |
1223 | 1223 | foreach ( $users as $user ) { |
1224 | - $choices[] = array( |
|
1224 | + $choices[ ] = array( |
|
1225 | 1225 | 'value' => $user->ID, |
1226 | 1226 | 'text' => $user->display_name, |
1227 | 1227 | ); |
@@ -1276,7 +1276,7 @@ discard block |
||
1276 | 1276 | */ |
1277 | 1277 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1278 | 1278 | |
1279 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1279 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1280 | 1280 | |
1281 | 1281 | return $js_dependencies; |
1282 | 1282 | } |
@@ -1320,7 +1320,7 @@ discard block |
||
1320 | 1320 | 'isRTL' => is_rtl(), |
1321 | 1321 | ), $view_data ); |
1322 | 1322 | |
1323 | - $localizations['datepicker'] = $datepicker_settings; |
|
1323 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1324 | 1324 | |
1325 | 1325 | return $localizations; |
1326 | 1326 | |
@@ -1347,7 +1347,7 @@ discard block |
||
1347 | 1347 | * @return void |
1348 | 1348 | */ |
1349 | 1349 | private function maybe_enqueue_flexibility() { |
1350 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1350 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1351 | 1351 | wp_enqueue_script( 'gv-flexibility' ); |
1352 | 1352 | } |
1353 | 1353 | } |
@@ -1369,7 +1369,7 @@ discard block |
||
1369 | 1369 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1370 | 1370 | |
1371 | 1371 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1372 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1372 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1373 | 1373 | |
1374 | 1374 | /** |
1375 | 1375 | * @filter `gravityview_search_datepicker_class` |