This repository has been archived by the owner on Oct 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.php
80 lines (71 loc) · 1.58 KB
/
plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* Common functions.
*/
class AJAX_Optimizer {
/**
* Single instance of the class.
*
* @var AJAX_Optimizer
*/
protected static $instance;
/**
* Plugin options.
*
* @var array (if loaded)
*/
protected $options;
/**
* Constructor.
*/
private function __construct() {
$this->load_plugin_textdomain();
}
/**
* Return instance of the class.
*
* @return Plugin_Conflicts
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null === self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Load the plugin text domain for translation.
*/
public function load_plugin_textdomain() {
load_plugin_textdomain( 'ajax-optimizer', false, AJAX_OPT_BASE_DIR . '/languages' );
}
/**
* Return plugin options.
*
* @return array $options
*/
public function options() {
if ( ! isset( $this->options ) ) {
$this->options = (array) get_option( AJAX_OPT_SLUG, array() );
}
return $this->options;
}
/**
* Update plugin options.
*
* @param array $options
*/
public function update_options( array $options ) {
$this->options = $options;
update_option( AJAX_OPT_SLUG, $options );
}
/**
* Single site or network wide activation.
*
* @param bool $network_wide Whether to enable the plugin for all sites in the network
* or just the current site. Multisite only. Default is false.
*/
public static function activation( $network_wide ) {
AJAX_Optimizer_MU_Admin::get_instance()->create_mu_plugin_on_activation();
}
}