Skip to:
Content

bbPress.org

Changeset 3830


Ignore:
Timestamp:
04/02/2012 06:15:44 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Introduce theme packages API for bbPress 2.1

  • Allow multiple theme packages to be registered (primarily as plugins)
  • Allow switching between theme packages on the fly
  • Register bbp-theme-compat and bbp-twentyten as available theme packages
  • Introduce new 'bbp_register_theme_packages' action, and supplemental functions
  • Introduce new option for saving the current theme package
  • Code and variable clean-up in related files
  • Fixes #1801
  • Fixes #1802
Location:
branches/plugin
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-admin/bbp-admin.php

    r3816 r3830  
    192192            __( 'Converter', 'bbpress' ),
    193193            'manage_options',
    194             'bbpress',
     194            'bbp-converter',
    195195            'bbp_converter_settings'
    196196        );
     
    289289        add_settings_field( '_bbp_use_autoembed', __( 'Auto-embed Links', 'bbpress' ), 'bbp_admin_setting_callback_use_autoembed', 'bbpress', 'bbp_main' );
    290290        register_setting  ( 'bbpress',           '_bbp_use_autoembed',                 'intval'                                                          );
     291
     292        /** Theme Packages ****************************************************/
     293
     294        // Add the per page section
     295        add_settings_section( 'bbp_theme_compat',    __( 'Theme Packages',  'bbpress' ), 'bbp_admin_setting_callback_subtheme_section', 'bbpress'                     );
     296
     297        // Replies per page setting
     298        add_settings_field( '_bbp_theme_package_id', __( 'Current Package', 'bbpress' ), 'bbp_admin_setting_callback_subtheme_id',      'bbpress', 'bbp_theme_compat' );
     299        register_setting  ( 'bbpress',               '_bbp_theme_package_id',            ''                                                                           );
    291300
    292301        /** Per Page Section **************************************************/
  • branches/plugin/bbp-admin/bbp-settings.php

    r3816 r3830  
    152152
    153153<?php
     154}
     155
     156/**
     157 * Main subtheme section
     158 *
     159 * @since bbPress (r2786)
     160 */
     161function bbp_admin_setting_callback_subtheme_section() {
     162?>
     163
     164    <p><?php _e( 'How your forum content is displayed within your existing theme.', 'bbpress' ); ?></p>
     165
     166<?php   
     167}
     168
     169/**
     170 * Use the WordPress editor setting field
     171 *
     172 * @since bbPress (r3586)
     173 *
     174 * @uses checked() To display the checked attribute
     175 */
     176function bbp_admin_setting_callback_subtheme_id() {
     177
     178    // Declare locale variable
     179    $theme_options   = '';
     180    $current_package = bbp_get_theme_package_id( 'default' );
     181
     182    // Note: This should never be empty. /bbp-includes/bbp-theme-compat/ is the
     183    // canonical backup if no other packages exist. If there's an error here,
     184    // something else is wrong.
     185    //
     186    // @see bbPress::register_theme_packages()
     187    foreach ( (array) bbpress()->theme_compat->packages as $id => $theme ) {
     188        $theme_options .= '<option value="' . esc_attr( $id ) . '"' . selected( $theme->id, $current_package, false ) . '>' . sprintf( __( '%1$s - %2$s', 'bbpress' ), esc_html( $theme->name ), esc_html( str_replace( WP_CONTENT_DIR, '', $theme->dir ) ) )  . '</option>';
     189    }
     190
     191    if ( !empty( $theme_options ) ) : ?>
     192
     193        <select name="_bbp_theme_package_id" id="_bbp_theme_package_id" /><?php echo $theme_options ?></select>
     194        <label for="_bbp_theme_package_id"><?php _e( 'will serve all bbPress templates', 'bbpress' ); ?></label>
     195
     196    <?php else : ?>
     197
     198        <select name="_bbp_theme_package_id" id="_bbp_theme_package_id" /><?php echo $theme_options ?></select>
     199        <label for="_bbp_theme_package_id"><?php _e( 'Use the fancy WordPress editor to create and edit topics and replies', 'bbpress' ); ?></label>
     200
     201    <?php endif;
    154202}
    155203
  • branches/plugin/bbp-includes/bbp-common-functions.php

    r3806 r3830  
    15201520                case bbp_get_forum_post_type() :
    15211521
    1522                     // Declare local variable(s)
     1522                    // Define local variable(s)
    15231523                    $meta_query = array();
    15241524
  • branches/plugin/bbp-includes/bbp-core-actions.php

    r3784 r3830  
    6666add_action( 'bbp_loaded', 'bbp_setup_globals',            8  );
    6767add_action( 'bbp_loaded', 'bbp_register_theme_directory', 10 );
     68add_action( 'bbp_loaded', 'bbp_register_theme_packages',  12 );
    6869
    6970/**
     
    251252 *
    252253 * @since bbPress (r3395)
    253  *
    254254 * @return If BuddyPress is not active
    255255 */
     
    291291 *
    292292 * @since bbPress (r2509)
    293  *
    294293 * @uses register_uninstall_hook() To register our own uninstall hook
    295294 * @uses do_action() Calls 'bbp_activation' hook
     
    303302 *
    304303 * @since bbPress (r2509)
    305  *
    306304 * @uses do_action() Calls 'bbp_deactivation' hook
    307305 */
     
    314312 *
    315313 * @since bbPress (r2509)
    316  *
    317314 * @uses do_action() Calls 'bbp_uninstall' hook
    318315 */
     
    327324 *
    328325 * @since bbPress (r2599)
    329  *
    330326 * @uses do_action() Calls 'bbp_loaded'
    331327 */
     
    338334 *
    339335 * @since bbPress (r2599)
    340  *
    341336 * @uses do_action() Calls 'bbp_constants'
    342337 */
     
    349344 *
    350345 * @since bbPress (r2599)
    351  *
    352346 * @uses do_action() Calls 'bbp_boot_strap_globals'
    353347 */
     
    360354 *
    361355 * @since bbPress (r2599)
    362  *
    363356 * @uses do_action() Calls 'bbp_includes'
    364357 */
     
    371364 *
    372365 * @since bbPress (r2599)
    373  *
    374366 * @uses do_action() Calls 'bbp_setup_globals'
    375367 */
     
    382374 *
    383375 * @since bbPress (r2599)
    384  *
    385376 * @uses do_action() Calls 'bbp_init'
    386377 */
     
    393384 *
    394385 * @since bbPress (r3389)
    395  *
    396386 * @uses do_action() Calls 'bbp_widgets_init'
    397387 */
     
    404394 *
    405395 * @since bbPress (r2695)
    406  *
    407396 * @uses do_action() Calls 'bbp_setup_current_user'
    408397 */
     
    417406 *
    418407 * @since bbPress (r2599)
    419  *
    420408 * @uses do_action() Calls 'bbp_load_textdomain'
    421409 */
     
    428416 *
    429417 * @since bbPress (r2507)
    430  *
    431418 * @uses do_action() Calls 'bbp_register_theme_directory'
    432419 */
     
    439426 *
    440427 * @since bbPress (r2464)
    441  *
    442428 * @uses do_action() Calls 'bbp_register_post_type'
    443429 */
     
    450436 *
    451437 * @since bbPress (r2727)
    452  *
    453438 * @uses do_action() Calls 'bbp_register_post_statuses'
    454439 */
     
    461446 *
    462447 * @since bbPress (r2464)
    463  *
    464448 * @uses do_action() Calls 'bbp_register_taxonomies'
    465449 */
     
    472456 *
    473457 * @since bbPress (r2789)
    474  *
    475458 * @uses do_action() Calls 'bbp_register_views'
    476459 */
     
    483466 *
    484467 * @since bbPress (r3373)
    485  *
    486468 * @uses do_action() Calls 'bbp_enqueue_scripts'
    487469 */
     
    494476 *
    495477 * @since bbPress (r2753)
    496  *
    497478 * @uses do_action() Calls 'bbp_add_rewrite_tags'
    498479 */
     
    507488 *
    508489 * @since bbPress (r2618)
    509  *
    510490 * @uses do_action() Calls 'bbp_ready'
    511491 */
     
    521501 *
    522502 * @since bbPress (r3605)
    523  *
    524503 * @uses do_action()
    525504 */
     
    533512 * The main action used for executing code before the theme has been setup
    534513 *
     514 * @since bbPress (r3829)
     515 * @uses do_action()
     516 */
     517function bbp_register_theme_packages() {
     518    do_action( 'bbp_register_theme_packages' );
     519}
     520
     521/**
     522 * The main action used for executing code before the theme has been setup
     523 *
    535524 * @since bbPress (r3732)
    536  *
    537525 * @uses do_action()
    538526 */
     
    545533 *
    546534 * @since bbPress (r3732)
    547  *
    548535 * @uses do_action()
    549536 */
  • branches/plugin/bbp-includes/bbp-core-options.php

    r3792 r3830  
    1515 *
    1616 * @since bbPress (r3421)
    17  *
    1817 * @return array Filtered option names and values
    1918 */
     
    5352        '_bbp_use_autoembed'        => false,
    5453
     54        // The ID for the current theme package
     55        '_bbp_theme_package_id'     => 'default',
     56
    5557        /** Per Page **********************************************************/
    5658
     
    159161 * This is non-destructive, so existing settings will not be overridden.
    160162 *
     163 * @since bbPress (r3421)
    161164 * @uses bbp_get_default_options() To get default options
    162165 * @uses add_option() Adds default options
     
    175178    do_action( 'bbp_add_options' );
    176179}
     180
    177181/**
    178182 * Delete default options
     
    181185 * This is destructive, so existing settings will be destroyed.
    182186 *
     187 * @since bbPress (r3421)
    183188 * @uses bbp_get_default_options() To get default options
    184189 * @uses delete_option() Removes default options
     
    203208 *
    204209 * @since bbPress (r3451)
    205  *
    206210 * @uses bbp_get_default_options() To get default options
    207211 * @uses add_filter() To add filters to 'pre_option_{$key}'
     
    226230 *
    227231 * @since bbPress (r3451)
    228  *
    229232 * @param bool $value Optional. Default value false
    230233 * @return mixed false if not overloaded, mixed if set
     
    253256 *
    254257 * @since bbPress (r2658)
    255  *
    256258 * @param $default bool Optional.Default value true
    257  *
    258259 * @uses get_option() To get the favorites option
    259260 * @return bool Is favorites enabled or not
     
    267268 *
    268269 * @since bbPress (r2658)
    269  *
    270270 * @param $default bool Optional.Default value true
    271  *
    272271 * @uses get_option() To get the subscriptions option
    273272 * @return bool Is subscription enabled or not
     
    281280 *
    282281 * @since bbPress (r3412)
    283  *
    284282 * @param $default bool Optional. Default value true
    285  *
    286283 * @uses get_option() To get the allow revisions
    287284 * @return bool Are revisions allowed?
     
    295292 *
    296293 * @since bbPress (r2659)
    297  *
    298294 * @param $default bool Optional. Default value
    299  *
    300295 * @uses get_option() To get the allow anonymous option
    301296 * @return bool Is anonymous posting allowed?
     
    309304 *
    310305 * @since bbPress (r3378)
    311  *
    312306 * @param $default bool Optional. Default value false
    313  *
    314307 * @uses get_option() To get the global access option
    315308 * @return bool Is global access allowed?
     
    323316 *
    324317 * @since bbPress (r3386)
    325  *
    326318 * @param $default bool Optional. Default value true
    327  *
    328319 * @uses get_option() To get the WP editor option
    329320 * @return bool Use WP editor?
     
    337328 *
    338329 * @since bbPress (r3752)
    339  *
    340330 * @param $default bool Optional. Default value true
    341  *
    342331 * @uses get_option() To get the oEmbed option
    343332 * @return bool Use oEmbed?
     
    348337
    349338/**
     339 * Get the current theme package ID
     340 *
     341 * @since bbPress (r3829)
     342 * @param $default string Optional. Default value 'default'
     343 * @uses get_option() To get the subtheme option
     344 * @return string ID of the subtheme
     345 */
     346function bbp_get_theme_package_id( $default = 'default' ) {
     347    return apply_filters( 'bbp_get_theme_package_id', get_option( '_bbp_theme_package_id', $default ) );
     348}
     349
     350/**
    350351 * Output the maximum length of a title
    351352 *
    352353 * @since bbPress (r3246)
    353  *
    354354 * @param $default bool Optional. Default value 80
    355355 */
     
    361361     *
    362362     * @since bbPress (r3246)
    363      *
    364363     * @param $default bool Optional. Default value 80
    365      *
    366364     * @uses get_option() To get the maximum title length
    367365     * @return int Is anonymous posting allowed?
     
    375373 *
    376374 * @since bbPress (r3575)
    377  *
    378375 * @param $default bool Optional. Default value
    379376 */
     
    385382     *
    386383     * @since bbPress (r3575)
    387      *
    388384     * @param $default bool Optional. Default value 0
    389      *
    390385     * @uses get_option() To get the maximum title length
    391386     * @return int Is anonymous posting allowed?
     
    399394 *
    400395 * @since bbPress (r3575)
    401  *
    402396 * @param $default bool Optional. Default value true
    403  *
    404397 * @uses get_option() To get the group forums option
    405398 * @return bool Is group forums enabled or not
     
    413406 *
    414407 * @since bbPress (r3575)
    415  *
    416408 * @param $default bool Optional. Default value true
    417  *
    418409 * @uses get_option() To get the Akismet option
    419410 * @return bool Is Akismet enabled or not
     
    536527 *
    537528 * @since bbPress (r3790)
    538  *
    539529 * @param $default string Optional. Default empty string
    540  *
    541530 * @uses get_option() To get the old bb-config.php location
    542531 * @return string The location of the bb-config.php file, if any
  • branches/plugin/bbp-includes/bbp-extend-akismet.php

    r3758 r3830  
    9191    public function check_post( $post_data ) {
    9292
    93         // Declare local variables
     93        // Define local variables
    9494        $user_data = array();
    9595        $post_permalink = '';
  • branches/plugin/bbp-includes/bbp-theme-compatibility.php

    r3783 r3830  
    3535 */
    3636class BBP_Theme_Compat {
     37
     38    /**
     39     * @var string ID of the theme (should be unique)
     40     */
     41    public $id = '';
    3742
    3843    /**
     
    6368 *
    6469 * @since bbPress (r3311)
    65  *
    6670 * @param BBP_Theme_Compat $theme
    6771 */
    6872function bbp_setup_theme_compat( $theme = '' ) {
    69     bbpress()->theme_compat->theme = $theme;
     73    $bbp = bbpress();
     74
     75    // Make sure theme package is available, set to default if not
     76    if ( ! isset( $bbp->theme_compat->packages[$theme] ) || ! is_a( $bbp->theme_compat->packages[$theme], 'BBP_Theme_Compat' ) ) {
     77        $theme = 'default';
     78    }
     79
     80    // Set the active theme compat theme
     81    $bbp->theme_compat->theme = $bbp->theme_compat->packages[$theme];
    7082}
    7183
     
    7789 *
    7890 * @since bbPress (r3506)
    79  *
     91 * @uses apply_filters()
     92 * @return string
     93 */
     94function bbp_get_theme_compat_id() {
     95    return apply_filters( 'bbp_get_theme_compat_id', bbpress()->theme_compat->theme->id );
     96}
     97
     98/**
     99 * Gets the name of the bbPress compatable theme used, in the event the
     100 * currently active WordPress theme does not explicitly support bbPress.
     101 * This can be filtered or set manually. Tricky theme authors can override the
     102 * default and include their own bbPress compatability layers for their themes.
     103 *
     104 * @since bbPress (r3506)
    80105 * @uses apply_filters()
    81106 * @return string
     
    92117 *
    93118 * @since bbPress (r3506)
    94  *
    95119 * @uses apply_filters()
    96120 * @return string
     
    107131 *
    108132 * @since bbPress (r3032)
    109  *
    110133 * @uses apply_filters()
    111134 * @return string
     
    122145 *
    123146 * @since bbPress (r3032)
    124  *
    125147 * @uses apply_filters()
    126148 * @return string
     
    134156 *
    135157 * @since bbPress (r3265)
    136  *
    137158 * @return bool
    138159 */
     
    150171 *
    151172 * @since bbPress (r3265)
    152  *
    153173 * @param bool $set
    154  *
    155174 * @return bool
    156175 */
     
    190209
    191210/**
     211 * Register a new bbPress theme package to the active theme packages array
     212 *
     213 * @since bbPress (r3829)
     214 * @param array $theme
     215 */
     216function bbp_register_theme_package( $theme = '', $override = true ) {
     217
     218    // Bail if no name or object passed is not a theme compat theme
     219    if ( ! is_a( $theme, 'BBP_Theme_Compat' ) )
     220        return;
     221
     222    // Load up bbPress
     223    $bbp = bbpress();
     224
     225    // Only override if the flag is set and notpreviously registered
     226    if ( ! empty( $bbp->theme_compat->packages[$theme->id] ) || ( true === $override ) ) {
     227        $bbp->theme_compat->packages[$theme->id] = $theme;
     228    }
     229}
     230
     231/**
    192232 * This fun little function fills up some WordPress globals with dummy data to
    193233 * stop your average page template from complaining about it missing.
    194234 *
    195235 * @since bbPress (r3108)
    196  *
    197236 * @global WP_Query $wp_query
    198237 * @global object $post
     
    247286
    248287    // Setup the dummy post object
     288    $wp_query->post                 = new stdClass;
    249289    $wp_query->post->ID             = $dummy['ID'];
    250290    $wp_query->post->post_title     = $dummy['post_title'];
     
    280320 *
    281321 * @since bbPress (r3032)
    282  *
    283322 * @param string $template
    284  *
    285323 * @uses bbp_is_single_user() To check if page is single user
    286324 * @uses bbp_get_single_user_template() To get user template
     
    498536 *
    499537 * @since bbPress (r3034)
    500  *
    501538 * @param string $content
    502539 * @return type
     
    749786 *
    750787 * @since bbPress (r2628)
    751  *
    752788 * @param string $redirect_url Redirect url
    753789 * @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks
     
    807843 *
    808844 * @since bbPress (r3251)
    809  *
    810845 * @global WP_filter $wp_filter
    811846 * @global array $merged_filters
    812  *
    813847 * @param string $tag
    814848 * @param int $priority
    815  *
    816849 * @return bool
    817850 */
     
    862895 *
    863896 * @since bbPress (r3251)
    864  *
    865897 * @global WP_filter $wp_filter
    866898 * @global array $merged_filters
    867  *
    868899 * @param string $tag
    869900 * @param int $priority
    870  *
    871901 * @return bool
    872902 */
     
    916946 *
    917947 * @since bbPress (r3589)
    918  *
    919948 * @param bool $open True if open, false if closed
    920949 * @param int $post_id ID of the post to check
  • branches/plugin/bbp-theme-compat/bbpress-functions.php

    r3782 r3830  
    1515
    1616if ( !class_exists( 'BBP_Default' ) ) :
    17 
    18 /**
    19  * Uncomment the line below if this is for a custom theme.
    20  */
    21 //add_theme_support( 'bbpress' );
    2217
    2318/**
     
    7267        // Use the default theme compat if current theme has not added support
    7368        if ( !current_theme_supports( 'bbpress' ) ) {
     69            $this->id      = bbp_get_theme_compat_id();
    7470            $this->name    = bbp_get_theme_compat_name();
    7571            $this->version = bbp_get_theme_compat_version();
     
    7975        // Theme supports bbPress, so set some smart defaults
    8076        } else {
    81             $this->name    = sprintf( __( '%s (bbPress)', 'bbpress' ), get_current_theme() ) ;
     77            $theme         = wp_get_theme();
     78            $this->id      = $theme->stylesheet;
     79            $this->name    = sprintf( __( '%s (bbPress)', 'bbpress' ), $theme->name ) ;
    8280            $this->version = bbp_get_version();
    8381            $this->dir     = trailingslashit( get_stylesheet_directory() );
    8482            $this->url     = trailingslashit( get_stylesheet_directory_uri() );
    8583        }
     84
     85        // Conditionally add theme support if needed
     86        if ( in_array( $this->id, array( get_template(), get_stylesheet() ) ) ) {
     87            add_theme_support( 'bbpress' );
     88        }
    8689    }
    8790
     
    97100    private function setup_actions() {
    98101
    99         // Enqueue theme CSS
    100         add_action( 'bbp_enqueue_scripts',      array( $this, 'enqueue_styles'        ) );
    101 
    102         // Enqueue theme JS
    103         add_action( 'bbp_enqueue_scripts',      array( $this, 'enqueue_scripts'       ) );
    104 
    105         // Enqueue theme script localization
    106         add_filter( 'bbp_enqueue_scripts',      array( $this, 'localize_topic_script' ) );
    107 
    108         // Output some extra JS in the <head>
    109         add_action( 'bbp_head',                 array( $this, 'head_scripts'          ) );
    110 
    111         // Handles the ajax favorite/unfavorite
    112         add_action( 'wp_ajax_dim-favorite',     array( $this, 'ajax_favorite'         ) );
    113 
    114         // Handles the ajax subscribe/unsubscribe
    115         add_action( 'wp_ajax_dim-subscription', array( $this, 'ajax_subscription'     ) );
     102        /** Scripts ***********************************************************/
     103
     104        add_action( 'bbp_enqueue_scripts',      array( $this, 'enqueue_styles'        ) ); // Enqueue theme CSS
     105        add_action( 'bbp_enqueue_scripts',      array( $this, 'enqueue_scripts'       ) ); // Enqueue theme JS
     106        add_filter( 'bbp_enqueue_scripts',      array( $this, 'localize_topic_script' ) ); // Enqueue theme script localization
     107        add_action( 'bbp_head',                 array( $this, 'head_scripts'          ) ); // Output some extra JS in the <head>
     108        add_action( 'wp_ajax_dim-favorite',     array( $this, 'ajax_favorite'         ) ); // Handles the ajax favorite/unfavorite
     109        add_action( 'wp_ajax_dim-subscription', array( $this, 'ajax_subscription'     ) ); // Handles the ajax subscribe/unsubscribe
    116110
    117111        /** Template Wrappers *************************************************/
    118112
    119         // Top wrapper HTML
    120         add_action( 'bbp_before_main_content', array( $this, 'before_main_content' ) );
    121 
    122         // Bottom wrapper HTML
    123         add_action( 'bbp_after_main_content',  array( $this, 'after_main_content'  ) );
     113        add_action( 'bbp_before_main_content',  array( $this, 'before_main_content'   ) ); // Top wrapper HTML
     114        add_action( 'bbp_after_main_content',   array( $this, 'after_main_content'    ) ); // Bottom wrapper HTML
    124115
    125116        /** Override **********************************************************/
  • branches/plugin/bbp-themes/bbp-twentyten/bbpress-functions.php

    r3821 r3830  
    1515
    1616if ( !class_exists( 'BBP_Twenty_Ten' ) ) :
    17 
    18 // Theme supports bbPress
    19 add_theme_support( 'bbpress' );
    2017
    2118/**
     
    5956     */
    6057    private function setup_globals() {
     58        $bbp           = bbpress();
     59        $this->id      = 'bbp-twentyten';
    6160        $this->name    = __( 'Twenty Ten (bbPress)', 'bbpress' ) ;
    6261        $this->version = bbp_get_version();
    63         $this->dir     = trailingslashit( get_stylesheet_directory() );
    64         $this->url     = trailingslashit( get_stylesheet_directory_uri() );
     62        $this->dir     = trailingslashit( $bbp->themes_dir . 'bbp-twentyten' );
     63        $this->url     = trailingslashit( $bbp->themes_url . 'bbp-twentyten' );
     64
     65        // Conditionally add theme support if needed
     66        if ( in_array( $this->id, array( get_template(), get_stylesheet() ) ) ) {
     67            add_theme_support( 'bbpress' );
     68        }
    6569    }
    6670
     
    7478     */
    7579    private function setup_actions() {
    76 
    77         // Enqueue theme CSS
    78         add_action( 'bbp_enqueue_scripts',      array( $this, 'enqueue_styles'        ) );
    79 
    80         // Enqueue theme JS
    81         add_action( 'bbp_enqueue_scripts',      array( $this, 'enqueue_scripts'       ) );
    82 
    83         // Enqueue theme script localization
    84         add_filter( 'bbp_enqueue_scripts',      array( $this, 'localize_topic_script' ) );
    85 
    86         // Output some extra JS in the <head>
    87         add_action( 'bbp_head',                 array( $this, 'head_scripts'          ) );
    88 
    89         // Handles the ajax favorite/unfavorite
    90         add_action( 'wp_ajax_dim-favorite',     array( $this, 'ajax_favorite'         ) );
    91 
    92         // Handles the ajax subscribe/unsubscribe
    93         add_action( 'wp_ajax_dim-subscription', array( $this, 'ajax_subscription'     ) );
     80        add_action( 'bbp_enqueue_scripts',      array( $this, 'enqueue_styles'        ) ); // Enqueue theme CSS
     81        add_action( 'bbp_enqueue_scripts',      array( $this, 'enqueue_scripts'       ) ); // Enqueue theme JS
     82        add_filter( 'bbp_enqueue_scripts',      array( $this, 'localize_topic_script' ) ); // Enqueue theme script localization
     83        add_action( 'bbp_head',                 array( $this, 'head_scripts'          ) ); // Output some extra JS in the <head>
     84        add_action( 'wp_ajax_dim-favorite',     array( $this, 'ajax_favorite'         ) ); // Handles the ajax favorite/unfavorite
     85        add_action( 'wp_ajax_dim-subscription', array( $this, 'ajax_subscription'     ) ); // Handles the ajax subscribe/unsubscribe
    9486    }
    9587
  • branches/plugin/bbpress.php

    r3827 r3830  
    250250     * @var string Theme to use for theme compatibility
    251251     */
    252     public $theme_compat = '';
     252    public $theme_compat;
    253253
    254254    /** Extensions ************************************************************/
     
    349349
    350350        // Themes
    351         $this->themes_dir = $this->plugin_dir . 'bbp-themes';
    352         $this->themes_url = $this->plugin_url . 'bbp-themes';
     351        $this->themes_dir = trailingslashit( $this->plugin_dir . 'bbp-themes' );
     352        $this->themes_url = trailingslashit( $this->plugin_url . 'bbp-themes' );
    353353
    354354        // Languages
    355         $this->lang_dir   = $this->plugin_dir . 'bbp-languages';
     355        $this->lang_dir   = trailingslashit( $this->plugin_dir . 'bbp-languages' );
    356356
    357357        /** Identifiers *******************************************************/
     
    395395        $this->tab_index         = apply_filters( 'bbp_default_tab_index', 100 );
    396396
     397        /** Theme Compat ******************************************************/
     398
     399        // Base theme compatibility class
     400        $this->theme_compat      = new stdClass();
     401
    397402        /** Cache *************************************************************/
    398403
     
    493498            'register_views',           // Register the views (no-replies)
    494499            'register_theme_directory', // Register the theme directory (bbp-themes)
     500            'register_theme_packages',  // Register bundled theme packages (bbp-theme-compat/bbp-themes)
    495501            'load_textdomain',          // Load textdomain (bbpress)
    496502            'add_rewrite_tags',         // Add rewrite tags (view|user|edit)
     
    509515
    510516    /**
     517     * Register bundled theme packages
     518     *
     519     * @since bbPress (r3829)
     520     */
     521    public function register_theme_packages() {
     522       
     523        /** Default Theme *****************************************************/
     524
     525        $theme          = new BBP_Theme_Compat();
     526        $theme->id      = 'default';
     527        $theme->name    = __( 'bbPress Default', 'bbpress' );
     528        $theme->version = bbp_get_version();
     529        $theme->dir     = trailingslashit( $this->plugin_dir . 'bbp-theme-compat' );
     530        $theme->url     = trailingslashit( $this->plugin_url . 'bbp-theme-compat' );
     531
     532        bbp_register_theme_package( $theme );
     533
     534        /** Default Theme *****************************************************/
     535
     536        $theme          = new BBP_Theme_Compat();
     537        $theme->id      = 'bbp-twentyten';
     538        $theme->name    = __( 'Twenty Ten (bbPress)', 'bbpress' ) ;
     539        $theme->version = bbp_get_version();
     540        $theme->dir     = trailingslashit( $this->themes_dir . 'bbp-twentyten' );
     541        $theme->url     = trailingslashit( $this->themes_url . 'bbp-twentyten' );
     542
     543        bbp_register_theme_package( $theme );
     544    }
     545
     546    /**
    511547     * Setup the default bbPress theme compatability location.
    512548     *
     
    515551    public function setup_theme() {
    516552
    517         // Bail early if theme_compat was set already by a plugin
    518         if ( !empty( $this->theme_compat ) )
     553        // Bail if something already has this under control
     554        if ( ! empty( $this->theme_compat->theme ) )
    519555            return;
    520556
    521         // Set the defaults
    522         $theme          = new BBP_Theme_Compat();
    523         $theme->name    = 'bbPress (Default)';
    524         $theme->version = bbp_get_version();
    525         $theme->dir     = trailingslashit( $this->plugin_dir . 'bbp-theme-compat' );
    526         $theme->url     = trailingslashit( $this->plugin_url . 'bbp-theme-compat' );
    527 
    528         bbp_setup_theme_compat( $theme );
     557        // Setup the theme package to use for compatibility
     558        bbp_setup_theme_compat( bbp_get_theme_package_id() );
    529559    }
    530560
     
    546576     */
    547577    public function load_textdomain() {
    548 
    549         // Default locale
    550         $locale = get_locale();
    551 
    552         // Traditional WordPress plugin locale filter
    553         $locale = apply_filters( 'plugin_locale',  $locale, 'bbpress' );
    554 
    555         // bbPress specific locale filter
    556         $locale = apply_filters( 'bbpress_locale', $locale );
    557 
    558         // Get mo file name
    559         $mofile = sprintf( 'bbpress-%s.mo', $locale );
     578        $locale = get_locale();                                          // Default locale
     579        $locale = apply_filters( 'plugin_locale',  $locale, 'bbpress' ); // Traditional WordPress plugin locale filter
     580        $locale = apply_filters( 'bbpress_locale', $locale );            // bbPress specific locale filter
     581        $mofile = sprintf( 'bbpress-%s.mo', $locale );                   // Get mo file name
    560582
    561583        // Setup paths to current locale file
    562         $mofile_local  = $this->lang_dir . '/' . $mofile;
     584        $mofile_local  = $this->lang_dir . $mofile;
    563585        $mofile_global = WP_LANG_DIR . '/bbpress/' . $mofile;
    564586
    565587        // Look in local /wp-content/plugins/bbpress/bbp-languages/ folder
    566         if ( file_exists( $mofile_local ) )
     588        if ( file_exists( $mofile_local ) ) {
    567589            return load_textdomain( 'bbpress', $mofile_local );
    568590
    569591        // Look in global /wp-content/languages/bbpress folder
    570         elseif ( file_exists( $mofile_global ) )
     592        } elseif ( file_exists( $mofile_global ) ) {
    571593            return load_textdomain( 'bbpress', $mofile_global );
     594        }
    572595
    573596        // Nothing found
     
    908931
    909932        // Topics with no replies
    910         $no_replies = apply_filters( 'bbp_register_view_no_replies', array(
    911             'meta_key'     => '_bbp_reply_count',
    912             'meta_value'   => 1,
    913             'meta_compare' => '<',
    914             'orderby'      => ''
     933        bbp_register_view(
     934            'no-replies',
     935            __( 'Topics with no replies', 'bbpress' ),
     936            apply_filters( 'bbp_register_view_no_replies', array(
     937                'meta_key'     => '_bbp_reply_count',
     938                'meta_value'   => 1,
     939                'meta_compare' => '<',
     940                'orderby'      => ''
     941            )
    915942        ) );
    916 
    917         bbp_register_view( 'no-replies', __( 'Topics with no replies', 'bbpress' ), $no_replies );
    918943    }
    919944
Note: See TracChangeset for help on using the changeset viewer.