PluginProbe ʕ •ᴥ•ʔ
WP Popular Posts / trunk
WP Popular Posts vtrunk
4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 5.0.0 5.0.1 5.0.2 5.1.0 5.2.0 5.2.1 5.2.2 5.2.3 5.2.4 5.3.0 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.4.0 5.4.1 5.4.2 5.5.0 5.5.1 6.0.0 6.0.1 6.0.2 6.0.3 6.0.4 6.0.5 6.1.0 6.1.1 6.1.2 6.1.3 6.1.4 6.2.0 6.2.1 6.3.0 6.3.1 6.3.2 6.3.3 6.3.4 6.4.0 6.4.1 6.4.2 7.0.0 7.0.1 7.1.0 7.2.0 7.3.0 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 7.3.7 7.3.8 7.4.0 trunk 2.3.7 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.2 4.0.3 4.0.5 4.0.6
wordpress-popular-posts / src / Block / Widget / edit / fields-main.js
wordpress-popular-posts / src / Block / Widget / edit Last commit date
controls.js 1 month ago edit.js 1 month ago fields-filters.js 1 month ago fields-html-markup.js 1 month ago fields-main.js 1 month ago fields-post-settings.js 1 month ago fields-stats-tag.js 1 month ago
fields-main.js
122 lines
1 import { escape_html, unescape_html } from '../../utils';
2
3 const { Fragment } = wp.element;
4 const { CheckboxControl, SelectControl, TextControl } = wp.components;
5 const { __ } = wp.i18n;
6
7 export function MainFields({ attributes, setAttributes }) {
8 const {
9 title,
10 limit,
11 order_by,
12 range,
13 time_quantity,
14 time_unit,
15 freshness
16 } = attributes;
17
18 const labelTitle = __('Title', 'wordpress-popular-posts');
19 const labelLimit = __('Limit', 'wordpress-popular-posts');
20 const labelSortBy = __('Sort posts by', 'wordpress-popular-posts');
21 const labelTimeRange = __('Time Range', 'wordpress-popular-posts');
22 const labelTimeQuantity = __('Time Quantity', 'wordpress-popular-posts');
23 const labelTimeUnit = __('Time Unit', 'wordpress-popular-posts');
24 const labelFreshness = __('Display only posts published within the selected Time Range', 'wordpress-popular-posts');
25
26 const sortingOptions = [
27 {label: __('Total views', 'wordpress-popular-posts'), value: 'views'},
28 {label: __('Avg. daily views', 'wordpress-popular-posts'), value: 'avg'},
29 {label: __('Comments', 'wordpress-popular-posts'), value: 'comments'}
30 ];
31
32 const timeRangeOptions = [
33 {label: __('Last 24 Hours', 'wordpress-popular-posts'), value: 'last24hours'},
34 {label: __('Last 7 days', 'wordpress-popular-posts'), value: 'last7days'},
35 {label: __('Last 30 days', 'wordpress-popular-posts'), value: 'last30days'},
36 {label: __('All-time', 'wordpress-popular-posts'), value: 'all'},
37 {label: __('Custom', 'wordpress-popular-posts'), value: 'custom'},
38 ];
39
40 const timeUnitOptions = [
41 {label: __('Minute(s)', 'wordpress-popular-posts'), value: 'minute'},
42 {label: __('Hour(s)', 'wordpress-popular-posts'), value: 'hour'},
43 {label: __('Day(s)', 'wordpress-popular-posts'), value: 'day'}
44 ];
45
46 const onTitleChange = (value) => {
47 setAttributes({ title: escape_html(unescape_html(value)) });
48 };
49
50 const onLimitChange = (value) => {
51 setAttributes({ limit: parseInt(value, 10) });
52 };
53
54 const onOrderByChange = (value) => {
55 setAttributes({ order_by: value });
56 };
57
58 const onTimeRangeChange = (value) => {
59 setAttributes({ range: value });
60 };
61
62 const onTimeQuantityChange = (value) => {
63 setAttributes({ time_quantity: parseInt(value, 10) });
64 };
65
66 const onTimeUnitChange = (value) => {
67 setAttributes({ time_unit: value });
68 };
69
70 const onFreshnessChange = (value) => {
71 setAttributes({ freshness: value });
72 };
73
74 return <Fragment>
75 <TextControl
76 label={labelTitle}
77 value={title}
78 onChange={onTitleChange}
79 />
80 <TextControl
81 label={labelLimit}
82 type='number'
83 value={limit}
84 min='1'
85 onChange={onLimitChange}
86 />
87 <SelectControl
88 label={labelSortBy}
89 value={order_by}
90 options={sortingOptions}
91 onChange={onOrderByChange}
92 />
93 <SelectControl
94 label={labelTimeRange}
95 value={range}
96 options={timeRangeOptions}
97 onChange={onTimeRangeChange}
98 />
99 { range === 'custom' &&
100 <div className='option-subset'>
101 <TextControl
102 label={labelTimeQuantity}
103 type='number'
104 value={time_quantity}
105 min='1'
106 onChange={onTimeQuantityChange}
107 />
108 <SelectControl
109 label={labelTimeUnit}
110 value={time_unit}
111 options={timeUnitOptions}
112 onChange={onTimeUnitChange}
113 />
114 </div>
115 }
116 <CheckboxControl
117 label={labelFreshness}
118 checked={freshness}
119 onChange={onFreshnessChange}
120 />
121 </Fragment>;
122 }