Access
3 years ago
Admin
8 months ago
Db
1 year ago
Emails
8 months ago
Forms
8 months ago
Frontend
8 months ago
Helpers
9 months ago
Integrations
8 months ago
Lite
9 months ago
Logger
8 months ago
Migrations
8 months ago
Providers
10 months ago
Requirements
8 months ago
SmartTags
8 months ago
Tasks
11 months ago
API.php
2 years ago
ErrorHandler.php
11 months ago
Loader.php
8 months ago
WPForms.php
8 months ago
Loader.php
953 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPForms; |
| 4 | |
| 5 | /** |
| 6 | * WPForms Class Loader. |
| 7 | * |
| 8 | * @since 1.5.8 |
| 9 | */ |
| 10 | class Loader { |
| 11 | |
| 12 | /** |
| 13 | * Classes to register. |
| 14 | * |
| 15 | * @since 1.5.8 |
| 16 | * |
| 17 | * @var array |
| 18 | */ |
| 19 | private $classes = []; |
| 20 | |
| 21 | /** |
| 22 | * Loader init. |
| 23 | * |
| 24 | * @since 1.5.8 |
| 25 | */ |
| 26 | public function init(): void { |
| 27 | |
| 28 | $this->populate_classes(); |
| 29 | |
| 30 | wpforms()->register_bulk( $this->classes ); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Populate the classes to register. |
| 35 | * |
| 36 | * @since 1.5.8 |
| 37 | */ |
| 38 | protected function populate_classes(): void { |
| 39 | |
| 40 | $this->populate_common(); |
| 41 | $this->populate_frontend(); |
| 42 | $this->populate_admin(); |
| 43 | $this->populate_caches(); |
| 44 | $this->populate_fields(); |
| 45 | $this->populate_forms_overview(); |
| 46 | $this->populate_entries(); |
| 47 | $this->populate_builder(); |
| 48 | $this->populate_db(); |
| 49 | $this->populate_migrations(); |
| 50 | $this->populate_capabilities(); |
| 51 | $this->populate_tasks(); |
| 52 | $this->populate_forms(); |
| 53 | $this->populate_smart_tags(); |
| 54 | $this->populate_logger(); |
| 55 | $this->populate_education(); |
| 56 | $this->populate_robots(); |
| 57 | $this->populate_anti_spam(); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Populate common classes. |
| 62 | * |
| 63 | * @since 1.8.6 |
| 64 | */ |
| 65 | private function populate_common(): void { |
| 66 | |
| 67 | $this->classes[] = [ |
| 68 | 'name' => 'API', |
| 69 | 'id' => 'api', |
| 70 | ]; |
| 71 | |
| 72 | $this->classes[] = [ |
| 73 | 'name' => 'Emails\Summaries', |
| 74 | ]; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Populate the Forms related classes. |
| 79 | * |
| 80 | * @since 1.6.2 |
| 81 | */ |
| 82 | private function populate_forms(): void { |
| 83 | |
| 84 | $this->classes[] = [ |
| 85 | 'name' => 'Forms\Preview', |
| 86 | 'id' => 'preview', |
| 87 | ]; |
| 88 | |
| 89 | $this->classes[] = [ |
| 90 | 'name' => 'Forms\Token', |
| 91 | 'id' => 'token', |
| 92 | ]; |
| 93 | |
| 94 | $this->classes[] = [ |
| 95 | 'name' => 'Forms\Honeypot', |
| 96 | 'id' => 'honeypot', |
| 97 | ]; |
| 98 | |
| 99 | $this->classes[] = [ |
| 100 | 'name' => 'Forms\Akismet', |
| 101 | 'id' => 'akismet', |
| 102 | ]; |
| 103 | |
| 104 | $this->classes[] = [ |
| 105 | 'name' => 'Forms\Submission', |
| 106 | 'id' => 'submission', |
| 107 | 'hook' => false, |
| 108 | 'run' => false, |
| 109 | ]; |
| 110 | |
| 111 | $this->classes[] = [ |
| 112 | 'name' => 'Forms\Locator', |
| 113 | 'id' => 'locator', |
| 114 | ]; |
| 115 | |
| 116 | $this->classes[] = [ |
| 117 | 'name' => 'Forms\IconChoices', |
| 118 | 'id' => 'icon_choices', |
| 119 | ]; |
| 120 | |
| 121 | $this->classes[] = [ |
| 122 | 'name' => 'Forms\AntiSpam', |
| 123 | 'id' => 'anti_spam', |
| 124 | ]; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Populate Frontend-related classes. |
| 129 | * |
| 130 | * @since 1.8.1 |
| 131 | */ |
| 132 | private function populate_frontend(): void { |
| 133 | |
| 134 | $this->classes[] = [ |
| 135 | 'name' => 'Frontend\Address', |
| 136 | 'id' => 'address', |
| 137 | ]; |
| 138 | |
| 139 | $this->classes[] = [ |
| 140 | 'name' => 'Frontend\Amp', |
| 141 | 'id' => 'amp', |
| 142 | ]; |
| 143 | |
| 144 | $this->classes[] = [ |
| 145 | 'name' => 'Frontend\Captcha', |
| 146 | 'id' => 'captcha', |
| 147 | ]; |
| 148 | |
| 149 | $this->classes[] = [ |
| 150 | 'name' => 'Frontend\CSSVars', |
| 151 | 'id' => 'css_vars', |
| 152 | ]; |
| 153 | |
| 154 | $this->classes[] = [ |
| 155 | 'name' => 'Frontend\Classic', |
| 156 | 'id' => 'frontend_classic', |
| 157 | ]; |
| 158 | |
| 159 | $this->classes[] = [ |
| 160 | 'name' => 'Frontend\Modern', |
| 161 | 'id' => 'frontend_modern', |
| 162 | ]; |
| 163 | |
| 164 | $this->classes[] = [ |
| 165 | 'name' => 'Frontend\Frontend', |
| 166 | 'id' => 'frontend', |
| 167 | ]; |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Populate Admin-related classes. |
| 172 | * |
| 173 | * @since 1.6.0 |
| 174 | */ |
| 175 | private function populate_admin(): void { |
| 176 | |
| 177 | array_push( |
| 178 | $this->classes, |
| 179 | [ |
| 180 | 'name' => 'Admin\Notice', |
| 181 | 'id' => 'notice', |
| 182 | ], |
| 183 | [ |
| 184 | 'name' => 'Admin\Revisions', |
| 185 | 'id' => 'revisions', |
| 186 | 'hook' => 'admin_init', |
| 187 | ], |
| 188 | [ |
| 189 | 'name' => 'Admin\Addons\AddonsCache', |
| 190 | 'id' => 'addons_cache', |
| 191 | ], |
| 192 | [ |
| 193 | 'name' => 'Admin\CoreInfoCache', |
| 194 | 'id' => 'core_info_cache', |
| 195 | ], |
| 196 | [ |
| 197 | 'name' => 'Admin\Addons\Addons', |
| 198 | 'id' => 'addons', |
| 199 | ], |
| 200 | [ |
| 201 | 'name' => 'Admin\AdminBarMenu', |
| 202 | 'hook' => 'init', |
| 203 | ], |
| 204 | [ |
| 205 | 'name' => 'Admin\Notifications\Notifications', |
| 206 | 'id' => 'notifications', |
| 207 | ], |
| 208 | [ |
| 209 | 'name' => 'Admin\Entries\Handler', |
| 210 | 'hook' => 'admin_init', |
| 211 | ], |
| 212 | [ |
| 213 | 'name' => 'Admin\Pages\Templates', |
| 214 | 'id' => 'templates_page', |
| 215 | 'hook' => 'admin_init', |
| 216 | ], |
| 217 | [ |
| 218 | 'name' => 'Admin\Forms\UserTemplates', |
| 219 | 'id' => 'user_templates', |
| 220 | ], |
| 221 | [ |
| 222 | 'name' => 'Admin\Forms\Page', |
| 223 | 'id' => 'forms_overview', |
| 224 | ], |
| 225 | [ |
| 226 | 'name' => 'Admin\Challenge', |
| 227 | 'id' => 'challenge', |
| 228 | ], |
| 229 | [ |
| 230 | 'name' => 'Admin\FormEmbedWizard', |
| 231 | 'hook' => 'admin_init', |
| 232 | 'id' => 'form_embed_wizard', |
| 233 | ], |
| 234 | [ |
| 235 | 'name' => 'Admin\SiteHealth', |
| 236 | 'hook' => 'admin_init', |
| 237 | ], |
| 238 | [ |
| 239 | 'name' => 'Admin\Settings\ModernMarkup', |
| 240 | 'hook' => 'admin_init', |
| 241 | ], |
| 242 | [ |
| 243 | 'name' => 'Admin\Settings\Email', |
| 244 | 'hook' => 'admin_init', |
| 245 | ], |
| 246 | [ |
| 247 | 'name' => 'Admin\Settings\Captcha\Page', |
| 248 | 'hook' => 'admin_init', |
| 249 | ], |
| 250 | [ |
| 251 | 'name' => 'Admin\Settings\Payments', |
| 252 | 'hook' => 'admin_init', |
| 253 | ], |
| 254 | [ |
| 255 | 'name' => 'Admin\Tools\Tools', |
| 256 | 'hook' => 'current_screen', |
| 257 | ], |
| 258 | [ |
| 259 | 'name' => 'Admin\Payments\Payments', |
| 260 | 'hook' => 'init', |
| 261 | ], |
| 262 | [ |
| 263 | 'name' => 'Admin\Payments\Views\Overview\Ajax', |
| 264 | 'hook' => 'admin_init', |
| 265 | 'run' => 'hooks', |
| 266 | 'condition' => wpforms_is_admin_ajax(), |
| 267 | ], |
| 268 | [ |
| 269 | 'name' => 'Admin\Tools\Importers', |
| 270 | 'hook' => 'admin_init', |
| 271 | 'run' => 'load', |
| 272 | 'condition' => wp_doing_ajax(), |
| 273 | ], |
| 274 | [ |
| 275 | 'name' => 'Admin\Pages\Addons', |
| 276 | 'id' => 'addons_page', |
| 277 | ], |
| 278 | [ |
| 279 | 'name' => 'Admin\Pages\ConstantContact', |
| 280 | 'hook' => 'admin_init', |
| 281 | ], |
| 282 | [ |
| 283 | 'name' => 'Admin\Pages\PrivacyCompliance', |
| 284 | 'hook' => 'admin_init', |
| 285 | ], |
| 286 | [ |
| 287 | 'name' => 'Forms\Fields\Richtext\EntryViewContent', |
| 288 | ], |
| 289 | [ |
| 290 | 'name' => 'Admin\DashboardWidget', |
| 291 | 'hook' => wpforms()->is_pro() ? 'admin_init' : 'init', |
| 292 | ], |
| 293 | [ |
| 294 | 'name' => 'Emails\Preview', |
| 295 | 'hook' => 'admin_init', |
| 296 | ], |
| 297 | [ |
| 298 | 'name' => 'Admin\Addons\GoogleSheets', |
| 299 | 'hook' => 'admin_init', |
| 300 | ], |
| 301 | [ |
| 302 | 'name' => 'Admin\PluginList', |
| 303 | 'id' => 'plugin_list', |
| 304 | 'hook' => 'admin_init', |
| 305 | ], |
| 306 | [ |
| 307 | 'name' => 'Admin\Splash\SplashScreen', |
| 308 | 'id' => 'splash_screen', |
| 309 | 'hook' => 'admin_init', |
| 310 | ], |
| 311 | [ |
| 312 | 'name' => 'Admin\Splash\SplashCache', |
| 313 | 'id' => 'splash_cache', |
| 314 | 'hook' => 'plugins_loaded', |
| 315 | ], |
| 316 | [ |
| 317 | 'name' => 'Admin\Splash\SplashUpgrader', |
| 318 | 'id' => 'splash_upgrader', |
| 319 | 'hook' => 'plugins_loaded', |
| 320 | ] |
| 321 | ); |
| 322 | } |
| 323 | |
| 324 | /** |
| 325 | * Populate Caches related classes. |
| 326 | * |
| 327 | * @since 1.8.7 |
| 328 | */ |
| 329 | private function populate_caches(): void { |
| 330 | |
| 331 | array_push( |
| 332 | $this->classes, |
| 333 | [ |
| 334 | 'name' => 'LicenseApi\PluginUpdateCache', |
| 335 | 'id' => 'license_api_plugin_update_cache', |
| 336 | ], |
| 337 | [ |
| 338 | 'name' => 'LicenseApi\ValidateKeyCache', |
| 339 | 'id' => 'license_api_validate_key_cache', |
| 340 | ] |
| 341 | ); |
| 342 | } |
| 343 | |
| 344 | /** |
| 345 | * Populate Fields related classes. |
| 346 | * |
| 347 | * @since 1.8.2 |
| 348 | */ |
| 349 | private function populate_fields(): void { |
| 350 | |
| 351 | // Fancy fields. |
| 352 | $this->classes[] = [ |
| 353 | 'name' => 'Forms\Fields\Address\Field', |
| 354 | 'hook' => 'init', |
| 355 | ]; |
| 356 | |
| 357 | $this->classes[] = [ |
| 358 | 'name' => 'Forms\Fields\Content\Field', |
| 359 | 'hook' => 'init', |
| 360 | ]; |
| 361 | |
| 362 | $this->classes[] = [ |
| 363 | 'name' => 'Forms\Fields\DateTime\Field', |
| 364 | 'hook' => 'init', |
| 365 | ]; |
| 366 | |
| 367 | $this->classes[] = [ |
| 368 | 'name' => 'Forms\Fields\Divider\Field', |
| 369 | 'hook' => 'init', |
| 370 | ]; |
| 371 | |
| 372 | $this->classes[] = [ |
| 373 | 'name' => 'Forms\Fields\FileUpload\Field', |
| 374 | 'hook' => 'init', |
| 375 | ]; |
| 376 | |
| 377 | $this->classes[] = [ |
| 378 | 'name' => 'Forms\Fields\Hidden\Field', |
| 379 | 'hook' => 'init', |
| 380 | ]; |
| 381 | |
| 382 | $this->classes[] = [ |
| 383 | 'name' => 'Forms\Fields\Html\Field', |
| 384 | 'hook' => 'init', |
| 385 | ]; |
| 386 | |
| 387 | $this->classes[] = [ |
| 388 | 'name' => 'Forms\Fields\Phone\Field', |
| 389 | 'hook' => 'init', |
| 390 | ]; |
| 391 | |
| 392 | $this->classes[] = [ |
| 393 | 'name' => 'Forms\Fields\EntryPreview\Field', |
| 394 | 'hook' => 'init', |
| 395 | ]; |
| 396 | |
| 397 | $this->classes[] = [ |
| 398 | 'name' => 'Forms\Fields\Password\Field', |
| 399 | 'hook' => 'init', |
| 400 | ]; |
| 401 | |
| 402 | $this->classes[] = [ |
| 403 | 'name' => 'Forms\Fields\CreditCard\Field', |
| 404 | 'hook' => 'init', |
| 405 | ]; |
| 406 | |
| 407 | $this->classes[] = [ |
| 408 | 'name' => 'Forms\Fields\Rating\Field', |
| 409 | 'hook' => 'init', |
| 410 | ]; |
| 411 | |
| 412 | $this->classes[] = [ |
| 413 | 'name' => 'Forms\Fields\Url\Field', |
| 414 | 'hook' => 'init', |
| 415 | ]; |
| 416 | |
| 417 | $this->classes[] = [ |
| 418 | 'name' => 'Forms\Fields\Richtext\Field', |
| 419 | 'hook' => 'init', |
| 420 | ]; |
| 421 | |
| 422 | $this->classes[] = [ |
| 423 | 'name' => 'Forms\Fields\Pagebreak\Field', |
| 424 | 'hook' => 'init', |
| 425 | ]; |
| 426 | |
| 427 | $this->classes[] = [ |
| 428 | 'name' => 'Forms\Fields\CustomCaptcha\Field', |
| 429 | ]; |
| 430 | |
| 431 | $this->classes[] = [ |
| 432 | 'name' => 'Forms\Fields\Layout\Field', |
| 433 | 'hook' => 'init', |
| 434 | ]; |
| 435 | |
| 436 | $this->classes[] = [ |
| 437 | 'name' => 'Forms\Fields\Layout\Process', |
| 438 | 'hook' => 'init', |
| 439 | ]; |
| 440 | |
| 441 | $this->classes[] = [ |
| 442 | 'name' => 'Forms\Fields\Layout\Notifications', |
| 443 | 'hook' => 'init', |
| 444 | ]; |
| 445 | |
| 446 | $this->classes[] = [ |
| 447 | 'name' => 'Forms\Fields\Repeater\Field', |
| 448 | ]; |
| 449 | |
| 450 | $this->classes[] = [ |
| 451 | 'name' => 'Forms\Fields\Camera\Field', |
| 452 | 'hook' => 'init', |
| 453 | ]; |
| 454 | |
| 455 | $this->classes[] = [ |
| 456 | 'name' => 'Forms\Fields\Repeater\Process', |
| 457 | 'id' => 'repeater_process', |
| 458 | 'hook' => 'init', |
| 459 | ]; |
| 460 | |
| 461 | $this->classes[] = [ |
| 462 | 'name' => 'Forms\Fields\Repeater\Notifications', |
| 463 | 'hook' => 'init', |
| 464 | ]; |
| 465 | |
| 466 | // Payment fields. |
| 467 | $this->classes[] = [ |
| 468 | 'name' => 'Forms\Fields\PaymentCheckbox\Field', |
| 469 | 'hook' => 'init', |
| 470 | ]; |
| 471 | |
| 472 | $this->classes[] = [ |
| 473 | 'name' => 'Forms\Fields\PaymentMultiple\Field', |
| 474 | 'hook' => 'init', |
| 475 | ]; |
| 476 | |
| 477 | $this->classes[] = [ |
| 478 | 'name' => 'Forms\Fields\PaymentSelect\Field', |
| 479 | 'hook' => 'init', |
| 480 | ]; |
| 481 | |
| 482 | $this->classes[] = [ |
| 483 | 'name' => 'Forms\Fields\PaymentSingle\Field', |
| 484 | 'hook' => 'init', |
| 485 | ]; |
| 486 | |
| 487 | $this->classes[] = [ |
| 488 | 'name' => 'Forms\Fields\PaymentTotal\Field', |
| 489 | 'hook' => 'init', |
| 490 | ]; |
| 491 | |
| 492 | // Addon fields in Lite. |
| 493 | $this->classes[] = [ |
| 494 | 'name' => 'Forms\Fields\Addons\Coupon\Field', |
| 495 | 'addon_class' => 'WPFormsCoupons\Field', |
| 496 | 'addon_slug' => 'coupons', |
| 497 | ]; |
| 498 | |
| 499 | $this->classes[] = [ |
| 500 | 'name' => 'Forms\Fields\Addons\Signature\Field', |
| 501 | 'addon_class' => 'WPFormsSignatures\Fields\Signature', |
| 502 | 'addon_slug' => 'signatures', |
| 503 | ]; |
| 504 | |
| 505 | $this->classes[] = [ |
| 506 | 'name' => 'Forms\Fields\Addons\LikertScale\Field', |
| 507 | 'addon_class' => 'WPFormsSurveys\Fields\LikertScale\Field', |
| 508 | 'addon_slug' => 'surveys-polls', |
| 509 | ]; |
| 510 | |
| 511 | $this->classes[] = [ |
| 512 | 'name' => 'Forms\Fields\Addons\NetPromoterScore\Field', |
| 513 | 'addon_class' => 'WPFormsSurveys\Fields\NetPromoterScore\Field', |
| 514 | 'addon_slug' => 'surveys-polls', |
| 515 | ]; |
| 516 | } |
| 517 | |
| 518 | /** |
| 519 | * Populate Forms Overview admin page related classes. |
| 520 | * |
| 521 | * @since 1.7.5 |
| 522 | */ |
| 523 | private function populate_forms_overview(): void { |
| 524 | |
| 525 | if ( ! wpforms_is_admin_page( 'overview' ) && ! wpforms_is_admin_ajax() ) { |
| 526 | return; |
| 527 | } |
| 528 | |
| 529 | array_push( |
| 530 | $this->classes, |
| 531 | [ |
| 532 | 'name' => 'Admin\Forms\Ajax\Columns', |
| 533 | 'id' => 'forms_columns_ajax', |
| 534 | ], |
| 535 | [ |
| 536 | 'name' => 'Admin\Forms\Ajax\Tags', |
| 537 | 'id' => 'forms_tags_ajax', |
| 538 | ], |
| 539 | [ |
| 540 | 'name' => 'Admin\Forms\Search', |
| 541 | 'id' => 'forms_search', |
| 542 | ], |
| 543 | [ |
| 544 | 'name' => 'Admin\Forms\Views', |
| 545 | 'id' => 'forms_views', |
| 546 | ], |
| 547 | [ |
| 548 | 'name' => 'Admin\Forms\BulkActions', |
| 549 | 'id' => 'forms_bulk_actions', |
| 550 | ], |
| 551 | [ |
| 552 | 'name' => 'Admin\Forms\Tags', |
| 553 | 'id' => 'forms_tags', |
| 554 | ] |
| 555 | ); |
| 556 | } |
| 557 | |
| 558 | /** |
| 559 | * Populate Entries related classes. |
| 560 | * |
| 561 | * @since 1.8.6 |
| 562 | */ |
| 563 | private function populate_entries(): void { |
| 564 | |
| 565 | array_push( |
| 566 | $this->classes, |
| 567 | [ |
| 568 | 'name' => 'Admin\Entries\PageOptions', |
| 569 | 'id' => 'entries_page_options', |
| 570 | ], |
| 571 | [ |
| 572 | 'name' => 'Admin\Entries\Page', |
| 573 | 'id' => 'entries_list_page', |
| 574 | 'hook' => 'admin_init', |
| 575 | ], |
| 576 | [ |
| 577 | 'name' => 'Admin\Entries\Overview\Page', |
| 578 | 'id' => 'entries_overview', |
| 579 | ], |
| 580 | [ |
| 581 | 'name' => 'Admin\Entries\Overview\Ajax', |
| 582 | 'hook' => 'admin_init', |
| 583 | 'run' => 'hooks', |
| 584 | 'condition' => wpforms_is_admin_ajax(), |
| 585 | ], |
| 586 | [ |
| 587 | 'name' => 'Admin\Entries\Ajax\Columns', |
| 588 | 'id' => 'entries_columns_ajax', |
| 589 | ], |
| 590 | [ |
| 591 | 'name' => 'Admin\Entries\Edit', |
| 592 | 'id' => 'entries_edit', |
| 593 | 'hook' => 'admin_init', |
| 594 | ], |
| 595 | [ |
| 596 | 'name' => 'Admin\Entries\Export\Export', |
| 597 | 'id' => 'entries_export', |
| 598 | 'hook' => 'init', |
| 599 | ], |
| 600 | [ |
| 601 | 'name' => 'Admin\Entries\DefaultScreen', |
| 602 | 'hook' => 'admin_init', |
| 603 | ] |
| 604 | ); |
| 605 | } |
| 606 | |
| 607 | /** |
| 608 | * Populate Form Builder related classes. |
| 609 | * |
| 610 | * @since 1.6.8 |
| 611 | */ |
| 612 | private function populate_builder(): void { |
| 613 | |
| 614 | array_push( |
| 615 | $this->classes, |
| 616 | [ |
| 617 | 'name' => 'Admin\Builder\HelpCache', |
| 618 | 'id' => 'builder_help_cache', |
| 619 | ], |
| 620 | [ |
| 621 | 'name' => 'Admin\Builder\Help', |
| 622 | 'id' => 'builder_help', |
| 623 | ], |
| 624 | [ |
| 625 | 'name' => 'Admin\Builder\Shortcuts', |
| 626 | ], |
| 627 | [ |
| 628 | 'name' => 'Admin\Builder\TemplatesCache', |
| 629 | 'id' => 'builder_templates_cache', |
| 630 | ], |
| 631 | [ |
| 632 | 'name' => 'Admin\Builder\TemplateSingleCache', |
| 633 | 'id' => 'builder_template_single', |
| 634 | ], |
| 635 | [ |
| 636 | 'name' => 'Admin\Builder\Templates', |
| 637 | 'id' => 'builder_templates', |
| 638 | ], |
| 639 | [ |
| 640 | 'name' => 'Admin\Builder\AntiSpam', |
| 641 | 'hook' => 'wpforms_builder_init', |
| 642 | ], |
| 643 | [ |
| 644 | 'name' => 'Admin\Builder\Settings\Themes', |
| 645 | 'hook' => 'wpforms_builder_init', |
| 646 | ], |
| 647 | [ |
| 648 | 'name' => 'Admin\Builder\Notifications\Advanced\EmailTemplate', |
| 649 | 'hook' => 'wpforms_builder_init', |
| 650 | ], |
| 651 | [ |
| 652 | 'name' => 'Admin\Builder\ContextMenu', |
| 653 | 'hook' => 'wpforms_builder_init', |
| 654 | 'id' => 'context_menu', |
| 655 | ], |
| 656 | [ |
| 657 | 'name' => 'Admin\Builder\ImageUpload', |
| 658 | 'hook' => 'wpforms_builder_init', |
| 659 | 'id' => 'image_upload', |
| 660 | ], |
| 661 | [ |
| 662 | 'name' => 'Admin\Builder\Notifications\Advanced\Settings', |
| 663 | ], |
| 664 | [ |
| 665 | 'name' => 'Admin\Builder\Notifications\Advanced\FileUploadAttachment', |
| 666 | ], |
| 667 | [ |
| 668 | 'name' => 'Admin\Builder\Notifications\Advanced\EntryCsvAttachment', |
| 669 | ], |
| 670 | [ |
| 671 | 'name' => 'Admin\Builder\Ajax\PanelLoader', |
| 672 | ], |
| 673 | [ |
| 674 | 'name' => 'Admin\Builder\Addons', |
| 675 | ], |
| 676 | [ |
| 677 | 'name' => 'Admin\Builder\Ajax\SaveForm', |
| 678 | 'id' => 'builder_save_form', |
| 679 | ], |
| 680 | [ |
| 681 | 'name' => 'Admin\Builder\Payments', |
| 682 | 'hook' => 'wpforms_builder_init', |
| 683 | 'id' => 'builder_payments', |
| 684 | ] |
| 685 | ); |
| 686 | } |
| 687 | |
| 688 | /** |
| 689 | * Populate database classes. |
| 690 | * |
| 691 | * @since 1.8.2 |
| 692 | */ |
| 693 | private function populate_db(): void { |
| 694 | |
| 695 | array_push( |
| 696 | $this->classes, |
| 697 | [ |
| 698 | 'name' => 'Db\Payments\Payment', |
| 699 | 'id' => 'payment', |
| 700 | 'hook' => false, |
| 701 | 'run' => false, |
| 702 | ], |
| 703 | [ |
| 704 | 'name' => 'Db\Payments\Meta', |
| 705 | 'id' => 'payment_meta', |
| 706 | 'hook' => false, |
| 707 | 'run' => false, |
| 708 | ], |
| 709 | [ |
| 710 | 'name' => 'Db\Payments\Queries', |
| 711 | 'id' => 'payment_queries', |
| 712 | 'hook' => false, |
| 713 | 'run' => false, |
| 714 | ], |
| 715 | [ |
| 716 | 'name' => 'Db\Files\ProtectedFiles', |
| 717 | 'id' => 'protected_files', |
| 718 | 'hook' => false, |
| 719 | 'run' => false, |
| 720 | ], |
| 721 | [ |
| 722 | 'name' => 'Db\Files\Restrictions', |
| 723 | 'id' => 'file_restrictions', |
| 724 | 'hook' => false, |
| 725 | 'run' => false, |
| 726 | ] |
| 727 | ); |
| 728 | } |
| 729 | |
| 730 | /** |
| 731 | * Populate migration classes. |
| 732 | * |
| 733 | * @since 1.5.9 |
| 734 | */ |
| 735 | private function populate_migrations(): void { |
| 736 | |
| 737 | $this->classes[] = [ |
| 738 | 'name' => 'Migrations\Migrations', |
| 739 | 'hook' => 'plugins_loaded', |
| 740 | ]; |
| 741 | } |
| 742 | |
| 743 | /** |
| 744 | * Populate access management (capabilities) classes. |
| 745 | * |
| 746 | * @since 1.5.8 |
| 747 | */ |
| 748 | private function populate_capabilities(): void { |
| 749 | |
| 750 | array_push( |
| 751 | $this->classes, |
| 752 | [ |
| 753 | 'name' => 'Access\Capabilities', |
| 754 | 'id' => 'access', |
| 755 | 'hook' => 'plugins_loaded', |
| 756 | ], |
| 757 | [ |
| 758 | 'name' => 'Access\Integrations', |
| 759 | ], |
| 760 | [ |
| 761 | 'name' => 'Access\File', |
| 762 | 'hook' => 'init', |
| 763 | 'condition' => ! is_admin(), |
| 764 | ], |
| 765 | [ |
| 766 | 'name' => 'Admin\Settings\Access', |
| 767 | 'condition' => is_admin(), |
| 768 | ] |
| 769 | ); |
| 770 | } |
| 771 | |
| 772 | /** |
| 773 | * Populate tasks related classes. |
| 774 | * |
| 775 | * @since 1.5.9 |
| 776 | */ |
| 777 | private function populate_tasks(): void { |
| 778 | |
| 779 | array_push( |
| 780 | $this->classes, |
| 781 | [ |
| 782 | 'name' => 'Tasks\Tasks', |
| 783 | 'id' => 'tasks', |
| 784 | 'hook' => 'init', |
| 785 | ], |
| 786 | [ |
| 787 | 'name' => 'Tasks\Meta', |
| 788 | 'id' => 'tasks_meta', |
| 789 | 'hook' => false, |
| 790 | 'run' => false, |
| 791 | ] |
| 792 | ); |
| 793 | } |
| 794 | |
| 795 | /** |
| 796 | * Populate smart tags loaded classes. |
| 797 | * |
| 798 | * @since 1.6.7 |
| 799 | */ |
| 800 | private function populate_smart_tags(): void { |
| 801 | |
| 802 | $this->classes[] = [ |
| 803 | 'name' => 'SmartTags\SmartTags', |
| 804 | 'id' => 'smart_tags', |
| 805 | 'run' => 'hooks', |
| 806 | ]; |
| 807 | } |
| 808 | |
| 809 | /** |
| 810 | * Populate logger-loaded classes. |
| 811 | * |
| 812 | * @since 1.6.3 |
| 813 | */ |
| 814 | private function populate_logger(): void { |
| 815 | |
| 816 | $this->classes[] = [ |
| 817 | 'name' => 'Logger\Log', |
| 818 | 'id' => 'log', |
| 819 | 'hook' => false, |
| 820 | 'run' => 'hooks', |
| 821 | ]; |
| 822 | } |
| 823 | |
| 824 | /** |
| 825 | * Populate education-related classes. |
| 826 | * |
| 827 | * @since 1.6.6 |
| 828 | */ |
| 829 | private function populate_education(): void { |
| 830 | |
| 831 | // Kill switch. |
| 832 | |
| 833 | /** |
| 834 | * Filters admin education status. |
| 835 | * |
| 836 | * @since 1.6.6 |
| 837 | * |
| 838 | * @param bool $status Current admin education status. |
| 839 | * |
| 840 | * @return bool |
| 841 | */ |
| 842 | if ( ! apply_filters( 'wpforms_admin_education', true ) ) { // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName |
| 843 | return; |
| 844 | } |
| 845 | |
| 846 | // Education core classes. |
| 847 | array_push( |
| 848 | $this->classes, |
| 849 | [ |
| 850 | 'name' => 'Admin\Education\Core', |
| 851 | 'id' => 'education', |
| 852 | ], |
| 853 | [ |
| 854 | 'name' => 'Admin\Education\Fields', |
| 855 | 'id' => 'education_fields', |
| 856 | ], |
| 857 | [ |
| 858 | 'name' => 'Admin\Education\Admin\Settings\SMTP', |
| 859 | 'id' => 'education_smtp_notice', |
| 860 | ], |
| 861 | [ |
| 862 | 'name' => 'Admin\Education\Admin\EditPost', |
| 863 | 'hook' => 'load-edit.php', |
| 864 | ], |
| 865 | [ |
| 866 | 'name' => 'Admin\Education\Admin\EditPost', |
| 867 | 'hook' => 'load-post-new.php', |
| 868 | ], |
| 869 | [ |
| 870 | 'name' => 'Admin\Education\Admin\EditPost', |
| 871 | 'hook' => 'load-post.php', |
| 872 | ], |
| 873 | [ |
| 874 | 'name' => 'Admin\Education\Admin\EditPost', |
| 875 | 'hook' => 'load-site-editor.php', |
| 876 | ], |
| 877 | [ |
| 878 | 'name' => 'Admin\Education\Pointers\Payment', |
| 879 | 'hook' => 'admin_init', |
| 880 | 'priority' => 20, |
| 881 | ] |
| 882 | ); |
| 883 | |
| 884 | // Education features classes. |
| 885 | $features = [ |
| 886 | 'LiteConnect', |
| 887 | 'Builder\Calculations', |
| 888 | 'Builder\Captcha', |
| 889 | 'Builder\Fields', |
| 890 | 'Builder\Settings', |
| 891 | 'Builder\Providers', |
| 892 | 'Builder\Payments', |
| 893 | 'Builder\DidYouKnow', |
| 894 | 'Builder\Geolocation', |
| 895 | 'Builder\Confirmations', |
| 896 | 'Builder\Notifications', |
| 897 | 'Builder\PDF', |
| 898 | 'Admin\DidYouKnow', |
| 899 | 'Admin\Settings\Integrations', |
| 900 | 'Admin\Settings\Geolocation', |
| 901 | 'Admin\NoticeBar', |
| 902 | 'Admin\Entries\Geolocation', |
| 903 | 'Admin\Entries\UserJourney', |
| 904 | ]; |
| 905 | |
| 906 | foreach ( $features as $feature ) { |
| 907 | $this->classes[] = [ |
| 908 | 'name' => 'Admin\Education\\' . $feature, |
| 909 | ]; |
| 910 | } |
| 911 | } |
| 912 | |
| 913 | /** |
| 914 | * Populate robots loaded class. |
| 915 | * |
| 916 | * @since 1.7.0 |
| 917 | */ |
| 918 | private function populate_robots(): void { |
| 919 | |
| 920 | $this->classes[] = [ |
| 921 | 'name' => 'Robots', |
| 922 | 'run' => 'hooks', |
| 923 | ]; |
| 924 | } |
| 925 | |
| 926 | /** |
| 927 | * Populate AntiSpam loaded classes. |
| 928 | * |
| 929 | * @since 1.7.8 |
| 930 | */ |
| 931 | private function populate_anti_spam(): void { |
| 932 | |
| 933 | array_push( |
| 934 | $this->classes, |
| 935 | [ |
| 936 | 'name' => 'AntiSpam\CountryFilter', |
| 937 | 'id' => 'antispam_country_filter', |
| 938 | 'hook' => 'init', |
| 939 | ], |
| 940 | [ |
| 941 | 'name' => 'AntiSpam\KeywordFilter', |
| 942 | 'id' => 'antispam_keyword_filter', |
| 943 | 'hook' => 'init', |
| 944 | ], |
| 945 | [ |
| 946 | 'name' => 'AntiSpam\SpamEntry', |
| 947 | 'id' => 'spam_entry', |
| 948 | 'hook' => 'init', |
| 949 | ] |
| 950 | ); |
| 951 | } |
| 952 | } |
| 953 |