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

Question

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

On all Admin Dashboard pages, I want to force the loading of all CSS, JS via https, even when URL in browser addressbar 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( 'default1', 'https://example.com/wp-admin/load-styles.php?c=0&dir=ltr&load%5B%5D=dashicons,admin-bar,wp-pointer,common,forms,admin-menu,dashboard,list-tables,edit,revisions,media,themes,about,nav-menus,widgets&load%5B%5D=,site-icon,l10n,buttons,wp-auth-check&ver=5.2.6', array(), '1.0' );
    wp_enqueue_script( 'default2', 'https://example.com/wp-content/plugins/wp-fastest-cache/css/style.css?ver=1591072501', array(), '1.0' );
    wp_enqueue_script( 'my_custom_script', 'https://example.com/wp-content/plugins/wordfence/css/wf-font-awesome.1587658822.css?ver=7.4.7', array(), '1.0' );
    wp_enqueue_script( 'my_custom_script', 'https://example.com/plugins/wordfence/css/wf-global.1587658822.css?ver=7.4.7', array(), '1.0' );
}
add_action( 'admin_enqueue_scripts', 'wpdocs_selectively_enqueue_admin_script' );

PS: Media files discussed above are default System+Plugin CSS/JS files (and not custom css/js file)

PS: I dont want to force HTTPS in Browser AddressBar, only force the included media files.

0
, Shailesh 3 years 2020-06-02T02:10:52-05:00 0 Answers 92 views 0

Leave an answer

Browse
Browse