2013-05-11 22 views
1

我想創建一個插件與可視化編輯器並添加媒體按鈕,可以POST和插入到數據庫中的所有HTML數據。這裏是我的代碼:wordpress插件wp_editor不張貼圖像

<?php 
if($_POST){ 
    print_r($_POST); 
    global $wpdb; 
    $table_name = $wpdb->prefix . "eventi_ecm"; 
    $name = $_POST['name']; 
    $text = $_POST['content']; 
    //$rows_affected = $wpdb->insert($table_name, array('time' => current_time('mysql'), 'name' => $name, 'text' => $text)); 
} 
$settings = array('textarea_name' => 'content','media_buttons' => true,'tinymce' => false); 
?> 
<div> 
    <h2>New Event</h2> 
    <form method="post" action="http://test.ble-group.com/wordpress/wp-admin/admin.php?page=eventi_new_page"> 
     <div id="poststuff"> 
      <input type="text" name="name"/> 
      <?php wp_editor('', 'content', $settings); ?> 
      </div> 
     </div> 
     <input type="hidden" name="action" value="update" /> 
     <p><input type="submit"/></p> 
    </form> 
</div> 

但是,當我嘗試插入圖像,關於圖像的HTML代碼被剝離。 。:(

回答

0

謝謝@ user850010,但沒有奏效,我這樣解決:

echo '<pre>' . htmlspecialchars(stripslashes($_POST['content'])) . '</pre>'; 
1

我發現this文章可能有助於您

總之,本文建議使用此代碼:

<?php wp_editor(stripslashes($content), $editor-id); ?> 

與此代碼顯示輸出:

<?php echo wpautop(stripslashes($editor-id)); ?>