|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Auto Load Next Post Conditional Functions |
|
4
|
|
|
* |
|
5
|
|
|
* Functions for determining the current query/page. |
|
6
|
|
|
* |
|
7
|
|
|
* @since 1.0.0 |
|
8
|
|
|
* @version 1.4.10 |
|
9
|
|
|
* @author Sébastien Dumont |
|
10
|
|
|
* @category Core |
|
11
|
|
|
* @package Auto Load Next Post |
|
12
|
|
|
* @license GPL-2.0+ |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
// Exit if accessed directly. |
|
16
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
17
|
|
|
exit; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
if ( ! function_exists( 'auto_load_next_post_is_ajax' ) ) { |
|
21
|
|
|
/** |
|
22
|
|
|
* Returns true when the page is loaded via ajax. |
|
23
|
|
|
* |
|
24
|
|
|
* @access public |
|
25
|
|
|
* @since 1.0.0 |
|
26
|
|
|
* @return bool |
|
27
|
|
|
*/ |
|
28
|
|
|
function auto_load_next_post_is_ajax() { |
|
29
|
|
|
if ( defined( 'DOING_AJAX' ) ) { |
|
30
|
|
|
return true; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
return( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) ? true : false; |
|
34
|
|
|
} // END auto_load_next_post_is_ajax |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
if ( ! function_exists( 'supports_alnp' ) ) { |
|
38
|
|
|
/** |
|
39
|
|
|
* Returns true or false if Auto Load Next Post supports the theme. |
|
40
|
|
|
* |
|
41
|
|
|
* @access public |
|
42
|
|
|
* @since 1.4.3 |
|
43
|
|
|
* @version 1.4.10 |
|
44
|
|
|
* @return boolen |
|
45
|
|
|
*/ |
|
46
|
|
|
function supports_alnp() { |
|
47
|
|
|
/* WordPress core themes. */ |
|
48
|
|
|
$core_themes = array( |
|
49
|
|
|
'twentyseventeen', 'twentysixteen', 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentytwelve', 'twentyten' |
|
50
|
|
|
); |
|
51
|
|
|
|
|
52
|
|
|
$other_themes = array( |
|
53
|
|
|
'storefront' |
|
54
|
|
|
); |
|
55
|
|
|
|
|
56
|
|
|
$supported_themes = array_merge( $core_themes, $other_themes ); |
|
57
|
|
|
|
|
58
|
|
|
if ( in_array( get_option('template'), $supported_themes ) ) { |
|
59
|
|
|
return true; |
|
60
|
|
|
} else if ( current_theme_supports( 'auto-load-next-post' ) ) { |
|
61
|
|
|
return true; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
return false; |
|
65
|
|
|
} // END supports_alnp() |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
if ( ! function_exists( 'alnp_template_location' ) ) { |
|
69
|
|
|
/** |
|
70
|
|
|
* Filters the template location for get_template_part(). |
|
71
|
|
|
* |
|
72
|
|
|
* @access public |
|
73
|
|
|
* @since 1.4.8 |
|
74
|
|
|
* @version 1.4.9 |
|
75
|
|
|
* @return boolen |
|
76
|
|
|
*/ |
|
77
|
|
|
function alnp_template_location() { |
|
78
|
|
|
$current_theme = get_option('template'); |
|
79
|
|
|
|
|
80
|
|
|
switch( $current_theme ) { |
|
81
|
|
|
case 'twentyseventeen': |
|
82
|
|
|
$path = 'template-parts/post/'; |
|
83
|
|
|
break; |
|
84
|
|
|
|
|
85
|
|
|
case 'twentysixteen': |
|
86
|
|
|
$path = 'template-parts/'; |
|
87
|
|
|
break; |
|
88
|
|
|
|
|
89
|
|
|
default: |
|
90
|
|
|
$path = ''; |
|
91
|
|
|
break; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
return $path; |
|
95
|
|
|
} // END alnp_template_location() |
|
96
|
|
|
|
|
97
|
|
|
add_filter('alnp_template_location', 'alnp_template_location'); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
if ( ! function_exists( 'is_alnp_pro_version_installed' ) ) { |
|
101
|
|
|
/** |
|
102
|
|
|
* Detects if Auto Load Next Post Pro is installed. |
|
103
|
|
|
* |
|
104
|
|
|
* @access public |
|
105
|
|
|
* @since 1.4.10 |
|
106
|
|
|
* @return boolen |
|
107
|
|
|
*/ |
|
108
|
|
|
function is_alnp_pro_version_installed() { |
|
109
|
|
|
$active_plugins = (array) get_option( 'active_plugins', array() ); |
|
110
|
|
|
|
|
111
|
|
|
if ( is_multisite() ) { |
|
112
|
|
|
$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) ); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
return in_array( 'auto-load-next-post-pro/auto-load-next-post-pro.php', $active_plugins ) || array_key_exists( 'auto-load-next-post-pro/auto-load-next-post-pro.php', $active_plugins ); |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|