1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Auto Load Next Post Theme Support: Twenty Twelve |
4
|
|
|
* |
5
|
|
|
* Applies support for WordPress Twenty Twelve Theme. |
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_Twenty_Twelve class. |
21
|
|
|
*/ |
22
|
|
|
class ALNP_Twenty_Twelve { |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Initlize Theme. |
26
|
|
|
* |
27
|
|
|
* @access public |
28
|
|
|
* @static |
29
|
|
|
*/ |
30
|
|
View Code Duplication |
public static function init() { |
|
|
|
|
31
|
|
|
// This removes the default post navigation in the repeater template. |
32
|
|
|
remove_action( 'alnp_load_after_content', 'auto_load_next_post_navigation', 1, 10 ); |
33
|
|
|
|
34
|
|
|
// Add a compaitable post navigation. |
35
|
|
|
add_action( 'alnp_load_after_content', array( __CLASS__, 'alnp_twentytwelve_post_navigation' ), 1, 10 ); |
36
|
|
|
|
37
|
|
|
// Add theme support and preset the theme selectors. |
38
|
|
|
add_action( 'after_setup_theme', array( __CLASS__, 'add_theme_support' ) ); |
39
|
|
|
} // END init() |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Adds a compaitable post navigation. |
43
|
|
|
* |
44
|
|
|
* @access public |
45
|
|
|
* @static |
46
|
|
|
*/ |
47
|
|
|
public static function alnp_twentytwelve_post_navigation() { |
48
|
|
|
?> |
49
|
|
|
<nav class="nav-single"> |
50
|
|
|
<h3 class="assistive-text"><?php _e( 'Post navigation', 'auto-load-next-post' ); ?></h3> |
51
|
|
|
<span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'auto-load-next-post' ) . '</span> %title' ); ?></span> |
52
|
|
|
</nav><!-- .nav-single --> |
53
|
|
|
<?php |
54
|
|
|
} // END alnp_twentytwelve_post_navigation() |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Add theme support by providing the theme selectors |
58
|
|
|
* to be applied once the theme is activated. |
59
|
|
|
* |
60
|
|
|
* @access public |
61
|
|
|
* @static |
62
|
|
|
*/ |
63
|
|
|
public static function add_theme_support() { |
64
|
|
|
add_theme_support( 'auto-load-next-post', array( |
65
|
|
|
'content_container' => '#content', |
66
|
|
|
'title_selector' => 'h1.entry-title', |
67
|
|
|
'navigation_container' => '.nav-single', |
68
|
|
|
'comments_container' => 'div#comments', |
69
|
|
|
) ); |
70
|
|
|
} // END add_theme_support() |
71
|
|
|
|
72
|
|
|
} // END class |
73
|
|
|
|
74
|
|
|
ALNP_Twenty_Twelve::init(); |
75
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.