Completed
Branch dev (58959f)
by
unknown
02:33
created

auto-load-next-post-conditional-functions.php ➔ supports_alnp()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
cc 3
eloc 8
c 4
b 1
f 0
nc 3
nop 0
dl 0
loc 14
rs 9.4285
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
	 * @author   Sébastien Dumont
9
	 * @category Core
10
	 * @package  Auto Load Next Post
11
	 * @license  GPL-2.0+
12
	 */
13
14
if ( ! defined('ABSPATH')) {
15
	exit;
16
}
17
// Exit if accessed directly
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
	 * @access public
42
	 * @return boolen
43
	 */
44
	function supports_alnp() {
45
		/* WordPress core themes. */
46
		$core_themes = array(
47
			'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentytwelve', 'twentyten'
48
		);
49
50
		if (in_array(get_option('template'), $core_themes)) {
51
			return true;
52
		} else if (current_theme_supports('auto-load-next-post')) {
53
			return true;
54
		}
55
56
		return false;
57
	} // END supports_alnp()
58
}
59