Code Duplication    Length = 87-101 lines in 4 locations

includes/admin/reports/class-earnings-report.php 1 location

@@ 16-105 (lines=90) @@
13
	exit; // Exit if accessed directly
14
}
15
16
if ( ! class_exists( 'Give_Earnings_Report' ) ) :
17
18
	/**
19
	 * Give_Earnings_Report.
20
	 *
21
	 * @sine 1.8
22
	 */
23
	class Give_Earnings_Report extends Give_Settings_Page {
24
25
		/**
26
		 * Flag to check if enable saving option for setting page or not
27
		 *
28
		 * @since 1.8.17
29
		 * @var bool
30
		 */
31
		protected $enable_save = false;
32
33
		/**
34
		 * Constructor.
35
		 */
36
		public function __construct() {
37
			$this->id    = 'earnings';
38
			$this->label = esc_html__( 'Income', 'give' );
39
40
			parent::__construct();
41
42
			add_action( 'give_admin_field_report_earnings', array( $this, 'render_report_earnings_field' ), 10, 2 );
43
44
			// Do not use main form for this tab.
45
			if ( give_get_current_setting_tab() === $this->id ) {
46
				add_action( 'give-reports_open_form', '__return_empty_string' );
47
				add_action( 'give-reports_close_form', '__return_empty_string' );
48
			}
49
		}
50
51
52
		/**
53
		 * Get settings array.
54
		 *
55
		 * @since  1.8
56
		 * @return array
57
		 */
58
		public function get_settings() {
59
			/**
60
			 * Filter the settings.
61
			 *
62
			 * @since  1.8
63
			 *
64
			 * @param  array $settings
65
			 */
66
			$settings = apply_filters(
67
				'give_get_settings_' . $this->id,
68
				array(
69
					array(
70
						'id'         => 'give_tools_earnings',
71
						'type'       => 'title',
72
						'table_html' => false,
73
					),
74
					array(
75
						'id'   => 'earnings',
76
						'name' => esc_html__( 'Income', 'give' ),
77
						'type' => 'report_earnings',
78
					),
79
					array(
80
						'id'         => 'give_tools_earnings',
81
						'type'       => 'sectionend',
82
						'table_html' => false,
83
					),
84
				)
85
			);
86
87
			// Output.
88
			return $settings;
89
		}
90
91
		/**
92
		 * Render earning field
93
		 *
94
		 * @since  1.8
95
		 * @access public
96
		 *
97
		 * @param $field
98
		 * @param $option_value
99
		 */
100
		public function render_report_earnings_field( $field, $option_value ) {
101
			do_action( 'give_reports_view_earnings' );
102
		}
103
	}
104
105
endif;
106
107
return new Give_Earnings_Report();
108

includes/admin/reports/class-forms-report.php 1 location

@@ 16-104 (lines=89) @@
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 extends Give_Settings_Page {
24
		/**
25
		 * Flag to check if enable saving option for setting page or not
26
		 *
27
		 * @since 1.8.17
28
		 * @var bool
29
		 */
30
		protected $enable_save = false;
31
32
		/**
33
		 * Constructor.
34
		 */
35
		public function __construct() {
36
			$this->id    = 'forms';
37
			$this->label = esc_html__( 'Forms', 'give' );
38
39
			parent::__construct();
40
41
			add_action( 'give_admin_field_report_forms', array( $this, 'render_report_forms_field' ), 10, 2 );
42
43
			// Do not use main form for this tab.
44
			if ( give_get_current_setting_tab() === $this->id ) {
45
				add_action( 'give-reports_open_form', '__return_empty_string' );
46
				add_action( 'give-reports_close_form', '__return_empty_string' );
47
			}
48
		}
49
50
		/**
51
		 * Get settings array.
52
		 *
53
		 * @since  1.8
54
		 * @return array
55
		 */
56
		public function get_settings() {
57
58
			/**
59
			 * Filter the settings.
60
			 *
61
			 * @since  1.8
62
			 *
63
			 * @param  array $settings
64
			 */
65
			$settings = apply_filters(
66
				'give_get_settings_' . $this->id,
67
				array(
68
					array(
69
						'id'         => 'give_reports_forms',
70
						'type'       => 'title',
71
						'table_html' => false,
72
					),
73
					array(
74
						'id'   => 'forms',
75
						'name' => esc_html__( 'Forms', 'give' ),
76
						'type' => 'report_forms',
77
					),
78
					array(
79
						'id'         => 'give_reports_forms',
80
						'type'       => 'sectionend',
81
						'table_html' => false,
82
					),
83
				)
84
			);
85
86
			// Output.
87
			return $settings;
88
		}
89
90
		/**
91
		 * Render report forms field
92
		 *
93
		 * @since  1.8
94
		 * @access public
95
		 *
96
		 * @param $field
97
		 * @param $option_value
98
		 */
99
		public function render_report_forms_field( $field, $option_value ) {
100
			do_action( 'give_reports_view_forms' );
101
		}
102
	}
103
104
endif;
105
106
return new Give_Forms_Report();
107

includes/admin/reports/class-gateways-report.php 1 location

@@ 16-116 (lines=101) @@
13
	exit; // Exit if accessed directly
