BuddyPress::autoload( string $class )
Autoload classes.
Description
Parameters
- $class
-
(Required)
Source
File: class-buddypress.php
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 | public function autoload( $class ) { $class_parts = explode ( '_' , strtolower ( $class ) ); if ( 'bp' !== $class_parts [0] ) { return ; } $components = array ( 'activity' , 'blogs' , 'core' , 'friends' , 'groups' , 'members' , 'messages' , 'notifications' , 'settings' , 'xprofile' , 'profiletype' , 'forums' , 'search' , 'media' , 'gdpr' , 'invites' , ); // These classes don't have a name that matches their component. $irregular_map = array ( 'BP_Akismet' => 'activity' , 'BP_Admin' => 'core' , 'BP_Attachment_Avatar' => 'core' , 'BP_Attachment_Cover_Image' => 'core' , 'BP_Attachment' => 'core' , 'BP_Button' => 'core' , 'BP_Component' => 'core' , 'BP_Integration' => 'core' , 'BP_Customizer_Control_Range' => 'core' , 'BP_Date_Query' => 'core' , 'BP_Email_Tokens' => 'core' , 'BP_Email_Delivery' => 'core' , 'BP_Email_Recipient' => 'core' , 'BP_Email' => 'core' , 'BP_Embed' => 'core' , 'BP_Media_Extractor' => 'core' , 'BP_Members_Suggestions' => 'core' , 'BP_PHPMailer' => 'core' , 'BP_Recursive_Query' => 'core' , 'BP_Suggestions' => 'core' , 'BP_Theme_Compat' => 'core' , 'BP_User_Query' => 'core' , 'BP_Walker_Category_Checklist' => 'core' , 'BP_Walker_Nav_Menu_Checklist' => 'core' , 'BP_Walker_Nav_Menu' => 'core' , 'BP_Core_Gdpr' => 'gdpr' , 'BP_Activity_Export' => 'gdpr' , 'BP_Export' => 'gdpr' , 'BP_Friendship_Export' => 'gdpr' , 'BP_Group_Export' => 'gdpr' , 'BP_Group_Membership_Export' => 'gdpr' , 'BP_Message_Export' => 'gdpr' , 'BP_Notification_Export' => 'gdpr' , 'BP_Settings_Export' => 'gdpr' , 'BP_Xprofile_Export' => 'gdpr' , 'BP_Bbp_Gdpr_Forums' => 'gdpr' , 'BP_Bbp_Gdpr_Replies' => 'gdpr' , 'BP_Bbp_Gdpr_Topics' => 'gdpr' , 'BP_Core_Friends_Widget' => 'friends' , 'BP_Core_Network_Posts_Widget' => 'core' , 'BP_Core_Follow_Following_Widget' => 'core' , 'BP_Group_Extension' => 'groups' , 'BP_Group_Member_Query' => 'groups' , 'BP_Core_Members_Template' => 'members' , 'BP_Core_Members_Widget' => 'members' , 'BP_Core_Recently_Active_Widget' => 'members' , 'BP_Core_Whos_Online_Widget' => 'members' , 'BP_Registration_Theme_Compat' => 'members' , 'BP_Signup' => 'members' , 'BP_BuddyBoss_Platform_Updater' => 'core' , ); $component = null; // First check to see if the class is one without a properly namespaced name. if ( isset( $irregular_map [ $class ] ) ) { $component = $irregular_map [ $class ]; // Next chunk is usually the component name. } elseif ( in_array( $class_parts [1], $components , true ) ) { $component = $class_parts [1]; } if ( ! $component ) { return ; } // Sanitize class name. $class = strtolower ( str_replace ( '_' , '-' , $class ) ); if ( 'gdpr' === $component ) { $path = dirname( __FILE__ ) . "/bp-core/gdpr/class-{$class}.php" ; } else { $path = dirname( __FILE__ ) . "/bp-{$component}/classes/class-{$class}.php" ; } // Sanity check. if ( ! file_exists ( $path ) ) { return ; } /* * Sanity check 2 - Check if component is active before loading class. * Skip if PHPUnit is running, or BuddyPress is installing for the first time. */ if ( ! in_array( $component , array ( 'core' , 'members' , 'xprofile' , 'gdpr' , 'profiletype' ), true ) && ! bp_is_active( $component ) && ! function_exists( 'tests_add_filter' ) ) { return ; } require $path ; } |
Changelog
Version | Description |
---|---|
BuddyPress 2.5.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.