Completed
Branch master (136588)
by
unknown
02:26
created

ALNP_Pro_Preview   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add_pro_tabs() 0 13 1
A hash() 0 13 2
1
<?php
2
/**
3
 * Auto Load Next Post Pro Preview class
4
 *
5
 * Adds a preview of the options coming to the Pro release.
6
 *
7
 * @since    1.6.0
8
 * @author   Sébastien Dumont
9
 * @category Classes
10
 * @package  Auto Load Next Post/Classes/Pro Preview
11
 * @license  GPL-2.0+
12
 */
13
14
// Exit if accessed directly.
15
if ( ! defined( 'ABSPATH' ) ) {
16
	exit;
17
}
18
19
if ( ! class_exists( 'ALNP_Pro_Preview' ) ) {
20
21
	class ALNP_Pro_Preview {
22
23
		/**
24
		 * Initialize.
25
		 *
26
		 * @access public
27
		 */
28
		public function __construct() {
29
			add_filter( 'alnp_settings_tabs_array', array( $this, 'add_pro_tabs' ), 99 );
30
			add_filter( 'alnp_settings_tab_url', array( $this, 'hash'), 0, 2 );
31
		} // END __construct()
32
33
		/**
34
		 * Adds the settings tabs that will be available in Pro.
35
		 *
36
		 * @access public
37
		 * @param  array $pages
38
		 * @return array $pages
39
		 */
40
		public function add_pro_tabs( $pages ) {
41
			$pro_pages = array(
42
				'comments'        => __( 'Comments', 'auto-load-next-post' ),
43
				'load-and-scroll' => __( 'Load & Scroll', 'auto-load-next-post' ),
44
				'restrictions'    => __( 'Restrictions', 'auto-load-next-post' ),
45
				'query'           => __( 'Query', 'auto-load-next-post' ),
46
				'license'         => __( 'License', 'auto-load-next-post' ),
47
			);
48
49
			$pages = array_merge( $pages, $pro_pages );
50
51
			return $pages;
52
		} // END add_pro_tabs()
53
54
		/**
55
		 * Overrides the link used for the tab.
56
		 *
57
		 * @access public
58
		 * @param  string $url
59
		 * @param  string $slug
60
		 * @return string
61
		 */
62
		public function hash( $url, $slug ) {
63
			if ( ! in_array( $slug, array(
64
				'comments', 
65
				'load-and-scroll', 
66
				'restrictions', 
67
				'query', 
68
				'license'
69
			) ) ) {
70
				return $url;
71
			}
72
73
			return '#';
74
		} // END hash()
75
76
	} // END class
77
78
} // END if class
79
80
return new ALNP_Pro_Preview();