PluginProbe
WP Ultimate Post Grid / 3.8.0
WP Ultimate Post Grid v3.8.0
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 3.8.0, at assets/js/admin-modal/grid/section/SectionDataSource.js

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