Skip to:
Content

bbPress.org


Ignore:
Timestamp:
08/07/2011 05:15:27 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Move bbp-twentyten JS and ajax into proper hook. Make topic.js aware that favorites can be disabled.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-themes/bbp-twentyten/functions.php

    r3374 r3389  
    3535function bbp_twentyten_enqueue_styles () {
    3636
     37    $version = 20110807;
     38
    3739    // Right to left
    3840    if ( is_rtl() ) {
    3941
    4042        // TwentyTen
    41         wp_enqueue_style( 'twentyten',     get_template_directory_uri() . '/style.css', '',          20100503, 'screen' );
    42         wp_enqueue_style( 'twentyten-rtl', get_template_directory_uri() . '/rtl.css',   'twentyten', 20100503, 'screen' );
     43        wp_enqueue_style( 'twentyten',     get_template_directory_uri() . '/style.css', '',          $version, 'screen' );
     44        wp_enqueue_style( 'twentyten-rtl', get_template_directory_uri() . '/rtl.css',   'twentyten', $version, 'screen' );
    4345
    4446        // bbPress specific
    45         wp_enqueue_style( 'bbp-twentyten-bbpress', get_stylesheet_directory_uri() . '/css/bbpress-rtl.css', 'twentyten-rtl', 20100503, 'screen' );
     47        wp_enqueue_style( 'bbp-twentyten-bbpress', get_stylesheet_directory_uri() . '/css/bbpress-rtl.css', 'twentyten-rtl', $version, 'screen' );
    4648
    4749    // Left to right
     
    4951
    5052        // TwentyTen
    51         wp_enqueue_style( 'twentyten', get_template_directory_uri() . '/style.css', '', 20100503, 'screen' );
     53        wp_enqueue_style( 'twentyten', get_template_directory_uri() . '/style.css', '', $version, 'screen' );
    5254
    5355        // bbPress specific
    54         wp_enqueue_style( 'bbp-twentyten-bbpress', get_stylesheet_directory_uri() . '/css/bbpress.css', 'twentyten', 20100503, 'screen' );
     56        wp_enqueue_style( 'bbp-twentyten-bbpress', get_stylesheet_directory_uri() . '/css/bbpress.css', 'twentyten', $version, 'screen' );
    5557    }
    5658}
     
    7072 */
    7173function bbp_twentyten_enqueue_scripts () {
     74
     75    $version = 20110807;
     76
    7277    if ( bbp_is_single_topic() )
    73         wp_enqueue_script( 'bbp_topic', get_stylesheet_directory_uri() . '/js/topic.js', array( 'wp-lists' ), '20101202' );
     78        wp_enqueue_script( 'bbp_topic', get_stylesheet_directory_uri() . '/js/topic.js', array( 'wp-lists' ), $version );
    7479
    7580    if ( bbp_is_single_user_edit() )
    7681        wp_enqueue_script( 'user-profile' );
    7782}
    78 add_action( 'bbp_setup_theme_compat', 'bbp_twentyten_enqueue_scripts' );
     83add_action( 'bbp_enqueue_scripts', 'bbp_twentyten_enqueue_scripts' );
    7984endif;
    8085
     
    139144        'currentUserId' => $user_id,
    140145        'topicId'       => bbp_get_topic_id(),
    141         'favoritesLink' => bbp_get_favorites_permalink( $user_id ),
    142         'isFav'         => (int) bbp_is_user_favorite( $user_id ),
    143         'favLinkYes'    => __( 'favorites',                                         'bbpress' ),
    144         'favLinkNo'     => __( '?',                                                 'bbpress' ),
    145         'favYes'        => __( 'This topic is one of your %favLinkYes% [%favDel%]', 'bbpress' ),
    146         'favNo'         => __( '%favAdd% (%favLinkNo%)',                            'bbpress' ),
    147         'favDel'        => __( '×',                                           'bbpress' ),
    148         'favAdd'        => __( 'Add this topic to your favorites',                  'bbpress' )
    149146    );
    150147
     148    // Favorites
     149    if ( bbp_is_favorites_active() ) {
     150        $localizations['favoritesActive'] = 1;
     151        $localizations['favoritesLink']   = bbp_get_favorites_permalink( $user_id );
     152        $localizations['isFav']           = (int) bbp_is_user_favorite( $user_id );
     153        $localizations['favLinkYes']      = __( 'favorites',                                         'bbpress' );
     154        $localizations['favLinkNo']       = __( '?',                                                 'bbpress' );
     155        $localizations['favYes']          = __( 'This topic is one of your %favLinkYes% [%favDel%]', 'bbpress' );
     156        $localizations['favNo']           = __( '%favAdd% (%favLinkNo%)',                            'bbpress' );
     157        $localizations['favDel']          = __( '×',                                           'bbpress' );
     158        $localizations['favAdd']          = __( 'Add this topic to your favorites',                  'bbpress' );
     159    } else {
     160        $localizations['favoritesActive'] = 0;
     161    }
     162
     163    // Subscriptions
    151164    if ( bbp_is_subscriptions_active() ) {
    152165        $localizations['subsActive']   = 1;
     
    161174    wp_localize_script( 'bbp_topic', 'bbpTopicJS', $localizations );
    162175}
    163 add_filter( 'bbp_setup_theme_compat', 'bbp_twentyten_topic_script_localization' );
     176add_filter( 'bbp_enqueue_scripts', 'bbp_twentyten_topic_script_localization' );
    164177endif;
    165178
Note: See TracChangeset for help on using the changeset viewer.