-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeme.php
114 lines (91 loc) · 2.64 KB
/
theme.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* Theme functions.
*
* @package WPX
*
* @since 1.0.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'wpx_is_blog' ) ) {
/**
* Check to see if the current page is the blog page.
*
* @since 1.0.0
*
* @return bool True if the current page is the blog page, false otherwise.
*/
function wpx_is_blog() {
return ( ( ! is_front_page() && is_home() ) || is_single() );
}
} // wpx_is_blog
if ( ! function_exists( 'wpx_is_login_page' ) ) {
/**
* Check if the current page is the login page.
*
* @return bool True if current page is Login Page, false otherwise
*/
function wpx_is_login_page() {
return ( 'wp-login.php' === $_SERVER['REQUEST_URI'] );
}
} // wpx_is_login_page
if ( ! function_exists( 'wpx_javascript_detection' ) ) {
/**
* Handles JavaScript detection.
*
* Adds a `js` class to the root `<html>` element when JavaScript is detected.
*
* @since 1.0.0
*/
function wpx_javascript_detection() {
echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n";
}
} // wpx_javascript_detection
if ( ! function_exists( 'wpx_register_javascript_detection' ) ) {
/**
* Register JavaScript detection.
*
* Adds a `js` class to the root `<html>` element when JavaScript is detected.
*
* @since 1.0.0
*/
function wpx_register_javascript_detection() {
add_action( 'wp_head', 'wpx_javascript_detection', 0 );
}
} // wpx_register_javascript_detection
if ( ! function_exists( 'wpx_cdn_jquery' ) ) {
/**
* Enqueues jQuery from CDN rather than core Wordpress include.
*
* @since 1.0.0
*/
function wpx_cdn_jquery() {
// Do not change jQuery in admin section
if ( is_admin() ) {
return;
}
// Get the current page
global $pagenow;
// Do not change jQuery on login page
if( 'wp-login.php' === $pagenow ) {
return;
}
// Remove the core jQuery
wp_deregister_script( 'jquery' );
// Enqueue jQuery from cdnjs
wp_enqueue_script( 'jquery', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js', array(), '3.1.1' );
}
} // wpx_cdn_jquery
if ( ! function_exists( 'wpx_register_cdn_jquery' ) ) {
/**
* Registers jQuery from CDN.
*
* @since 1.0.0
*/
function wpx_register_cdn_jquery() {
add_action( 'init', 'wpx_cdn_jquery' );
}
} // wpx_register_cdn_jquery