Completed
Push — develop ( 778b65...65bf35 )
by Zack
04:07
created

GravityView_Entry_Approval::update_approved()   C

Complexity

Conditions 11
Paths 12

Size

Total Lines 63
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 11
eloc 29
nc 12
nop 4
dl 0
loc 63
rs 6.1137
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 23 and the first side effect is on line 15.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * @file class-gravityview-entry-approval.php
4
 * @package   GravityView
5
 * @license   GPL2+
6
 * @author    Katz Web Services, Inc.
7
 * @link      https://gravityview.co
8
 * @copyright Copyright 2016, Katz Web Services, Inc.
9
 *
10
 * @since 1.18
11
 */
12
13
/** If this file is called directly, abort. */
14
if ( ! defined( 'ABSPATH' ) ) {
15
	die;
16
}
17
18
/**
19
 * Generate linked list output for a list of entries.
20
 *
21
 * @since 1.18
22
 */
23
class GravityView_Entry_Approval {
24
25
	/**
26
	 * @var string Key used to store approval status in the Gravity Forms entry meta table
27
	 */
28
	const meta_key = 'is_approved';
29
30
	public function __construct() {
31
		$this->add_hooks();
32
	}
33
34
	/**
35
	 * Add actions and filters related to entry approval
36
	 *
37
	 * @return void
38
	 */
39
	private function add_hooks() {
40
41
		// in case entry is edited (on admin or frontend)
42
		add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2);
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
43
44
		// when using the User opt-in field, check on entry submission
45
		add_action( 'gform_after_submission', array( $this, 'after_submission' ), 10, 2 );
46
47
		// process ajax approve entry requests
48
		add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved'));
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
introduced by
No space before closing parenthesis of array is bad style
Loading history...
49
50
	}
51
52
	/**
53
	 * Get the approval status for an entry
54
	 *
55
	 * @since 1.18
56
	 * @uses GVCommon::get_entry_id() Accepts entry slug or entry ID
57
	 *
58
	 * @param array|int|string $entry Entry array, entry slug, or entry ID
59
	 * @param string $value_or_label "value" or "label" (default: "label")
60
	 *
61
	 * @return bool|string Return the label or value of entry approval
62
	 */
63
	public static function get_entry_status( $entry, $value_or_label = 'label' ) {
64
65
		$entry_id = is_array( $entry ) ? $entry['id'] : GVCommon::get_entry_id( $entry );
66
67
		$status = gform_get_meta( $entry_id, self::meta_key );
68
69
		$status = GravityView_Entry_Approval_Status::maybe_convert_status( $status );
70
71
		if( 'value' === $value_or_label ) {
72
			return $status;
73
		}
74
75
		return GravityView_Entry_Approval_Status::get_label( $status );
76
	}
77
78
	/**
79
	 * Approve/Disapprove entries using the × or ✓ icons in the GF Entries screen
80
	 *
81
	 * @uses wp_send_json_error()
82
	 * @uses wp_send_json_success()
83
	 *
84
	 * Expects a $_POST request with the following $_POST keys and values:
85
	 *
86
	 * @global array $_POST {
87
	 * @type int $form_id ID of the form connected to the entry being updated
88
	 * @type string|int $entry_slug The ID or slug of the entry being updated
89
	 * @type string $approved The value of the entry approval status {@see GravityView_Entry_Approval_Status::is_valid() }
90
	 * }
91
	 *
92
	 * @return void Prints result using wp_send_json_success() and wp_send_json_error()
93
	 */
94
	public function ajax_update_approved() {
95
96
		$form_id = intval( rgpost('form_id') );
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
97
98
		$entry_id = GVCommon::get_entry_id( rgpost('entry_slug') );
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
99
100
		$approval_status = rgpost('approved');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
101
102
		$nonce = rgpost('nonce');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
103
104
		// Valid status
105
		if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) {
106
107
			do_action( 'gravityview_log_error', __METHOD__ . ': Invalid approval status', $_POST );
0 ignored issues
show
introduced by
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
108
109
			$result = new WP_Error( 'invalid_status', __( 'The request was invalid. Refresh the page and try again.', 'gravityview' ) );
110
111
		}
112
113
		// Valid values
114
		elseif ( empty( $entry_id ) || empty( $form_id ) ) {
115
116
			do_action( 'gravityview_log_error', __METHOD__ . ' entry_id or form_id are empty.', $_POST );
0 ignored issues
show
introduced by
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
117
118
			$result = new WP_Error( 'empty_details', __( 'The request was invalid. Refresh the page and try again.', 'gravityview' ) );
119
120
		}
