我已经在多个地方发布了这个问题,但是还没有任何回应,因此请在这里尝试。我正在创建一个Wordpress插件。该插件的一部分从数据库加载下拉列表。从下拉菜单中选择选项后,将使用Javascript从外部页面加载表单。我遇到的问题是,当我尝试加载wp_editor时,它仅被部分加载。它缺少工具栏。任何帮助表示赞赏。
这是我所得到的图像。
这是用于加载页面的javascript:
function showeditevent(str) {
var location1 = window.location.href;
var directoryPath = '<?php echo plugins_url(); ?>';
//alert(directoryPath);
if (str == "") {
document.getElementById("txtEditevent").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("txtEditevent").innerHTML = this.responseText;
}
};
xmlhttp.open("GET",directoryPath+"/events/editevent.php?q="+str,true);
xmlhttp.send();
}
}
这是editevent.php
<script src="../../../wp-includes/js/tinymce/tiny_mce_popup.js"></script>
<script src="../../../wp-includes/js/tinymce/tinymce.min.js"></script>
<?php
require_once('../../../wp-load.php');
require_once('../../../wp-includes/class-wp-editor.php');
//require_once('../../../wp-admin/admin-ajax.php');
global $wpdb;
$id = $_GET["q"];
$sql = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "cmc_events where id=$id");
$title = $sql->title;
$date = $sql->date;
$time = $sql->time;
$info = $sql->info;
$filename = $sql->filename;
$newdate = DateTime::createFromFormat('m-d-Y', $date)->format('Y-m-d');
?>
<form name="editevent" action="" method="post" enctype="multipart/form-data">
<table>
<tr>
<th align="right" valign="top">Title:</th>
<td><input type="text" name="title" placeholder="Title" value="<?php echo $title; ?>" /></td>
</tr>
<tr>
<th align="right" valign="top">Date:</th>
<td><input type="date" name="newdate" value="<?php echo $newdate; ?>" /></td>
</tr>
<tr>
<th align="right" valign="top">Time:</th>
<td><input type="time" name="newtime" value="<?php echo $time; ?>" /></td>
</tr>
<tr>
<th align="right" valign="top">Information:</th>
<td>
<?php
$content = $info;
$editor_id = 'info';
$settings = array(
'textarea_name' => 'info',
'textarea_rows' => 10,
'tinymce' => array(
'width' => 1000
)
);
wp_editor( $content, $editor_id, $settings );
?>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="save_edit_event" value="Save Edit"></td>
</tr>
</table>
</form>
答案 0 :(得分:0)
您是否通过user_can_richedit()函数检查当前用户是否可以进行richedit? WP_Editor仅在用户可以进行richedit时完全加载。