BuddyPress 默认主题

BuddyPress 默认主题

Codex Home → Legacy Docs → Archived Section: Theme Development → The BuddyPress Default Theme
The BuddyPress Default Theme

Archived file. Good up to BP 1.9 version. The BP Default theme will no longer be activated in new installations from BP 1.9 onwards and will be retired in the near future. http://bpdevel.wordpress.com/2013/11/13/the-future-of-the-bp-default-theme/

The BP Default theme bundled with the BuddyPress plugin is a theme framework which contains all the functionality of regular WordPress templates enhanced with BuddyPress template tags along with special templates, AJAX, JS, and CSS to render the basic components and features of BuddyPress.
Basic bp-default theme HTML Structure
bp-default theme files have the basic structure in common:

[HEADER] div#header
div#container

div#content

div.padder

[PAGE CONTENT]

div#sidebar

[SIDEBAR CONTENT]

[FOOTER] div#footer

To be more specific, the general theme structure is shown below:
?123456789101112131415161718192021222324252627282930313233343536373839404142434445// Start of header.php    

        

        

            

                

                                

            

        

         

     // End of header.php //Start of Template files         

                

                              

            

             

                

                 // login form, widgets, etc.             

            

     // End of Template files // Start of footer.php     

         

            paragraph    

     // End of footer.php

    插件兼容性 – BP 1.5

    插件兼容性 – BP 1.5

    Codex Home → Legacy Docs → Archived Section: Plugin Development → Plugin Compatibility – BP 1.5
    Plugin Compatibility – BP 1.5

    Archived file. Good up to BP 1.5 version

    This list is a community volunteer effort to check compatibility of the majority of publicly available BuddyPress plugins against BuddyPress 1.5. Even if a plugin is marked as not fully working, most plugins will eventually be updated by their authors, but please be patient. If you know of a plugin that works with BuddyPress 1.5, or doesn』t, please contribute to this forum discussion.
    If you』re a plugin author, the BuddyPress Media plugin team has put together a wiki showing developers how to make their plugin compatible with BuddyPress 1.5.
    PASS
    FAIL
    UNKNOWN

    安装向导 (v1.5)

    安装向导 (v1.5)

    Codex Home → Legacy Docs → Archived Section: Getting Started → Installation Wizard (v1.5)
    Installation Wizard (v1.5)

    Archived file. Good only up to BP 1.5 version

    After installing and activating BuddyPress, you will see an admin message with the link to the new BuddyPress Installation Wizard. Click on the "installation wizard" link.

    Step 1: Choose the BuddyPress Components you want in your installation.
    Click on "Save & Next" button.

    Step 2: Associate/Create Pages for your BuddyPress Components.
    Click on "Save & Next" button.

    Step 3: Choose Pretty Permalinks structure.
    Click on "Save & Next" button.

    Step 4: Choose theme to use for your BP install.
    Recommend using the bp-default theme to test drive all the BP features you activated. Click on "Save & Next" button.

    Step 5: Finish and Activate

    You now have the following tables in your database

    Proceed to Next Task
    Configure BuddyPress Components for BP 1.5

    bp_core_new_nav_default()

    bp_core_new_nav_default()

    Codex Home → Developer Resources → Function Examples → Core Component → bp_core_new_nav_default()
    bp_core_new_nav_default()

    This function changes the default subnav item of a parent item.
    Example:
    function change_settings_subnav() {
    $args = array(
    'parent_slug' => 'settings',
    'screen_function' => 'bp_core_screen_notification_settings',
    'subnav_slug' => 'notifications'
    );

    bp_core_new_nav_default($args);
    }
    add_action('bp_setup_nav', 'change_settings_subnav', 5);

    This changes the default subnav of the 「Settings」 nav item to 「Notifications」
    NOTE: The 5 priority flag is required
    Source File
    bp_core_new_nav_default() is located in bp-core/bp-core-buddybar.php

    安装兼容的主题

    安装兼容的主题

    Codex Home → Legacy Docs → Archived Section: Theme Development → Installing a Compatible Theme
    Installing a Compatible Theme

    Archived file. Good only up to BP 1.5 version

    After you activate BuddyPress, you』ll get this message under the header of the Plugins page:
    BuddyPress is ready. You'll need to activate a BuddyPress compatible theme to take advantage of all of the features. We've bundled a default theme, but you can always install some other compatible themes or upgrade your existing WordPress theme.
    Activate a BuddyPress compatible theme
    This link goes to your admin themes page where you can activate the bp-default theme to test drive the different BuddyPress components that you, as Super/Site Admin, chose to enable for your community.
    Note:
    If you want to modify or customize the bp-default theme, build a child theme instead to ensure that your revisions will not be overwritten when you upgrade BuddyPress.
    Install some other compatible themes
    This link goes to a special theme installation page listing all BuddyPress-compatible themes and child themes of the bp-default theme which have been accepted in the WordPress Themes repository and are ready to install and activate in your site.
    Notes:
    1. BuddyPress themes and bp-default child themes are also available at:

    https://wordpress.org/extend/themes/tags/buddypress
    https://buddypress.org/extend/themes/

    2. Make sure that the theme you want to install is compatible with the WordPress/BuddyPress versions you have activated in your installation.

    BP 1.1.3 compatible themes are not compatible with BP 1.2+ installations.
    New functions/features contained in WP 3.0 compatible themes will not work with WP/MU 2.9.2 installations

    Upgrade your existing WordPress theme
    This link goes to a new BuddyPress admin panel where you can automatically install the BP Template Pack plugin to integrate BuddyPress component templates into your active WordPress theme.
    https://codex.buddypress.org/extending-buddypress/wordpress-to-buddypress-theme/

    主题函数 (functions.php)

    主题函数 (functions.php)

    Codex Home → BuddyPress Theme Development → functions.php
    functions.php

    You』ve probably heard a lot of talk about a theme』s functions.php file on the BuddyPress forums or WordPress forums.
    So what is it?
    functions.php is a file in your theme』s folder where you can add a bunch of custom code hacks and modifications to your theme.
    When to use it
    functions.php is a sister file to bp-custom.php which may exist in your sites plugin folder. Both files perform a similar type of service, running snippets of code for a site. There are two primary differences in these files though, bp-custom.php runs from the plugins folder and is therefore independent of your theme so is useful for adding snippets that you require to interact with BP regardless of the theme in use also it runs at a specific point in the loading of BP that allows BP to acknowledge it』s instructions, functions.php on the other hand is tied to a specific theme so code in it is only run for that theme, changing themes means those snippets of code will no longer be run unless transfers to the other theme. Choosing which file you need to place your code in is largely a matter of choice, most bp code may be run from function.php and this file generally exists in theme folders already as it may be running WP functions so running your BP code in this file is the usual option and using suitable hooks to ensure your code runs at specific points in the BP process should allow most BP functions to execute but if those do not work or you want your code modifications to be available to any theme then run your code in bp-custom.php.
    Creating your file
    If you don』t have a file called functions.php in your theme』s folder, go ahead and create one by creating a blank file with the following:
    It』s important to note:
    that when running child themes, where the parent theme has a functions.php file and your child theme also has one that both files are loaded, the child theme file is checked first (in the same principle that WP manages template hierachy) but then the parent file is run, this is important because if your try and declare the same functions in both you will get a 『Cannot redeclare』 error.
    In difference with a normal php file, functions.php must begin with an opening php tag ().
    When you encounter a forum thread telling you to put a code snippet in your theme』s functions.php, now you』ll know what to do!
    ?12<?php// hacks and mods will go here

    开发者和设计师信息 BP 1.5

    开发者和设计师信息 BP 1.5

    Codex Home → Legacy Docs → Archived Section: Getting Started → Developer and Designer Information BP 1.5
    Developer and Designer Information BP 1.5

    Archived file. Good up to BP 1.5 version

    As with any release developers and designers may need extra information so here is a collection of links around the new release.
    BuddyPress 1.5.2 and WordPress 3.3
    Use wp_enqueue_scripts, not wp_print_styles, to enqueue scripts and styles for the frontend
    BuddyPress 1.5 and WordPress 3.2.1
    Plugin update information : Boone B Gorges
    Better Metadata wrappers : Boone B Gorges
    Accessing User metadata : Boone B Gorges
    Does your BuddyPress plugin or theme modify BP』s navigation menus? : Boone B Gorges
    Maintain Backward Compatibility with an abstraction file: Boone B Gorges
    Custom Post Types Comments and the Activity Stream in bp 1.5 : Boone B Gorges
    Manually modifying single group navigation in BuddyPres 1.5 : Boone B Gorges
    Fix your older plugin to be compatible with BP 1.5: BuddyPress Media Dev team
    Theme information:
    Member settings pages are blank
    BuddyPress 1.5 comes with brand-new templates so you can style your member settings pages.   However, if you』re using an older child theme, you will need to copy over these templates to your WP theme.
    To fix this problem, copy over the following folder:
    ?1/plugins/buddypress/bp-themes/bp-default/members/single/settings/
    directly to your WP theme』s folder.
    Member forum pages are blank
    BuddyPress 1.5 ships with a brand new member sub-nav item called 「Forums」 where members can find the topics they have started or replied to.
    Example:
    http://testbp.org/members/johnjamesjacoby/forums
    For this to function properly in older child themes, you』ll need to copy over the following files and folders:
    ?12/plugins/buddypress/bp-themes/bp-default/members/single/forums.php/plugins/buddypress/bp-themes/bp-default/members/single/forums/
    directly to your WP theme』s folder.
    You』ll also need to modify the following file in your WP theme:
    ?1/wp-content/themes/YOUR-THEME/members/single/home.php
    Open up /members/single/home.php in your editor and after:
    ?12    
    Add:
    ?12    
    Activity entries are missing the 「Delete」 button
    BuddyPress 1.5 changed the way the 「Delete」 button is rendered in activity entry items.
    In older child themes, you will need to modify the activity entry template located in:
    ?1/wp-content/themes/YOUR-THEME/activity/entry.php
    Open up entry.php and add the following snippet:
    ?1
    Above or below:
    ?1
    Now you can delete activity entries again!
    Group avatar uploading doesn』t work
    BuddyPress 1.5 changed a bit of code in the group creation template that broke compatibility with older themes.
    For compatibility, you will need to modify the group creation template located in:
    ?1/wp-content/themes/YOUR-THEME/groups/create.php
    Open up create.php and find the following snippet:
    ?1
    And replace it with:
    ?1
    You should now be able to upload group avatars again!
    Avatar uploading doesn』t work on the registration page
    In BuddyPress 1.5, the ability to upload an avatar was removed from the registration page.
    In older child themes, you should remove a section of code in the registration template located in:
    ?1/wp-content/themes/YOUR-THEME/registration/register.php
    Open up register.php and remove the following block of code:
    ?1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950              

            

             

                        

             

                            <input type="submit" name="upload" id="upload" value="" />                        <input type="hidden" name="signup_email" id="signup_email" value="" />            <input type="hidden" name="signup_username" id="signup_username" value="" />        

                                

             <img src="" id="avatar-to-crop" class="avatar" alt="" />         

                <img src="" id="avatar-crop-preview" class="avatar" alt="" />        

             <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="" />         <input type="hidden" name="signup_email" id="signup_email" value="" />        <input type="hidden" name="signup_username" id="signup_username" value="" />        <input type="hidden" name="signup_avatar_dir" id="signup_avatar_dir" value="" />         <input type="hidden" name="image_src" id="image_src" value="" />                                               
    Stylesheet changes
    BuddyPress Default uses a function to enqueue it』s stylesheets in BuddyPress 1.5. Our 「Building a Child Theme」 codex article has been updated for BP 1.5 and reflects the information posted below.
    The function you want to be interested in is this:
    ?1234567891011121314151617181920if ( !function_exists( 'bp_dtheme_enqueue_styles' ) ) :/** * Enqueue theme CSS safely * * @see https://codex.wordpress.org/Function_Reference/wp_enqueue_style * @since 1.5 */function bp_dtheme_enqueue_styles() {    // Bump this when changes are made to bust cache    $version = '20110804';     // Default CSS    wp_enqueue_style( 'bp-default-main', get_template_directory_uri() . '/_inc/css/default.css', array(), $version );     // Right to left CSS    if ( is_rtl() )        wp_enqueue_style( 'bp-default-main-rtl',  get_template_directory_uri() . '/_inc/css/default-rtl.css', array( 'bp-default-main' ), $version );}add_action( 'wp_enqueue_scripts', 'bp_dtheme_enqueue_styles' );endif;
    All you need to do is declare that in your child theme as it has a check to see if exists it will then use your function so no need to deregister.
    In your functions.php declare the function like this:
    ?123456789101112function bp_dtheme_enqueue_styles() {    // Bump this when changes are made to bust cache    $version = '20110804';     // Default CSS    wp_enqueue_style( 'bp-default-main', get_template_directory_uri() . '/_inc/css/default.css', array(), $version );     // Right to left CSS    if ( is_rtl() )        wp_enqueue_style( 'bp-default-main-rtl',  get_template_directory_uri() . '/_inc/css/default-rtl.css', array( 'bp-default-main' ), $version );}add_action( 'wp_enqueue_scripts', 'bp_dtheme_enqueue_styles' );
    If you want no styles enqueued you can just call it empty like this:
    ?12345
    Alternatively if you anted to add in your own styles you can simply enqueue them after the default or even instead of the default.
    You can also do the same for scripting and other functions in the BuddyPress Default』s functions.php.
    BuddyPress Template Pack Tutorials for BP 1.5
    Twenty Eleven theme – https://codex.buddypress.org/theme-development/theme-dev-bp-template-pack-walkthrough-twenty-eleven-bp-1-5/ by mercime
    Twenty Ten Theme – https://codex.buddypress.org/theme-development/theme-dev-bp-template-pack-walkthrough-twenty-ten-bp-1-5/ by mercime

    建立子主题 (传统)

    建立子主题 (传统)

    Codex Home → Legacy Docs → Archived Section: Theme Development → The BuddyPress Default Theme → Building a Child Theme (Legacy)
    Building a Child Theme (Legacy)

    Archived file. Good up to BP 1.5 version

    Creating your own unique site design or theme is extremely simple to do, thanks to the Parent-Child functionality available in BuddyPress. This step-by-step guide will help you build your own custom theme. BuddyPress themes include more templates than your standard WordPress theme, However, these templates follow exactly the same structure as WordPress templates.
    Child Themes: What is the point? Why not just create a brand new theme?
    Building a child theme is the easiest and most future-proof way of building a BuddyPress theme. You can take advantage of an existing theme』s functionality, tweaking it to suit your own needs. By extending the default BuddyPress theme, you inherit all of the templates, JS, AJAX and if you wish, the CSS, all while preserving the core bp-default theme files. When new versions of BuddyPress are released with an updated default theme, your theme will automatically update along with it!
    You can override any Parent theme template simply by either (1) copying it into your child theme and tweaking it or (2) creating a new, 「same-name」 template file in your Child theme directory. You can also add your own CSS, JS and AJAX features. For more information about Child themes, please go to the WordPress Codex page.
    Let』s Start Building
    The default BuddyPress theme is not located in the usual /wp-content/themes/ directory. It is stored in the BuddyPress plugin folder so it can be updated along with the plugin. WordPress knows where it is, even though your own theme is in /wp-content/themes/.
    The first step is to create a new theme folder in /wp-content/themes/ and give it a unique name. For this example, the theme is called 「dusk」. In this new folder, create a file and call it 「style.css.」 This will be your child theme』s stylesheet.
    Open up 「style.css」 and add the following code to the header, replacing necessary details with your own.
    /*
    Theme Name: BuddyPress Dusk
    Theme URI: http://example.org/themes/dusk/
    Description: Dark theme for BuddyPress.
    Version: 1.0
    Author: John Doe
    Author URI: http://example.org/
    Template: bp-default
    Tags: buddypress, two-column, grey, dark
    */

    Note the 「Template:」 entry, which tells WordPress that we want to use the BuddyPress default theme (bp-default) as the parent theme, and inherit all templates from it. You』ll also notice the 「Tags:」 line and the tag 「buddypress」. This will tell BuddyPress that you are using a BuddyPress capable theme so it won』t nag you in the admin area.
    Save the file, and at this point, let』s activate the new theme. In the WordPress admin area, 「Appearance」 menu, you should see your new theme in the list of themes (if you don』t see it, and you』re using WordPress MU, make sure you』ve enabled the theme in 「Site Admin > Themes」). Go ahead and activate the new theme.
    Check your site home page. You』ll notice that there is no design at all. It』s just text on a white page, possibly with a mangled header image. This is great, exactly what we want. This means your new child theme is working correctly and inheriting all of the template files. If you click around the site you』ll notice it still works, just with no design.
    Inheriting CSS
    At this point you have an important decision to make, you can start writing your own CSS from scratch, or you can inherit the default theme』s CSS and work from there. If you』re going to make a radically new theme design, you might want to start with a fresh slate. However, if you simply want to change the color scheme, and perhaps alter the layout a bit, I would highly recommend inheriting the CSS.
    If you decide to inherit the CSS, you will need to add the following lines to your 「style.css」 file (below the comment header):
    /* Inherit the default theme styles */
    @import url( ../../plugins/buddypress/bp-themes/bp-default/_inc/css/default.css );
    /* Inherit the default theme adminbar styles */
    @import url( ../../plugins/buddypress/bp-themes/bp-default/_inc/css/adminbar.css );

    Once you』ve added these lines, try reloading your home page again. You』ll notice that the design has gone back to the design of the default theme. This is perfect, you can now start making design adjustments in your own theme by adding your own CSS styles below this line. If you』ve decided to not inherit the CSS, then you can just start adding your own styles right below the header comment.
    Overriding and Adding Template Files
    By default your child theme will inherit all the template files in the default theme. What if you wanted to change some of the HTML though? Most design and layout changes can be done in the CSS, but if you really need to change some of the structure then you can override template files.
    As an example let』s override the header.php template file. The first step is to head to the BuddyPress plugin folder (usually /wp-content/plugins/buddypress/) and then to the bp-themes/bp-default folder. In this folder you』ll see the header.php file, copy this file and paste it directly into your child theme』s folder (the same place as your style.css file). You can now make any edits to the HTML you wish and these will be reflected in your child theme. The header.php file in your child theme is essentially replacing the one in the parent.
    You can do this with any template file in the parent theme. However, if you want to override a template file that is in a sub folder, you must also recreate the sub folder in your child theme.
    functions.php
    There is one exception to the template override rule – functions.php. If you create a blank functions.php file in your child theme, the parent theme functions.php will still be loaded. This will allow you to inherit existing functions, but also add your own. You must make sure you give your child theme functions a unique name, otherwise they will clash with the parent.
    That is really all there is to creating child themes! I hope you found this guide useful, and remember that if you build your themes in this way, you are going to find upgrading BuddyPress much easier in the future.

    安装 BuddyPress 插件

    安装 BuddyPress 插件

    Codex Home → Getting Started → Customizing → Installing BuddyPress Plugins
    Installing BuddyPress Plugins

    Plugins which extend BuddyPress are available at:
    https://wordpress.org/extend/plugins/tags/buddypress
    https://buddypress.org/extend/plugins/
    Make sure that the plugin tagged as 「buddypress」 is compatible with the BP/WP version activated in your server. Note that some BuddyPress plugins require PHP 5+. Also note that when extending BuddyPress using various 3rd party plugins and themes acquired in the WordPress repo or elsewhere, it is advisable to check against other plugins and registration upon activating each individual plugin and/or theme. Reason being is that some plugins and themes do not always play well with certain BuddyPress plugins, themes and the registration. So by using a process of elimination by testing each plugin and theme individually you will avoid having to go through many plugins at one time trying to find the culprit that causes a conflict within your installation.
    [This article is still incomplete and will be expanded at a later time.]

    故障排除

    故障排除

    Codex Home → Getting Started → Troubleshooting
    Troubleshooting

    Please read the following and if your problem cannot be resolved then feel free to post in the support forums. Make sure that you include important troubleshooting information.

    Check error logs in server.
    Switch to a WordPress Default Theme like the Twenty Fourteen or Twenty Thirteen themes, etc. to rule out possible issue/s caused by your theme.
    Deactivate all plugins in your Plugins Activated panel except BuddyPress to see if that resolves the problem. Remember to deactivate plugins in the wp-content/mu-plugins folder as well as any custom /code in your wp-content/plugins/bp-custom.php in your server, if any. If the problem is resolved at any stage, reactivate plugins one at a time until you identify the plugin/s which caused the issuue.
    If you cannot access your wp-admin/dashboard, you can reset the plugins folder via FTP or phpMyAdmin.
    Clear server and/or browser caches.
    Download a fresh copy of the latest WordPress and BuddyPress versions and re-upload to server.

    For BP theme-related troubleshooting, go to https://buddypress.org/support/topic/basic-troubleshooting-tips/