I have made some changes to functions.php, specifically i deregister some js libraries and then manually add them back to the footer using a plugin(header and footer plugin). That changes caused to my site a minor problem, some times when i try to visit wp-admin it shows me that message "The page cannot be displayed because an internal server error has occurred." with a blank page behind the message BUT the front site is okay. If i visit themes, plugins or anything else it is okay except mysite.com/wp-admin And i also mention it again, that occurs some times and then it is ok, not everytime.
1 Answer
When you enqueue new libraries to WordPress for the sake of front-end effect only, it is highly recommended to preface the function in the conditional if (!is_admin());
, thus:
/**
* Load newer jQuery min file.
*/
if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
function my_jquery_enqueue() {
wp_deregister_script('jquery');
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js", false, null, false);
wp_enqueue_script('jquery');
}
Additionally, wp_enqueue_script()
has the necessary options to specify loading in the footer, and only once other dependencies have loaded. Read more here.
is_admin
to check and perform customization only in the frontend.