14
}
15
16
if ( ! class_exists( 'Give_Gateways_Report' ) ) :
17
18
	/**
19
	 * Give_Gateways_Report.
20
	 *
21
	 * @sine 1.8
22
	 */
23
	class Give_Gateways_Report extends Give_Settings_Page {
24
		/**
25
		 * Flag to check if enable saving option for setting page or not
26
		 *
27
		 * @since 1.8.17
28
		 * @var bool
29
		 */
30
		protected $enable_save = false;
31
32
		/**
33
		 * Constructor.
34
		 */
35
		public function __construct() {
36
			$this->id    = 'gateways';
37
			$this->label = esc_html__( 'Donation Methods', 'give' );
38
39
			parent::__construct();
40
41
			add_action( 'give_admin_field_report_gateways', array( $this, 'render_report_gateways_field' ), 10, 2 );
42
43
			// Do not use main form for this tab.
44
			if ( give_get_current_setting_tab() === $this->id ) {
45
				add_action( 'give-reports_open_form', '__return_empty_string' );
46
				add_action( 'give-reports_close_form', '__return_empty_string' );
47
			}
48
		}
49
50
51
		/**
52
		 * Get sections.
53
		 *
54
		 * @since  1.8.17
55
		 * @access public
56
		 *
57
		 * @return array
58
		 */
59
		public function get_sections() {
60
			return array();
61
		}
62
63
		/**
64
		 * Get settings array.
65
		 *
66
		 * @since  1.8
67
		 * @return array
68
		 */
69
		public function get_settings() {
70
			/**
71
			 * Filter the settings.
72
			 *
73
			 * @since  1.8
74
			 *
75
			 * @param  array $settings
76
			 */
77
			$settings = apply_filters(
78
				'give_get_settings_' . $this->id,
79
				array(
80
					array(
81
						'id'         => 'give_reports_gateways',
82
						'type'       => 'title',
83
						'table_html' => false,
84
					),
85
					array(
86
						'id'   => 'gateways',
87
						'name' => esc_html__( 'Gateways', 'give' ),
88
						'type' => 'report_gateways',
89
					),
90
					array(
91
						'id'         => 'give_reports_gateways',
92
						'type'       => 'sectionend',
93
						'table_html' => false,
94
					),
95
				)
96
			);
97
98
			// Output.
99
			return $settings;
100
		}
101
102
		/**
103
		 * Render earning field
104
		 *
105
		 * @since  1.8
106
		 * @access public
107
		 *
108
		 * @param $field
109
		 * @param $option_value
110
		 */
111
		public function render_report_gateways_field( $field, $option_value ) {
112
			do_action( 'give_reports_view_gateways' );
113
		}
114
	}
115
116
endif;
117
118
return new Give_Gateways_Report();
119

includes/admin/tools/class-settings-export.php 1 location

@@ 16-102 (lines=87) @@
13
	exit; // Exit if accessed directly
14
}
15
16
if ( ! class_exists( 'Give_Settings_Export' ) ) :
17
18
	/**
19
	 * Give_Settings_Export.
20
	 *
21
	 * @sine 1.8
22
	 */
23
	class Give_Settings_Export extends Give_Settings_Page {
24
		/**
25
		 * Flag to check if enable saving option for setting page or not
26
		 *
27
		 * @since 1.8.17
28
		 * @var bool
29
		 */
30
		protected $enable_save = false;
31
32
		/**
33
		 * Constructor.
34
		 */
35
		public function __construct() {
36
			$this->id    = 'export';
37
			$this->label = __( 'Export', 'give' );
38
39
			parent::__construct();
40
41
			add_action( 'give_admin_field_tools_export', array( $this, 'render_export_field' ), 10, 2 );
42
43
			// Do not use main donor for this tab.
44
			if( give_get_current_setting_tab() === $this->id ) {
45
				add_action( 'give-tools_open_form', '__return_empty_string' );
46
				add_action( 'give-tools_close_form', '__return_empty_string' );
47
			}
48
		}
49
50
		/**
51
		 * Get settings array.
52
		 *
53
		 * @since  1.8
54
		 * @return array
55
		 */
56
		public function get_settings() {
57
			/**
58
			 * Filter the settings.
59
			 *
60
			 * @since  1.8
61
			 * @param  array $settings
62
			 */
63
			$settings = apply_filters(
64
				'give_get_settings_' . $this->id,
65
				array(
66
					array(
67
						'id'   => 'give_tools_export',
68
						'type' => 'title',
69
						'table_html' => false
70
					),
71
					array(
72
						'id'   => 'export',
73
						'name' => __( 'Export', 'give' ),
74
						'type' => 'tools_export',
75
					),
76
					array(
77
						'id'   => 'give_tools_export',
78
						'type' => 'sectionend',
79
						'table_html' => false
80
					)
81
				)
82
			);
83
84
			// Output.
85
			return $settings;
86
		}
87
88
		/**
89
		 * Render report export field
90
		 *
91
		 * @since  1.8
92
		 * @access public
93
		 *
94
		 * @param $field
95
		 * @param $option_value
96
		 */
97
		public function render_export_field( $field, $option_value ) {
98
			include_once( 'views/html-admin-page-exports.php' );
99
		}
100
	}
101
102
endif;
103
104
return new Give_Settings_Export();
105