Changeset 5183
- Timestamp:
- 11/25/2013 02:20:06 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/templates/default/bbpress-functions.php
r5172 r5183 45 45 * @uses BBP_Default::setup_actions() 46 46 */ 47 public function __construct() { 48 $this->setup_globals(); 47 public function __construct( $properties = array() ) { 48 49 parent::__construct( bbp_parse_args( $properties, array( 50 'id' => 'default', 51 'name' => __( 'bbPress Default', 'bbpress' ), 52 'version' => bbp_get_version(), 53 'dir' => trailingslashit( bbpress()->themes_dir . 'default' ), 54 'url' => trailingslashit( bbpress()->themes_url . 'default' ), 55 ), 'default_theme' ) ); 56 49 57 $this->setup_actions(); 50 }51 52 /**53 * Component global variables54 *55 * Note that this function is currently commented out in the constructor.56 * It will only be used if you copy this file into your current theme and57 * uncomment the line above.58 *59 * You'll want to customize the values in here, so they match whatever your60 * needs are.61 *62 * @since bbPress (r3732)63 * @access private64 */65 private function setup_globals() {66 $bbp = bbpress();67 $this->id = 'default';68 $this->name = __( 'bbPress Default', 'bbpress' );69 $this->version = bbp_get_version();70 $this->dir = trailingslashit( $bbp->themes_dir . 'default' );71 $this->url = trailingslashit( $bbp->themes_url . 'default' );72 58 } 73 59 … … 141 127 public function enqueue_styles() { 142 128 143 $styles = array( 'bbp-default' => 'css/bbpress.css' ); 144 145 if ( is_rtl() ) 146 $styles['bbp-default-rtl'] = 'css/bbpress-rtl.css'; 147 148 foreach ( $styles as $handle => $file ) { 149 150 // Check child theme 151 if ( file_exists( trailingslashit( get_stylesheet_directory() ) . $file ) ) { 152 $location = trailingslashit( get_stylesheet_directory_uri() ); 153 154 // Check parent theme 155 } elseif ( file_exists( trailingslashit( get_template_directory() ) . $file ) ) { 156 $location = trailingslashit( get_template_directory_uri() ); 157 158 // bbPress Theme Compatibility 159 } else { 160 $location = trailingslashit( $this->url ); 161 } 162 163 // Enqueue the bbPress styling 164 wp_enqueue_style( $handle, $location . $file, array(), $this->version, 'screen' ); 129 // Setup styles array 130 $styles = array(); 131 132 // LTR 133 $styles['bbp-default'] = array( 134 'file' => 'css/bbpress.css', 135 'dependencies' => array() 136 ); 137 138 // RTL helpers 139 if ( is_rtl() ) { 140 $styles['bbp-default-rtl'] = array( 141 'file' => 'css/bbpress-rtl.css', 142 'dependencies' => array( 'bbp-default' ) 143 ); 144 } 145 146 // Filter the scripts 147 $styles = apply_filters( 'bbp_default_styles', $styles ); 148 149 // Enqueue the styles 150 foreach ( $styles as $handle => $attributes ) { 151 bbp_enqueue_style( $handle, $attributes['file'], $attributes['dependencies'], $this->version, 'screen' ); 165 152 } 166 153 } … … 179 166 public function enqueue_scripts() { 180 167 168 // Setup scripts array 169 $scripts = array(); 170 181 171 // Always pull in jQuery for TinyMCE shortcode usage 182 172 if ( bbp_use_wp_editor() ) { 183 wp_enqueue_script( 'jquery' ); 184 wp_enqueue_script( 'bbpress-editor', $this->url . 'js/editor.js', array( 'jquery' ), $this->version ); 173 $scripts['bbpress-editor'] = array( 174 'file' => 'js/editor.js', 175 'dependencies' => array( 'jquery' ) 176 ); 185 177 } 186 178 187 179 // Forum-specific scripts 188 180 if ( bbp_is_single_forum() ) { 189 190 // Forum subscribe/unsubscribe 191 wp_enqueue_script( 'bbpress-forum', $this->url . 'js/forum.js', array( 'jquery' ), $this->version ); 181 $scripts['bbpress-forum'] = array( 182 'file' => 'js/forum.js', 183 'dependencies' => array( 'jquery' ) 184 ); 192 185 } 193 186 … … 196 189 197 190 // Topic favorite/unsubscribe 198 wp_enqueue_script( 'bbpress-topic', $this->url . 'js/topic.js', array( 'jquery' ), $this->version ); 191 $scripts['bbpress-topic'] = array( 192 'file' => 'js/topic.js', 193 'dependencies' => array( 'jquery' ) 194 ); 199 195 200 196 // Hierarchical replies 201 197 if ( bbp_thread_replies() ) { 202 wp_enqueue_script( 'bbpress-reply', $this->url . 'js/reply.js', array(), $this->version ); 198 $scripts['bbpress-reply'] = array( 199 'file' => 'js/reply.js', 200 'dependencies' => array( 'jquery' ) 201 ); 203 202 } 204 203 } … … 206 205 // User Profile edit 207 206 if ( bbp_is_single_user_edit() ) { 208 wp_enqueue_script( 'user-profile' ); 209 wp_enqueue_script( 'bbpress-user', $this->url . 'js/user.js', array(), $this->version ); 207 $scripts['bbpress-user'] = array( 208 'file' => 'js/user.js', 209 'dependencies' => array( 'user-query' ) 210 ); 211 } 212 213 // Filter the scripts 214 $scripts = apply_filters( 'bbp_default_scripts', $scripts ); 215 216 // Enqueue the scripts 217 foreach ( $scripts as $handle => $attributes ) { 218 bbp_enqueue_script( $handle, $attributes['file'], $attributes['dependencies'], $this->version, 'screen' ); 210 219 } 211 220 } … … 241 250 'subs_nonce' => wp_create_nonce( 'toggle-subscription_' . get_the_ID() ) 242 251 ) ); 243 252 244 253 // Single topic 245 254 } elseif ( bbp_is_single_topic() ) {
Note: See TracChangeset
for help on using the changeset viewer.