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

Give_Settings_Display   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 288
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 288
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
B get_settings() 0 250 5
A get_sections() 0 10 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_Display
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_Display' ) ) :
17
18
	/**
19
	 * Give_Settings_Display.
20
	 *
21
	 * @sine 1.8
22
	 */
23
	class Give_Settings_Display extends Give_Settings_Page {
24
25
		/**
26
		 * Constructor.
27
		 */
28
		public function __construct() {
29
			$this->id    = 'display';
30
			$this->label = esc_html__( 'Display Options', 'give' );
31
32
			$this->default_tab = 'display-settings';
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
			$current_section = give_get_current_setting_section();
46
47
			switch ( $current_section ) {
48
				case 'display-settings' :
49
					$settings = array(
50
						// Section 1: Display
51
						array(
52
							'id'   => 'give_title_display_settings_1',
53
							'type' => 'title'
54
						),
55
						array(
56
							'name'    => esc_html__( 'Default Give Styles', 'give' ),
57
							'desc'    => esc_html__( 'Give includes default styles for donation forms and other frontend elements.', 'give' ),
58
							'id'      => 'css',
59
							'type'    => 'radio_inline',
60
							'default' => 'enabled',
61
							'options' => array(
62
								'enabled' => __( 'Enabled', 'give' ),
63
								'disabled' => __( 'Disabled', 'give' ),
64
							)
65
						),
66
						array(
67
							'name' => esc_html__( 'Floating Labels', 'give' ),
68
							/* translators: %s: https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels */
69
							'desc' => sprintf( wp_kses( __( '<a href="%s" target="_blank">Floating labels</a> in set form labels within fields and can improve the donor experience. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( 'https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels' ) ),
70
							'id'   => 'floatlabels',
71
							'type'    => 'radio_inline',
72
							'default' => 'disabled',
73
							'options' => array(
74
								'enabled' => __( 'Enabled', 'give' ),
75
								'disabled' => __( 'Disabled', 'give' ),
76
							)
77
						),
78
						array(
79
							'name'    => esc_html__( 'Welcome Screen', 'give' ),
80
							/* translators: %s: about page URL */
81
							'desc'    => sprintf( wp_kses( __( 'Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> that display each time Give is activated or updated.', 'give' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( admin_url( 'index.php?page=give-about' ) ) ),
82
							'id'      => 'welcome',
83
							'type'    => 'radio_inline',
84
							'default' => 'enabled',
85
							'options' => array(
86
								'enabled' => __( 'Enabled', 'give' ),
87
								'disabled' => __( 'Disabled', 'give' ),
88
							)
89
						),
90
                        array(
91
                            'name'  => esc_html__( 'Display Settings Docs Link', 'give' ),
92
                            'id'    => 'display_settings_docs_link',
93
                            'url'   => esc_url( 'http://docs.givewp.com/displayoptions' ),
94
                            'title' => __( 'Display Options Settings', 'give' ),
95
                            'type'  => 'give_docs_link',
96
                        ),
97
						array(
98
							'id'   => 'give_title_display_settings_1',
99
							'type' => 'sectionend'
100
						)
101
					);
102
					break;
103
104
				case 'post-types' :
105
					$settings = array(
106
						array(
107
							'id'   => 'give_title_display_settings_2',
108
							'type' => 'title'
109
						),
110
						array(
111
							'name'    => esc_html__( 'Form Single Views', 'give' ),
112
							'desc'    => esc_html__( 'By default, all donation form have single views enabled which creates a specific URL on your website for that form. This option disables the singular posts from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give' ),
113
							'id'      => 'forms_singular',
114
							'type'    => 'radio_inline',
115
							'default' => 'enabled',
116
							'options' => array(
117
								'enabled' => __( 'Enabled', 'give' ),
118
								'disabled' => __( 'Disabled', 'give' ),
119
							)
120
						),
121
						array(
122
							'name'    => esc_html__( 'Form Archives', 'give' ),
123
							'desc'    => esc_html__( 'Archives pages list all the donation forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give' ),
124
							'id'      => 'forms_archives',
125
							'type'    => 'radio_inline',
126
							'default' => 'enabled',
127
							'options' => array(
128
								'enabled' => __( 'Enabled', 'give' ),
129
								'disabled' => __( 'Disabled', 'give' ),
130
							)
131
						),
132
						array(
133
							'name'    => esc_html__( 'Form Excerpts', 'give' ),
134
							'desc'    => esc_html__( 'The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give' ),
135
							'id'      => 'forms_excerpt',
136
							'type'    => 'radio_inline',
137
							'default' => 'enabled',
138
							'options' => array(
139
								'enabled' => __( 'Enabled', 'give' ),
140
								'disabled' => __( 'Disabled', 'give' ),
141
							)
142
						),
143
						array(
144
							'name'    => esc_html__( 'Form Featured Image', 'give' ),
145
							'desc'    => esc_html__( 'If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give' ),
146
							'id'      => 'form_featured_img',
147
							'type'    => 'radio_inline',
148
							'default' => 'enabled',
149
							'options' => array(
150
								'enabled' => __( 'Enabled', 'give' ),
151
								'disabled' => __( 'Disabled', 'give' ),
152
							)
153
						),
154
						array(
155
							'name'    => esc_html__( 'Featured Image Size', 'give' ),
156
							'desc'    => esc_html__( 'The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation form\'s featured image.', 'give' ),
157
							'id'      => 'featured_image_size',
158
							'type'    => 'select',
159
							'default' => 'large',
160
							'options' => give_get_featured_image_sizes()
161
						),
162
						array(
163
							'name'    => esc_html__( 'Single Form Sidebar', 'give' ),
164
							'desc'    => esc_html__( 'The sidebar allows you to add additional widgets to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give' ),
165
							'id'      => 'form_sidebar',
166
							'type'    => 'radio_inline',
167
							'default' => 'enabled',
168
							'options' => array(
169
								'enabled' => __( 'Enabled', 'give' ),
170
								'disabled' => __( 'Disabled', 'give' ),
171
							)
172
						),
173
                        array(
174
                            'name'  => esc_html__( 'Post Types Docs Link', 'give' ),
175
                            'id'    => 'post_types_settings_docs_link',
176
                            'url'   => esc_url( 'http://docs.givewp.com/posttypessettings' ),
177
                            'title' => __( 'Post Types Settings', 'give' ),
178
                            'type'  => 'give_docs_link',
179
                        ),
180
						array(
181
							'id'   => 'give_title_display_settings_2',
182
							'type' => 'sectionend'
183
						)
184
					);
185
					break;
186
187
				case 'taxonomies':
188
					$settings = array(
189
						array(
190
							'id'   => 'give_title_display_settings_3',
191
							'type' => 'title'
192
						),
193
						array(
194
							'name' => esc_html__( 'Form Categories', 'give' ),
195
							'desc' => esc_html__( 'Enable the "Category" taxonomy for all Give forms.', 'give' ),
196
							'id'   => 'categories',
197
							'type'    => 'radio_inline',
198
							'default' => 'disabled',
199
							'options' => array(
200
								'enabled' => __( 'Enabled', 'give' ),
201
								'disabled' => __( 'Disabled', 'give' ),
202
							)
203
						),
204
						array(
205
							'name' => esc_html__( 'Form Tags', 'give' ),
206
							'desc' => esc_html__( 'Enable the "Tag" taxonomy for all Give forms.', 'give' ),
207
							'id'   => 'tags',
208
							'type'    => 'radio_inline',
209
							'default' => 'disabled',
210
							'options' => array(
211
								'enabled' => __( 'Enabled', 'give' ),
212
								'disabled' => __( 'Disabled', 'give' ),
213
							)
214
						),
215
                        array(
216
                            'name'  => esc_html__( 'Taxonomies Docs Link', 'give' ),
217
                            'id'    => 'taxonomies_settings_docs_link',
218
                            'url'   => esc_url( 'http://docs.givewp.com/taxonomiessettings' ),
219
                            'title' => __( 'Taxonomies Settings', 'give' ),
220
                            'type'  => 'give_docs_link',
221
                        ),
222
						array(
223
							'id'   => 'give_title_display_settings_3',
224
							'type' => 'sectionend'
225
						)
226
					);
227
					break;
228
229
				case 'term-and-conditions':
230
					$settings = array(
231
						array(
232
							'id'   => 'give_title_display_settings_4',
233
							'type' => 'title'
234
						),
235
						array(
236
							'name'    => esc_html__( 'Terms and Conditions', 'give' ),
237
							'desc'    => esc_html__( 'Would you like donors to have to agree to your terms when making a donation? Note: You can toggle this option and customize the terms per form.', 'give' ),
238
							'id'      => 'terms',
239
							'type'    => 'radio_inline',
240
							'default' => 'disabled',
241
							'options' => array(
242
								'enabled' => __( 'Enabled', 'give' ),
243
								'disabled' => __( 'Disabled', 'give' ),
244
							)
245
						),
246
						array(
247
							'name' => esc_html__( 'Agree to Terms Label', 'give' ),
248
							'desc' => esc_html__( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder. Note: You can customize the label per form as needed.', 'give' ),
249
							'id'   => 'agree_to_terms_label',
250
							'attributes'  => array(
251
								'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ),
252
							),
253
							'type' => 'text'
254
						),
255
						array(
256
							'name' => esc_html__( 'Agreement Text', 'give' ),
257
							'desc' => esc_html__( 'This is the actual text which the user will have to agree to in order to make a donation. Note: You can customize the content per form as needed.', 'give' ),
258
							'id'   => 'agreement_text',
259
							'type' => 'wysiwyg'
260
						),
261
                        array(
262
                            'name'  => esc_html__( 'Terms and Conditions Docs Link', 'give' ),
263
                            'id'    => 'terms_settings_docs_link',
264
                            'url'   => esc_url( 'http://docs.givewp.com/termssettings' ),
265
                            'title' => __( 'Terms and Conditions Settings', 'give' ),
266
                            'type'  => 'give_docs_link',
267
                        ),
268
						array(
269
							'id'   => 'give_title_display_settings_4',
270
							'type' => 'sectionend'
271
						)
272
					);
273
					break;
274
			}
275
276
			/**
277
			 * Filter the display options settings.
278
			 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
279
			 */
280
			$settings = apply_filters( 'give_settings_display', $settings );
281
282
			/**
283
			 * Filter the settings.
284
			 *
285
			 * @since  1.8
286
			 * @param  array $settings
287
			 */
288
			$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
289
290
			// Output.
291
			return $settings;
292
		}
293
294
		/**
295
		 * Get sections.
296
		 *
297
		 * @since 1.8
298
		 * @return array
299
		 */
300
		public function get_sections() {
301
			$sections = array(
302
				'display-settings'    => esc_html__( 'Display', 'give' ),
303
				'post-types'          => esc_html__( 'Post Types', 'give' ),
304
				'taxonomies'          => esc_html__( 'Taxonomies', 'give' ),
305
				'term-and-conditions' => esc_html__( 'Terms and Conditions', 'give' )
306
			);
307
308
			return apply_filters( 'give_get_sections_' . $this->id, $sections );
309
		}
310
	}
311
312
endif;
313
314
return new Give_Settings_Display();
315