* @copyright 2007 Sphere
* @copyright 2007 Sam Bauers
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v2
* @version 0.2.1
**/
function bb_sphere_header()
{
$scope = bb_get_sphere_scope();
$sphereit = false;
if ($scope == 'first') {
global $page;
if ($page == 1) {
$sphereit = true;
}
} else {
$sphereit = true;
}
if ($sphereit) {
$r = '' . "\r\n";
$r .= '' . "\r\n";
echo $r;
}
}
function bb_sphere_get_sphereit_link()
{
$scope = bb_get_sphere_scope();
$sphereit = false;
if ($scope == 'first') {
global $page;
if ($page == 1) {
$sphereit = true;
}
} else {
$sphereit = true;
}
if ($sphereit) {
$link = get_topic_link();
$r = '
';
$r .= 'Sphere: Related Content';
$r .= "";
echo $r;
}
}
function bb_sphere_post($content)
{
$scope = bb_get_sphere_scope();
$sphereit = false;
if ($scope == 'first') {
global $bb_post;
if ($bb_post->post_position == 1) {
$sphereit = true;
}
} else {
$sphereit = true;
}
if ($sphereit) {
$r = '' . "\r\n";
$r .= $content . "\r\n";
$r .= '';
} else {
$r = $content;
}
return $r;
}
function bb_get_sphere_rc_wtype()
{
$wtype = bb_get_option('bb_sphere_rc_wtype');
if (!$wtype) {
$wtype = "wordpressorg";
}
return $wtype;
}
function bb_get_sphere_scope()
{
$scope = bb_get_option('bb_sphere_scope');
if (!$scope) {
$scope = 'all';
}
return $scope;
}
add_action('bb_head', 'bb_sphere_header');
add_action('topicmeta','bb_sphere_get_sphereit_link');
add_action('post_text','bb_sphere_post');
/**
* The admin pages below are handled outside of the class due to constraints
* in the architecture of the admin menu generation routine in bbPress
*/
// Don't bother with registering admin interface if not in admin (bbPress 0.9+ only)
if (defined('BB_IS_ADMIN') && !BB_IS_ADMIN) {
return;
}
// Add filters for the admin area
add_action('bb_admin_menu_generator', 'bb_sphere_admin_page_add');
add_action('bb_admin-header.php', 'bb_sphere_admin_page_process');
/**
* Adds in an item to the $bb_admin_submenu array
*
* @return void
* @author Sam Bauers
**/
function bb_sphere_admin_page_add()
{
if (function_exists('bb_admin_add_submenu')) { // Build 794+
bb_admin_add_submenu(__('Sphere related content'), 'use_keys', 'bb_sphere_admin_page');
} else {
global $bb_submenu;
$submenu = array(__('Sphere related content'), 'use_keys', 'bb_sphere_admin_page');
if (isset($bb_submenu['plugins.php'])) { // Build 740-793
$bb_submenu['plugins.php'][] = $submenu;
} else { // Build 277-739
$bb_submenu['site.php'][] = $submenu;
}
}
}
/**
* Writes an admin page for the plugin
*
* @return string
* @author Sam Bauers
**/
function bb_sphere_admin_page()
{
$inputs['wordpressorg'] = false;
$inputs['political_dem'] = false;
$inputs['political_rep'] = false;
$inputs['political_gen'] = false;
$wtype = bb_get_sphere_rc_wtype();
$inputs[$wtype] = ' checked="checked"';
$inputs['first'] = false;
$scope = bb_get_sphere_scope();
$inputs[$scope] = ' checked="checked"';
?>
Select the Sphere content plug-in you'd like to use on your forum.
If your forum is about technology, news, gossip, sports or any other topics, stick with the
CLASSIC Sphere plug-in. If your forum is about POLITICS, you may want to use a POLITICS plug-ins.