まず、カスタムTinyMCEボタンを追加します。
function add_mce_button_custom_em() {
    // 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', 'add_tinymce_plugin_custom_em' );
        add_filter( 'mce_buttons', 'register_mce_button_custom_em' );
    }
}
add_action('admin_head', 'add_mce_button_custom_em');
次に、新しいボタンを宣言して登録します。
// Declare script for new button
function add_tinymce_plugin_custom_em( $plugin_array ) {
    $plugin_array['custom_em'] = get_template_directory_uri() .'/plug/custom-em/custom-em.js';
    return $plugin_array;
}
// Register new button in the editor
function register_mce_button_custom_em( $buttons ) {
    array_push( $buttons, 'custom_em' );
    return $buttons;
}
最後に、表示するボタンを決定します(ボタンの詳細については、コンテンツのフォーマットで確認できます)。明らかに、UXを念頭に置いている場合は、そのうちのいくつかだけを表示します。例:
// TinyMCE: TinyMCE choose which buttons you want to display
function myformatTinyMCE( $in ) {
    $in['toolbar1'] = 'styleselect,bold,custom_em,blockquote,hr,aligncenter,link,unlink,spellchecker,undo,removeformat';
    return $in;
}
add_filter( 'tiny_mce_before_init', 'myformatTinyMCE' );
add_tinymce_plugin_custom_em関数でわかるように、内部でJavaScriptファイルを宣言しています。get_template_directory_uri() .'/plug/custom-em/custom-em.js'
したがって、custom-em.jsファイルを作成します。これを行うには2つの方法があります。
次のショートコード形式[shortcode foo="" bar=""]またはを使用できます[shortcode][/shortcode]。
[shortcode foo="" bar=""]フォーマットから始めましょう:
(function() {
    tinymce.create('tinymce.plugins.custom_em', {
        init : function(ed, url) {
            ed.addButton('custom_em', {
                title : 'Custom EM',
                image : url+'/images/btn_custom_em.png',
                onclick : function() {
                    ed.execCommand(
                        "mceInsertContent",
                        false,
                        "[shortcode foo=\"\" bar=\"\"]"
                    );
                }
            });
        }
    });
    tinymce.PluginManager.add('custom_em', tinymce.plugins.custom_em);
})(); 
ご覧のとおり、ボタンアイコンとして画像を使用しています。以下の例で概説するように、それをテキストに変更できます。
以下は、独自のプラットフォームで使用するものであり、選択範囲をラップします<em class="whatever">hello world</em>。
(function() {
    tinymce.PluginManager.add('custom_em', function( editor, url ) {
        editor.on('init', function(e) {
            this.formatter.register('thetarget', {
                inline : 'em',
                classes : 'whatever'
            });
        });
        editor.addButton('custom_em', {
            text: 'Custom EM',
            icon: false,
            onclick : function() {
                var contents = editor.selection.getContent(),
                tags = jQuery(jQuery.parseHTML(contents)).find('em.whatever').andSelf();
                editor.formatter.toggle('thetarget');
            }
        });
    });
})(jQuery);
結果を投稿して編集してください。TinyMCEはペストで頭痛が必要ですが、共同で解決できます。