Version Description
- Added Ditty widget block
- Added functionality to convert classic widget to block
Download this release
Release Info
Developer | metaphorcreations |
Plugin | Ditty News Ticker |
Version | 3.0.28 |
Comparing to | |
See all releases |
Code changes from version 3.0.27 to 3.0.28
- blocks/ditty-block/icon.js +0 -14
- blocks/ditty-block/index.js +0 -150
- blocks/ditty-block/index.php +0 -36
- blocks/frontend.js +0 -0
- blocks/i18n.js +0 -1
- blocks/index.js +0 -2
- build/blocks/ditty/block.json +37 -0
- build/blocks/ditty/index.asset.php +1 -0
- build/blocks/ditty/index.css +1 -0
- build/blocks/ditty/index.js +1 -0
- build/blocks/ditty/style-index.css +1 -0
- ditty-news-ticker.php +2 -2
- includes/class-ditty.php +5 -54
- includes/css/ditty.css +1 -0
- includes/helpers.php +2 -0
- includes/hooks.php +1 -1
- includes/js/ditty.js +5 -4
- includes/js/ditty.min.js +1 -1
- includes/js/editor.blocks.js +0 -86
- includes/js/editor.blocks.min.js +0 -1
- includes/js/frontend.blocks.js +0 -75
- includes/js/frontend.blocks.min.js +0 -75
- includes/sass/partials/_general.scss +1 -0
- includes/widget.php +18 -9
- readme.txt +7 -3
- src/blocks/ditty/block.json +32 -0
- src/blocks/ditty/edit.js +156 -0
- {blocks/ditty-block → src/blocks/ditty}/editor.scss +11 -18
- src/blocks/ditty/icon.js +62 -0
- src/blocks/ditty/index.js +45 -0
- src/blocks/ditty/index.php +35 -0
- src/blocks/ditty/save.js +19 -0
- blocks/ditty-block/style.scss → src/blocks/ditty/script.js +0 -0
- src/blocks/ditty/style.scss +6 -0
blocks/ditty-block/icon.js
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
const icons = {}
|
2 |
-
icons.iconBlack = <svg class="ditty-logo ditty-icon--black" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 69.8 71.1"><path d="M0 46.4c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V0H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 71.1 0 58.4 0 46.4Zm31.2 7.4V28.6a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM54.7 63.7a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z"/></svg>;
|
3 |
-
|
4 |
-
icons.iconWhite= <svg class="ditty-logo ditty-icon--white" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 69.8 71.1"><path d="M0 46.4c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V0H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 71.1 0 58.4 0 46.4Zm31.2 7.4V28.6a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM54.7 63.7a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z"/></svg>;
|
5 |
-
|
6 |
-
icons.iconGreen = <svg class="ditty-logo ditty-icon--green" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 69.8 71.1"><path d="M0 46.4c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V0H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 71.1 0 58.4 0 46.4Zm31.2 7.4V28.6a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM54.7 63.7a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z"/></svg>;
|
7 |
-
|
8 |
-
icons.logoBlack = <svg class="ditty-logo ditty-logo--black" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 258.8 99.21"><path d="M0 49.5c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V3.1H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 74.2 0 61.5 0 49.5Zm31.2 7.4V31.7a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM55.7 7.4A7.33 7.33 0 0 1 63.4 0c4.6 0 7.8 3.3 7.8 7.4s-3.2 7.4-7.8 7.4-7.7-3.1-7.7-7.4Zm14.8 14.5v50.7H56.4V21.9ZM95.8 3.1v18.8H112V3.1h14.1v18.8h13v10.9h-13v23.1c0 5.9 2.6 7.6 6.4 7.6a11.9 11.9 0 0 0 6.1-1.9l3.2 9c-3 2-8.2 3.5-13.3 3.5-15.2 0-16.5-8.7-16.5-17.8V32.8H95.8v23.1c0 5.9 2 7.6 5.7 7.6a11.64 11.64 0 0 0 5.7-1.6l2.1 9.4c-2.6 1.7-7.4 2.8-11.1 2.8-15.1 0-16.4-8.7-16.4-17.8V3.1ZM149.6 85.81c0-7.21 4.4-12.81 10.3-17.11-8.4-1.3-13-5.9-13-16V21.9h14v29.7c0 5.4.5 9.1 7 9.1 4 0 7.7-3.2 7.7-8.3V21.9h14v42.3a108.13 108.13 0 0 1-.9 13.9c-1.5 13.5-8.9 21.11-22.4 21.11-11.1 0-16.7-5.21-16.7-13.4Zm26.3-9.11v-9.5c-7.4 3.5-14 8.5-14 16.11 0 3.9 2.2 5.79 6 5.79 5.9 0 8-4.7 8-12.4ZM198.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM221.2 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM243.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z"/></svg>;
|
9 |
-
|
10 |
-
icons.logoWhite = <svg class="ditty-logo ditty-logo--white" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 258.8 99.21"><path d="M0 49.5c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V3.1H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 74.2 0 61.5 0 49.5Zm31.2 7.4V31.7a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM55.7 7.4A7.33 7.33 0 0 1 63.4 0c4.6 0 7.8 3.3 7.8 7.4s-3.2 7.4-7.8 7.4-7.7-3.1-7.7-7.4Zm14.8 14.5v50.7H56.4V21.9ZM95.8 3.1v18.8H112V3.1h14.1v18.8h13v10.9h-13v23.1c0 5.9 2.6 7.6 6.4 7.6a11.9 11.9 0 0 0 6.1-1.9l3.2 9c-3 2-8.2 3.5-13.3 3.5-15.2 0-16.5-8.7-16.5-17.8V32.8H95.8v23.1c0 5.9 2 7.6 5.7 7.6a11.64 11.64 0 0 0 5.7-1.6l2.1 9.4c-2.6 1.7-7.4 2.8-11.1 2.8-15.1 0-16.4-8.7-16.4-17.8V3.1ZM149.6 85.81c0-7.21 4.4-12.81 10.3-17.11-8.4-1.3-13-5.9-13-16V21.9h14v29.7c0 5.4.5 9.1 7 9.1 4 0 7.7-3.2 7.7-8.3V21.9h14v42.3a108.13 108.13 0 0 1-.9 13.9c-1.5 13.5-8.9 21.11-22.4 21.11-11.1 0-16.7-5.21-16.7-13.4Zm26.3-9.11v-9.5c-7.4 3.5-14 8.5-14 16.11 0 3.9 2.2 5.79 6 5.79 5.9 0 8-4.7 8-12.4ZM198.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM221.2 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM243.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z"/></svg>;
|
11 |
-
|
12 |
-
icons.logoGreen = <svg class="ditty-logo ditty-logo--green" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 258.8 99.21"><path d="M0 49.5c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V3.1H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 74.2 0 61.5 0 49.5Zm31.2 7.4V31.7a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM55.7 7.4A7.33 7.33 0 0 1 63.4 0c4.6 0 7.8 3.3 7.8 7.4s-3.2 7.4-7.8 7.4-7.7-3.1-7.7-7.4Zm14.8 14.5v50.7H56.4V21.9ZM95.8 3.1v18.8H112V3.1h14.1v18.8h13v10.9h-13v23.1c0 5.9 2.6 7.6 6.4 7.6a11.9 11.9 0 0 0 6.1-1.9l3.2 9c-3 2-8.2 3.5-13.3 3.5-15.2 0-16.5-8.7-16.5-17.8V32.8H95.8v23.1c0 5.9 2 7.6 5.7 7.6a11.64 11.64 0 0 0 5.7-1.6l2.1 9.4c-2.6 1.7-7.4 2.8-11.1 2.8-15.1 0-16.4-8.7-16.4-17.8V3.1ZM149.6 85.81c0-7.21 4.4-12.81 10.3-17.11-8.4-1.3-13-5.9-13-16V21.9h14v29.7c0 5.4.5 9.1 7 9.1 4 0 7.7-3.2 7.7-8.3V21.9h14v42.3a108.13 108.13 0 0 1-.9 13.9c-1.5 13.5-8.9 21.11-22.4 21.11-11.1 0-16.7-5.21-16.7-13.4Zm26.3-9.11v-9.5c-7.4 3.5-14 8.5-14 16.11 0 3.9 2.2 5.79 6 5.79 5.9 0 8-4.7 8-12.4ZM198.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM221.2 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM243.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z"/></svg>;
|
13 |
-
|
14 |
-
export default icons;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
blocks/ditty-block/index.js
DELETED
@@ -1,150 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* Block dependencies
|
3 |
-
*/
|
4 |
-
import icons from './icon';
|
5 |
-
import './style.scss';
|
6 |
-
import './editor.scss';
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Internal block libraries
|
10 |
-
*/
|
11 |
-
const { __, sprintf } = wp.i18n;
|
12 |
-
const { registerBlockType } = wp.blocks;
|
13 |
-
const { InspectorControls } = wp.blockEditor;
|
14 |
-
const { Fragment } = wp.element;
|
15 |
-
const { PanelBody, PanelRow, SelectControl, Spinner } = wp.components;
|
16 |
-
const { withSelect } = wp.data;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Register block
|
20 |
-
*/
|
21 |
-
export default registerBlockType(
|
22 |
-
'metaphorcreations/ditty-block',
|
23 |
-
{
|
24 |
-
title: __( 'Ditty', 'ditty-news-ticker' ),
|
25 |
-
description: __( 'Display your Ditty within the content of the post.', 'ditty-news-ticker' ),
|
26 |
-
category: 'widgets',
|
27 |
-
icon: {
|
28 |
-
//background: '#39b44a',
|
29 |
-
src: icons.iconGreen,
|
30 |
-
},
|
31 |
-
keywords: [
|
32 |
-
__( 'Ticker', 'ditty-news-ticker' ),
|
33 |
-
__( 'Display', 'ditty-news-ticker' ),
|
34 |
-
__( 'Content', 'ditty-news-ticker' ),
|
35 |
-
],
|
36 |
-
supports: {
|
37 |
-
html: false,
|
38 |
-
},
|
39 |
-
attributes: {
|
40 |
-
ditty: {
|
41 |
-
type: 'string',
|
42 |
-
},
|
43 |
-
display: {
|
44 |
-
type: 'string',
|
45 |
-
}
|
46 |
-
},
|
47 |
-
edit: withSelect( select => {
|
48 |
-
const { getEntityRecords } = select( 'core' );
|
49 |
-
return {
|
50 |
-
dittys: getEntityRecords( 'postType', 'ditty-news-ticker', { per_page: -1 } ),
|
51 |
-
};
|
52 |
-
} )( ( { attributes: { ditty, display }, dittys, className, isSelected, setAttributes } ) => {
|
53 |
-
|
54 |
-
let ditty_posts = null;
|
55 |
-
if ( dittys ) {
|
56 |
-
ditty_posts = dittys.map( ditty_post => {
|
57 |
-
return ( { key: ditty_post.id, value: ditty_post.id, label: ditty_post.title.raw } );
|
58 |
-
} );
|
59 |
-
ditty_posts.unshift( { key: 'selectDittyTicker', value: '', label: __( 'Select a Ticker', 'ditty-news-ticker' ) } );
|
60 |
-
}
|
61 |
-
|
62 |
-
const display_posts = dittyBlocksEditorVars.displays.map( data => {
|
63 |
-
const value = data.type_id + '--' + data.display_id;
|
64 |
-
const label = data.display_label + ' (' + data.type_label + ')';
|
65 |
-
return ( { key: value, value: value, label: label } );
|
66 |
-
} );
|
67 |
-
display_posts.unshift( { key: 'useDefaultDisplay', value: '', label: __( 'Use Default Display', 'ditty-news-ticker' ) } );
|
68 |
-
|
69 |
-
let currentDisplay = '';
|
70 |
-
if ( display ) {
|
71 |
-
for ( let i = 0; i < display_posts.length; i++ ) {
|
72 |
-
if ( display === display_posts[i].value ) {
|
73 |
-
currentDisplay = display_posts[i].label;
|
74 |
-
}
|
75 |
-
}
|
76 |
-
}
|
77 |
-
if ( '' === currentDisplay ) {
|
78 |
-
currentDisplay = 'Default Display';
|
79 |
-
}
|
80 |
-
|
81 |
-
return [
|
82 |
-
<InspectorControls key='dittySelectTicker'>
|
83 |
-
<PanelBody>
|
84 |
-
{ ditty_posts
|
85 |
-
?
|
86 |
-
<SelectControl
|
87 |
-
label={ __( 'Ditty', 'ditty-news-ticker' ) }
|
88 |
-
value={ ditty }
|
89 |
-
options={ ditty_posts }
|
90 |
-
onChange={ ditty => setAttributes( { ditty } ) }
|
91 |
-
/>
|
92 |
-
:
|
93 |
-
<Fragment><Spinner />{ __( 'Loading Tickers', 'ditty-news-ticker' ) }</Fragment>
|
94 |
-
}
|
95 |
-
{ display_posts
|
96 |
-
?
|
97 |
-
<SelectControl
|
98 |
-
label={ __( 'Display', 'ditty-news-ticker' ) }
|
99 |
-
value={ display }
|
100 |
-
options={ display_posts }
|
101 |
-
onChange={ display => setAttributes( { display } ) }
|
102 |
-
/>
|
103 |
-
:
|
104 |
-
<Fragment><Spinner />{ __( 'Loading Displays', 'ditty-news-ticker' ) }</Fragment>
|
105 |
-
}
|
106 |
-
</PanelBody>
|
107 |
-
</InspectorControls>,
|
108 |
-
<div key="dittyBlockViewTicker" className={ className }>
|
109 |
-
{
|
110 |
-
( ! ditty || isSelected ) ?
|
111 |
-
<Fragment>
|
112 |
-
<div className="wp-block-metaphorcreations-ditty-block__info">
|
113 |
-
{icons.logoBlack}
|
114 |
-
<div className="wp-block-metaphorcreations-ditty-block__vals">{ __( 'ID:', 'ditty-news-ticker' ) } <strong>{ ditty }</strong></div>
|
115 |
-
<div className="wp-block-metaphorcreations-ditty-block__vals">{ __( 'Display:', 'ditty-news-ticker' ) } <strong>{ currentDisplay }</strong></div>
|
116 |
-
</div>
|
117 |
-
<div className="wp-block-metaphorcreations-ditty-block__controls">
|
118 |
-
<SelectControl
|
119 |
-
label={ __( 'ID:', 'ditty-news-ticker' ) }
|
120 |
-
labelPosition = 'side'
|
121 |
-
value={ ditty }
|
122 |
-
options={ ditty_posts }
|
123 |
-
onChange={ ditty => setAttributes( { ditty } ) }
|
124 |
-
/>
|
125 |
-
<SelectControl
|
126 |
-
label={ __( 'Display:', 'ditty-news-ticker' ) }
|
127 |
-
labelPosition = 'side'
|
128 |
-
value={ display }
|
129 |
-
options={ display_posts }
|
130 |
-
onChange={ display => setAttributes( { display } ) }
|
131 |
-
/>
|
132 |
-
</div>
|
133 |
-
</Fragment>
|
134 |
-
: (
|
135 |
-
<div className="wp-block-metaphorcreations-ditty-block__info">
|
136 |
-
{icons.logoBlack}
|
137 |
-
<div className="wp-block-metaphorcreations-ditty-block__vals">{ __( 'ID:', 'ditty-news-ticker' ) } <strong>{ ditty }</strong></div>
|
138 |
-
<div className="wp-block-metaphorcreations-ditty-block__vals">{ __( 'Display:', 'ditty-news-ticker' ) } <strong>{ currentDisplay }</strong></div>
|
139 |
-
</div>
|
140 |
-
)
|
141 |
-
|
142 |
-
}
|
143 |
-
</div>
|
144 |
-
];
|
145 |
-
} ), // end edit
|
146 |
-
save: props => {
|
147 |
-
return null;
|
148 |
-
},
|
149 |
-
},
|
150 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
blocks/ditty-block/index.php
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Metaphor_Creations\Ditty\Blocks\Ditty_Block;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Register the dynamic block.
|
7 |
-
*
|
8 |
-
* @since 1.0
|
9 |
-
* @return void
|
10 |
-
*/
|
11 |
-
function register_dynamic_block() {
|
12 |
-
if ( ! function_exists( 'register_block_type' ) ) {
|
13 |
-
return;
|
14 |
-
}
|
15 |
-
|
16 |
-
// Hook server side rendering into render callback
|
17 |
-
register_block_type( 'metaphorcreations/ditty-block', [
|
18 |
-
'render_callback' => __NAMESPACE__ . '\render_dynamic_block',
|
19 |
-
] );
|
20 |
-
}
|
21 |
-
add_action( 'plugins_loaded', __NAMESPACE__ . '\register_dynamic_block' );
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Server rendering for /blocks/examples/12-dynamic
|
25 |
-
*/
|
26 |
-
function render_dynamic_block( $atts ) {
|
27 |
-
if ( is_admin() ) {
|
28 |
-
return false;
|
29 |
-
}
|
30 |
-
$args = array(
|
31 |
-
'id' => isset( $atts['ditty'] ) ? intval( $atts['ditty'] ) : false,
|
32 |
-
'display' => isset( $atts['display'] ) ? sanitize_text_field( $atts['display'] ) : false,
|
33 |
-
'class' => isset( $atts['className'] ) ? sanitize_text_field( $atts['className'] ) : false,
|
34 |
-
);
|
35 |
-
return ditty_render( $args );
|
36 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
blocks/frontend.js
DELETED
File without changes
|
blocks/i18n.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
wp.i18n.setLocaleData( { '': {} }, 'ditty' );
|
|
blocks/index.js
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
import './i18n.js';
|
2 |
-
import './ditty-block';
|
|
|
|
build/blocks/ditty/block.json
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"apiVersion": 2,
|
3 |
+
"name": "metaphorcreations/ditty",
|
4 |
+
"version": "0.1.0",
|
5 |
+
"title": "Ditty",
|
6 |
+
"description": "Display your Ditty within the content of the post.",
|
7 |
+
"category": "widgets",
|
8 |
+
"icon": "smiley",
|
9 |
+
"keywords": [
|
10 |
+
"ticker",
|
11 |
+
"list",
|
12 |
+
"slider",
|
13 |
+
"display",
|
14 |
+
"content"
|
15 |
+
],
|
16 |
+
"supports": {
|
17 |
+
"html": false
|
18 |
+
},
|
19 |
+
"textdomain": "ditty",
|
20 |
+
"attributes": {
|
21 |
+
"ditty": {
|
22 |
+
"type": "integer"
|
23 |
+
},
|
24 |
+
"display": {
|
25 |
+
"type": "integer"
|
26 |
+
},
|
27 |
+
"customID": {
|
28 |
+
"type": "string"
|
29 |
+
},
|
30 |
+
"customClasses": {
|
31 |
+
"type": "string"
|
32 |
+
}
|
33 |
+
},
|
34 |
+
"editorScript": "file:./index.js",
|
35 |
+
"editorStyle": "file:./index.css",
|
36 |
+
"style": "file:./style-index.css"
|
37 |
+
}
|
build/blocks/ditty/index.asset.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php return array('dependencies' => array('wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '20b955d6f2f24fc9c725');
|
build/blocks/ditty/index.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.wp-block-metaphorcreations-ditty{border:2px solid #39b44a}.wp-block-metaphorcreations-ditty .ditty-logo{margin-bottom:15px;width:100px}.wp-block-metaphorcreations-ditty__contents{background:hsla(0,0%,100%,.8);padding:20px}.wp-block-metaphorcreations-ditty__info{align-items:center;display:flex;flex-direction:row;justify-content:flex-start}.wp-block-metaphorcreations-ditty__vals{background:#39b44a;border-radius:3px;color:#fff;font-size:14px;margin-right:5px;padding:5px 10px}.wp-block-metaphorcreations-ditty__controls label{font-weight:700;width:60px}.wp-block-metaphorcreations-ditty select{padding-bottom:0!important;padding-top:0!important}
|
build/blocks/ditty/index.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
(()=>{"use strict";var e,t={479:(e,t,a)=>{const l=window.wp.blocks,c=window.wp.element,n=window.wp.i18n,s=window.wp.blockEditor,i=window.wp.components,o=window.wp.apiFetch;var r=a.n(o);const d={};d.iconBlack=(0,c.createElement)("svg",{className:"ditty-logo ditty-icon--black",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 69.8 71.1"},(0,c.createElement)("path",{d:"M0 46.4c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V0H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 71.1 0 58.4 0 46.4Zm31.2 7.4V28.6a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM54.7 63.7a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z"})),d.iconWhite=(0,c.createElement)("svg",{className:"ditty-logo ditty-icon--white",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 69.8 71.1"},(0,c.createElement)("path",{d:"M0 46.4c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V0H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 71.1 0 58.4 0 46.4Zm31.2 7.4V28.6a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM54.7 63.7a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z"})),d.iconGreen=(0,c.createElement)("svg",{className:"ditty-logo ditty-icon--green",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 69.8 71.1"},(0,c.createElement)("path",{d:"M0 46.4c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V0H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 71.1 0 58.4 0 46.4Zm31.2 7.4V28.6a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM54.7 63.7a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z"})),d.logoBlack=(0,c.createElement)("svg",{className:"ditty-logo ditty-logo--black",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 258.8 99.21"},(0,c.createElement)("path",{d:"M0 49.5c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V3.1H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 74.2 0 61.5 0 49.5Zm31.2 7.4V31.7a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM55.7 7.4A7.33 7.33 0 0 1 63.4 0c4.6 0 7.8 3.3 7.8 7.4s-3.2 7.4-7.8 7.4-7.7-3.1-7.7-7.4Zm14.8 14.5v50.7H56.4V21.9ZM95.8 3.1v18.8H112V3.1h14.1v18.8h13v10.9h-13v23.1c0 5.9 2.6 7.6 6.4 7.6a11.9 11.9 0 0 0 6.1-1.9l3.2 9c-3 2-8.2 3.5-13.3 3.5-15.2 0-16.5-8.7-16.5-17.8V32.8H95.8v23.1c0 5.9 2 7.6 5.7 7.6a11.64 11.64 0 0 0 5.7-1.6l2.1 9.4c-2.6 1.7-7.4 2.8-11.1 2.8-15.1 0-16.4-8.7-16.4-17.8V3.1ZM149.6 85.81c0-7.21 4.4-12.81 10.3-17.11-8.4-1.3-13-5.9-13-16V21.9h14v29.7c0 5.4.5 9.1 7 9.1 4 0 7.7-3.2 7.7-8.3V21.9h14v42.3a108.13 108.13 0 0 1-.9 13.9c-1.5 13.5-8.9 21.11-22.4 21.11-11.1 0-16.7-5.21-16.7-13.4Zm26.3-9.11v-9.5c-7.4 3.5-14 8.5-14 16.11 0 3.9 2.2 5.79 6 5.79 5.9 0 8-4.7 8-12.4ZM198.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM221.2 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM243.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z"})),d.logoWhite=(0,c.createElement)("svg",{className:"ditty-logo ditty-logo--white",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 258.8 99.21"},(0,c.createElement)("path",{d:"M0 49.5c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V3.1H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 74.2 0 61.5 0 49.5Zm31.2 7.4V31.7a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM55.7 7.4A7.33 7.33 0 0 1 63.4 0c4.6 0 7.8 3.3 7.8 7.4s-3.2 7.4-7.8 7.4-7.7-3.1-7.7-7.4Zm14.8 14.5v50.7H56.4V21.9ZM95.8 3.1v18.8H112V3.1h14.1v18.8h13v10.9h-13v23.1c0 5.9 2.6 7.6 6.4 7.6a11.9 11.9 0 0 0 6.1-1.9l3.2 9c-3 2-8.2 3.5-13.3 3.5-15.2 0-16.5-8.7-16.5-17.8V32.8H95.8v23.1c0 5.9 2 7.6 5.7 7.6a11.64 11.64 0 0 0 5.7-1.6l2.1 9.4c-2.6 1.7-7.4 2.8-11.1 2.8-15.1 0-16.4-8.7-16.4-17.8V3.1ZM149.6 85.81c0-7.21 4.4-12.81 10.3-17.11-8.4-1.3-13-5.9-13-16V21.9h14v29.7c0 5.4.5 9.1 7 9.1 4 0 7.7-3.2 7.7-8.3V21.9h14v42.3a108.13 108.13 0 0 1-.9 13.9c-1.5 13.5-8.9 21.11-22.4 21.11-11.1 0-16.7-5.21-16.7-13.4Zm26.3-9.11v-9.5c-7.4 3.5-14 8.5-14 16.11 0 3.9 2.2 5.79 6 5.79 5.9 0 8-4.7 8-12.4ZM198.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM221.2 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM243.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z"})),d.logoGreen=(0,c.createElement)("svg",{className:"ditty-logo ditty-logo--green",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 258.8 99.21"},(0,c.createElement)("path",{d:"M0 49.5c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V3.1H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 74.2 0 61.5 0 49.5Zm31.2 7.4V31.7a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM55.7 7.4A7.33 7.33 0 0 1 63.4 0c4.6 0 7.8 3.3 7.8 7.4s-3.2 7.4-7.8 7.4-7.7-3.1-7.7-7.4Zm14.8 14.5v50.7H56.4V21.9ZM95.8 3.1v18.8H112V3.1h14.1v18.8h13v10.9h-13v23.1c0 5.9 2.6 7.6 6.4 7.6a11.9 11.9 0 0 0 6.1-1.9l3.2 9c-3 2-8.2 3.5-13.3 3.5-15.2 0-16.5-8.7-16.5-17.8V32.8H95.8v23.1c0 5.9 2 7.6 5.7 7.6a11.64 11.64 0 0 0 5.7-1.6l2.1 9.4c-2.6 1.7-7.4 2.8-11.1 2.8-15.1 0-16.4-8.7-16.4-17.8V3.1ZM149.6 85.81c0-7.21 4.4-12.81 10.3-17.11-8.4-1.3-13-5.9-13-16V21.9h14v29.7c0 5.4.5 9.1 7 9.1 4 0 7.7-3.2 7.7-8.3V21.9h14v42.3a108.13 108.13 0 0 1-.9 13.9c-1.5 13.5-8.9 21.11-22.4 21.11-11.1 0-16.7-5.21-16.7-13.4Zm26.3-9.11v-9.5c-7.4 3.5-14 8.5-14 16.11 0 3.9 2.2 5.79 6 5.79 5.9 0 8-4.7 8-12.4ZM198.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM221.2 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM243.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z"}));const v=d;(0,l.registerBlockType)("metaphorcreations/ditty",{version:Date.now(),icon:{src:v.iconGreen},transforms:{from:[{type:"block",blocks:["core/legacy-widget"],isMatch:e=>{let{idBase:t,instance:a}=e;return!(null==a||!a.raw)&&"ditty-widget"===t},transform:e=>{let{instance:t}=e;const a=[(0,l.createBlock)("metaphorcreations/ditty",{ditty:t.raw.ditty,display:t.raw.display})];return t.raw.title&&a.unshift((0,l.createBlock)("core/heading",{content:t.raw.title})),a}}]},edit:function(e){let{isSelected:t,setAttributes:a,attributes:l}=e;const{ditty:o,display:d,customID:m,customClasses:w}=l,[y,u]=(0,c.useState)([]),[p,h]=(0,c.useState)([]),g=y.map((e=>({key:e.id,value:e.id,label:e.title.rendered})));g.unshift({key:0,value:0,label:(0,n.__)("No Ditty Selected","ditty-news-ticker")});const Z=p.map((e=>({key:e.id,value:e.id,label:e.title.rendered})));Z.unshift({key:0,value:0,label:(0,n.__)("Use Default Display","ditty-news-ticker")});const k=g.filter((e=>e.value===o)),b=k[0]?k[0].label:"",_=Z.filter((e=>e.value===d)),E=_[0]?_[0].label:"",f="wp-block-metaphorcreations-ditty";return(0,c.useEffect)((()=>{!async function(){const e=await r()({path:"/wp/v2/ditty"});u(e)}(),async function(){const e=await r()({path:"/wp/v2/ditty_display"});h(e)}()}),[]),(0,c.createElement)("div",(0,s.useBlockProps)(),(0,c.createElement)(s.InspectorControls,{key:"dittySelectTicker"},(0,c.createElement)(i.PanelBody,null,g?(0,c.createElement)(i.SelectControl,{label:(0,n.__)("Ditty","ditty-news-ticker"),value:o,options:g,onChange:e=>a({ditty:Number(e)})}):(0,c.createElement)(c.Fragment,null,(0,c.createElement)(i.Spinner,null),(0,n.__)("Loading Tickers","ditty-news-ticker")),Z?(0,c.createElement)(i.SelectControl,{label:(0,n.__)("Display","ditty-news-ticker"),value:d,options:Z,onChange:e=>a({display:Number(e)})}):(0,c.createElement)(c.Fragment,null,(0,c.createElement)(i.Spinner,null),(0,n.__)("Loading Displays","ditty-news-ticker")),(0,c.createElement)(i.TextControl,{label:(0,n.__)("Custom ID","ditty-news-ticker"),value:m,onChange:e=>a({customID:e})}),(0,c.createElement)(i.TextControl,{label:(0,n.__)("Custom Classes","ditty-news-ticker"),value:w,onChange:e=>a({customClasses:e})}))),(0,c.createElement)("div",{className:`${f}__contents`},v.logoBlack,!t&&(0,c.createElement)("div",{className:`${f}__info`},(0,c.createElement)("div",{className:`${f}__vals`},(0,n.__)("ID:","ditty-news-ticker")," ",(0,c.createElement)("strong",null,b)),(0,c.createElement)("div",{className:`${f}__vals`},(0,n.__)("Display:","ditty-news-ticker")," ",(0,c.createElement)("strong",null,E))),t&&(0,c.createElement)("div",{className:`${f}__controls`},(0,c.createElement)(i.SelectControl,{label:(0,n.__)("ID:","ditty-news-ticker"),labelPosition:"side",value:o,options:g,onChange:e=>a({ditty:Number(e)})}),(0,c.createElement)(i.SelectControl,{label:(0,n.__)("Display:","ditty-news-ticker"),labelPosition:"side",value:d,options:Z,onChange:e=>a({display:Number(e)})}))))},save:function(e){let{attributes:t}=e;return null}})}},a={};function l(e){var c=a[e];if(void 0!==c)return c.exports;var n=a[e]={exports:{}};return t[e](n,n.exports,l),n.exports}l.m=t,e=[],l.O=(t,a,c,n)=>{if(!a){var s=1/0;for(d=0;d<e.length;d++){a=e[d][0],c=e[d][1],n=e[d][2];for(var i=!0,o=0;o<a.length;o++)(!1&n||s>=n)&&Object.keys(l.O).every((e=>l.O[e](a[o])))?a.splice(o--,1):(i=!1,n<s&&(s=n));if(i){e.splice(d--,1);var r=c();void 0!==r&&(t=r)}}return t}n=n||0;for(var d=e.length;d>0&&e[d-1][2]>n;d--)e[d]=e[d-1];e[d]=[a,c,n]},l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},l.d=(e,t)=>{for(var a in t)l.o(t,a)&&!l.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={335:0,880:0};l.O.j=t=>0===e[t];var t=(t,a)=>{var c,n,s=a[0],i=a[1],o=a[2],r=0;if(s.some((t=>0!==e[t]))){for(c in i)l.o(i,c)&&(l.m[c]=i[c]);if(o)var d=o(l)}for(t&&t(a);r<s.length;r++)n=s[r],l.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return l.O(d)},a=self.webpackChunkditty=self.webpackChunkditty||[];a.forEach(t.bind(null,0)),a.push=t.bind(null,a.push.bind(a))})();var c=l.O(void 0,[880],(()=>l(479)));c=l.O(c)})();
|
build/blocks/ditty/style-index.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
|
ditty-news-ticker.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Ditty
|
5 |
* Plugin URI: https://www.metaphorcreations.com/ditty
|
6 |
* Description: Formerly Ditty News Ticker, Ditty is a multi-functional content display WordPress plugin.
|
7 |
-
* Version: 3.0.
|
8 |
* Author: Metaphor Creations
|
9 |
* Author URI: https://www.metaphorcreations.com
|
10 |
* License: GPL-2.0+
|
@@ -20,7 +20,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
20 |
|
21 |
// Plugin version.
|
22 |
if ( ! defined( 'DITTY_VERSION' ) ) {
|
23 |
-
define( 'DITTY_VERSION', '3.0.
|
24 |
}
|
25 |
|
26 |
// Plugin Folder Path.
|
4 |
* Plugin Name: Ditty
|
5 |
* Plugin URI: https://www.metaphorcreations.com/ditty
|
6 |
* Description: Formerly Ditty News Ticker, Ditty is a multi-functional content display WordPress plugin.
|
7 |
+
* Version: 3.0.28
|
8 |
* Author: Metaphor Creations
|
9 |
* Author URI: https://www.metaphorcreations.com
|
10 |
* License: GPL-2.0+
|
20 |
|
21 |
// Plugin version.
|
22 |
if ( ! defined( 'DITTY_VERSION' ) ) {
|
23 |
+
define( 'DITTY_VERSION', '3.0.28' );
|
24 |
}
|
25 |
|
26 |
// Plugin Folder Path.
|
includes/class-ditty.php
CHANGED
@@ -317,7 +317,7 @@ class Ditty {
|
|
317 |
require_once DITTY_DIR . 'includes/class-ditty-singles.php';
|
318 |
require_once DITTY_DIR . 'includes/class-ditty-wpml.php';
|
319 |
|
320 |
-
|
321 |
|
322 |
if ( is_admin() ) {
|
323 |
if ( ! class_exists( 'Ditty_Plugin_Updater' ) ) {
|
@@ -368,8 +368,6 @@ class Ditty {
|
|
368 |
$this->loader->add_action( 'wp_enqueue_scripts', $this, 'enqueue_styles' );
|
369 |
$this->loader->add_action( 'admin_enqueue_scripts', $this, 'enqueue_scripts' );
|
370 |
$this->loader->add_action( 'wp_enqueue_scripts', $this, 'enqueue_scripts' );
|
371 |
-
//$this->loader->add_action( 'enqueue_block_editor_assets', $this, 'enqueue_block_editor_assets' );
|
372 |
-
//$this->loader->add_action( 'enqueue_block_assets', $this, 'enqueue_block_assets' );
|
373 |
$this->loader->add_action( 'admin_footer', $this, 'enqueue_global_scripts', 20 );
|
374 |
$this->loader->add_action( 'wp_footer', $this, 'enqueue_global_scripts', 20 );
|
375 |
}
|
@@ -576,57 +574,10 @@ class Ditty {
|
|
576 |
$ditty_scripts_enqueued = 'enqueued';
|
577 |
}
|
578 |
|
579 |
-
/**
|
580 |
-
* Enqueue block editor only JavaScript and CSS
|
581 |
-
*
|
582 |
-
* @since 3.0
|
583 |
-
*/
|
584 |
-
// public function enqueue_block_editor_assets() {
|
585 |
-
// wp_enqueue_style(
|
586 |
-
// 'ditty-blocks-editor',
|
587 |
-
// DITTY_URL . 'includes/css/blocks.editor.css',
|
588 |
-
// [ ],
|
589 |
-
// $this->version,
|
590 |
-
// );
|
591 |
-
//
|
592 |
-
// wp_enqueue_script(
|
593 |
-
// 'ditty-blocks-editor',
|
594 |
-
// DITTY_URL . 'includes/js/editor.blocks.js',
|
595 |
-
// [ 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-editor' ],
|
596 |
-
// $this->version,
|
597 |
-
// true,
|
598 |
-
// );
|
599 |
-
// wp_add_inline_script( 'ditty-blocks-editor', 'const dittyBlocksEditorVars = ' . json_encode( array(
|
600 |
-
// 'displays' => Ditty()->displays->get_displays_data(),
|
601 |
-
// ) ), 'before' );
|
602 |
-
// }
|
603 |
-
|
604 |
-
/**
|
605 |
-
* Enqueue front end and editor JavaScript and CSS assets
|
606 |
-
*
|
607 |
-
* @since 3.0
|
608 |
-
*/
|
609 |
-
// public function enqueue_block_assets() {
|
610 |
-
// wp_enqueue_style(
|
611 |
-
// 'ditty-blocks',
|
612 |
-
// DITTY_URL . 'includes/css/blocks.style.css',
|
613 |
-
// [],
|
614 |
-
// $this->version
|
615 |
-
// );
|
616 |
-
//
|
617 |
-
// wp_enqueue_script(
|
618 |
-
// 'ditty-blocks',
|
619 |
-
// DITTY_URL . 'includes/js/frontend.blocks.js',
|
620 |
-
// [],
|
621 |
-
// $this->version,
|
622 |
-
// true,
|
623 |
-
// );
|
624 |
-
// }
|
625 |
-
|
626 |
/**
|
627 |
* Enqueue global scripts for any Ditty's displayed
|
628 |
*
|
629 |
-
* @since 3.0.
|
630 |
*/
|
631 |
public function enqueue_global_scripts() {
|
632 |
|
@@ -648,11 +599,11 @@ class Ditty {
|
|
648 |
}
|
649 |
if ( is_array( $ditty_display_scripts ) && count( $ditty_display_scripts ) > 0 ) {
|
650 |
$add_ditty = false;
|
651 |
-
foreach ( $ditty_display_scripts as $i => $
|
652 |
-
if ( empty( $
|
653 |
continue;
|
654 |
}
|
655 |
-
wp_print_scripts( "ditty-display-{$
|
656 |
$add_ditty = true;
|
657 |
}
|
658 |
if ( $add_ditty ) {
|
317 |
require_once DITTY_DIR . 'includes/class-ditty-singles.php';
|
318 |
require_once DITTY_DIR . 'includes/class-ditty-wpml.php';
|
319 |
|
320 |
+
require_once DITTY_DIR . 'src/blocks/ditty/index.php';
|
321 |
|
322 |
if ( is_admin() ) {
|
323 |
if ( ! class_exists( 'Ditty_Plugin_Updater' ) ) {
|
368 |
$this->loader->add_action( 'wp_enqueue_scripts', $this, 'enqueue_styles' );
|
369 |
$this->loader->add_action( 'admin_enqueue_scripts', $this, 'enqueue_scripts' );
|
370 |
$this->loader->add_action( 'wp_enqueue_scripts', $this, 'enqueue_scripts' );
|
|
|
|
|
371 |
$this->loader->add_action( 'admin_footer', $this, 'enqueue_global_scripts', 20 );
|
372 |
$this->loader->add_action( 'wp_footer', $this, 'enqueue_global_scripts', 20 );
|
373 |
}
|
574 |
$ditty_scripts_enqueued = 'enqueued';
|
575 |
}
|
576 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
/**
|
578 |
* Enqueue global scripts for any Ditty's displayed
|
579 |
*
|
580 |
+
* @since 3.0.28
|
581 |
*/
|
582 |
public function enqueue_global_scripts() {
|
583 |
|
599 |
}
|
600 |
if ( is_array( $ditty_display_scripts ) && count( $ditty_display_scripts ) > 0 ) {
|
601 |
$add_ditty = false;
|
602 |
+
foreach ( $ditty_display_scripts as $i => $display_type ) {
|
603 |
+
if ( empty( $display_type ) ) {
|
604 |
continue;
|
605 |
}
|
606 |
+
wp_print_scripts( "ditty-display-{$display_type}" );
|
607 |
$add_ditty = true;
|
608 |
}
|
609 |
if ( $add_ditty ) {
|
includes/css/ditty.css
CHANGED
@@ -851,6 +851,7 @@
|
|
851 |
.ditty {
|
852 |
position: relative;
|
853 |
flex: 1;
|
|
|
854 |
max-width: 100%;
|
855 |
box-sizing: border-box; }
|
856 |
|
851 |
.ditty {
|
852 |
position: relative;
|
853 |
flex: 1;
|
854 |
+
width: 100%;
|
855 |
max-width: 100%;
|
856 |
box-sizing: border-box; }
|
857 |
|
includes/helpers.php
CHANGED
@@ -1305,6 +1305,7 @@ function ditty_render( $atts ) {
|
|
1305 |
'layout_settings' => '',
|
1306 |
'uniqid' => '',
|
1307 |
'class' => '',
|
|
|
1308 |
'show_editor' => 0,
|
1309 |
);
|
1310 |
$args = shortcode_atts( $defaults, $atts );
|
@@ -1336,6 +1337,7 @@ function ditty_render( $atts ) {
|
|
1336 |
ditty_add_scripts( $args['id'], $args['display']);
|
1337 |
|
1338 |
$ditty_atts = array(
|
|
|
1339 |
'class' => $class,
|
1340 |
'data-id' => $args['id'],
|
1341 |
'data-uniqid' => $args['uniqid'],
|
1305 |
'layout_settings' => '',
|
1306 |
'uniqid' => '',
|
1307 |
'class' => '',
|
1308 |
+
'el_id' => '',
|
1309 |
'show_editor' => 0,
|
1310 |
);
|
1311 |
$args = shortcode_atts( $defaults, $atts );
|
1337 |
ditty_add_scripts( $args['id'], $args['display']);
|
1338 |
|
1339 |
$ditty_atts = array(
|
1340 |
+
'id' => ( '' != $args['el_id'] ) ? sanitize_title( $args['el_id'] ) : false,
|
1341 |
'class' => $class,
|
1342 |
'data-id' => $args['id'],
|
1343 |
'data-uniqid' => $args['uniqid'],
|
includes/hooks.php
CHANGED
@@ -71,7 +71,7 @@ function ditty_check_content_for_blocks() {
|
|
71 |
$blocks = parse_blocks( $post->post_content );
|
72 |
if ( is_array( $blocks ) && count( $blocks ) > 0 ) {
|
73 |
foreach ( $blocks as $i => $block ) {
|
74 |
-
if ( 'metaphorcreations/ditty
|
75 |
$ditty = $block['attrs']['ditty'];
|
76 |
$display = isset( $block['attrs']['display'] ) ? $block['attrs']['display'] : '';
|
77 |
ditty_add_scripts( $ditty, $display );
|
71 |
$blocks = parse_blocks( $post->post_content );
|
72 |
if ( is_array( $blocks ) && count( $blocks ) > 0 ) {
|
73 |
foreach ( $blocks as $i => $block ) {
|
74 |
+
if ( 'metaphorcreations/ditty' === $block['blockName'] ) {
|
75 |
$ditty = $block['attrs']['ditty'];
|
76 |
$display = isset( $block['attrs']['display'] ) ? $block['attrs']['display'] : '';
|
77 |
ditty_add_scripts( $ditty, $display );
|
includes/js/ditty.js
CHANGED
@@ -178,11 +178,11 @@ jQuery( function( $ ) {
|
|
178 |
if ( data.live_updates && '1' === String( data.live_updates ) ) {
|
179 |
$ditty.attr( 'data-live_updates', '1' );
|
180 |
}
|
181 |
-
if ( data.
|
182 |
-
$ditty.attr( 'id', data.
|
183 |
}
|
184 |
-
if ( data.
|
185 |
-
$ditty.addClass( data.
|
186 |
}
|
187 |
switch( data.position ) {
|
188 |
case 'prepend':
|
@@ -213,6 +213,7 @@ jQuery( function( $ ) {
|
|
213 |
setupGlobalDitty();
|
214 |
|
215 |
$( '.ditty' ).each( function() {
|
|
|
216 |
var $ditty = $( this ),
|
217 |
ajax_load = $ditty.data( 'ajax_load' ) ? $ditty.data( 'ajax_load' ) : false,
|
218 |
live_updates = $ditty.data( 'live_updates' ) ? $ditty.data( 'live_updates' ) : false,
|
178 |
if ( data.live_updates && '1' === String( data.live_updates ) ) {
|
179 |
$ditty.attr( 'data-live_updates', '1' );
|
180 |
}
|
181 |
+
if ( data.custom_id && '' !== data.custom_id ) {
|
182 |
+
$ditty.attr( 'id', data.custom_id );
|
183 |
}
|
184 |
+
if ( data.custom_classes && '' !== data.custom_classes ) {
|
185 |
+
$ditty.addClass( data.custom_classes );
|
186 |
}
|
187 |
switch( data.position ) {
|
188 |
case 'prepend':
|
213 |
setupGlobalDitty();
|
214 |
|
215 |
$( '.ditty' ).each( function() {
|
216 |
+
console.log( $( this )[0]);
|
217 |
var $ditty = $( this ),
|
218 |
ajax_load = $ditty.data( 'ajax_load' ) ? $ditty.data( 'ajax_load' ) : false,
|
219 |
live_updates = $ditty.data( 'live_updates' ) ? $ditty.data( 'live_updates' ) : false,
|
includes/js/ditty.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function dittyLayoutCss(t,a,e){var i=jQuery("style#ditty-layout--"+a);void 0===i[0]&&(i=jQuery('<style id="ditty-layout--'+a+'"></style>'),jQuery("head").append(i),e="update"),"update"===e&&(t=t.replace(">",">"),i.html(t))}function dittyDisplayCss(t,a){var e=jQuery("style#ditty-display--"+a);void 0===e[0]&&(e=jQuery('<style id="ditty-display--'+a+'"></style>'),jQuery("head").append(e)),t=t.replace(">",">"),e.html(t)}function dittyUpdateItems(t){jQuery.each(t,(function(t,a){var e=a.currentItem,i=a.newItem;e.wrap('<div class="ditty-update-wrapper"></div>');var s=e.parent(),d=i.attr("style");s.stop().css({height:e.outerHeight()}),e.stop().css({position:"absolute",top:0,left:0,width:"100%"}),i.stop().css({position:"absolute",top:0,left:0,width:"100%",opacity:0}),e.after(i),e.stop().animate({opacity:0},375,"linear"),i.stop().animate({opacity:1},375,"linear"),s.stop().animate({height:i.outerHeight()},500,"easeOutQuint",(function(){s.removeAttr("style"),e.unwrap(),e.remove(),d?i.attr("style",d):i.removeAttr("style"),i.hasClass("ditty-temp-item")&&i.remove()}))}))}jQuery((function($){!function(){"use strict";var t={},a=null;function e(){var a={action:"ditty_live_updates",live_ids:t,security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(a){a.updated_items&&$.each(a.updated_items,(function(a,e){!function(t,a){$('.ditty[data-id="'+t+'"]').each((function(){var t=$(this).data("type");"development"===dittyVars.mode&&window.console&&console.log("LIVE UPDATE"),$(this)["ditty_"+t]("options","items",a)}))}(a,e),t[a].timestamp=Math.floor($.now()/1e3)}))}),"json")}$.each(dittyVars.globals,(function(t,a){var e=$(a.selector);if(a.ditty&&void 0!==e[0]){var i=$('<div class="ditty" data-id="'+a.ditty+'" data-ajax_load="1"></div>');switch(a.display&&""!==a.display&&i.attr("data-display",a.display),a.live_updates&&"1"===String(a.live_updates)&&i.attr("data-live_updates","1"),a.
|
1 |
+
function dittyLayoutCss(t,a,e){var i=jQuery("style#ditty-layout--"+a);void 0===i[0]&&(i=jQuery('<style id="ditty-layout--'+a+'"></style>'),jQuery("head").append(i),e="update"),"update"===e&&(t=t.replace(">",">"),i.html(t))}function dittyDisplayCss(t,a){var e=jQuery("style#ditty-display--"+a);void 0===e[0]&&(e=jQuery('<style id="ditty-display--'+a+'"></style>'),jQuery("head").append(e)),t=t.replace(">",">"),e.html(t)}function dittyUpdateItems(t){jQuery.each(t,(function(t,a){var e=a.currentItem,i=a.newItem;e.wrap('<div class="ditty-update-wrapper"></div>');var s=e.parent(),d=i.attr("style");s.stop().css({height:e.outerHeight()}),e.stop().css({position:"absolute",top:0,left:0,width:"100%"}),i.stop().css({position:"absolute",top:0,left:0,width:"100%",opacity:0}),e.after(i),e.stop().animate({opacity:0},375,"linear"),i.stop().animate({opacity:1},375,"linear"),s.stop().animate({height:i.outerHeight()},500,"easeOutQuint",(function(){s.removeAttr("style"),e.unwrap(),e.remove(),d?i.attr("style",d):i.removeAttr("style"),i.hasClass("ditty-temp-item")&&i.remove()}))}))}jQuery((function($){!function(){"use strict";var t={},a=null;function e(){var a={action:"ditty_live_updates",live_ids:t,security:dittyVars.security};$.post(dittyVars.ajaxurl,a,(function(a){a.updated_items&&$.each(a.updated_items,(function(a,e){!function(t,a){$('.ditty[data-id="'+t+'"]').each((function(){var t=$(this).data("type");"development"===dittyVars.mode&&window.console&&console.log("LIVE UPDATE"),$(this)["ditty_"+t]("options","items",a)}))}(a,e),t[a].timestamp=Math.floor($.now()/1e3)}))}),"json")}$.each(dittyVars.globals,(function(t,a){var e=$(a.selector);if(a.ditty&&void 0!==e[0]){var i=$('<div class="ditty" data-id="'+a.ditty+'" data-ajax_load="1"></div>');switch(a.display&&""!==a.display&&i.attr("data-display",a.display),a.live_updates&&"1"===String(a.live_updates)&&i.attr("data-live_updates","1"),a.custom_id&&""!==a.custom_id&&i.attr("id",a.custom_id),a.custom_classes&&""!==a.custom_classes&&i.addClass(a.custom_classes),a.position){case"prepend":$(e[0]).prepend(i);break;case"before":$(e[0]).before(i);break;case"after":$(e[0]).after(i);break;default:$(e[0]).append(i)}}})),$(".ditty").each((function(){console.log($(this)[0]);var a=$(this),e=!!a.data("ajax_load")&&a.data("ajax_load"),i=!!a.data("live_updates")&&a.data("live_updates"),s=!!a.data("display_settings")&&a.data("display_settings"),d=!!a.data("layout_settings")&&a.data("layout_settings"),o=!!a.data("show_editor")&&a.data("show_editor");if(e){var n={action:"ditty_init",id:!!a.data("id")&&a.data("id"),uniqid:!!a.data("uniqid")&&a.data("uniqid"),display:a.data("display")?a.data("display"):"",display_settings:s,layout_settings:d,editor:o,security:dittyVars.security};$.post(dittyVars.ajaxurl,n,(function(e){if(!e.display_type||"function"!=typeof a["ditty_"+e.display_type])return window.console&&console.log("Ditty Display type not loaded:",e.display_type),!1;a["ditty_"+e.display_type](e.args),!o&&i&&(t[a.data("id")]={timestamp:Math.floor($.now()/1e3),layout_settings:d})}),"json")}else!o&&i&&(t[a.data("id")]={timestamp:Math.floor($.now()/1e3),layout_settings:d})})),$(".ditty").length&&dittyVars.updateInterval&&function(){if(null!==a||1>Object.keys(t).length)return!1;cancelAnimationFrame(a);var i=dittyVars.updateInterval?parseInt(dittyVars.updateInterval):60,s=Date.now();a=requestAnimationFrame((function t(){var d=Date.now();Math.floor((d-s)/1e3)>=i&&(s=d,e()),a=requestAnimationFrame(t)}))}()}()}));
|
includes/js/editor.blocks.js
DELETED
@@ -1,86 +0,0 @@
|
|
1 |
-
/******/ (function(modules) { // webpackBootstrap
|
2 |
-
/******/ // The module cache
|
3 |
-
/******/ var installedModules = {};
|
4 |
-
/******/
|
5 |
-
/******/ // The require function
|
6 |
-
/******/ function __webpack_require__(moduleId) {
|
7 |
-
/******/
|
8 |
-
/******/ // Check if module is in cache
|
9 |
-
/******/ if(installedModules[moduleId]) {
|
10 |
-
/******/ return installedModules[moduleId].exports;
|
11 |
-
/******/ }
|
12 |
-
/******/ // Create a new module (and put it into the cache)
|
13 |
-
/******/ var module = installedModules[moduleId] = {
|
14 |
-
/******/ i: moduleId,
|
15 |
-
/******/ l: false,
|
16 |
-
/******/ exports: {}
|
17 |
-
/******/ };
|
18 |
-
/******/
|
19 |
-
/******/ // Execute the module function
|
20 |
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
21 |
-
/******/
|
22 |
-
/******/ // Flag the module as loaded
|
23 |
-
/******/ module.l = true;
|
24 |
-
/******/
|
25 |
-
/******/ // Return the exports of the module
|
26 |
-
/******/ return module.exports;
|
27 |
-
/******/ }
|
28 |
-
/******/
|
29 |
-
/******/
|
30 |
-
/******/ // expose the modules object (__webpack_modules__)
|
31 |
-
/******/ __webpack_require__.m = modules;
|
32 |
-
/******/
|
33 |
-
/******/ // expose the module cache
|
34 |
-
/******/ __webpack_require__.c = installedModules;
|
35 |
-
/******/
|
36 |
-
/******/ // define getter function for harmony exports
|
37 |
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
38 |
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
39 |
-
/******/ Object.defineProperty(exports, name, {
|
40 |
-
/******/ configurable: false,
|
41 |
-
/******/ enumerable: true,
|
42 |
-
/******/ get: getter
|
43 |
-
/******/ });
|
44 |
-
/******/ }
|
45 |
-
/******/ };
|
46 |
-
/******/
|
47 |
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
48 |
-
/******/ __webpack_require__.n = function(module) {
|
49 |
-
/******/ var getter = module && module.__esModule ?
|
50 |
-
/******/ function getDefault() { return module['default']; } :
|
51 |
-
/******/ function getModuleExports() { return module; };
|
52 |
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
53 |
-
/******/ return getter;
|
54 |
-
/******/ };
|
55 |
-
/******/
|
56 |
-
/******/ // Object.prototype.hasOwnProperty.call
|
57 |
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
58 |
-
/******/
|
59 |
-
/******/ // __webpack_public_path__
|
60 |
-
/******/ __webpack_require__.p = "";
|
61 |
-
/******/
|
62 |
-
/******/ // Load entry module and return exports
|
63 |
-
/******/ return __webpack_require__(__webpack_require__.s = 0);
|
64 |
-
/******/ })
|
65 |
-
/************************************************************************/
|
66 |
-
/******/ ([
|
67 |
-
/* 0 */
|
68 |
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
69 |
-
|
70 |
-
"use strict";
|
71 |
-
eval("Object.defineProperty(__webpack_exports__, \"__esModule\", { value: true });\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__i18n_js__ = __webpack_require__(1);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__i18n_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__i18n_js__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__ditty_block__ = __webpack_require__(2);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__ditty_block___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__ditty_block__);\n\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2Jsb2Nrcy9pbmRleC5qcz84MTkzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCAnLi9pMThuLmpzJztcbmltcG9ydCAnLi9kaXR0eS1ibG9jayc7XG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gLi9ibG9ja3MvaW5kZXguanNcbi8vIG1vZHVsZSBpZCA9IDBcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sIm1hcHBpbmdzIjoiQUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7Iiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///0\n");
|
72 |
-
|
73 |
-
/***/ }),
|
74 |
-
/* 1 */
|
75 |
-
/***/ (function(module, exports) {
|
76 |
-
|
77 |
-
eval("wp.i18n.setLocaleData({ '': {} }, 'ditty');//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2Jsb2Nrcy9pMThuLmpzP2I0MTQiXSwic291cmNlc0NvbnRlbnQiOlsid3AuaTE4bi5zZXRMb2NhbGVEYXRhKHsgJyc6IHt9IH0sICdkaXR0eScpO1xuXG5cbi8vLy8vLy8vLy8vLy8vLy8vL1xuLy8gV0VCUEFDSyBGT09URVJcbi8vIC4vYmxvY2tzL2kxOG4uanNcbi8vIG1vZHVsZSBpZCA9IDFcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///1\n");
|
78 |
-
|
79 |
-
/***/ }),
|
80 |
-
/* 2 */
|
81 |
-
/***/ (function(module, exports) {
|
82 |
-
|
83 |
-
eval("throw new Error(\"Module build failed: SyntaxError: Unexpected token (82:8)\\n\\n\\u001b[0m \\u001b[90m 80 | \\u001b[39m \\n \\u001b[90m 81 | \\u001b[39m \\u001b[36mreturn\\u001b[39m [\\n\\u001b[31m\\u001b[1m>\\u001b[22m\\u001b[39m\\u001b[90m 82 | \\u001b[39m \\u001b[33m<\\u001b[39m\\u001b[33mInspectorControls\\u001b[39m key\\u001b[33m=\\u001b[39m\\u001b[32m'dittySelectTicker'\\u001b[39m\\u001b[33m>\\u001b[39m\\n \\u001b[90m | \\u001b[39m \\u001b[31m\\u001b[1m^\\u001b[22m\\u001b[39m\\n \\u001b[90m 83 | \\u001b[39m \\u001b[33m<\\u001b[39m\\u001b[33mPanelBody\\u001b[39m\\u001b[33m>\\u001b[39m\\n \\u001b[90m 84 | \\u001b[39m { ditty_posts\\n \\u001b[90m 85 | \\u001b[39m \\u001b[33m?\\u001b[39m\\u001b[0m\\n\");//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMi5qcyIsInNvdXJjZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///2\n");
|
84 |
-
|
85 |
-
/***/ })
|
86 |
-
/******/ ]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/js/editor.blocks.min.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
!function(u){var e={};function n(_){if(e[_])return e[_].exports;var t=e[_]={i:_,l:!1,exports:{}};return u[_].call(t.exports,t,t.exports,n),t.l=!0,t.exports}n.m=u,n.c=e,n.d=function(exports,u,e){n.o(exports,u)||Object.defineProperty(exports,u,{configurable:!1,enumerable:!0,get:e})},n.n=function(u){var e=u&&u.__esModule?function(){return u.default}:function(){return u};return n.d(e,"a",e),e},n.o=function(u,e){return Object.prototype.hasOwnProperty.call(u,e)},n.p="",n(n.s=0)}([function(module,__webpack_exports__,__webpack_require__){"use strict";eval('Object.defineProperty(__webpack_exports__, "__esModule", { value: true });\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__i18n_js__ = __webpack_require__(1);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__i18n_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__i18n_js__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__ditty_block__ = __webpack_require__(2);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__ditty_block___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__ditty_block__);\n\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2Jsb2Nrcy9pbmRleC5qcz84MTkzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCAnLi9pMThuLmpzJztcbmltcG9ydCAnLi9kaXR0eS1ibG9jayc7XG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gLi9ibG9ja3MvaW5kZXguanNcbi8vIG1vZHVsZSBpZCA9IDBcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sIm1hcHBpbmdzIjoiQUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7Iiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///0\n')},function(module,exports){eval("wp.i18n.setLocaleData({ '': {} }, 'ditty');//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2Jsb2Nrcy9pMThuLmpzP2I0MTQiXSwic291cmNlc0NvbnRlbnQiOlsid3AuaTE4bi5zZXRMb2NhbGVEYXRhKHsgJyc6IHt9IH0sICdkaXR0eScpO1xuXG5cbi8vLy8vLy8vLy8vLy8vLy8vL1xuLy8gV0VCUEFDSyBGT09URVJcbi8vIC4vYmxvY2tzL2kxOG4uanNcbi8vIG1vZHVsZSBpZCA9IDFcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///1\n")},function(module,exports){eval("throw new Error(\"Module build failed: SyntaxError: Unexpected token (82:8)\\n\\n\\u001b[0m \\u001b[90m 80 | \\u001b[39m \\n \\u001b[90m 81 | \\u001b[39m \\u001b[36mreturn\\u001b[39m [\\n\\u001b[31m\\u001b[1m>\\u001b[22m\\u001b[39m\\u001b[90m 82 | \\u001b[39m \\u001b[33m<\\u001b[39m\\u001b[33mInspectorControls\\u001b[39m key\\u001b[33m=\\u001b[39m\\u001b[32m'dittySelectTicker'\\u001b[39m\\u001b[33m>\\u001b[39m\\n \\u001b[90m | \\u001b[39m \\u001b[31m\\u001b[1m^\\u001b[22m\\u001b[39m\\n \\u001b[90m 83 | \\u001b[39m \\u001b[33m<\\u001b[39m\\u001b[33mPanelBody\\u001b[39m\\u001b[33m>\\u001b[39m\\n \\u001b[90m 84 | \\u001b[39m { ditty_posts\\n \\u001b[90m 85 | \\u001b[39m \\u001b[33m?\\u001b[39m\\u001b[0m\\n\");//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMi5qcyIsInNvdXJjZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///2\n")}]);
|
|
includes/js/frontend.blocks.js
DELETED
@@ -1,75 +0,0 @@
|
|
1 |
-
/******/ (function(modules) { // webpackBootstrap
|
2 |
-
/******/ // The module cache
|
3 |
-
/******/ var installedModules = {};
|
4 |
-
/******/
|
5 |
-
/******/ // The require function
|
6 |
-
/******/ function __webpack_require__(moduleId) {
|
7 |
-
/******/
|
8 |
-
/******/ // Check if module is in cache
|
9 |
-
/******/ if(installedModules[moduleId]) {
|
10 |
-
/******/ return installedModules[moduleId].exports;
|
11 |
-
/******/ }
|
12 |
-
/******/ // Create a new module (and put it into the cache)
|
13 |
-
/******/ var module = installedModules[moduleId] = {
|
14 |
-
/******/ i: moduleId,
|
15 |
-
/******/ l: false,
|
16 |
-
/******/ exports: {}
|
17 |
-
/******/ };
|
18 |
-
/******/
|
19 |
-
/******/ // Execute the module function
|
20 |
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
21 |
-
/******/
|
22 |
-
/******/ // Flag the module as loaded
|
23 |
-
/******/ module.l = true;
|
24 |
-
/******/
|
25 |
-
/******/ // Return the exports of the module
|
26 |
-
/******/ return module.exports;
|
27 |
-
/******/ }
|
28 |
-
/******/
|
29 |
-
/******/
|
30 |
-
/******/ // expose the modules object (__webpack_modules__)
|
31 |
-
/******/ __webpack_require__.m = modules;
|
32 |
-
/******/
|
33 |
-
/******/ // expose the module cache
|
34 |
-
/******/ __webpack_require__.c = installedModules;
|
35 |
-
/******/
|
36 |
-
/******/ // define getter function for harmony exports
|
37 |
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
38 |
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
39 |
-
/******/ Object.defineProperty(exports, name, {
|
40 |
-
/******/ configurable: false,
|
41 |
-
/******/ enumerable: true,
|
42 |
-
/******/ get: getter
|
43 |
-
/******/ });
|
44 |
-
/******/ }
|
45 |
-
/******/ };
|
46 |
-
/******/
|
47 |
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
48 |
-
/******/ __webpack_require__.n = function(module) {
|
49 |
-
/******/ var getter = module && module.__esModule ?
|
50 |
-
/******/ function getDefault() { return module['default']; } :
|
51 |
-
/******/ function getModuleExports() { return module; };
|
52 |
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
53 |
-
/******/ return getter;
|
54 |
-
/******/ };
|
55 |
-
/******/
|
56 |
-
/******/ // Object.prototype.hasOwnProperty.call
|
57 |
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
58 |
-
/******/
|
59 |
-
/******/ // __webpack_public_path__
|
60 |
-
/******/ __webpack_require__.p = "";
|
61 |
-
/******/
|
62 |
-
/******/ // Load entry module and return exports
|
63 |
-
/******/ return __webpack_require__(__webpack_require__.s = 3);
|
64 |
-
/******/ })
|
65 |
-
/************************************************************************/
|
66 |
-
/******/ ({
|
67 |
-
|
68 |
-
/***/ 3:
|
69 |
-
/***/ (function(module, exports) {
|
70 |
-
|
71 |
-
eval("//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMy5qcyIsInNvdXJjZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///3\n");
|
72 |
-
|
73 |
-
/***/ })
|
74 |
-
|
75 |
-
/******/ });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/js/frontend.blocks.min.js
DELETED
@@ -1,75 +0,0 @@
|
|
1 |
-
/******/ (function(modules) { // webpackBootstrap
|
2 |
-
/******/ // The module cache
|
3 |
-
/******/ var installedModules = {};
|
4 |
-
/******/
|
5 |
-
/******/ // The require function
|
6 |
-
/******/ function __webpack_require__(moduleId) {
|
7 |
-
/******/
|
8 |
-
/******/ // Check if module is in cache
|
9 |
-
/******/ if(installedModules[moduleId]) {
|
10 |
-
/******/ return installedModules[moduleId].exports;
|
11 |
-
/******/ }
|
12 |
-
/******/ // Create a new module (and put it into the cache)
|
13 |
-
/******/ var module = installedModules[moduleId] = {
|
14 |
-
/******/ i: moduleId,
|
15 |
-
/******/ l: false,
|
16 |
-
/******/ exports: {}
|
17 |
-
/******/ };
|
18 |
-
/******/
|
19 |
-
/******/ // Execute the module function
|
20 |
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
21 |
-
/******/
|
22 |
-
/******/ // Flag the module as loaded
|
23 |
-
/******/ module.l = true;
|
24 |
-
/******/
|
25 |
-
/******/ // Return the exports of the module
|
26 |
-
/******/ return module.exports;
|
27 |
-
/******/ }
|
28 |
-
/******/
|
29 |
-
/******/
|
30 |
-
/******/ // expose the modules object (__webpack_modules__)
|
31 |
-
/******/ __webpack_require__.m = modules;
|
32 |
-
/******/
|
33 |
-
/******/ // expose the module cache
|
34 |
-
/******/ __webpack_require__.c = installedModules;
|
35 |
-
/******/
|
36 |
-
/******/ // define getter function for harmony exports
|
37 |
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
38 |
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
39 |
-
/******/ Object.defineProperty(exports, name, {
|
40 |
-
/******/ configurable: false,
|
41 |
-
/******/ enumerable: true,
|
42 |
-
/******/ get: getter
|
43 |
-
/******/ });
|
44 |
-
/******/ }
|
45 |
-
/******/ };
|
46 |
-
/******/
|
47 |
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
48 |
-
/******/ __webpack_require__.n = function(module) {
|
49 |
-
/******/ var getter = module && module.__esModule ?
|
50 |
-
/******/ function getDefault() { return module['default']; } :
|
51 |
-
/******/ function getModuleExports() { return module; };
|
52 |
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
53 |
-
/******/ return getter;
|
54 |
-
/******/ };
|
55 |
-
/******/
|
56 |
-
/******/ // Object.prototype.hasOwnProperty.call
|
57 |
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
58 |
-
/******/
|
59 |
-
/******/ // __webpack_public_path__
|
60 |
-
/******/ __webpack_require__.p = "";
|
61 |
-
/******/
|
62 |
-
/******/ // Load entry module and return exports
|
63 |
-
/******/ return __webpack_require__(__webpack_require__.s = 3);
|
64 |
-
/******/ })
|
65 |
-
/************************************************************************/
|
66 |
-
/******/ ({
|
67 |
-
|
68 |
-
/***/ 3:
|
69 |
-
/***/ (function(module, exports) {
|
70 |
-
|
71 |
-
eval("//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMy5qcyIsInNvdXJjZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///3\n");
|
72 |
-
|
73 |
-
/***/ })
|
74 |
-
|
75 |
-
/******/ });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/sass/partials/_general.scss
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
.ditty {
|
2 |
position: relative;
|
3 |
flex: 1;
|
|
|
4 |
max-width: 100%;
|
5 |
box-sizing: border-box;
|
6 |
&--pre {
|
1 |
.ditty {
|
2 |
position: relative;
|
3 |
flex: 1;
|
4 |
+
width: 100%;
|
5 |
max-width: 100%;
|
6 |
box-sizing: border-box;
|
7 |
&--pre {
|
includes/widget.php
CHANGED
@@ -3,25 +3,22 @@
|
|
3 |
/**
|
4 |
* Create a class for the widget
|
5 |
*
|
6 |
-
* @since 3.0.
|
7 |
*/
|
8 |
class ditty_widget extends WP_Widget {
|
9 |
|
10 |
/** Constructor */
|
11 |
function __construct() {
|
12 |
-
|
13 |
-
'
|
14 |
-
|
15 |
-
|
16 |
-
'classname' => 'ditty-widget',
|
17 |
-
'description' => __( 'Displays a Ditty.', 'ditty-news-ticker' )
|
18 |
-
)
|
19 |
);
|
|
|
20 |
}
|
21 |
|
22 |
/** @see WP_Widget::widget */
|
23 |
function widget( $args, $instance ) {
|
24 |
-
|
25 |
extract( $args );
|
26 |
|
27 |
// User-selected settings
|
@@ -31,6 +28,10 @@ class ditty_widget extends WP_Widget {
|
|
31 |
$ditty = isset( $instance['ditty'] ) ? $instance['ditty'] : '';
|
32 |
$display = isset( $instance['display'] ) ? $instance['display'] : '';
|
33 |
|
|
|
|
|
|
|
|
|
34 |
ob_start();
|
35 |
|
36 |
// Display the ticker
|
@@ -128,3 +129,11 @@ function ditty_widget_init() {
|
|
128 |
}
|
129 |
add_action( 'widgets_init', 'ditty_widget_init' );
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
/**
|
4 |
* Create a class for the widget
|
5 |
*
|
6 |
+
* @since 3.0.28
|
7 |
*/
|
8 |
class ditty_widget extends WP_Widget {
|
9 |
|
10 |
/** Constructor */
|
11 |
function __construct() {
|
12 |
+
$widget_ops = array(
|
13 |
+
'description' => __( 'Add a navigation menu to your sidebar.' ),
|
14 |
+
'customize_selective_refresh' => true,
|
15 |
+
'show_instance_in_rest' => true,
|
|
|
|
|
|
|
16 |
);
|
17 |
+
parent::__construct( 'ditty-widget', __( 'Ditty', 'ditty-news-ticker' ), $widget_ops );
|
18 |
}
|
19 |
|
20 |
/** @see WP_Widget::widget */
|
21 |
function widget( $args, $instance ) {
|
|
|
22 |
extract( $args );
|
23 |
|
24 |
// User-selected settings
|
28 |
$ditty = isset( $instance['ditty'] ) ? $instance['ditty'] : '';
|
29 |
$display = isset( $instance['display'] ) ? $instance['display'] : '';
|
30 |
|
31 |
+
if ( '' == $ditty ) {
|
32 |
+
return;
|
33 |
+
}
|
34 |
+
|
35 |
ob_start();
|
36 |
|
37 |
// Display the ticker
|
129 |
}
|
130 |
add_action( 'widgets_init', 'ditty_widget_init' );
|
131 |
|
132 |
+
|
133 |
+
function ditty_hide_widget( $widget_types ) {
|
134 |
+
$widget_types[] = 'ditty-widget';
|
135 |
+
return $widget_types;
|
136 |
+
}
|
137 |
+
//add_filter( 'widget_types_to_hide_from_legacy_widget_block', 'ditty_hide_widget' );
|
138 |
+
|
139 |
+
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: metaphorcreations
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FUZKZGAJSBAE6
|
4 |
Tags: ticker, post ticker, content slider, content list, responsive slider, content display
|
5 |
Requires at least: 4.5
|
6 |
-
Tested up to: 6.0
|
7 |
-
Stable tag: 3.0.
|
8 |
License: GPL2
|
9 |
|
10 |
Formerly Ditty News Ticker, Ditty is a multi-functional content display WordPress plugin.
|
@@ -130,6 +130,10 @@ The most common cause for an unresponsive Ditty (when using scroll or rotate mod
|
|
130 |
|
131 |
== Changelog ==
|
132 |
|
|
|
|
|
|
|
|
|
133 |
= 3.0.27 =
|
134 |
* Bug fix in legacy settings code
|
135 |
* Bug fix in gutenberg block check code
|
@@ -798,4 +802,4 @@ The most common cause for an unresponsive Ditty (when using scroll or rotate mod
|
|
798 |
|
799 |
== Upgrade Notice ==
|
800 |
|
801 |
-
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FUZKZGAJSBAE6
|
4 |
Tags: ticker, post ticker, content slider, content list, responsive slider, content display
|
5 |
Requires at least: 4.5
|
6 |
+
Tested up to: 6.0.2
|
7 |
+
Stable tag: 3.0.28
|
8 |
License: GPL2
|
9 |
|
10 |
Formerly Ditty News Ticker, Ditty is a multi-functional content display WordPress plugin.
|
130 |
|
131 |
== Changelog ==
|
132 |
|
133 |
+
= 3.0.28 =
|
134 |
+
* Added Ditty widget block
|
135 |
+
* Added functionality to convert classic widget to block
|
136 |
+
|
137 |
= 3.0.27 =
|
138 |
* Bug fix in legacy settings code
|
139 |
* Bug fix in gutenberg block check code
|
802 |
|
803 |
== Upgrade Notice ==
|
804 |
|
805 |
+
Added Ditty widget block
|
src/blocks/ditty/block.json
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"apiVersion": 2,
|
3 |
+
"name": "metaphorcreations/ditty",
|
4 |
+
"version": "0.1.0",
|
5 |
+
"title": "Ditty",
|
6 |
+
"description": "Display your Ditty within the content of the post.",
|
7 |
+
"category": "widgets",
|
8 |
+
"icon": "smiley",
|
9 |
+
|
10 |
+
"keywords": [ "ticker", "list", "slider", "display", "content" ],
|
11 |
+
"supports": {
|
12 |
+
"html": false
|
13 |
+
},
|
14 |
+
"textdomain": "ditty",
|
15 |
+
"attributes": {
|
16 |
+
"ditty": {
|
17 |
+
"type": "integer"
|
18 |
+
},
|
19 |
+
"display": {
|
20 |
+
"type": "integer"
|
21 |
+
},
|
22 |
+
"customID": {
|
23 |
+
"type": "string"
|
24 |
+
},
|
25 |
+
"customClasses": {
|
26 |
+
"type": "string"
|
27 |
+
}
|
28 |
+
},
|
29 |
+
"editorScript": "file:./index.js",
|
30 |
+
"editorStyle": "file:./index.css",
|
31 |
+
"style": "file:./style-index.css"
|
32 |
+
}
|
src/blocks/ditty/edit.js
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { __ } from "@wordpress/i18n";
|
2 |
+
import { useBlockProps, InspectorControls } from "@wordpress/block-editor";
|
3 |
+
import { Fragment, useState, useEffect } from "@wordpress/element";
|
4 |
+
import {
|
5 |
+
PanelBody,
|
6 |
+
SelectControl,
|
7 |
+
TextControl,
|
8 |
+
Spinner,
|
9 |
+
} from "@wordpress/components";
|
10 |
+
import apiFetch from "@wordpress/api-fetch";
|
11 |
+
import icons from "./icon";
|
12 |
+
import "./editor.scss";
|
13 |
+
|
14 |
+
export default function Edit({
|
15 |
+
isSelected,
|
16 |
+
setAttributes,
|
17 |
+
attributes,
|
18 |
+
}) {
|
19 |
+
const { ditty, display, customID, customClasses } = attributes;
|
20 |
+
const [dittyPosts, setDittyPosts] = useState([]);
|
21 |
+
const [displayPosts, setDisplayPosts] = useState([]);
|
22 |
+
|
23 |
+
const dittyOptions = dittyPosts.map((ditty) => {
|
24 |
+
return {
|
25 |
+
key: ditty.id,
|
26 |
+
value: ditty.id,
|
27 |
+
label: ditty.title.rendered,
|
28 |
+
};
|
29 |
+
});
|
30 |
+
dittyOptions.unshift({
|
31 |
+
key: 0,
|
32 |
+
value: 0,
|
33 |
+
label: __("No Ditty Selected", "ditty-news-ticker"),
|
34 |
+
});
|
35 |
+
|
36 |
+
const displayOptions = displayPosts.map((display) => {
|
37 |
+
return {
|
38 |
+
key: display.id,
|
39 |
+
value: display.id,
|
40 |
+
label: display.title.rendered,
|
41 |
+
};
|
42 |
+
});
|
43 |
+
displayOptions.unshift({
|
44 |
+
key: 0,
|
45 |
+
value: 0,
|
46 |
+
label: __("Use Default Display", "ditty-news-ticker"),
|
47 |
+
});
|
48 |
+
|
49 |
+
const currentDitty = dittyOptions.filter((option) => {
|
50 |
+
return option.value === ditty;
|
51 |
+
});
|
52 |
+
const currentDittyLabel = currentDitty[0] ? currentDitty[0].label : "";
|
53 |
+
|
54 |
+
const currentDisplay = displayOptions.filter((option) => {
|
55 |
+
return option.value === display;
|
56 |
+
});
|
57 |
+
const currentDisplayLabel = currentDisplay[0] ? currentDisplay[0].label : "";
|
58 |
+
const blockClass = "wp-block-metaphorcreations-ditty";
|
59 |
+
|
60 |
+
useEffect(() => {
|
61 |
+
async function getDittyPosts() {
|
62 |
+
const posts = await apiFetch({ path: "/wp/v2/ditty" });
|
63 |
+
setDittyPosts(posts);
|
64 |
+
}
|
65 |
+
async function getDisplayPosts() {
|
66 |
+
const posts = await apiFetch({ path: "/wp/v2/ditty_display" });
|
67 |
+
setDisplayPosts(posts);
|
68 |
+
}
|
69 |
+
getDittyPosts();
|
70 |
+
getDisplayPosts();
|
71 |
+
}, []);
|
72 |
+
|
73 |
+
return (
|
74 |
+
<div {...useBlockProps()}>
|
75 |
+
<InspectorControls key="dittySelectTicker">
|
76 |
+
<PanelBody>
|
77 |
+
{dittyOptions ? (
|
78 |
+
<SelectControl
|
79 |
+
label={__("Ditty", "ditty-news-ticker")}
|
80 |
+
value={ditty}
|
81 |
+
options={dittyOptions}
|
82 |
+
onChange={(ditty) => setAttributes({ ditty: Number(ditty) })}
|
83 |
+
/>
|
84 |
+
) : (
|
85 |
+
<Fragment>
|
86 |
+
<Spinner />
|
87 |
+
{__("Loading Tickers", "ditty-news-ticker")}
|
88 |
+
</Fragment>
|
89 |
+
)}
|
90 |
+
{displayOptions ? (
|
91 |
+
<SelectControl
|
92 |
+
label={__("Display", "ditty-news-ticker")}
|
93 |
+
value={display}
|
94 |
+
options={displayOptions}
|
95 |
+
onChange={(display) =>
|
96 |
+
setAttributes({ display: Number(display) })
|
97 |
+
}
|
98 |
+
/>
|
99 |
+
) : (
|
100 |
+
<Fragment>
|
101 |
+
<Spinner />
|
102 |
+
{__("Loading Displays", "ditty-news-ticker")}
|
103 |
+
</Fragment>
|
104 |
+
)}
|
105 |
+
<TextControl
|
106 |
+
label={__("Custom ID", "ditty-news-ticker")}
|
107 |
+
value={customID}
|
108 |
+
onChange={(customID) => setAttributes({ customID })}
|
109 |
+
/>
|
110 |
+
<TextControl
|
111 |
+
label={__("Custom Classes", "ditty-news-ticker")}
|
112 |
+
value={customClasses}
|
113 |
+
onChange={(customClasses) => setAttributes({ customClasses })}
|
114 |
+
/>
|
115 |
+
</PanelBody>
|
116 |
+
</InspectorControls>
|
117 |
+
|
118 |
+
<div className={`${blockClass}__contents`}>
|
119 |
+
{icons.logoBlack}
|
120 |
+
{!isSelected && (
|
121 |
+
<div className={`${blockClass}__info`}>
|
122 |
+
<div className={`${blockClass}__vals`}>
|
123 |
+
{__("ID:", "ditty-news-ticker")}{" "}
|
124 |
+
<strong>{currentDittyLabel}</strong>
|
125 |
+
</div>
|
126 |
+
<div className={`${blockClass}__vals`}>
|
127 |
+
{__("Display:", "ditty-news-ticker")}{" "}
|
128 |
+
<strong>{currentDisplayLabel}</strong>
|
129 |
+
</div>
|
130 |
+
</div>
|
131 |
+
)}
|
132 |
+
|
133 |
+
{isSelected && (
|
134 |
+
<div className={`${blockClass}__controls`}>
|
135 |
+
<SelectControl
|
136 |
+
label={__("ID:", "ditty-news-ticker")}
|
137 |
+
labelPosition="side"
|
138 |
+
value={ditty}
|
139 |
+
options={dittyOptions}
|
140 |
+
onChange={(ditty) => setAttributes({ ditty: Number(ditty) })}
|
141 |
+
/>
|
142 |
+
<SelectControl
|
143 |
+
label={__("Display:", "ditty-news-ticker")}
|
144 |
+
labelPosition="side"
|
145 |
+
value={display}
|
146 |
+
options={displayOptions}
|
147 |
+
onChange={(display) =>
|
148 |
+
setAttributes({ display: Number(display) })
|
149 |
+
}
|
150 |
+
/>
|
151 |
+
</div>
|
152 |
+
)}
|
153 |
+
</div>
|
154 |
+
</div>
|
155 |
+
);
|
156 |
+
}
|
{blocks/ditty-block → src/blocks/ditty}/editor.scss
RENAMED
@@ -1,17 +1,15 @@
|
|
1 |
$ditty_primary: #39b44a;
|
2 |
-
.ditty
|
3 |
-
.ditty-icon--white {
|
4 |
-
fill: #FFF !important;
|
5 |
-
}
|
6 |
-
.ditty-logo--green,
|
7 |
-
.ditty-icon--green {
|
8 |
-
fill: $ditty_primary !important;
|
9 |
-
}
|
10 |
-
.wp-block-metaphorcreations-ditty-block {
|
11 |
-
background: rgba( 255, 255, 255, .8 );
|
12 |
border: 2px solid $ditty_primary;
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
display: flex;
|
16 |
flex-direction: row;
|
17 |
align-items: center;
|
@@ -25,8 +23,7 @@ $ditty_primary: #39b44a;
|
|
25 |
padding: 5px 10px;
|
26 |
margin-right: 5px;
|
27 |
}
|
28 |
-
|
29 |
-
margin-top: 15px;
|
30 |
label {
|
31 |
width: 60px;
|
32 |
font-weight: bold;
|
@@ -36,8 +33,4 @@ $ditty_primary: #39b44a;
|
|
36 |
padding-top: 0 !important;
|
37 |
padding-bottom: 0 !important;
|
38 |
}
|
39 |
-
svg {
|
40 |
-
max-height: 60px;
|
41 |
-
margin-right: 10px;
|
42 |
-
}
|
43 |
}
|
1 |
$ditty_primary: #39b44a;
|
2 |
+
.wp-block-metaphorcreations-ditty {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
border: 2px solid $ditty_primary;
|
4 |
+
.ditty-logo {
|
5 |
+
width: 100px;
|
6 |
+
margin-bottom: 15px;
|
7 |
+
}
|
8 |
+
&__contents {
|
9 |
+
background: rgba( 255, 255, 255, .8 );
|
10 |
+
padding: 20px;
|
11 |
+
}
|
12 |
+
&__info {
|
13 |
display: flex;
|
14 |
flex-direction: row;
|
15 |
align-items: center;
|
23 |
padding: 5px 10px;
|
24 |
margin-right: 5px;
|
25 |
}
|
26 |
+
&__controls {
|
|
|
27 |
label {
|
28 |
width: 60px;
|
29 |
font-weight: bold;
|
33 |
padding-top: 0 !important;
|
34 |
padding-bottom: 0 !important;
|
35 |
}
|
|
|
|
|
|
|
|
|
36 |
}
|
src/blocks/ditty/icon.js
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const icons = {};
|
2 |
+
icons.iconBlack = (
|
3 |
+
<svg
|
4 |
+
className="ditty-logo ditty-icon--black"
|
5 |
+
xmlns="http://www.w3.org/2000/svg"
|
6 |
+
viewBox="0 0 69.8 71.1"
|
7 |
+
>
|
8 |
+
<path d="M0 46.4c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V0H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 71.1 0 58.4 0 46.4Zm31.2 7.4V28.6a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM54.7 63.7a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z" />
|
9 |
+
</svg>
|
10 |
+
);
|
11 |
+
|
12 |
+
icons.iconWhite = (
|
13 |
+
<svg
|
14 |
+
className="ditty-logo ditty-icon--white"
|
15 |
+
xmlns="http://www.w3.org/2000/svg"
|
16 |
+
viewBox="0 0 69.8 71.1"
|
17 |
+
>
|
18 |
+
<path d="M0 46.4c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V0H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 71.1 0 58.4 0 46.4Zm31.2 7.4V28.6a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM54.7 63.7a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z" />
|
19 |
+
</svg>
|
20 |
+
);
|
21 |
+
|
22 |
+
icons.iconGreen = (
|
23 |
+
<svg
|
24 |
+
className="ditty-logo ditty-icon--green"
|
25 |
+
xmlns="http://www.w3.org/2000/svg"
|
26 |
+
viewBox="0 0 69.8 71.1"
|
27 |
+
>
|
28 |
+
<path d="M0 46.4c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V0H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 71.1 0 58.4 0 46.4Zm31.2 7.4V28.6a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM54.7 63.7a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z" />
|
29 |
+
</svg>
|
30 |
+
);
|
31 |
+
|
32 |
+
icons.logoBlack = (
|
33 |
+
<svg
|
34 |
+
className="ditty-logo ditty-logo--black"
|
35 |
+
xmlns="http://www.w3.org/2000/svg"
|
36 |
+
viewBox="0 0 258.8 99.21"
|
37 |
+
>
|
38 |
+
<path d="M0 49.5c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V3.1H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 74.2 0 61.5 0 49.5Zm31.2 7.4V31.7a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM55.7 7.4A7.33 7.33 0 0 1 63.4 0c4.6 0 7.8 3.3 7.8 7.4s-3.2 7.4-7.8 7.4-7.7-3.1-7.7-7.4Zm14.8 14.5v50.7H56.4V21.9ZM95.8 3.1v18.8H112V3.1h14.1v18.8h13v10.9h-13v23.1c0 5.9 2.6 7.6 6.4 7.6a11.9 11.9 0 0 0 6.1-1.9l3.2 9c-3 2-8.2 3.5-13.3 3.5-15.2 0-16.5-8.7-16.5-17.8V32.8H95.8v23.1c0 5.9 2 7.6 5.7 7.6a11.64 11.64 0 0 0 5.7-1.6l2.1 9.4c-2.6 1.7-7.4 2.8-11.1 2.8-15.1 0-16.4-8.7-16.4-17.8V3.1ZM149.6 85.81c0-7.21 4.4-12.81 10.3-17.11-8.4-1.3-13-5.9-13-16V21.9h14v29.7c0 5.4.5 9.1 7 9.1 4 0 7.7-3.2 7.7-8.3V21.9h14v42.3a108.13 108.13 0 0 1-.9 13.9c-1.5 13.5-8.9 21.11-22.4 21.11-11.1 0-16.7-5.21-16.7-13.4Zm26.3-9.11v-9.5c-7.4 3.5-14 8.5-14 16.11 0 3.9 2.2 5.79 6 5.79 5.9 0 8-4.7 8-12.4ZM198.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM221.2 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM243.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z" />
|
39 |
+
</svg>
|
40 |
+
);
|
41 |
+
|
42 |
+
icons.logoWhite = (
|
43 |
+
<svg
|
44 |
+
className="ditty-logo ditty-logo--white"
|
45 |
+
xmlns="http://www.w3.org/2000/svg"
|
46 |
+
viewBox="0 0 258.8 99.21"
|
47 |
+
>
|
48 |
+
<path d="M0 49.5c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V3.1H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 74.2 0 61.5 0 49.5Zm31.2 7.4V31.7a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM55.7 7.4A7.33 7.33 0 0 1 63.4 0c4.6 0 7.8 3.3 7.8 7.4s-3.2 7.4-7.8 7.4-7.7-3.1-7.7-7.4Zm14.8 14.5v50.7H56.4V21.9ZM95.8 3.1v18.8H112V3.1h14.1v18.8h13v10.9h-13v23.1c0 5.9 2.6 7.6 6.4 7.6a11.9 11.9 0 0 0 6.1-1.9l3.2 9c-3 2-8.2 3.5-13.3 3.5-15.2 0-16.5-8.7-16.5-17.8V32.8H95.8v23.1c0 5.9 2 7.6 5.7 7.6a11.64 11.64 0 0 0 5.7-1.6l2.1 9.4c-2.6 1.7-7.4 2.8-11.1 2.8-15.1 0-16.4-8.7-16.4-17.8V3.1ZM149.6 85.81c0-7.21 4.4-12.81 10.3-17.11-8.4-1.3-13-5.9-13-16V21.9h14v29.7c0 5.4.5 9.1 7 9.1 4 0 7.7-3.2 7.7-8.3V21.9h14v42.3a108.13 108.13 0 0 1-.9 13.9c-1.5 13.5-8.9 21.11-22.4 21.11-11.1 0-16.7-5.21-16.7-13.4Zm26.3-9.11v-9.5c-7.4 3.5-14 8.5-14 16.11 0 3.9 2.2 5.79 6 5.79 5.9 0 8-4.7 8-12.4ZM198.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM221.2 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM243.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z" />
|
49 |
+
</svg>
|
50 |
+
);
|
51 |
+
|
52 |
+
icons.logoGreen = (
|
53 |
+
<svg
|
54 |
+
className="ditty-logo ditty-logo--green"
|
55 |
+
xmlns="http://www.w3.org/2000/svg"
|
56 |
+
viewBox="0 0 258.8 99.21"
|
57 |
+
>
|
58 |
+
<path d="M0 49.5c0-17.2 8.6-29.1 24.6-29.1a19.93 19.93 0 0 1 6.6 1V3.1H45v59.2l1 10.3H34.2l-.9-5.2h-.5a15.21 15.21 0 0 1-13 6.8C3.8 74.2 0 61.5 0 49.5Zm31.2 7.4V31.7a13.7 13.7 0 0 0-6-1.3c-8.7 0-11.3 8.7-11.3 17.8 0 8.5 1.9 15.8 8.9 15.8 5.1 0 8.4-3.8 8.4-7.1ZM55.7 7.4A7.33 7.33 0 0 1 63.4 0c4.6 0 7.8 3.3 7.8 7.4s-3.2 7.4-7.8 7.4-7.7-3.1-7.7-7.4Zm14.8 14.5v50.7H56.4V21.9ZM95.8 3.1v18.8H112V3.1h14.1v18.8h13v10.9h-13v23.1c0 5.9 2.6 7.6 6.4 7.6a11.9 11.9 0 0 0 6.1-1.9l3.2 9c-3 2-8.2 3.5-13.3 3.5-15.2 0-16.5-8.7-16.5-17.8V32.8H95.8v23.1c0 5.9 2 7.6 5.7 7.6a11.64 11.64 0 0 0 5.7-1.6l2.1 9.4c-2.6 1.7-7.4 2.8-11.1 2.8-15.1 0-16.4-8.7-16.4-17.8V3.1ZM149.6 85.81c0-7.21 4.4-12.81 10.3-17.11-8.4-1.3-13-5.9-13-16V21.9h14v29.7c0 5.4.5 9.1 7 9.1 4 0 7.7-3.2 7.7-8.3V21.9h14v42.3a108.13 108.13 0 0 1-.9 13.9c-1.5 13.5-8.9 21.11-22.4 21.11-11.1 0-16.7-5.21-16.7-13.4Zm26.3-9.11v-9.5c-7.4 3.5-14 8.5-14 16.11 0 3.9 2.2 5.79 6 5.79 5.9 0 8-4.7 8-12.4ZM198.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM221.2 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4ZM243.7 66.8a7 7 0 0 1 7.4-7.2c5 0 7.7 2.8 7.7 7.1s-2.6 7.5-7.4 7.5c-5.1 0-7.7-3.1-7.7-7.4Z" />
|
59 |
+
</svg>
|
60 |
+
);
|
61 |
+
|
62 |
+
export default icons;
|
src/blocks/ditty/index.js
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { registerBlockType, createBlock } from "@wordpress/blocks";
|
2 |
+
import Edit from "./edit";
|
3 |
+
import save from "./save";
|
4 |
+
import icons from "./icon";
|
5 |
+
import "./style.scss";
|
6 |
+
|
7 |
+
registerBlockType("metaphorcreations/ditty", {
|
8 |
+
version: Date.now(),
|
9 |
+
icon: {
|
10 |
+
src: icons.iconGreen,
|
11 |
+
},
|
12 |
+
transforms: {
|
13 |
+
from: [
|
14 |
+
{
|
15 |
+
type: "block",
|
16 |
+
blocks: ["core/legacy-widget"],
|
17 |
+
isMatch: ({ idBase, instance }) => {
|
18 |
+
if (!instance?.raw) {
|
19 |
+
// Can't transform if raw instance is not shown in REST API.
|
20 |
+
return false;
|
21 |
+
}
|
22 |
+
return idBase === "ditty-widget";
|
23 |
+
},
|
24 |
+
transform: ({ instance }) => {
|
25 |
+
const blocks = [
|
26 |
+
createBlock("metaphorcreations/ditty", {
|
27 |
+
ditty: instance.raw.ditty,
|
28 |
+
display: instance.raw.display,
|
29 |
+
}),
|
30 |
+
];
|
31 |
+
if (instance.raw.title) {
|
32 |
+
blocks.unshift(
|
33 |
+
createBlock("core/heading", {
|
34 |
+
content: instance.raw.title,
|
35 |
+
})
|
36 |
+
);
|
37 |
+
}
|
38 |
+
return blocks;
|
39 |
+
},
|
40 |
+
},
|
41 |
+
],
|
42 |
+
},
|
43 |
+
edit: Edit,
|
44 |
+
save,
|
45 |
+
});
|
src/blocks/ditty/index.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Metaphor_Creations\Ditty\Blocks\Ditty;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Register the dynamic block.
|
7 |
+
*
|
8 |
+
* @since 1.0
|
9 |
+
* @return void
|
10 |
+
*/
|
11 |
+
function register_dynamic_block() {
|
12 |
+
if ( ! function_exists( 'register_block_type' ) ) {
|
13 |
+
return;
|
14 |
+
}
|
15 |
+
register_block_type( DITTY_DIR . '/build/blocks/ditty', [
|
16 |
+
'render_callback' => __NAMESPACE__ . '\render_dynamic_block',
|
17 |
+
] );
|
18 |
+
}
|
19 |
+
add_action( 'init', __NAMESPACE__ . '\register_dynamic_block' );
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Server rendering for /blocks/examples/12-dynamic
|
23 |
+
*/
|
24 |
+
function render_dynamic_block( $atts ) {
|
25 |
+
if ( is_admin() ) {
|
26 |
+
return false;
|
27 |
+
}
|
28 |
+
$args = array(
|
29 |
+
'id' => isset( $atts['ditty'] ) ? intval( $atts['ditty'] ) : false,
|
30 |
+
'display' => isset( $atts['display'] ) ? sanitize_text_field( $atts['display'] ) : false,
|
31 |
+
'el_id' => isset( $atts['customID'] ) ? sanitize_title( $atts['customID'] ) : false,
|
32 |
+
'class' => isset( $atts['customClasses'] ) ? esc_attr( $atts['customClasses'] ) : false,
|
33 |
+
);
|
34 |
+
return ditty_render( $args );
|
35 |
+
}
|
src/blocks/ditty/save.js
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { __ } from "@wordpress/i18n";
|
2 |
+
import { useBlockProps } from "@wordpress/block-editor";
|
3 |
+
|
4 |
+
export default function save({ attributes }) {
|
5 |
+
return null;
|
6 |
+
// const { ditty, display, customID, customClasses } = attributes;
|
7 |
+
// let classNames = "ditty dity--pre";
|
8 |
+
// if (customClasses) {
|
9 |
+
// classNames += ` ${customClasses}`;
|
10 |
+
// }
|
11 |
+
|
12 |
+
// return (
|
13 |
+
// <div {...useBlockProps.save()}>
|
14 |
+
// <div className={classNames} data-id={ditty} data-display={display}>
|
15 |
+
// This is my ditty...
|
16 |
+
// </div>
|
17 |
+
// </div>
|
18 |
+
// );
|
19 |
+
}
|
blocks/ditty-block/style.scss → src/blocks/ditty/script.js
RENAMED
File without changes
|
src/blocks/ditty/style.scss
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The following styles get applied both on the front of your site
|
3 |
+
* and in the editor.
|
4 |
+
*
|
5 |
+
* Replace them with your own styles or remove the file completely.
|
6 |
+
*/
|