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.8 |
9
|
|
|
* @author Sébastien Dumont |
10
|
|
|
* @category Core |
11
|
|
|
* @package Auto Load Next Post |
12
|
|
|
* @license GPL-2.0+ |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
if ( ! defined('ABSPATH')) { |
16
|
|
|
exit; // Exit if accessed directly. |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
if ( ! function_exists('auto_load_next_post_is_ajax')) { |
20
|
|
|
/** |
21
|
|
|
* Returns true when the page is loaded via ajax. |
22
|
|
|
* |
23
|
|
|
* @since 1.0.0 |
24
|
|
|
* @access public |
25
|
|
|
* @return bool |
26
|
|
|
*/ |
27
|
|
|
function auto_load_next_post_is_ajax() { |
28
|
|
|
if (defined('DOING_AJAX')) { |
29
|
|
|
return true; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
return(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') ? true : false; |
33
|
|
|
} // END auto_load_next_post_is_ajax |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
if ( ! function_exists('supports_alnp')) { |
37
|
|
|
/** |
38
|
|
|
* Returns true or false if the plugin is supported by the theme. |
39
|
|
|
* |
40
|
|
|
* @since 1.4.3 |
41
|
|
|
* @version 1.4.8 |
42
|
|
|
* @access public |
43
|
|
|
* @return boolen |
44
|
|
|
*/ |
45
|
|
|
function supports_alnp() { |
46
|
|
|
/* WordPress core themes. */ |
47
|
|
|
$core_themes = array( |
48
|
|
|
'twentyseventeen', 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentytwelve', 'twentyten' |
49
|
|
|
); |
50
|
|
|
|
51
|
|
|
if (in_array(get_option('template'), $core_themes)) { |
52
|
|
|
return true; |
53
|
|
|
} else if (current_theme_supports('auto-load-next-post')) { |
54
|
|
|
return true; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return false; |
58
|
|
|
} // END supports_alnp() |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
if ( ! function_exists('alnp_template_location')) { |
62
|
|
|
/** |
63
|
|
|
* Filters the template location for get_template_part(). |
64
|
|
|
* |
65
|
|
|
* @since 1.4.8 |
66
|
|
|
* @access public |
67
|
|
|
* @return boolen |
68
|
|
|
*/ |
69
|
|
|
function alnp_template_location() { |
70
|
|
|
$current_theme = get_option('template'); |
71
|
|
|
|
72
|
|
|
switch( $current_theme ) { |
73
|
|
|
case 'twentyseventeen': |
74
|
|
|
$path = 'template-parts/post/'; |
75
|
|
|
break; |
76
|
|
|
|
77
|
|
|
default: |
78
|
|
|
$path = ''; |
79
|
|
|
break; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return $path; |
83
|
|
|
} // END alnp_template_location() |
84
|
|
|
|
85
|
|
|
add_filter('alnp_template_location', 'alnp_template_location'); |
86
|
|
|
} |
87
|
|
|
|