Completed
Push — master ( 92cdcd...79386d )
by Zack
20:40 queued 10:41
created

add_hooks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 1
b 0
f 1
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 9 and the first side effect is on line 76.

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-field-workflow_final_status.php
4
 * @since 1.17.2
5
 * @package GravityView
6
 * @subpackage includes\fields
7
 */
8
9
class GravityView_Field_Workflow_Final_Status extends GravityView_Field {
10
11
	var $name = 'workflow_final_status';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

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

Loading history...
12
13
	var $group = 'meta';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $group.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

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

Loading history...
14
15
	public function __construct() {
16
		$this->label = esc_html__( 'Workflow Status', 'gravityview' );
17
		$this->default_search_label = $this->label;
18
		$this->add_hooks();
19
		parent::__construct();
20
	}
21
22
	function add_hooks() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
23
		add_filter( 'gravityview_widget_search_filters', array( $this, 'modify_search_filters' ), 10, 3 );
24
25
		add_filter( 'gravityview_field_entry_value_workflow_final_status', array( $this, 'modify_entry_value_workflow_final_status' ), 10, 4 );
26
	}
27
28
	/**
29
	 * Convert the status key with the full status label. Uses custom labels, if set.
30
	 *
31
	 * @uses Gravity_Flow::translate_status_label()
32
	 *
33
	 * @param string $output HTML value output
34
	 * @param array  $entry The GF entry array
35
	 * @param  array $field_settings Settings for the particular GV field
36
	 * @param array $field Current field being displayed
37
	 *
38
	 * @since 1.17
39
	 *
40
	 * @return string If Gravity Flow not found, or entry not processed yet, returns initial value. Otherwise, returns name of workflow step.
41
	 */
42
	function modify_entry_value_workflow_final_status( $output, $entry, $field_settings, $field ) {
0 ignored issues
show
Unused Code introduced by
The parameter $entry is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $field_settings is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $field is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
43
44
		if( ! empty( $output ) ) {
45
			$output = gravity_flow()->translate_status_label( $output );
46
		}
47
48
		return $output;
49
	}
50
51
52
	/**
53
	 * Populate the Final Status Search Bar field dropdown with all the statuses in Gravity Flow
54
	 *
55
	 * @since 1.17.3
56
	 *
57
	 * @param array $search_fields
58
	 * @param GravityView_Widget_Search $widget
59
	 * @param array $widget_args
60
	 *
61
	 * @return array
62
	 */
63
	function modify_search_filters( $search_fields = array(), GravityView_Widget_Search $widget, $widget_args = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $widget is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $widget_args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
64
65
		foreach ( $search_fields as & $search_field ) {
66
			if ( $this->name === $search_field['key'] ) {
67
				$search_field['choices'] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options();
68
			}
69
		}
70
71
		return $search_fields;
72
	}
73
74
}
75
76
new GravityView_Field_Workflow_Final_Status;
77