php aggiungo un campo select con gli shortcode desiderati。 Il primo文件si mette nella function del tem
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php aggiungo un campo select con gli shortcode desiderati。 Il primo文件si mette nella function del tem相关的知识,希望对你有一定的参考价值。
(function() {
tinymce.PluginManager.add('rashortcodes', function( editor )
{
var shortcodeValues = [];
jQuery.each(shortcodes_button, function(i)
{
shortcodeValues.push({text: shortcodes_button[i], value:i});
});
editor.addButton('rashortcodes', {
type: 'listbox',
text: 'Shortcodes',
onselect: function(e) {
var v = e.control.state.data.text;
console.log(e);
tinyMCE.activeEditor.selection.setContent('[' + v + '][/' + v + ']');
},
values: shortcodeValues
});
});
})();
//aggiungo select con shortcode nell'editor
new Shortcode_Tinymce();
class Shortcode_Tinymce
{
public function __construct()
{
add_action('admin_init', array(
$this,
'shortcode_button'
));
add_action('admin_footer', array(
$this,
'get_shortcodes'
));
}
public function shortcode_button()
{
if (current_user_can('edit_posts') && current_user_can('edit_pages')) {
add_filter('mce_external_plugins', array(
$this,
'add_buttons'
));
add_filter('mce_buttons', array(
$this,
'register_buttons'
));
}
}
public function add_buttons($plugin_array)
{
$path = get_template_directory_uri() . '/js/shortcode-tinymce-button.js';
$plugin_array['rashortcodes'] = $path;
return $plugin_array;
}
public function register_buttons($buttons)
{
array_push($buttons, 'separator', 'rashortcodes');
return $buttons;
}
public function get_shortcodes()
{
global $shortcode_tags;
$scPermessi = ['titoletto1', 'titoletto2'];
echo '<script type="text/javascript">
var shortcodes_button = new Array();';
$count = 0;
foreach ($shortcode_tags as $tag => $code) {
if (array_search($tag, $scPermessi) !== false) {
echo "shortcodes_button[{$count}] = '{$tag}';";
$count++;
}
}
echo '</script>';
}
}
以上是关于php aggiungo un campo select con gli shortcode desiderati。 Il primo文件si mette nella function del tem的主要内容,如果未能解决你的问题,请参考以下文章