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