Skip to:
Content

BuddyPress.org

Changeset 2696


Ignore:
Timestamp:
02/12/2010 12:48:30 PM (15 years ago)
Author:
apeatling
Message:

Moving the firstname template function into the core so that template files are not tied to functions in functions.php of the default. Remove deprecated code and added to back compat plugin.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs.php

    r2695 r2696  
    131131
    132132    $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/';
    133 
    134     /* Add the subnav items to the blogs nav item */
    135     bp_core_new_subnav_item( array( 'name' => __( 'My Blogs', 'buddypress' ), 'slug' => 'my-blogs', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_my_blogs', 'position' => 10, 'item_css_id' => 'my-blogs-list' ) );
    136     bp_core_new_subnav_item( array( 'name' => __( 'Recent Posts', 'buddypress' ), 'slug' => 'recent-posts', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_recent_posts', 'position' => 20 ) );
    137     bp_core_new_subnav_item( array( 'name' => __( 'Recent Comments', 'buddypress' ), 'slug' => 'recent-comments', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_recent_comments', 'position' => 30 ) );
    138133
    139134    /* Set up the component options navigation for Blog */
  • trunk/bp-core/bp-core-templatetags.php

    r2695 r2696  
    685685        return apply_filters( 'bp_last_activity', $last_activity );
    686686}
     687
     688function bp_user_firstname() {
     689    echo bp_get_user_firstname();
     690}
     691    function bp_get_user_firstname( $name = false ) {
     692        global $bp;
     693
     694        if ( !$name )
     695            $name = $bp->loggedin_user->fullname;
     696
     697        $fullname = (array)explode( ' ', $name );
     698
     699        return apply_filters( 'bp_get_user_firstname', $fullname[0], $fullname );
     700    }
    687701
    688702function bp_user_link() {
  • trunk/bp-themes/bp-default/activity/post-form.php

    r2692 r2696  
    1717    <h5>
    1818        <?php if ( bp_is_group() ) : ?>
    19             <?php printf( __( "What's new in %s, %s?", 'buddypress' ), bp_get_group_name(), bp_dtheme_firstname() ) ?>
     19            <?php printf( __( "What's new in %s, %s?", 'buddypress' ), bp_get_group_name(), bp_get_user_firstname() ) ?>
    2020        <?php else : ?>
    21             <?php printf( __( "What's new %s?", 'buddypress' ), bp_dtheme_firstname() ) ?>
     21            <?php printf( __( "What's new %s?", 'buddypress' ), bp_get_user_firstname() ) ?>
    2222        <?php endif; ?>
    2323    </h5>
  • trunk/bp-themes/bp-default/functions.php

    r2676 r2696  
    2222wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/_inc/global.js', array( 'jquery' ) );
    2323
    24 function bp_dtheme_firstname( $name = false, $echo = false ) {
    25     global $bp;
    26 
    27     if ( !$name )
    28         $name = $bp->loggedin_user->fullname;
    29 
    30     $fullname = (array)explode( ' ', $name );
    31     $firstname = apply_filters( 'bp_dtheme_firstname', $fullname[0], $fullname );
    32 
    33     if ( $echo )
    34         echo $firstname;
    35     else
    36         return $firstname;
    37 }
    38 
     24/* Add the JS needed for blog comment replies */
    3925function bp_dtheme_add_blog_comments_js() {
    4026    if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
     
    4228add_action( 'template_redirect', 'bp_dtheme_add_blog_comments_js' );
    4329
     30/* HTML for outputting blog comments as defined by the WP comment API */
    4431function bp_dtheme_blog_comments( $comment, $args, $depth ) {
    4532    $GLOBALS['comment'] = $comment; ?>
     
    8370}
    8471
     72/* Filter the dropdown for selecting the page to show on front to include "Activity Stream" */
    8573function bp_dtheme_wp_pages_filter( $page_html ) {
    8674    if ( 'page_on_front' != substr( $page_html, 14, 13 ) )
     
    9886add_filter( 'wp_dropdown_pages', 'bp_dtheme_wp_pages_filter' );
    9987
     88/* Hijack the saving of page on front setting to save the activity stream setting */
    10089function bp_dtheme_page_on_front_update( $oldvalue, $newvalue ) {
    10190    if ( !is_admin() || !is_site_admin() )
     
    10998add_action( 'pre_update_option_page_on_front', 'bp_dtheme_page_on_front_update', 10, 2 );
    11099
     100/* Load the activity stream template if settings allow */
    111101function bp_dtheme_page_on_front_template( $template ) {
    112102    global $wp_query;
     
    212202add_action( 'init', 'bp_dtheme_add_custom_header_support' );
    213203
    214 function bp_dtheme_remove_redundant() {
    215     global $bp;
    216 
    217     /* Remove the navigation options we do not need in this theme. */
    218     bp_core_remove_subnav_item( $bp->blogs->slug, 'my-blogs' );
    219     bp_core_remove_subnav_item( $bp->blogs->slug, 'recent-posts' );
    220     bp_core_remove_subnav_item( $bp->blogs->slug, 'recent-comments' );
    221 }
    222 add_action( 'init', 'bp_dtheme_remove_redundant' );
    223 
     204/* Show a notice to the user in wp-admin when the theme is activated */
    224205function bp_dtheme_show_notice() { ?>
    225206    <div id="message" class="updated fade">
     
    230211    <?php
    231212}
     213if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" )
     214    add_action( 'admin_notices', 'bp_dtheme_show_notice' );
    232215
    233216/* Add words that we need to use in JS to the end of the page so they can be translated and still used. */
     
    241224    var bp_terms_comments = '<?php _e( "comments", "buddypress" ) ?>';
    242225    var bp_terms_close = '<?php _e( "Close", "buddypress" ) ?>';
    243     var bp_terms_mention_explain = '<?php printf( __( "%s is a unique identifier for %s that you can type into any message on this site. %s will be sent a notification and a link to your message any time you use it.", "buddypress" ), '@' . bp_get_displayed_user_username(), bp_dtheme_firstname(bp_get_displayed_user_fullname()), bp_dtheme_firstname(bp_get_displayed_user_fullname()) ); ?>';
     226    var bp_terms_mention_explain = '<?php printf( __( "%s is a unique identifier for %s that you can type into any message on this site. %s will be sent a notification and a link to your message any time you use it.", "buddypress" ), '@' . bp_get_displayed_user_username(), bp_get_user_firstname(bp_get_displayed_user_fullname()), bp_get_user_firstname(bp_get_displayed_user_fullname()) ); ?>';
    244227    </script>
    245228<?php
     
    247230add_action( 'wp_footer', 'bp_dtheme_js_terms' );
    248231
    249 
    250 /* Show a notice when the theme is activated - workaround by Ozh (http://old.nabble.com/Activation-hook-exist-for-themes--td25211004.html) */
    251 if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) {
    252     add_action( 'admin_notices', 'bp_dtheme_show_notice' );
    253 }
    254 
    255 
    256232?>
Note: See TracChangeset for help on using the changeset viewer.