问题
I have 2 metaboxes added to "page" type. But only in first case Wordpress (on its own) adds hide-if-js class to metabox container. Questin is - when does Wordpress add this hide-if-js to the metabox container div ??
First metabox add code - this one gets hide-if-js class automatically:
add_action( 'add_meta_boxes', 'add_portfolio_template_meta' );
function add_portfolio_template_meta() {
add_meta_box('projects-details-for-template', 'Portfolio template options:', 'projects_details_for_template_html', 'page', 'side', 'default');
}
Second metabox add script:
add_action( 'add_meta_boxes', 'add_contact_template_meta' );
function add_contact_template_meta() {
add_meta_box('contact-details-for-template', 'Contact page details:', 'contact_details_html', 'page', 'side', 'default');
}
回答1:
Just ran into this today. Turns out it's related to the top "screen options" section (top right of the backend when editing a post, pulls open a new div).
The "hide-if-js" class will be on your metabox when the page is loaded if it's unselected in "screen options". To remove the class/make the metabox visible, check it off.
回答2:
After updating my WordPress to 3.9 I noticed I could no longer type inside the big content box. I also noticed the editor menu above the box was gone. Using Google Chrome / Inspect Element I saw a red error msg that said "Uncaught TypeError" tinymce was trying to load but couldn't. I looked at the right of the element inspector and saw that the div caught had a style of "hide-if-js". Began researching and came across this post.
I discovered that WordPress 3.9 no longer supports TinyMCE but instead uses WP-edit. I never installed TinyMCE but it made me realize that another plugin may possible be built on top of it. I one by one deactivated the plugins I had installed, checking back after each one to see if that fixed the problem. After the 3rd plugin I deactivated, the editor menu appeared again and I could type in the content box! (I did go back and reactivate the 1st 2 plugins since I knew these were not the problems.)
I hope that helps. By the way - the plugin that was causing the problem was Foter but I am sure there are several other plugins out there causing the same problem.
来源:https://stackoverflow.com/questions/15067832/when-does-wordpress-add-hide-if-js-class-to-metaboxes