2015-10-02 69 views
0

我最近不得不更新舊的(3.0.1)Wordpress網站,同時保持所有管理員功能,插件等與以前一樣。唯一讓人搞不清楚的是舊的「More Fields」插件中的wysiwyg字段,它曾經是一個tinyMCE文本編輯器,現在它只是一個帶有html標記的textarea。WordPress的管理員:如何將文本編輯器添加到插件textarea?

從我可以告訴這是它如何被從多個字段,object.php稱爲:

$wysiwyg = new mf_field_type; 
    $wysiwyg->title = __('WYSIWYG', 'more-fields'); 
    $wysiwyg->html_before = ' 

    <script type="text/javascript"> 
     /* <![CDATA[ */ 
// jQuery(document).ready(function() { 
//  tinyMCE2 = tinyMCE; 
     tinyMCE.init({ 
      mode:"textareas", 
      width:"100%", 
      theme:"advanced", 
      skin:"wp_theme", 
      theme_advanced_buttons1:"bold,italic,strikethrough,|,bullist,numlist,blockquote,|,justifyleft,justifycenter,justifyright,|,link,unlink,wp_more,|,spellchecker,fullscreen,wp_adv", 
      theme_advanced_buttons2:"", //formatselect,underline,justifyfull,forecolor,|,pastetext,pasteword,removeformat,|,media,charmap,|,outdent,indent,|,undo,redo,wp_help", 
      theme_advanced_buttons3:"", 
      theme_advanced_buttons4:"",language:"en",spellchecker_languages:"+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv", 
      theme_advanced_toolbar_location:"top", 
      theme_advanced_toolbar_align:"left", 
      theme_advanced_statusbar_location:"bottom", 
      theme_advanced_resizing:"0", 
      theme_advanced_resize_horizontal:"", 
      plugins:"safari,inlinepopups,spellchecker,paste,wordpress,media,fullscreen,wpeditimage", 
      editor_selector:"%key%" 
     }); 
// });  

     jQuery(document).ready(function() { 
      jQuery("#%key%").addClass("mceEditor"); 
      if (typeof(tinyMCE) == "object" && typeof(tinyMCE.execCommand) == "function") { 
      tinyMCE.execCommand("mceAddControl", false, "%key%"); 
      } 
     }); 

     /* ]]> */ 
     </script> 
     <div style="width: 100%"> 
    <textarea class="%class% %key%" name="%key%" id="%key%">' . "\n"; 

    $wysiwyg->html_item = "%value%"; 
    $wysiwyg->html_after = "</textarea></div>\n"; 
    $this->field_types[] = $wysiwyg; 

This is the whole file

我已經試過crowbarring以各種方式wp_editor但我的PHP技能是非常基本的,所以任何人都可以告訴我如何將該textarea製作成文本編輯框?無論是使用php還是jQuery等等,它只需要一大堆格式化按鈕,編輯器就可以更容易地發佈內容。

謝謝!

回答

0

使用說明

// jQuery 
wp_enqueue_script('jquery'); 

     <?php 
      $settings = array(
      'teeny' => true, 
      'textarea_rows' => 5, 
      'tabindex' => 1, 
      'media_buttons' => false 
      ); 
      wp_editor(__(get_option('whatever_you_need', 'field_value')), 'field_name', $settings); 
     ?> 
相關問題