Instantly share code, notes, and snippets.
Last active
December 13, 2016 05:35
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save mustafix/afb3c0c9ef294c20892bc0a47d5b4719 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
tinymce.PluginManager.add('my_mce_button', function( editor, url ) { | |
editor.addButton( 'my_mce_button', { | |
title: 'Shortcode', | |
text: 'Shortcode', //Display name | |
icon: 'moderna', | |
type:'menubutton', | |
menu: [ | |
// First Menu Start | |
{ | |
text: 'Pricing Table 01', | |
menu: [ | |
{ | |
text: 'Pop-Up', | |
onclick: function() { | |
editor.windowManager.open( { | |
title: 'Insert Your Pricing Table Value', | |
body: [ | |
{ | |
type: 'textbox', | |
name: 'serviceTitle', | |
level:'Insert your title', | |
label: 'Title', | |
}, | |
{ | |
type: 'textbox', | |
name: 'serviceDescription', | |
level:'Insert your description', | |
label: 'Description', | |
multiline: true, | |
minWidth: 300, | |
minHeight: 100 | |
}, | |
{ | |
type: 'textbox', | |
name: 'serviceCategory', | |
level:'Insert your category', | |
label: 'Category', | |
} | |
], | |
onsubmit: function( e ) { | |
editor.insertContent( '[services title="' + e.data.serviceTitle + '" des="' + e.data.serviceDescription + '" category="' + e.data.serviceCategory + '"]'); | |
} | |
} | |
); | |
} | |
}, | |
{ | |
text: 'Pricing Table 02', | |
menu: [ | |
{ | |
text: 'Pricing Table 03', | |
menu: [ | |
{ | |
text: 'Pricing Table 04', | |
}, | |
] | |
}, | |
{ | |
text: 'Pricing Table 03', | |
menu: [ | |
{ | |
text: 'Pricing Table 04', | |
}, | |
{ | |
text: 'Pricing Table 04', | |
}, | |
] | |
}, | |
] | |
}, | |
] | |
}, | |
// // Second Menu Start Here | |
{ | |
text: 'Pop-Up', | |
onclick: function() { | |
editor.windowManager.open( { | |
title: 'Insert Your Pricing Table Value', | |
body: [ | |
{ | |
type: 'textbox', | |
name: 'textboxName', | |
label: 'Text Box', | |
value: '30' | |
}, | |
{ | |
type: 'textbox', | |
name: 'multilineName', | |
label: 'Multiline Text Box', | |
value: 'You can say a lot of stuff in here', | |
multiline: true, | |
minWidth: 300, | |
minHeight: 100 | |
}, | |
{ | |
type: 'textbox', | |
name: 'textboxName', | |
label: 'Text Box', | |
value: '30' | |
}, | |
{ | |
type: 'listbox', | |
name: 'listboxName', | |
label: 'List Box', | |
'values': [ | |
{text: 'Name 1', value: '1'}, | |
{text: 'Option 2', value: '2'}, | |
{text: 'Option 3', value: '3'} | |
] | |
} | |
], | |
onsubmit: function( e ) { | |
editor.insertContent( '[random_shortcode textbox="' + e.data.textboxName + '" multiline="' + e.data.multilineName + '" listbox="' + e.data.listboxName + '"]'); | |
} | |
} | |
); | |
} | |
}, | |
] | |
}); | |
}); | |
})(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Hooks your functions into the correct filters | |
function my_add_mce_button() { | |
// check user permissions | |
if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) { | |
return; | |
} | |
// check if WYSIWYG is enabled | |
if ( 'true' == get_user_option( 'rich_editing' ) ) { | |
add_filter( 'mce_external_plugins', 'my_add_tinymce_plugin' ); | |
add_filter( 'mce_buttons', 'my_register_mce_button' ); | |
} | |
} | |
add_action('admin_head', 'my_add_mce_button'); | |
// Declare script for new button | |
function my_add_tinymce_plugin( $plugin_array ) { | |
$plugin_array['my_mce_button'] = get_template_directory_uri() .'/js/tiny-mce-button.js'; | |
return $plugin_array; | |
} | |
// Register new button in the editor | |
function my_register_mce_button( $buttons ) { | |
array_push( $buttons, 'my_mce_button' ); | |
return $buttons; | |
} | |
?> | |
<?php | |
Note: 1."tiny-mce-button.js" file কে js file মধ্য দিতে হবে | |
2. "tiny-mce-button.php" file কে functions.php তে call করে দিলেই হবে (আর কিছু করা লাগবে না) | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment