Completed
Pull Request — master (#1412)
by Ravinder
17:25
created

Give_Settings_Advanced   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 116
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 116
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
B get_settings() 0 81 2
A get_sections() 0 7 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 23 and the first side effect is on line 13.

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
 * Give Settings Page/Tab
4
 *
5
 * @package     Give
6
 * @subpackage  Classes/Give_Settings_Advanced
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_Settings_Advanced' ) ) :
17
18
	/**
19
	 * Give_Settings_Advanced.
20
	 *
21
	 * @sine 1.8
22
	 */
23
	class Give_Settings_Advanced extends Give_Settings_Page {
24
25
		/**
26
		 * Constructor.
27
		 */
28
		public function __construct() {
29
			$this->id    = 'advanced';
30
			$this->label = esc_html__( 'Advanced', 'give' );
31
32
			$this->default_tab = 'advanced-options';
33
34
			parent::__construct();
35
		}
36
37
		/**
38
		 * Get settings array.
39
		 *
40
		 * @since  1.8
41
		 * @return array
42
		 */
43
		public function get_settings() {
44
			$settings = array();
45
46
			$current_section = give_get_current_setting_section();
47
48
			switch ( $current_section ) {
49
				case 'advanced-options':
50
					$settings = array(
51
						array(
52
							'id'   => 'give_title_data_control_2',
53
							'type' => 'title'
54
						),
55
						array(
56
							'name'    => esc_html__( 'Remove Data on Uninstall', 'give' ),
57
							'desc'    => esc_html__( 'When the plugin is deleted, completely remove all Give data.', 'give' ),
58
							'id'      => 'uninstall_on_delete',
59
							'type'    => 'radio_inline',
60
							'default' => 'disabled',
61
							'options' => array(
62
								'enabled'  => __( 'Enabled', 'give' ),
63
								'disabled' => __( 'Disabled', 'give' ),
64
							)
65
						),
66
						array(
67
							/* translators: %s: the_content */
68
							'name'    => sprintf( __( '%s filter', 'give' ), '<code>the_content</code>' ),
69
							/* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */
70
							'desc'    => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ),
71
							'id'      => 'the_content_filter',
72
							'default' => 'enabled',
73
							'type'    => 'radio_inline',
74
							'options' => array(
75
								'enabled'  => __( 'Enabled', 'give' ),
76
								'disabled' => __( 'Disabled', 'give' ),
77
							)
78
						),
79
						array(
80
							'name'    => esc_html__( 'Load Scripts in Footer?', 'give' ),
81
							'desc'    => esc_html__( 'Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give' ),
82
							'id'      => 'scripts_footer',
83
							'type'    => 'radio_inline',
84
							'default' => 'disabled',
85
							'options' => array(
86
								'enabled'  => __( 'Enabled', 'give' ),
87
								'disabled' => __( 'Disabled', 'give' ),
88
							)
89
						),
90
                        array(
91
                            'name'  => esc_html__( 'Advanced Settings Docs Link', 'give' ),
92
                            'id'    => 'advanced_settings_docs_link',
93
                            'url'   => esc_url( 'http://docs.givewp.com/advancedsettings' ),
94
                            'title' => __( 'Advanced Settings', 'give' ),
95
                            'type'  => 'give_docs_link',
96
                        ),
97
						array(
98
							'id'   => 'give_title_data_control_2',
99
							'type' => 'sectionend'
100
						)
101
					);
102
					break;
103
			}
104
105
106
			/**
107
			 * Filter the advanced settings.
108
			 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
109
			 */
110
			$settings = apply_filters( 'give_settings_advanced', $settings );
111
112
			/**
113
			 * Filter the settings.
114
			 *
115
			 * @since  1.8
116
			 *
117
			 * @param  array $settings
118
			 */
119
			$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
120
121
			// Output.
122
			return $settings;
123
		}
124
125
		/**
126
		 * Get sections.
127
		 *
128
		 * @since 1.8
129
		 * @return array
130
		 */
131
		public function get_sections() {
132
			$sections = array(
133
				'advanced-options' => esc_html__( 'Advanced Options', 'give' )
134
			);
135
136
			return apply_filters( 'give_get_sections_' . $this->id, $sections );
137
		}
138
	}
139
140
endif;
141
142
return new Give_Settings_Advanced();
143