2014-09-03 14 views
9

Voglio aggiungere editor di WordPress dinamicamente utilizzando jQuery nel mio plugin personalizzato come segue:Come caricare wp_editor usando Jquery?

<?php 

    $content = ''; 

    $editor_id = 'mycustomeditor';  

?> 

$('#container').append('<?php wp_editor($content, $editor_id);?>'); 

sto ottenendo errore:

SyntaxError: missing) after argument list

...-active"><link rel='stylesheet' id='editor-buttons-css' href='http://localhost 

Ho anche provato il codice qui sotto (qui ho sostituito apici a doppi apici):

:

<?php 

    $content = ''; 

    $editor_id = 'mycustomeditor';  

    ?> 

    $('#container').append("<?php wp_editor($content, $editor_id);?>"); 

sto ottenendo l'errore

SyntaxError: missing) after argument list 


$('#container').append("<div id="wp-mycustomeditor-wrap" class="wp-core-ui wp-ed... 

Se avete qualche soluzione, fatemelo sapere.

Grazie in anticipo

risposta

3

so risposta in ritardo. ma aiuterà gli altri. Prova questo plugin jQuery.

https://github.com/anteprimorac/js-wp-editor

è possibile utilizzare semplici come qui di seguito

jQuery(document).ready(function(){ 

     jQuery('#container').wp_editor(); 

    }); 
0

Credo che il problema è che si sta utilizzando sola virgola invertita qui:

'<?php wp_editor($content, $editor_id);?>'

e qui:

$content = ''; 
    $editor_id = 'mycustomeditor'; 

Provare con doppie virgolette e vedere se questo aiuta.

2
add_action('init','my_wpEditOUPUTT');function my_wpEditOUPUTT(){ 
if (isset($_POST['Give_me_editorrr'])){ 
    wp_editor('' , 'txtrID_'.$_POST['myNumber'], $settings = array('editor_class'=>'my_class',  'textarea_name'=>'named_'. $_POST['myNumber'], 'tinymce'=>true , 'media_buttons' => true , 'teeny' => false,)); 
    exit; 
}} 

<div id="MyPlace"></div> <a href="javascript:myLoad();">Click to load</a> 

<script type="text/javascript"> 
    startNumber = 1; 
    function myLoad(){ alert('wait 1 sec'); 
    startNumber ++; 
    $.post('./index.php', '&Give_me_editorrr=1&myNumber='+startNumber , 
    function(data,status){ 
     if (status == "success") { 
      document.getElementById('MyPlace').innerHTML += data; alert("Inserted!"); 
      tinymce.init({ selector: 'txtrID_'+startNumber, theme:'modern', skin:'lightgray'}); tinyMCE.execCommand('mceAddEditor', false, 'txtrID_'+startNumber); 
     } 
});} 

0

nee commento char interna (") e cambiare wp_ da the_ ottenere la stringa di

in php:.

$editorCode = the_editor($content, $editor_id); 

nello script sostituire:

$('#container').append("<?php echo str_replace('"', '\"', $editorCode); ?>"); 
Problemi correlati