Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/25/2011 08:58:56 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Rename new 'bp-users' component to 'bp-members' for consistency through-out project.
Core, Messages, and Friends Components now use the BP_Component class.
Split Friends and Messages components into smaller files.
Change references to 'profile' to 'xprofile' through-out project for consistency.
Introduce 'bp_actions' and 'bp_screens' standard hooks to replace the usage of 'wp' through-out project.
Move component loader sequence into bp-core-bootstrap.php,
Move old root_component action into 1.3 deprecated file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-component.php

    r3751 r3917  
    3434
    3535    /**
     36     * @var string The path to the plugins files
     37     */
     38    var $path;
     39
     40    /**
    3641     * @var WP_Query The loop for this component
    3742     */
     
    6368     * @uses bp_Component::_setup_actions() Setup the hooks and actions
    6469     */
    65     function start( $id, $name ) {
     70    function start( $id, $name, $path ) {
    6671        // Internal identifier of component
    6772        $this->id   = $id;
     
    7075        $this->name = $name;
    7176
    72         $this->_setup_actions ();
     77        // Path for includes
     78        $this->path = $path;
     79
     80        // Move on to the next step
     81        $this->_setup_actions();
    7382    }
    7483
     
    9099
    91100        $defaults = array(
    92             'slug'      => '',
    93             'root_slug' => ''
     101            'slug'                  => '',
     102            'root_slug'             => '',
     103            'notification_callback' => '',
     104            'global_tables'         => ''
    94105        );
    95106        $r = wp_parse_args( $args, $defaults );
     
    101112        $this->root_slug = apply_filters( 'bp_' . $this->id . '_root_slug', $r['root_slug'] );
    102113
     114        // Notifications callback
     115        $this->notification_callback = 'bp_' . $this->id . '_notification_callback';
     116
     117        // Setup global table names
     118        if ( !empty( $r['global_tables'] ) )
     119            foreach ( $r['global_tables'] as $global_name => $table_name )
     120                $this->$global_name = $table_name;
     121
    103122        /** BuddyPress ********************************************************/
    104123
    105         // Avoid syntactical errors
    106         $component_id = $this->id;
    107 
    108124        // Register this component in the active components array
    109         $bp->active_components[$bp->$component_id->slug] = $this->id;
    110 
    111         // Notifications callback
    112         $bp->$component_id->notification_callback = apply_filters( 'bp_' . $this->id . '_format_notifications', 'bp_' . $this->id . '_format_notifications' );
     125        $bp->active_components[$this->slug] = $this->id;
     126
     127        // Call action
     128        do_action( 'bp_' . $this->id . '_setup_globals' );
    113129    }
    114130
     
    121137     * @uses do_action() Calls 'bp_{@link bp_Component::name}_includes'
    122138     */
    123     function _includes() {
     139    function _includes( $includes = '' ) {
     140        if ( empty( $includes ) )
     141            return;
     142
     143        // Loop through files to be included
     144        foreach ( $includes as $file ) {
     145
     146            // Check path + file
     147            if ( file_exists( $this->path . '/' . $file ) )
     148                require_once( $this->path . '/' . $file );
     149
     150            // Check path + /bp-component/ + file
     151            elseif ( file_exists( $this->path . '/bp-' . $this->id . '/' . $file ) )
     152                require_once( $this->$path . '/bp-' . $this->id . '/' . $file );
     153
     154            // Check buddypress/bp-component/bp-component-$file.php
     155            elseif ( file_exists( $this->path . '/bp-' . $this->id . '/bp-' . $this->id . '-' . $file  . '.php' ) )
     156                require_once( $this->path . '/bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php' );
     157
     158        }
     159
     160        // Call action
    124161        do_action( 'bp_' . $this->id . '_includes' );
    125162    }
     
    145182
    146183        // Register post types
     184        add_action( 'bp_setup_title',              array ( $this, '_setup_title'             ), 10 );
     185
     186        // Register post types
    147187        add_action( 'bp_register_post_types',      array ( $this, 'register_post_types'      ), 10 );
    148188
     
    161201
    162202    /**
     203     * Setup the navigation
     204     *
     205     * @param arr $main_nav
     206     * @param arr $sub_nav
     207     */
     208    function _setup_nav( $main_nav, $sub_nav ) {
     209        bp_core_new_nav_item( $main_nav );
     210
     211        foreach( $sub_nav as $nav )
     212            bp_core_new_subnav_item( $nav );
     213
     214        // Call action
     215        do_action( 'bp_' . $this->id . '_setup_nav' );
     216    }
     217
     218
     219    function _setup_title( ) {
     220       
     221    }
     222
     223    /**
    163224     * Setup the component post types
    164225     *
     
    204265    }
    205266}
    206 endif; // bp_Component
     267endif; // BP_Component
     268
     269?>
Note: See TracChangeset for help on using the changeset viewer.