PluginProbe
WP Ultimate Post Grid / 3.3.0
WP Ultimate Post Grid v3.3.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 / blocks / Helpers.js

Helpers.js in WP Ultimate Post Grid 3.3.0, at assets/js/blocks/Helpers.js

57 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 const { __ } = wp.i18n;
2 const {
3 Button,
4 PanelBody,
5 TextareaControl,
6 } = wp.components;
7
8 export default {
9 dynamicObjectToString( obj, glue = ' ' ) {
10 let dynamic = [];
11 for ( let key of Object.keys( obj ) ) {
12 if ( key ) {
13 const value = obj[ key ];
14
15 if ( value ) {
16 dynamic.push( `${key}="${ value }"` );
17 }
18 }
19 }
20
21 return dynamic.join( glue );
22 },
23 dynamicSidebar( attributes, setAttributes, type = 'grid' ) {
24 return (
25 <PanelBody title={ 'grid' === type ? __( 'Dynamic Filters' ) : __( 'Default Filter Selections' ) }>
26 <p>
27 {
28 ! wpupg_admin.addons.premium
29 &&
30 <span style={ { color: 'darkred' } }>This feature is only available in WP Ultimate Post Grid Premium.<br/></span>
31 }
32 {
33 'grid' === type
34 ?
35 <a href="https://help.bootstrapped.ventures/article/238-limit-items-dynamically" target="_blank">Learn More</a>
36 :
37 <a href="https://help.bootstrapped.ventures/article/247-default-filter-selections" target="_blank">Learn More</a>
38 }
39 </p>
40 <TextareaControl
41 value={ attributes.dynamic }
42 onChange={( value ) => {
43 // Clean up.
44 value = value.replace( '\n', ' ' );
45 value = value.replace( '\r', ' ' );
46 value = value.replace( ' ', ' ' );
47
48 setAttributes({
49 dynamic: value,
50 });
51 }}
52 />
53 </PanelBody>
54 )
55 }
56 };
57