Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php WP Tiny MCE Posts编辑器上的自定义按钮用于短代码_Php_Wordpress_Tinymce_Shortcode - Fatal编程技术网

Php WP Tiny MCE Posts编辑器上的自定义按钮用于短代码

Php WP Tiny MCE Posts编辑器上的自定义按钮用于短代码,php,wordpress,tinymce,shortcode,Php,Wordpress,Tinymce,Shortcode,试图在Wordpress的Post editor上的微型MCE编辑器上创建一个特殊按钮。我想为我创建的快捷代码工具提示创建一个按钮 查看我想要的输出: 我的工具提示快捷码有以下代码: //Text tooltip function tooltip($atts, $content = ''){ $atts = shortcode_atts( array( 'class' => '', 'title' => ''

试图在Wordpress的Post editor上的微型MCE编辑器上创建一个特殊按钮。我想为我创建的快捷代码工具提示创建一个按钮

查看我想要的输出:

我的工具提示快捷码有以下代码:

//Text tooltip
function tooltip($atts, $content = ''){
    $atts = shortcode_atts(
        array(
          'class' => '',
          'title' => ''
        ), $atts);


     $html = '<a class="' . $atts['class'] .'"  title="'. $atts['title']. '" href="#">' . $content . ' <span>' .$atts['title']. '</span> </a>';
    return $html;    
  } 

add_shortcode('tooltip', 'tooltip');
[tooltips class="top_tooltip" title="Your Tooltip here"] Text here [/tooltip]
我所做的是创建了一些函数,使用以下代码在我的主题的functions.php文件上显示我创建的自定义按钮工具提示快捷码

//Create Tiny MCE buttons
function mce_tooltip($button) {
  $buttons[] = 'superscript';
  return $button;
}
add_filter('mce_buttons_2', 'mce_tooltip');



/*
* Callback function to filter the MCE settings
*/

function mce_tooltip( $init_array ) {  

// Define the style_formats array

  $style_formats = array(  
    // Each array child is a format with it's own settings
    array(  
      'class' => '',  
      'title' => ''      
  );  
  // Insert the array, JSON ENCODED, into 'style_formats'
  $init_array['style_formats'] = json_encode( $style_formats );  

  return $init_array;  

} 
// Attach callback to 'tiny_mce_before_init' 
add_filter( 'tiny_mce_before_init', 'mce_tooltip' ); 
我尝试了代码,但在Wordpress上的微型MCE编辑器上,它不会显示我的自定义快捷码按钮。你知道如何做得更好吗


试试这个教程,它很管用。它教您如何在新的tinymce 4中添加自定义按钮,以及如何将其用于您自己的短代码

检查您的代码。我猜有无效的返回值

function mce_tooltip($button) {
  $buttons[] = 'superscript';
  return $button;
}

对于TinyMCE高级版本:4.1.1,请执行以下步骤:

在/wp content/plugins/tinymce-advanced/tinymce-advanced.php函数中,获取所有按钮添加$buttons[]=“yourButton” 在/wp中包括/js/tinymce/tinymce.min.js,在一些按钮之后添加您自己的 e、 addButton'yourButton',{title:'yourButton',text:yourButton,'class':'yourButton btn',onclick:function{e.focus;e.selection.setContent+e.selection.getContent+;}} 然后进入wp admin中的tinymce设置,并将新按钮添加到编辑器中。
很抱歉回复太晚,为了给你一个基于代码的工作版本,还有很多东西要写,这就是我链接教程的原因。。这是一个循序渐进的过程。非常糟糕的主意。编辑wp中包含的文件这绝对是错误的方法!!!!wp includes类似于供应商目录-这意味着,不要修改其中的任何内容!!