简体   繁体   中英

wp_editor not loading completely

I have posted this question in multiple places, but haven't had any responses so going to try here. I am creating a Wordpress plugin. Part of the plugin loads a dropdown from a database. When an option is selected from the dropdown, a form is loaded from an external page using Javascript. The issue I am having is that when I try to load the wp_editor, it is only partially loaded. It is missing the toolbars. Any help is appreciated.

Here is an image of what I am getting.

在此处输入图片说明

Here is the javascript used to load the page:

 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(); } } 

And here is 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('md-Y', $date)->format('Ym-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> 

Do you check if the current user can richedit by user_can_richedit() function? WP_Editor will only fully load when users can richedit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM