2

我有这个用于 shorcodes 的 wordpress 插件。我正在尝试在我的主题中实现这一点,而无需安装它。

如何更改上面写着“plugin_dir_url”的这两行代码,以便从我的模板文件夹中获取文件?

class SYMPLE_TinyMCE_Buttons {
function __construct() {
    add_action( 'init', array(&$this,'init') );
}
function init() {
    if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
        return;     
    if ( get_user_option('rich_editing') == 'true' ) {  
        add_filter( 'mce_external_plugins', array(&$this, 'add_plugin') );  
        add_filter( 'mce_buttons', array(&$this,'register_button') ); 
        **wp_localize_script( 'jquery', 'sympleShortcodesVars', array('template_url' => plugin_dir_url( __FILE__ ) ) );**
    }  
}  
function add_plugin($plugin_array) {  
   **$plugin_array['symple_shortcodes'] = plugin_dir_url( __FILE__ ) .'js/symple_shortcodes_tinymce.js';**
   return $plugin_array; 
}
function register_button($buttons) {  
   array_push($buttons, "symple_shortcodes_button");
   return $buttons; 
}   

多谢。

4

1 回答 1

0

get_bloginfo("template_directory")应该这样做。

法典:get_bloginfo()

于 2012-12-04T03:20:57.730 回答