Completed
Pull Request — develop (#1444)
by Zack
08:30
created

View_Settings::with_defaults()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
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
			'admin_show_all_statuses' => array(
100 187
				'label'             => __( 'Show all entries to administrators', 'gravityview' ),
101 187
				'desc'              => __( 'Administrators will be able to see entries with any approval status.', 'gravityview' ),
102 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' ),
103 187
				'requires'          => 'show_only_approved',
104 187
				'type'              => 'checkbox',
105 187
				'group'             => 'default',
106 187
				'value'             => 0,
107
				'show_in_shortcode' => false,
108
			),
109
			'hide_until_searched' => array(
110 187
				'label'             => __( 'Hide View data until search is performed', 'gravityview' ),
111 187
				'type'              => 'checkbox',
112 187
				'group'             => 'default',
113 187
				'tooltip'           => __( 'When enabled it will only show any View entries after a search is performed.', 'gravityview' ),
114 187
				'value'             => 0,
115
				'show_in_shortcode' => false,
116
				'article'           => array(
117
					'id' => '5c772fa02c7d3a0cb9320a84',
118
					'url' => 'https://docs.gravityview.co/article/536-how-to-hide-results-and-only-display-them-if-a-search-is-performed',
119
				),
120
			),
121
			'hide_empty' => array(
122 187
				'label'             => __( 'Hide empty fields', 'gravityview' ),
123 187
				'group'             => 'default',
124 187
				'type'              => 'checkbox',
125 187
				'desc'              => __( 'When enabled, empty fields will be not be displayed. If disabled, fields and their labels will be displayed with no content.', 'gravityview' ),
126 187
				'value'             => 1,
127
				'tooltip'           => false,
128
				'show_in_shortcode' => false,
129
			),
130
			'hide_empty_single' => array(
131 187
				'label'             => __( 'Hide empty fields', 'gravityview' ),
132 187
				'group'             => 'default',
133 187
				'type'              => 'checkbox',
134 187
				'desc'              => __( 'When enabled, empty fields will be not be displayed. If disabled, fields and their labels will be displayed with no content.', 'gravityview' ),
135 187
				'value'             => 1,
136
				'tooltip'           => false,
137
				'show_in_shortcode' => false,
138
			),
139
			'edit_feeds' => array(
140 187
				'label'             => __( 'Feeds', 'gravityview' ),
141 187
				'group'             => 'default',
142 187
				'type'              => 'checkbox',
143
				'value'             => array(),
144
				'show_in_shortcode' => false,
145
			),
146
			'user_edit' => array(
147 187
				'label'             => __( 'Allow User Edit', 'gravityview' ), 'group'             => 'default',
148 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' ) ),
149 187
				'value'             => 0,
150 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' ),
151 187
				'type'              => 'checkbox',
152
				'show_in_shortcode' => true,
153
				'article'           => array(
154
					'id' => '54c67bbbe4b07997ea3f3f6b',
155
					'url' => 'https://docs.gravityview.co/article/77-user-edit-allow-users-to-edit-their-own-entries',
156
				),
157
			),
158
			'unapprove_edit' => array(
159 187
				'label'             => __( 'Unapprove Entries After Edit', 'gravityview' ),
160 187
				'group'             => 'default',
161 187
				'requires'          => 'user_edit',
162 187
				'desc'              => __( 'When an entry is edited by a non-administrator, reset the approval status to "Unapproved".', 'gravityview' ),
163 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' ),
164 187
				'value'             => 0,
165 187
				'type'              => 'checkbox',
166
				'show_in_shortcode' => true,
167
				'article'           => array(
168
					'id' => '5ddd81d504286364bc923957',
169
					'url' => 'https://docs.gravityview.co/article/657-unapproving-edited-entries-automatically',
170
				),
171
			),
172
			'user_delete' => array(
173 187
				'label'             => __( 'Allow User Delete', 'gravityview' ),
174 187
				'group'             => 'default',
175 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' ) ),
176 187
				'value'             => 0,
177 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' ),
178 187
				'type'              => 'checkbox',
179
				'show_in_shortcode' => true,
180
				'article'           => array(
181
					'id' => '54c67bb9e4b0512429885512',
182
					'url' => 'https://docs.gravityview.co/article/66-configuring-delete-entry',
183
				),
184
			),
185
			'user_duplicate' => array(
186 187
				'label'             => __( 'Allow User Duplicate', 'gravityview' ),
187 187
				'group'             => 'default',
188 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' ) ),
189 187
				'value'             => 0,
190 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' ),
191
				'article'           => array(
192
					'id' => '5df11eb704286364bc92bf36',
193
					'url' => 'https://docs.gravityview.co/article/66-configuring-delete-entry',
194
					'type' => 'inline',
195
				),
196 187
				'type'              => 'checkbox',
197
				'show_in_shortcode' => true,
198
			),
199
			'sort_field' => array(
200 187
				'label'             => __( 'Sort by field', 'gravityview' ),
201 187
				'type'              => 'select',
202 187
				'desc'              => __( 'By default, entries are sorted by Entry ID.', 'gravityview' ),
203 187
				'value'             => '',
204 187
				'group'             => 'sort',
205
				'options'           => array(
206 187
					''             => __( 'Default', 'gravityview' ),
207 187
					'date_created' => __( 'Date Created', 'gravityview' ),
208
				),
209
				'show_in_shortcode' => true,
210
				'article'           => array(
211
					'id' => '54c67bbbe4b051242988551a',
212
					'url' => 'https://docs.gravityview.co/article/74-sorting-results-by-field-value',
213
				),
214
			),
215
			'sort_direction' => array(
216 187
				'label'             => __( 'Sort direction', 'gravityview' ),
217 187
				'type'              => 'select',
218 187
				'value'             => 'ASC',
219 187
				'group'             => 'sort',
220
				'options'           => array(
221 187
										'ASC'  => __( 'ASC', 'gravityview' ),
222 187
										'DESC' => __( 'DESC', 'gravityview' ),
223
				),
224
				'show_in_shortcode' => true,
225
				'article'           => array(
226
					'id' => '5c9d338a2c7d3a1544617f9b',
227
					'url' => 'https://docs.gravityview.co/article/570-sorting-by-multiple-columns',
228
				),
229
			),
230
			'sort_field_2' => array(
231 187
				'label'             => __( 'Sort by secondary field', 'gravityview' ),
232 187
				'type'              => 'select',
233 187
				'value'             => '',
234 187
				'group'             => 'sort',
235
				'options'           => array(
236 187
					''             => __( 'Default', 'gravityview' ),
237 187
					'date_created' => __( 'Date Created', 'gravityview' ),
238
				),
239 187
				'requires_not'          => 'sort_direction][=RAND', // ][ is for toggleRequired, so it ends in []
240
				'show_in_shortcode' => true,
241
				'article'           => array(
242
					'id' => '5c9d338a2c7d3a1544617f9b',
243
					'url' => 'https://docs.gravityview.co/article/570-sorting-by-multiple-columns',
244
				),
245
			),
246
			'sort_direction_2' => array(
247 187
				'label'             => __( 'Secondary sort direction', 'gravityview' ),
248 187
				'type'              => 'select',
249 187
				'value'             => 'ASC',
250 187
				'group'             => 'sort',
251
				'options'           => array(
252 187
					'ASC'  => __( 'ASC', 'gravityview' ),
253 187
					'DESC' => __( 'DESC', 'gravityview' ),
254
				),
255 187
				'requires_not'      => 'sort_direction][=RAND', // ][ is for toggleRequired, so it ends in []
256
				'show_in_shortcode' => true,
257
				'article'           => array(
258
					'id' => '5c9d338a2c7d3a1544617f9b',
259
					'url' => 'https://docs.gravityview.co/article/570-sorting-by-multiple-columns',
260
				),
261
			),
262
			'sort_columns' => array(
263 187
				'label'             => __( 'Enable sorting by column', 'gravityview' ),
264 187
				'left_label'        => __( 'Column Sorting', 'gravityview' ),
265 187
				'type'              => 'checkbox',
266
				'value'             => false,
267 187
				'group'             => 'sort',
268
				'tooltip'           => NULL,
269
				'show_in_shortcode' => true,
270
				'show_in_template'  => array( 'default_table', 'preset_business_data', 'preset_issue_tracker', 'preset_resume_board', 'preset_job_board' ),
271
				'article'           => array(
272
					'id' => '54ee1246e4b034c37ea91c11',
273
					'url' => 'https://docs.gravityview.co/article/230-enabling-the-table-column-sorting-feature',
274
				),
275
			),
276
			'start_date' => array(
277 187
				'label'             => __( 'Filter by Start Date', 'gravityview' ),
278 187
				'class'             => 'gv-datepicker',
279 187
				'desc'              => __( 'Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ),
280 187
				'type'              => 'text',
281 187
				'value'             => '',
282 187
				'group'             => 'filter',
283
				'show_in_shortcode' => true,
284
				'article'           => array(
285
					'id' => '54c67bbbe4b0512429885520',
286
					'url' => 'https://docs.gravityview.co/article/79-using-relative-start-dates-and-end-dates',
287
				),
288
			),
289
			'end_date' => array(
290 187
				'label'             => __( 'Filter by End Date', 'gravityview' ),
291 187
				'class'             => 'gv-datepicker',
292 187
				'desc'              => __( 'Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ),
293 187
				'type'              => 'text',
294 187
				'value'             => '',
295 187
				'group'             => 'filter',
296
				'show_in_shortcode' => true,
297
				'article'           => array(
298
					'id' => '54c67bbbe4b0512429885520',
299
					'url' => 'https://docs.gravityview.co/article/79-using-relative-start-dates-and-end-dates',
300
				),
301
			),
302
			'class' => array(
303 187
				'label'             => __( 'CSS Class', 'gravityview' ),
304 187
				'desc'              => __( 'CSS class to add to the wrapping HTML container.', 'gravityview' ),
305 187
				'group'             => 'default',
306 187
				'type'              => 'text',
307 187
				'value'             => '',
308
				'show_in_shortcode' => false,
309
			),
310
			'search_value' => array(
311 187
				'label'             => __( 'Search Value', 'gravityview' ),
312 187
				'desc'              => __( 'Define a default search value for the View', 'gravityview' ),
313 187
				'type'              => 'text',
314 187
				'value'             => '',
315 187
				'group'             => 'filter',
316
				'show_in_shortcode' => false,
317
			),
318
			'search_field' => array(
319 187
				'label'             => __( 'Search Field', 'gravityview' ),
320 187
				'desc'              => __( 'If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview' ),
321 187
				'type'              => 'text',
322 187
				'value'             => '',
323 187
				'group'             => 'filter',
324
				'show_in_shortcode' => false,
325
			),
326
			'search_operator' => array(
327 187
				'label'             => __( 'Search Operator', 'gravityview' ),
328 187
				'type'              => 'operator',
329 187
				'value'             => 'contains',
330 187
				'group'             => 'filter',
331
				'show_in_shortcode' => false,
332
			),
333
			'single_title' => array(
334 187
				'label'             => __( 'Single Entry Title', 'gravityview' ),
335 187
				'type'              => 'text',
336 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' ),
337 187
				'group'             => 'default',
338 187
				'value'             => '',
339
				'show_in_shortcode' => false,
340
				'full_width'        => true,
341
				'article'           => array(
342
					'id' => '54c67bcee4b07997ea3f3f9a',
343
					'url' => 'https://docs.gravityview.co/article/121-changing-the-single-entry-page-title',
344
				),
345
			),
346
			'back_link_label' => array(
347 187
				'label'             => __( 'Back Link Label', 'gravityview' ),
348 187
				'group'             => 'default',
349 187
				'desc'              => __( 'The text of the link that returns to the multiple entries view.', 'gravityview' ),
350 187
				'type'              => 'text',
351 187
				'value'             => '',
352 187
				'placeholder'       => __( '&larr; Go back', 'gravityview' ),
353 187
				'class'             => 'widefat',
354 187
				'merge_tags'        => 'force',
355
				'show_in_shortcode' => false,
356
				'full_width'        => true,
357
			),
358
			'edit_redirect' => array(
359 187
				'label'             => __( 'Redirect After Editing', 'gravityview' ),
360 187
				'group'             => 'default',
361 187
				'desc'              => __( 'The page to redirect to after editing an entry.', 'gravityview' ),
362 187
				'type'              => 'select',
363 187
				'value'             => '',
364
				'options'           => array(
365 187
					'' => __( 'Stay on Edit Entry', 'gravityview' ),
366 187
					'0'  => __( 'Redirect to Single Entry', 'gravityview' ),
367 187
					'1' => __( 'Redirect to Multiple Entries', 'gravityview' ),
368 187
					'2' => __( 'Redirect to URL', 'gravityview' ),
369
				)
370
			),
371
			'edit_return_context' => array(
372 187
				'label'             => __( 'Editing Returns To&hellip;', 'gravityview' ),
373 187
				'type'              => 'radio',
374 187
				'desc'              => __( 'After editing an entry or clicking Cancel, where should the user be sent?', 'gravityview' ),
375 187
				'group'             => 'default',
376 187
				'value'             => 'single',
377
				'options'           => array(
378 187
					'multiple' => __( 'Multiple Entries', 'gravityview' ),
379 187
					'single'   => __( 'Single Entry', 'gravityview' ),
380 187
					'custom'   => __( 'Other URL', 'gravityview' ),
381
				),
382
				'show_in_shortcode' => false,
383
				'full_width'        => true,
384
				'article'           => array(
385
					'id' => '5e9a3e0c2c7d3a7e9aeb2efb',
386
					'url' => 'https://docs.gravityview.co/article/707-view-settings-redirect-after-editing',
387
				),
388
			),
389
			'edit_redirect_url' => array(
390 187
				'label'             => __( 'Edit Entry Redirect URL', 'gravityview' ),
391 187
				'group'             => 'default',
392 187
				'desc'              => __( 'After editing an entry, the user will be taken to this URL.', 'gravityview' ),
393 187
				'type'              => 'text',
394 187
				'class'             => 'code widefat',
395 187
				'value'             => '',
396 187
				'requires'          => 'edit_redirect=2',
397 187
				'merge_tags'        => 'force',
398
			),
399
			'edit_locking' => array(
400 187
				'label'             => __( 'Enable Edit Locking', 'gravityview' ),
401 187
				'group'             => 'default',
402 187
				'desc'              => __( 'Prevent multiple users from editing the same entry at the same time.', 'gravityview' ),
403 187
				'type'              => 'checkbox',
404
				'full_width'        => true,
405 187
				'class'             => 'code widefat',
406
				'value'             => true,
407
				'article'           => array(
408
					'id' => '5e4449d72c7d3a7e9ae7a54c',
409
					'url' => 'https://docs.gravityview.co/article/676-entry-locking',
410
				),
411
			),
412
			'embed_only' => array(
413 187
				'label'             => __( 'Prevent Direct Access', 'gravityview' ),
414 187
				'group'             => 'default',
415 187
				'desc'              => __( 'Only allow access to this View when embedded using the shortcode.', 'gravityview' ),
416 187
				'type'              => 'checkbox',
417 187
				'value'             => '',
418
				'tooltip'           => false,
419
				'show_in_shortcode' => false,
420
				'full_width'        => true,
421
			),
422 187
		), ( gravityview()->plugin->supports( Plugin::FEATURE_REST ) && ( gravityview()->plugin->settings->get( 'rest_api' ) === '1' ) ) ?
423
			array(
424 187
				'rest_disable'          => array(
425 187
					'label'             => __( 'Prevent REST Access', 'gravityview' ),
426 187
					'group'             => 'default',
427 187
					'desc'              => __( 'Disable REST access to this View.', 'gravityview' ),
428 187
					'type'              => 'checkbox',
429 187
					'value'             => '',
430
					'tooltip'           => false,
431
					'show_in_shortcode' => false,
432
					'full_width'        => true,
433
				),
434 187
			) : array(),
435 187
		( gravityview()->plugin->supports( Plugin::FEATURE_REST ) && ( gravityview()->plugin->settings->get( 'rest_api' ) !== '1' ) ) ?
436
			array(
437 1
				'rest_enable'           => array(
438 1
					'label'             => __( 'Allow REST Access', 'gravityview' ),
439 1
					'group'             => 'default',
440 1
					'desc'              => __( 'Enable REST access to this View.', 'gravityview' ),
441 1
					'type'              => 'checkbox',
442 1
					'value'             => '',
443
					'tooltip'           => false,
444
					'show_in_shortcode' => false,
445
					'full_width'        => true,
446
				),
447 187
			) : array(),
448
		array(
449 187
			'csv_enable'            => array(
450 187
				'label'             => __( 'Allow CSV Access', 'gravityview' ),
451 187
				'group'             => 'default',
452 187
				'desc'              => __( 'Enable CSV access to this View.', 'gravityview' ),
453 187
				'type'              => 'checkbox',
454 187
				'value'             => '',
455 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' ),
456
				'show_in_shortcode' => false,
457
				'full_width'        => true,
458
				'article'          => array(
459
					'id' => '5bad2a0c042863158cc6d4ac',
460
					'url' => 'https://docs.gravityview.co/article/491-csv-export',
461
				),
462
			),
463
		),
464
		array(
465 187
			'csv_nolimit'           => array(
466 187
				'label'             => __( 'Show all in CSV', 'gravityview' ),
467 187
				'group'             => 'default',
468 187
				'requires'          => 'csv_enable',
469 187
				'desc'              => __( 'Do not limit the number of entries output in the CSV.', 'gravityview' ),
470 187
				'type'              => 'checkbox',
471 187
				'value'             => '',
472
				'tooltip'           => false,
473
				'show_in_shortcode' => false,
474
				'full_width'        => true,
475
			),
476
		),
477
		array(
478 187
			'post_id' => array(
479
				'type'              => 'number',
480
				'value'             => '',
481
				'show_in_shortcode' => false,
482
			),
483
		) );
484
485 187
		if ( version_compare( \GFCommon::$version, '2.3-beta-4', '>=' ) ) {
486 187
			$default_settings['sort_direction']['options']['RAND'] = __( 'Random', 'gravityview' );
487
		}
488
489
		/**
490
		 * @filter `gravityview_default_args` Modify the default settings for new Views
491
		 * @param[in,out] array $default_args Array of default args.
492
		 * @deprecated
493
		 * @see filter `gravityview/view/settings/defaults`
494
		 */
495 187
		$default_settings = apply_filters( 'gravityview_default_args', $default_settings );
496
497
		/**
498
		 * @filter `gravityview/view/defaults` Modify the default settings for new Views
499
		 * @param[in,out] array $default_settings Array of default settings.
500
		 */
501 187
		$default_settings = apply_filters( 'gravityview/view/settings/defaults', $default_settings );
502
503
		// By default, we only want the key => value pairing, not the whole array.
504 187
		if ( ! $detailed ) {
505 187
			$defaults = array();
506 187
			foreach( $default_settings as $key => $value ) {
507 187
				$defaults[ $key ] = $value['value'];
508
			}
509 187
			return $defaults;
510
511
		// But sometimes, we want all the details.
512
		} else {
513 11
			foreach ( $default_settings as $key => $value ) {
514
515
				// If the $group argument is set for the method,
516
				// ignore any settings that aren't in that group.
517 11
				if ( ! empty( $group ) && is_string( $group ) ) {
518 1
					if ( empty( $value['group'] ) || $value['group'] !== $group ) {
519 1
						unset( $default_settings[ $key ] );
520
					}
521
				}
522
			}
523 11
			return $default_settings;
524
		}
525
	}
526
527
	/**
528
	 * Turn to an $atts array as used around the old codebase.
529
	 *
530
	 * @internal
531
	 * @deprecated
532
	 *
533
	 * @return array
534
	 */
535 108
	public function as_atts() {
536 108
		$defaults = array_keys( self::defaults() );
537 108
		$_this = &$this;
538
		return array_combine( $defaults, array_map( function( $key ) use ( $_this ) {
539 108
			return $_this->get( $key );
540 108
		}, $defaults ) );
541
	}
542
}
543