More Fields Plugin Remove Meta Boxes instead of Hiding them with Jquery
-
My site uses a lot of plugins that add meta boxes to the write panel of wordpress. I’m using More Fields plugin to create different types of posts (EX: Events, Article, Gallery, etc) and show only the meta boxes assigned to each type of post. It works fine, the problem is that More Fields use Javascript to hide the boxes , instead of only loading the corresponding meta boxes. This causes that my write page load very slow.
I tried to use remove_meta_box on different parts of my site but it didn’t work. I not sure if there is something wrong with this function.
My current solution involves modifying the wordpress do_meta_boxes function defined on the Template.php file to filter the metaboxes based on the post type. Can anybody suggest a better solution?function do_meta_boxes($page, $context, $object) { global $wp_meta_boxes; $type = attribute_escape($_GET['type']); //get type if ($type == '') $type = 'Article'; // default type $article_mbx = array('yapbdiv','wp-post-thumbnail','postexcerpt','postcustom','commentstatusdiv','tagsdiv'); $event_mbx = array('yapbdiv','wp-post-thumbnail','postexcerpt','postcustom','commentstatusdiv','tagsdiv','ec3_schedule_editor','event'); $venue_mbx = array('yapbdiv','wp-post-thumbnail','postexcerpt','postcustom','commentstatusdiv','tagsdiv','venues'); $gallery_mbx = array('yapbdiv','postexcerpt','postcustom','commentstatusdiv','tagsdiv','wp-gallery-rmz','gallerydiv'); $rotator_mbx = array('yapbdiv','postexcerpt','postcustom','rot3_schedule_editor'); $blog_mbx = array('yapbdiv','wp-post-thumbnail','postexcerpt','postcustom','commentstatusdiv','tagsdiv'); do_action('do_meta_boxes', $page, $context, $object); if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) ) return; foreach ( array('high', 'core', 'default', 'low') as $priority ) { foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) { if ( false === $box ) continue; if ($type == 'Article' && !in_array($box['id'], $article_mbx)) // filter metaboxes continue; if ($type == 'Event' && !in_array($box['id'], $event_mbx)) // filter metaboxes continue; if ($type == 'Venue' && !in_array($box['id'], $venue_mbx)) // filter metaboxes continue; if ($type == 'Gallery' && !in_array($box['id'], $gallery_mbx)) // filter metaboxes continue; if ($type == 'Rotator' && !in_array($box['id'], $rotator_mbx)) // filter metaboxes continue; if ($type == 'Blog' && !in_array($box['id'], $blog_mbx)) // filter metaboxes continue; echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '">' . "\n"; echo "<h3>{$box['title']}</h3>\n"; echo '<div class="inside">' . "\n"; call_user_func($box['callback'], $object, $box); echo "</div>\n"; echo "</div>\n"; } } }
- The topic ‘More Fields Plugin Remove Meta Boxes instead of Hiding them with Jquery’ is closed to new replies.