WYSIWYG Field not swapping between editor modes
- This topic has 8 replies, 2 voices, and was last updated 6 years, 6 months ago by
SLG Marketing.
-
AuthorPosts
-
October 3, 2018 at 5:20 PM #11514
SLG Marketing
ParticipantI have added the WYSIWYG editor on a custom post type but I can't toggle between the visual and plain text editors.
I'm getting the following error in my dev console:
TypeError: j is undefined[Learn More] 3 load-scripts.php:702:681
e http://localhost/wp-admin/load-scripts.php:702:681
c/< http://localhost/wp-admin/load-scripts.php:702:271
C http://localhost/wp-includes/js/tinymce/wp-tinymce.php:3:11105
d http://localhost/wp-includes/js/tinymce/wp-tinymce.php:3:11256My code for the metaboxes is:
public function generateMetaBox($meta_boxes){ $prefix = strtolower($this->attributes['post']['single']); // Content Area $meta_boxes[]=array( 'id'=>'content', 'title'=>'Case Study Content', 'post_types' => $this->attributes['post']['slug'], 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'name' => 'cs-content', 'desc' => 'THIS NEEDS SOME INSTRUCTIONAL COPY', 'id' => $prefix . '_content_group', 'type' => 'group', 'clone' => true, 'sort_clone' => true, 'fields' => array( array( 'name' => 'Content Block', 'desc' => 'Content block test', 'id' => $prefix . '_content', 'type' => 'wysiwyg', ) ) ), ) ); return $meta_boxes; }
There are no other plugins installed and the CPT doesn't have the standard editor.
What am I doing wrong here?
October 4, 2018 at 4:56 PM #11534Anh Tran
KeymasterHi,
I've just tried your code and it works for me. Here is my screenshot:
https://i.imgur.com/JdbBHX7.png
I think the problem might come from another part that has JavaScript error. Any JS error can breaks the execution of other JS, which might include the JS for the editors. Can you add these lines to
wp-config.php
and see what's in the console:define( 'WP_DEBUG', true ); define( 'SCRIPT_DEBUG', true ); define( 'CONCATENATE_SCRIPTS', false );
October 10, 2018 at 8:55 PM #11591SLG Marketing
ParticipantHi
Sorry for taking so long to reply, I've been on another project. This is the output:
TypeError: textarea is undefined[Learn More] editor.js:100:5
switchEditor http://localhost/wp-admin/js/editor.js:100:5
init/< http://localhost/wp-admin/js/editor.js:34:7
C http://localhost/wp-includes/js/tinymce/tinymce.min.js:2:11105
d http://localhost/wp-includes/js/tinymce/tinymce.min.js:2:11256Any ideas?
October 10, 2018 at 9:09 PM #11592SLG Marketing
ParticipantI should add that we are using the classic editor and WP 4.9.8. No other plugins are installed.
October 12, 2018 at 11:07 AM #11602October 12, 2018 at 3:15 PM #11607SLG Marketing
ParticipantNot really as this is a local development site. I'll see about deploying it somewhere for you to test.
In the meantime I'll try reinstalling the Metabox plugin.
October 12, 2018 at 4:10 PM #11610SLG Marketing
ParticipantI have set up a demo site for you to debug on. let me know if there is anything else you need.
October 13, 2018 at 9:32 AM #11615Anh Tran
KeymasterThanks for the info. I'm checking your site and found a problem: the ID of the field contains a space:
https://i.imgur.com/sFnaTYm.png
That comes from the
$prefix = strtolower($this->attributes['post']['single']);
, which transformCase Study
to justcase study
. It should becase_study
. Please try this code:$prefix = str_replace(' ', '_', strtolower($this->attributes['post']['single']));
The space in field ID (and then in the input name/ID) causes unexpected behavior, and that might be a cause to this problem.
October 15, 2018 at 4:31 PM #11623SLG Marketing
ParticipantGreat spot! Thank you so much! It was driving me up the wall.
Thanks again, this has restored the anticipated behaviour.
-
AuthorPosts
- You must be logged in to reply to this topic.