PluginProbe ʕ •ᴥ•ʔ
Shortcoder — Create Shortcodes for Anything / 5.0.4
Shortcoder — Create Shortcodes for Anything v5.0.4
trunk 3.0 3.0.1 3.1 3.2 3.3 3.4 3.4.1 4.0 4.0.1 4.0.2 4.0.3 4.1 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2 4.3 4.4 4.5 4.6 5.0 5.0.1 5.0.2 5.0.3 5.0.4 5.1 5.2 5.2.1 5.3 5.3.1 5.3.2 5.3.3 5.3.4 5.4 5.5 5.6 5.7 5.8 6.0 6.1 6.2 6.3 6.3.1 6.3.2 6.4 6.5 6.5.1 6.5.2 6.5.3
shortcoder / admin / js / blocks / shortcoder.js
shortcoder / admin / js / blocks Last commit date
shortcoder.js 6 years ago
shortcoder.js
88 lines
1 (function( blocks, element ){
2 var el = element.createElement;
3
4 function shortcoderBlock( props ){
5
6 return el( 'div', {
7 'id': 'shortcoder_wrap_' + props.instanceId,
8 'style': {
9 'background-color': '#f8f9f9',
10 'padding': '15px',
11 'border-radius': '5px'
12 }
13 },
14 el( window.wp.editor.PlainText, {
15 'id': 'shortcoder_box_' + props.instanceId,
16 'className': 'input-control',
17 'onChange': function(value){
18 props.setAttributes({
19 text: value
20 });
21 },
22 'placeholder': 'Select/enter shortcode',
23 'spellcheck': 'false',
24 'value': props.attributes.text,
25 'style': {
26 'font-family': 'monospace',
27 'font-size': '15px'
28 }
29 }),
30 el( 'button', {
31 'class': 'button button-primary',
32 'onClick': function(){
33 if( window.sc_show_insert ){
34 var sc_val = document.getElementById('shortcoder_box_' + props.instanceId).value;
35 window.sc_show_insert( sc_val, props.instanceId );
36 }
37 }
38 }, 'Select shortcode')
39 );
40
41 }
42
43 function icon() {
44 return el('svg', {
45 width: 64,
46 height: 64,
47 viewBox: '0 0 16.933 16.933'
48 }, el('g', {
49 fill: '#00aee9',
50 transform: 'translate(-22.213 -238.799) scale(.93445)'
51 }, el('path', {
52 d: 'M24.549 257.815a.493.493 0 00-.495.494v12.602c0 .274.22.495.495.495h3.541c.274 0 .494-.22.494-.495v-.993a.493.493 0 00-.494-.494h-2.054v-9.627h2.054c.274 0 .494-.22.494-.494v-.994a.493.493 0 00-.494-.494H24.55z'
53 }), el('rect', {
54 ry: 0.515,
55 transform: 'matrix(1 0 -.2671 .96367 0 0)',
56 y: 265.478,
57 x: 104.75,
58 height: 18.217,
59 width: 2.464
60 }), el('path', {
61 d: 'M37.573 257.815a.493.493 0 00-.494.494v.994c0 .273.22.494.494.494h2.054v9.627h-2.054a.493.493 0 00-.494.494v.993c0 .274.22.495.494.495h3.542c.274 0 .494-.22.494-.495V258.31a.493.493 0 00-.494-.494h-3.542z'
62 })));
63 }
64
65 blocks.registerBlockType( 'shortcoder/shortcoder', {
66 title: 'Shortcoder',
67 icon: icon,
68 category: 'widgets',
69 attributes: {
70 text: {
71 type: 'string',
72 source: 'text'
73 },
74 },
75 supports: {
76 html: false,
77 customClassName: false,
78 className: false
79 },
80 edit: wp.compose.withInstanceId( shortcoderBlock ),
81 save: function(props) {
82 return el( element.RawHTML, {}, props.attributes.text);
83 },
84 });
85 }(
86 window.wp.blocks,
87 window.wp.element
88 ));