alnp_twentytwelve_post_navigation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
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( '&larr;', '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
			'load_js_in_footer'    => 'no',
70
			'lock_js_in_footer'    => 'no',
71
		) );
72
	} // END add_theme_support()
73
74
} // END class
75
76
ALNP_Twenty_Twelve::init();
77