first commit
This commit is contained in:
43
wp-content/plugins/widget-shortcode/assets/block.js
Normal file
43
wp-content/plugins/widget-shortcode/assets/block.js
Normal file
@@ -0,0 +1,43 @@
|
||||
( function( wp ) {
|
||||
var el = wp.element.createElement;
|
||||
var __ = wp.i18n.__;
|
||||
var ServerSideRender = wp.components.ServerSideRender;
|
||||
var InspectorControls = wp.editor.InspectorControls;
|
||||
var SelectControl = wp.components.SelectControl;
|
||||
|
||||
wp.blocks.registerBlockType( 'widget-shortcode/block', {
|
||||
title: __( 'Widget Shortcode', 'widget-shortcode' ),
|
||||
icon: 'welcome-widgets-menus',
|
||||
category: 'widgets',
|
||||
attributes : {
|
||||
id: {
|
||||
default : '',
|
||||
},
|
||||
},
|
||||
// Display block preview and UI
|
||||
edit( props ) {
|
||||
return el( 'div', {}, [
|
||||
el( ServerSideRender, {
|
||||
block: "widget-shortcode/block",
|
||||
attributes: props.attributes
|
||||
} ),
|
||||
el( InspectorControls, {}, [
|
||||
el( SelectControl, {
|
||||
value : props.attributes.id,
|
||||
label : __( 'Widget', 'widget-shortcode' ),
|
||||
options : widgetShortcodeGutenberg.widgets,
|
||||
onChange : function( id ) {
|
||||
props.setAttributes( { id } );
|
||||
},
|
||||
} )
|
||||
] )
|
||||
] )
|
||||
},
|
||||
save() {
|
||||
// nothing to see here, ServerSideRender handles this
|
||||
return null;
|
||||
},
|
||||
} );
|
||||
}(
|
||||
window.wp
|
||||
) );
|
||||
30
wp-content/plugins/widget-shortcode/assets/tinymce.js
Normal file
30
wp-content/plugins/widget-shortcode/assets/tinymce.js
Normal file
@@ -0,0 +1,30 @@
|
||||
(function($) {
|
||||
if ( typeof widgetShortcodeTinyMCE === 'undefined' )
|
||||
return;
|
||||
|
||||
if ( widgetShortcodeTinyMCE.widgets.length < 1 )
|
||||
return;
|
||||
|
||||
tinymce.PluginManager.add( 'widgetShortcode', function( editor, url ) {
|
||||
var items = [];
|
||||
$.each( widgetShortcodeTinyMCE.widgets, function( i, v ) {
|
||||
var item = {
|
||||
'text' : v.label,
|
||||
'body': {
|
||||
'type': v.label
|
||||
},
|
||||
'onclick' : function(){
|
||||
editor.insertContent( '[widget id="' + v.value + '"]' );
|
||||
}
|
||||
};
|
||||
items.push( item );
|
||||
} );
|
||||
|
||||
editor.addButton( 'widgetShortcode', {
|
||||
title: widgetShortcodeTinyMCE.title,
|
||||
type : 'menubutton',
|
||||
image : widgetShortcodeTinyMCE.image,
|
||||
menu : items
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
BIN
wp-content/plugins/widget-shortcode/assets/widget-icon.png
Normal file
BIN
wp-content/plugins/widget-shortcode/assets/widget-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 786 B |
Reference in New Issue
Block a user