Developer – bbPress Codex https://codex.bbpress.org Tue, 31 Jan 2017 23:00:39 +0000 en-US hourly 1 https://wordpress.org/?v=7.1-alpha-62259 Favorites & Subscriptions https://codex.bbpress.org/getting-started/installing-bbpress/upgrading-bbpress/favorites-subscriptions/ Tue, 31 Jan 2017 22:54:07 +0000 https://codex.bbpress.org/?page_id=4866 bbPress 2.6 changes the way favorites & subscriptions are stored in the database. This page explains why, and what steps you may need to take if the upgrade does not automatically trigger for you.

If an upgrade failed before completing, that’s OK. You can safely rerun the upgrade from Tools > Forums at anytime without destroying or duplicating data.

Caveat

For small forums with less than 10,000 users, bbPress will try to automatically migrate your favorites & subscriptions. If your forum has more than 10,000 users, bbPress knows it may take more resources than are available, and will skip the upgrade.

Explanation

All versions of bbPress previous to 2.6 stored favorites & subscriptions in wp_usermeta with 1 value for each user on each site. On multisite installations with many users, this results in inefficient database queries and many globally available rows that are never used in a global way.

bbPress 2.6 takes the approach of storing each individual favorite & subscription in the wp_postmeta database table. This allows for a few different improvements

  • It’s easier to query both ways – Subscriptions per User & Site, and Subscriptions per Topic
  • Fewer rows in wp_usermeta result in performance improvements unilaterally in WordPress & bbPress
  • Gathering user email addresses to send subscriptions to is now a very simple & fast database query

Manually Upgrade

If you’re one of the lucky few who need to manually upgrade your forums because you have more than 10,000 users, there are 3 bbPress functions in bbpress/includes/admin/tools.php that you will want to review:

  • bbp_admin_upgrade_user_forum_subscriptions()
  • bbp_admin_upgrade_user_topic_subscriptions()
  • bbp_admin_upgrade_user_favorites()

These 3 functions do the following:

  • Query wp_usermeta by meta_key for all users who have favorited or subscribed
  • Loop through each row, and split it into post IDs
  • Loop through each post ID, and add the user ID to it’s meta-data with the appropriate meta_key
  • If the number of items added matches the original, the pre-2.6 usermeta is deleted

You may want to do the following:

  • Increase the amount of memory made available to PHP, and your web-server software (Apache, Nginx, etc…)
  • Increase the physical memory of the server running these scripts
  • Increase the timeout length to allow these scripts a few minutes to run as-is
  • Modify the original query to limit user ID results to loop through. (Usually 1000 users at a time is a good number.)
  • Comment-out calls to add_post_meta() and delete_metadata_by_mid() to dry-run the tests

For added context, these are the same scripts & techniques the bbPress team employed to upgrade BuddyPress.org, bbPress.org, WordCamp.org, and WordPress.org. They work, and they work very well, but we understand moving data around is scary, and want you to feel prepared & comfortable with what’s happening under the hood.

]]>
bbp_setup_current_user was called incorrectly https://codex.bbpress.org/bbp_setup_current_user/was-called-incorrectly/ Wed, 22 Jul 2015 15:11:00 +0000 http://codex.bbpress.org/?page_id=4575 This debug notice is triggered when WP_DEBUG constant is defined to true and a plugin *other than* bbPress is attempting to access something pertaining to the current user before $wp->init() and/or the init action has fired in wp-settings.php. The notice is there to alert you that bbPress is being forced into a configuration that may cause other (potentially serious) access control issues that WordPress has no hooks to let properly bbPress circumvent or restore back to safe operating conditions.

Unfortunately, it’s difficult to ascertain from within bbPress exactly what other plugin causes this to happen, so bbp_setup_current_user comes up in the logs.

Also, there is no wp_set_current_user action; the wp_set_current_user() function was introduced in WordPress 2.0.3 and the set_current_user action remains for backwards compatibility.

