Featured Image add tab

WordPress does not have a built-in hook or function on the PHP side that allows you to directly add a new tab to the Media Library Modal window. To achieve this, you need to use JavaScript to modify the media uploader interface.

You can add a custom tab to the WordPress Media Library modal by using JavaScript to extend the media frame. Here’s a quick example:

JavaScript Code:

jQuery(document).ready(function($){
    var originalMediaTabs = wp.media.view.MediaFrame.Select.prototype.browseRouter;
    wp.media.view.MediaFrame.Select.prototype.browseRouter = function(routerView) {
        originalMediaTabs.apply(this, [routerView]);
        routerView.set({
            'new-tab': {
                text: 'New Tab',  // Tab title
                priority: 100
            }
        });
    };

    wp.media.view.MediaFrame.Select.prototype.on('router:new-tab', function() {
        this.content.set(new wp.media.view.AttachmentsBrowser({
            controller: this,
            collection: new wp.media.model.Attachments(),
            selection: this.state().get('selection'),
            model: this.state()
        }));
    });
});

PHP Code:

function my_custom_media_scripts() {
    wp_enqueue_script(
        'my-custom-media-scripts',
        plugin_dir_url(__FILE__) . 'js/admin.js', // Path to your JS file
        array('jquery', 'media-views'), // Dependencies
        null,
        true
    );
}
add_action('admin_enqueue_scripts', 'my_custom_media_scripts');

This JavaScript code adds a new tab called “New Tab” to the Media Library modal window. The PHP code enqueues the JavaScript on admin pages.

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş