admin管理员组

文章数量:1122832

I am currently developing a plugin and I need to get the handlers of various enqueued files in the theme. I have tried working with global $wp_scripts and global $wp_styles, but I only get the scripts and styles that are loaded for the backend (which is expected).

However, it is crucial for me to know the handlers in the backend so that I can dequeue them from there.

Can anyone help?

Best regards

Edit:

Here is an example of what I am trying to implement:

it should not only work with static paths but with different file types and files.

function json_file_handler() {

    if (is_user_logged_in()) {
        // Path to the staging JS file in the theme directory

        $json_file_path = get_template_directory() . '/assets/js/staging_core.js';

        // Check if the file exists
        if (file_exists($json_file_path)) {
            // If the file exists, dequeue the default script and enqueue the staging script
            wp_dequeue_script('core');
            wp_deregister_script('core');
            wp_enqueue_script('staging-script', get_template_directory_uri() . '/assets/js/staging_core.js', array('jquery'), _S_VERSION, true);
        }
    }
}

sorry I don't know why it only shows one part as code

本文标签: pluginsFrontend Enqueued Files in the Backend