ALNP_OceanWP   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 20.97 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 13
loc 62
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 13 13 1
A template_redirect() 0 3 1
A alnp_oceanwp_template_location() 0 3 1
A add_theme_support() 0 11 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: OceanWP
4
 *
5
 * Applies support for OceanWP Theme.
6
 *
7
 * @since    1.5.8
8
 * @version  1.6.0
9
 * @author   Sébastien Dumont
10
 * @category Theme Support
11
 * @package  Auto Load Next Post/Theme Support
12
 * @license  GPL-2.0+
13
 */
14
15
// Exit if accessed directly.
16
if ( ! defined( 'ABSPATH' ) ) {
17
	exit;
18
}
19
20
/**
21
 * ALNP_OceanWP class.
22
 */
23
class ALNP_OceanWP {
24
25
	/**
26
	 * Initlize Theme.
27
	 *
28
	 * @access public
29
	 * @static
30
	 */
31 View Code Duplication
	public static function init() {
32
		// Add theme support and preset the theme selectors.
33
		add_action( 'after_setup_theme', array( __CLASS__, 'add_theme_support' ) );
34
35
		// Filters the location of the repeater template.
36
		add_filter( 'alnp_template_redirect', array( __CLASS__, 'template_redirect' ) );
37
38
		// Filters the repeater template location.
39
		//add_filter( 'alnp_template_location', array( __CLASS__, 'alnp_oceanwp_template_location' ) );
40
41
		// Remove Auto Load Next Post compatible post navigation.
42
		remove_action( 'alnp_load_after_content', 'auto_load_next_post_navigation', 1, 10 );
43
	} // END init()
44
45
	/**
46
	 * Filters the location of the repeater template to override the default repeater template.
47
	 *
48
	 * @access public
49
	 * @return string
50
	 */
51
	public static function template_redirect() {
52
		return AUTO_LOAD_NEXT_POST_FILE_PATH . '/template/theme-support/oceanwp/content-alnp.php';
53
	} // END template_redirect()
54
55
	/**
56
	 * Filters the template location for get_template_part().
57
	 *
58
	 * @access public
59
	 * @static
60
	 */
61
	public static function alnp_oceanwp_template_location() {
62
		return 'partials/single/';
63
	} // END alnp_oceanwp_template_location()
64
65
	/**
66
	 * Add theme support by providing the theme selectors
67
	 * to be applied once the theme is activated.
68
	 *
69
	 * @access public
70
	 * @static
71
	 */
72
	public static function add_theme_support() {
73
		add_theme_support( 'auto-load-next-post', array(
74
			'content_container'    => 'div.site-content',
75
			'title_selector'       => '.entry-title',
76
			'navigation_container' => 'nav.post-navigation',
77
			'comments_container'   => 'section#comments',
78
			'load_js_in_footer'    => 'no',
79
			'lock_js_in_footer'    => 'no',
80
			'directory_post'       => 'partials/single/'
81
		) );
82
	} // END add_theme_support()
83
84
} // END class
85
86
ALNP_OceanWP::init();
87