PluginProbe ʕ •ᴥ•ʔ
WP Popular Posts / 7.4.1
WP Popular Posts v7.4.1
7.4.1 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-html-markup.js
wordpress-popular-posts / src / Block / Widget / edit Last commit date
controls.js 2 months ago edit.js 2 months ago fields-filters.js 2 months ago fields-html-markup.js 1 week ago fields-main.js 2 months ago fields-post-settings.js 2 months ago fields-stats-tag.js 2 months ago
fields-html-markup.js
154 lines
1 const { Fragment } = wp.element;
2 const { CheckboxControl, SelectControl, TextareaControl } = wp.components;
3 const { __ } = wp.i18n;
4
5 export function HTMLMarkupFields({ attributes, setAttributes, themes }) {
6 const {
7 display_post_thumbnail,
8 custom_html,
9 header_start,
10 header_end,
11 wpp_start,
12 wpp_end,
13 post_html,
14 theme
15 } = attributes;
16
17 const defaultHTML = {
18 theme: '',
19 wpp_start: `<ul class="wpp-list${display_post_thumbnail ? ' wpp-list-with-thumbnails' : ''}">`,
20 post_html: '<li class="{current_class}">{thumb} {title} <span class="wpp-meta post-stats">{stats}</span></li>',
21 wpp_end: '</ul>'
22 };
23
24 const labelUseCustomHTML = __('Use custom HTML Markup', 'wordpress-popular-posts');
25 const labelBeforeTitle = __('Before title', 'wordpress-popular-posts');
26 const labelAfterTitle = __('After title', 'wordpress-popular-posts');
27 const labelBeforePosts = __('Before popular posts', 'wordpress-popular-posts');
28 const labelAfterPosts = __('After popular posts', 'wordpress-popular-posts');
29 const labelPostHTMLMarkup = __('Post HTML markup', 'wordpress-popular-posts');
30 const labelContentTagsList = __('Content Tags List', 'wordpress-popular-posts');
31 const labelTheme = __('Theme', 'wordpress-popular-posts');
32
33 const themeOptions = [
34 { label: __('None', 'wordpress-popular-posts'), value: '' }
35 ];
36
37 if ( themes ) {
38 for ( const t in themes ) {
39 if ( themes.hasOwnProperty(t) ) {
40 themeOptions.push({ label: themes[t].json.name, value: t });
41 }
42 }
43 }
44
45 const onUseCustomHTMLChange = (isChecked) => {
46 setAttributes({
47 custom_html: isChecked,
48 ...(!isChecked && defaultHTML)
49 });
50 };
51
52 const onBeforeTitleChange = (value) => {
53 setAttributes({ header_start: value });
54 };
55
56 const onAfterTitleChange = (value) => {
57 setAttributes({ header_end: value });
58 };
59
60 const onBeforePostsChange = (value) => {
61 setAttributes({ wpp_start: value });
62 };
63
64 const onAfterPostsChange = (value) => {
65 setAttributes({ wpp_end: value });
66 };
67
68 const onPostHTMLMarkupChange = (value) => {
69 setAttributes({ post_html: value });
70 };
71
72 const onThemeChange = (value) => {
73 if ( themes && typeof themes[value] !== 'undefined' ) {
74 const config = themes[value].json.config;
75
76 setAttributes({
77 shorten_title: config.shorten_title.active,
78 title_length: config.shorten_title.length,
79 title_by_words: config.shorten_title.words ? 1 : 0,
80 display_post_excerpt: config['post-excerpt'].active,
81 excerpt_format: config['post-excerpt'].format,
82 excerpt_length: config['post-excerpt'].length,
83 excerpt_by_words: config['post-excerpt'].words ? 1 : 0,
84 display_post_thumbnail: config.thumbnail.active,
85 thumbnail_build: config.thumbnail.build,
86 thumbnail_width: config.thumbnail.width,
87 thumbnail_height: config.thumbnail.height,
88 stats_comments: config.stats_tag.comment_count,
89 stats_views: config.stats_tag.views,
90 stats_author: config.stats_tag.author,
91 stats_date: config.stats_tag.date.active,
92 stats_date_format: config.stats_tag.date.format,
93 stats_taxonomy: config.stats_tag.taxonomy.active,
94 taxonomy: config.stats_tag.taxonomy.name,
95 custom_html: true,
96 wpp_start: config.markup['wpp-start'],
97 wpp_end: config.markup['wpp-end'],
98 post_html: config.markup['post-html'],
99 theme: value
100 });
101 } else {
102 setAttributes(defaultHTML);
103 }
104 };
105
106 return <Fragment>
107 <p className='not-a-legend'><strong>{__('HTML Markup settings', 'wordpress-popular-posts')}</strong> <small>(<a href="https://github.com/cabrerahector/wordpress-popular-posts/wiki/5.-FAQ#how-can-i-use-my-own-html-markup-with-your-plugin" target="_blank">{__('What is this?', 'wordpress-popular-posts')}</a>)</small></p>
108 <CheckboxControl
109 label={labelUseCustomHTML}
110 checked={custom_html}
111 onChange={onUseCustomHTMLChange}
112 />
113 { custom_html &&
114 <div className='option-subset'>
115 <TextareaControl
116 rows="1"
117 label={labelBeforeTitle}
118 value={header_start}
119 onChange={onBeforeTitleChange}
120 />
121 <TextareaControl
122 rows="1"
123 label={labelAfterTitle}
124 value={header_end}
125 onChange={onAfterTitleChange}
126 />
127 <TextareaControl
128 rows="1"
129 label={labelBeforePosts}
130 value={wpp_start}
131 onChange={onBeforePostsChange}
132 />
133 <TextareaControl
134 rows="1"
135 label={labelAfterPosts}
136 value={wpp_end}
137 onChange={onAfterPostsChange}
138 />
139 <TextareaControl
140 label={labelPostHTMLMarkup}
141 value={post_html}
142 onChange={onPostHTMLMarkupChange}
143 />
144 <small><a href="https://github.com/cabrerahector/wordpress-popular-posts/wiki/2.-Template-tags#content-tags" target="_blank">{labelContentTagsList}</a></small>
145 </div>
146 }
147 <SelectControl
148 label={labelTheme}
149 value={theme}
150 options={themeOptions}
151 onChange={onThemeChange}
152 />
153 </Fragment>;
154 }