121
122
		// Valid nonce
123
		else if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'gravityview_entry_approval' ) ) {
124
125
			do_action( 'gravityview_log_error', __METHOD__ . ' Security check failed.', $_POST );
0 ignored issues
show
introduced by
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
126
127
			$result = new WP_Error( 'invalid_nonce', __( 'The request was invalid. Refresh the page and try again.', 'gravityview' ) );
128
129
		}
130
131
		// Has capability
132
		elseif ( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry_id ) ) {
133
134
			do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' );
135
136
			$result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview') );
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
137
138
		}
139
140
		// All checks passed
141
		else {
142
143
			$result = self::update_approved( $entry_id, $approval_status, $form_id );
144
145
		}
146
147
		if ( is_wp_error( $result ) ) {
148
			do_action( 'gravityview_log_error', __METHOD__ . ' Error updating approval: ' . $result->get_error_message() );
149
150
			wp_send_json_error( $result );
151
		}
152
153
		$current_status = self::get_entry_status( $entry_id, 'value' );
154
155
		wp_send_json_success( array(
156
			'status' => $current_status
0 ignored issues
show
introduced by
Each line in an array declaration must end in a comma
Loading history...
157
		) );
158
	}
159
160
	/**
161
	 * Update the is_approved meta whenever the entry is submitted (and it contains a User Opt-in field)
162
	 *
163
	 * @since 1.16.6
164
	 *
165
	 * @param $entry array Gravity Forms entry object
166
	 * @param $form array Gravity Forms form object
167
	 */
168
	public function after_submission( $entry, $form ) {
169
		$this->after_update_entry_update_approved_meta( $form , $entry['id'] );
170
	}
171
172
	/**
173
	 * Update the is_approved meta whenever the entry is updated
174
	 *
175
	 * @since 1.7.6.1 Was previously named `update_approved_meta`
176
	 *
177
	 * @param  array $form     Gravity Forms form array
178
	 * @param  int $entry_id ID of the Gravity Forms entry
179
	 * @return void
180
	 */
181
	public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) {
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected null, but found NULL.
Loading history...
182
183
		$approved_column = self::get_approved_column( $form['id'] );
184
185
		/**
186
		 * If the form doesn't contain the approve field, don't assume anything.
187
		 */
188
		if( empty( $approved_column ) ) {
189
			return;
190
		}
191
192
		$entry = GFAPI::get_entry( $entry_id );
193
194
		self::update_approved_meta( $entry_id, $entry[ (string)$approved_column ], $form['id'] );
0 ignored issues
show
introduced by
No space after closing casting parenthesis is prohibited
Loading history...
195
	}
196
197
	/**
198
	 * Process a bulk of entries to update the approve field/property
199
	 *
200
	 * @since 1.18 Moved to GravityView_Entry_Approval
201
	 * @since 1.18 Made public
202
	 *
203
	 * @access public
204
	 * @static
205
	 * @param array|boolean $entries If array, array of entry IDs that are to be updated. If true: update all entries.
206
	 * @param int $approved Approved status. If `0`: unapproved, if not empty, `Approved`
207
	 * @param int $form_id The Gravity Forms Form ID
208
	 * @return boolean|null True: successfully updated all entries. False: there was an error updating at least one entry. NULL: an error occurred (see log)
209
	 */
210
	public static function update_bulk( $entries = array(), $approved, $form_id ) {
211
212
		if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) {
0 ignored issues
show
introduced by
Found "!== true". Use Yoda Condition checks, you must
Loading history...
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
introduced by
Expected 1 space after "!"; 0 found
Loading history...
213
			do_action( 'gravityview_log_error', __METHOD__ . ' Entries were empty or malformed.', $entries );
214
			return NULL;
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected null, but found NULL.
Loading history...
215
		}
216
217
		if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) {
218
			do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' );
219
			return NULL;
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected null, but found NULL.
Loading history...
220
		}
221
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
222
223
		if ( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) {
224
			do_action( 'gravityview_log_error', __METHOD__ . ' Invalid approval status', $approved );
225
			return NULL;
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected null, but found NULL.
Loading history...
226
		}
227
228
		// calculate approved field id once instead of looping through in the update_approved() method
229
		$approved_column_id = self::get_approved_column( $form_id );
230
231
		$success = true;
232
		foreach( $entries as $entry_id ) {
0 ignored issues
show
Bug introduced by
The expression $entries of type boolean|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
233
			$update_success = self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id );