See also:

  • #WP24169 regarding the Customizer also doing this wrong
  • #WP23106 regarding adding an action to allow plugins to reliably hook in and repair capabilities
  • The many bbPress Trac Tickets this WordPress load order issue has resulted in
]]>
bbp_setup_current_user https://codex.bbpress.org/bbp_setup_current_user/ Wed, 22 Jul 2015 15:05:57 +0000 http://codex.bbpress.org/?page_id=4573 The bbp_setup_current_user() function is hooked to WordPress’s set_current_user action. Internally, it only calls the bbp_setup_current_user action, which is used by bbPress to announce itself to third party plugins looking to hook into bbPress user functionality.

This is a bit of a hack, since plugin dependencies do not exist in WordPress proper, but it’s still an excellent way to target bbPress and create plugins specifically for it.

]]>
Upgrading bbPress https://codex.bbpress.org/getting-started/installing-bbpress/upgrading-bbpress/ Thu, 11 Dec 2014 23:07:35 +0000 http://codex.bbpress.org/?page_id=3990 This section is your guide to bbPress theme updates, by version release.

From time to time bbPress creates new functionality that requires templates and markup adjustments, adds new JavaScript scripting and perhaps requires CSS properties supporting these additions.

If your bbPress installation is a particularly custom one, that is, you have customized template files to your theme or child theme, maybe copied JS and CSS files as well and even running your own bbPress functions setup you will not necessarily inherit these new features, this section will list these changes grouped under version release numbering detailing just what template files, js, css you need to update in your theme.


Theme Updates for bbPress 2.6

Template updating guide

]]>
Themes https://codex.bbpress.org/themes/ Thu, 29 May 2014 04:05:18 +0000 http://codex.bbpress.org/?page_id=1729 Plugins https://codex.bbpress.org/plugins/ Thu, 29 May 2014 04:02:44 +0000 http://codex.bbpress.org/?page_id=283 bbPress uses its own internal actions to help aid in third-party plugin development, and to limit the amount of potential future code changes when updates to WordPress core occur. These internal actions can be thought of as “sub-actions” and allow you to add or re-order WordPress actions as necessary for plugins that depend on bbPress.

These actions exist to create the concept of ‘plugin dependencies’. They provide a safe way for plugins to execute code *only* when bbPress is installed and activated, without needing to do complicated guesswork.

bbPress is completely self-sufficient within WordPress. You can load it anywhere or in any order from any place.

]]>
README https://codex.bbpress.org/developer/readme/ Thu, 24 Apr 2014 05:56:18 +0000 http://codex.bbpress.org/?page_id=1680 # bbPress

bbPress is forum software with a twist from the creators of WordPress. Easily setup discussion forums inside your WordPress.org powered site.

Have you ever been frustrated with forum or bulletin board software that was slow, bloated and always got your server hacked? bbPress is focused on ease of integration, ease of use, web standards, and speed.

We’re keeping things as small and light as possible while still allowing for great add-on features through WordPress’s extensive plugin system. What does all that mean? bbPress is lean, mean, and ready to take on any job you throw at it.

## The new development repo

As part of bbPress 2.6 we have revamped our development workflow to streamline and automate many of the tasks that come up day-to-day.

* Validate and test i18n support and generating *pot* files for easy translation into other languages
* Generate RTL CSS for our international locales that use *right-to-left* text such as Arabic and Hebrew
* Compile bbPress’ admin themes SCSS into CSS
* Minimize CSS, RTL CSS and JavaScript files
* Validating our JavaScript files for errors and coding best practices
* PHPUnit testing framework for PHP integrated with Travis-CI

### The src directory

The `/src` directory is the bbPress core source. All of the existing bbPress core files have been moved into this directory. You’ll develop and test against this directory as usual, but the real power will come from using the rest of the tools in the repository. The contents are optimized for development, not production (this means uncompressed CSS and JavaScript files and uncompiled SCSS files).

### The tests directory

The `/tests` directory is where our PHPUnit tests are stored and makes testing a cinch, it also allows us to commit patches that include changes to both the source and the tests in a single commit.

### The root directory

The `/` direcory includes configuration files for our *build* tools, Travis CI and PHPUnit tests.

## Installing the tools

### Node.js

Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications.

