I’m creating a setting to set a logo. It works but there is a problem.
I only need one image to be set so the gallery item should be disabled / hidden. Of course this should only effect this page, of even better this setting.

<?php
// above this I do a simple settings api
?>
<input id="set_logo" type="text" size="100" name="set_logo" value="<?php echo esc_attr( $value ); ?>" />
<?php
do_action( 'media_buttons', 'set_logo' );

I’ve looked in multiple places in code but I can’t find any clues how to do this.

EDIT
I’ve solved it in a different way that is not related to this. The solution is now implemented in my first plugin: http://wordpress.org/extend/plugins/default-featured-image/
shameless plug.

2 Answers
2

You can disable tabs using a filter hook. Replace wpse_76095_isOurMediaUpload() with however you determine that you’re running the media popup.

add_filter('media_upload_tabs', 'wpse_76095_filterMediaUploadTabs');

/**
* filter out unwanted media upload tabs
* @param array $tabs
* @return array
*/
function wpse_76095_filterMediaUploadTabs($tabs) {
    if (wpse_76095_isOurMediaUpload()) {
        unset(
            $tabs['type_url'],  // no linking from external sites (no local image)
            $tabs['gallery'],   // no galleries
            $tabs['nextgen']    // no NextGEN galleries
        );
    }

    return $tabs;
}

Leave a Reply

Your email address will not be published. Required fields are marked *