0 ignored issues
show
introduced by
No space after closing casting parenthesis is prohibited
Loading history...
234
235
			if( ! $update_success ) {
236
				$success = false;
237
			}
238
		}
239
240
		return $success;
241
	}
242
243
	/**
244
	 * update_approved function.
245
	 *
246
	 * @since 1.18 Moved to GravityView_Entry_Approval class
247
	 *
248
	 * @access public
249
	 * @static
250
	 * @param int $entry_id (default: 0)
251
	 * @param int $approved (default: 0)
252
	 * @param int $form_id (default: 0)
253
	 * @param int $approvedcolumn (default: 0)
254
	 *
255
	 * @return boolean True: It worked; False: it failed
256
	 */
257
	public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0 ) {
258
259
		if( !class_exists( 'GFAPI' ) ) {
0 ignored issues
show
introduced by
Expected 1 space after "!"; 0 found
Loading history...
260
			do_action( 'gravityview_log_error', __METHOD__ . 'GFAPI does not exist' );
261
			return false;
262
		}
263
264
		if( '' === $approved || ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) {
0 ignored issues
show
Unused Code Bug introduced by
The strict comparison === seems to always evaluate to false as the types of '' (string) and $approved (integer) can never be identical. Maybe you want to use a loose comparison == instead?
Loading history...
265
			do_action( 'gravityview_log_error', __METHOD__ . ': Not a valid approval value.' );
266
			return false;
267
		}
268
269
		$result = self::update_approved_column( $entry_id, $approved, $form_id, $approvedcolumn );
270
271
		/**
272
		 * GFAPI::update_entry() doesn't trigger `gform_after_update_entry`, so we trigger updating the meta ourselves.
273
		 */
274
		self::update_approved_meta( $entry_id, $approved, $form_id );
275
276
		// add note to entry if approval field updating worked or there was no approved field
277
		// There's no validation for the meta
278
		if( true === $result ) {
279
280
			switch ( $approved ) {
281
				case GravityView_Entry_Approval_Status::APPROVED:
282
					$note = __( 'Approved the Entry for GravityView', 'gravityview' );
283
					break;
284
				case GravityView_Entry_Approval_Status::UNAPPROVED:
285
					$note = __( 'Reset Entry approval for GravityView', 'gravityview' );
286
					break;
287
				case GravityView_Entry_Approval_Status::DISAPPROVED:
288
					$note = __( 'Disapproved the Entry for GravityView', 'gravityview' );
289
					break;
290
			}
291
292
			/**
293
			 * @filter `gravityview/approve_entries/add-note` Add a note when the entry has been approved or disapproved?
294
			 * @since 1.16.3
295
			 * @param bool $add_note True: Yep, add that note! False: Do not, under any circumstances, add that note!
296
			 */
297
			$add_note = apply_filters( 'gravityview/approve_entries/add-note', true );
298
299
			if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) {
300
				$current_user = wp_get_current_user();
301
				GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $current_user->display_name, $note );
0 ignored issues
show
Bug introduced by
The variable $note does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
302
			}
303
304
			/**
305
			 * Destroy the cache for this form
306
			 * @see class-cache.php
307
			 * @since 1.5.1
308
			 */
309
			do_action( 'gravityview_clear_form_cache', $form_id );
310
311
		} else if( is_wp_error( $result ) ) {
312
313
			do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - Entry approval not updated: %s', $result->get_error_message() ) );
314
315
			$result = false;
316
		}
317
318
		return $result;
319
	}
320
321
	/**
322
	 * Update the Approve/Disapproved field value
323
	 *
324
	 * @param  int $entry_id ID of the Gravity Forms entry
325
	 * @param  string $status String whether entry is approved or not. `0` for not approved, `Approved` for approved.
326
	 * @param int $form_id ID of the form of the entry being updated. Improves query performance.
327
	 * @param string $approvedcolumn Gravity Forms Field ID
328
	 *
329
	 * @return true|WP_Error
330
	 */
