|
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( 'ALNP_Extensions' ) ) { |
|
20
|
|
|
|
|
21
|
|
|
class ALNP_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( 'alnp_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_view |
|
71
|
|
|
* @param array $tabs |
|
72
|
|
|
*/ |
|
73
|
|
|
public function output( $current_view, $tabs ) { |
|
74
|
|
|
if ( $current_view !== 'extensions' ) { |
|
75
|
|
|
return; |
|
76
|
|
|
} |
|
77
|
|
|
?> |
|
78
|
|
|
<div class="wrap auto-load-next-post"> |
|
79
|
|
|
<?php |
|
80
|
|
|
// Include settings tabs. |
|
81
|
|
|
include_once( dirname( __FILE__ ) . '/views/html-admin-tabs.php' ); |
|
82
|
|
|
?> |
|
83
|
|
|
<h1 class="screen-reader-text"><?php echo esc_html( $this->label ); ?></h1> |
|
84
|
|
|
|
|
85
|
|
|
<?php |
|
86
|
|
|
// Load the class if it exists and Airplane Mode is disabled. |
|
87
|
|
|
if ( class_exists( 'Connekt_Plugin_Installer' ) && ! alnp_airplane_mode_enabled() ) { |
|
88
|
|
|
Connekt_Plugin_Installer::init( self::$extensions ); |
|
89
|
|
|
} |
|
90
|
|
|
?> |
|
91
|
|
|
</div> |
|
92
|
|
|
<?php |
|
93
|
|
|
} // END output() |
|
94
|
|
|
|
|
95
|
|
|
} // END class |
|
96
|
|
|
|
|
97
|
|
|
} // END if class |
|
98
|
|
|
|
|
99
|
|
|
return new ALNP_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: