Completed
Push — develop ( ce7f6f...f5b0bc )
by Zack
07:24
created

View_Settings   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 555
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 98.42%

Importance

Changes 0
Metric Value
dl 0
loc 555
ccs 249
cts 253
cp 0.9842
rs 10
c 0
b 0
f 0
wmc 15
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A with_defaults() 0 5 1
C defaults() 0 503 13
A as_atts() 0 7 1
1
<?php
2
namespace GV;
3
4
/** If this file is called directly, abort. */
5
if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
6
	die();
7
}
8
9
/**
10
 * The View Settings class.
11
 */
12
class View_Settings extends Settings {
13
	/**
14
	 * Retrieve an instance of the settings with default values.
15
	 * @param bool $detailed Whether to return detailed setting meta information or just the value.
16
	 *
17
	 * @api
18
	 * @since 2.0
19
	 *
20
	 * @return \GV\View_Settings
21
	 */
22
	public static function with_defaults( $detailed = false ) {
23
		$settings = new self();
24
		$settings->update( self::defaults( $detailed ) );
25
		return $settings;
26
	}
27
28
	/**
29
	 * Retrieve the default View settings.
30
	 *
31
	 * @param bool $detailed Whether to return detailed setting meta information or just the value.
32
	 * @param string $group Retrieve settings of a particular group.
33
	 *
34
	 * @api
35
	 * @since 2.0
36
	 *
37
	 * @return array The default settings along with their values.
38
	 *      @param[out] string $label Setting label shown in admin
39
	 *      @param[out] string $type Gravity Forms field type
40
	 *      @param[out] string $group The field group the setting is associated with. Default: "default"
41
	 *      @param[out] mixed  $value The default value for the setting
42
	 *      @param[out] string $tooltip Tooltip displayed for the setting
43
	 *      @param[out] boolean $show_in_shortcode Whether to show the setting in the shortcode configuration modal
44
	 *      @param[out] array  $options Array of values to use when generating select, multiselect, radio, or checkboxes fields
45
	 *      @param[out] boolean $full_width True: Display the input and label together when rendering. False: Display label and input in separate columns when rendering.
46
	 */
47 187
	public static function defaults( $detailed = false, $group = null ) {
48
49 187
		$default_settings = array_merge( array(
50 187
			'id' => array(
51 187
				'label'             => __( 'View ID', 'gravityview' ),
52 187
				'type'              => 'number',
53 187
				'group'             => 'default',
54
				'value'             => NULL,
55
				'tooltip'           => NULL,
56
				'show_in_shortcode' => false,
57
			),
58
			'page_size' => array(
59 187
				'label'             => __( 'Number of entries per page', 'gravityview' ),
60 187
				'type'              => 'number',
61 187
				'class'             => 'small-text',
62 187
				'group'             => 'default',
63 187
				'value'             => 25,
64
				'show_in_shortcode' => true,
65
			),
66
			'offset' => array(
67 187
				'label'             => __( 'Offset entries starting from', 'gravityview' ),
68 187
				'type'              => 'number',
69 187
				'class'             => 'small-text',
70 187
				'group'             => 'default',
71 187
				'value'             => 0,
72
				'show_in_shortcode' => true,
73
			),
74
			'lightbox' => array(
75 187
				'label'             => __( 'Enable lightbox for images', 'gravityview' ),
76 187
				'type'              => 'checkbox',
77 187
				'group'             => 'default',
78 187
				'value'             => 1,
79 187
				'tooltip'           => __( 'If enabled, images will open full-size in a "lightbox". A lightbox displays images and videos by filling the screen and dimming out the rest of the web page.', 'gravityview' ),
80
				'show_in_shortcode' => true,
81
				'article'           => array(
82
					'id' => '5e9a1f8904286364bc98931f',
83
					'url' => 'https://docs.gravityview.co/article/705-view-settings-enable-lightbox-for-images',
84
				),
85
			),
86
			'show_only_approved'    => array(
87 187
				'label'             => __( 'Show only approved entries', 'gravityview' ),
88 187
				'type'              => 'checkbox',
89 187
				'group'             => 'default',
90 187
				'desc'              => __( 'By default, only approved entries are displayed in a View. When enabled, this setting prevents unapproved or disapproved entries from appearing in results. If disabled, entries with all approval statuses will be visible, including disapproved entries.', 'gravityview' ),
91
				'tooltip'           => false,
92 187
				'value'             => 1,
93
				'show_in_shortcode' => true,
94
				'article'           => array(
95
					'id' => '5bad1a33042863158cc6d396',
96
					'url' => 'https://docs.gravityview.co/article/490-entry-approval-gravity-forms',
97
				),
98
			),
99
			'no_results_text'       => array(
100 187
				'label'             => __( '"No Results" Text', 'gravityview' ),
101 187
				'type'              => 'text',
102 187
				'group'             => 'default',
103 187
				'desc'              => '',
104
				'tooltip'           => false,
105 187
				'value'             => '',
106 187
				'placeholder'       => __( 'No entries match your request.', 'gravityview' ),
107
				'show_in_shortcode' => true,
108 187
				'class'             => 'widefat',
109
				'full_width'        => true,
110
			),
111
			'no_search_results_text' => array(
112 187
				'label'             => __( '"No Search Results" Text', 'gravityview' ),
113 187
				'type'              => 'text',
114 187
				'group'             => 'default',
115 187
				'desc'              => '',
116
				'tooltip'           => false,
117 187
				'value'             => '',
118 187
				'placeholder'       => __( 'This search returned no results.', 'gravityview' ),
119
				'show_in_shortcode' => true,
120 187
				'class'             => 'widefat',
121
				'full_width'        => true,
122
			),
123
			'admin_show_all_statuses' => array(
124 187
				'label'             => __( 'Show all entries to administrators', 'gravityview' ),
125 187
				'desc'              => __( 'Administrators will be able to see entries with any approval status.', 'gravityview' ),
126 187
				'tooltip'           => __( 'Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview' ),
127 187
				'requires'          => 'show_only_approved',
128 187
				'type'              => 'checkbox',
129 187
				'group'             => 'default',
130 187
				'value'             => 0,
131
				'show_in_shortcode' => false,
132
			),
133
			'hide_until_searched' => array(
134 187
				'label'             => __( 'Hide View data until search is performed', 'gravityview' ),
135 187
				'type'              => 'checkbox',
136 187
				'group'             => 'default',
137 187
				'tooltip'           => __( 'When enabled it will only show any View entries after a search is performed.', 'gravityview' ),
138 187
				'value'             => 0,
139
				'show_in_shortcode' => false,
140
				'article'           => array(
141
					'id' => '5c772fa02c7d3a0cb9320a84',
142
					'url' => 'https://docs.gravityview.co/article/536-how-to-hide-results-and-only-display-them-if-a-search-is-performed',
143
				),
144
			),
145
			'hide_empty' => array(
146 187
				'label'             => __( 'Hide empty fields', 'gravityview' ),
147 187
				'group'             => 'default',
148 187
				'type'              => 'checkbox',
149 187
				'desc'              => __( 'When enabled, empty fields will be not be displayed. If disabled, fields and their labels will be displayed with no content.', 'gravityview' ),
150 187
				'value'             => 1,
151
				'tooltip'           => false,
152
				'show_in_shortcode' => false,
153
			),
154
			'hide_empty_single' => array(
155 187
				'label'             => __( 'Hide empty fields', 'gravityview' ),
156 187
				'group'             => 'default',
157 187
				'type'              => 'checkbox',
158 187
				'desc'              => __( 'When enabled, empty fields will be not be displayed. If disabled, fields and their labels will be displayed with no content.', 'gravityview' ),
159 187
				'value'             => 1,
160
				'tooltip'           => false,
161
				'show_in_shortcode' => false,
162
			),
163
			'edit_feeds' => array(
164 187
				'label'             => __( 'Feeds', 'gravityview' ),
165 187
				'group'             => 'default',
166 187
				'type'              => 'checkbox',
167
				'value'             => array(),
168
				'show_in_shortcode' => false,
169
			),
170
			'user_edit' => array(
171 187
				'label'             => __( 'Allow User Edit', 'gravityview' ), 'group'             => 'default',
172 187
				'desc'              => __( 'Allow logged-in users to edit entries they created.', 'gravityview' ) . ' ' . sprintf( __( 'Administrators are able to %s regardless of this setting.', 'gravityview' ), _x( 'edit entries', 'an action that admins can perform', 'gravityview' ) ),
173 187
				'value'             => 0,
174 187
				'tooltip'           => __( 'Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview' ),
175 187
				'type'              => 'checkbox',
176
				'show_in_shortcode' => true,
177
				'article'           => array(
178
					'id' => '54c67bbbe4b07997ea3f3f6b',
179
					'url' => 'https://docs.gravityview.co/article/77-user-edit-allow-users-to-edit-their-own-entries',
180
				),
181
			),
182
			'unapprove_edit' => array(
183 187
				'label'             => __( 'Unapprove Entries After Edit', 'gravityview' ),
184 187
				'group'             => 'default',
185 187
				'requires'          => 'user_edit',
186 187
				'desc'              => __( 'When an entry is edited by a non-administrator, reset the approval status to "Unapproved".', 'gravityview' ),
187 187
				'tooltip'           => __( 'If the "Show only approved entries" setting is enabled, the entry will need to be re-approved by an administrator before it is shown in the View.', 'gravityview' ),
188 187
				'value'             => 0,
189 187
				'type'              => 'checkbox',
190
				'show_in_shortcode' => true,
191
				'article'           => array(
192
					'id' => '5ddd81d504286364bc923957',
193
					'url' => 'https://docs.gravityview.co/article/657-unapproving-edited-entries-automatically',
194
				),
195
			),
196
			'user_delete' => array(
197 187
				'label'             => __( 'Allow User Delete', 'gravityview' ),
198 187
				'group'             => 'default',
199 187
				'desc'              => __( 'Allow logged-in users to delete entries they created.', 'gravityview' ) . ' ' . sprintf( __( 'Administrators are able to %s regardless of this setting.', 'gravityview' ), _x( 'delete entries', 'an action that admins can perform', 'gravityview' ) ),
200 187
				'value'             => 0,
201 187
				'tooltip'           => __( 'Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview' ),
202 187
				'type'              => 'checkbox',
203
				'show_in_shortcode' => true,
204
				'article'           => array(
205
					'id' => '54c67bb9e4b0512429885512',
206
					'url' => 'https://docs.gravityview.co/article/66-configuring-delete-entry',
207
				),
208
			),
209
			'user_duplicate' => array(
210 187
				'label'             => __( 'Allow User Duplicate', 'gravityview' ),
211 187
				'group'             => 'default',
212 187
				'desc'              => __( 'Allow logged-in users to duplicate entries they created.', 'gravityview' ) . ' ' . sprintf( __( 'Administrators are able to %s regardless of this setting.', 'gravityview' ), _x( 'duplicate entries', 'an action that admins can perform', 'gravityview' ) ),
213 187
				'value'             => 0,
214 187
				'tooltip'           => __( 'Display "Duplicate Entry" fields to non-administrator users if they created the entry. Duplicate Entry fields will always be displayed to site administrators.', 'gravityview' ),
215
				'article'           => array(
216
					'id' => '5df11eb704286364bc92bf36',
217
					'url' => 'https://docs.gravityview.co/article/66-configuring-delete-entry',
218
					'type' => 'inline',
219
				),
220 187
				'type'              => 'checkbox',
221
				'show_in_shortcode' => true,
222
			),
223
			'sort_field' => array(
224 187
				'label'             => __( 'Sort by field', 'gravityview' ),
225 187
				'type'              => 'select',
226 187
				'desc'              => __( 'By default, entries are sorted by Entry ID.', 'gravityview' ),
227 187
				'value'             => '',
228 187
				'group'             => 'sort',
229
				'options'           => array(
230 187
					''             => __( 'Default', 'gravityview' ),
231 187
					'date_created' => __( 'Date Created', 'gravityview' ),
232
				),
233
				'show_in_shortcode' => true,
234
				'article'           => array(
235
					'id' => '54c67bbbe4b051242988551a',
236
					'url' => 'https://docs.gravityview.co/article/74-sorting-results-by-field-value',
237
				),
238
			),
239
			'sort_direction' => array(
240 187
				'label'             => __( 'Sort direction', 'gravityview' ),
241 187
				'type'              => 'select',
242 187
				'value'             => 'ASC',
243 187
				'group'             => 'sort',
244
				'options'           => array(
245 187
										'ASC'  => __( 'ASC', 'gravityview' ),
246 187
										'DESC' => __( 'DESC', 'gravityview' ),
247
				),
248
				'show_in_shortcode' => true,
249
				'article'           => array(
250
					'id' => '5c9d338a2c7d3a1544617f9b',
251
					'url' => 'https://docs.gravityview.co/article/570-sorting-by-multiple-columns',
252
				),
253
			),
254
			'sort_field_2' => array(
255 187
				'label'             => __( 'Sort by secondary field', 'gravityview' ),
256 187
				'type'              => 'select',
257 187
				'value'             => '',
258 187
				'group'             => 'sort',
259
				'options'           => array(
260 187
					''             => __( 'Default', 'gravityview' ),
261 187
					'date_created' => __( 'Date Created', 'gravityview' ),
262
				),
263 187
				'requires_not'          => 'sort_direction][=RAND', // ][ is for toggleRequired, so it ends in []
264
				'show_in_shortcode' => true,
265
				'article'           => array(
266
					'id' => '5c9d338a2c7d3a1544617f9b',
267
					'url' => 'https://docs.gravityview.co/article/570-sorting-by-multiple-columns',
268
				),
269
			),
270
			'sort_direction_2' => array(
271 187
				'label'             => __( 'Secondary sort direction', 'gravityview' ),
272 187
				'type'              => 'select',
273 187
				'value'             => 'ASC',
274 187
				'group'             => 'sort',
275
				'options'           => array(
276 187
					'ASC'  => __( 'ASC', 'gravityview' ),
277 187
					'DESC' => __( 'DESC', 'gravityview' ),
278
				),
279 187
				'requires_not'      => 'sort_direction][=RAND', // ][ is for toggleRequired, so it ends in []
280
				'show_in_shortcode' => true,
281
				'article'           => array(
282
					'id' => '5c9d338a2c7d3a1544617f9b',
283
					'url' => 'https://docs.gravityview.co/article/570-sorting-by-multiple-columns',
284
				),
285
			),
286
			'sort_columns' => array(
287 187
				'label'             => __( 'Enable sorting by column', 'gravityview' ),
288 187
				'left_label'        => __( 'Column Sorting', 'gravityview' ),
289 187
				'type'              => 'checkbox',
290
				'value'             => false,
291 187
				'group'             => 'sort',
292
				'tooltip'           => NULL,
293
				'show_in_shortcode' => true,
294
				'show_in_template'  => array( 'default_table', 'preset_business_data', 'preset_issue_tracker', 'preset_resume_board', 'preset_job_board' ),
295
				'article'           => array(
296
					'id' => '54ee1246e4b034c37ea91c11',
297
					'url' => 'https://docs.gravityview.co/article/230-enabling-the-table-column-sorting-feature',
298
				),
299
			),
300
			'start_date' => array(
301 187
				'label'             => __( 'Filter by Start Date', 'gravityview' ),
302 187
				'class'             => 'gv-datepicker',
303 187
				'desc'              => __( 'Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ),
304 187
				'type'              => 'text',
305 187
				'value'             => '',
306 187
				'group'             => 'filter',
307
				'show_in_shortcode' => true,
308
				'article'           => array(
309
					'id' => '54c67bbbe4b0512429885520',
310
					'url' => 'https://docs.gravityview.co/article/79-using-relative-start-dates-and-end-dates',
311
				),
312
			),
313
			'end_date' => array(
314 187
				'label'             => __( 'Filter by End Date', 'gravityview' ),
315 187
				'class'             => 'gv-datepicker',
316 187
				'desc'              => __( 'Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ),
317 187
				'type'              => 'text',
318 187
				'value'             => '',
319 187
				'group'             => 'filter',
320
				'show_in_shortcode' => true,
321
				'article'           => array(
322
					'id' => '54c67bbbe4b0512429885520',
323
					'url' => 'https://docs.gravityview.co/article/79-using-relative-start-dates-and-end-dates',
324
				),
325
			),
326
			'class' => array(
327 187
				'label'             => __( 'CSS Class', 'gravityview' ),
328 187
				'desc'              => __( 'CSS class to add to the wrapping HTML container.', 'gravityview' ),
329 187
				'group'             => 'default',
330 187
				'type'              => 'text',
331 187
				'value'             => '',
332
				'show_in_shortcode' => false,
333
			),
334
			'search_value' => array(
335 187
				'label'             => __( 'Search Value', 'gravityview' ),
336 187
				'desc'              => __( 'Define a default search value for the View', 'gravityview' ),
337 187
				'type'              => 'text',
338 187
				'value'             => '',
339 187
				'group'             => 'filter',
340
				'show_in_shortcode' => false,
341
			),
342
			'search_field' => array(
343 187
				'label'             => __( 'Search Field', 'gravityview' ),
344 187
				'desc'              => __( 'If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview' ),
345 187
				'type'              => 'text',
346 187
				'value'             => '',
347 187
				'group'             => 'filter',
348
				'show_in_shortcode' => false,
349
			),
350
			'search_operator' => array(
351 187
				'label'             => __( 'Search Operator', 'gravityview' ),
352 187
				'type'              => 'operator',
353 187
				'value'             => 'contains',
354 187
				'group'             => 'filter',
355
				'show_in_shortcode' => false,
356
			),
357
			'single_title' => array(
358 187
				'label'             => __( 'Single Entry Title', 'gravityview' ),
359 187
				'type'              => 'text',
360 187
				'desc'              => __( 'When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview' ),
361 187
				'group'             => 'default',
362 187
				'value'             => '',
363
				'show_in_shortcode' => false,
364
				'full_width'        => true,
365
				'article'           => array(
366
					'id' => '54c67bcee4b07997ea3f3f9a',
367
					'url' => 'https://docs.gravityview.co/article/121-changing-the-single-entry-page-title',
368
				),
369
			),
370
			'back_link_label' => array(
371 187
				'label'             => __( 'Back Link Label', 'gravityview' ),
372 187
				'group'             => 'default',
373 187
				'desc'              => __( 'The text of the link that returns to the multiple entries view.', 'gravityview' ),
374 187
				'type'              => 'text',
375 187
				'value'             => '',
376 187
				'placeholder'       => __( '&larr; Go back', 'gravityview' ),
377 187
				'class'             => 'widefat',
378 187
				'merge_tags'        => 'force',
379
				'show_in_shortcode' => false,
380
				'full_width'        => true,
381
			),
382
			'edit_redirect' => array(
383 187
				'label'             => __( 'Redirect After Editing', 'gravityview' ),
384 187
				'group'             => 'default',
385 187
				'desc'              => __( 'The page to redirect to after editing an entry.', 'gravityview' ),
386 187
				'type'              => 'select',
387 187
				'value'             => '',
388
				'options'           => array(
389 187
					'' => __( 'Stay on Edit Entry', 'gravityview' ),
390 187
					'0'  => __( 'Redirect to Single Entry', 'gravityview' ),
391 187
					'1' => __( 'Redirect to Multiple Entries', 'gravityview' ),
392 187
					'2' => __( 'Redirect to URL', 'gravityview' ),
393
				)
394
			),
395
			'edit_return_context' => array(
396 187
				'label'             => __( 'Editing Returns To&hellip;', 'gravityview' ),
397 187
				'type'              => 'radio',
398 187
				'desc'              => __( 'After editing an entry or clicking Cancel, where should the user be sent?', 'gravityview' ),
399 187
				'group'             => 'default',
400 187
				'value'             => 'single',
401
				'options'           => array(
402 187
					'multiple' => __( 'Multiple Entries', 'gravityview' ),
403 187
					'single'   => __( 'Single Entry', 'gravityview' ),
404 187
					'custom'   => __( 'Other URL', 'gravityview' ),
405
				),
406
				'show_in_shortcode' => false,
407
				'full_width'        => true,
408
				'article'           => array(
409
					'id' => '5e9a3e0c2c7d3a7e9aeb2efb',
410
					'url' => 'https://docs.gravityview.co/article/707-view-settings-redirect-after-editing',
411
				),
412
			),
413
			'edit_redirect_url' => array(
414 187
				'label'             => __( 'Edit Entry Redirect URL', 'gravityview' ),
415 187
				'group'             => 'default',
416 187
				'desc'              => __( 'After editing an entry, the user will be taken to this URL.', 'gravityview' ),
417 187
				'type'              => 'text',
418 187
				'class'             => 'code widefat',
419 187
				'value'             => '',
420 187
				'requires'          => 'edit_redirect=2',
421 187
				'merge_tags'        => 'force',
422
			),
423
			'edit_locking' => array(
424 187
				'label'             => __( 'Enable Edit Locking', 'gravityview' ),
425 187
				'group'             => 'default',
426 187
				'desc'              => __( 'Prevent multiple users from editing the same entry at the same time.', 'gravityview' ),
427 187
				'type'              => 'checkbox',
428
				'full_width'        => true,
429 187
				'class'             => 'code widefat',
430
				'value'             => true,
431
				'article'           => array(
432
					'id' => '5e4449d72c7d3a7e9ae7a54c',
433
					'url' => 'https://docs.gravityview.co/article/676-entry-locking',
434
				),
435
			),
436
			'embed_only' => array(
437 187
				'label'             => __( 'Prevent Direct Access', 'gravityview' ),
438 187
				'group'             => 'default',
439 187
				'desc'              => __( 'Only allow access to this View when embedded using the shortcode.', 'gravityview' ),
440 187
				'type'              => 'checkbox',
441 187
				'value'             => '',
442
				'tooltip'           => false,
443
				'show_in_shortcode' => false,
444
				'full_width'        => true,
445
			),
446 187
		), ( gravityview()->plugin->supports( Plugin::FEATURE_REST ) && ( gravityview()->plugin->settings->get( 'rest_api' ) === '1' ) ) ?
447
			array(
448 187
				'rest_disable'          => array(
449 187
					'label'             => __( 'Prevent REST Access', 'gravityview' ),
450 187
					'group'             => 'default',
451 187
					'desc'              => __( 'Disable REST access to this View.', 'gravityview' ),
452 187
					'type'              => 'checkbox',
453 187
					'value'             => '',
454
					'tooltip'           => false,
455
					'show_in_shortcode' => false,
456
					'full_width'        => true,
457
				),
458 187
			) : array(),
459 187
		( gravityview()->plugin->supports( Plugin::FEATURE_REST ) && ( gravityview()->plugin->settings->get( 'rest_api' ) !== '1' ) ) ?
460
			array(
461 1
				'rest_enable'           => array(
462 1
					'label'             => __( 'Allow REST Access', 'gravityview' ),
463 1
					'group'             => 'default',
464 1
					'desc'              => __( 'Enable REST access to this View.', 'gravityview' ),
465 1
					'type'              => 'checkbox',
466 1
					'value'             => '',
467
					'tooltip'           => false,
468
					'show_in_shortcode' => false,
469
					'full_width'        => true,
470
				),
471 187
			) : array(),
472
		array(
473 187
			'csv_enable'            => array(
474 187
				'label'             => __( 'Allow CSV Access', 'gravityview' ),
475 187
				'group'             => 'default',
476 187
				'desc'              => __( 'Enable CSV access to this View.', 'gravityview' ),
477 187
				'type'              => 'checkbox',
478 187
				'value'             => '',
479 187
				'tooltip'           => __( 'If enabled, entries can be exported for this View by adding "/csv/" to the View URL. Each configured field will be a column in the exported CSV.', 'gravityview' ),
480
				'show_in_shortcode' => false,
481
				'full_width'        => true,
482
				'article'          => array(
483
					'id' => '5bad2a0c042863158cc6d4ac',
484
					'url' => 'https://docs.gravityview.co/article/491-csv-export',
485
				),
486
			),
487
		),
488
		array(
489 187
			'csv_nolimit'           => array(
490 187
				'label'             => __( 'Show all in CSV', 'gravityview' ),
491 187
				'group'             => 'default',
492 187
				'requires'          => 'csv_enable',
493 187
				'desc'              => __( 'Do not limit the number of entries output in the CSV.', 'gravityview' ),
494 187
				'type'              => 'checkbox',
495 187
				'value'             => '',
496
				'tooltip'           => false,
497
				'show_in_shortcode' => false,
498
				'full_width'        => true,
499
			),
500
		),
501
		array(
502 187
			'post_id' => array(
503
				'type'              => 'number',
504
				'value'             => '',
505
				'show_in_shortcode' => false,
506
			),
507
		) );
508
509 187
		if ( version_compare( \GFCommon::$version, '2.3-beta-4', '>=' ) ) {
510 187
			$default_settings['sort_direction']['options']['RAND'] = __( 'Random', 'gravityview' );
511
		}
512
513
		/**
514
		 * @filter `gravityview_default_args` Modify the default settings for new Views
515
		 * @param[in,out] array $default_args Array of default args.
516
		 * @deprecated
517
		 * @see filter `gravityview/view/settings/defaults`
518
		 */
519 187
		$default_settings = apply_filters( 'gravityview_default_args', $default_settings );
520
521
		/**
522
		 * @filter `gravityview/view/defaults` Modify the default settings for new Views
523
		 * @param[in,out] array $default_settings Array of default settings.
524
		 */
525 187
		$default_settings = apply_filters( 'gravityview/view/settings/defaults', $default_settings );
526
527
		// By default, we only want the key => value pairing, not the whole array.
528 187
		if ( ! $detailed ) {
529 187
			$defaults = array();
530 187
			foreach( $default_settings as $key => $value ) {
531 187
				$defaults[ $key ] = $value['value'];
532
			}
533 187
			return $defaults;
534
535
		// But sometimes, we want all the details.
536
		} else {
537 11
			foreach ( $default_settings as $key => $value ) {
538
539
				// If the $group argument is set for the method,
540
				// ignore any settings that aren't in that group.
541 11
				if ( ! empty( $group ) && is_string( $group ) ) {
542 1
					if ( empty( $value['group'] ) || $value['group'] !== $group ) {
543 1
						unset( $default_settings[ $key ] );
544
					}
545
				}
546
			}
547 11
			return $default_settings;
548
		}
549
	}
550
551
	/**
552
	 * Turn to an $atts array as used around the old codebase.
553
	 *
554
	 * @internal
555
	 * @deprecated
556
	 *
557
	 * @return array
558
	 */
559 108
	public function as_atts() {
560 108
		$defaults = array_keys( self::defaults() );
561 108
		$_this = &$this;
562
		return array_combine( $defaults, array_map( function( $key ) use ( $_this ) {
563 108
			return $_this->get( $key );
564 108
		}, $defaults ) );
565
	}
566
}
567