-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-total-branding.php
179 lines (134 loc) · 3.73 KB
/
wp-total-branding.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
/**
* Plugin Name: WP Total Branding
* Plugin URI: https://handyplugins.co/wp-total-branding/
* Description: Simple and powerful branding solution for WordPress.
* Author: HandyPlugins
* Author URI: https://handyplugins.co
* Text Domain: wp-total-branding
* Domain Path: /languages
* Version: 1.0.4
*
* @package WP_Total_Branding
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
define( 'WPTB_REQUIRED_WP_VERSION', '4.0' );
if ( ! class_exists( 'WP_Total_Branding' ) ) :
class WP_Total_Branding {
/**
* Stores the single instance of this plugin.
* @since 1.0
*/
private static $instance;
/**
* A dummy constructor
*
* @since 1.0
*/
protected function __construct() { }
/**
* Singleton instance of the current class
*
* @since 1.0
* @return WP_Total_Branding
*/
public static function instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new WP_Total_Branding();
self::$instance->setup_constants();
self::$instance->includes();
self::$instance->setup();
}
return self::$instance;
}
/**
* Setup plugin constants.
*
* @since 1.0
* @return void
*/
private function setup_constants() {
if ( ! defined( 'WPTB_PLUGIN_FILE' ) ) {
define( 'WPTB_PLUGIN_FILE', __FILE__ );
}
if ( ! defined( 'WPTB_OPTION' ) ) {
define( 'WPTB_OPTION', 'wptb_options' );
}
if ( ! defined( 'WPTB_PLUGIN_VERSION' ) ) {
define( 'WPTB_PLUGIN_VERSION', '1.0.4' );
}
if ( ! defined( 'WPTB_PLUGIN_DIR' ) ) {
define( 'WPTB_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'WPTB_INC_DIR' ) ) {
define( 'WPTB_INC_DIR', WPTB_PLUGIN_DIR . 'includes/' );
}
if ( ! defined( 'WPTB_PLUGIN_URL' ) ) {
define( 'WPTB_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
}
/**
* Include required files
*
* @since 1.0
*/
private function includes() {
require_once WPTB_INC_DIR . 'functions.php';
require_once WPTB_INC_DIR . 'module-loader.php';
require_once WPTB_INC_DIR . 'class-wptb-admin.php';
}
/**
* Setup plugin functionality
* @since 1.0
*/
private function setup() {
add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) );
if ( is_admin() || is_network_admin() ) {
WPTB_Admin::factory();
}
}
/**
* Loads the language packs
*
* @access public
* @since 1.0
* @return bool
*/
public function load_textdomain() {
return load_plugin_textdomain( 'wp-total-branding', false, basename( WPTB_PLUGIN_DIR ) . '/languages/' );
}
}
endif;
/**
* The main function for that returns WP_Total_Branding
*
* @since 1.0
* @return WP_Total_Branding
*/
function wp_total_branding() {
return WP_Total_Branding::instance();
}
/**
* Check requirement
*/
function wptb_requirements_notice() {
if ( ! current_user_can( 'update_core' ) ) {
return;
}
?>
<div id="message" class="error notice">
<p><strong><?php esc_html_e( 'Your site does not support WP Total Branding.', 'wp-total-branding' ); ?></strong></p>
<p><?php printf( esc_html__( 'Your site is currently running WordPress version %1$s, while WP Total Branding requires version %2$s or greater.', 'wp-total-branding' ), esc_html( get_bloginfo( 'version' ) ), WPTB_REQUIRED_WP_VERSION ); ?></p>
<p><?php esc_html_e( 'Please update your WordPress or deactivate WP Total Branding.', 'wp-total-branding' ); ?></p>
</div>
<?php
}
if ( version_compare( get_bloginfo( 'version' ), WPTB_REQUIRED_WP_VERSION, '<' ) ) {
add_action( 'admin_notices', 'wptb_requirements_notice' );
add_action( 'network_admin_notices', 'wptb_requirements_notice' );
return;
}
// run
wp_total_branding();