1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Auto Load Next Post Theme Support |
4
|
|
|
* |
5
|
|
|
* Configures theme support if supported. |
6
|
|
|
* |
7
|
|
|
* @since 1.5.0 |
8
|
|
|
* @author Sébastien Dumont |
9
|
|
|
* @category Theme Support |
10
|
|
|
* @package Auto Load Next Post/Theme Support |
11
|
|
|
* @license GPL-2.0+ |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
// Exit if accessed directly. |
15
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
16
|
|
|
exit; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* ALNP_Theme_Support class. |
21
|
|
|
*/ |
22
|
|
|
class ALNP_Theme_Support { |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Constructor. |
26
|
|
|
* |
27
|
|
|
* @access public |
28
|
|
|
*/ |
29
|
|
|
public function __construct() { |
30
|
|
|
// Update theme selectors if the theme was switched and it has theme support. |
31
|
|
|
add_action( 'after_switch_theme', array( $this, 'update_alnp_theme_selectors' ), 15, 2 ); |
32
|
|
|
} // END __construct() |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Updates the theme selectors if the theme had changed |
36
|
|
|
* and Auto Load Next Post is supported within that theme. |
37
|
|
|
* |
38
|
|
|
* @access public |
39
|
|
|
*/ |
40
|
|
|
public function update_alnp_theme_selectors( $stylesheet = '', $old_theme = false ) { |
|
|
|
|
41
|
|
|
// Check if Auto Load Next Post is supported before updating the theme selectors. |
42
|
|
|
if ( is_alnp_supported() ) { |
43
|
|
|
$theme_support = get_theme_support( 'auto-load-next-post' ); |
44
|
|
|
|
45
|
|
|
if ( is_array( $theme_support ) ) { |
46
|
|
|
// Preferred implementation, where theme provides an array of options |
47
|
|
|
if ( isset( $theme_support[0] ) && is_array( $theme_support[0] ) ) { |
48
|
|
|
foreach( $theme_support[0] as $key => $value ) { |
49
|
|
|
if ( ! empty( $value ) ) update_option( 'auto_load_next_post_' . $key, $value ); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
} // END update_alnp_theme_selectors() |
55
|
|
|
|
56
|
|
|
} // END class |
57
|
|
|
|
58
|
|
|
return new ALNP_Theme_Support(); |
59
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.