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

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/how-to-load-dashboard-media-files-via-https-even-when-browser-url-has-http/">

How to load Dashboard media files via HTTPS even when Browser URL has HTTP</a>
0
, Shailesh 1 month 0 Answers 48 views 0

Leave an answer