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