PluginProbe
LoftLoader / 2.3.1
LoftLoader v2.3.1
trunk 1.0.0 1.0.1 1.0.2 2.0.0 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.3 2.3.1 2.3.2 2.3.3 All 34 releases
loftloader / inc / any-page / gutenberg / plugin.js

plugin.js in LoftLoader 2.3.1, at inc/any-page/gutenberg/plugin.js

92 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function( editor, components, i18n, element, $ ) {
2 "use strict";
3
4 const __ = i18n.__;
5 const el = element.createElement;
6 const compose = wp.compose.compose;
7 const registerPlugin = wp.plugins.registerPlugin;
8
9 const {
10 Fragment,
11 Component
12 } = element;
13
14
15 const {
16 TextareaControl,
17 PanelBody
18 } = components;
19
20 const {
21 dispatch,
22 withSelect,
23 withDispatch
24 } = wp.data;
25
26 const {
27 PluginSidebar,
28 PluginSidebarMoreMenuItem
29 } = wp.editPost;
30
31 const Icon = el( 'svg', {
32 height: '20px',
33 width: '20px',
34 viewBox: '0 0 17.39 17.39'
35 }, el ( 'polygon', {
36 points: '14.77 11.19 17.3 8.65 14.77 6.12 14.77 2.53 11.19 2.53 8.65 0 6.12 2.53 2.53 2.53 2.53 6.12 0 8.65 2.53 11.19 2.53 14.77 6.12 14.77 8.65 17.3 11.19 14.77 14.77 14.77 14.77 11.19'
37 } )
38 );
39
40 function LoftLoaderPlugin( props ) {
41 return el( Fragment, {},
42 el( PluginSidebarMoreMenuItem, { target: 'loftloader-any-page' }, __( 'LoftLoader Any Page Shortcode' ) ),
43 el( PluginSidebar, { name: 'loftloader-any-page', title: __( 'LoftLoader Any Page Shortcode' ) },
44 el( PanelBody, {
45 className: 'loftloader-any-page-sidebar',
46 initialOpen: true
47 },
48 el( TextareaControl, {
49 label: __( 'Paste LoftLoader shortcode into the box below' ),
50 value: props.meta.loftloader_page_shortcode,
51 onChange: ( value ) => {
52 props.updateValue( { loftloader_page_shortcode: value } );
53 }
54 } )
55 ),
56 el( 'input', {
57 type: 'hidden',
58 name: 'loftloader_gutenberg_enabled',
59 value: 'on'
60 } )
61 )
62 );
63 }
64
65 // Fetch the post meta.
66 const applyWithSelect = withSelect( ( select ) => {
67 const { getEditedPostAttribute } = select( 'core/editor' );
68 return { meta: getEditedPostAttribute( 'meta' ) };
69 } );
70
71 const applyWithDispatch = withDispatch( ( dispatch ) => {
72 const { editPost } = dispatch( 'core/editor' );
73 return {
74 updateValue: function( value ) {
75 editPost( { meta: { ...value } } );
76 }
77 }
78 } );
79
80 const render = compose( [ applyWithSelect, applyWithDispatch ] )( LoftLoaderPlugin );
81
82 registerPlugin( 'loftloader-any-page', {
83 icon: Icon,
84 render
85 } );
86 } )(
87 window.wp.editor,
88 window.wp.components,
89 window.wp.i18n,
90 window.wp.element,
91 jQuery
92 );