-
Notifications
You must be signed in to change notification settings - Fork 0
/
user-avatars.php
159 lines (138 loc) · 3.6 KB
/
user-avatars.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/**
* User Avatars
*
* Local user avatars for ClassicPress & WordPress.
*
* @package User_Avatars
* @version 1.0.0
* @link https://github.com/ControlledChaos/user-avatars
*
* Plugin Name: User Avatars
* Plugin URI: https://github.com/ControlledChaos/user-avatars
* Description: Local user avatars for ClassicPress & WordPress.
* Version: 1.0.0
* Author: Controlled Chaos Design
* Author URI: http://ccdzine.com/
* Text Domain: user-avatars
* Domain Path: /languages
* Requires PHP: 5.4
* Requires at least: 3.8
* Tested up to: 5.7.1
*/
namespace User_Avatars;
// Alias namespaces.
use User_Avatars\Classes\Activate as Activate;
// Restrict direct access.
if ( ! defined( 'ABSPATH' ) ) {
die;
}
/**
* License & Warranty
*
* User Avatars is free software.
* It can be redistributed and/or modified ad libidum.
*
* User Avatars is distributed WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* Constant: Plugin basename
*
* @since 1.0.0
* @var string The basename of this plugin file.
*/
define( 'UAP_BASENAME', plugin_basename( __FILE__ ) );
// Get the PHP version class.
require_once plugin_dir_path( __FILE__ ) . 'includes/classes/class-php-version.php';
// Get plugin configuration file.
require plugin_dir_path( __FILE__ ) . 'config.php';
/**
* Activation & deactivation
*
* The activation & deactivation methods run here before the check
* for PHP version which otherwise disables the functionality of
* the plugin.
*/
// Get the plugin activation class.
include_once UAP_PATH . 'activate/classes/class-activate.php';
// Get the plugin deactivation class.
include_once UAP_PATH . 'activate/classes/class-deactivate.php';
/**
* Register the activation & deactivation hooks
*
* The namspace of this file must remain escaped by use of the
* backslash (`\`) prepending the activation hooks and corresponding
* functions.
*
* @since 1.0.0
* @access public
* @return void
*/
\register_activation_hook( __FILE__, __NAMESPACE__ . '\activate_plugin' );
\register_deactivation_hook( __FILE__, __NAMESPACE__ . '\deactivate_plugin' );
/**
* Activation callback
*
* The function that runs during plugin activation.
*
* @since 1.0.0
* @access public
* @return void
*/
function activate_plugin() {
// Instantiate the Activate class.
$activate = new Activate\Activate;
// Update options.
$activate->options();
}
/**
* Deactivation callback
*
* The function that runs during plugin deactivation.
*
* @since 1.0.0
* @access public
* @return void
*/
function deactivate_plugin() {
// Instantiate the Deactivate class.
$deactivate = new Activate\Deactivate;
// Update options.
$deactivate->options();
}
/**
* Disable plugin for PHP version
*
* Stop here if the minimum PHP version in the config
* file is not met. Prevents breaking sites running
* older PHP versions.
*
* A notice is added to the plugin row on the Plugins
* screen as a more elegant and more informative way
* of disabling the plugin than putting the PHP minimum
* in the plugin header, which activates a die() message.
* However, the Requires PHP tag is included in the
* plugin header with a minimum of version 5.4
* because of the namespaces.
*
* @since 1.0.0
* @return void
*/
if ( ! Classes\php()->version() ) {
// First add a notice to the plugin row.
$activate = new Activate\Activate;
$activate->get_row_notice();
// Stop here.
return;
}
/**
* Plugin initialization
*
* Get the plugin initialization file if
* the PHP minimum is met.
*
* @since 1.0.0
*/
require_once UAP_PATH . 'init.php';