Test Failed
Push — master ( b86487...e5e5a2 )
by Ravinder
07:05
created

Give_Forms_Report   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 110
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 110
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A add_settings_page() 0 5 1
B get_settings() 0 34 1
A output() 0 5 1
A render_report_forms_field() 0 3 1
1
<?php
2
/**
3
 * Give Reports Page/Tab
4
 *
5
 * @package     Give
6
 * @subpackage  Classes/Give_Forms_Report
7
 * @copyright   Copyright (c) 2016, WordImpress
8
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
 * @since       1.8
10
 */
11
12
if ( ! defined( 'ABSPATH' ) ) {
13
	exit; // Exit if accessed directly
14
}
15
16
if ( ! class_exists( 'Give_Forms_Report' ) ) :
17
18
	/**
19
	 * Give_Forms_Report.
20
	 *
21
	 * @sine 1.8
22
	 */
23
	class Give_Forms_Report {
24
25
		/**
26
		 * Setting page id.
27
		 *
28
		 * @since 1.8
29
		 * @var   string
30
		 */
31
		protected $id = '';
32
33
		/**
34
		 * Setting page label.
35
		 *
36
		 * @since 1.8
37
		 * @var   string
38
		 */
39
		protected $label = '';
40
41
		/**
42
		 * Constructor.
43
		 */
44
		public function __construct() {
45
			$this->id    = 'forms';
46
			$this->label = esc_html__( 'Forms', 'give' );
47
48
			add_filter( 'give-reports_tabs_array', array( $this, 'add_settings_page' ), 20 );
49
			add_action( "give-reports_settings_{$this->id}_page", array( $this, 'output' ) );
50
			add_action( 'give_admin_field_report_forms', array( $this, 'render_report_forms_field' ), 10, 2 );
51
52
		}
53
54
		/**
55
		 * Add this page to settings.
56
		 *
57
		 * @since  1.8
58
		 * @param  array $pages List of pages.
59
		 * @return array
60
		 */
61
		public function add_settings_page( $pages ) {
62
			$pages[ $this->id ] = $this->label;
63
64
			return $pages;
65
		}
66
67
		/**
68
		 * Get settings array.
69
		 *
70
		 * @since  1.8
71
		 * @return array
72
		 */
73
		public function get_settings() {
74
			// Hide save button.
75
			$GLOBALS['give_hide_save_button'] = true;
76
77
			/**
78
			 * Filter the settings.
79
			 *
80
			 * @since  1.8
81
			 * @param  array $settings
82
			 */
83
			$settings = apply_filters(
84
				'give_get_settings_' . $this->id,
85
				array(
86
					array(
87
						'id'   => 'give_reports_forms',
88
						'type' => 'title',
89
						'table_html' => false
0 ignored issues
show
introduced by
Each line in an array declaration must end in a comma
Loading history...
90
					),
91
					array(
92
						'id'   => 'forms',
93
						'name' => esc_html__( 'Forms', 'give' ),
94
						'type' => 'report_forms',
95
					),
96
					array(
97
						'id'   => 'give_reports_forms',
98
						'type' => 'sectionend',
99
						'table_html' => false
0 ignored issues
show
introduced by
Each line in an array declaration must end in a comma
Loading history...
100
					)
0 ignored issues
show
introduced by
Comma required after last value in array declaration
Loading history...
101
				)
102
			);
103
104
			// Output.
105
			return $settings;
106
		}
107
108
		/**
109
		 * Output the settings.
110
		 *
111
		 * @since  1.8
112
		 * @return void
113
		 */
114
		public function output() {
115
			$settings = $this->get_settings();
116
117
			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
118
		}
119
120
		/**
121
		 * Render report forms field
122
		 *
123
		 * @since  1.8
124
		 * @access public
125
		 *
126
		 * @param $field
127
		 * @param $option_value
128
		 */
129
		public function render_report_forms_field( $field, $option_value ) {
0 ignored issues
show
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...
Unused Code introduced by
The parameter $option_value 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...
130
			do_action( 'give_reports_view_forms');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
131
		}
132
	}
133
134
endif;
135
136
return new Give_Forms_Report();
137