Completed
Pull Request — master (#133)
by Sébastien
01:53
created

ALNP_Twenty_Twelve   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 19.61 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 10
loc 51
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 10 10 1
A alnp_twentytwelve_post_navigation() 0 8 1
A add_theme_support() 0 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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() {
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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
		) );
70
	} // END add_theme_support()
71
72
} // END class
73
74
ALNP_Twenty_Twelve::init();
75