Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

Commit

Permalink
Add current_theme_supports('buddypress') and other changes.
Browse files Browse the repository at this point in the history
-Add bp-default check and current_theme_supports('buddypress') before TPack loads. Fixes #15.
-Add add_theme_support('buddypress') to bp_tpack_theme_setup().
-Move localization to loader.php
-Add missing @SInCE PHPDoc to bpt-admin.php.
  • Loading branch information
r-a-y committed Apr 24, 2012
1 parent f7c5a17 commit 5e5ea27
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
20 changes: 11 additions & 9 deletions bpt-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

/**
* When BPT is deactivated, remove a few options from the DB
*
* @since 1.0
*/
function bp_tpack_deactivate() {
/* Cleanup */
Expand All @@ -24,22 +26,18 @@ function bp_tpack_deactivate() {

/**
* Adds the BPT admin page under the "Themes" menu.
*
* @since 1.0
*/
function bp_tpack_add_theme_menu() {
add_theme_page( __( 'BP Compatibility', 'bp-tpack' ), __( 'BP Compatibility', 'bp-tpack' ), 'switch_themes', 'bp-tpack-options', 'bp_tpack_theme_menu' );
}
add_action( 'admin_menu', 'bp_tpack_add_theme_menu' );

/**
* Loads custom language file.
*/
function bp_tpack_load_language() {
load_plugin_textdomain( 'bp-tpack', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
}
add_action( 'plugins_loaded', 'bp_tpack_load_language', 9 );

/**
* Adds an admin notice if BPT hasn't been setup yet.
*
* @since 1.1
*/
function bp_tpack_admin_notices() {
global $wp_version;
Expand Down Expand Up @@ -71,6 +69,8 @@ function bp_tpack_admin_notices() {

/**
* Output the BPT admin page
*
* @since 1.0
*/
function bp_tpack_theme_menu() {
if ( !empty( $_GET['finish'] ) )
Expand Down Expand Up @@ -328,6 +328,7 @@ function bp_tpack_theme_menu() {
* Function to copy over bp-default's main templates to the current WP theme
*
* @uses bp_tpack_recurse_copy()
* @since 1.0
*/
function bp_tpack_move_templates() {
$destination_dir = get_stylesheet_directory() . '/';
Expand All @@ -347,7 +348,7 @@ function bp_tpack_move_templates() {
* Removes the "you'll need to activate a BuddyPress-compatible theme" message from the admin when
* the plugin is up and running successfully
*
* @since 1.3
* @since 1.2
*/
function bp_tpack_remove_compatibility_message() {
global $bp;
Expand Down Expand Up @@ -377,6 +378,7 @@ function bp_tpack_remove_compatibility_message() {
* @param string $src Location of source directory to copy
* @param string $dst Location of destination directory where the copied files should reside
* @see bp_tpack_move_templates()
* @since 1.0
*/
function bp_tpack_recurse_copy( $src, $dst ) {
$dir = @opendir( $src );
Expand Down
9 changes: 4 additions & 5 deletions bpt-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;

// Check to make sure the active theme is not bp-default
if ( 'bp-default' == get_option( 'template' ) )
return;

/**
* Sets up WordPress theme for BuddyPress support.
*
Expand All @@ -28,7 +24,10 @@ function bp_tpack_theme_setup() {
if ( ! (int)get_option( 'bp_tpack_disable_js' ) || ! function_exists( 'bp_dtheme_ajax_querystring' ) )
require_once( BP_PLUGIN_DIR . '/bp-themes/bp-default/_inc/ajax.php' );

if ( !is_admin() ) {
// Let's tell BP that we support it!
add_theme_support( 'buddypress' );

if ( ! is_admin() ) {
// Register buttons for the relevant component templates
// Friends button
if ( bp_is_active( 'friends' ) )
Expand Down
21 changes: 21 additions & 0 deletions loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,34 @@

/**
* Initialize the plugin once BuddyPress has initialized.
*
* @since 1.1
*/
function bp_tpack_loader() {
// Check if the current theme supports BuddyPress or if the current theme is using bp-default
// If so, stop now!
if ( current_theme_supports( 'buddypress' ) || 'bp-default' == get_option( 'template' ) ) {
add_action( 'admin_notices', function() {
echo '<div class="error"><p>' . __( "Hey! It looks like your theme already supports BuddyPress! This means you don't need BP Template Pack. To get rid of this notice, deactivate the BuddyPress Template Pack plugin.", 'bp-tpack' ) . '</p></div>';
} );
return;
}

if ( is_admin() )
include( dirname( __FILE__ ) . '/bpt-admin.php' );

include( dirname( __FILE__ ) . '/bpt-functions.php' );
}
add_action( 'bp_include', 'bp_tpack_loader' );

/**
* Localize the plugin.
*
* @since 1.2
*/
function bp_tpack_load_language() {
load_plugin_textdomain( 'bp-tpack', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
}
add_action( 'plugins_loaded', 'bp_tpack_load_language' );

?>

3 comments on commit 5e5ea27

@boonebgorges
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thanks for this, Ray. Let me know when/if you want me to release a dot-dot upgrade. (You're welcome to do it yourself if you want, too)

@r-a-y
Copy link
Collaborator Author

@r-a-y r-a-y commented on 5e5ea27 May 4, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the next update, I want to refresh the instructions so it's a little bit more detailed.

We should emphasize that the plugin is not a "set-it-and-forget-it" plugin and that people with a little bit of HTML / CSS knowledge at the bare minimum should be playing around with this plugin.

I'll have a first pass at this in a bit, but what do you think?

@boonebgorges
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Don't want to make it sound too scary, but I think it may help with support requests if it's made clear that it may be plug-n-play.

Please sign in to comment.