Changeset 3917 for trunk/bp-core/bp-core-component.php
- Timestamp:
- 01/25/2011 08:58:56 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-component.php
r3751 r3917 34 34 35 35 /** 36 * @var string The path to the plugins files 37 */ 38 var $path; 39 40 /** 36 41 * @var WP_Query The loop for this component 37 42 */ … … 63 68 * @uses bp_Component::_setup_actions() Setup the hooks and actions 64 69 */ 65 function start( $id, $name ) {70 function start( $id, $name, $path ) { 66 71 // Internal identifier of component 67 72 $this->id = $id; … … 70 75 $this->name = $name; 71 76 72 $this->_setup_actions (); 77 // Path for includes 78 $this->path = $path; 79 80 // Move on to the next step 81 $this->_setup_actions(); 73 82 } 74 83 … … 90 99 91 100 $defaults = array( 92 'slug' => '', 93 'root_slug' => '' 101 'slug' => '', 102 'root_slug' => '', 103 'notification_callback' => '', 104 'global_tables' => '' 94 105 ); 95 106 $r = wp_parse_args( $args, $defaults ); … … 101 112 $this->root_slug = apply_filters( 'bp_' . $this->id . '_root_slug', $r['root_slug'] ); 102 113 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 103 122 /** BuddyPress ********************************************************/ 104 123 105 // Avoid syntactical errors106 $component_id = $this->id;107 108 124 // Register this component in the active components array 109 $bp->active_components[$ bp->$component_id->slug] = $this->id;110 111 // Notifications callback112 $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' ); 113 129 } 114 130 … … 121 137 * @uses do_action() Calls 'bp_{@link bp_Component::name}_includes' 122 138 */ 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 124 161 do_action( 'bp_' . $this->id . '_includes' ); 125 162 } … … 145 182 146 183 // Register post types 184 add_action( 'bp_setup_title', array ( $this, '_setup_title' ), 10 ); 185 186 // Register post types 147 187 add_action( 'bp_register_post_types', array ( $this, 'register_post_types' ), 10 ); 148 188 … … 161 201 162 202 /** 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 /** 163 224 * Setup the component post types 164 225 * … … 204 265 } 205 266 } 206 endif; // bp_Component 267 endif; // BP_Component 268 269 ?>
Note: See TracChangeset
for help on using the changeset viewer.