1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Auto Load Next Post Extensions class |
4
|
|
|
* |
5
|
|
|
* Displays Extensions available for Auto Load Next Post hosted via WordPress.org |
6
|
|
|
* |
7
|
|
|
* @since 1.6.0 |
8
|
|
|
* @author Sébastien Dumont |
9
|
|
|
* @category Classes |
10
|
|
|
* @package Auto Load Next Post/Classes/Extensions |
11
|
|
|
* @license GPL-2.0+ |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
// Exit if accessed directly. |
15
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
16
|
|
|
exit; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
if ( ! class_exists( 'Auto_Load_Next_Post_Extensions' ) ) { |
20
|
|
|
|
21
|
|
|
class Auto_Load_Next_Post_Extensions { |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Extensions Var |
25
|
|
|
* |
26
|
|
|
* @access public |
27
|
|
|
* @static |
28
|
|
|
*/ |
29
|
|
|
public static $extensions; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Initialize Extensions. |
33
|
|
|
* |
34
|
|
|
* @access public |
35
|
|
|
*/ |
36
|
|
|
public function __construct() { |
37
|
|
|
$this->id = 'extensions'; |
|
|
|
|
38
|
|
|
$this->label = esc_html__( 'Extensions', 'auto-load-next-post' ); |
|
|
|
|
39
|
|
|
|
40
|
|
|
// Below are extensions hosted on WordPress.org |
41
|
|
|
self::$extensions = array( |
42
|
|
|
array( |
43
|
|
|
'slug' => 'alnp-facebook-pixel-tracking', // Facebook Pixel Tracking |
44
|
|
|
), |
45
|
|
|
); |
46
|
|
|
|
47
|
|
|
include_once( AUTO_LOAD_NEXT_POST_FILE_PATH . '/vendor/connekt-plugin-installer/class-connekt-plugin-installer.php'); // Plugin Installer |
48
|
|
|
|
49
|
|
|
add_filter( 'auto_load_next_post_settings_tabs_array', array( $this, 'add_extensions_page' ), 99 ); |
50
|
|
|
add_action( 'auto_load_next_post_settings_end', array( $this, 'output' ), 10, 2 ); |
51
|
|
|
} // END __construct() |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Add the extensions page to the settings. |
55
|
|
|
* |
56
|
|
|
* @access public |
57
|
|
|
* @param array $pages |
58
|
|
|
* @return array $pages |
59
|
|
|
*/ |
60
|
|
|
public function add_extensions_page( $pages ) { |
61
|
|
|
$pages[$this->id] = $this->label; |
62
|
|
|
|
63
|
|
|
return $pages; |
64
|
|
|
} // END add_extensions_page() |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Output the extensions. |
68
|
|
|
* |
69
|
|
|
* @access public |
70
|
|
|
* @param string $current_tab |
71
|
|
|
* @param array $tabs |
72
|
|
|
*/ |
73
|
|
|
public function output( $current_tab, $tabs ) { |
74
|
|
|
if ( $current_tab !== 'extensions' ) { |
75
|
|
|
return; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
$tab_exists = isset( $tabs[ $current_tab ] ) || has_action( 'auto_load_next_post_sections_' . $current_tab ) || has_action( 'auto_load_next_post_settings_' . $current_tab ) || has_action( 'auto_load_next_post_settings_tabs_' . $current_tab ); |
|
|
|
|
79
|
|
|
$current_tab_label = isset( $tabs[ $current_tab ] ) ? $tabs[ $current_tab ] : ''; |
80
|
|
|
?> |
81
|
|
|
<div class="wrap auto-load-next-post"> |
82
|
|
|
<nav class="nav-tab-wrapper"> |
83
|
|
|
<?php |
84
|
|
View Code Duplication |
foreach ( $tabs as $slug => $label ) { |
85
|
|
|
echo '<a href="' . esc_html( admin_url( 'options-general.php?page=auto-load-next-post-settings&tab=' . esc_attr( $slug ) ) ) . '" class="nav-tab ' . ( $current_tab === $slug ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
do_action( 'auto_load_next_post_settings_tabs' ); |
89
|
|
|
?> |
90
|
|
|
</nav> |
91
|
|
|
<h1 class="screen-reader-text"><?php echo esc_html( $current_tab_label ); ?></h1> |
92
|
|
|
</div> |
93
|
|
|
|
94
|
|
|
<?php |
95
|
|
|
if ( class_exists( 'Connekt_Plugin_Installer' ) ) { |
96
|
|
|
Connekt_Plugin_Installer::init( self::$extensions ); |
97
|
|
|
} |
98
|
|
|
} // END output() |
99
|
|
|
|
100
|
|
|
} // END class |
101
|
|
|
|
102
|
|
|
} // END if class |
103
|
|
|
|
104
|
|
|
return new Auto_Load_Next_Post_Extensions(); |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: