Completed
Push — issues-2258 ( a23f05 )
by Ravinder
956:03 queued 950:20
created

Give_Settings_Display::give_reset_rewrite_rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
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 = __( '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'    => __( 'Default Give Styles', 'give' ),
57
							'desc'    => __( 'You can disable Give\'s 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'    => __( 'Floating Labels', 'give' ),
68
							/* translators: %s: http://docs.givewp.com/form-floating-labels */
69
							'desc'    => sprintf( wp_kses( __( '<a href="%s" target="_blank">Floating labels</a> allows your labels to be inset within the form fields to provide a cleaner form appearance. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give' ), array(
70
								'a' => array(
71
									'href'   => array(),
72
									'target' => array(),
73
								),
74
							) ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ),
75
							'id'      => 'floatlabels',
76
							'type'    => 'radio_inline',
77
							'default' => 'disabled',
78
							'options' => array(
79
								'enabled'  => __( 'Enabled', 'give' ),
80
								'disabled' => __( 'Disabled', 'give' ),
81
							),
82
						),
83
						array(
84
							'name'    => __( 'Welcome Screen', 'give' ),
85
							/* translators: %s: about page URL */
86
							'desc'    => sprintf( wp_kses( __( 'Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> that displays each time Give is activated or updated.', 'give' ), array(
87
								'a' => array(
88
									'href'   => array(),
89
									'target' => array(),
90
								),
91
							) ), esc_url( admin_url( 'index.php?page=give-about' ) ) ),
92
							'id'      => 'welcome',
93
							'type'    => 'radio_inline',
94
							'default' => 'enabled',
95
							'options' => array(
96
								'enabled'  => __( 'Enabled', 'give' ),
97
								'disabled' => __( 'Disabled', 'give' ),
98
							),
99
						),
100
						array(
101
							'name'  => __( 'Display Settings Docs Link', 'give' ),
102
							'id'    => 'display_settings_docs_link',
103
							'url'   => esc_url( 'http://docs.givewp.com/form-display-options' ),
104
							'title' => __( 'Display Options Settings', 'give' ),
105
							'type'  => 'give_docs_link',
106
						),
107
						array(
108
							'id'   => 'give_title_display_settings_1',
109
							'type' => 'sectionend',
110
						),
111
					);
112
					break;
113
114
				case 'post-types' :
115
					$settings = array(
116
						array(
117
							'id'   => 'give_title_display_settings_2',
118
							'type' => 'title',
119
						),
120
						array(
121
							'name'    => __( 'Form Single Views', 'give' ),
122
							'desc'    => __( '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' ),
123
							'id'      => 'forms_singular',
124
							'type'    => 'radio_inline',
125
							'default' => 'enabled',
126
							'options' => array(
127
								'enabled'  => __( 'Enabled', 'give' ),
128
								'disabled' => __( 'Disabled', 'give' ),
129
							),
130
						),
131
						array(
132
							'name'    => __( 'Form Archives', 'give' ),
133
							'desc'    => sprintf( wp_kses( __( '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 <a href="%s">refresh your permalinks</a> after this option has been enabled.', 'give' ), array(
134
								'a' => array(
135
									'href'   => array(),
136
									'target' => array(),
137
								),
138
							) ), esc_url( admin_url( 'options-permalink.php' ) ) ),
139
							'id'      => 'forms_archives',
140
							'type'    => 'radio_inline',
141
							'default' => 'enabled',
142
							'options' => array(
143
								'enabled'  => __( 'Enabled', 'give' ),
144
								'disabled' => __( 'Disabled', 'give' ),
145
							),
146
						),
147
						array(
148
							'name'    => __( 'Form Excerpts', 'give' ),
149
							'desc'    => __( 'The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give' ),
150
							'id'      => 'forms_excerpt',
151
							'type'    => 'radio_inline',
152
							'default' => 'enabled',
153
							'options' => array(
154
								'enabled'  => __( 'Enabled', 'give' ),
155
								'disabled' => __( 'Disabled', 'give' ),
156
							),
157
						),
158
						array(
159
							'name'    => __( 'Form Featured Image', 'give' ),
160
							'desc'    => __( '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' ),
161
							'id'      => 'form_featured_img',
162
							'type'    => 'radio_inline',
163
							'default' => 'enabled',
164
							'options' => array(
165
								'enabled'  => __( 'Enabled', 'give' ),
166
								'disabled' => __( 'Disabled', 'give' ),
167
							),
168
						),
169
						array(
170
							'name'    => __( 'Featured Image Size', 'give' ),
171
							'desc'    => __( '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' ),
172
							'id'      => 'featured_image_size',
173
							'type'    => 'select',
174
							'default' => 'large',
175
							'options' => give_get_featured_image_sizes(),
176
						),
177
						array(
178
							'name'    => __( 'Single Form Sidebar', 'give' ),
179
							'desc'    => __( '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' ),
180
							'id'      => 'form_sidebar',
181
							'type'    => 'radio_inline',
182
							'default' => 'enabled',
183
							'options' => array(
184
								'enabled'  => __( 'Enabled', 'give' ),
185
								'disabled' => __( 'Disabled', 'give' ),
186
							),
187
						),
188
						array(
189
							'name'  => __( 'Post Types Docs Link', 'give' ),
190
							'id'    => 'post_types_settings_docs_link',
191
							'url'   => esc_url( 'http://docs.givewp.com/settings-post-types' ),
192
							'title' => __( 'Post Types Settings', 'give' ),
193
							'type'  => 'give_docs_link',
194
						),
195
						array(
196
							'id'   => 'give_title_display_settings_2',
197
							'type' => 'sectionend',
198
						),
199
					);
200
					break;
201
202 View Code Duplication
				case 'taxonomies':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
203
					$settings = array(
204
						array(
205
							'id'   => 'give_title_display_settings_3',
206
							'type' => 'title',
207
						),
208
						array(
209
							'name'    => __( 'Form Categories', 'give' ),
210
							'desc'    => __( 'Enable Categories for all Give forms.', 'give' ),
211
							'id'      => 'categories',
212
							'type'    => 'radio_inline',
213
							'default' => 'disabled',
214
							'options' => array(
215
								'enabled'  => __( 'Enabled', 'give' ),
216
								'disabled' => __( 'Disabled', 'give' ),
217
							),
218
						),
219
						array(
220
							'name'    => __( 'Form Tags', 'give' ),
221
							'desc'    => __( 'Enable Tags for all Give forms.', 'give' ),
222
							'id'      => 'tags',
223
							'type'    => 'radio_inline',
224
							'default' => 'disabled',
225
							'options' => array(
226
								'enabled'  => __( 'Enabled', 'give' ),
227
								'disabled' => __( 'Disabled', 'give' ),
228
							),
229
						),
230
						array(
231
							'name'  => __( 'Taxonomies Docs Link', 'give' ),
232
							'id'    => 'taxonomies_settings_docs_link',
233
							'url'   => esc_url( 'http://docs.givewp.com/settings-taxonomies' ),
234
							'title' => __( 'Taxonomies Settings', 'give' ),
235
							'type'  => 'give_docs_link',
236
						),
237
						array(
238
							'id'   => 'give_title_display_settings_3',
239
							'type' => 'sectionend',
240
						),
241
					);
242
					break;
243
244
				case 'term-and-conditions':
245
					$settings = array(
246
						array(
247
							'id'   => 'give_title_display_settings_4',
248
							'type' => 'title',
249
						),
250
						array(
251
							'name'    => __( 'Terms and Conditions', 'give' ),
252
							'desc'    => __( 'Would you like donors to require that donors agree to your terms when donating? Note: You can enable/disable this option and customize the terms per form as well.', 'give' ),
253
							'id'      => 'terms',
254
							'type'    => 'radio_inline',
255
							'default' => 'disabled',
256
							'options' => array(
257
								'enabled'  => __( 'Enabled', 'give' ),
258
								'disabled' => __( 'Disabled', 'give' ),
259
							),
260
						),
261
						array(
262
							'name'       => __( 'Agree to Terms Label', 'give' ),
263
							'desc'       => __( 'The label shown next to the agree to terms check box. Customize it here or leave blank to use the default placeholder text. Note: You can customize the label per form.', 'give' ),
264
							'id'         => 'agree_to_terms_label',
265
							'attributes' => array(
266
								'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ),
267
							),
268
							'type'       => 'text',
269
						),
270
						array(
271
							'name' => __( 'Agreement Text', 'give' ),
272
							'desc' => __( 'This is the actual text which the user will be asked to agree to in order to donate. Note: You can customize the content per form as needed.', 'give' ),
273
							'id'   => 'agreement_text',
274
							'type' => 'wysiwyg',
275
						),
276
						array(
277
							'name'  => __( 'Terms and Conditions Docs Link', 'give' ),
278
							'id'    => 'terms_settings_docs_link',
279
							'url'   => esc_url( 'http://docs.givewp.com/settings-terms' ),
280
							'title' => __( 'Terms and Conditions Settings', 'give' ),
281
							'type'  => 'give_docs_link',
282
						),
283
						array(
284
							'id'   => 'give_title_display_settings_4',
285
							'type' => 'sectionend',
286
						),
287
					);
288
					break;
289
			}
290
291
			/**
292
			 * Filter the display options settings.
293
			 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
294
			 */
295
			$settings = apply_filters( 'give_settings_display', $settings );
296
297
			/**
298
			 * Filter the settings.
299
			 *
300
			 * @since  1.8
301
			 *
302
			 * @param  array $settings
303
			 */
304
			$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
305
306
			// Output.
307
			return $settings;
308
		}
309
310
		/**
311
		 * Get sections.
312
		 *
313
		 * @since 1.8
314
		 * @return array
315
		 */
316
		public function get_sections() {
317
			$sections = array(
318
				'display-settings'    => __( 'Display', 'give' ),
319
				'post-types'          => __( 'Post Types', 'give' ),
320
				'taxonomies'          => __( 'Taxonomies', 'give' ),
321
				'term-and-conditions' => __( 'Terms and Conditions', 'give' ),
322
			);
323
324
			return apply_filters( 'give_get_sections_' . $this->id, $sections );
325
		}
326
	}
327
328
endif;
329
330
return new Give_Settings_Display();
331