PluginProbe ʕ •ᴥ•ʔ
Advanced Ads – Ad Manager & AdSense / 2.0.4
Advanced Ads – Ad Manager & AdSense v2.0.4
2.0.23 2.0.22 2.0.21 1.38.0 1.39.0 1.39.1 1.39.2 1.39.3 1.39.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.40.0 1.40.1 1.40.2 1.41.0 1.42.0 1.42.1 1.42.2 1.43.0 1.44.0 1.44.1 1.45.0 1.45.1 1.46.0 1.47.0 1.47.1 1.47.2 1.47.3 1.47.4 1.47.5 1.48.0 1.48.1 1.49.0 1.5.0 1.5.0.1 1.5.1 1.5.2 1.5.2.1 1.5.4 1.5.4.1 1.5.5 1.50.0 1.51.0 1.51.1 1.51.2 1.51.3 1.52.0 1.52.1 1.52.2 1.52.3 1.52.4 1.53.0 1.53.1 1.53.2 1.54.0 1.54.1 1.55.0 1.56.0 1.56.1 1.56.2 1.56.3 1.56.4 1.6 1.6.1 1.6.10 1.6.10.1 1.6.10.2 1.6.11 1.6.11.1 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.17.1 1.6.17.2 1.6.2 1.6.2.1 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.6 1.6.6.1 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.6.8.3 1.6.9 1.6.9.1 1.6.9.2 1.6.9.3 1.6.9.4 1.7 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.1.1 1.7.1.2 1.7.1.3 1.7.1.4 1.7.1.5 1.7.10 trunk 1.7.11 1.0.1 1.7.12 1.0.2 1.7.13 1.0.3 1.7.14 1.1.0 1.7.15 1.1.1 1.7.16 1.1.2 1.7.17 1.1.3 1.7.18 1.10 1.7.19 1.10.1 1.7.2 1.10.10 1.7.2.1 1.10.11 1.7.20 1.10.12 1.7.21 1.10.2 1.7.22 1.10.3 1.7.23 1.10.4 1.7.24 1.10.5 1.7.25 1.10.6 1.7.3 1.10.7 1.7.4 1.10.8 1.7.4.1 1.10.9 1.7.4.2 1.11 1.7.4.3 1.11.1 1.7.4.4 1.11.2 1.7.4.5 1.12 1.7.5 1.13 1.7.5.1 1.13.1 1.7.6 1.13.2 1.7.7 1.13.3 1.7.8 1.13.4 1.7.9 1.13.5 1.7.9.1 1.13.6 1.7.9.2 1.13.7 1.7.9.3 1.13.8 1.8 1.14 1.8.1 1.14.1 1.8.10 1.14.10 1.8.11 1.14.11 1.8.12 1.14.2 1.8.13 1.14.3 1.8.14 1.14.4 1.8.15 1.14.5 1.8.16 1.14.6 1.8.17 1.14.7 1.8.18 1.14.8 1.8.19 1.14.9 1.8.2 1.15 1.8.20 1.16 1.8.21 1.16.1 1.8.22 1.17 1.8.23 1.17.1 1.8.24 1.17.10 1.8.25 1.17.10-rc.1 1.8.26 1.17.11 1.8.27 1.17.12 1.8.28 1.17.12-rc.1 1.8.29 1.17.2 1.8.3 1.17.3 1.8.30 1.17.4 1.8.4 1.17.5 1.8.5 1.17.6 1.8.6 1.17.7 1.8.7 1.17.8 1.8.8 1.17.9 1.8.9 1.17.9-beta.1 1.9 1.18.0 2.0.0 1.19.0 2.0.1 1.19.1 2.0.10 1.2 2.0.11 1.2.1 2.0.12 1.2.2 2.0.13 1.2.3 2.0.14 1.2.4 2.0.15 1.2.5 2.0.16 1.2.6 2.0.17 1.2.7 2.0.18 1.20.0 2.0.19 1.20.0-rc.1 2.0.2 1.20.0-rc.2 2.0.20 1.20.1 2.0.3 1.20.2 2.0.4 1.20.3 2.0.5 1.21.0 2.0.6 1.21.1 2.0.7 1.22.0 2.0.8 1.22.1 2.0.9 1.22.2 1.23.0 1.23.1 1.23.2 1.24.0 1.24.1 1.24.2 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.29.0 1.29.1 1.3 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.30.0 1.30.1 1.30.2 1.30.2-rc.1 1.30.3 1.30.4 1.30.4-rc.1 1.30.5 1.31.0 1.31.1 1.32.0 1.32.0-rc.1 1.33.0 1.33.1 1.33.2 1.34.0 1.35.0 1.35.1 1.36.0 1.36.1 1.36.2 1.36.3 1.37.0 1.37.1 1.37.2
advanced-ads / includes / class-plugin.php
advanced-ads / includes Last commit date
abstracts 1 year ago admin 1 year ago ads 1 year ago compatibility 1 year ago crons 1 year ago frontend 1 year ago groups 1 year ago importers 1 year ago installation 1 year ago interfaces 1 year ago placements 1 year ago rest 1 year ago traits 1 year ago utilities 1 year ago array_ad_conditions.php 1 year ago cap_map.php 3 years ago class-assets-registry.php 1 year ago class-autoloader.php 1 year ago class-constants.php 1 year ago class-entities.php 1 year ago class-modal.php 1 year ago class-modules.php 1 year ago class-options.php 1 year ago class-plugin.php 1 year ago class-post-data.php 1 year ago class-shortcodes.php 1 year ago class-upgrades.php 1 year ago class-widget.php 1 year ago default-hooks.php 1 year ago functions-ad.php 1 year ago functions-conditional.php 1 year ago functions-core.php 1 year ago functions-group.php 1 year ago functions-placement.php 1 year ago functions.php 1 year ago index.php 2 years ago load_modules.php 2 years ago
class-plugin.php
359 lines
1 <?php
2 /**
3 * The plugin bootstrap.
4 *
5 * @package AdvancedAds
6 * @author Advanced Ads <info@wpadvancedads.com>
7 * @since 1.47.0
8 */
9
10 namespace AdvancedAds;
11
12 use AdvancedAds\Ads\Ads;
13 use AdvancedAds\Groups\Groups;
14 use Advanced_Ads_Admin_Licenses;
15 use AdvancedAds\Installation\Install;
16 use AdvancedAds\Placements\Placements;
17
18 defined( 'ABSPATH' ) || exit;
19
20 /**
21 * Plugin.
22 *
23 * Containers:
24 *
25 * @property Shortcodes $shortcodes Shortcodes handler.
26 * @property Assets_Registry $registry Assets registry.
27 * @property Framework\JSON $json JSON handler.
28 * @property Admin\Admin_Menu $screens Admin screens.
29 * @property Frontend\Ad_Renderer $renderer Ads renderer.
30 * @property Frontend\Manager $frontend Frontend manager.
31 * @property Importers\Manager $importers Importers manager.
32 */
33 class Plugin extends Framework\Loader {
34
35 use Traits\Extras;
36
37 /**
38 * The ads container
39 *
40 * @var Ads
41 */
42 public $ads = null;
43
44 /**
45 * The groups container
46 *
47 * @var Groups
48 */
49 public $groups = null;
50
51 /**
52 * The placements container
53 *
54 * @var Placements
55 */
56 public $placements = null;
57
58 /**
59 * Modules manager
60 *
61 * @var Modules
62 */
63 public $modules = null;
64
65 /**
66 * Main instance
67 *
68 * Ensure only one instance is loaded or can be loaded.
69 *
70 * @return Plugin
71 */
72 public static function get(): Plugin {
73 static $instance;
74
75 if ( null === $instance ) {
76 $instance = new Plugin();
77 $instance->setup();
78 }
79
80 return $instance;
81 }
82
83 /**
84 * Get plugin version
85 *
86 * @return string
87 */
88 public function get_version(): string {
89 return ADVADS_VERSION;
90 }
91
92 /**
93 * Bootstrap plugin.
94 *
95 * @return void
96 */
97 private function setup(): void {
98 $this->define_constants();
99 $this->includes_functions();
100 $this->includes();
101 $this->includes_rest();
102 $this->includes_admin();
103 $this->includes_frontend();
104 $this->includes_deprecated();
105
106 /**
107 * Old loading strategy
108 *
109 * TODO: need to remove it in future.
110 */
111 // Public-Facing and Core Functionality.
112 \Advanced_Ads::get_instance();
113 \Advanced_Ads_ModuleLoader::loadModules( ADVADS_ABSPATH . 'modules/' ); // enable modules, requires base class.
114
115 if ( is_admin() ) {
116 Advanced_Ads_Admin_Licenses::get_instance();
117 }
118
119 add_action( 'init', [ $this, 'load_textdomain' ] );
120 add_action( 'plugins_loaded', [ $this, 'on_plugins_loaded' ], -1 );
121 add_action( 'widgets_init', [ $this, 'register_widgets' ] );
122
123 // Load it all.
124 $this->ads->initialize();
125 $this->groups->initialize();
126 $this->placements->initialize();
127 $this->modules->initialize();
128 $this->load();
129 }
130
131 /**
132 * Register the Advanced Ads classic Widget
133 *
134 * @return void
135 */
136 public function register_widgets(): void {
137 register_widget( '\AdvancedAds\Widget' );
138 }
139
140 /**
141 * When WordPress has loaded all plugins, trigger the `advanced-ads-loaded` hook.
142 *
143 * @since 1.47.0
144 *
145 * @return void
146 */
147 public function on_plugins_loaded(): void {
148 /**
149 * Action trigger after loading finished.
150 *
151 * @since 1.47.0
152 */
153 do_action( 'advanced-ads-loaded' );
154 }
155
156 /**
157 * Load the plugin text domain for translation.
158 *
159 * @return void
160 */
161 public function load_textdomain(): void {
162 $locale = apply_filters( 'plugin_locale', determine_locale(), 'advanced-ads' );
163
164 unload_textdomain( 'advanced-ads' );
165 if ( false === load_textdomain( 'advanced-ads', WP_LANG_DIR . '/plugins/advanced-ads-' . $locale . '.mo' ) ) {
166 load_textdomain( 'advanced-ads', WP_LANG_DIR . '/advanced-ads/advanced-ads-' . $locale . '.mo' );
167 }
168
169 load_plugin_textdomain( 'advanced-ads', false, dirname( ADVADS_PLUGIN_BASENAME ) . '/languages' );
170 }
171
172 /**
173 * Define Advanced Ads constant
174 *
175 * @return void
176 */
177 private function define_constants(): void {
178 $this->define( 'ADVADS_ABSPATH', dirname( ADVADS_FILE ) . '/' );
179 $this->define( 'ADVADS_PLUGIN_BASENAME', plugin_basename( ADVADS_FILE ) );
180 $this->define( 'ADVADS_BASE_URL', plugin_dir_url( ADVADS_FILE ) );
181 $this->define( 'ADVADS_SLUG', 'advanced-ads' );
182 // name for group & option in settings.
183 $this->define( 'ADVADS_SETTINGS_ADBLOCKER', 'advanced-ads-adblocker' );
184
185 // Deprecated Constants.
186 /**
187 * ADVADS_BASE
188 *
189 * @deprecated 1.47.0 use ADVADS_PLUGIN_BASENAME now.
190 */
191 define( 'ADVADS_BASE', ADVADS_PLUGIN_BASENAME );
192
193 /**
194 * ADVADS_BASE_PATH
195 *
196 * @deprecated 1.47.0 use ADVADS_ABSPATH now.
197 */
198 define( 'ADVADS_BASE_PATH', ADVADS_ABSPATH );
199
200 /**
201 * ADVADS_BASE_DIR
202 *
203 * @deprecated 1.47.0 Avoid global declaration of the constant used exclusively in `load_text_domain` function; use localized declaration instead.
204 */
205 define( 'ADVADS_BASE_DIR', dirname( ADVADS_PLUGIN_BASENAME ) );
206
207 /**
208 * ADVADS_URL
209 *
210 * @deprecated 1.47.0 Deprecating the constant in favor of using the direct URL to circumvent costly `esc_url` function; please update code accordingly.
211 */
212 define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
213 }
214
215 /**
216 * Includes core files used in admin and on the frontend.
217 *
218 * @return void
219 */
220 private function includes(): void {
221 $this->ads = new Ads();
222 $this->groups = new Groups();
223 $this->placements = new Placements();
224 $this->modules = new Modules();
225
226 // Common.
227 $this->register_initializer( Install::class );
228 $this->register_integration( Entities::class );
229 $this->register_integration( Assets_Registry::class, 'registry' );
230 $this->register_integration( Framework\JSON::class, 'json', [ 'advancedAds' ] );
231 $this->register_integration( Compatibility\Compatibility::class );
232 $this->register_integration( Compatibility\AAWP::class );
233 $this->register_integration( Compatibility\Peepso::class );
234 $this->register_integration( Post_Data::class );
235 $this->register_integration( Crons\Ads::class );
236 $this->register_integration( Shortcodes::class, 'shortcodes' );
237 $this->register_integration( Frontend\Debug_Ads::class );
238 }
239
240 /**
241 * Includes files used on the frontend.
242 *
243 * @return void
244 */
245 private function includes_frontend(): void {
246 // Early bail!!
247 if ( is_admin() ) {
248 return;
249 }
250
251 $this->register_integration( Frontend\Ad_Renderer::class, 'renderer' );
252 $this->register_integration( Frontend\Manager::class, 'frontend' );
253 $this->register_integration( Frontend\Scripts::class );
254 }
255
256 /**
257 * Includes files used in admin.
258 *
259 * @return void
260 */
261 private function includes_admin(): void {
262 // Early bail!!
263 if ( ! is_admin() ) {
264 return;
265 }
266
267 $this->register_integration( Compatibility\Capability_Manager::class );
268 $this->register_initializer( Upgrades::class );
269 $this->register_integration( Admin\Action_Links::class );
270 $this->register_integration( Admin\Admin_Menu::class, 'screens' );
271 $this->register_integration( Admin\Admin_Notices::class );
272 $this->register_integration( Admin\Assets::class );
273 $this->register_integration( Admin\Header::class );
274 $this->register_integration( Admin\Marketing::class );
275 $this->register_integration( Admin\Metabox_Ad::class );
276 $this->register_integration( Admin\Metabox_Ad_Settings::class );
277 $this->register_integration( Admin\Post_Types::class );
278 $this->register_integration( Admin\Screen_Options::class );
279 $this->register_integration( Admin\Shortcode_Creator::class );
280 $this->register_integration( Admin\TinyMCE::class );
281 $this->register_integration( Admin\WordPress_Dashboard::class );
282 $this->register_integration( Admin\Quick_Bulk_Edit::class );
283 $this->register_integration( Admin\Page_Quick_Edit::class );
284 $this->register_integration( Admin\Placement_Quick_Edit::class );
285 $this->register_integration( Importers\Manager::class, 'importers' );
286 $this->register_integration( Admin\AJAX::class );
287 $this->register_integration( Admin\Version_Control::class );
288 $this->register_integration( Admin\Upgrades::class );
289 $this->register_integration( Admin\Authors::class );
290 $this->register_integration( Admin\Settings::class );
291 $this->register_integration( Admin\Misc::class );
292 $this->register_integration( Admin\Post_List::class );
293 $this->register_integration( Admin\Placement\Bulk_Edit::class );
294 $this->register_integration( Admin\Addon_Updater::class );
295
296 if ( ! wp_doing_ajax() ) {
297 $this->register_integration( Admin\List_Filters::class, 'list_filters' );
298 }
299 }
300
301 /**
302 * Includes rest api files used in admin and on the frontend.
303 *
304 * @return void
305 */
306 private function includes_rest(): void {
307 $this->register_route( Rest\Groups::class );
308 $this->register_route( Rest\Quick_Edit::class );
309 $this->register_route( Rest\Page_Quick_Edit::class );
310 $this->register_route( Rest\Placements::class );
311 $this->register_route( Rest\OnBoarding::class );
312 $this->register_route( Rest\Utilities::class );
313 }
314
315 /**
316 * Includes the necessary functions files.
317 *
318 * @return void
319 */
320 private function includes_functions(): void {
321 require_once ADVADS_ABSPATH . 'includes/functions.php';
322 require_once ADVADS_ABSPATH . 'includes/functions-core.php';
323 require_once ADVADS_ABSPATH . 'includes/functions-conditional.php';
324 require_once ADVADS_ABSPATH . 'includes/functions-ad.php';
325 require_once ADVADS_ABSPATH . 'includes/functions-group.php';
326 require_once ADVADS_ABSPATH . 'includes/functions-placement.php';
327 require_once ADVADS_ABSPATH . 'includes/cap_map.php';
328 require_once ADVADS_ABSPATH . 'includes/default-hooks.php';
329 }
330
331 /**
332 * Includes deprecated files.
333 *
334 * @return void
335 */
336 private function includes_deprecated(): void {
337 require_once ADVADS_ABSPATH . 'deprecated/ad_group.php';
338 require_once ADVADS_ABSPATH . 'deprecated/ad_placements.php';
339 require_once ADVADS_ABSPATH . 'deprecated/Ad_Repository.php';
340 require_once ADVADS_ABSPATH . 'deprecated/ad_type_abstract.php';
341 require_once ADVADS_ABSPATH . 'deprecated/ad_type_content.php';
342 require_once ADVADS_ABSPATH . 'deprecated/ad_type_dummy.php';
343 require_once ADVADS_ABSPATH . 'deprecated/ad_type_group.php';
344 require_once ADVADS_ABSPATH . 'deprecated/ad_type_image.php';
345 require_once ADVADS_ABSPATH . 'deprecated/ad_type_plain.php';
346 require_once ADVADS_ABSPATH . 'deprecated/ad-ajax.php';
347 require_once ADVADS_ABSPATH . 'deprecated/ad-debug.php';
348 require_once ADVADS_ABSPATH . 'deprecated/ad-expiration.php';
349 require_once ADVADS_ABSPATH . 'deprecated/ad-model.php';
350 require_once ADVADS_ABSPATH . 'deprecated/ad-select.php';
351 require_once ADVADS_ABSPATH . 'deprecated/ad.php';
352 require_once ADVADS_ABSPATH . 'deprecated/deprecated-functions.php';
353 require_once ADVADS_ABSPATH . 'deprecated/gadsense-dummy.php';
354 require_once ADVADS_ABSPATH . 'deprecated/Group_Repository.php';
355 require_once ADVADS_ABSPATH . 'deprecated/class-admin.php';
356 require_once ADVADS_ABSPATH . 'deprecated/class-advanced-ads-plugin.php';
357 }
358 }
359