How to load Dashboard media files via HTTPS even when Browser URL has HTTP

Question

How to load Dashboard media files via HTTPS even when Browser URL has HTTP

On all Admin Dashboard pages, I want to force loading of all CSS, JS to be via https, even when URL in browser is using http.

Can this be done?

Currently, I have tried to hardcode in wp-login.php the default list of media files. This loads the hardcoded CSS/JS files via https even when its HTTP in Browser URL.

But, I cant go further into complex structure of wp-admin/ admin-header.php

I’m now looking into trying enqueue in my theme’s function.php

/*Enqueue Admin CSS JS */
function wpdocs_selectively_enqueue_admin_script( $hook ) {
    wp_enqueue_script( 'my_custom_script', 'https://example.com/myscript.css', array(), '1.0' );
    wp_enqueue_script( 'my_custom_script', 'https://example.com/myscript1.css', array(), '1.0' );
    wp_enqueue_script( 'my_custom_script', 'https://example.com/myscript1.js', array(), '1.0' );
    wp_enqueue_script( 'my_custom_script', 'https://example.com/myscript2.js', array(), '1.0' );
}
add_action( 'admin_enqueue_scripts', 'wpdocs_selectively_enqueue_admin_script' );
0
, Shailesh 4 years 2020-06-02T01:11:05-05:00 0 Answers 86 views 0

Leave an answer

Browse
Browse