GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
class-gv-settings-view.php
Go to the documentation of this file.
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  *
16  * @param bool $detailed Whether to return detailed setting meta information or just the value.
17  *
18  * @api
19  * @since 2.0
20  *
21  * @return \GV\View_Settings
22  */
23  public static function with_defaults( $detailed = false ) {
24  $settings = new self();
25  $settings->update( self::defaults( $detailed ) );
26  return $settings;
27  }
28 
29  /**
30  * Retrieve the default View settings.
31  *
32  * @param bool $detailed Whether to return detailed setting meta information or just the value.
33  * @param string $group Retrieve settings of a particular group.
34  *
35  * @api
36  * @since 2.0
37  *
38  * @return array The default settings along with their values.
39  * @param string $label Setting label shown in admin
40  * @param string $type Gravity Forms field type
41  * @param string $group The field group the setting is associated with. Default: "default"
42  * @param mixed $value The default value for the setting
43  * @param string $tooltip Tooltip displayed for the setting
44  * @param boolean $show_in_shortcode Whether to show the setting in the shortcode configuration modal
45  * @param array $options Array of values to use when generating select, multiselect, radio, or checkboxes fields
46  * @param boolean $full_width True: Display the input and label together when rendering. False: Display label and input in separate columns when rendering.
47  */
48  public static function defaults( $detailed = false, $group = null ) {
49 
50  $default_settings = array_merge(
51  array(
52  'id' => array(
53  'label' => __( 'View ID', 'gk-gravityview' ),
54  'type' => 'number',
55  'group' => 'default',
56  'value' => null,
57  'tooltip' => null,
58  'show_in_shortcode' => false,
59  ),
60  'page_size' => array(
61  'label' => __( 'Number of entries per page', 'gk-gravityview' ),
62  'type' => 'number',
63  'class' => 'small-text',
64  'group' => 'default',
65  'value' => 25,
66  'show_in_shortcode' => true,
67  ),
68  'offset' => array(
69  'label' => __( 'Offset entries starting from', 'gk-gravityview' ),
70  'type' => 'number',
71  'class' => 'small-text',
72  'group' => 'default',
73  'value' => 0,
74  'show_in_shortcode' => true,
75  ),
76  'lightbox' => array(
77  'label' => __( 'Enable lightbox for images', 'gk-gravityview' ),
78  'type' => 'checkbox',
79  'group' => 'default',
80  'value' => 1,
81  '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.', 'gk-gravityview' ),
82  'show_in_shortcode' => true,
83  'article' => array(
84  'id' => '5e9a1f8904286364bc98931f',
85  'url' => 'https://docs.gravityview.co/article/705-view-settings-enable-lightbox-for-images',
86  ),
87  ),
88  'show_only_approved' => array(
89  'label' => __( 'Show only approved entries', 'gk-gravityview' ),
90  'type' => 'checkbox',
91  'group' => 'default',
92  '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.', 'gk-gravityview' ),
93  'tooltip' => false,
94  'value' => 1,
95  'show_in_shortcode' => true,
96  'article' => array(
97  'id' => '5bad1a33042863158cc6d396',
98  'url' => 'https://docs.gravityview.co/article/490-entry-approval-gravity-forms',
99  ),
100  ),
101  'no_entries_options' => array(
102  'label' => __( 'No Entries Behavior', 'gk-gravityview' ),
103  'type' => 'select',
104  'desc' => __( 'Choose what happens when a View has no entries visible to the current user.', 'gk-gravityview' ),
105  'group' => 'default',
106  'options' => array(
107  '0' => __( 'Show a Message', 'gk-gravityview' ),
108  '1' => __( 'Display a Form', 'gk-gravityview' ),
109  '2' => __( 'Redirect to URL', 'gk-gravityview' ),
110  ),
111  'value' => '0',
112  'show_in_shortcode' => true,
113  ),
114  'no_results_text' => array(
115  'label' => __( 'No Entries Message', 'gk-gravityview' ),
116  'type' => 'text',
117  'group' => 'default',
118  'desc' => esc_html__( 'The text to display when there are no entries to show. HTML and shortcodes are allowed.', 'gk-gravityview' ),
119  'tooltip' => false,
120  'value' => '',
121  'placeholder' => esc_html__( 'No entries match your request.', 'gk-gravityview' ),
122  'show_in_shortcode' => true,
123  'class' => 'widefat',
124  'requires' => 'no_entries_options=0',
125  'full_width' => true,
126  ),
127  'no_entries_form' => array(
128  'label' => __( 'No Entries Form', 'gk-gravityview' ),
129  'type' => 'select',
130  'desc' => __( 'Show a Gravity Forms form if there are no entries to show in the View.', 'gk-gravityview' ),
131  'group' => 'default',
132  'requires' => 'no_entries_options=1',
133  'options' => \GVCommon::get_forms_as_options(),
134  'value' => esc_attr( \GV\Utils::_POST( 'post' ) ? gravityview_get_form_id( \GV\Utils::_POST( 'post' ) ) : \GV\Utils::_GET( 'form_id', '' ) ),
135  'show_in_shortcode' => true,
136  ),
137  'no_entries_form_title' => array(
138  'label' => __( 'Form Title', 'gk-gravityview' ),
139  'type' => 'checkbox',
140  'group' => 'default',
141  'requires' => 'no_entries_options=1',
142  'value' => 1,
143  'show_in_shortcode' => true,
144  ),
145  'no_entries_form_description' => array(
146  'label' => __( 'Form Description', 'gk-gravityview' ),
147  'type' => 'checkbox',
148  'group' => 'default',
149  'requires' => 'no_entries_options=1',
150  'value' => 1,
151  'show_in_shortcode' => true,
152  ),
153  'no_entries_redirect' => array(
154  'label' => __( 'No Entries Redirect URL', 'gk-gravityview' ),
155  'group' => 'default',
156  'desc' => __( 'If there are no entries to show, the user will be taken to this URL.', 'gk-gravityview' ),
157  'type' => 'text',
158  'class' => 'code widefat',
159  'value' => '',
160  'placeholder' => 'https://www.example.com',
161  'requires' => 'no_entries_options=2',
162  ),
163  'no_search_results_text' => array(
164  'label' => __( '"No Search Results" Text', 'gk-gravityview' ),
165  'type' => 'text',
166  'group' => 'default',
167  'desc' => '',
168  'tooltip' => false,
169  'value' => '',
170  'placeholder' => __( 'This search returned no results.', 'gk-gravityview' ),
171  'show_in_shortcode' => true,
172  'class' => 'widefat',
173  'full_width' => true,
174  ),
175  'admin_show_all_statuses' => array(
176  'label' => __( 'Show all entries to administrators', 'gk-gravityview' ),
177  'desc' => __( 'Administrators will be able to see entries with any approval status.', 'gk-gravityview' ),
178  '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.', 'gk-gravityview' ),
179  'requires' => 'show_only_approved',
180  'type' => 'checkbox',
181  'group' => 'default',
182  'value' => 0,
183  'show_in_shortcode' => false,
184  ),
185  'hide_until_searched' => array(
186  'label' => __( 'Hide View data until search is performed', 'gk-gravityview' ),
187  'type' => 'checkbox',
188  'group' => 'default',
189  'tooltip' => __( 'When enabled it will only show any View entries after a search is performed.', 'gk-gravityview' ),
190  'value' => 0,
191  'show_in_shortcode' => false,
192  'article' => array(
193  'id' => '5c772fa02c7d3a0cb9320a84',
194  'url' => 'https://docs.gravityview.co/article/536-how-to-hide-results-and-only-display-them-if-a-search-is-performed',
195  ),
196  ),
197  'hide_empty' => array(
198  'label' => __( 'Hide empty fields', 'gk-gravityview' ),
199  'group' => 'default',
200  'type' => 'checkbox',
201  'desc' => __( 'When enabled, empty fields will be not be displayed. If disabled, fields and their labels will be displayed with no content.', 'gk-gravityview' ),
202  'value' => 1,
203  'tooltip' => false,
204  'show_in_shortcode' => false,
205  ),
206  'hide_empty_single' => array(
207  'label' => __( 'Hide empty fields', 'gk-gravityview' ),
208  'group' => 'default',
209  'type' => 'checkbox',
210  'desc' => __( 'When enabled, empty fields will be not be displayed. If disabled, fields and their labels will be displayed with no content.', 'gk-gravityview' ),
211  'value' => 1,
212  'tooltip' => false,
213  'show_in_shortcode' => false,
214  ),
215  'edit_feeds' => array(
216  'label' => __( 'Feeds', 'gk-gravityview' ),
217  'group' => 'default',
218  'type' => 'checkbox',
219  'value' => array(),
220  'show_in_shortcode' => false,
221  ),
222  'user_edit' => array(
223  'label' => __( 'Allow User Edit', 'gk-gravityview' ),
224  'group' => 'default',
225  'desc' => __( 'Allow logged-in users to edit entries they created.', 'gk-gravityview' ) . ' ' . sprintf( __( 'Administrators are able to %s regardless of this setting.', 'gk-gravityview' ), _x( 'edit entries', 'an action that admins can perform', 'gk-gravityview' ) ),
226  'value' => 0,
227  'tooltip' => __( 'Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gk-gravityview' ),
228  'type' => 'checkbox',
229  'show_in_shortcode' => true,
230  'article' => array(
231  'id' => '54c67bbbe4b07997ea3f3f6b',
232  'url' => 'https://docs.gravityview.co/article/77-user-edit-allow-users-to-edit-their-own-entries',
233  ),
234  ),
235  'unapprove_edit' => array(
236  'label' => __( 'Unapprove Entries After Edit', 'gk-gravityview' ),
237  'group' => 'default',
238  'requires' => 'user_edit',
239  'desc' => __( 'When an entry is edited by a non-administrator, reset the approval status to "Unapproved".', 'gk-gravityview' ),
240  '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.', 'gk-gravityview' ),
241  'value' => 0,
242  'type' => 'checkbox',
243  'show_in_shortcode' => true,
244  'article' => array(
245  'id' => '5ddd81d504286364bc923957',
246  'url' => 'https://docs.gravityview.co/article/657-unapproving-edited-entries-automatically',
247  ),
248  ),
249  'user_delete' => array(
250  'label' => __( 'Allow User Delete', 'gk-gravityview' ),
251  'group' => 'default',
252  'desc' => __( 'Allow logged-in users to delete entries they created.', 'gk-gravityview' ) . ' ' . sprintf( __( 'Administrators are able to %s regardless of this setting.', 'gk-gravityview' ), _x( 'delete entries', 'an action that admins can perform', 'gk-gravityview' ) ),
253  'value' => 0,
254  'tooltip' => __( 'Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gk-gravityview' ),
255  'type' => 'checkbox',
256  'show_in_shortcode' => true,
257  'article' => array(
258  'id' => '54c67bb9e4b0512429885512',
259  'url' => 'https://docs.gravityview.co/article/66-configuring-delete-entry',
260  ),
261  ),
262  'user_duplicate' => array(
263  'label' => __( 'Allow User Duplicate', 'gk-gravityview' ),
264  'group' => 'default',
265  'desc' => __( 'Allow logged-in users to duplicate entries they created.', 'gk-gravityview' ) . ' ' . sprintf( __( 'Administrators are able to %s regardless of this setting.', 'gk-gravityview' ), _x( 'duplicate entries', 'an action that admins can perform', 'gk-gravityview' ) ),
266  'value' => 0,
267  'tooltip' => __( 'Display "Duplicate Entry" fields to non-administrator users if they created the entry. Duplicate Entry fields will always be displayed to site administrators.', 'gk-gravityview' ),
268  'article' => array(
269  'id' => '5df11eb704286364bc92bf36',
270  'url' => 'https://docs.gravityview.co/article/66-configuring-delete-entry',
271  ),
272  'type' => 'checkbox',
273  'show_in_shortcode' => true,
274  ),
275  'sort_field' => array(
276  'label' => __( 'Sort by field', 'gk-gravityview' ),
277  'type' => 'select',
278  'desc' => __( 'By default, entries are sorted by Entry ID.', 'gk-gravityview' ),
279  'value' => '',
280  'group' => 'sort',
281  'options' => array(
282  '' => __( 'Default', 'gk-gravityview' ),
283  'date_created' => __( 'Date Created', 'gk-gravityview' ),
284  ),
285  'show_in_shortcode' => true,
286  'article' => array(
287  'id' => '54c67bbbe4b051242988551a',
288  'url' => 'https://docs.gravityview.co/article/74-sorting-results-by-field-value',
289  ),
290  ),
291  'sort_direction' => array(
292  'label' => __( 'Sort direction', 'gk-gravityview' ),
293  'type' => 'select',
294  'value' => 'ASC',
295  'group' => 'sort',
296  'options' => array(
297  'ASC' => __( 'ASC', 'gk-gravityview' ),
298  'DESC' => __( 'DESC', 'gk-gravityview' ),
299  'RAND' => __( 'Random', 'gk-gravityview' ),
300  ),
301  'show_in_shortcode' => true,
302  'article' => array(
303  'id' => '5c9d338a2c7d3a1544617f9b',
304  'url' => 'https://docs.gravityview.co/article/570-sorting-by-multiple-columns',
305  ),
306  ),
307  'sort_field_2' => array(
308  'label' => __( 'Sort by secondary field', 'gk-gravityview' ),
309  'type' => 'select',
310  'value' => '',
311  'group' => 'sort',
312  'options' => array(
313  '' => __( 'Default', 'gk-gravityview' ),
314  'date_created' => __( 'Date Created', 'gk-gravityview' ),
315  ),
316  'requires_not' => 'sort_direction][=RAND', // ][ is for toggleRequired, so it ends in []
317  'show_in_shortcode' => true,
318  'article' => array(
319  'id' => '5c9d338a2c7d3a1544617f9b',
320  'url' => 'https://docs.gravityview.co/article/570-sorting-by-multiple-columns',
321  ),
322  ),
323  'sort_direction_2' => array(
324  'label' => __( 'Secondary sort direction', 'gk-gravityview' ),
325  'type' => 'select',
326  'value' => 'ASC',
327  'group' => 'sort',
328  'options' => array(
329  'ASC' => __( 'ASC', 'gk-gravityview' ),
330  'DESC' => __( 'DESC', 'gk-gravityview' ),
331  ),
332  'requires_not' => 'sort_direction][=RAND', // ][ is for toggleRequired, so it ends in []
333  'show_in_shortcode' => true,
334  'article' => array(
335  'id' => '5c9d338a2c7d3a1544617f9b',
336  'url' => 'https://docs.gravityview.co/article/570-sorting-by-multiple-columns',
337  ),
338  ),
339  'sort_columns' => array(
340  'label' => __( 'Enable sorting by column', 'gk-gravityview' ),
341  'left_label' => __( 'Column Sorting', 'gk-gravityview' ),
342  'type' => 'checkbox',
343  'value' => false,
344  'group' => 'sort',
345  'tooltip' => null,
346  'show_in_shortcode' => true,
347  'show_in_template' => array(
348  'default_table',
349  'preset_business_data',
350  'preset_issue_tracker',
351  'preset_resume_board',
352  'preset_job_board'
353  ),
354  'article' => array(
355  'id' => '54ee1246e4b034c37ea91c11',
356  'url' => 'https://docs.gravityview.co/article/230-enabling-the-table-column-sorting-feature',
357  ),
358  ),
359  'start_date' => array(
360  'label' => __( 'Filter by Start Date', 'gk-gravityview' ),
361  'class' => 'gv-datepicker',
362  'desc' => __( 'Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gk-gravityview' ),
363  'type' => 'text',
364  'value' => '',
365  'group' => 'filter',
366  'show_in_shortcode' => true,
367  'article' => array(
368  'id' => '54c67bbbe4b0512429885520',
369  'url' => 'https://docs.gravityview.co/article/79-using-relative-start-dates-and-end-dates',
370  ),
371  ),
372  'end_date' => array(
373  'label' => __( 'Filter by End Date', 'gk-gravityview' ),
374  'class' => 'gv-datepicker',
375  'desc' => __( 'Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gk-gravityview' ),
376  'type' => 'text',
377  'value' => '',
378  'group' => 'filter',
379  'show_in_shortcode' => true,
380  'article' => array(
381  'id' => '54c67bbbe4b0512429885520',
382  'url' => 'https://docs.gravityview.co/article/79-using-relative-start-dates-and-end-dates',
383  ),
384  ),
385  'class' => array(
386  'label' => __( 'CSS Class', 'gk-gravityview' ),
387  'desc' => __( 'CSS class to add to the wrapping HTML container.', 'gk-gravityview' ),
388  'group' => 'default',
389  'type' => 'text',
390  'value' => '',
391  'show_in_shortcode' => false,
392  ),
393  'search_value' => array(
394  'label' => __( 'Search Value', 'gk-gravityview' ),
395  'desc' => __( 'Define a default search value for the View', 'gk-gravityview' ),
396  'type' => 'text',
397  'value' => '',
398  'group' => 'filter',
399  'show_in_shortcode' => false,
400  ),
401  'search_field' => array(
402  'label' => __( 'Search Field', 'gk-gravityview' ),
403  'desc' => __( 'If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gk-gravityview' ),
404  'type' => 'text',
405  'value' => '',
406  'group' => 'filter',
407  'show_in_shortcode' => false,
408  ),
409  'search_operator' => array(
410  'label' => __( 'Search Operator', 'gk-gravityview' ),
411  'type' => 'operator',
412  'value' => 'contains',
413  'group' => 'filter',
414  'show_in_shortcode' => false,
415  ),
416  'single_title' => array(
417  'label' => __( 'Single Entry Title', 'gk-gravityview' ),
418  'type' => 'text',
419  '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.', 'gk-gravityview' ),
420  'group' => 'default',
421  'value' => '',
422  'show_in_shortcode' => false,
423  'full_width' => true,
424  'article' => array(
425  'id' => '54c67bcee4b07997ea3f3f9a',
426  'url' => 'https://docs.gravityview.co/article/121-changing-the-single-entry-page-title',
427  ),
428  ),
429  'back_link_label' => array(
430  'label' => __( 'Back Link Label', 'gk-gravityview' ),
431  'group' => 'default',
432  'desc' => __( 'The text of the link that returns to the multiple entries view.', 'gk-gravityview' ),
433  'type' => 'text',
434  'value' => '',
435  'placeholder' => __( '&larr; Go back', 'gk-gravityview' ),
436  'class' => 'widefat',
437  'merge_tags' => 'force',
438  'show_in_shortcode' => false,
439  'full_width' => true,
440  ),
441  'edit_redirect' => array(
442  'label' => __( 'Redirect After Editing', 'gk-gravityview' ),
443  'group' => 'default',
444  'desc' => __( 'The page to redirect to after editing an entry.', 'gk-gravityview' ),
445  'type' => 'select',
446  'value' => '',
447  'options' => array(
448  '' => __( 'Stay on Edit Entry', 'gk-gravityview' ),
449  '0' => __( 'Redirect to Single Entry', 'gk-gravityview' ),
450  '1' => __( 'Redirect to Multiple Entries', 'gk-gravityview' ),
451  '2' => __( 'Redirect to URL', 'gk-gravityview' ),
452  ),
453  'article' => array(
454  'id' => '5e9a3e0c2c7d3a7e9aeb2efb',
455  'url' => 'https://docs.gravityview.co/article/707-view-settings-redirect-after-editing',
456  ),
457  ),
458  'edit_return_context' => array(
459  'label' => __( 'Editing Returns To&hellip;', 'gk-gravityview' ),
460  'type' => 'radio',
461  'desc' => __( 'After editing an entry or clicking Cancel, where should the user be sent?', 'gk-gravityview' ),
462  'group' => 'default',
463  'value' => 'single',
464  'options' => array(
465  'multiple' => __( 'Multiple Entries', 'gk-gravityview' ),
466  'single' => __( 'Single Entry', 'gk-gravityview' ),
467  'custom' => __( 'Other URL', 'gk-gravityview' ),
468  ),
469  'show_in_shortcode' => false,
470  'full_width' => true,
471  'article' => array(
472  'id' => '5e9a3e0c2c7d3a7e9aeb2efb',
473  'url' => 'https://docs.gravityview.co/article/707-view-settings-redirect-after-editing',
474  ),
475  ),
476  'edit_redirect_url' => array(
477  'label' => __( 'Edit Entry Redirect URL', 'gk-gravityview' ),
478  'group' => 'default',
479  'desc' => __( 'After editing an entry, the user will be taken to this URL.', 'gk-gravityview' ),
480  'type' => 'text',
481  'class' => 'code widefat',
482  'value' => '',
483  'placeholder' => 'https://www.example.com/landing-page/',
484  'requires' => 'edit_redirect=2',
485  'merge_tags' => 'force',
486  ),
487  'action_label_update' => array(
488  'label' => __( 'Update Button Text', 'gk-gravityview' ),
489  'group' => 'default',
490  'desc' => '',
491  'type' => 'text',
492  'value' => _x( 'Update', 'Button to update an entry the user is editing', 'gk-gravityview' ),
493  'merge_tags' => 'force',
494  ),
495  'action_label_cancel' => array(
496  'label' => __( 'Cancel Link Text', 'gk-gravityview' ),
497  'group' => 'default',
498  'desc' => '',
499  'type' => 'text',
500  'value' => _x( 'Cancel', 'Shown when the user decides not to edit an entry', 'gk-gravityview' ),
501  'merge_tags' => 'force',
502  ),
503  'action_label_next' => array(
504  'label' => __( 'Next Page Button Text', 'gk-gravityview' ),
505  'group' => 'default',
506  'desc' => __( 'Only shown when multi-page forms are enabled.', 'gk-gravityview' ),
507  'type' => 'text',
508  'value' => __( 'Next', 'Show the next page in a multi-page form', 'gk-gravityview' ),
509  'merge_tags' => 'force',
510  ),
511  'action_label_previous' => array(
512  'label' => __( 'Previous Page Button Text', 'gk-gravityview' ),
513  'group' => 'default',
514  'desc' => __( 'Only shown when multi-page forms are enabled.', 'gk-gravityview' ),
515  'type' => 'text',
516  'value' => __( 'Previous', 'Show the previous page in a multi-page form', 'gk-gravityview' ),
517  'merge_tags' => 'force',
518  ),
519  'action_label_delete' => array(
520  'label' => __( 'Delete Link Text', 'gk-gravityview' ),
521  'group' => 'default',
522  'desc' => '',
523  'type' => 'text',
524  'value' => __( 'Delete', 'Button label to delete an entry from the Edit Entry screen', 'gk-gravityview' ),
525  'merge_tags' => 'force',
526  ),
527  'edit_locking' => array(
528  'label' => __( 'Enable Edit Locking', 'gk-gravityview' ),
529  'group' => 'default',
530  'desc' => __( 'Prevent multiple users from editing the same entry at the same time.', 'gk-gravityview' ),
531  'type' => 'checkbox',
532  'full_width' => true,
533  'class' => 'code widefat',
534  'value' => true,
535  'article' => array(
536  'id' => '5e4449d72c7d3a7e9ae7a54c',
537  'url' => 'https://docs.gravityview.co/article/676-entry-locking',
538  ),
539  ),
540  'delete_redirect' => array(
541  'label' => __( 'Redirect After Deleting', 'gk-gravityview' ),
542  'group' => 'default',
543  'desc' => __( 'The page to redirect to after deleting an entry.', 'gk-gravityview' ),
544  'type' => 'select',
545  'value' => '1',
546  'options' => array(
547  \GravityView_Delete_Entry::REDIRECT_TO_MULTIPLE_ENTRIES_VALUE => __( 'Redirect to Multiple Entries', 'gk-gravityview' ),
548  \GravityView_Delete_Entry::REDIRECT_TO_URL_VALUE => __( 'Redirect to URL', 'gk-gravityview' ),
549  ),
550  ),
551  'delete_redirect_url' => array(
552  'label' => __( 'Delete Entry Redirect URL', 'gk-gravityview' ),
553  'group' => 'default',
554  'desc' => __( 'After deleting an entry, the user will be taken to this URL.', 'gk-gravityview' ),
555  'type' => 'text',
556  'class' => 'code widefat',
557  'value' => '',
558  'placeholder' => 'https://www.example.com/landing-page/',
559  'requires' => 'delete_redirect=' . \GravityView_Delete_Entry::REDIRECT_TO_URL_VALUE,
560  'merge_tags' => 'force',
561  ),
562  'embed_only' => array(
563  'label' => __( 'Prevent Direct Access', 'gk-gravityview' ),
564  'group' => 'default',
565  'desc' => __( 'Only allow access to this View when embedded using the shortcode.', 'gk-gravityview' ),
566  'type' => 'checkbox',
567  'value' => '',
568  'tooltip' => false,
569  'show_in_shortcode' => false,
570  'full_width' => true,
571  ),
572  ),
573  ( gravityview()->plugin->supports( Plugin::FEATURE_REST ) && ( gravityview()->plugin->settings->get( 'rest_api' ) ) ) ?
574  array(
575  'rest_disable' => array(
576  'label' => __( 'Prevent REST Access', 'gk-gravityview' ),
577  'group' => 'default',
578  'desc' => __( 'Disable REST access to this View.', 'gk-gravityview' ),
579  'type' => 'checkbox',
580  'value' => '',
581  'tooltip' => false,
582  'show_in_shortcode' => false,
583  'full_width' => true,
584  ),
585  ) : array(),
586  ( gravityview()->plugin->supports( Plugin::FEATURE_REST ) && ( ! gravityview()->plugin->settings->get( 'rest_api' ) ) ) ?
587  array(
588  'rest_enable' => array(
589  'label' => __( 'Allow REST Access', 'gk-gravityview' ),
590  'group' => 'default',
591  'desc' => __( 'Enable REST access to this View.', 'gk-gravityview' ),
592  'type' => 'checkbox',
593  'value' => '',
594  'tooltip' => false,
595  'show_in_shortcode' => false,
596  'full_width' => true,
597  ),
598  ) : array(),
599  array(
600  'csv_enable' => array(
601  'label' => __( 'Allow Export', 'gk-gravityview' ),
602  'group' => 'default',
603  'desc' => __( 'Enable users to download data as a CSV or TSV file.', 'gk-gravityview' ),
604  'type' => 'checkbox',
605  'value' => '',
606  'tooltip' => __( 'If enabled, entries can be exported for this View by adding "/csv/" or "/tsv/" to the View URL. Each configured field will be a column in the exported file.', 'gk-gravityview' ),
607  'show_in_shortcode' => false,
608  'full_width' => true,
609  'article' => array(
610  'id' => '5bad2a0c042863158cc6d4ac',
611  'url' => 'https://docs.gravityview.co/article/491-csv-export',
612  ),
613  ),
614  ),
615  array(
616  'csv_nolimit' => array(
617  'label' => __( 'Show all in file', 'gk-gravityview' ),
618  'group' => 'default',
619  'desc' => __( 'Do not limit the number of entries output in the file.', 'gk-gravityview' ),
620  'type' => 'checkbox',
621  'value' => '',
622  'tooltip' => false,
623  'show_in_shortcode' => false,
624  'full_width' => true,
625  'requires' => 'csv_enable=1',
626  ),
627  ),
628  array(
629  'post_id' => array(
630  'type' => 'number',
631  'value' => '',
632  'show_in_shortcode' => false,
633  ),
634  )
635  );
636 
637  /**
638  * @filter `gravityview_default_args` Modify the default settings for new Views
639  * @deprecated
640  * @see filter `gravityview/view/settings/defaults`
641  *
642  * @param array $default_args Array of default args.
643  */
644  $default_settings = apply_filters( 'gravityview_default_args', $default_settings );
645 
646  /**
647  * @filter `gravityview/view/defaults` Modify the default settings for new Views
648  *
649  * @param array $default_settings Array of default settings.
650  */
651  $default_settings = apply_filters( 'gravityview/view/settings/defaults', $default_settings );
652 
653  // By default, we only want the key => value pairing, not the whole array.
654  if ( ! $detailed ) {
655  $defaults = array();
656  foreach ( $default_settings as $key => $value ) {
657  $defaults[ $key ] = $value['value'];
658  }
659 
660  return $defaults;
661 
662  // But sometimes, we want all the details.
663  } else {
664  foreach ( $default_settings as $key => $value ) {
665 
666  // If the $group argument is set for the method,
667  // ignore any settings that aren't in that group.
668  if ( ! empty( $group ) && is_string( $group ) ) {
669  if ( empty( $value['group'] ) || $value['group'] !== $group ) {
670  unset( $default_settings[ $key ] );
671  }
672  }
673  }
674 
675  return $default_settings;
676  }
677  }
678 
679  /**
680  * Turn to an $atts array as used around the old codebase.
681  *
682  * @internal
683  * @deprecated
684  *
685  * @return array
686  */
687  public function as_atts() {
688  $defaults = array_keys( self::defaults() );
689  $_this = &$this;
690  return array_combine(
691  $defaults,
692  array_map(
693  function( $key ) use ( $_this ) {
694  return $_this->get( $key );
695  },
696  $defaults
697  )
698  );
699  }
700 }
If this file is called directly, abort.
static with_defaults( $detailed=false)
Retrieve an instance of the settings with default values.
static get_forms_as_options( $active=true, $trash=false, $sort_column='id', $sort_dir='ASC')
Get all forms to use as options in View settings.
If this file is called directly, abort.
gravityview_get_form_id( $view_id)
Get the connected form ID from a View ID.
const REDIRECT_TO_URL_VALUE
The value of the delete_redirect option when the setting is to redirect to URL.
gravityview()
The main GravityView wrapper function.
as_atts()
Turn to an $atts array as used around the old codebase.
static defaults( $detailed=false, $group=null)
Retrieve the default View settings.
const REDIRECT_TO_MULTIPLE_ENTRIES_VALUE
The value of the delete_redirect option when the setting is to redirect to Multiple Entries after del...