How to remove 'Project Gallery' meta box on project edit screen?
I want to replace 'Project Gallery' meta box with my own custom meta box. Thanks
It's easy to remove the metabox and add the new one, the problem is that you'll lose the functionality of the project gallery, as at the moment the gallery can be populated only from Project Gallery area.
Here is a function that will help to remove the Project Gallery metabox:
/**
* Remove portfolio project "Project Gallery" metabox
*/
function fw_remove_portfolio_project_gallery_metabox() {
remove_action( 'fw_post_options', array( fw()->extensions->get( 'portfolio' ), '_action_admin_add_post_options' ) );
}
add_action( 'init', 'fw_remove_portfolio_project_gallery_metabox' );
And in framework-customizations/theme/options/posts/fw-portfolio.php add the metabox option you need:
<?php if ( ! defined( 'FW' ) ) {
die( 'Forbidden' );
}
$options = array(
'my-metabox' => array(
'context' => 'side',
'title' => __( 'My Metabox', 'unyson' ),
'type' => 'box',
'options' => array(
'project-gallery' => array(
'label' => false,
'type' => 'multi-upload',
'desc' => false,
'texts' => array(
'button_add' => __( 'Set project gallery', 'unyson' ),
'button_edit' => __( 'Edit project gallery', 'unyson' )
)
)
)
)
);
info above is wrong , this is a filter now https://github.com/ThemeFuse/Unyson-Portfolio-Extension/blob/master/class-fw-extension-portfolio.php#L227
not an action so to remove it you should use
/**
* Remove portfolio project "Project Gallery" metabox
*/
function fw_remove_portfolio_project_gallery_metabox() {
remove_filter( 'fw_post_options', array( fw()->extensions->get( 'portfolio' ), '_filter_admin_add_post_options' ) );
}
add_action( 'init', 'fw_remove_portfolio_project_gallery_metabox' );