331
	private static function update_approved_column( $entry_id = 0, $status = '0', $form_id = 0, $approvedcolumn = 0 ) {
332
333
		if( empty( $approvedcolumn ) ) {
334
			$approvedcolumn = self::get_approved_column( $form_id );
335
		}
336
337
		if ( empty( $approvedcolumn ) ) {
338
			return true;
339
		}
340
341
		if ( ! GravityView_Entry_Approval_Status::is_valid( $status ) ) {
342
			return new WP_Error( 'invalid_status', 'Invalid entry approval status', $status );
343
		}
344
345
		//get the entry
346
		$entry = GFAPI::get_entry( $entry_id );
347
348
		//update entry
349
		$entry[ (string)$approvedcolumn ] = $status;
0 ignored issues
show
introduced by
No space after closing casting parenthesis is prohibited
Loading history...
350
351
		/** @var bool|WP_Error $result */
352
		$result = GFAPI::update_entry( $entry );
353
354
		return $result;
355
	}
356
357
	/**
358
	 * Update the `is_approved` entry meta value
359
	 *
360
	 * @since 1.7.6.1 `after_update_entry_update_approved_meta` was previously to be named `update_approved_meta`
361
	 * @since 1.17.1 Added $form_id parameter
362
	 *
363
	 * @param  int $entry_id ID of the Gravity Forms entry
364
	 * @param  string $status String whether entry is approved or not. `0` for not approved, `Approved` for approved.
365
	 * @param int $form_id ID of the form of the entry being updated. Improves query performance.
366
	 *
367
	 * @return void
368
	 */
369
	private static function update_approved_meta( $entry_id, $status, $form_id = 0 ) {
370
371
		if ( ! GravityView_Entry_Approval_Status::is_valid( $status ) ) {
372
			do_action('gravityview_log_error', __METHOD__ . ': $is_approved not valid value', $status );
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
373
			return;
374
		}
375
376
		$status = GravityView_Entry_Approval_Status::maybe_convert_status( $status );
377
378
		// update entry meta
379
		if( function_exists('gform_update_meta') ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
380
381
			if( GravityView_Entry_Approval_Status::is_unapproved( $status ) ) {
382
				gform_delete_meta( $entry_id, self::meta_key );
383
			} else {
384
				gform_update_meta( $entry_id, self::meta_key, $status, $form_id );
385
			}
386
387
			/**
388
			 * @action `gravityview/approve_entries/updated` Triggered when an entry approval is updated
389
			 * @since 1.7.6.1
390
			 * @param  int $entry_id ID of the Gravity Forms entry
391
			 * @param  string|int $status String whether entry is approved or not. See GravityView_Entry_Approval_Status for valid statuses.
392
			 */
393
			do_action( 'gravityview/approve_entries/updated', $entry_id, $status );
394
395
			$action = GravityView_Entry_Approval_Status::get_key( $status );
396
397
			/**
398
			 * @action `gravityview/approve_entries/{$action}` Triggered when an entry approval is reset.
399
			 * $action can be 'approved', 'unapproved', or 'disapproved'
400
			 * @since 1.7.6.1
401
			 * @since 1.18 Added "unapproved"
402
			 * @param  int $entry_id ID of the Gravity Forms entry
403
			 */
404
			do_action( 'gravityview/approve_entries/' . $action , $entry_id );
405
406
		} else {
407
408
			do_action('gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' );
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
409
410
		}
411
	}
412
413
	/**
414
	 * Calculate the approve field.input id
415
	 *
416
	 * @access public
417
	 * @static
418
	 * @param mixed $form GF Form or Form ID
419
	 * @return false|null|string Returns the input ID of the approved field. Returns NULL if no approved fields were found. Returns false if $form_id wasn't set.
420
	 */
421
	static public function get_approved_column( $form ) {
0 ignored issues
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
422
423
		if( empty( $form ) ) {
424
			return null;
425
		}
426
427
		if( !is_array( $form ) ) {
0 ignored issues
show
introduced by
Expected 1 space after "!"; 0 found
Loading history...
428
			$form = GVCommon::get_form( $form );
429
		}
430
431
		foreach( $form['fields'] as $key => $field ) {
432
433
			$field = (array) $field;
434
435
			if( !empty( $field['gravityview_approved'] ) ) {
0 ignored issues
show
introduced by
Expected 1 space after "!"; 0 found
Loading history...
436
				if( !empty($field['inputs'][0]['id']) ) {
0 ignored issues
show
introduced by
Expected 1 space after "!"; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
437
					return $field['inputs'][0]['id'];
438
				}
439
			}
440
441
			// Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work..
442
			if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) {
443
				foreach ( $field['inputs'] as $key2 => $input ) {
444
					if ( strtolower( $input['label'] ) == 'approved' ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
445
						return $input['id'];
446
					}
447
				}
448
			}
449
		}
450
451
		return null;
452
	}
453
454
}
455
456
new GravityView_Entry_Approval;