@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | /** If this file is called directly, abort. */ |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | die; |
17 | 17 | } |
18 | 18 | |
@@ -25,18 +25,18 @@ discard block |
||
25 | 25 | * @param mixed $form_id |
26 | 26 | * @return mixed False: no form ID specified or Gravity Forms isn't active. Array: Form returned from Gravity Forms |
27 | 27 | */ |
28 | - public static function get_form( $form_id ) { |
|
29 | - if ( empty( $form_id ) ) { |
|
28 | + public static function get_form($form_id) { |
|
29 | + if (empty($form_id)) { |
|
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | 33 | // Only get_form_meta is cached. ::facepalm:: |
34 | - if ( class_exists( 'RGFormsModel' ) ) { |
|
35 | - return GFFormsModel::get_form_meta( $form_id ); |
|
34 | + if (class_exists('RGFormsModel')) { |
|
35 | + return GFFormsModel::get_form_meta($form_id); |
|
36 | 36 | } |
37 | 37 | |
38 | - if ( class_exists( 'GFAPI' ) ) { |
|
39 | - return GFAPI::get_form( $form_id ); |
|
38 | + if (class_exists('GFAPI')) { |
|
39 | + return GFAPI::get_form($form_id); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return false; |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return bool True: user has at least one passed capability; False: user does not have any defined capabilities |
57 | 57 | */ |
58 | - public static function has_cap( $caps = '', $object_id = null, $user_id = null ) { |
|
59 | - return GravityView_Roles_Capabilities::has_cap( $caps, $object_id, $user_id ); |
|
58 | + public static function has_cap($caps = '', $object_id = null, $user_id = null) { |
|
59 | + return GravityView_Roles_Capabilities::has_cap($caps, $object_id, $user_id); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | * @param array|GF_Fields $field Gravity Forms field or array |
68 | 68 | * @return array Array version of $field |
69 | 69 | */ |
70 | - public static function get_field_array( $field ) { |
|
70 | + public static function get_field_array($field) { |
|
71 | 71 | |
72 | - if ( class_exists( 'GF_Fields' ) ) { |
|
72 | + if (class_exists('GF_Fields')) { |
|
73 | 73 | |
74 | - $field_object = GF_Fields::create( $field ); |
|
74 | + $field_object = GF_Fields::create($field); |
|
75 | 75 | |
76 | 76 | // Convert the field object in 1.9 to an array for backward compatibility |
77 | - $field_array = get_object_vars( $field_object ); |
|
77 | + $field_array = get_object_vars($field_object); |
|
78 | 78 | |
79 | 79 | } else { |
80 | 80 | $field_array = $field; |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * @filter `gravityview/get_all_views/params` Modify the parameters sent to get all views. |
102 | 102 | * @param[in,out] array $params Array of parameters to pass to `get_posts()` |
103 | 103 | */ |
104 | - $views_params = apply_filters( 'gravityview/get_all_views/params', $params ); |
|
104 | + $views_params = apply_filters('gravityview/get_all_views/params', $params); |
|
105 | 105 | |
106 | - $views = get_posts( $views_params ); |
|
106 | + $views = get_posts($views_params); |
|
107 | 107 | |
108 | 108 | return $views; |
109 | 109 | } |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | * @param int|string $entry_slug Entry slug |
115 | 115 | * @return array Gravity Forms form array |
116 | 116 | */ |
117 | - public static function get_form_from_entry_id( $entry_slug ) { |
|
117 | + public static function get_form_from_entry_id($entry_slug) { |
|
118 | 118 | |
119 | - $entry = self::get_entry( $entry_slug, true ); |
|
119 | + $entry = self::get_entry($entry_slug, true); |
|
120 | 120 | |
121 | - $form = self::get_form( $entry['form_id'] ); |
|
121 | + $form = self::get_form($entry['form_id']); |
|
122 | 122 | |
123 | 123 | return $form; |
124 | 124 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @param string $slug The entry slug, as returned by GravityView_API::get_entry_slug() |
131 | 131 | * @return int|null The entry ID, if exists; `NULL` if not |
132 | 132 | */ |
133 | - public static function get_entry_id_from_slug( $slug ) { |
|
133 | + public static function get_entry_id_from_slug($slug) { |
|
134 | 134 | global $wpdb; |
135 | 135 | |
136 | 136 | $search_criteria = array( |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | 'page_size' => 1, |
150 | 150 | ); |
151 | 151 | |
152 | - $results = GFAPI::get_entries( 0, $search_criteria, null, $paging ); |
|
152 | + $results = GFAPI::get_entries(0, $search_criteria, null, $paging); |
|
153 | 153 | |
154 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
154 | + $result = (!empty($results) && !empty($results[0]['id'])) ? $results[0]['id'] : null; |
|
155 | 155 | |
156 | 156 | return $result; |
157 | 157 | } |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public static function get_forms() { |
168 | 168 | $forms = array(); |
169 | - if ( class_exists( 'GFAPI' ) ) { |
|
169 | + if (class_exists('GFAPI')) { |
|
170 | 170 | $gf_forms = GFAPI::get_forms(); |
171 | - foreach ( $gf_forms as $form ) { |
|
171 | + foreach ($gf_forms as $form) { |
|
172 | 172 | $forms[] = array( |
173 | 173 | 'id' => $form['id'], |
174 | 174 | 'title' => $form['title'], |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | * @param string|array $form_id (default: '') or $form object |
186 | 186 | * @return array |
187 | 187 | */ |
188 | - public static function get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) { |
|
188 | + public static function get_form_fields($form = '', $add_default_properties = false, $include_parent_field = true) { |
|
189 | 189 | |
190 | - if ( ! is_array( $form ) ) { |
|
191 | - $form = self::get_form( $form ); |
|
190 | + if (!is_array($form)) { |
|
191 | + $form = self::get_form($form); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | $fields = array(); |
@@ -198,56 +198,56 @@ discard block |
||
198 | 198 | $has_poll_fields = false; |
199 | 199 | |
200 | 200 | // If GF_Field exists, we're using GF 1.9+, where add_default_properties has been deprecated. |
201 | - if ( false === class_exists( 'GF_Field' ) && $add_default_properties ) { |
|
202 | - $form = RGFormsModel::add_default_properties( $form ); |
|
201 | + if (false === class_exists('GF_Field') && $add_default_properties) { |
|
202 | + $form = RGFormsModel::add_default_properties($form); |
|
203 | 203 | } |
204 | 204 | |
205 | - if ( $form ) { |
|
206 | - foreach ( $form['fields'] as $field ) { |
|
207 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
208 | - $fields[ $field['id'] ] = array( |
|
209 | - 'label' => rgar( $field, 'label' ), |
|
205 | + if ($form) { |
|
206 | + foreach ($form['fields'] as $field) { |
|
207 | + if ($include_parent_field || empty($field['inputs'])) { |
|
208 | + $fields[$field['id']] = array( |
|
209 | + 'label' => rgar($field, 'label'), |
|
210 | 210 | 'parent' => null, |
211 | - 'type' => rgar( $field, 'type' ), |
|
212 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
213 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
211 | + 'type' => rgar($field, 'type'), |
|
212 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
213 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
214 | 214 | ); |
215 | 215 | } |
216 | 216 | |
217 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
218 | - foreach ( $field['inputs'] as $input ) { |
|
217 | + if ($add_default_properties && !empty($field['inputs'])) { |
|
218 | + foreach ($field['inputs'] as $input) { |
|
219 | 219 | /** |
220 | 220 | * @hack |
221 | 221 | * In case of email/email confirmation, the input for email has the same id as the parent field |
222 | 222 | */ |
223 | - if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
223 | + if ('email' == rgar($field, 'type') && false === strpos($input['id'], '.')) { |
|
224 | 224 | continue; |
225 | 225 | } |
226 | - $fields[ (string)$input['id'] ] = array( |
|
227 | - 'label' => rgar( $input, 'label' ), |
|
228 | - 'customLabel' => rgar( $input, 'customLabel' ), |
|
226 | + $fields[(string)$input['id']] = array( |
|
227 | + 'label' => rgar($input, 'label'), |
|
228 | + 'customLabel' => rgar($input, 'customLabel'), |
|
229 | 229 | 'parent' => $field, |
230 | - 'type' => rgar( $field, 'type' ), |
|
231 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
232 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
230 | + 'type' => rgar($field, 'type'), |
|
231 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
232 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
233 | 233 | ); |
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | 237 | /** @since 1.14 */ |
238 | - if( 'list' === $field['type'] && !empty( $field['enableColumns'] ) ) { |
|
238 | + if ('list' === $field['type'] && !empty($field['enableColumns'])) { |
|
239 | 239 | |
240 | - foreach ( (array)$field['choices'] as $key => $input ) { |
|
240 | + foreach ((array)$field['choices'] as $key => $input) { |
|
241 | 241 | |
242 | - $input_id = sprintf( '%d.%d', $field['id'], $key ); // {field_id}.{column_key} |
|
242 | + $input_id = sprintf('%d.%d', $field['id'], $key); // {field_id}.{column_key} |
|
243 | 243 | |
244 | - $fields[ $input_id ] = array( |
|
245 | - 'label' => rgar( $input, 'text' ), |
|
244 | + $fields[$input_id] = array( |
|
245 | + 'label' => rgar($input, 'text'), |
|
246 | 246 | 'customLabel' => '', |
247 | 247 | 'parent' => $field, |
248 | - 'type' => rgar( $field, 'type' ), |
|
249 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
250 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
248 | + 'type' => rgar($field, 'type'), |
|
249 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
250 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
251 | 251 | ); |
252 | 252 | } |
253 | 253 | } |
@@ -255,27 +255,27 @@ discard block |
||
255 | 255 | /** |
256 | 256 | * @since 1.8 |
257 | 257 | */ |
258 | - if( 'quiz' === $field['type'] ) { |
|
258 | + if ('quiz' === $field['type']) { |
|
259 | 259 | $has_quiz_fields = true; |
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
263 | 263 | * @since 1.8 |
264 | 264 | */ |
265 | - if( 'poll' === $field['type'] ) { |
|
265 | + if ('poll' === $field['type']) { |
|
266 | 266 | $has_poll_fields = true; |
267 | 267 | } |
268 | 268 | |
269 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
269 | + if (GFCommon::is_product_field($field['type'])) { |
|
270 | 270 | $has_product_fields = true; |
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
274 | 274 | * @hack Version 1.9 |
275 | 275 | */ |
276 | - $field_for_is_post_field = class_exists( 'GF_Fields' ) ? (object) $field : (array) $field; |
|
276 | + $field_for_is_post_field = class_exists('GF_Fields') ? (object)$field : (array)$field; |
|
277 | 277 | |
278 | - if ( GFCommon::is_post_field( $field_for_is_post_field ) ) { |
|
278 | + if (GFCommon::is_post_field($field_for_is_post_field)) { |
|
279 | 279 | $has_post_fields = true; |
280 | 280 | } |
281 | 281 | } |
@@ -284,47 +284,47 @@ discard block |
||
284 | 284 | /** |
285 | 285 | * @since 1.7 |
286 | 286 | */ |
287 | - if ( $has_post_fields ) { |
|
287 | + if ($has_post_fields) { |
|
288 | 288 | $fields['post_id'] = array( |
289 | - 'label' => __( 'Post ID', 'gravityview' ), |
|
289 | + 'label' => __('Post ID', 'gravityview'), |
|
290 | 290 | 'type' => 'post_id', |
291 | 291 | ); |
292 | 292 | } |
293 | 293 | |
294 | - if ( $has_product_fields ) { |
|
294 | + if ($has_product_fields) { |
|
295 | 295 | |
296 | 296 | $fields['payment_status'] = array( |
297 | - 'label' => __( 'Payment Status', 'gravityview' ), |
|
297 | + 'label' => __('Payment Status', 'gravityview'), |
|
298 | 298 | 'type' => 'payment_status', |
299 | 299 | ); |
300 | 300 | |
301 | 301 | $fields['payment_date'] = array( |
302 | - 'label' => __( 'Payment Date', 'gravityview' ), |
|
302 | + 'label' => __('Payment Date', 'gravityview'), |
|
303 | 303 | 'type' => 'payment_date', |
304 | 304 | ); |
305 | 305 | |
306 | 306 | $fields['payment_amount'] = array( |
307 | - 'label' => __( 'Payment Amount', 'gravityview' ), |
|
307 | + 'label' => __('Payment Amount', 'gravityview'), |
|
308 | 308 | 'type' => 'payment_amount', |
309 | 309 | ); |
310 | 310 | |
311 | 311 | $fields['payment_method'] = array( |
312 | - 'label' => __( 'Payment Method', 'gravityview' ), |
|
312 | + 'label' => __('Payment Method', 'gravityview'), |
|
313 | 313 | 'type' => 'payment_method', |
314 | 314 | ); |
315 | 315 | |
316 | 316 | $fields['is_fulfilled'] = array( |
317 | - 'label' => __( 'Is Fulfilled', 'gravityview' ), |
|
317 | + 'label' => __('Is Fulfilled', 'gravityview'), |
|
318 | 318 | 'type' => 'is_fulfilled', |
319 | 319 | ); |
320 | 320 | |
321 | 321 | $fields['transaction_id'] = array( |
322 | - 'label' => __( 'Transaction ID', 'gravityview' ), |
|
322 | + 'label' => __('Transaction ID', 'gravityview'), |
|
323 | 323 | 'type' => 'transaction_id', |
324 | 324 | ); |
325 | 325 | |
326 | 326 | $fields['transaction_type'] = array( |
327 | - 'label' => __( 'Transaction Type', 'gravityview' ), |
|
327 | + 'label' => __('Transaction Type', 'gravityview'), |
|
328 | 328 | 'type' => 'transaction_type', |
329 | 329 | ); |
330 | 330 | |
@@ -333,27 +333,27 @@ discard block |
||
333 | 333 | /** |
334 | 334 | * @since 1.8 |
335 | 335 | */ |
336 | - if( $has_quiz_fields ) { |
|
336 | + if ($has_quiz_fields) { |
|
337 | 337 | |
338 | - $fields['gquiz_score'] = array( |
|
339 | - 'label' => __( 'Quiz Score Total', 'gravityview' ), |
|
338 | + $fields['gquiz_score'] = array( |
|
339 | + 'label' => __('Quiz Score Total', 'gravityview'), |
|
340 | 340 | 'type' => 'quiz_score', |
341 | - 'desc' => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ), |
|
341 | + 'desc' => __('Displays the number of correct Quiz answers the user submitted.', 'gravityview'), |
|
342 | 342 | ); |
343 | 343 | $fields['gquiz_percent'] = array( |
344 | - 'label' => __( 'Quiz Percentage Grade', 'gravityview' ), |
|
344 | + 'label' => __('Quiz Percentage Grade', 'gravityview'), |
|
345 | 345 | 'type' => 'quiz_percent', |
346 | - 'desc' => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ), |
|
346 | + 'desc' => __('Displays the percentage of correct Quiz answers the user submitted.', 'gravityview'), |
|
347 | 347 | ); |
348 | - $fields['gquiz_grade'] = array( |
|
349 | - 'label' => __( 'Quiz Letter Grade', 'gravityview' ), |
|
348 | + $fields['gquiz_grade'] = array( |
|
349 | + 'label' => __('Quiz Letter Grade', 'gravityview'), |
|
350 | 350 | 'type' => 'quiz_grade', |
351 | - 'desc' => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ), |
|
351 | + 'desc' => __('Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview'), |
|
352 | 352 | ); |
353 | 353 | $fields['gquiz_is_pass'] = array( |
354 | - 'label' => __( 'Quiz Pass/Fail', 'gravityview' ), |
|
354 | + 'label' => __('Quiz Pass/Fail', 'gravityview'), |
|
355 | 355 | 'type' => 'quiz_is_pass', |
356 | - 'desc' => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ), |
|
356 | + 'desc' => __('Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview'), |
|
357 | 357 | ); |
358 | 358 | } |
359 | 359 | |
@@ -367,15 +367,15 @@ discard block |
||
367 | 367 | * @param string $form_id (default: '') |
368 | 368 | * @return array |
369 | 369 | */ |
370 | - public static function get_entry_meta( $form_id, $only_default_column = true ) { |
|
370 | + public static function get_entry_meta($form_id, $only_default_column = true) { |
|
371 | 371 | |
372 | - $extra_fields = GFFormsModel::get_entry_meta( $form_id ); |
|
372 | + $extra_fields = GFFormsModel::get_entry_meta($form_id); |
|
373 | 373 | |
374 | 374 | $fields = array(); |
375 | 375 | |
376 | - foreach ( $extra_fields as $key => $field ){ |
|
377 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
378 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
376 | + foreach ($extra_fields as $key => $field) { |
|
377 | + if (!empty($only_default_column) && !empty($field['is_default_column'])) { |
|
378 | + $fields[$key] = array('label' => $field['label'], 'type' => 'entry_meta'); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | * @since 1.1.6 |
392 | 392 | * @return array Array of entry IDs |
393 | 393 | */ |
394 | - public static function get_entry_ids( $form_id, $search_criteria = array() ) { |
|
394 | + public static function get_entry_ids($form_id, $search_criteria = array()) { |
|
395 | 395 | |
396 | - if ( ! class_exists( 'GFFormsModel' ) ) { |
|
396 | + if (!class_exists('GFFormsModel')) { |
|
397 | 397 | return; |
398 | 398 | } |
399 | 399 | |
400 | - return GFFormsModel::search_lead_ids( $form_id, $search_criteria ); |
|
400 | + return GFFormsModel::search_lead_ids($form_id, $search_criteria); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | /** |
@@ -409,33 +409,33 @@ discard block |
||
409 | 409 | * @param null $form_ids array Gravity Forms form IDs |
410 | 410 | * @return array|mixed|void |
411 | 411 | */ |
412 | - public static function calculate_get_entries_criteria( $passed_criteria = null, $form_ids = null ) { |
|
412 | + public static function calculate_get_entries_criteria($passed_criteria = null, $form_ids = null) { |
|
413 | 413 | |
414 | 414 | $search_criteria_defaults = array( |
415 | 415 | 'search_criteria' => null, |
416 | 416 | 'sorting' => null, |
417 | 417 | 'paging' => null, |
418 | - 'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true), |
|
418 | + 'cache' => (isset($passed_criteria['cache']) ? $passed_criteria['cache'] : true), |
|
419 | 419 | ); |
420 | 420 | |
421 | - $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
|
421 | + $criteria = wp_parse_args($passed_criteria, $search_criteria_defaults); |
|
422 | 422 | |
423 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
424 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
423 | + if (!empty($criteria['search_criteria']['field_filters'])) { |
|
424 | + foreach ($criteria['search_criteria']['field_filters'] as &$filter) { |
|
425 | 425 | |
426 | - if ( ! is_array( $filter ) ) { |
|
426 | + if (!is_array($filter)) { |
|
427 | 427 | continue; |
428 | 428 | } |
429 | 429 | |
430 | 430 | // By default, we want searches to be wildcard for each field. |
431 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
431 | + $filter['operator'] = empty($filter['operator']) ? 'contains' : $filter['operator']; |
|
432 | 432 | |
433 | 433 | /** |
434 | 434 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
435 | 435 | * @param string $operator Existing search operator |
436 | 436 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
437 | 437 | */ |
438 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
438 | + $filter['operator'] = apply_filters('gravityview_search_operator', $filter['operator'], $filter); |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | |
@@ -443,32 +443,32 @@ discard block |
||
443 | 443 | * Prepare date formats to be in Gravity Forms DB format; |
444 | 444 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
445 | 445 | */ |
446 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
446 | + foreach (array('start_date', 'end_date') as $key) { |
|
447 | 447 | |
448 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
448 | + if (!empty($criteria['search_criteria'][$key])) { |
|
449 | 449 | |
450 | 450 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
451 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
451 | + $date = date_create($criteria['search_criteria'][$key]); |
|
452 | 452 | |
453 | - if ( $date ) { |
|
453 | + if ($date) { |
|
454 | 454 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
455 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
455 | + $criteria['search_criteria'][$key] = $date->format('Y-m-d H:i:s'); |
|
456 | 456 | } else { |
457 | 457 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
458 | - unset( $criteria['search_criteria'][ $key ] ); |
|
458 | + unset($criteria['search_criteria'][$key]); |
|
459 | 459 | |
460 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
460 | + do_action('gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][$key]); |
|
461 | 461 | } |
462 | 462 | } |
463 | 463 | } |
464 | 464 | |
465 | 465 | |
466 | 466 | // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter |
467 | - if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) { |
|
467 | + if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry()) { |
|
468 | 468 | $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
469 | - } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
|
470 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null; |
|
471 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
469 | + } elseif ('delete' === RGForms::get('action')) { |
|
470 | + $criteria['context_view_id'] = isset($_GET['view_id']) ? $_GET['view_id'] : null; |
|
471 | + } elseif (!isset($criteria['context_view_id'])) { |
|
472 | 472 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
473 | 473 | $criteria['context_view_id'] = null; |
474 | 474 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * @param array $form_ids Forms to search |
480 | 480 | * @param int $view_id ID of the view being used to search |
481 | 481 | */ |
482 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
482 | + $criteria = apply_filters('gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id']); |
|
483 | 483 | |
484 | 484 | return $criteria; |
485 | 485 | |
@@ -497,32 +497,32 @@ discard block |
||
497 | 497 | * @param mixed &$total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate the total count. (default: null) |
498 | 498 | * @return mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays |
499 | 499 | */ |
500 | - public static function get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) { |
|
500 | + public static function get_entries($form_ids = null, $passed_criteria = null, &$total = null) { |
|
501 | 501 | |
502 | 502 | // Filter the criteria before query (includes Adv Filter) |
503 | - $criteria = self::calculate_get_entries_criteria( $passed_criteria, $form_ids ); |
|
503 | + $criteria = self::calculate_get_entries_criteria($passed_criteria, $form_ids); |
|
504 | 504 | |
505 | - do_action( 'gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria ); |
|
505 | + do_action('gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria); |
|
506 | 506 | |
507 | 507 | // Return value |
508 | 508 | $return = null; |
509 | 509 | |
510 | - if ( ! empty( $criteria['cache'] ) ) { |
|
510 | + if (!empty($criteria['cache'])) { |
|
511 | 511 | |
512 | - $Cache = new GravityView_Cache( $form_ids, $criteria ); |
|
512 | + $Cache = new GravityView_Cache($form_ids, $criteria); |
|
513 | 513 | |
514 | - if ( $entries = $Cache->get() ) { |
|
514 | + if ($entries = $Cache->get()) { |
|
515 | 515 | |
516 | 516 | // Still update the total count when using cached results |
517 | - if ( ! is_null( $total ) ) { |
|
518 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
517 | + if (!is_null($total)) { |
|
518 | + $total = GFAPI::count_entries($form_ids, $criteria['search_criteria']); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | $return = $entries; |
522 | 522 | } |
523 | 523 | } |
524 | 524 | |
525 | - if ( is_null( $return ) && class_exists( 'GFAPI' ) && ( is_numeric( $form_ids ) || is_array( $form_ids ) ) ) { |
|
525 | + if (is_null($return) && class_exists('GFAPI') && (is_numeric($form_ids) || is_array($form_ids))) { |
|
526 | 526 | |
527 | 527 | /** |
528 | 528 | * @filter `gravityview_pre_get_entries` Define entries to be used before GFAPI::get_entries() is called |
@@ -532,24 +532,24 @@ discard block |
||
532 | 532 | * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()` |
533 | 533 | * @param int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate |
534 | 534 | */ |
535 | - $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
|
535 | + $entries = apply_filters('gravityview_before_get_entries', null, $criteria, $passed_criteria, $total); |
|
536 | 536 | |
537 | 537 | // No entries returned from gravityview_before_get_entries |
538 | - if( is_null( $entries ) ) { |
|
538 | + if (is_null($entries)) { |
|
539 | 539 | |
540 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
540 | + $entries = GFAPI::get_entries($form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total); |
|
541 | 541 | |
542 | - if ( is_wp_error( $entries ) ) { |
|
543 | - do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
|
542 | + if (is_wp_error($entries)) { |
|
543 | + do_action('gravityview_log_error', $entries->get_error_message(), $entries); |
|
544 | 544 | |
545 | 545 | return false; |
546 | 546 | } |
547 | 547 | } |
548 | 548 | |
549 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
549 | + if (!empty($criteria['cache']) && isset($Cache)) { |
|
550 | 550 | |
551 | 551 | // Cache results |
552 | - $Cache->set( $entries, 'entries' ); |
|
552 | + $Cache->set($entries, 'entries'); |
|
553 | 553 | |
554 | 554 | } |
555 | 555 | |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()` |
564 | 564 | * @param int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate |
565 | 565 | */ |
566 | - $return = apply_filters( 'gravityview_entries', $return, $criteria, $passed_criteria, $total ); |
|
566 | + $return = apply_filters('gravityview_entries', $return, $criteria, $passed_criteria, $total); |
|
567 | 567 | |
568 | 568 | return $return; |
569 | 569 | } |
@@ -580,15 +580,15 @@ discard block |
||
580 | 580 | * @param boolean $check_entry_display Check whether the entry is visible for the current View configuration. Default: true. {@since 1.14} |
581 | 581 | * @return array|boolean |
582 | 582 | */ |
583 | - public static function get_entry( $entry_slug, $force_allow_ids = false, $check_entry_display = true ) { |
|
583 | + public static function get_entry($entry_slug, $force_allow_ids = false, $check_entry_display = true) { |
|
584 | 584 | |
585 | - if ( class_exists( 'GFAPI' ) && ! empty( $entry_slug ) ) { |
|
585 | + if (class_exists('GFAPI') && !empty($entry_slug)) { |
|
586 | 586 | |
587 | 587 | /** |
588 | 588 | * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. |
589 | 589 | * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) |
590 | 590 | */ |
591 | - $custom_slug = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
591 | + $custom_slug = apply_filters('gravityview_custom_entry_slug', false); |
|
592 | 592 | |
593 | 593 | /** |
594 | 594 | * @filter `gravityview_custom_entry_slug_allow_id` When using a custom slug, allow access to the entry using the original slug (the Entry ID). |
@@ -596,38 +596,38 @@ discard block |
||
596 | 596 | * - If enabled, you could access using the custom slug OR the entry id (example: `/entry/custom-slug/` OR `/entry/123/`) |
597 | 597 | * @param boolean $custom_slug_id_access True: allow accessing the slug by ID; False: only use the slug passed to the method. |
598 | 598 | */ |
599 | - $custom_slug_id_access = $force_allow_ids || apply_filters( 'gravityview_custom_entry_slug_allow_id', false ); |
|
599 | + $custom_slug_id_access = $force_allow_ids || apply_filters('gravityview_custom_entry_slug_allow_id', false); |
|
600 | 600 | |
601 | 601 | /** |
602 | 602 | * If we're using custom entry slugs, we do a meta value search |
603 | 603 | * instead of doing a straightup ID search. |
604 | 604 | */ |
605 | - if ( $custom_slug ) { |
|
605 | + if ($custom_slug) { |
|
606 | 606 | |
607 | - $entry_id = self::get_entry_id_from_slug( $entry_slug ); |
|
607 | + $entry_id = self::get_entry_id_from_slug($entry_slug); |
|
608 | 608 | |
609 | 609 | } |
610 | 610 | |
611 | 611 | // If custom slug is off, search using the entry ID |
612 | 612 | // ID allow ID access is on, also use entry ID as a backup |
613 | - if ( empty( $custom_slug ) || ! empty( $custom_slug_id_access ) ) { |
|
613 | + if (empty($custom_slug) || !empty($custom_slug_id_access)) { |
|
614 | 614 | // Search for IDs matching $entry_slug |
615 | 615 | $entry_id = $entry_slug; |
616 | 616 | } |
617 | 617 | |
618 | - if ( empty( $entry_id ) ) { |
|
618 | + if (empty($entry_id)) { |
|
619 | 619 | return false; |
620 | 620 | } |
621 | 621 | |
622 | 622 | // fetch the entry |
623 | - $entry = GFAPI::get_entry( $entry_id ); |
|
623 | + $entry = GFAPI::get_entry($entry_id); |
|
624 | 624 | |
625 | - if( $check_entry_display ) { |
|
625 | + if ($check_entry_display) { |
|
626 | 626 | // Is the entry allowed |
627 | - $entry = self::check_entry_display( $entry ); |
|
627 | + $entry = self::check_entry_display($entry); |
|
628 | 628 | } |
629 | 629 | |
630 | - return is_wp_error( $entry ) ? false : $entry; |
|
630 | + return is_wp_error($entry) ? false : $entry; |
|
631 | 631 | |
632 | 632 | } |
633 | 633 | |
@@ -651,51 +651,51 @@ discard block |
||
651 | 651 | * |
652 | 652 | * @return bool True: matches, false: not matches |
653 | 653 | */ |
654 | - public static function matches_operation( $val1, $val2, $operation ) { |
|
654 | + public static function matches_operation($val1, $val2, $operation) { |
|
655 | 655 | |
656 | 656 | $value = false; |
657 | 657 | |
658 | - if( 'context' === $val1 ) { |
|
658 | + if ('context' === $val1) { |
|
659 | 659 | |
660 | - $matching_contexts = array( $val2 ); |
|
660 | + $matching_contexts = array($val2); |
|
661 | 661 | |
662 | 662 | // We allow for non-standard contexts. |
663 | - switch( $val2 ) { |
|
663 | + switch ($val2) { |
|
664 | 664 | // Check for either single or edit |
665 | 665 | case 'singular': |
666 | - $matching_contexts = array( 'single', 'edit' ); |
|
666 | + $matching_contexts = array('single', 'edit'); |
|
667 | 667 | break; |
668 | 668 | // Use multiple as alias for directory for consistency |
669 | 669 | case 'multiple': |
670 | - $matching_contexts = array( 'directory' ); |
|
670 | + $matching_contexts = array('directory'); |
|
671 | 671 | break; |
672 | 672 | } |
673 | 673 | |
674 | - $val1 = in_array( gravityview_get_context(), $matching_contexts ) ? $val2 : false; |
|
674 | + $val1 = in_array(gravityview_get_context(), $matching_contexts) ? $val2 : false; |
|
675 | 675 | } |
676 | 676 | |
677 | - switch ( $operation ) { |
|
677 | + switch ($operation) { |
|
678 | 678 | case 'equals': |
679 | - $value = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
679 | + $value = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
680 | 680 | break; |
681 | 681 | case 'greater_than_or_is': |
682 | 682 | case 'greater_than_or_equals': |
683 | - $is = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
684 | - $gt = GFFormsModel::matches_operation( $val1, $val2, 'greater_than' ); |
|
685 | - $value = ( $is || $gt ); |
|
683 | + $is = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
684 | + $gt = GFFormsModel::matches_operation($val1, $val2, 'greater_than'); |
|
685 | + $value = ($is || $gt); |
|
686 | 686 | break; |
687 | 687 | case 'less_than_or_is': |
688 | 688 | case 'less_than_or_equals': |
689 | - $is = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
690 | - $gt = GFFormsModel::matches_operation( $val1, $val2, 'less_than' ); |
|
691 | - $value = ( $is || $gt ); |
|
689 | + $is = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
690 | + $gt = GFFormsModel::matches_operation($val1, $val2, 'less_than'); |
|
691 | + $value = ($is || $gt); |
|
692 | 692 | break; |
693 | 693 | case 'not_contains': |
694 | - $contains = GFFormsModel::matches_operation( $val1, $val2, 'contains' ); |
|
695 | - $value = ! $contains; |
|
694 | + $contains = GFFormsModel::matches_operation($val1, $val2, 'contains'); |
|
695 | + $value = !$contains; |
|
696 | 696 | break; |
697 | 697 | default: |
698 | - $value = GFFormsModel::matches_operation( $val1, $val2, $operation ); |
|
698 | + $value = GFFormsModel::matches_operation($val1, $val2, $operation); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | return $value; |
@@ -712,31 +712,31 @@ discard block |
||
712 | 712 | * @param array $entry Gravity Forms Entry object |
713 | 713 | * @return bool|array Returns 'false' if entry is not valid according to the view search filters (Adv Filter) |
714 | 714 | */ |
715 | - public static function check_entry_display( $entry ) { |
|
715 | + public static function check_entry_display($entry) { |
|
716 | 716 | |
717 | - if ( ! $entry || is_wp_error( $entry ) ) { |
|
718 | - do_action( 'gravityview_log_debug', __METHOD__ . ' Entry was not found.', $entry ); |
|
717 | + if (!$entry || is_wp_error($entry)) { |
|
718 | + do_action('gravityview_log_debug', __METHOD__.' Entry was not found.', $entry); |
|
719 | 719 | return false; |
720 | 720 | } |
721 | 721 | |
722 | - if ( empty( $entry['form_id'] ) ) { |
|
723 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
|
722 | + if (empty($entry['form_id'])) { |
|
723 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry); |
|
724 | 724 | return false; |
725 | 725 | } |
726 | 726 | |
727 | 727 | $criteria = self::calculate_get_entries_criteria(); |
728 | 728 | |
729 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
730 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
|
729 | + if (empty($criteria['search_criteria']) || !is_array($criteria['search_criteria'])) { |
|
730 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria); |
|
731 | 731 | return $entry; |
732 | 732 | } |
733 | 733 | |
734 | 734 | $search_criteria = $criteria['search_criteria']; |
735 | - unset( $criteria ); |
|
735 | + unset($criteria); |
|
736 | 736 | |
737 | 737 | // check entry status |
738 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
739 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
738 | + if (array_key_exists('status', $search_criteria) && $search_criteria['status'] != $entry['status']) { |
|
739 | + do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status']), $search_criteria); |
|
740 | 740 | return false; |
741 | 741 | } |
742 | 742 | |
@@ -744,53 +744,53 @@ discard block |
||
744 | 744 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
745 | 745 | |
746 | 746 | // field_filters |
747 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
748 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
|
747 | + if (empty($search_criteria['field_filters']) || !is_array($search_criteria['field_filters'])) { |
|
748 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria); |
|
749 | 749 | return $entry; |
750 | 750 | } |
751 | 751 | |
752 | 752 | $filters = $search_criteria['field_filters']; |
753 | - unset( $search_criteria ); |
|
753 | + unset($search_criteria); |
|
754 | 754 | |
755 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
756 | - unset( $filters['mode'] ); |
|
755 | + $mode = array_key_exists('mode', $filters) ? strtolower($filters['mode']) : 'all'; |
|
756 | + unset($filters['mode']); |
|
757 | 757 | |
758 | - $form = self::get_form( $entry['form_id'] ); |
|
758 | + $form = self::get_form($entry['form_id']); |
|
759 | 759 | |
760 | - foreach ( $filters as $filter ) { |
|
760 | + foreach ($filters as $filter) { |
|
761 | 761 | |
762 | - if ( ! isset( $filter['key'] ) ) { |
|
762 | + if (!isset($filter['key'])) { |
|
763 | 763 | continue; |
764 | 764 | } |
765 | 765 | |
766 | 766 | $k = $filter['key']; |
767 | 767 | |
768 | - if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
|
769 | - $field_value = $entry[ $k ]; |
|
768 | + if (in_array($k, array('created_by', 'payment_status'))) { |
|
769 | + $field_value = $entry[$k]; |
|
770 | 770 | $field = null; |
771 | 771 | } else { |
772 | - $field = self::get_field( $form, $k ); |
|
773 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
772 | + $field = self::get_field($form, $k); |
|
773 | + $field_value = GFFormsModel::get_lead_field_value($entry, $field); |
|
774 | 774 | } |
775 | 775 | |
776 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
777 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
776 | + $operator = isset($filter['operator']) ? strtolower($filter['operator']) : 'is'; |
|
777 | + $is_value_match = GFFormsModel::is_value_match($field_value, $filter['value'], $operator, $field); |
|
778 | 778 | |
779 | 779 | // verify if we are already free to go! |
780 | - if ( ! $is_value_match && 'all' === $mode ) { |
|
781 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter ); |
|
780 | + if (!$is_value_match && 'all' === $mode) { |
|
781 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter); |
|
782 | 782 | return false; |
783 | - } elseif ( $is_value_match && 'any' === $mode ) { |
|
783 | + } elseif ($is_value_match && 'any' === $mode) { |
|
784 | 784 | return $entry; |
785 | 785 | } |
786 | 786 | } |
787 | 787 | |
788 | 788 | // at this point, if in ALL mode, then entry is approved - all conditions were met. |
789 | 789 | // Or, for ANY mode, means none of the conditions were satisfied, so entry is not approved |
790 | - if ( 'all' === $mode ) { |
|
790 | + if ('all' === $mode) { |
|
791 | 791 | return $entry; |
792 | 792 | } else { |
793 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
793 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters); |
|
794 | 794 | return false; |
795 | 795 | } |
796 | 796 | |
@@ -805,14 +805,14 @@ discard block |
||
805 | 805 | * @param string $field_id |
806 | 806 | * @return string |
807 | 807 | */ |
808 | - public static function get_field_label( $form = array(), $field_id = '' ) { |
|
808 | + public static function get_field_label($form = array(), $field_id = '') { |
|
809 | 809 | |
810 | - if ( empty( $form ) || empty( $field_id ) ) { |
|
810 | + if (empty($form) || empty($field_id)) { |
|
811 | 811 | return ''; |
812 | 812 | } |
813 | 813 | |
814 | - $field = self::get_field( $form, $field_id ); |
|
815 | - return isset( $field['label'] ) ? $field['label'] : ''; |
|
814 | + $field = self::get_field($form, $field_id); |
|
815 | + return isset($field['label']) ? $field['label'] : ''; |
|
816 | 816 | |
817 | 817 | } |
818 | 818 | |
@@ -829,9 +829,9 @@ discard block |
||
829 | 829 | * @param string|int $field_id |
830 | 830 | * @return array|null Array: Gravity Forms field array; NULL: Gravity Forms GFFormsModel does not exist |
831 | 831 | */ |
832 | - public static function get_field( $form, $field_id ) { |
|
833 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
834 | - return GFFormsModel::get_field( $form, $field_id ); |
|
832 | + public static function get_field($form, $field_id) { |
|
833 | + if (class_exists('GFFormsModel')) { |
|
834 | + return GFFormsModel::get_field($form, $field_id); |
|
835 | 835 | } else { |
836 | 836 | return null; |
837 | 837 | } |
@@ -847,16 +847,16 @@ discard block |
||
847 | 847 | * @param WP_Post $post WordPress post object |
848 | 848 | * @return boolean True: yep, GravityView; No: not! |
849 | 849 | */ |
850 | - public static function has_gravityview_shortcode( $post = null ) { |
|
851 | - if ( ! is_a( $post, 'WP_Post' ) ) { |
|
850 | + public static function has_gravityview_shortcode($post = null) { |
|
851 | + if (!is_a($post, 'WP_Post')) { |
|
852 | 852 | return false; |
853 | 853 | } |
854 | 854 | |
855 | - if ( 'gravityview' === get_post_type( $post ) ) { |
|
855 | + if ('gravityview' === get_post_type($post)) { |
|
856 | 856 | return true; |
857 | 857 | } |
858 | 858 | |
859 | - return self::has_shortcode_r( $post->post_content, 'gravityview' ) ? true : false; |
|
859 | + return self::has_shortcode_r($post->post_content, 'gravityview') ? true : false; |
|
860 | 860 | |
861 | 861 | } |
862 | 862 | |
@@ -867,27 +867,27 @@ discard block |
||
867 | 867 | * @param string $content Content to check whether there's a shortcode |
868 | 868 | * @param string $tag Current shortcode tag |
869 | 869 | */ |
870 | - public static function has_shortcode_r( $content, $tag = 'gravityview' ) { |
|
871 | - if ( false === strpos( $content, '[' ) ) { |
|
870 | + public static function has_shortcode_r($content, $tag = 'gravityview') { |
|
871 | + if (false === strpos($content, '[')) { |
|
872 | 872 | return false; |
873 | 873 | } |
874 | 874 | |
875 | - if ( shortcode_exists( $tag ) ) { |
|
875 | + if (shortcode_exists($tag)) { |
|
876 | 876 | |
877 | 877 | $shortcodes = array(); |
878 | 878 | |
879 | - preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
|
880 | - if ( empty( $matches ) ){ |
|
879 | + preg_match_all('/'.get_shortcode_regex().'/s', $content, $matches, PREG_SET_ORDER); |
|
880 | + if (empty($matches)) { |
|
881 | 881 | return false; |
882 | 882 | } |
883 | 883 | |
884 | - foreach ( $matches as $shortcode ) { |
|
885 | - if ( $tag === $shortcode[2] ) { |
|
884 | + foreach ($matches as $shortcode) { |
|
885 | + if ($tag === $shortcode[2]) { |
|
886 | 886 | |
887 | 887 | // Changed this to $shortcode instead of true so we get the parsed atts. |
888 | 888 | $shortcodes[] = $shortcode; |
889 | 889 | |
890 | - } else if ( isset( $shortcode[5] ) && $result = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
890 | + } else if (isset($shortcode[5]) && $result = self::has_shortcode_r($shortcode[5], $tag)) { |
|
891 | 891 | $shortcodes = $result; |
892 | 892 | } |
893 | 893 | } |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | * |
912 | 912 | * @return array Array with view details, as returned by get_posts() |
913 | 913 | */ |
914 | - public static function get_connected_views( $form_id, $args = array() ) { |
|
914 | + public static function get_connected_views($form_id, $args = array()) { |
|
915 | 915 | |
916 | 916 | $defaults = array( |
917 | 917 | 'post_type' => 'gravityview', |
@@ -920,9 +920,9 @@ discard block |
||
920 | 920 | 'meta_value' => (int)$form_id, |
921 | 921 | ); |
922 | 922 | |
923 | - $args = wp_parse_args( $args, $defaults ); |
|
923 | + $args = wp_parse_args($args, $defaults); |
|
924 | 924 | |
925 | - $views = get_posts( $args ); |
|
925 | + $views = get_posts($args); |
|
926 | 926 | |
927 | 927 | return $views; |
928 | 928 | } |
@@ -934,8 +934,8 @@ discard block |
||
934 | 934 | * |
935 | 935 | * @return string ID of the connected Form, if exists. Empty string if not. |
936 | 936 | */ |
937 | - public static function get_meta_form_id( $view_id ) { |
|
938 | - return get_post_meta( $view_id, '_gravityview_form_id', true ); |
|
937 | + public static function get_meta_form_id($view_id) { |
|
938 | + return get_post_meta($view_id, '_gravityview_form_id', true); |
|
939 | 939 | } |
940 | 940 | |
941 | 941 | /** |
@@ -947,8 +947,8 @@ discard block |
||
947 | 947 | * |
948 | 948 | * @return string GravityView_Template::template_id value. Empty string if not. |
949 | 949 | */ |
950 | - public static function get_meta_template_id( $view_id ) { |
|
951 | - return get_post_meta( $view_id, '_gravityview_directory_template', true ); |
|
950 | + public static function get_meta_template_id($view_id) { |
|
951 | + return get_post_meta($view_id, '_gravityview_directory_template', true); |
|
952 | 952 | } |
953 | 953 | |
954 | 954 | |
@@ -959,15 +959,15 @@ discard block |
||
959 | 959 | * @param int $post_id View ID |
960 | 960 | * @return array Associative array of settings with plugin defaults used if not set by the View |
961 | 961 | */ |
962 | - public static function get_template_settings( $post_id ) { |
|
962 | + public static function get_template_settings($post_id) { |
|
963 | 963 | |
964 | - $settings = get_post_meta( $post_id, '_gravityview_template_settings', true ); |
|
964 | + $settings = get_post_meta($post_id, '_gravityview_template_settings', true); |
|
965 | 965 | |
966 | - if ( class_exists( 'GravityView_View_Data' ) ) { |
|
966 | + if (class_exists('GravityView_View_Data')) { |
|
967 | 967 | |
968 | 968 | $defaults = GravityView_View_Data::get_default_args(); |
969 | 969 | |
970 | - return wp_parse_args( (array)$settings, $defaults ); |
|
970 | + return wp_parse_args((array)$settings, $defaults); |
|
971 | 971 | |
972 | 972 | } |
973 | 973 | |
@@ -984,12 +984,12 @@ discard block |
||
984 | 984 | * @param string $key Key for the setting |
985 | 985 | * @return mixed|null Setting value, or NULL if not set. |
986 | 986 | */ |
987 | - public static function get_template_setting( $post_id, $key ) { |
|
987 | + public static function get_template_setting($post_id, $key) { |
|
988 | 988 | |
989 | - $settings = self::get_template_settings( $post_id ); |
|
989 | + $settings = self::get_template_settings($post_id); |
|
990 | 990 | |
991 | - if ( isset( $settings[ $key ] ) ) { |
|
992 | - return $settings[ $key ]; |
|
991 | + if (isset($settings[$key])) { |
|
992 | + return $settings[$key]; |
|
993 | 993 | } |
994 | 994 | |
995 | 995 | return null; |
@@ -1025,8 +1025,8 @@ discard block |
||
1025 | 1025 | * @param int $post_id View ID |
1026 | 1026 | * @return array Multi-array of fields with first level being the field zones. See code comment. |
1027 | 1027 | */ |
1028 | - public static function get_directory_fields( $post_id ) { |
|
1029 | - return get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
|
1028 | + public static function get_directory_fields($post_id) { |
|
1029 | + return get_post_meta($post_id, '_gravityview_directory_fields', true); |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | |
@@ -1037,25 +1037,25 @@ discard block |
||
1037 | 1037 | * @param int $formid Form ID |
1038 | 1038 | * @return string html |
1039 | 1039 | */ |
1040 | - public static function get_sortable_fields( $formid, $current = '' ) { |
|
1041 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1040 | + public static function get_sortable_fields($formid, $current = '') { |
|
1041 | + $output = '<option value="" '.selected('', $current, false).'>'.esc_html__('Default', 'gravityview').'</option>'; |
|
1042 | 1042 | |
1043 | - if ( empty( $formid ) ) { |
|
1043 | + if (empty($formid)) { |
|
1044 | 1044 | return $output; |
1045 | 1045 | } |
1046 | 1046 | |
1047 | - $fields = self::get_sortable_fields_array( $formid ); |
|
1047 | + $fields = self::get_sortable_fields_array($formid); |
|
1048 | 1048 | |
1049 | - if ( ! empty( $fields ) ) { |
|
1049 | + if (!empty($fields)) { |
|
1050 | 1050 | |
1051 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
|
1051 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array('list', 'textarea'), null); |
|
1052 | 1052 | |
1053 | - foreach ( $fields as $id => $field ) { |
|
1054 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1053 | + foreach ($fields as $id => $field) { |
|
1054 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
1055 | 1055 | continue; |
1056 | 1056 | } |
1057 | 1057 | |
1058 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1058 | + $output .= '<option value="'.$id.'" '.selected($id, $current, false).'>'.esc_attr($field['label']).'</option>'; |
|
1059 | 1059 | } |
1060 | 1060 | } |
1061 | 1061 | |
@@ -1073,27 +1073,27 @@ discard block |
||
1073 | 1073 | * |
1074 | 1074 | * @return array |
1075 | 1075 | */ |
1076 | - public static function get_sortable_fields_array( $formid, $blacklist = array( 'list', 'textarea' ) ) { |
|
1076 | + public static function get_sortable_fields_array($formid, $blacklist = array('list', 'textarea')) { |
|
1077 | 1077 | |
1078 | 1078 | // Get fields with sub-inputs and no parent |
1079 | - $fields = self::get_form_fields( $formid, true, false ); |
|
1079 | + $fields = self::get_form_fields($formid, true, false); |
|
1080 | 1080 | |
1081 | 1081 | $date_created = array( |
1082 | 1082 | 'date_created' => array( |
1083 | 1083 | 'type' => 'date_created', |
1084 | - 'label' => __( 'Date Created', 'gravityview' ), |
|
1084 | + 'label' => __('Date Created', 'gravityview'), |
|
1085 | 1085 | ), |
1086 | 1086 | ); |
1087 | 1087 | |
1088 | 1088 | $fields = $date_created + $fields; |
1089 | 1089 | |
1090 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
|
1090 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', $blacklist, NULL); |
|
1091 | 1091 | |
1092 | 1092 | // TODO: Convert to using array_filter |
1093 | - foreach( $fields as $id => $field ) { |
|
1093 | + foreach ($fields as $id => $field) { |
|
1094 | 1094 | |
1095 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1096 | - unset( $fields[ $id ] ); |
|
1095 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
1096 | + unset($fields[$id]); |
|
1097 | 1097 | } |
1098 | 1098 | } |
1099 | 1099 | |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | * @param array $fields Sub-set of GF form fields that are sortable |
1104 | 1104 | * @param int $formid The Gravity Forms form ID that the fields are from |
1105 | 1105 | */ |
1106 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1106 | + $fields = apply_filters('gravityview/common/sortable_fields', $fields, $formid); |
|
1107 | 1107 | |
1108 | 1108 | return $fields; |
1109 | 1109 | } |
@@ -1114,15 +1114,15 @@ discard block |
||
1114 | 1114 | * @param mixed $field_id Field ID or Field array |
1115 | 1115 | * @return string field type |
1116 | 1116 | */ |
1117 | - public static function get_field_type( $form = null, $field_id = '' ) { |
|
1117 | + public static function get_field_type($form = null, $field_id = '') { |
|
1118 | 1118 | |
1119 | - if ( ! empty( $field_id ) && ! is_array( $field_id ) ) { |
|
1120 | - $field = self::get_field( $form, $field_id ); |
|
1119 | + if (!empty($field_id) && !is_array($field_id)) { |
|
1120 | + $field = self::get_field($form, $field_id); |
|
1121 | 1121 | } else { |
1122 | 1122 | $field = $field_id; |
1123 | 1123 | } |
1124 | 1124 | |
1125 | - return class_exists( 'RGFormsModel' ) ? RGFormsModel::get_input_type( $field ) : ''; |
|
1125 | + return class_exists('RGFormsModel') ? RGFormsModel::get_input_type($field) : ''; |
|
1126 | 1126 | |
1127 | 1127 | } |
1128 | 1128 | |
@@ -1133,22 +1133,22 @@ discard block |
||
1133 | 1133 | * @param int|array $field field key or field array |
1134 | 1134 | * @return boolean |
1135 | 1135 | */ |
1136 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1136 | + public static function is_field_numeric($form = null, $field = '') { |
|
1137 | 1137 | |
1138 | 1138 | /** |
1139 | 1139 | * @filter `gravityview/common/numeric_types` What types of fields are numeric? |
1140 | 1140 | * @since 1.5.2 |
1141 | 1141 | * @param array $numeric_types Fields that are numeric. Default: `[ number, time ]` |
1142 | 1142 | */ |
1143 | - $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
|
1143 | + $numeric_types = apply_filters('gravityview/common/numeric_types', array('number', 'time')); |
|
1144 | 1144 | |
1145 | - if ( ! is_array( $form ) && ! is_array( $field ) ) { |
|
1146 | - $form = self::get_form( $form ); |
|
1145 | + if (!is_array($form) && !is_array($field)) { |
|
1146 | + $form = self::get_form($form); |
|
1147 | 1147 | } |
1148 | 1148 | |
1149 | - $type = self::get_field_type( $form, $field ); |
|
1149 | + $type = self::get_field_type($form, $field); |
|
1150 | 1150 | |
1151 | - return in_array( $type, $numeric_types ); |
|
1151 | + return in_array($type, $numeric_types); |
|
1152 | 1152 | |
1153 | 1153 | } |
1154 | 1154 | |
@@ -1166,19 +1166,19 @@ discard block |
||
1166 | 1166 | * |
1167 | 1167 | * @return string Content, encrypted |
1168 | 1168 | */ |
1169 | - public static function js_encrypt( $content, $message = '' ) { |
|
1169 | + public static function js_encrypt($content, $message = '') { |
|
1170 | 1170 | |
1171 | 1171 | $output = $content; |
1172 | 1172 | |
1173 | - if ( ! class_exists( 'StandalonePHPEnkoder' ) ) { |
|
1174 | - include_once( GRAVITYVIEW_DIR . 'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php' ); |
|
1173 | + if (!class_exists('StandalonePHPEnkoder')) { |
|
1174 | + include_once(GRAVITYVIEW_DIR.'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php'); |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | - if ( class_exists( 'StandalonePHPEnkoder' ) ) { |
|
1177 | + if (class_exists('StandalonePHPEnkoder')) { |
|
1178 | 1178 | |
1179 | 1179 | $enkoder = new StandalonePHPEnkoder; |
1180 | 1180 | |
1181 | - $message = empty( $message ) ? __( 'Email hidden; Javascript is required.', 'gravityview' ) : $message; |
|
1181 | + $message = empty($message) ? __('Email hidden; Javascript is required.', 'gravityview') : $message; |
|
1182 | 1182 | |
1183 | 1183 | /** |
1184 | 1184 | * @filter `gravityview/phpenkoder/msg` Modify the message shown when Javascript is disabled and an encrypted email field is displayed |
@@ -1186,9 +1186,9 @@ discard block |
||
1186 | 1186 | * @param string $message Existing message |
1187 | 1187 | * @param string $content Content to encrypt |
1188 | 1188 | */ |
1189 | - $enkoder->enkode_msg = apply_filters( 'gravityview/phpenkoder/msg', $message, $content ); |
|
1189 | + $enkoder->enkode_msg = apply_filters('gravityview/phpenkoder/msg', $message, $content); |
|
1190 | 1190 | |
1191 | - $output = $enkoder->enkode( $content ); |
|
1191 | + $output = $enkoder->enkode($content); |
|
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | return $output; |
@@ -1205,25 +1205,25 @@ discard block |
||
1205 | 1205 | * |
1206 | 1206 | * @author rubo77 at https://gist.github.com/rubo77/6821632 |
1207 | 1207 | **/ |
1208 | - public static function gv_parse_str( $string, &$result ) { |
|
1209 | - if ( empty( $string ) ) { |
|
1208 | + public static function gv_parse_str($string, &$result) { |
|
1209 | + if (empty($string)) { |
|
1210 | 1210 | return false; |
1211 | 1211 | } |
1212 | 1212 | |
1213 | 1213 | $result = array(); |
1214 | 1214 | |
1215 | 1215 | // find the pairs "name=value" |
1216 | - $pairs = explode( '&', $string ); |
|
1216 | + $pairs = explode('&', $string); |
|
1217 | 1217 | |
1218 | - foreach ( $pairs as $pair ) { |
|
1218 | + foreach ($pairs as $pair) { |
|
1219 | 1219 | // use the original parse_str() on each element |
1220 | - parse_str( $pair, $params ); |
|
1220 | + parse_str($pair, $params); |
|
1221 | 1221 | |
1222 | - $k = key( $params ); |
|
1223 | - if ( ! isset( $result[ $k ] ) ) { |
|
1222 | + $k = key($params); |
|
1223 | + if (!isset($result[$k])) { |
|
1224 | 1224 | $result += $params; |
1225 | - } elseif ( array_key_exists( $k, $params ) && is_array( $params[ $k ] ) ) { |
|
1226 | - $result[ $k ] = self::array_merge_recursive_distinct( $result[ $k ], $params[ $k ] ); |
|
1225 | + } elseif (array_key_exists($k, $params) && is_array($params[$k])) { |
|
1226 | + $result[$k] = self::array_merge_recursive_distinct($result[$k], $params[$k]); |
|
1227 | 1227 | } |
1228 | 1228 | } |
1229 | 1229 | return true; |
@@ -1245,7 +1245,7 @@ discard block |
||
1245 | 1245 | * |
1246 | 1246 | * @return string HTML output of anchor link. If empty $href, returns NULL |
1247 | 1247 | */ |
1248 | - public static function get_link_html( $href = '', $anchor_text = '', $atts = array() ) { |
|
1248 | + public static function get_link_html($href = '', $anchor_text = '', $atts = array()) { |
|
1249 | 1249 | |
1250 | 1250 | // Supported attributes for anchor tags. HREF left out intentionally. |
1251 | 1251 | $allowed_atts = array( |
@@ -1281,31 +1281,31 @@ discard block |
||
1281 | 1281 | * @filter `gravityview/get_link/allowed_atts` Modify the attributes that are allowed to be used in generating links |
1282 | 1282 | * @param array $allowed_atts Array of attributes allowed |
1283 | 1283 | */ |
1284 | - $allowed_atts = apply_filters( 'gravityview/get_link/allowed_atts', $allowed_atts ); |
|
1284 | + $allowed_atts = apply_filters('gravityview/get_link/allowed_atts', $allowed_atts); |
|
1285 | 1285 | |
1286 | 1286 | // Make sure the attributes are formatted as array |
1287 | - $passed_atts = wp_parse_args( $atts ); |
|
1287 | + $passed_atts = wp_parse_args($atts); |
|
1288 | 1288 | |
1289 | 1289 | // Make sure the allowed attributes are only the ones in the $allowed_atts list |
1290 | - $final_atts = shortcode_atts( $allowed_atts, $passed_atts ); |
|
1290 | + $final_atts = shortcode_atts($allowed_atts, $passed_atts); |
|
1291 | 1291 | |
1292 | 1292 | // Remove attributes with empty values |
1293 | - $final_atts = array_filter( $final_atts ); |
|
1293 | + $final_atts = array_filter($final_atts); |
|
1294 | 1294 | |
1295 | 1295 | // If the href wasn't passed as an attribute, use the value passed to the function |
1296 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1296 | + if (empty($final_atts['href']) && !empty($href)) { |
|
1297 | 1297 | $final_atts['href'] = $href; |
1298 | 1298 | } |
1299 | 1299 | |
1300 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1300 | + $final_atts['href'] = esc_url_raw($href); |
|
1301 | 1301 | |
1302 | 1302 | // For each attribute, generate the code |
1303 | 1303 | $output = ''; |
1304 | - foreach ( $final_atts as $attr => $value ) { |
|
1305 | - $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
|
1304 | + foreach ($final_atts as $attr => $value) { |
|
1305 | + $output .= sprintf(' %s="%s"', $attr, esc_attr($value)); |
|
1306 | 1306 | } |
1307 | 1307 | |
1308 | - $output = '<a'. $output .'>'. $anchor_text .'</a>'; |
|
1308 | + $output = '<a'.$output.'>'.$anchor_text.'</a>'; |
|
1309 | 1309 | |
1310 | 1310 | return $output; |
1311 | 1311 | } |
@@ -1324,14 +1324,14 @@ discard block |
||
1324 | 1324 | * @author Daniel <daniel (at) danielsmedegaardbuus (dot) dk> |
1325 | 1325 | * @author Gabriel Sobrinho <gabriel (dot) sobrinho (at) gmail (dot) com> |
1326 | 1326 | */ |
1327 | - public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) { |
|
1327 | + public static function array_merge_recursive_distinct(array &$array1, array &$array2) { |
|
1328 | 1328 | $merged = $array1; |
1329 | 1329 | |
1330 | - foreach ( $array2 as $key => &$value ) { |
|
1331 | - if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
|
1332 | - $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
|
1330 | + foreach ($array2 as $key => &$value) { |
|
1331 | + if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) { |
|
1332 | + $merged[$key] = self::array_merge_recursive_distinct($merged[$key], $value); |
|
1333 | 1333 | } else { |
1334 | - $merged[ $key ] = $value; |
|
1334 | + $merged[$key] = $value; |
|
1335 | 1335 | } |
1336 | 1336 | } |
1337 | 1337 | |
@@ -1345,26 +1345,26 @@ discard block |
||
1345 | 1345 | * @param array $args Arguments to modify the user query. See get_users() {@since 1.14} |
1346 | 1346 | * @return array Array of WP_User objects. |
1347 | 1347 | */ |
1348 | - public static function get_users( $context = 'change_entry_creator', $args = array() ) { |
|
1348 | + public static function get_users($context = 'change_entry_creator', $args = array()) { |
|
1349 | 1349 | |
1350 | 1350 | $default_args = array( |
1351 | 1351 | 'number' => 2000, |
1352 | 1352 | 'orderby' => 'display_name', |
1353 | 1353 | 'order' => 'ASC', |
1354 | - 'fields' => array( 'ID', 'display_name', 'user_login', 'user_nicename' ) |
|
1354 | + 'fields' => array('ID', 'display_name', 'user_login', 'user_nicename') |
|
1355 | 1355 | ); |
1356 | 1356 | |
1357 | 1357 | // Merge in the passed arg |
1358 | - $get_users_settings = wp_parse_args( $args, $default_args ); |
|
1358 | + $get_users_settings = wp_parse_args($args, $default_args); |
|
1359 | 1359 | |
1360 | 1360 | /** |
1361 | 1361 | * @filter `gravityview/get_users/{$context}` There are issues with too many users using [get_users()](http://codex.wordpress.org/Function_Reference/get_users) where it breaks the select. We try to keep it at a reasonable number. \n |
1362 | 1362 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1363 | 1363 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1364 | 1364 | */ |
1365 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1365 | + $get_users_settings = apply_filters('gravityview/get_users/'.$context, apply_filters('gravityview_change_entry_creator_user_parameters', $get_users_settings)); |
|
1366 | 1366 | |
1367 | - return get_users( $get_users_settings ); |
|
1367 | + return get_users($get_users_settings); |
|
1368 | 1368 | } |
1369 | 1369 | |
1370 | 1370 | |
@@ -1376,8 +1376,8 @@ discard block |
||
1376 | 1376 | * |
1377 | 1377 | * @return string |
1378 | 1378 | */ |
1379 | - public static function generate_notice( $notice, $class = '' ) { |
|
1380 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1379 | + public static function generate_notice($notice, $class = '') { |
|
1380 | + return '<div class="gv-notice '.gravityview_sanitize_html_class($class).'">'.$notice.'</div>'; |
|
1381 | 1381 | } |
1382 | 1382 | |
1383 | 1383 | |
@@ -1399,6 +1399,6 @@ discard block |
||
1399 | 1399 | * |
1400 | 1400 | * @return string HTML output of anchor link. If empty $href, returns NULL |
1401 | 1401 | */ |
1402 | -function gravityview_get_link( $href = '', $anchor_text = '', $atts = array() ) { |
|
1403 | - return GVCommon::get_link_html( $href, $anchor_text, $atts ); |
|
1402 | +function gravityview_get_link($href = '', $anchor_text = '', $atts = array()) { |
|
1403 | + return GVCommon::get_link_html($href, $anchor_text, $atts); |
|
1404 | 1404 | } |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @param string $prevent_multiple_instances |
71 | 71 | */ |
72 | - public function __construct( $prevent_multiple_instances = '' ) { |
|
72 | + public function __construct($prevent_multiple_instances = '') { |
|
73 | 73 | |
74 | - if( $prevent_multiple_instances === 'get_instance' ) { |
|
74 | + if ($prevent_multiple_instances === 'get_instance') { |
|
75 | 75 | return parent::__construct(); |
76 | 76 | } |
77 | 77 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public static function get_instance() { |
85 | 85 | |
86 | - if( empty( self::$instance ) ) { |
|
87 | - self::$instance = new self( 'get_instance' ); |
|
86 | + if (empty(self::$instance)) { |
|
87 | + self::$instance = new self('get_instance'); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | return self::$instance; |
@@ -100,21 +100,21 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return bool |
102 | 102 | */ |
103 | - public function current_user_can_any( $caps ) { |
|
103 | + public function current_user_can_any($caps) { |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * Prevent Gravity Forms from showing the uninstall tab on the settings page |
107 | 107 | * @hack |
108 | 108 | */ |
109 | - if( $caps === $this->_capabilities_uninstall ) { |
|
109 | + if ($caps === $this->_capabilities_uninstall) { |
|
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - if( empty( $caps ) ) { |
|
114 | - $caps = array( 'gravityview_full_access' ); |
|
113 | + if (empty($caps)) { |
|
114 | + $caps = array('gravityview_full_access'); |
|
115 | 115 | } |
116 | 116 | |
117 | - return GVCommon::has_cap( $caps ); |
|
117 | + return GVCommon::has_cap($caps); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | |
131 | 131 | $this->license_key_notice(); |
132 | 132 | |
133 | - add_filter( 'gform_addon_app_settings_menu_gravityview', array( $this, 'modify_app_settings_menu_title' ) ); |
|
133 | + add_filter('gform_addon_app_settings_menu_gravityview', array($this, 'modify_app_settings_menu_title')); |
|
134 | 134 | |
135 | 135 | /** @since 1.7.6 */ |
136 | - add_action('network_admin_menu', array( $this, 'add_network_menu' ) ); |
|
136 | + add_action('network_admin_menu', array($this, 'add_network_menu')); |
|
137 | 137 | |
138 | 138 | parent::init_admin(); |
139 | 139 | } |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @return array |
147 | 147 | */ |
148 | - public function modify_app_settings_menu_title( $setting_tabs ) { |
|
148 | + public function modify_app_settings_menu_title($setting_tabs) { |
|
149 | 149 | |
150 | - $setting_tabs[0]['label'] = __( 'GravityView Settings', 'gravityview'); |
|
150 | + $setting_tabs[0]['label'] = __('GravityView Settings', 'gravityview'); |
|
151 | 151 | |
152 | 152 | return $setting_tabs; |
153 | 153 | } |
@@ -164,13 +164,13 @@ discard block |
||
164 | 164 | */ |
165 | 165 | private function _load_license_handler() { |
166 | 166 | |
167 | - if( !empty( $this->License_Handler ) ) { |
|
167 | + if (!empty($this->License_Handler)) { |
|
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
171 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gv-license-handler.php'); |
|
171 | + require_once(GRAVITYVIEW_DIR.'includes/class-gv-license-handler.php'); |
|
172 | 172 | |
173 | - $this->License_Handler = GV_License_Handler::get_instance( $this ); |
|
173 | + $this->License_Handler = GV_License_Handler::get_instance($this); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | function license_key_notice() { |
181 | 181 | |
182 | 182 | // Only show on GravityView pages |
183 | - if( ! gravityview_is_admin_page() ) { |
|
183 | + if (!gravityview_is_admin_page()) { |
|
184 | 184 | return; |
185 | 185 | } |
186 | 186 | |
187 | 187 | $license_status = self::getSetting('license_key_status'); |
188 | 188 | $license_id = self::getSetting('license_key'); |
189 | - $license_id = empty( $license_id ) ? 'license' : $license_id; |
|
189 | + $license_id = empty($license_id) ? 'license' : $license_id; |
|
190 | 190 | |
191 | 191 | $message = esc_html__('Your GravityView license %s. This means you’re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview'); |
192 | 192 | |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | * I wanted to remove the period from after the buttons in the string, |
195 | 195 | * but didn't want to mess up the translation strings for the translators. |
196 | 196 | */ |
197 | - $message = mb_substr( $message, 0, mb_strlen( $message ) - 1 ); |
|
197 | + $message = mb_substr($message, 0, mb_strlen($message) - 1); |
|
198 | 198 | $title = __('Inactive License', 'gravityview'); |
199 | 199 | $status = ''; |
200 | 200 | $update_below = false; |
201 | - $primary_button_link = admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ); |
|
202 | - switch ( $license_status ) { |
|
201 | + $primary_button_link = admin_url('edit.php?post_type=gravityview&page=gravityview_settings'); |
|
202 | + switch ($license_status) { |
|
203 | 203 | case 'invalid': |
204 | 204 | $title = __('Invalid License', 'gravityview'); |
205 | 205 | $status = __('is invalid', 'gravityview'); |
@@ -220,19 +220,19 @@ discard block |
||
220 | 220 | $url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice'; |
221 | 221 | |
222 | 222 | // Show a different notice on settings page for inactive licenses (hide the buttons) |
223 | - if( $update_below && gravityview_is_admin_page( '', 'settings' ) ) { |
|
224 | - $message = sprintf( $message, $status, '<div class="hidden">', '', '', '</div><a href="#" onclick="jQuery(\'#license_key\').focus(); return false;">' . $update_below . '</a>' ); |
|
223 | + if ($update_below && gravityview_is_admin_page('', 'settings')) { |
|
224 | + $message = sprintf($message, $status, '<div class="hidden">', '', '', '</div><a href="#" onclick="jQuery(\'#license_key\').focus(); return false;">'.$update_below.'</a>'); |
|
225 | 225 | } else { |
226 | - $message = sprintf( $message, $status, "\n\n" . '<a href="' . $primary_button_link . '" class="button button-primary">', '</a>', '<a href="' . esc_url( $url ) . '" class="button button-secondary">', '</a>' ); |
|
226 | + $message = sprintf($message, $status, "\n\n".'<a href="'.$primary_button_link.'" class="button button-primary">', '</a>', '<a href="'.esc_url($url).'" class="button button-secondary">', '</a>'); |
|
227 | 227 | } |
228 | 228 | |
229 | - if( !empty( $status ) ) { |
|
230 | - GravityView_Admin_Notices::add_notice( array( |
|
229 | + if (!empty($status)) { |
|
230 | + GravityView_Admin_Notices::add_notice(array( |
|
231 | 231 | 'message' => $message, |
232 | 232 | 'class' => 'updated', |
233 | 233 | 'title' => $title, |
234 | 234 | 'cap' => 'gravityview_edit_settings', |
235 | - 'dismiss' => sha1( $license_status.'_'.$license_id ), |
|
235 | + 'dismiss' => sha1($license_status.'_'.$license_id), |
|
236 | 236 | )); |
237 | 237 | } |
238 | 238 | } |
@@ -247,15 +247,15 @@ discard block |
||
247 | 247 | |
248 | 248 | $styles[] = array( |
249 | 249 | 'handle' => 'gravityview_settings', |
250 | - 'src' => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ), |
|
250 | + 'src' => plugins_url('assets/css/admin-settings.css', GRAVITYVIEW_FILE), |
|
251 | 251 | 'version' => GravityView_Plugin::version, |
252 | 252 | "deps" => array( |
253 | 253 | 'gaddon_form_settings_css' |
254 | 254 | ), |
255 | 255 | 'enqueue' => array( |
256 | - array( 'admin_page' => array( |
|
256 | + array('admin_page' => array( |
|
257 | 257 | 'app_settings' |
258 | - ) ), |
|
258 | + )), |
|
259 | 259 | ) |
260 | 260 | ); |
261 | 261 | |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | * @return void |
269 | 269 | */ |
270 | 270 | public function add_network_menu() { |
271 | - if( GravityView_Plugin::is_network_activated() ) { |
|
272 | - add_menu_page( __( 'Settings', 'gravityview' ), __( 'GravityView', 'gravityview' ), $this->_capabilities_app_settings, "{$this->_slug}_settings", array( $this, 'app_tab_page' ), 'none' ); |
|
271 | + if (GravityView_Plugin::is_network_activated()) { |
|
272 | + add_menu_page(__('Settings', 'gravityview'), __('GravityView', 'gravityview'), $this->_capabilities_app_settings, "{$this->_slug}_settings", array($this, 'app_tab_page'), 'none'); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
@@ -285,17 +285,17 @@ discard block |
||
285 | 285 | * If multisite and not network admin, we don't want the settings to show. |
286 | 286 | * @since 1.7.6 |
287 | 287 | */ |
288 | - $show_submenu = !is_multisite() || is_main_site() || !GravityView_Plugin::is_network_activated() || ( is_network_admin() && GravityView_Plugin::is_network_activated() ); |
|
288 | + $show_submenu = !is_multisite() || is_main_site() || !GravityView_Plugin::is_network_activated() || (is_network_admin() && GravityView_Plugin::is_network_activated()); |
|
289 | 289 | |
290 | 290 | /** |
291 | 291 | * Override whether to show the Settings menu on a per-blog basis. |
292 | 292 | * @since 1.7.6 |
293 | 293 | * @param bool $hide_if_network_activated Default: true |
294 | 294 | */ |
295 | - $show_submenu = apply_filters( 'gravityview/show-settings-menu', $show_submenu ); |
|
295 | + $show_submenu = apply_filters('gravityview/show-settings-menu', $show_submenu); |
|
296 | 296 | |
297 | - if( $show_submenu ) { |
|
298 | - add_submenu_page( 'edit.php?post_type=gravityview', __( 'Settings', 'gravityview' ), __( 'Settings', 'gravityview' ), $this->_capabilities_app_settings, $this->_slug . '_settings', array( $this, 'app_tab_page' ) ); |
|
297 | + if ($show_submenu) { |
|
298 | + add_submenu_page('edit.php?post_type=gravityview', __('Settings', 'gravityview'), __('Settings', 'gravityview'), $this->_capabilities_app_settings, $this->_slug.'_settings', array($this, 'app_tab_page')); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | * @inheritDoc |
321 | 321 | * @access public |
322 | 322 | */ |
323 | - public function get_app_setting( $setting_name ) { |
|
323 | + public function get_app_setting($setting_name) { |
|
324 | 324 | |
325 | 325 | /** |
326 | 326 | * Backward compatibility with Redux |
327 | 327 | */ |
328 | - if( $setting_name === 'license' ) { |
|
328 | + if ($setting_name === 'license') { |
|
329 | 329 | return array( |
330 | - 'license' => parent::get_app_setting( 'license_key' ), |
|
331 | - 'status' => parent::get_app_setting( 'license_key_status' ), |
|
332 | - 'response' => parent::get_app_setting( 'license_key_response' ), |
|
330 | + 'license' => parent::get_app_setting('license_key'), |
|
331 | + 'status' => parent::get_app_setting('license_key_status'), |
|
332 | + 'response' => parent::get_app_setting('license_key_response'), |
|
333 | 333 | ); |
334 | 334 | } |
335 | 335 | |
336 | - return parent::get_app_setting( $setting_name ); |
|
336 | + return parent::get_app_setting($setting_name); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @return array |
349 | 349 | */ |
350 | 350 | public function get_app_settings() { |
351 | - return get_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', $this->get_default_settings() ); |
|
351 | + return get_option('gravityformsaddon_'.$this->_slug.'_app_settings', $this->get_default_settings()); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | |
@@ -361,8 +361,8 @@ discard block |
||
361 | 361 | * |
362 | 362 | * @return boolean False if value was not updated and true if value was updated. |
363 | 363 | */ |
364 | - public function update_app_settings( $settings ) { |
|
365 | - return update_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', $settings ); |
|
364 | + public function update_app_settings($settings) { |
|
365 | + return update_option('gravityformsaddon_'.$this->_slug.'_app_settings', $settings); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | * @inheritDoc |
371 | 371 | * @access public |
372 | 372 | */ |
373 | - public function set_field_error( $field, $error_message = '' ) { |
|
374 | - parent::set_field_error( $field, $error_message ); |
|
373 | + public function set_field_error($field, $error_message = '') { |
|
374 | + parent::set_field_error($field, $error_message); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | /** |
@@ -381,15 +381,15 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @return string |
383 | 383 | */ |
384 | - protected function settings_edd_license( $field, $echo = true ) { |
|
384 | + protected function settings_edd_license($field, $echo = true) { |
|
385 | 385 | |
386 | - $text = self::settings_text( $field, false ); |
|
386 | + $text = self::settings_text($field, false); |
|
387 | 387 | |
388 | - $activation = $this->License_Handler->settings_edd_license_activation( $field, false ); |
|
388 | + $activation = $this->License_Handler->settings_edd_license_activation($field, false); |
|
389 | 389 | |
390 | - $return = $text . $activation; |
|
390 | + $return = $text.$activation; |
|
391 | 391 | |
392 | - if( $echo ) { |
|
392 | + if ($echo) { |
|
393 | 393 | echo $return; |
394 | 394 | } |
395 | 395 | |
@@ -414,32 +414,32 @@ discard block |
||
414 | 414 | * |
415 | 415 | * @return string The HTML |
416 | 416 | */ |
417 | - public function settings_submit( $field, $echo = true ) { |
|
417 | + public function settings_submit($field, $echo = true) { |
|
418 | 418 | |
419 | - $field['type'] = ( isset($field['type']) && in_array( $field['type'], array('submit','reset','button') ) ) ? $field['type'] : 'submit'; |
|
419 | + $field['type'] = (isset($field['type']) && in_array($field['type'], array('submit', 'reset', 'button'))) ? $field['type'] : 'submit'; |
|
420 | 420 | |
421 | - $attributes = $this->get_field_attributes( $field ); |
|
422 | - $default_value = rgar( $field, 'value' ) ? rgar( $field, 'value' ) : rgar( $field, 'default_value' ); |
|
423 | - $value = $this->get_setting( $field['name'], $default_value ); |
|
421 | + $attributes = $this->get_field_attributes($field); |
|
422 | + $default_value = rgar($field, 'value') ? rgar($field, 'value') : rgar($field, 'default_value'); |
|
423 | + $value = $this->get_setting($field['name'], $default_value); |
|
424 | 424 | |
425 | 425 | |
426 | - $attributes['class'] = isset( $attributes['class'] ) ? esc_attr( $attributes['class'] ) : 'button-primary gfbutton'; |
|
427 | - $name = ( $field['name'] === 'gform-settings-save' ) ? $field['name'] : '_gaddon_setting_'.$field['name']; |
|
426 | + $attributes['class'] = isset($attributes['class']) ? esc_attr($attributes['class']) : 'button-primary gfbutton'; |
|
427 | + $name = ($field['name'] === 'gform-settings-save') ? $field['name'] : '_gaddon_setting_'.$field['name']; |
|
428 | 428 | |
429 | - if ( empty( $value ) ) { |
|
430 | - $value = __( 'Update Settings', 'gravityview' ); |
|
429 | + if (empty($value)) { |
|
430 | + $value = __('Update Settings', 'gravityview'); |
|
431 | 431 | } |
432 | 432 | |
433 | - $attributes = $this->get_field_attributes( $field ); |
|
433 | + $attributes = $this->get_field_attributes($field); |
|
434 | 434 | |
435 | 435 | $html = '<input |
436 | - type="' . $field['type'] . '" |
|
437 | - name="' . esc_attr( $name ) . '" |
|
438 | - value="' . $value . '" ' . |
|
439 | - implode( ' ', $attributes ) . |
|
436 | + type="' . $field['type'].'" |
|
437 | + name="' . esc_attr($name).'" |
|
438 | + value="' . $value.'" '. |
|
439 | + implode(' ', $attributes). |
|
440 | 440 | ' />'; |
441 | 441 | |
442 | - if ( $echo ) { |
|
442 | + if ($echo) { |
|
443 | 443 | echo $html; |
444 | 444 | } |
445 | 445 | |
@@ -454,17 +454,17 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @return string |
456 | 456 | */ |
457 | - public function settings_save( $field, $echo = true ) { |
|
457 | + public function settings_save($field, $echo = true) { |
|
458 | 458 | $field['type'] = 'submit'; |
459 | 459 | $field['name'] = 'gform-settings-save'; |
460 | - $field['class'] = isset( $field['class'] ) ? $field['class'] : 'button-primary gfbutton'; |
|
460 | + $field['class'] = isset($field['class']) ? $field['class'] : 'button-primary gfbutton'; |
|
461 | 461 | |
462 | - if ( ! rgar( $field, 'value' ) ) |
|
463 | - $field['value'] = __( 'Update Settings', 'gravityview' ); |
|
462 | + if (!rgar($field, 'value')) |
|
463 | + $field['value'] = __('Update Settings', 'gravityview'); |
|
464 | 464 | |
465 | - $output = $this->settings_submit( $field, false ); |
|
465 | + $output = $this->settings_submit($field, false); |
|
466 | 466 | |
467 | - if( $echo ) { |
|
467 | + if ($echo) { |
|
468 | 468 | echo $output; |
469 | 469 | } |
470 | 470 | |
@@ -476,22 +476,22 @@ discard block |
||
476 | 476 | * @inheritDoc |
477 | 477 | * @param $field array |
478 | 478 | */ |
479 | - public function single_setting_label( $field ) { |
|
479 | + public function single_setting_label($field) { |
|
480 | 480 | |
481 | 481 | echo $field['label']; |
482 | 482 | |
483 | 483 | |
484 | - if ( isset( $field['tooltip'] ) ) { |
|
485 | - echo ' ' . gform_tooltip( $field['tooltip'], rgar( $field, 'tooltip_class' ), true ); |
|
484 | + if (isset($field['tooltip'])) { |
|
485 | + echo ' '.gform_tooltip($field['tooltip'], rgar($field, 'tooltip_class'), true); |
|
486 | 486 | } |
487 | 487 | |
488 | - if ( rgar( $field, 'required' ) ) { |
|
489 | - echo ' ' . $this->get_required_indicator( $field ); |
|
488 | + if (rgar($field, 'required')) { |
|
489 | + echo ' '.$this->get_required_indicator($field); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | // Added by GravityView |
493 | - if ( isset( $field['description'] ) ) { |
|
494 | - echo '<span class="description">'. $field['description'] .'</span>'; |
|
493 | + if (isset($field['description'])) { |
|
494 | + echo '<span class="description">'.$field['description'].'</span>'; |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | } |
@@ -507,10 +507,10 @@ discard block |
||
507 | 507 | |
508 | 508 | $defaults = array( |
509 | 509 | // Set the default license in wp-config.php |
510 | - 'license_key' => defined( 'GRAVITYVIEW_LICENSE_KEY' ) ? GRAVITYVIEW_LICENSE_KEY : '', |
|
510 | + 'license_key' => defined('GRAVITYVIEW_LICENSE_KEY') ? GRAVITYVIEW_LICENSE_KEY : '', |
|
511 | 511 | 'license_key_response' => '', |
512 | 512 | 'license_key_status' => '', |
513 | - 'support-email' => get_bloginfo( 'admin_email' ), |
|
513 | + 'support-email' => get_bloginfo('admin_email'), |
|
514 | 514 | 'no-conflict-mode' => '0', |
515 | 515 | 'support_port' => '1', |
516 | 516 | 'delete-on-uninstall' => '0', |
@@ -528,10 +528,10 @@ discard block |
||
528 | 528 | */ |
529 | 529 | public function maybe_save_app_settings() { |
530 | 530 | |
531 | - if ( $this->is_save_postback() ) { |
|
532 | - if ( ! GVCommon::has_cap( 'gravityview_edit_settings' ) ) { |
|
531 | + if ($this->is_save_postback()) { |
|
532 | + if (!GVCommon::has_cap('gravityview_edit_settings')) { |
|
533 | 533 | $_POST = array(); // If you don't reset the $_POST array, it *looks* like the settings were changed, but they weren't |
534 | - GFCommon::add_error_message( __( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ) ); |
|
534 | + GFCommon::add_error_message(__('You don\'t have the ability to edit plugin settings.', 'gravityview')); |
|
535 | 535 | return; |
536 | 536 | } |
537 | 537 | } |
@@ -548,16 +548,16 @@ discard block |
||
548 | 548 | |
549 | 549 | $posted_settings = parent::get_posted_settings(); |
550 | 550 | |
551 | - $local_key = rgar( $posted_settings, 'license_key' ); |
|
552 | - $response_key = rgars( $posted_settings, 'license_key_response/license_key' ); |
|
551 | + $local_key = rgar($posted_settings, 'license_key'); |
|
552 | + $response_key = rgars($posted_settings, 'license_key_response/license_key'); |
|
553 | 553 | |
554 | 554 | // If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response), |
555 | 555 | // then we assume it's changed. If it's changed, unset the status and the previous response. |
556 | - if( $local_key !== $response_key ) { |
|
556 | + if ($local_key !== $response_key) { |
|
557 | 557 | |
558 | - unset( $posted_settings['license_key_response'] ); |
|
559 | - unset( $posted_settings['license_key_status'] ); |
|
560 | - GFCommon::add_error_message( __('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) ); |
|
558 | + unset($posted_settings['license_key_response']); |
|
559 | + unset($posted_settings['license_key_status']); |
|
560 | + GFCommon::add_error_message(__('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview')); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | return $posted_settings; |
@@ -571,8 +571,8 @@ discard block |
||
571 | 571 | * |
572 | 572 | * @return string - Returns markup of the required indicator symbol |
573 | 573 | */ |
574 | - public function get_required_indicator( $field ) { |
|
575 | - return '<span class="required" title="' . esc_attr__( 'Required', 'gravityview' ) . '">*</span>'; |
|
574 | + public function get_required_indicator($field) { |
|
575 | + return '<span class="required" title="'.esc_attr__('Required', 'gravityview').'">*</span>'; |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -583,18 +583,18 @@ discard block |
||
583 | 583 | |
584 | 584 | $default_settings = $this->get_default_settings(); |
585 | 585 | |
586 | - $disabled_attribute = GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled'; |
|
586 | + $disabled_attribute = GVCommon::has_cap('gravityview_edit_settings') ? false : 'disabled'; |
|
587 | 587 | |
588 | - $fields = apply_filters( 'gravityview_settings_fields', array( |
|
588 | + $fields = apply_filters('gravityview_settings_fields', array( |
|
589 | 589 | array( |
590 | 590 | 'name' => 'license_key', |
591 | 591 | 'required' => true, |
592 | - 'label' => __( 'License Key', 'gravityview' ), |
|
593 | - 'description' => __( 'Enter the license key that was sent to you on purchase. This enables plugin updates & support.', 'gravityview' ), |
|
592 | + 'label' => __('License Key', 'gravityview'), |
|
593 | + 'description' => __('Enter the license key that was sent to you on purchase. This enables plugin updates & support.', 'gravityview'), |
|
594 | 594 | 'type' => 'edd_license', |
595 | 595 | 'data-pending-text' => __('Verifying license…', 'gravityview'), |
596 | 596 | 'default_value' => $default_settings['license_key'], |
597 | - 'class' => ( '' == $this->get_app_setting( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key', |
|
597 | + 'class' => ('' == $this->get_app_setting('license_key')) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key', |
|
598 | 598 | ), |
599 | 599 | array( |
600 | 600 | 'name' => 'license_key_response', |
@@ -611,8 +611,8 @@ discard block |
||
611 | 611 | 'type' => 'text', |
612 | 612 | 'validate' => 'email', |
613 | 613 | 'default_value' => $default_settings['support-email'], |
614 | - 'label' => __( 'Support Email', 'gravityview' ), |
|
615 | - 'description' => __( 'In order to provide responses to your support requests, please provide your email address.', 'gravityview' ), |
|
614 | + 'label' => __('Support Email', 'gravityview'), |
|
615 | + 'description' => __('In order to provide responses to your support requests, please provide your email address.', 'gravityview'), |
|
616 | 616 | 'class' => 'code regular-text', |
617 | 617 | ), |
618 | 618 | /** |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | array( |
622 | 622 | 'name' => 'support_port', |
623 | 623 | 'type' => 'radio', |
624 | - 'label' => __( 'Show Support Port?', 'gravityview' ), |
|
624 | + 'label' => __('Show Support Port?', 'gravityview'), |
|
625 | 625 | 'default_value' => $default_settings['support_port'], |
626 | 626 | 'horizontal' => 1, |
627 | 627 | 'choices' => array( |
@@ -634,13 +634,13 @@ discard block |
||
634 | 634 | 'value' => '0', |
635 | 635 | ), |
636 | 636 | ), |
637 | - 'tooltip' => '<p><img src="' . esc_url_raw( plugins_url('assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE ) ) . '" alt="' . esc_attr__( 'The Support Port looks like this.', 'gravityview' ) . '" class="alignright" style="max-width:40px; margin:.5em;" />' . esc_html__('The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview') . '</p>', |
|
638 | - 'description' => __( 'Show the Support Port on GravityView pages?', 'gravityview' ), |
|
637 | + 'tooltip' => '<p><img src="'.esc_url_raw(plugins_url('assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE)).'" alt="'.esc_attr__('The Support Port looks like this.', 'gravityview').'" class="alignright" style="max-width:40px; margin:.5em;" />'.esc_html__('The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview').'</p>', |
|
638 | + 'description' => __('Show the Support Port on GravityView pages?', 'gravityview'), |
|
639 | 639 | ), |
640 | 640 | array( |
641 | 641 | 'name' => 'no-conflict-mode', |
642 | 642 | 'type' => 'radio', |
643 | - 'label' => __( 'No-Conflict Mode', 'gravityview' ), |
|
643 | + 'label' => __('No-Conflict Mode', 'gravityview'), |
|
644 | 644 | 'default_value' => $default_settings['no-conflict-mode'], |
645 | 645 | 'horizontal' => 1, |
646 | 646 | 'choices' => array( |
@@ -653,30 +653,30 @@ discard block |
||
653 | 653 | 'value' => '0', |
654 | 654 | ), |
655 | 655 | ), |
656 | - 'description' => __( 'Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview' ) . ' ' . __('If your Edit View tabs are ugly, enable this setting.', 'gravityview'), |
|
656 | + 'description' => __('Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview').' '.__('If your Edit View tabs are ugly, enable this setting.', 'gravityview'), |
|
657 | 657 | ), |
658 | 658 | array( |
659 | 659 | 'name' => 'delete-on-uninstall', |
660 | 660 | 'type' => 'radio', |
661 | - 'label' => __( 'Remove Data on Delete?', 'gravityview' ), |
|
661 | + 'label' => __('Remove Data on Delete?', 'gravityview'), |
|
662 | 662 | 'default_value' => $default_settings['delete-on-uninstall'], |
663 | 663 | 'horizontal' => 1, |
664 | 664 | 'choices' => array( |
665 | 665 | array( |
666 | - 'label' => _x( 'Keep GravityView Data', 'Setting: what to do when uninstalling plugin', 'gravityview' ), |
|
666 | + 'label' => _x('Keep GravityView Data', 'Setting: what to do when uninstalling plugin', 'gravityview'), |
|
667 | 667 | 'value' => '0', |
668 | - 'tooltip' => sprintf( '<h6>%s</h6><p>%s</p>', __( 'Keep GravityView content and settings', 'gravityview' ), __( 'If you delete then re-install the plugin, all GravityView data will be kept. Views, settings, etc. will be untouched.', 'gravityview' ) ), |
|
668 | + 'tooltip' => sprintf('<h6>%s</h6><p>%s</p>', __('Keep GravityView content and settings', 'gravityview'), __('If you delete then re-install the plugin, all GravityView data will be kept. Views, settings, etc. will be untouched.', 'gravityview')), |
|
669 | 669 | ), |
670 | 670 | array( |
671 | - 'label' => _x( 'Permanently Delete', 'Setting: what to do when uninstalling plugin', 'gravityview' ), |
|
671 | + 'label' => _x('Permanently Delete', 'Setting: what to do when uninstalling plugin', 'gravityview'), |
|
672 | 672 | 'value' => 'delete', |
673 | - 'tooltip' => sprintf( '<h6>%s</h6><p><span class="howto">%s</span></p><p>%s</p>', __( 'Delete all GravityView content and settings', 'gravityview' ), __( 'If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview' ), __( 'When GravityView is uninstalled and deleted, delete all Views, GravityView entry approvals, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings. No Gravity Forms data will be touched.', 'gravityview' ) ), |
|
673 | + 'tooltip' => sprintf('<h6>%s</h6><p><span class="howto">%s</span></p><p>%s</p>', __('Delete all GravityView content and settings', 'gravityview'), __('If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview'), __('When GravityView is uninstalled and deleted, delete all Views, GravityView entry approvals, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings. No Gravity Forms data will be touched.', 'gravityview')), |
|
674 | 674 | ), |
675 | 675 | ), |
676 | - 'description' => sprintf( __( 'Should GravityView content and entry approval status be removed from the site when the GravityView plugin is deleted?', 'gravityview' ), __( 'Permanently Delete', 'gravityview' ) ), |
|
676 | + 'description' => sprintf(__('Should GravityView content and entry approval status be removed from the site when the GravityView plugin is deleted?', 'gravityview'), __('Permanently Delete', 'gravityview')), |
|
677 | 677 | ), |
678 | 678 | |
679 | - ) ); |
|
679 | + )); |
|
680 | 680 | |
681 | 681 | |
682 | 682 | |
@@ -684,21 +684,21 @@ discard block |
||
684 | 684 | * Redux backward compatibility |
685 | 685 | * @since 1.7.4 |
686 | 686 | */ |
687 | - foreach ( $fields as &$field ) { |
|
688 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : rgget('id', $field ); |
|
689 | - $field['label'] = isset( $field['label'] ) ? $field['label'] : rgget('title', $field ); |
|
690 | - $field['default_value'] = isset( $field['default_value'] ) ? $field['default_value'] : rgget('default', $field ); |
|
691 | - $field['description'] = isset( $field['description'] ) ? $field['description'] : rgget('subtitle', $field ); |
|
692 | - |
|
693 | - if( $disabled_attribute ) { |
|
694 | - $field['disabled'] = $disabled_attribute; |
|
687 | + foreach ($fields as &$field) { |
|
688 | + $field['name'] = isset($field['name']) ? $field['name'] : rgget('id', $field); |
|
689 | + $field['label'] = isset($field['label']) ? $field['label'] : rgget('title', $field); |
|
690 | + $field['default_value'] = isset($field['default_value']) ? $field['default_value'] : rgget('default', $field); |
|
691 | + $field['description'] = isset($field['description']) ? $field['description'] : rgget('subtitle', $field); |
|
692 | + |
|
693 | + if ($disabled_attribute) { |
|
694 | + $field['disabled'] = $disabled_attribute; |
|
695 | 695 | } |
696 | 696 | } |
697 | 697 | |
698 | 698 | |
699 | 699 | $sections = array( |
700 | 700 | array( |
701 | - 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ), |
|
701 | + 'description' => sprintf('<span class="version-info description">%s</span>', sprintf(__('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version)), |
|
702 | 702 | 'fields' => $fields, |
703 | 703 | ) |
704 | 704 | ); |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | 'type' => 'save', |
710 | 710 | ); |
711 | 711 | |
712 | - if( $disabled_attribute ) { |
|
712 | + if ($disabled_attribute) { |
|
713 | 713 | $button['disabled'] = $disabled_attribute; |
714 | 714 | } |
715 | 715 | |
@@ -725,22 +725,22 @@ discard block |
||
725 | 725 | * </code> |
726 | 726 | * @param array $extension_settings Empty array, ready for extension settings! |
727 | 727 | */ |
728 | - $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() ); |
|
728 | + $extension_sections = apply_filters('gravityview/settings/extension/sections', array()); |
|
729 | 729 | |
730 | 730 | // If there are extensions, add a section for them |
731 | - if ( ! empty( $extension_sections ) ) { |
|
731 | + if (!empty($extension_sections)) { |
|
732 | 732 | |
733 | - if( $disabled_attribute ) { |
|
734 | - foreach ( $extension_sections as &$section ) { |
|
735 | - foreach ( $section['fields'] as &$field ) { |
|
733 | + if ($disabled_attribute) { |
|
734 | + foreach ($extension_sections as &$section) { |
|
735 | + foreach ($section['fields'] as &$field) { |
|
736 | 736 | $field['disabled'] = $disabled_attribute; |
737 | 737 | } |
738 | 738 | } |
739 | 739 | } |
740 | 740 | |
741 | - $k = count( $extension_sections ) - 1 ; |
|
742 | - $extension_sections[ $k ]['fields'][] = $button; |
|
743 | - $sections = array_merge( $sections, $extension_sections ); |
|
741 | + $k = count($extension_sections) - 1; |
|
742 | + $extension_sections[$k]['fields'][] = $button; |
|
743 | + $sections = array_merge($sections, $extension_sections); |
|
744 | 744 | } else { |
745 | 745 | // add the 'update settings' button to the general section |
746 | 746 | $sections[0]['fields'][] = $button; |
@@ -756,8 +756,8 @@ discard block |
||
756 | 756 | * |
757 | 757 | * @return mixed |
758 | 758 | */ |
759 | - static public function getSetting( $key ) { |
|
760 | - return self::get_instance()->get_app_setting( $key ); |
|
759 | + static public function getSetting($key) { |
|
760 | + return self::get_instance()->get_app_setting($key); |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | } |