-
Notifications
You must be signed in to change notification settings - Fork 1
/
adzonia.php
232 lines (193 loc) · 5.81 KB
/
adzonia.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?php
/**
* @package AdZonia
* @author nanodesigns <[email protected]>
* @license GPL-2.0+
* @link http://nanodesignsbd.com/
*
* @wordpress-plugin
* Plugin Name: AdZonia
* Plugin URI: http://nanodesignsbd.com/freeproducts/adzonia/
* Description: A simpler and easier advertisement manager plugin for WordPress sites, and most astonishingly - it's in WordPress way.
* Version: 2.0.1
* Author: nanodesigns
* Author URI: http://nanodesignsbd.com/
* Requires at least: 3.5.0
* Tested up to: 4.8.1
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: adzonia
* Domain Path: /i18n/languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
/**
* Translation-ready
* Make the plugin translation-ready.
*
* Note:
* the first-loaded translation file overrides any
* following ones if the same translation is present.
*
* Locales found in:
* - WP_LANG_DIR/adzonia/adzonia-LOCALE.mo
* - WP_LANG_DIR/plugins/adzonia-LOCALE.mo
*
* @since 1.0.0 Initiated.
* @since 2.0.0 Modified for more flexibility.
*/
function adzonia_load_textdomain() {
/**
* -----------------------------------------------------------------------
* WP FILTER HOOK
* plugin_locale
*
* WordPress' core filter hook to filter a plugin's locale.
*
* @link https://developer.wordpress.org/reference/hooks/plugin_locale/
*
* @param string $locale The plugin's current locale.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* -----------------------------------------------------------------------
*/
$locale = apply_filters( 'plugin_locale', get_locale(), 'adzonia' );
load_textdomain(
'adzonia',
WP_LANG_DIR .'/adzonia/adzonia-'. $locale .'.mo'
);
load_plugin_textdomain(
'adzonia',
false,
dirname( plugin_basename( __FILE__ ) ) .'/i18n/languages'
);
}
add_action( 'init', 'adzonia_load_textdomain', 1 );
if ( ! class_exists( 'AdZonia' ) ) :
/**
* Main AdZonia Class
*
* @class AdZonia
* -----------------------------------------------------------------------
*/
final class AdZonia {
/**
* @var string
*/
public $plugin = 'AdZonia';
/**
* @var string
*/
public $version = '2.0.1';
/**
* Minimum WordPress version.
* @var string
*/
public $wp_version = '3.5.0';
/**
* Minimum PHP version.
* @var string
*/
public $php_version = '5.2.1';
/**
* @var ADZ The single instance of the class
*/
protected static $_instance = null;
/**
* Main AdZonia Instance.
*
* Ensures only one instance of AdZonia Ticket is loaded or can be loaded.
*
* @static
* @see ADZ()
* @return AdZonia - Main instance
* ...
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Get the plugin url.
* @return string
* ...
*/
public function plugin_url() {
return untrailingslashit( plugins_url( '/', __FILE__ ) );
}
/**
* Get the plugin path.
* @return string
* ...
*/
public function plugin_path() {
return untrailingslashit( plugin_dir_path( __FILE__ ) );
}
/**
* Get the plugin base location.
* @return string
* ...
*/
public function plugin_basename() {
return plugin_basename( __FILE__ );
}
}
endif;
/**
* Returns the main instance of AdZonia.
* @return ADZ
* -----------------------------------------------------------------------
*/
function ADZ() {
return AdZonia::instance();
}
/**
* Cross Check Requirements when active.
*
* Cross check for Current WordPress version is
* greater than required. Cross check whether the user
* has privilege to `activate_plugins`, so that notice
* cannot be visible to any non-admin user.
*
* @link http://10up.com/blog/2012/wordpress-plug-in-self-deactivation/
*
* @since 2.0.0
* -----------------------------------------------------------------------
*/
function adzonia_cross_check_on_activation() {
$unmet = false;
$install = new ADZ_Install;
if ( current_user_can( 'activate_plugins' ) ) :
if ( ! $install->adzonia_is_version_supported() ) {
$unmet = true;
add_action( 'admin_notices', array( 'ADZ_Install', 'adzonia_fail_version_admin_notice' ) );
}
if ( ! $install->adzonia_is_dependency_loaded() ) {
$unmet = true;
add_action( 'admin_notices', array( 'ADZ_Install', 'adzonia_fail_dependency_admin_notice' ) );
}
if( $unmet ) {
add_action( 'admin_init', array( 'ADZ_Install', 'adzonia_force_deactivate' ) );
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
}
endif;
}
add_action( 'plugins_loaded', 'adzonia_cross_check_on_activation' );
/* REQUIRE ALL THE NECESSARY FILES */
require_once( 'includes/class-adzonia-install.php' );
require_once( 'includes/adzonia-cpt-adzonia.php' );
require_once( 'includes/adzonia-functions.php' );
require_once( 'includes/shortcodes/adzonia-shortcode.php' );
require_once( 'includes/widgets/adzonia-widget.php' );
if( is_admin() ) :
require_once( 'includes/adzonia-metaboxes.php' );
require_once( 'includes/admin/adzonia-admin-functions.php' );
require_once( 'includes/admin/adzonia-help.php' );
endif;
/* SET UP THE PLUGIN ON ACTIVATION */
register_activation_hook( __FILE__, array( 'ADZ_Install', 'adzonia_install' ) );