PluginProbe
WP Ultimate Post Grid / 4.0.1
WP Ultimate Post Grid v4.0.1
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / assets / js / admin-modal / grid / section / SectionDataSource.js

SectionDataSource.js in WP Ultimate Post Grid 4.0.1, at assets/js/admin-modal/grid/section/SectionDataSource.js

264 lines 11.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { Fragment } from 'react';
2
3 import Field from 'Modal/field';
4 import { __wpupg } from 'Shared/Translations';
5
6 const SectionDataSource = (props) => {
7 let languageOptions = [
8 { value: false, label: __wpupg( 'Ignore post language' ) },
9 ];
10 if ( wpupg_admin_manage_modal.hasOwnProperty( 'multilingual' ) && 'wpml' === wpupg_admin_manage_modal.multilingual.plugin ) {
11 languageOptions = languageOptions.concat( Object.values( wpupg_admin_manage_modal.multilingual.languages ) );
12 }
13
14 return (
15 <Fragment>
16 <Field
17 value={ props.grid.type }
18 onChange={ ( value ) => {
19 props.onGridChange({
20 type: value,
21 });
22 }}
23 type="dropdown"
24 label={ __wpupg( 'Type of Grid' ) }
25 options={[
26 {
27 value: 'posts',
28 label: __wpupg( 'Grid of Posts, Pages or Custom Post Types' ),
29 },
30 {
31 value: 'terms',
32 label: `${ __wpupg( 'Grid of Category or Taxonomy Terms' ) }${ wpupg_admin.addons.premium ? '' : ` (${__wpupg( 'Premium Only' ) })` }`,
33 }
34 ]}
35 />
36 {
37 'posts' === props.grid.type
38 &&
39 <Fragment>
40 <Field
41 value={ wpupg_admin.addons.premium ? props.grid.post_types : props.grid.post_types[0] }
42 onChange={ ( value ) => {
43 const post_types = wpupg_admin.addons.premium ? value : [value];
44 props.onGridChange({
45 post_types,
46 });
47 }}
48 type="dropdown"
49 options={ Object.values( wpupg_admin_manage_modal.post_types ) }
50 isMulti={ wpupg_admin.addons.premium }
51 label={ __wpupg( 'Post Types' ) }
52 help={ wpupg_admin.addons.premium ? null : __wpupg( 'Multiple post types are available in WP Ultimate Post Grid Premium' ) }
53 />
54 <Field
55 value={ props.grid.password_protected }
56 onChange={ ( value ) => {
57 props.onGridChange({
58 password_protected: value,
59 });
60 }}
61 type="dropdown"
62 label={ __wpupg( 'Password Protected' ) }
63 options={[
64 {
65 value: 'all',
66 label: __wpupg( 'Include all posts' ),
67 },
68 {
69 value: 'exclude',
70 label: __wpupg( 'Exclude password protected posts' ),
71 },
72 {
73 value: 'only',
74 label: __wpupg( 'Only show password protected posts' ),
75 },
76 ]}
77 />
78 <Field
79 value={ props.grid.post_status }
80 onChange={ ( value ) => {
81 props.onGridChange({
82 post_status: value,
83 });
84 }}
85 type="dropdown"
86 label={ __wpupg( 'Post Status' ) }
87 options={[
88 {
89 value: 'publish',
90 label: __wpupg( 'Published Posts' ),
91 },
92 {
93 value: 'private',
94 label: __wpupg( 'Private Posts' ),
95 },
96 {
97 value: 'future',
98 label: __wpupg( 'Scheduled Posts' ),
99 },
100 {
101 value: 'pending',
102 label: __wpupg( 'Pending Posts' ),
103 },
104 {
105 value: 'draft',
106 label: __wpupg( 'Draft Posts' ),
107 },
108 ]}
109 isMulti
110 help={ __wpupg( 'Select the post statusses you want to display in the grid.' ) }
111 />
112 {
113 props.grid.post_status.includes( 'private' )
114 &&
115 <Field
116 value={ props.grid.post_status_require_permission }
117 onChange={ ( value ) => {
118 props.onGridChange({
119 post_status_require_permission: value,
120 });
121 }}
122 type="checkbox"
123 label={ __wpupg( 'Only if readable' ) }
124 help={ __wpupg( 'Only show private posts when a visitor has read permission for them.' ) }
125 />
126 }
127 {
128
129 1 < languageOptions.length
130 &&
131 <Field
132 value={ props.grid.language }
133 onChange={ ( value ) => {
134 props.onGridChange({
135 language: value,
136 });
137 }}
138 type="dropdown"
139 label={ __wpupg( 'Language' ) }
140 options={ languageOptions }
141 />
142 }
143 <Field
144 value={ props.grid.order_by }
145 onChange={ ( value ) => {
146 props.onGridChange({
147 order_by: value,
148 });
149 }}
150 type="dropdown"
151 options={[
152 { value: 'title', label: __wpupg( 'Title' ) },
153 { value: 'date', label: __wpupg( 'Date' ) },
154 { value: 'modified', label: __wpupg( 'Date Modified' ) },
155 { value: 'author', label: __wpupg( 'Author' ) },
156 { value: 'comment_count', label: __wpupg( 'Comment Count' ) },
157 { value: 'rand', label: __wpupg( 'Random' ) },
158 { value: 'menu_order', label: __wpupg( 'Menu Order (pages)' ) },
159 { value: 'custom', label: `${ __wpupg( 'Custom Field' ) }${ wpupg_admin.addons.premium ? '' : ` (${__wpupg( 'Premium Only' ) })` }`, },
160 ]}
161 label={ __wpupg( 'Order By' ) }
162 />
163 {
164 'custom' === props.grid.order_by
165 &&
166 <Fragment>
167 <Field
168 value={ props.grid.order_custom_key }
169 onChange={ ( value ) => {
170 props.onGridChange({
171 order_custom_key: value,
172 });
173 }}
174 type="text"
175 label={ __wpupg( 'Field Key' ) }
176 help={ __wpupg( 'Key of the custom field to order the grid by.' ) }
177 />
178 <Field
179 value={ props.grid.order_custom_key_numeric }
180 onChange={ ( value ) => {
181 props.onGridChange({
182 order_custom_key_numeric: value,
183 });
184 }}
185 type="checkbox"
186 label={ __wpupg( 'Numeric Field' ) }
187 help={ __wpupg( 'Enable if the custom field contains numbers.' ) }
188 />
189 </Fragment>
190 }
191 {
192 'rand' !== props.grid.order_by
193 &&
194 <Field
195 value={ props.grid.order }
196 onChange={ ( value ) => {
197 props.onGridChange({
198 order: value,
199 });
200 }}
201 type="dropdown"
202 options={[
203 { value: 'asc', label: __wpupg( 'Ascending' ) },
204 { value: 'desc', label: __wpupg( 'Descending' ) },
205 ]}
206 label={ __wpupg( 'Order' ) }
207 />
208 }
209 </Fragment>
210 }
211 {
212 'terms' === props.grid.type
213 &&
214 <Fragment>
215 <Field
216 value={ props.grid.taxonomies }
217 onChange={ ( value ) => {
218 props.onGridChange({
219 taxonomies: value,
220 });
221 }}
222 type="dropdown"
223 options={ Object.values( wpupg_admin_manage_modal.taxonomies ) }
224 isMulti={ true }
225 label={ __wpupg( 'Taxonomies' ) }
226 />
227 <Field
228 value={ props.grid.terms_order_by }
229 onChange={ ( value ) => {
230 props.onGridChange({
231 terms_order_by: value,
232 });
233 }}
234 type="dropdown"
235 options={[
236 { value: 'name', label: __wpupg( 'Name' ) },
237 { value: 'slug', label: __wpupg( 'Slug' ) },
238 { value: 'term_id', label: __wpupg( 'ID' ) },
239 { value: 'description', label: __wpupg( 'Description' ) },
240 { value: 'count', label: __wpupg( 'Post Count' ) },
241 ]}
242 label={ __wpupg( 'Order By' ) }
243 />
244 <Field
245 value={ props.grid.terms_order }
246 onChange={ ( value ) => {
247 props.onGridChange({
248 terms_order: value,
249 });
250 }}
251 type="dropdown"
252 options={[
253 { value: 'asc', label: __wpupg( 'Ascending' ) },
254 { value: 'desc', label: __wpupg( 'Descending' ) },
255 ]}
256 label={ __wpupg( 'Order' ) }
257 />
258 </Fragment>
259 }
260 </Fragment>
261 );
262 }
263 export default SectionDataSource;
264