Any of the following options will get Node.js installed for you:

* Visit [Node.js](http://nodejs.org/) and click on the *install* link to download Node.js
* If your a Mac user and have [Homebrew](http://brew.sh) installed `brew install node`
* If your a Windows user and have [Scoop](http://scoop.sh) installed `scoop install nodejs`

### Grunt

Grunt is a JavaScript task runner to automate the tasks outlined above.

First we need to install Grunt’s command line interface (CLI).

1. Open a command shell terminal *You may need to use sudo (for OSX, *nix, BSD etc) or run your command shell as Administrator (for Windows)*
2. Type the following into your command shell `npm install -g grunt-cli`

## Checking out the bbPress source

You can use SVN or Git to contribute to bbPress, the choice is yours. so first you need to get a copy of our source

Once you’ve made that choice checkout of clone our repo If you’re fixing a bug, start by checking out bbPress’ repository on your computer.

* `svn checkout https://bbpress.svn.wordpress.org/trunk`
* `git clone git://bbpress.git.wordpress.org/`
* `git clone https://github.com/bbpress/bbPress.git`

Note: Our GitHub mirror repo is *not* setup at this stage, soon, just not yet.

## Installing Node.js dependancies with Node Package Manager (NPM)

NPM is included with Node.js and to install the dependancies we need

* Open up your terminal/command shell, you no longer need use sudu/admin
* Change to the directory where you checked out the source eg. `cd ~/dev/bbpress`
* Type the following into your command shell `npm install`

## Creating the build

* Open up your terminal/command shell, again, you no longer need use sudu/admin
* Change to the directory where you checked out the source eg. `cd ~/dev/bbpress`
* Type the following into your command shell `grunt`

## Overview of the Grunt tasks we use

### Build tasks.
The default task `grunt` or `grunt build` runs the following tasks in order:

1. `clean:all` – Cleans and deletes the entire `/build` folder
2. `copy:files` – Copies all the required files to the `/build` folder
3. `colors` – Compiles our admin themes SCSS and copies the compile CSS to the `/build` folder
4. `cssjanus:core` – Compiles the default CSS to RTL CSS in the `/build` folder
5. `cssmin:ltr` – Minimizes the default LTR CSS in the `/build` folder
6. `cssmin:rtl` – Minimizes the RTL CSS in the `/build` folder
7. `uglify:core` – Minimizes the JavaScript files in the `/build` folder
8. `jsvalidate:build` – Validates the JavaScript files for errors and coding best practices
9. `makepot` – Generates the `bbpress.pot` file for translators

The build release task `grunt build-release` tasks prepares everything we need to release a new version of bbPress on WordPress.org. Again the following tasks are run in order:

1. `clean:all` – Cleans and deletes the entire `/build` folder
2. `copy:files` – Copies all the required files to the `/build` folder
3. `colors` – Compiles our admin themes SCSS and copies the compile CSS to the `/build` folder
4. `cssjanus:core` – Compiles the default CSS to RTL CSS in the `/build` folder
5. `cssmin:ltr` – Minimizes the default LTR CSS in the `/build` folder
6. `cssmin:rtl` – Minimizes the RTL CSS in the `/build` folder
7. `uglify:core` – Minimizes the JavaScript files in the `/build` folder
8. `jsvalidate:build` – Validates the JavaScript files for errors and coding best practices
9. `checktextdomain` – Validates all of bbPress i18n text domains for internationalization
10. `makepot` – Generates the `bbpress.pot` file for translators
11. `phpunit` – Runs the PHPUnit tests for single site and multisite WordPress installs
### Testing tasks.

* `grunt phpunit` – Runs PHPUnit tests, including the ajax and multisite tests.
* `grunt jstest` – Runs both our javascript tasks `grunt jsvalidate` and `grunt jshint`
### Color schemes task.

* `grunt colors` – Compiles our admin themes SCSS and copies the compile CSS to the `/build` folder

### Patch task.

* `grunt patch` – List, download and patch bbPress like a boss eg. `grunt patch:2452`

### Watch task

* `grunt watch` or `grunt watch:all` Watches for file changes in the `/src` directory and automatically copy the updated file to the `/build` directory with any minification or RTL tasks included if nessecsary

## Patch All the Things! Creating and Submitting Patches

### Bug Zapping

## Development Best Practices for Everyone

For best practices please refer to the information in the WordPress.org codex. You’ll find more information about [PHP](https://make.wordpress.org/core/handbook/coding-standards/php/), [HTML](https://make.wordpress.org/core/handbook/coding-standards/html/), [CSS](https://make.wordpress.org/core/handbook/coding-standards/css/) and [JavaScript](https://make.wordpress.org/core/handbook/coding-standards/javascript/) coding standards there.

]]>
Developer Resources https://codex.bbpress.org/developer/ Tue, 04 Feb 2014 22:26:13 +0000 http://codex.bbpress.org/?page_id=1361 The developer docs are here to help you understand how bbPress works and how you can extend it.

[under construction]

]]>
bbp_topic_author_link https://codex.bbpress.org/bbp_topic_author_link/ Sat, 04 Jan 2014 01:38:22 +0000 http://codex.bbpress.org/?page_id=1304 Description

