2
TinyMCEプラグインを使用してエディタボタンを作成しました。エディタツールバーにボタンが表示されています。しかし、それをクリックして値を配置すると、次のコンソールエラーが表示されます。どうすればいいですか?エディタボタンを使用してショートコード値を配置できません - キャッチしないタイプのエラーを取得します
WordPressのバージョン:4.7.5
Uncaught TypeError: Cannot read property 'paste' of undefined
at d (http://vagrant.local/wp/wp-includes/js/tinymce/wp-tinymce.php?c=1&ver=4506-20170408:9:9994)
at Object.f [as insertAtCaret] (http://vagrant.local/wp/wp-includes/js/tinymce/wp-tinymce.php?c=1&ver=4506-20170408:9:10103)
at mceInsertContent (http://vagrant.local/wp/wp-includes/js/tinymce/wp-tinymce.php?c=1&ver=4506-20170408:9:14254)
at Object.m [as execCommand] (http://vagrant.local/wp/wp-includes/js/tinymce/wp-tinymce.php?c=1&ver=4506-20170408:9:10568)
at L.execCommand (http://vagrant.local/wp/wp-includes/js/tinymce/wp-tinymce.php?c=1&ver=4506-20170408:13:4493)
at L.<anonymous> (http://vagrant.local/content/themes/vip/yrc-wordpress-theme/plugins/mce-live-chat-button/mce-live-chat-button-plugin.js?wp-mce-4506-20170408:20:20)
at D.exec.(anonymous function) (http://vagrant.local/wp/wp-includes/js/tinymce/wp-tinymce.php?c=1&ver=4506-20170408:9:11468)
at Object.m [as execCommand] (http://vagrant.local/wp/wp-includes/js/tinymce/wp-tinymce.php?c=1&ver=4506-20170408:9:10568)
at L.execCommand (http://vagrant.local/wp/wp-includes/js/tinymce/wp-tinymce.php?c=1&ver=4506-20170408:13:4493)
at t.cmd.t.onclick (http://vagrant.local/wp/wp-includes/js/tinymce/wp-tinymce.php?c=1&ver=4506-20170408:13:3626)
これは私のショートです:
<?php
add_shortcode('live-chat-button', 'live_chat_editor_button_html');
function live_chat_editor_button_html() {
$button_html = 'I have been placed...';
return $button_html;
}
これは、JSファイルです:
(function() {
tinymce.create('tinymce.plugins.LiveChatEditorButton', {
init : function(ed, url) {
ed.addButton('livechat', {
text: 'Live Chat',
//icon: 'dashicons dashicons-admin-links',
tooltip: 'Live Chat',
cmd: 'livechat',
});
ed.addCommand('livechat', function(){
ed.execCommand('mceInsertContent', '[live-chat-button]');
});
},
createControl : function(n, cm) {
return null;
},
getInfo : function() {
return {
longname : 'Live chat editor button',
version : "0.1"
};
}
});
// Register plugin
tinymce.PluginManager.add('yrceditorbutton', tinymce.plugins.LiveChatEditorButton);
})();
そして、ここでは、私が使用していたコードです私のfunctions.phpファイル:
add_action('init', 'yrc_live_chat_editor_button');
function yrc_live_chat_editor_button() {
add_filter("mce_external_plugins", "yrc_add_button");
add_filter('mce_buttons', 'yrc_register_button');
}
function yrc_add_button($plugin_array) {
$plugin_array['yrceditorbutton'] = get_template_directory_uri() . '/plugins/mce-live-chat-button/mce-live-chat-button-plugin.js';
return $plugin_array;
}
function yrc_register_button($buttons) {
array_push($buttons, 'livechat');
return $buttons;
}
私は上記のJSエラーを解決するのを手伝ってください。
もう一度申し訳ありません。私はボタンでダッシュボードを表示したいが、それは空の四角形として表示されます。ダシコンが現れるようにするために何をする必要がありますか?
初めてエディタボタンを作成しています。だから私の初心者の知識を考慮してください。