PluginProbe ʕ •ᴥ•ʔ
Advanced Ads – Ad Manager & AdSense / trunk
Advanced Ads – Ad Manager & AdSense vtrunk
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 day ago admin 1 day ago ads 1 day ago compatibility 1 day ago crons 1 day ago frontend 1 day ago groups 1 day ago importers 1 day ago installation 1 year ago interfaces 4 months ago license 3 months ago placements 1 day ago rest 1 year ago traits 1 day ago utilities 1 day ago cap_map.php 3 years ago class-assets-registry.php 3 weeks ago class-autoloader.php 1 day ago class-cache-invalidator.php 1 day ago class-constants.php 1 year ago class-content-injector.php 3 weeks ago class-entities.php 3 months ago class-modal.php 1 year ago class-modules.php 1 year ago class-options.php 1 year ago class-plugin.php 1 day ago class-post-data.php 10 months ago class-shortcodes.php 1 day ago class-upgrades.php 1 year ago class-widget.php 11 months ago default-hooks.php 4 months ago functions-ad.php 1 day ago functions-components.php 3 months ago functions-conditional.php 1 year ago functions-core.php 1 year ago functions-group.php 1 day ago functions-placement.php 1 day ago functions.php 1 day ago index.php 2 years ago load_modules.php 2 years ago
class-plugin.php
354 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 Advanced_Ads_Admin_Licenses;
13 use AdvancedAds\Ads\Ads;
14 use AdvancedAds\Groups\Groups;
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/', [ 'disabled' => [ 'pef' => true ] ] ); // enable modules, requires base class.
114
115 if ( is_admin() ) {
116 Advanced_Ads_Admin_Licenses::get_instance();
117 }
118
119 add_action( 'plugins_loaded', [ $this, 'on_plugins_loaded' ], -1 );
120 add_action( 'widgets_init', [ $this, 'register_widgets' ] );
121
122 // Load it all.
123 $this->ads->initialize();
124 $this->groups->initialize();
125 $this->placements->initialize();
126 $this->modules->initialize();
127 $this->load();
128 }
129
130 /**
131 * Register the Advanced Ads classic Widget
132 *
133 * @return void
134 */
135 public function register_widgets(): void {
136 register_widget( '\AdvancedAds\Widget' );
137 }
138
139 /**
140 * When WordPress has loaded all plugins, trigger the `advanced-ads-loaded` hook.
141 *
142 * @since 1.47.0
143 *
144 * @return void
145 */
146 public function on_plugins_loaded(): void {
147 /**
148 * Action trigger after loading finished.
149 *
150 * @since 1.47.0
151 */
152 do_action( 'advanced-ads-loaded' );
153 }
154
155 /**
156 * Define Advanced Ads constant
157 *
158 * @return void
159 */
160 private function define_constants(): void {
161 $this->define( 'ADVADS_ABSPATH', dirname( ADVADS_FILE ) . '/' );
162 $this->define( 'ADVADS_PLUGIN_BASENAME', plugin_basename( ADVADS_FILE ) );
163 $this->define( 'ADVADS_BASE_URL', plugin_dir_url( ADVADS_FILE ) );
164 $this->define( 'ADVADS_SLUG', 'advanced-ads' );
165 // name for group & option in settings.
166 $this->define( 'ADVADS_SETTINGS_ADBLOCKER', 'advanced-ads-adblocker' );
167
168 // Deprecated Constants.
169 /**
170 * ADVADS_BASE
171 *
172 * @deprecated 1.47.0 use ADVADS_PLUGIN_BASENAME now.
173 */
174 define( 'ADVADS_BASE', ADVADS_PLUGIN_BASENAME );
175
176 /**
177 * ADVADS_BASE_PATH
178 *
179 * @deprecated 1.47.0 use ADVADS_ABSPATH now.
180 */
181 define( 'ADVADS_BASE_PATH', ADVADS_ABSPATH );
182
183 /**
184 * ADVADS_BASE_DIR
185 *
186 * @deprecated 1.47.0 Avoid global declaration of the constant used exclusively in `load_text_domain` function; use localized declaration instead.
187 */
188 define( 'ADVADS_BASE_DIR', dirname( ADVADS_PLUGIN_BASENAME ) );
189
190 /**
191 * ADVADS_URL
192 *
193 * @deprecated 1.47.0 Deprecating the constant in favor of using the direct URL to circumvent costly `esc_url` function; please update code accordingly.
194 */
195 define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
196 }
197
198 /**
199 * Includes core files used in admin and on the frontend.
200 *
201 * @return void
202 */
203 private function includes(): void {
204 $this->ads = new Ads();
205 $this->groups = new Groups();
206 $this->placements = new Placements();
207 $this->modules = new Modules();
208
209 // Common.
210 $this->register_initializer( Install::class );
211 $this->register_integration( Entities::class );
212 $this->register_integration( Assets_Registry::class, 'registry' );
213 $this->register_integration( Framework\JSON::class, 'json', [ 'advancedAds' ] );
214 $this->register_integration( Compatibility\Compatibility::class );
215 $this->register_integration( Compatibility\Inline_JS::class );
216 $this->register_integration( Compatibility\AAWP::class );
217 $this->register_integration( Compatibility\Peepso::class );
218 $this->register_integration( Post_Data::class );
219 $this->register_integration( Cache_Invalidator::class );
220 $this->register_integration( Crons\Ads::class );
221 $this->register_integration( Shortcodes::class, 'shortcodes' );
222 $this->register_integration( Frontend\Debug_Ads::class );
223 }
224
225 /**
226 * Includes files used on the frontend.
227 *
228 * @return void
229 */
230 private function includes_frontend(): void {
231 // Early bail!!
232 if ( is_admin() ) {
233 return;
234 }
235
236 $this->register_integration( Frontend\Ad_Renderer::class, 'renderer' );
237 $this->register_integration( Frontend\Manager::class, 'frontend' );
238 $this->register_integration( Frontend\Scripts::class );
239 }
240
241 /**
242 * Includes files used in admin.
243 *
244 * @return void
245 */
246 private function includes_admin(): void {
247 // Early bail!!
248 if ( ! is_admin() ) {
249 return;
250 }
251
252 // Ads.
253 $this->register_integration( Admin\Ads\Ajax::class );
254 $this->register_integration( Admin\Metabox_Ad::class );
255 $this->register_integration( Admin\Metabox_Ad_Settings::class );
256 $this->register_integration( Admin\Ads\Quick_Bulk_Edit::class );
257
258 // Groups.
259 $this->register_integration( Admin\Groups\Ajax::class );
260
261 // Placements.
262 $this->register_integration( Admin\Placements\Ajax::class );
263 $this->register_integration( Admin\Placements\Bulk_Edit::class );
264 $this->register_integration( Admin\Placements\Quick_Edit::class );
265
266 // Entities.
267 $this->register_integration( Admin\Page_Quick_Edit::class );
268
269 $this->register_integration( Compatibility\Capability_Manager::class );
270 $this->register_initializer( Upgrades::class );
271 $this->register_integration( Admin\Action_Links::class );
272 $this->register_integration( Admin\Admin_Menu::class, 'screens' );
273 $this->register_integration( Admin\Admin_Notices::class );
274 $this->register_integration( Admin\Assets::class );
275 $this->register_integration( Admin\Marketing::class );
276 $this->register_integration( Admin\Post_Types::class );
277 $this->register_integration( Admin\Screen_Options::class );
278 $this->register_integration( Admin\Shortcode_Creator::class );
279 $this->register_integration( Admin\TinyMCE::class );
280 $this->register_integration( Admin\WordPress_Dashboard::class );
281 $this->register_integration( Importers\Manager::class, 'importers' );
282 $this->register_integration( Admin\AJAX::class );
283 $this->register_integration( Admin\Version_Control::class );
284 $this->register_integration( Admin\Upgrades::class );
285 $this->register_integration( Admin\Authors::class );
286 $this->register_integration( Admin\Settings::class );
287 $this->register_integration( Admin\Misc::class );
288 $this->register_integration( Admin\Post_List::class );
289 $this->register_integration( Admin\Addon_Updater::class );
290
291 if ( ! wp_doing_ajax() ) {
292 $this->register_integration( Admin\List_Filters::class, 'list_filters' );
293 }
294 }
295
296 /**
297 * Includes rest api files used in admin and on the frontend.
298 *
299 * @return void
300 */
301 private function includes_rest(): void {
302 $this->register_route( Rest\Groups::class );
303 $this->register_route( Rest\Page_Quick_Edit::class );
304 $this->register_route( Rest\Placements::class );
305 $this->register_route( Rest\OnBoarding::class );
306 $this->register_route( Rest\Utilities::class );
307 }
308
309 /**
310 * Includes the necessary functions files.
311 *
312 * @return void
313 */
314 private function includes_functions(): void {
315 require_once ADVADS_ABSPATH . 'includes/functions.php';
316 require_once ADVADS_ABSPATH . 'includes/functions-core.php';
317 require_once ADVADS_ABSPATH . 'includes/functions-conditional.php';
318 require_once ADVADS_ABSPATH . 'includes/functions-ad.php';
319 require_once ADVADS_ABSPATH . 'includes/functions-group.php';
320 require_once ADVADS_ABSPATH . 'includes/functions-placement.php';
321 require_once ADVADS_ABSPATH . 'includes/cap_map.php';
322 require_once ADVADS_ABSPATH . 'includes/default-hooks.php';
323 require_once ADVADS_ABSPATH . 'includes/functions-components.php';
324 }
325
326 /**
327 * Includes deprecated files.
328 *
329 * @return void
330 */
331 private function includes_deprecated(): void {
332 require_once ADVADS_ABSPATH . 'deprecated/ad_group.php';
333 require_once ADVADS_ABSPATH . 'deprecated/ad_placements.php';
334 require_once ADVADS_ABSPATH . 'deprecated/Ad_Repository.php';
335 require_once ADVADS_ABSPATH . 'deprecated/ad_type_abstract.php';
336 require_once ADVADS_ABSPATH . 'deprecated/ad_type_content.php';
337 require_once ADVADS_ABSPATH . 'deprecated/ad_type_dummy.php';
338 require_once ADVADS_ABSPATH . 'deprecated/ad_type_group.php';
339 require_once ADVADS_ABSPATH . 'deprecated/ad_type_image.php';
340 require_once ADVADS_ABSPATH . 'deprecated/ad_type_plain.php';
341 require_once ADVADS_ABSPATH . 'deprecated/ad-ajax.php';
342 require_once ADVADS_ABSPATH . 'deprecated/ad-debug.php';
343 require_once ADVADS_ABSPATH . 'deprecated/ad-expiration.php';
344 require_once ADVADS_ABSPATH . 'deprecated/ad-model.php';
345 require_once ADVADS_ABSPATH . 'deprecated/ad-select.php';
346 require_once ADVADS_ABSPATH . 'deprecated/ad.php';
347 require_once ADVADS_ABSPATH . 'deprecated/gadsense-dummy.php';
348 require_once ADVADS_ABSPATH . 'deprecated/Group_Repository.php';
349 require_once ADVADS_ABSPATH . 'deprecated/class-admin.php';
350 require_once ADVADS_ABSPATH . 'deprecated/class-advanced-ads-plugin.php';
351 require_once ADVADS_ABSPATH . 'deprecated/in-content-injector.php';
352 }
353 }
354