The ‘bbp_topic_author_link’ function is used to display the current topic author’s user role, avatar and username linked to their profile

Where is it used

Templates: content-single-topic-lead.php

How to use it

<?php bbp_topic_author_link( $args ); ?>

$args (optional) – Accepts an array of arguments to configure display ( post_id, link_title, type, size, sep, show_role )

Uses bbp_get_topic_author_link()

Sample code example

<?php bbp_topic_author_link(); ?>

Displays the linked avatar and username for the current topic author

<?php bbp_topic_author_link( array( 'sep' => '<br />', 'show_role' => true ) ); ?>

Displays the current topic author and user role separated by an HTML <br /> element

<?php bbp_topic_author_link( array( 'sep' => '<br />', 'show_role' => true, 'size' => 32 ) ); ?>

Displays the current topic author and user role separated by an HTML <br /> element and sets their avatar to a size of 32px wide and 32px tall

<?php bbp_topic_author_link( array( 'sep' => '<br />', 'show_role' => false, 'type' => 'avatar' ) ); ?>

Displays only the current topic author user’s avatar without their display name or user role

<?php bbp_topic_author_link( array( 'sep' => '<br />', 'show_role' => false, 'type' => 'name' ) ); ?>

Displays only the current topic author user’s display name without their avatar or user role

Related

bbp_author_link()
bbp_reply_author_link()
bbp_show_lead_topic()

]]>
bbp_reply_author_link https://codex.bbpress.org/bbp_reply_author_link/ Sat, 04 Jan 2014 01:38:19 +0000 http://codex.bbpress.org/bbp_reply_author_link/ Description

The ‘bbp_reply_author_link’ function is used to display the current reply author’s user role, avatar and username linked to their profile

Where is it used

Templates: loop-single-reply.php loop-search-reply.php

How to use it

<?php bbp_reply_author_link( $args ); ?>

$args (optional) – Accepts an array of arguments to configure display ( post_id, link_title, type, size, sep, show_role )

Uses bbp_get_reply_author_link()

Sample code example

<?php bbp_reply_author_link(); ?>

Displays the linked avatar and username for the current reply author

<?php bbp_reply_author_link( array( 'sep' => '<br />', 'show_role' => true ) ); ?>

Displays the current reply author and user role separated by an HTML <br /> element

<?php bbp_reply_author_link( array( 'sep' => '<br />', 'show_role' => true, 'size' => 32 ) ); ?>

Displays the current reply author and user role separated by an HTML <br /> element and sets their avatar to a size of 32px wide and 32px tall

<?php bbp_reply_author_link( array( 'sep' => '<br />', 'show_role' => false, 'type' => 'avatar' ) ); ?>

Displays only the current reply author user’s avatar without their display name or user role

<?php bbp_reply_author_link( array( 'sep' => '<br />', 'show_role' => false, 'type' => 'name' ) ); ?>

Displays only the current reply author user’s display name without their avatar or user role

Related

bbp_author_link()
bbp_topic_author_link()

]]>