Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

How to remove 'Project Gallery' meta box on project edit screen?

Open blackmekemeke opened this issue 12 years ago • 2 comments

I want to replace 'Project Gallery' meta box with my own custom meta box. Thanks

blackmekemeke avatar Nov 19 '14 15:11 blackmekemeke

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' )
                )
            )
        )
    )
);

GheorgheP avatar Nov 20 '14 06:11 GheorgheP

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' );

danyj avatar Feb 18 '16 17:02 danyj