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