Plugin Directory

Changeset 637712


Ignore:
Timestamp:
12/12/2012 01:17:16 PM (13 years ago)
Author:
codebycarter
Message:

tagging version 1.1.0

Location:
wp-bulletin-board
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-bulletin-board/tags/1.1.0/css/wpbb-light-style.css

    r607181 r637712  
    11/*
    22    WPBB light style
    3    
    4     To be used on a light background, preferably white
    5    
    6     This only affects the front end as the back end implements wordpress styling.
    73*/
    84
     
    3026    font-weight:bold;
    3127    padding-bottom:10px;
     28}
     29
     30/* Change the forum title position and color of the slash (/) character here */
     31h2.wpbb-forum-title {
     32    text-align:center;
     33    padding-bottom:10px;
     34}
     35
     36/* Change the color of the forum title link here, boldness, etc */
     37h2.wpbb-forum-title a {
     38    font-weight:bold;
     39    color:purple;
    3240}
    3341
     
    184192    min-width: 500px;
    185193    white-space: pre-line;
     194    text-align:left;
    186195}
    187196
  • wp-bulletin-board/tags/1.1.0/php/facebook/wpbb-facebook.php

    r607181 r637712  
    99$user_id = get_current_user_id();
    1010
    11 if ($user_id !== 0) { // User is logged in
    12 
     11if ($user_id !== 0)
     12{
     13    // User is logged in
    1314    $user_access_token = get_user_meta($user_id, 'wpbb_facebook_access_token', true);
    14 
    15     if ($user_access_token != "" && is_user_logged_in()) { // User is logged into Facebook
    16    
     15    if ($user_access_token != "" && is_user_logged_in())
     16    {
     17        // User is logged into Facebook
    1718        $logged_into_facebook = true;
    18 
    19         if (count($_GET) == 0) {
     19        if (count($_GET) == 0)
     20        {
    2021        ?>
    2122        <div class="wpbb-centered">
     
    2526        <?php
    2627        }
    27    
    28     }
    29    
    30    
    31 } else { // User is not logged in
    32    
    33     // Registering for a Wordpress account through Facebook
     28    }
     29}
     30else
     31{
     32    /*
     33        User is not logged in
     34        Registering for a Wordpress account through Facebook
     35    */
    3436    if ((isset($_GET['register'])) && (isset($_GET['method'])) && (count($_GET) == 2)) {
    3537   
     
    130132                        <br />
    131133                        <div class="wpbb-centered">
    132                             <?php printf(__('Thankyou for logging in to Facebook, %s!'), $facebook_user['name']); ?>
     134                            <?php printf(__('Thank you for logging in to Facebook, %s!'), $facebook_user['name']); ?>
    133135                            <br /><br />
    134136                            <?php _e('Please now enter the password for your Wordpress account you registered using Facebook.', 'wp-bb'); ?><br /><br /><?php
     
    238240        <div class="wpbb-message-success">
    239241            <?php
    240             _e('Thankyou for registering. Please login with your Facebook username and password you just created', 'wp-bb');
     242            _e('Thank you for registering. Please login with your Facebook username and password you just created', 'wp-bb');
    241243            ?>
    242244        </div>
  • wp-bulletin-board/tags/1.1.0/php/twitter/wpbb-twitter.php

    r611368 r637712  
    55*/
    66
    7 if (count($_GET) == 0) {
     7if (count($_GET) == 0)
     8{
    89    ?>
    910    <div class="wpbb-centered">
  • wp-bulletin-board/tags/1.1.0/php/wpbb-forum.php

    r607181 r637712  
    44    Checks if the plugin is deactivated
    55*/
    6 
    76
    87// Since we're not in the admin area we must require the plugin.php file
     
    1817    <div style="text-align:center;font-weight:bold;color:red;">
    1918        <?php
    20             _e('The plugin is deactivated. Please reactivate the plugin to continue using WPBB', 'wp-bb');
     19            _e('The plugin is deactivated. Please reactivate the plugin to continue using WPBB or delete this page', 'wp-bb');
    2120            wpbb_exit();
    2221        ?>
     
    3534
    3635// Sets the default timezone used by all date/time functions in a script depending on server configuration option
    37 if (ini_get('date.timezone.')) {
     36if (ini_get('date.timezone.'))
     37{
    3838    $timezone = ini_get('date.timezone');
    3939    date_default_timezone_set($timezone);
     
    4848define('POST_TABLE', $wpdb->prefix.'wpbb_posts');
    4949define('MESSAGES_TABLE', $wpdb->prefix.'wpbb_messages');
     50define('UN_READ_TABLE', $wpdb->prefix.'wpbb_topics_unread');
    5051
    5152// The WP-BB plugin url on wordpress - only used if show footer option is set to yes
     
    5354
    5455
    55 function wpbb_exit() {
     56function wpbb_exit()
     57{
    5658    get_header();
    5759    get_footer();
     
    6365    && (!is_user_logged_in())
    6466    && (!isset($_GET['method']))
    65     && (!isset($_GET['state']))) {
    66     if ($wpbb_facebook_options['allow_facebook'] == 'yes') {
     67    && (!isset($_GET['state'])))
     68    {
     69    if ($wpbb_facebook_options['allow_facebook'] == 'yes')
     70    {
    6771        require_once('facebook/wpbb-facebook.php');
    6872    }
    69     require_once('wpbb-functions.php');
     73    require_once('functions.php');
    7074    ?>
    7175    <div class="wpbb-centered-bold">
     
    7781}
    7882
    79 if ($wpbb_options['maintenance_mode'] == 'on') {
    80     if (current_user_can('manage_options')) {
     83if ($wpbb_options['maintenance_mode'] == 'on')
     84{
     85    if (current_user_can('manage_options'))
     86    {
    8187        ?>
    8288        <div class="wpbb-message-warning">
     
    8490        </div>
    8591        <?php
    86     } else {
     92    }
     93    else
     94    {
    8795        ?>
    8896        <div class="wpbb-message-warning">
     
    9098        </div>
    9199        <?php
    92         if ($wpbb_facebook_options['allow_facebook'] == 'yes') {
     100        if ($wpbb_facebook_options['allow_facebook'] == 'yes')
     101        {
    93102            require_once('facebook/wpbb-facebook.php');
    94103        }
    95         require_once('wpbb-functions.php');
     104        require_once('functions.php');
    96105        wpbb_footer();
    97106        wpbb_exit();
     
    103112*/
    104113
    105 require_once('wpbb-functions.php');
    106 
    107 /* 
     114require_once('functions.php');
     115
     116/*
    108117    Checks a page supplied exists
    109118*/
     
    115124*/
    116125
    117 if ($wpbb_facebook_options['allow_facebook'] == 'yes') {
     126if ($wpbb_facebook_options['allow_facebook'] == 'yes')
     127{
    118128    require_once('facebook/wpbb-facebook.php');
    119129}
     
    126136$wpbb_twitter_options = get_option('wpbb_twitter_options');
    127137
    128 if ($wpbb_twitter_options['allow_twitter'] == 'yes') {
     138if ($wpbb_twitter_options['allow_twitter'] == 'yes')
     139{
    129140    require_once('twitter/wpbb-twitter.php');
    130141}
     
    138149*/
    139150
     151
    140152if (empty($permalink_options))
    141153{
    142     if (count($_GET) == 1) {
    143         require_once('wpbb-index.php');
    144     }
    145 
     154    if (count($_GET) == 1)
     155    {
     156        require_once('forum-index.php');
     157    }
    146158
    147159    /*
     
    152164        && (isset($_GET['current_page']))
    153165        && (count($_GET) == 3)) {
    154         require_once('wpbb-view-forum.php');
     166        require_once('view-forum.php');
    155167    }
    156168   
     
    165177        && (isset($_GET['current_page']))
    166178        && (count($_GET) == 4)) {
    167         require_once('wpbb-view-forum-topic.php');
    168     }
    169 
     179        require_once('view-forum-topic.php');
     180    }
    170181
    171182    /*
     
    177188        && (isset($_GET['forum']) && isset($_GET['subforum']))
    178189        && (count($_GET) == 4)) {
    179         require_once('wpbb-create-topic.php');
     190        require_once('create-topic.php');
    180191    }
    181192
     
    184195        && (isset($_GET['forum']))
    185196        && (count($_GET) == 3)) {
    186         require_once('wpbb-create-topic.php');
    187     }
    188 
     197        require_once('create-topic.php');
     198    }
    189199
    190200    /*
     
    197207        && (isset($_GET['current_page']))
    198208        && (count($_GET) == 4)) {
    199         require_once('wpbb-view-subforum.php');
     209        require_once('view-subforum.php');
    200210    }
    201211
     
    211221        && (isset($_GET['current_page']))
    212222        && (count($_GET) == 5)) {
    213         require_once('wpbb-view-subforum-topic.php');
     223        require_once('view-subforum-topic.php');
    214224    }
    215225
     
    221231        && (isset($_GET['page_id']))
    222232        && (count($_GET) == 2)) {
    223         require_once('wpbb-view-profile.php');
     233        require_once('view-profile.php');
    224234    }
    225235
     
    232242        && (isset($_GET['current_page']))
    233243        && (count($_GET) == 3)) {
    234         require_once('wpbb-all-messages.php');
     244        require_once('all-messages.php');
    235245    }
    236246   
     
    243253        && (isset($_GET['page_id']))
    244254        && (count($_GET) > 1 && count($_GET) <= 3)) {
    245         require_once('wpbb-delete-message.php');
     255        require_once('delete-message.php');
    246256    }
    247257
     
    255265        && ((isset($_GET['view'])) && ($_GET['view']))
    256266        && (count($_GET) == 3)) {
    257         require_once('wpbb-view-message.php');
     267        require_once('view-message.php');
    258268    }
    259269
     
    265275        && (isset($_GET['page_id']))
    266276        && (count($_GET) == 2)) {
    267         require_once('wpbb-message-user.php');
     277        require_once('message-user.php');
    268278    }
    269279
     
    281291        && ($_GET['action'] != 'reply')
    282292        && ($_GET['action'] != 'sticky')))) {
    283         require_once('wpbb-edit-topic.php');
     293        require_once('edit-topic.php');
    284294    }
    285295
     
    297307        && ($_GET['action'] != 'reply')
    298308        && ($_GET['action'] != 'sticky')))) {
    299         require_once('wpbb-lock-topic.php');
     309        require_once('lock-topic.php');
    300310    }
    301311
     
    313323        && ($_GET['action'] != 'reply')
    314324        && ($_GET['action'] != 'edit')))) {
    315         require_once('wpbb-sticky-topic.php');
     325        require_once('sticky-topic.php');
    316326    }
    317327
     
    329339        && ($_GET['action'] != 'reply')
    330340        && ($_GET['action'] != 'sticky')))) {
    331         require_once('wpbb-delete-topic.php');
     341        require_once('delete-topic.php');
    332342    }
    333343
     
    346356        && ($_GET['action'] != 'reply')
    347357        && ($_GET['action'] != 'sticky')))) {
    348         require_once('wpbb-markread-topic.php');
     358        require_once('markread-topic.php');
    349359    }
    350360
     
    363373        && ($_GET['action'] != 'edit')
    364374        && ($_GET['action'] != 'sticky')))) {
    365         require_once('wpbb-reply-topic.php');
     375        require_once('reply-topic.php');
    366376    }
    367377
     
    375385        && (isset($_GET['current_page']))
    376386        && (count($_GET) == 3)) {
    377         require_once('wpbb-unread-topics.php');
     387        require_once('unread-topics.php');
    378388    }
    379389
     
    387397        && (isset($_GET['current_page']))
    388398        && (count($_GET) == 3)) {
    389         require_once('wpbb-unanswered-topics.php');
     399        require_once('unanswered-topics.php');
    390400    }
    391401   
    392402    // Not default or custom structure
    393403
    394 } else {
    395 
    396     if (count($_GET) == 0) {
    397         require_once('wpbb-index.php');
     404}
     405else
     406{
     407    if (count($_GET) == 0)
     408    {
     409        require_once('forum-index.php');
    398410    }
    399411
     
    405417        && (isset($_GET['current_page']))
    406418        && (count($_GET) == 2)) {
    407         require_once('wpbb-view-forum.php');
    408     }
    409 
    410 
    411 
     419        require_once('view-forum.php');
     420    }
     421   
    412422    /*
    413423        Viewing A Forum Topic
     
    418428        && (isset($_GET['current_page']))
    419429        && (count($_GET) == 3)) {
    420         require_once('wpbb-view-forum-topic.php');
     430        require_once('view-forum-topic.php');
    421431    }
    422432
     
    429439        && (isset($_GET['forum']) && isset($_GET['subforum']) || isset($_GET['forum']) && !isset($_GET['subforum']))
    430440        && (count($_GET) == 2 || count($_GET) == 3)) {
    431             require_once('wpbb-create-topic.php');
     441            require_once('create-topic.php');
    432442    }
    433443
     
    440450        && (isset($_GET['current_page']))
    441451        && (count($_GET) == 3)) {
    442         require_once('wpbb-view-subforum.php');
     452        require_once('view-subforum.php');
    443453    }
    444454
     
    453463        && (isset($_GET['current_page']))
    454464        && (count($_GET) == 4)) {
    455         require_once('wpbb-view-subforum-topic.php');
     465        require_once('view-subforum-topic.php');
    456466    }
    457467
     
    462472    if ((isset($_GET['profile']))
    463473        && (count($_GET) == 1)) {
    464         require_once('wpbb-view-profile.php');
     474        require_once('view-profile.php');
    465475    }
    466476
     
    474484        && (isset($_GET['current_page']))
    475485        && (count($_GET) == 2 || count($_GET) == 3)) {
    476         require_once('wpbb-all-messages.php');
     486        require_once('all-messages.php');
    477487    }
    478488   
     
    485495        && (isset($_GET['delete_msg']))
    486496        && (count($_GET) > 1 && count($_GET) <= 2)) {
    487         require_once('wpbb-delete-message.php');
     497        require_once('delete-message.php');
    488498    }
    489499    /*
     
    495505        && ((isset($_GET['view']))
    496506        && (count($_GET) == 2))) {
    497         require_once('wpbb-view-message.php');
     507        require_once('view-message.php');
    498508    }
    499509
     
    504514    if ((isset($_GET['message']))
    505515        && (count($_GET) == 1)) {
    506         require_once('wpbb-message-user.php');
     516        require_once('message-user.php');
    507517    }
    508518
     
    519529        && ($_GET['action'] != 'reply')
    520530        && ($_GET['action'] != 'sticky')))) {
    521         require_once('wpbb-edit-topic.php');
     531        require_once('edit-topic.php');
    522532    }
    523533
     
    534544        && ($_GET['action'] != 'reply')
    535545        && ($_GET['action'] != 'sticky')))) {
    536         require_once('wpbb-lock-topic.php');
     546        require_once('lock-topic.php');
    537547    }
    538548
     
    549559        && ($_GET['action'] != 'reply')
    550560        && ($_GET['action'] != 'edit')))) {
    551         require_once('wpbb-sticky-topic.php');
     561        require_once('sticky-topic.php');
    552562    }
    553563
     
    564574        && ($_GET['action'] != 'reply')
    565575        && ($_GET['action'] != 'sticky')))) {
    566         require_once('wpbb-delete-topic.php');
     576        require_once('delete-topic.php');
    567577    }
    568578
     
    574584        && (isset($_GET['topic']))
    575585        && ((isset($_GET['action'])
    576         && ($_GET['action'] == 'markread') 
     586        && ($_GET['action'] == 'markread')
    577587        && ($_GET['action'] != 'delete')
    578588        && ($_GET['action'] != 'lock')
     
    580590        && ($_GET['action'] != 'reply')
    581591        && ($_GET['action'] != 'sticky')))) {
    582         require_once('wpbb-markread-topic.php');
     592        require_once('markread-topic.php');
    583593    }
    584594
     
    596606        && ($_GET['action'] != 'edit')
    597607        && ($_GET['action'] != 'sticky')))) {
    598         require_once('wpbb-reply-topic.php');
     608        require_once('reply-topic.php');
    599609    }
    600610
     
    607617        && (isset($_GET['current_page']))
    608618        && (count($_GET) == 2)) {
    609         require_once('wpbb-unread-topics.php');
     619        require_once('unread-topics.php');
    610620    }
    611621
     
    618628        && (isset($_GET['current_page']))
    619629        && (count($_GET) == 2)) {
    620         require_once('wpbb-unanswered-topics.php');
     630        require_once('unanswered-topics.php');
    621631    }
    622632}
  • wp-bulletin-board/tags/1.1.0/readme.txt

    r611368 r637712  
    33Donate link: http://codebycarter.x10.mx/wp/donate/
    44Tags: forum, bulletin board, twitter, facebook, discussion, discussion board, messaging, private message, topic, post, pagination, profile, subforum, wpbb
    5 Requires at least: 3.3
    6 Tested up to: 3.4.2
    7 Stable tag: 1.0.4
     5Requires at least: 3.0
     6Tested up to: 3.5
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1818
    1919= Features =
    20 * - Ease of Integration - WPBB creates a template file for your current template when you install or change your theme so you don't have to do anything. Everything can be managed from your admin area.
    21 * - Translatable - WPBB can easily be translated into your preferred language!
    22 * - Facebook registration - Allow your users to register on your Wordpress site via Facebook. This automatically creates a WP account for your Facebook users which they can then login to after authenticating.
    23 * - Twitter - Enter your twitter account in your settings and your users will be able to follow your website / personal account with the click of a button.
    24 * - Private Messaging System - Allow users to send messages to each other.
    25 * - Member Profiles - All your WP users are automatically  apart of your forum whenever you create it and have a "forum profile" which can be viewed on the forum which shows the users avatar, username, role, posts, website and signature. Signatures are apart of WPBB and allow your users to enter a signature which can be text or images and is displayed below their profile and posts.
    26 * - Categories, Forums, Sub forums - Organise your forums into categories and your sub forums into forums. There is no limit to the amount of forums its parent can have, and each are ordered by its appearance in its parent.
    27 * - Permissions system - Currently supports the ability to allow or disallow any role (even custom roles!) any specific permission (edit, view, read, post, reply, lock, delete, sticky). WPBB grabs all known roles from your WP site which you can set permissions for manually or copy existing permissions from a previous forum.
    28 * - Topics - If you have the permissions to do so you can edit, lock, delete, sticky, view, read, post or reply with a topic.
    29 * - Posts - You can edit and delete any post and the posts topic affects the posts status. You can create posts in two ways, creating a topic reply with presents the WP editor for improved formatting or you can use the quick reply feature (if it is enabled in your settings).
    30 * - Pagination System - Supports a simple pagination system which organises your topics and posts - you can set the max topics/posts per page in your wpbb settings.
    31 * - Unread Topics - WPBB collects a list of topics which have been posted when you were offline and displays them for you. You can mark any of them as read once you've read them.
    32 * - Unanswered Topics - Similar to the above feature, unanswered topics are ones which haven't yet received any replies.
    33 * - Admin area - The WPBB settings integrate with your existing WP admin area where you can easily manage your forums with ease. The WPBB overview allows you to change the order of a category, forum or sub forum, edit it and delete it with a single click. You can also create new categories, forums, sub forums and topics via the admin area.
    34 * - Settings - WPBB is jam packed with settings that you can use to customise the forum any way you want to.
     20* Compatibility - Fully compatible with 3.5, 3.4, 3.3, 3.2, 3.1 and 3.0
     21* Ease of Integration - WPBB works with any theme, you can change your theme anytime and WPBB will automatically update itself.
     22* Translatable - WPBB can easily be translated into your preferred language!
     23* Facebook registration - Allow your users to register on your Wordpress site via Facebook. This automatically creates a WP account for your Facebook users which they can then login to after authenticating.
     24* Twitter - Enter your twitter account in your settings and your users will be able to follow your website / personal account with the click of a button.
     25* Private Messaging System - Allow users to send messages to each other.
     26* Member Profiles - All your WP users are automatically  apart of your forum whenever you create it and have a "forum profile" which can be viewed on the forum which shows the users avatar, username, role, posts, website and signature. Signatures are apart of WPBB and allow your users to enter a signature which can be text or images and is displayed below their profile and posts.
     27* Categories, Forums, Sub forums - Organise your forums into categories and your sub forums into forums. There is no limit to the amount of forums its parent can have, and each are ordered by its appearance in its parent.
     28* Permissions system - Currently supports the ability to allow or disallow any role (even custom roles!) any specific permission (edit, view, read, post, reply, lock, delete, sticky). WPBB grabs all known roles from your WP site which you can set permissions for manually or copy existing permissions from a previous forum.
     29* Role Permissions - New in 1.1. Allows you to choose whether a role can only edit, lock, delete and sticky their own topics or everyones.
     30* Topics - If you have the permissions to do so you can edit, lock, delete, sticky, view, read, post or reply with a topic.
     31* Posts - You can edit and delete any post and the posts topic affects the posts status. You can create posts in two ways, creating a topic reply with presents the WP editor for improved formatting or you can use the quick reply feature (if it is enabled in your settings).
     32* Pagination System - Supports a simple pagination system which organises your topics and posts - you can set the max topics/posts per page in your wpbb settings.
     33* Unread Topics - WPBB collects a list of topics which have been posted when you were offline and displays them for you. You can mark any of them as read once you've read them.
     34* Unanswered Topics - Similar to the above feature, unanswered topics are ones which haven't yet received any replies.
     35* Admin area - The WPBB settings integrate with your existing WP admin area where you can easily manage your forums with ease. The WPBB overview allows you to change the order of a category, forum or sub forum, edit it and delete it with a single click. You can also create new categories, forums, sub forums and topics via the admin area.
     36* Settings - WPBB is jam packed with settings that you can use to customise the forum any way you want to.
     37* Tools - Tools help make your life easier. Tools such as updating your roles whenever you add, change or remove them and a tool to recreate the forum page if you ever accidentally delete it.
    3538
    36 And many more...
     39And much much more!
    3740
    3841== Installation ==
     
    6063Firstly always download the plugin again as the plugin is constantly updated. It is likely the problem you're having has been fixed already. If that doesn't work, create a topic here: http://wordpress.org/support/plugin/wp-bulletin-board
    6164
     65= How to Setup Facebook Integration =
     66
     671. https://developers.facebook.com/apps (register or login)
     682. "Create New App"
     693. Enter App Name, can be anything you want, don't worry about app namespace or web hosting. Click continue.
     704. Facebook should've created the app for you and you'll see at the top the name of your app and the default avatar, next to that there is your App ID and App Secret Key. Enter those into your WPBB facebook settings.
     715. You may want to enter a contact email and change any other settings to your liking but leave sandbox mode disabled and don't use the "Hosting URL"
     726. Click "Website with Facebook Login" under "Select how your app integrates with Facebook" then enter the URL to your wpbb forum e.g. http://mysite.com/wordpress/forum
     737. Save changes
     74
     75= When I edit and save my forum or subforum, there is an error =
     76
     77It is likely that you are updating a forum with roles that no longer exist. Go to your admin dashboard -> WPBB -> Tools -> Refresh Roles. Use this tool whenever you add, change or remove roles. Roles are like the ranks or capabilities that users have, e.g. subscriber, author, administrator, etc.
     78
    6279== Screenshots ==
    6380
     
    7188
    7289== Changelog ==
     90
     91= 1.1.0 =
     92* Role permissions added which allow you to set whether a role can edit, lock, delete or sticky only their own topics or posts or everyones.
     93* Now compatible with wordpress versions 3.0, 3.1, 3.2, 3.3 and 3.5
     94* Fixes error in topic post editor
     95* (un)read topics are now used per user instead of globally as it should be
     96* Removed unneccessary forum prefix setting as you can include 'forum' in your own title
     97* Fixed post count not changing when deleting topics and/or posts and when editing topics and posts.
     98* Fixes a number of bugs translators encountered when trying to translate wpbb
     99* Clicking the search box now clears the textbox, more javascript will be added in the future for those that use it
     100* Added useful descriptions next to all the settings in the wpbb settings.
     101* New tool added which allows you to recreate your forums page if it was accidentally deleted or didn't create for some reason
     102* Last post/reply will now take you to that topic or post
     103* You can no longer create empty topics, posts or messages or give them empty titles
     104* You can now go straight to your newly created topic or post when creating a topic or reply.
     105* Updated FAQ
     106* Minor bug fixes and typos fixed.
    73107
    74108= 1.0.4 =
  • wp-bulletin-board/tags/1.1.0/wp-bb.php

    r611368 r637712  
    44    Plugin URI: http://wordpress.org/extend/plugins/wp-bulletin-board/
    55    Description: An easy to use Bulletin board for Wordpress with Facebook and Twitter integration.
    6     Version: 1.0.4
     6    Version: 1.1.0
    77    Author: Jay Carter
    88    Author URI: http://codebycarter.com
     
    2929
    3030// Sets the default timezone used by all date/time functions in a script depending on server configuration option
    31 if (ini_get('date.timezone.')) {
     31if (ini_get('date.timezone.'))
     32{
    3233    $timezone = ini_get('date.timezone');
    3334    date_default_timezone_set($timezone);
     
    3536
    3637// Define wpbb plugin directory
    37 define('WPBB_DIR', plugin_dir_path(__FILE__));
     38if (!defined('WPBB_DIR'))
     39{
     40    define('WPBB_DIR', plugin_dir_path(__FILE__));
     41}
    3842// Contains categories, forums and subforums
    39 define('CATEGORY_TABLE', $wpdb->prefix.'wpbb_categories');
     43if (!defined('CATEGORY_TABLE'))
     44{
     45    define('CATEGORY_TABLE', $wpdb->prefix.'wpbb_categories');
     46}
    4047// Contains all topics whether in a category, forum or subforum
    41 define('TOPICS_TABLE', $wpdb->prefix.'wpbb_topics');
     48if (!defined('TOPICS_TABLE'))
     49{
     50    define('TOPICS_TABLE', $wpdb->prefix.'wpbb_topics');
     51}
    4252// Contains all posts inside a specific topic
    43 define('POSTS_TABLE', $wpdb->prefix.'wpbb_posts');
     53if (!defined('POSTS_TABLE'))
     54{
     55    define('POSTS_TABLE', $wpdb->prefix.'wpbb_posts');
     56}
    4457// Contains all user messages
    45 define('MESSAGE_TABLE', $wpdb->prefix.'wpbb_messages');
     58if (!defined('MESSAGE_TABLE'))
     59{
     60    define('MESSAGE_TABLE', $wpdb->prefix.'wpbb_messages');
     61}
     62// Contains all topics for each user and whether they are read or not
     63if (!defined('UNREAD_TABLE'))
     64{
     65    define('UNREAD_TABLE', $wpdb->prefix.'wpbb_topics_unread');
     66}
    4667// Define current version
    47 define('WPBB_VERSION', 'v1.0.4');
     68if (!defined('WPBB_VERSION'))
     69{
     70    define('WPBB_VERSION', 'v1.1.0');
     71}
    4872// Define plugin url (wp plugin page)
    49 define('WPBB_PLUGIN_URL', 'http://wordpress.org/support/plugin/wp-bulletin-board');
     73if (!defined('WPBB_PLUGIN_URL'))
     74{
     75    define('WPBB_PLUGIN_URL', 'http://wordpress.org/support/plugin/wp-bulletin-board');
     76}
    5077
    5178/*
     
    5380*/
    5481
    55 function wpbb_load_language() {
    56     load_plugin_textdomain('wp-bb', false, dirname(plugin_basename(__FILE__)).'/languages/');
    57 }
    5882add_action('plugins_loaded', 'wpbb_load_language');
     83
     84if (!function_exists('wpbb_load_language'))
     85{
     86    function wpbb_load_language()
     87    {
     88        load_plugin_textdomain('wp-bb', false, dirname(plugin_basename(__FILE__)).'/languages/');
     89    }
     90}
    5991
    6092/*
     
    75107add_action('wp_enqueue_scripts', 'wpbb_register_styles');
    76108
     109$options = get_option('wpbb_options');
     110if ($options['post_to_forum'] == 'yes')
     111{
     112    add_action('add_meta_boxes', 'wpbb_create_metaboxes'); // Metaboxes
     113    add_action('save_post', 'wpbb_post_saved'); // Wordpress post saved
     114}
     115
    77116/*
    78117    All WPBB Admin (Non Page or DB related) Functions
     
    81120*/
    82121
    83 require_once('php/admin/wpbb-admin-functions.php');
     122require_once('php/admin/admin-functions.php');
    84123
    85124/*
     
    87126*/
    88127
    89 function wpbb_activate() {
    90     // Create all neccessary database tables
    91     wpbb_create_db_table();
    92     // Create options in DB for our settings
    93     wpbb_create_options();
    94     // Create the user meta for all users currently registered
    95     wpbb_setup_user_meta();
    96     // Creates the Forum page
    97     wpbb_create_page();
     128if (!function_exists('wpbb_activate'))
     129{
     130    function wpbb_activate()
     131    {
     132        // Create all neccessary database tables
     133        wpbb_create_db_table();
     134        // Create options in DB for our settings
     135        wpbb_create_options();
     136        // Create the user meta for all users currently registered
     137        wpbb_setup_user_meta();
     138        // Creates the Forum page
     139        wpbb_create_page();
     140    }
    98141}
    99142
     
    102145*/
    103146
    104 function wpbb_uninstall() {
    105     global $wpdb;
    106     // Delete main options from database
    107     delete_option('wpbb_options');
    108     // Delete theme options
    109     delete_option('wpbb_theme_options');
    110     // Delete facebook options
    111     delete_option('wpbb_facebook_options');
    112     // Delete twitter options
    113     delete_option('wpbb_twitter_options');
    114     // Delete guest options
    115     delete_option('wpbb_guest_options');
    116     // Delete the user meta
    117     wpbb_delete_user_meta();
    118     // Delete post meta (this function is in wpbb-functions.php as the page is created in wpbb-forum.php)
    119     wpbb_delete_post_meta();
    120     // Delete database tables
    121     $wpdb->query("DROP TABLE ".CATEGORY_TABLE.", ".TOPICS_TABLE.", ".POSTS_TABLE.", ".MESSAGE_TABLE.";");
    122 }
    123 
    124 function wpbb_delete_user_meta() {
    125     global $wpdb;
    126     $delete_user_meta = $wpdb->query("DELETE FROM ".$wpdb->prefix."usermeta WHERE meta_key LIKE 'wpbb_%';");
    127 }
    128 
    129 function wpbb_delete_post_meta() {
    130     global $wpdb;
    131     $post_meta = $wpdb->prefix.'postmeta';
    132     $key = '_wp_page_template';
    133     $value = 'wpbb-template.php';
    134     $post_id = $wpdb->get_var("SELECT post_id FROM $post_meta WHERE meta_key = '$key' AND meta_value = '$value';");
    135     // Delete the meta data
    136     delete_post_meta($post_id, $key, $value);
    137     // Delete the page
    138     wp_delete_post($post_id, true);
     147if (!function_exists('wpbb_uninstall'))
     148{
     149    function wpbb_uninstall()
     150    {
     151        global $wpdb;
     152        delete_option('wpbb_options');
     153        delete_option('wpbb_theme_options');
     154        delete_option('wpbb_facebook_options');
     155        delete_option('wpbb_twitter_options');
     156        delete_option('wpbb_guest_options');
     157        wpbb_delete_user_meta();
     158        wpbb_delete_post_meta();
     159        $wpdb->query("DROP TABLE ".CATEGORY_TABLE.", ".TOPICS_TABLE.", ".POSTS_TABLE.", ".MESSAGE_TABLE.", ".UNREAD_TABLE.";");
     160    }
     161}
     162
     163if (!function_exists('wpbb_delete_user_meta'))
     164{
     165    function wpbb_delete_user_meta()
     166    {
     167        global $wpdb;
     168        $delete_user_meta = $wpdb->query("DELETE FROM ".$wpdb->prefix."usermeta WHERE meta_key LIKE 'wpbb_%';");
     169    }
     170}
     171
     172if (!function_exists('wpbb_delete_post_meta'))
     173{
     174    function wpbb_delete_post_meta()
     175    {
     176        global $wpdb;
     177        $post_meta = $wpdb->prefix.'postmeta';
     178        $key = '_wp_page_template';
     179        $value = 'wpbb-template.php';
     180        $post_id = $wpdb->get_var("SELECT post_id FROM $post_meta WHERE meta_key = '$key' AND meta_value = '$value';");
     181        // Delete the meta data
     182        delete_post_meta($post_id, $key, $value);
     183        // Delete the page
     184        wp_delete_post($post_id, true);
     185    }
    139186}
    140187
     
    143190*/
    144191
    145 function wpbb_create_db_table() {
    146 
    147     global $wpdb;
    148    
    149     $options = get_option('wpbb_options');
    150    
    151     // This is not being activated the first time
    152     //if (isset($options['version']) && $options['version'] != WPBB_VERSION) {
    153     if ($options) {
    154    
    155         wpbb_refresh_roles();
    156        
    157     } else {
    158        
     192if (!function_exists('wpbb_create_db_table'))
     193{
     194    function wpbb_create_db_table()
     195    {
     196        global $wpdb;
     197        $options = get_option('wpbb_options');
     198        if ($options)
     199        {
     200            wpbb_refresh_roles();
     201        }
    159202        $roles = wpbb_admin_get_all_roles('string', true);
    160    
    161203        $perms = "SET($roles) NOT NULL";
    162        
    163204        $create_category_query = "CREATE TABLE ".CATEGORY_TABLE." (
    164205            `id` TINYINT(1) UNSIGNED NOT NULL AUTO_INCREMENT,
    165             `name` VARCHAR(25) NOT NULL,
     206            `name` VARCHAR(30) NOT NULL,
    166207            `description` VARCHAR(200) NOT NULL,
    167208            `forum` TINYINT(1) NOT NULL,
     
    183224            `id` INT(1) NOT NULL AUTO_INCREMENT,
    184225            `author` SMALLINT(1) NOT NULL,
    185             `name` VARCHAR(25) NOT NULL,
     226            `name` VARCHAR(35) NOT NULL,
    186227            `content` TEXT NULL,
    187228            `forum` TINYINT(1) NOT NULL,
     
    215256            ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
    216257        ";
     258   
     259        $create_topic_unread_query = "CREATE TABLE ".UNREAD_TABLE." (
     260            `id` INT(1) NOT NULL,
     261            `author` INT(1) NOT NULL,
     262            `read` INT(1) NOT NULL
     263            ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
     264        ";
    217265     
    218266        $create_category_table = $wpdb->query($create_category_query);
     
    220268        $create_post_table = $wpdb->query($create_post_query);
    221269        $create_message_table = $wpdb->query($create_messages_query);
     270        $create_topic_unread_table = $wpdb->query($create_topic_unread_query);
    222271   
    223         if ($create_category_table === false) {
     272        if ($create_category_table === false)
     273        {
    224274            $create_category_table_err = __('There was an error creating the table wpbb_categorie', 'wp-bb');
    225             error_log($create_category_table_err);
     275            error_log($create_category_table_err);
    226276        }
    227         if ($create_topic_table === false) {
     277        if ($create_topic_table === false)
     278        {
    228279            $create_topic_table_err = __('There was an error creating the table wpbb_topics', 'wp-bb');
    229280            error_log($create_topic_table_err);
    230281        }
    231         if ($create_post_table === false) {
     282        if ($create_post_table === false)
     283        {
    232284            $create_post_table_err = __('There was an error creating the table wpbb_posts', 'wp-bb');
    233285            error_log($create_post_table_err);
    234286        }
    235         if ($create_message_table === false) {
     287        if ($create_message_table === false)
     288        {
    236289            $create_message_table_err = __('There was an error creating the table wpbb_messages', 'wp-bb');
    237290            error_log($create_message_table_err);
    238291        }
     292        if ($create_topic_unread_table === false)
     293        {
     294            $create_topic_unread_table_err = __('There was an error creating the table wpbb_topics_unread', 'wp-bb');
     295            error_log($create_topic_unread_table_err);
     296        }
    239297    }
    240298}
     
    244302*/
    245303
    246 function wpbb_create_options() {
    247     // Retrieve options from database
    248     $old_options = get_option('wpbb_options');
    249     // If options do not exist
    250     if (!$old_options) {
    251         $maintenance_message = __('This is the message that will be displayed to users when you disable the board. Edit this in your settings.', 'wp-bb');
    252         $forum_name = __('My WPBB Forum', 'wp-bb');
    253         $options = array(
    254             'maintenance_mode' => 'off',
    255             'maintenance_message' => $maintenance_message,
    256             'forum_name' => $forum_name,
    257             'forum_prefix' => 'no',
    258             'allow_guests' => 'yes',
    259             'allow_subforums' => 'yes',
    260             'enable_quick_reply' => 'yes',
    261             'topics_per_page' => 20,
    262             'posts_per_page' => 20,
    263             'topic_cutoff' => 15,
    264             'post_cutoff' => 15,
    265             'post_to_forum' => 'yes',
    266             'show_footer' => 'no',
    267             'version' => WPBB_VERSION
    268         );
    269         $add_wpbb_options = add_option('wpbb_options', $options);
    270     } else {
    271         if (!isset($old_options['version'])) {
    272             // Attempting to update a key in the options value will remove all the other keys so we must
    273             // set all the other keys as well
     304if (!function_exists('wpbb_create_options'))
     305{
     306    function wpbb_create_options()
     307    {
     308        // Retrieve options from database
     309        $old_options = get_option('wpbb_options');
     310        /*
     311        *   Add all current roles to an array with a default value of 'yes'
     312        *   This is for our role permissions
     313        */
     314        $roles = wpbb_admin_get_all_roles();
     315        $role_array = array();
     316        if ($roles)
     317        {
     318            foreach ($roles as $role)
     319            {
     320                $role_array[$role] = 'yes';
     321            }
     322        }
     323        // If options do not exist
     324        if (!$old_options)
     325        {
     326            $maintenance_message = __('This is the message that will be displayed to users when you disable the board. Edit this in your settings.', 'wp-bb');
     327            $forum_name = __('My WPBB Forum', 'wp-bb');
    274328            $options = array(
    275                 'maintenance_mode' => $old_options['maintenance_mode'],
    276                 'maintenance_message' => $old_options['maintenance_message'],
    277                 'forum_name' => $old_options['forum_name'],
    278                 'forum_prefix' => $old_options['forum_prefix'],
    279                 'allow_guests' => $old_options['allow_guests'],
    280                 'allow_subforums' => $old_options['allow_subforums'],
    281                 'enable_quick_reply' => $old_options['enable_quick_reply'],
    282                 'topics_per_page' => $old_options['topics_per_page'],
    283                 'posts_per_page' => $old_options['posts_per_page'],
    284                 'topic_cutoff' => $old_options['topic_cutoff'],
    285                 'post_cutoff' => $old_options['post_cutoff'],
    286                 'post_to_forum' => $old_options['post_to_forum'],
    287                 'show_footer' => $old_options['show_footer'],
     329                'maintenance_mode' => 'off',
     330                'maintenance_message' => $maintenance_message,
     331                'forum_name' => $forum_name,
     332                'allow_guests' => 'yes',
     333                'allow_subforums' => 'yes',
     334                'enable_quick_reply' => 'yes',
     335                'topics_per_page' => 20,
     336                'posts_per_page' => 20,
     337                'topic_cutoff' => 15,
     338                'post_cutoff' => 15,
     339                'post_to_forum' => 'yes',
     340                'show_footer' => 'no',
     341                'role_permissions' => $role_array,
    288342                'version' => WPBB_VERSION
    289343            );
    290             update_option('wpbb_options', $options);
    291         }
    292     }
    293     /* Theme Options */
    294     $old_theme_options = get_option('wpbb_theme_options');
    295     if (!$old_theme_options) {
    296         $add_wpbb_theme_options = add_option('wpbb_theme_options', array('theme' => 'light'));
    297     }
    298     /* Facebook Options */
    299     $old_facebook_options = get_option('wpbb_facebook_options');
    300     if (!$old_facebook_options) {
    301         $facebook_app_id = __('Enter your Facebook App ID / API Key', 'wp-bb');
    302         $facebook_app_secret_key = __('Enter your App Secret Key', 'wp-bb');
    303         $facebook_redirect_uri = __('Enter your URL (Redirect URL)', 'wp-bb');
    304         $facebook_state = __('Enter a long random string', 'wp-bb');
    305         $facebook_role = __('Enter the default role for new facebook registrations');
    306         $facebook_options = array(
    307             'allow_facebook' => 'no',
    308             'facebook_app_id' => $facebook_app_id,
    309             'facebook_app_secret_key' => $facebook_app_secret_key,
    310             'facebook_redirect_uri' => $facebook_redirect_uri,
    311             'facebook_state' => $facebook_state,
    312             'facebook_default_role' => $facebook_role
    313         );
    314         $add_wpbb_facebook_options = add_option('wpbb_facebook_options', $facebook_options);
    315     }
    316     /* Twitter Options */
    317     $old_twitter_options = get_option('wpbb_twitter_options');
    318     if (!$old_twitter_options) {
    319         $twitter_account = __('Enter your website/personal Twitter Account', 'wp-bb');
    320         $twitter_options = array(
    321             'allow_twitter' => 'no',
    322             'twitter_account' => $twitter_account
    323         );
    324         $add_wpbb_twitter_options = add_option('wpbb_twitter_options', $twitter_options);
    325     }
    326     $old_guest_options = get_option('wpbb_guest_options');
    327     if (!$old_guest_options) {
    328         $guest_options = array(
    329             'guest_last_post' => '0000-00-00 00:00:00'
    330         );
    331         $add_wpbb_guest_options = add_option('wpbb_guest_options', $guest_options);
     344            $add_wpbb_options = add_option('wpbb_options', $options);
     345        }
     346        else
     347        {
     348            if (!isset($old_options['version']))
     349            {
     350                $options = array(
     351                    'maintenance_mode' => $old_options['maintenance_mode'],
     352                    'maintenance_message' => $old_options['maintenance_message'],
     353                    'forum_name' => $old_options['forum_name'],
     354                    'allow_guests' => $old_options['allow_guests'],
     355                    'allow_subforums' => $old_options['allow_subforums'],
     356                    'enable_quick_reply' => $old_options['enable_quick_reply'],
     357                    'topics_per_page' => $old_options['topics_per_page'],
     358                    'posts_per_page' => $old_options['posts_per_page'],
     359                    'topic_cutoff' => $old_options['topic_cutoff'],
     360                    'post_cutoff' => $old_options['post_cutoff'],
     361                    'post_to_forum' => $old_options['post_to_forum'],
     362                    'show_footer' => $old_options['show_footer'],
     363                    'role_permissions' => $role_array,
     364                    'version' => WPBB_VERSION
     365                );
     366                update_option('wpbb_options', $options);
     367            }
     368        }
     369        /* Theme Options */
     370        $old_theme_options = get_option('wpbb_theme_options');
     371        if (!$old_theme_options)
     372        {
     373            $add_wpbb_theme_options = add_option('wpbb_theme_options', array('theme' => 'light'));
     374        }
     375        /* Facebook Options */
     376        $old_facebook_options = get_option('wpbb_facebook_options');
     377        if (!$old_facebook_options) {
     378            $facebook_app_id = __('Enter your Facebook App ID / API Key', 'wp-bb');
     379            $facebook_app_secret_key = __('Enter your App Secret Key', 'wp-bb');
     380            $facebook_redirect_uri = __('Enter your URL (Redirect URL)', 'wp-bb');
     381            $facebook_state = __('Enter a long random string', 'wp-bb');
     382            $facebook_role = __('Enter the default role for new facebook registrations');
     383            $facebook_options = array(
     384                'allow_facebook' => 'no',
     385                'facebook_app_id' => $facebook_app_id,
     386                'facebook_app_secret_key' => $facebook_app_secret_key,
     387                'facebook_redirect_uri' => $facebook_redirect_uri,
     388                'facebook_state' => $facebook_state,
     389                'facebook_default_role' => $facebook_role
     390            );
     391            $add_wpbb_facebook_options = add_option('wpbb_facebook_options', $facebook_options);
     392        }
     393        /* Twitter Options */
     394        $old_twitter_options = get_option('wpbb_twitter_options');
     395        if (!$old_twitter_options)
     396        {
     397            $twitter_account = __('Enter your website/personal Twitter Account', 'wp-bb');
     398            $twitter_options = array(
     399                'allow_twitter' => 'no',
     400                'twitter_account' => $twitter_account
     401            );
     402            $add_wpbb_twitter_options = add_option('wpbb_twitter_options', $twitter_options);
     403        }
     404        $old_guest_options = get_option('wpbb_guest_options');
     405        if (!$old_guest_options)
     406        {
     407            $guest_options = array(
     408                'guest_last_post' => '0000-00-00 00:00:00'
     409            );
     410            $add_wpbb_guest_options = add_option('wpbb_guest_options', $guest_options);
     411        }
    332412    }
    333413}
     
    337417*/
    338418
    339 function wpbb_admin_pages() {
    340    
    341     $create_category = __('Create Category', 'wp-bb');
    342     $create_forum = __('Create Forum', 'wp-bb');
    343     $create_subforum = __('Create Subforum', 'wp-bb');
    344     $create_topic = __('Create Topic', 'wp-bb');
    345     $create_tools = __('Tools', 'wp-bb');
    346     $faq_support = __('FAQ & Support', 'wp-bb');
    347     $settings = __('WPBB Settings', 'wp-bb');
    348 
    349     // Main WPBB page
    350     add_menu_page('WPBB Overview', 'WPBB', 'manage_options', 'wpbb_admin', 'wpbb_admin_display', '', 26);
    351    
    352     // Create/Edit Category
    353     add_submenu_page('wpbb_admin', 'WPBB Categories', $create_category, 'manage_options', 'wpbb_admin_categories', 'wpbb_admin_categories');
    354    
    355     // Create/Edit Forum
    356     add_submenu_page('wpbb_admin', 'WPBB Forums', $create_forum, 'manage_options', 'wpbb_admin_forums', 'wpbb_admin_forums');
    357    
    358     // Create/Edit Subforum
    359     add_submenu_page('wpbb_admin', 'WPBB Subforums', $create_subforum, 'manage_options', 'wpbb_admin_subforums', 'wpbb_admin_subforums');
    360    
    361     // Create/Edit Topics
    362     add_submenu_page('wpbb_admin', 'WPBB Topics', $create_topic, 'manage_options', 'wpbb_admin_topics', 'wpbb_admin_topics');
    363    
    364     // Create Tools page
    365     add_submenu_page('wpbb_admin', 'WPBB Tools', $create_tools, 'manage_options', 'wpbb_admin_tools', 'wpbb_admin_tools');
    366    
    367     // FAQ / First Installation Page
    368     add_submenu_page('wpbb_admin', 'FAQ / Support', $faq_support, 'manage_options', 'wpbb_admin_help', 'wpbb_admin_help');
    369    
    370     // WPBB Settings
    371     add_options_page('WPBB Settings', $settings, 'manage_options', 'wpbb_settings_page', 'wpbb_display_settings');
    372 }
    373 
    374 function wpbb_create_template_file() {
    375     // Get current theme directory
    376     $template_directory = get_template_directory();
    377     // Check if required template file doesn't exist and if true create it
    378     if (!file_exists($template_directory.'/wpbb-template.php')) {
    379         // Check directory is writable
    380         if (is_writable($template_directory)) {
    381             // Copys wp-bb template file to your current theme
    382             $template_file_path = WPBB_DIR.'/wpbb-template.php';
    383             $move_template_file = copy($template_file_path, $template_directory.'/wpbb-template.php');
    384             if (!$move_template_file) {
    385                 $move_template_file_failed = sprintf(__('Failed to move required wp-bb template file %s to theme directory %s. Please make sure both the file and directory exist or move the wp-bb template file to your current theme directory manually'), $template_file_path, $template_directory);
    386                 error_log($move_template_file_failed);
     419if (!function_exists('wpbb_admin_pages'))
     420{
     421    function wpbb_admin_pages()
     422    {
     423        $create_category = __('Create Category', 'wp-bb');
     424        $create_forum = __('Create Forum', 'wp-bb');
     425        $create_subforum = __('Create Subforum', 'wp-bb');
     426        $create_topic = __('Create Topic', 'wp-bb');
     427        $role_permissions = __('Role Permissions', 'wp-bb');
     428        $create_tools = __('Tools', 'wp-bb');
     429        $faq_support = __('FAQ & Support', 'wp-bb');
     430        $settings = __('WPBB Settings', 'wp-bb');
     431
     432        // Main WPBB page
     433        add_menu_page('WPBB Overview', 'WPBB', 'manage_options', 'wpbb_admin', 'wpbb_admin_display', '', 27.7);
     434   
     435        // Create/Edit Category
     436        add_submenu_page('wpbb_admin', 'WPBB Categories', $create_category, 'manage_options', 'wpbb_admin_categories', 'wpbb_admin_categories');
     437   
     438        // Create/Edit Forum
     439        add_submenu_page('wpbb_admin', 'WPBB Forums', $create_forum, 'manage_options', 'wpbb_admin_forums', 'wpbb_admin_forums');
     440   
     441        // Create/Edit Subforum
     442        add_submenu_page('wpbb_admin', 'WPBB Subforums', $create_subforum, 'manage_options', 'wpbb_admin_subforums', 'wpbb_admin_subforums');
     443   
     444        // Create/Edit Topics
     445        add_submenu_page('wpbb_admin', 'WPBB Topics', $create_topic, 'manage_options', 'wpbb_admin_topics', 'wpbb_admin_topics');
     446       
     447        // Role permissions
     448        add_submenu_page('wpbb_admin', 'Role Permissions', $role_permissions, 'manage_options', 'wpbb_admin_role_permissions', 'wpbb_admin_role_permissions');
     449   
     450        // Create Tools page
     451        add_submenu_page('wpbb_admin', 'WPBB Tools', $create_tools, 'manage_options', 'wpbb_admin_tools', 'wpbb_admin_tools');
     452   
     453        // FAQ / First Installation Page
     454        add_submenu_page('wpbb_admin', 'FAQ / Support', $faq_support, 'manage_options', 'wpbb_admin_help', 'wpbb_admin_help');
     455       
     456        // Shortcut to WPBB settings - some people don't know they exist
     457        add_submenu_page('wpbb_admin', 'WPBB Settings', $settings, 'manage_options', 'wpbb_settings_page', 'wpbb_display_settings');
     458   
     459        // WPBB Settings
     460        add_options_page('WPBB Settings', $settings, 'manage_options', 'wpbb_settings_page', 'wpbb_display_settings');
     461    }
     462}
     463
     464
     465if (!function_exists('wpbb_create_template_file'))
     466{
     467    function wpbb_create_template_file()
     468    {
     469        // Get current theme directory
     470        $template_directory = get_template_directory();
     471        // Check if required template file doesn't exist and if true create it
     472        if (!file_exists($template_directory.'/wpbb-template.php'))
     473        {
     474            // Check directory is writable
     475            if (is_writable($template_directory))
     476            {
     477                // Copys wp-bb template file to your current theme
     478                $template_file_path = WPBB_DIR.'/wpbb-template.php';
     479                $move_template_file = copy($template_file_path, $template_directory.'/wpbb-template.php');
     480                if (!$move_template_file)
     481                {
     482                    $move_template_file_failed = sprintf(__('Failed to move required wp-bb template file %s to theme directory %s. Please make sure both the file and directory exist or move the wp-bb template file to your current theme directory manually'), $template_file_path, $template_directory);
     483                    error_log($move_template_file_failed);
     484                }
    387485            }
    388         } else { // Is not writable and user should change permissions accordingly
    389             $template_write_failed = sprintf(__('%s is not writable. Could not create required WPBB template file forum.php. Please change the folders permissions and visit your Wordpress site again or copy the file forum.php from your wp-bb plugin folder to your template folders directory manually.'), $template_directory);
    390             error_log($template_write_failed);
    391         }
    392     }
    393 }
    394 
    395 function wpbb_create_page() {
    396     // Check the page doesn't already exist (e.g. when reactivating)
    397     global $wpdb;
    398     $post_meta = $wpdb->prefix.'postmeta';
    399     $post_id = $wpdb->get_var("SELECT post_id FROM $post_meta WHERE meta_key = '_wp_page_template' AND meta_value = 'wpbb-template.php';");
    400     if ($post_id == NULL) {
    401         $wpbb_page_title = __('Forums', 'wp-bb');
    402         $link = site_url().'/'.strtolower($wpbb_page_title);
    403         $page = array(
    404             'post_status' => 'publish',
    405             'post_title' => $wpbb_page_title,
    406             'comment_status' => 'closed',
    407             'post_type' => 'page'
    408         );
    409         global $forum_page;
    410         $forum_page = wp_insert_post($page, false);
    411         add_post_meta($forum_page, '_wp_page_template', 'wpbb-template.php', true);
    412     }
    413     // This function checks if the template file exists before doing anything
    414     $template = wpbb_create_template_file();
    415 }
    416 
    417 function wpbb_register_styles() {
    418     $wpbb_theme_options = get_option('wpbb_theme_options');
    419     if ($wpbb_theme_options['theme'] == 'light') {
    420         wp_register_style('wpbb-light-style', plugins_url('wp-bulletin-board/css/wpbb-light-style.css'));
    421         wp_enqueue_style('wpbb-light-style');
    422     } else {
    423         wp_register_style('wpbb-dark-style', plugins_url('wp-bulletin-board/css/wpbb-dark-style.css'));
    424         wp_enqueue_style('wpbb-dark-style');
     486            else
     487            {
     488                // Is not writable and user should change permissions accordingly
     489                $template_write_failed = sprintf(__('%s is not writable. Could not create required WPBB template file forum.php. Please change the folders permissions and visit your Wordpress site again or copy the file forum.php from your wp-bb plugin folder to your template folders directory manually.'), $template_directory);
     490                error_log($template_write_failed);
     491            }
     492        }
     493    }
     494}
     495
     496if (!function_exists('wpbb_create_page'))
     497{
     498    function wpbb_create_page()
     499    {
     500        // Check the page doesn't already exist (e.g. when reactivating)
     501        global $wpdb;
     502        $post_meta = $wpdb->prefix.'postmeta';
     503        $post_id = $wpdb->get_var("SELECT post_id FROM $post_meta WHERE meta_key = '_wp_page_template' AND meta_value = 'wpbb-template.php';");
     504        if ($post_id == NULL)
     505        {
     506            $wpbb_page_title = __('Forums', 'wp-bb');
     507            $link = site_url().'/'.strtolower($wpbb_page_title);
     508            $page = array(
     509                'post_status' => 'publish',
     510                'post_title' => $wpbb_page_title,
     511                'comment_status' => 'closed',
     512                'post_type' => 'page'
     513            );
     514            global $forum_page;
     515            $forum_page = wp_insert_post($page, false);
     516            add_post_meta($forum_page, '_wp_page_template', 'wpbb-template.php', true);
     517        }
     518        // This function checks if the template file exists before doing anything
     519        $template = wpbb_create_template_file();
     520    }
     521}
     522
     523/*
     524    Wordpress post metaboxes
     525*/
     526
     527if (!function_exists('wpbb_post_saved'))
     528{
     529    function wpbb_post_saved($_post_id)
     530    {
     531        if (wp_is_post_revision($_post_id))
     532        {
     533            return;
     534        }
     535        static $first = true;
     536        if (!$first) return;
     537        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
     538        {
     539            return;
     540        }
     541        $post_metabox_nonce = isset($_POST['wpbb-post-metabox-nonce']);
     542        if (!wp_verify_nonce($post_metabox_nonce, plugin_basename(__FILE__)))
     543        {
     544            return;
     545        }
     546        $_post_type = isset($_POST['post_type']);
     547        if ('post' == $_post_type)
     548        {
     549            if (!current_user_can('edit_page', $_post_id))
     550            {
     551                return;
     552            }
     553        }
     554        $post_id = absint($_post_id);
     555        $post_data = get_post($post_id, ARRAY_A);
     556        $post_to_forum_id = NULL;
     557        if (isset($_POST['wpbb-post-to-forum']))
     558        {
     559            $post_to_forum_id = absint($_POST['wpbb-post-to-forum']);
     560        }
     561        if ($post_to_forum_id == NULL)
     562        {
     563            error_log(__('When copying the post to a WPBB forum, the wpbb-post-to-forum was NULL - a forum ID wasn\'t provided'));
     564        }
     565        $is_forum = NULL;
     566        $is_subforum = NULL;
     567        global $wpdb;
     568        // Check to see if this forum is a forum or a subforum
     569        $forum_or_subforum = $wpdb->get_results("SELECT `forum`, `subforum` FROM ".CATEGORY_TABLE." WHERE id = $post_to_forum_id;");
     570        if ($forum_or_subforum)
     571        {
     572            foreach ($forum_or_subforum as $forum)
     573            {
     574                if ($forum->forum > 0 && $forum->subforum == 0)
     575                {
     576                    // Forum
     577                    $is_forum = true;
     578                    $is_subforum = false;
     579                }
     580                else if ($forum->subforum > 0 && $forum->forum == 0)
     581                {
     582                    // Subforum
     583                    $is_subforum = true;
     584                    $is_forum = false;
     585                }
     586            }
     587        }
     588        if ($post_data)
     589        {
     590            $forum_id = ($is_forum) ? $post_to_forum_id : 0;
     591            $subforum_id = ($is_subforum) ? $post_to_forum_id : 0;
     592            $data = array(
     593                'name' => $post_data['post_title'],
     594                'author' => $post_data['post_author'],
     595                'content' => $post_data['post_content'],
     596                'forum' => $forum_id,
     597                'subforum' => $subforum_id,
     598                'status' => '',
     599                'created' => $post_data['post_date'],
     600                'last_reply' => $post_data['post_date']
     601            );
     602            $copy_post_to_forum = $wpdb->insert(TOPICS_TABLE, $data);
     603            if ($copy_post_to_forum === false)
     604            {
     605                error_log(__('Failed to copy the wordpress post to the wpbb forum', 'wp-bb'));
     606            }
     607            else
     608            {
     609                // Update authors post count
     610                wpbb_admin_update_user_meta($post_data['post_author'], 'increase');
     611                $first = false;
     612            }
     613        }
     614    }
     615}
     616
     617if (!function_exists('wpbb_display_metaboxes'))
     618{
     619    function wpbb_display_metaboxes()
     620    {
     621        global $wpdb;
     622        wp_nonce_field(plugin_basename(__FILE__), 'wpbb-post-metabox-nonce');
     623        ?>
     624        <div id="minor-publishing-actions">
     625            <p class="description">Send a copy of this post to one of your WPBB forums or subforums or check "None" or disable this in your WPBB Settings</p>
     626            <select name="wpbb-post-to-forum">
     627                <!-- Default -->
     628                <option value="0">None</option>
     629                <?php
     630                // All forums and subforums
     631                $forums = $wpdb->get_results("SELECT `id`, `name` FROM ".CATEGORY_TABLE." WHERE forum > 0 || subforum > 0;");
     632                if ($forums)
     633                {
     634                    foreach ($forums as $forum)
     635                    {
     636                        ?>
     637                        <option value="<?php echo $forum->id; ?>"><?php echo $forum->name;?></option>
     638                        <?php
     639                    }
     640                }
     641                ?>
     642            </select>
     643        </div>
     644        <?php
     645    }
     646}
     647
     648if (!function_exists('wpbb_create_metaboxes'))
     649{
     650    function wpbb_create_metaboxes()
     651    {
     652        add_meta_box('wpbb-post-to-forum-meta-box', __('Post to WPBB Forum', 'wp-bb'), 'wpbb_display_metaboxes', 'post', 'side', 'high', NULL);
     653    }
     654}
     655
     656/*
     657    Register and loads the style and javascript files depending on settings
     658*/
     659
     660if (!function_exists('wpbb_register_styles'))
     661{
     662    function wpbb_register_styles()
     663    {
     664        $wpbb_theme_options = get_option('wpbb_theme_options');
     665        if ($wpbb_theme_options['theme'] == 'light')
     666        {
     667            wp_register_style('wpbb-light-style', plugins_url('wp-bulletin-board/css/wpbb-light-style.css'));
     668            wp_enqueue_style('wpbb-light-style');
     669        }
     670        else
     671        {
     672            wp_register_style('wpbb-dark-style', plugins_url('wp-bulletin-board/css/wpbb-dark-style.css'));
     673            wp_enqueue_style('wpbb-dark-style');
     674        }
     675        wp_enqueue_script('jquery');
     676        wp_register_script('wpbb-search', plugins_url('wp-bulletin-board/js/wpbb-search.js'), 'jquery');
     677        wp_enqueue_script('wpbb-search');
    425678    }
    426679}
     
    432685*/
    433686
    434 function wpbb_admin_display() {
    435     require_once('php/admin/wpbb-admin-main.php');
    436 }
     687if (!function_exists('wpbb_admin_display'))
     688{
     689    function wpbb_admin_display()
     690    {
     691        require_once('php/admin/admin-main.php');
     692    }
     693}
     694
    437695
    438696
     
    441699*/
    442700
    443 function wpbb_admin_categories() {
    444     require_once('php/admin/wpbb-admin-categories.php');
     701if (!function_exists('wpbb_admin_categories'))
     702{
     703    function wpbb_admin_categories()
     704    {
     705        require_once('php/admin/admin-categories.php');
     706    }
    445707}
    446708
     
    449711*/
    450712
    451 function wpbb_admin_forums() {
    452     require_once('php/admin/wpbb-admin-forums.php');
     713if (!function_exists('wpbb_admin_forums'))
     714{
     715    function wpbb_admin_forums()
     716    {
     717        require_once('php/admin/admin-forums.php');
     718    }
    453719}
    454720
     
    457723*/
    458724
    459 function wpbb_admin_subforums() {
    460     require_once('php/admin/wpbb-admin-subforums.php');
     725if (!function_exists('wpbb_admin_subforums'))
     726{
     727    function wpbb_admin_subforums()
     728    {
     729        require_once('php/admin/admin-subforums.php');
     730    }
    461731}
    462732
     
    465735*/
    466736
    467 function wpbb_admin_topics() {
    468     require_once('php/admin/wpbb-admin-topics.php');
     737if (!function_exists('wpbb_admin_topics'))
     738{
     739    function wpbb_admin_topics()
     740    {
     741        require_once('php/admin/admin-topics.php');
     742    }
     743}
     744
     745/*
     746    Role Permissions
     747*/
     748
     749if (!function_exists('wpbb_admin_role_permissions'))
     750{
     751    function wpbb_admin_role_permissions()
     752    {
     753        require_once('php/admin/admin-role-permissions.php');
     754    }
    469755}
    470756
     
    473759*/
    474760
    475 function wpbb_admin_tools() {
    476     require_once('php/admin/wpbb-admin-tools.php');
     761if (!function_exists('wpbb_admin_tools'))
     762{
     763    function wpbb_admin_tools()
     764    {
     765        require_once('php/admin/admin-tools.php');
     766    }
    477767}
    478768
     
    481771*/
    482772
    483 function wpbb_admin_help() {
    484     require_once('php/admin/wpbb-admin-faq-support.php');
    485 }
    486 
     773if (!function_exists('wpbb_admin_help'))
     774{
     775    function wpbb_admin_help()
     776    {
     777        require_once('php/admin/admin-faq-support.php');
     778    }
     779}
    487780
    488781/*
     
    490783*/
    491784
    492 function wpbb_display_settings() {
    493     require_once('php/admin/wpbb-admin-settings.php');
     785if (!function_exists('wpbb_display_settings'))
     786{
     787    function wpbb_display_settings()
     788    {
     789        require_once('php/admin/admin-settings.php');
     790    }
    494791}
    495792
  • wp-bulletin-board/trunk/css/wpbb-light-style.css

    r607181 r637712  
    11/*
    22    WPBB light style
    3    
    4     To be used on a light background, preferably white
    5    
    6     This only affects the front end as the back end implements wordpress styling.
    73*/
    84
     
    3026    font-weight:bold;
    3127    padding-bottom:10px;
     28}
     29
     30/* Change the forum title position and color of the slash (/) character here */
     31h2.wpbb-forum-title {
     32    text-align:center;
     33    padding-bottom:10px;
     34}
     35
     36/* Change the color of the forum title link here, boldness, etc */
     37h2.wpbb-forum-title a {
     38    font-weight:bold;
     39    color:purple;
    3240}
    3341
     
    184192    min-width: 500px;
    185193    white-space: pre-line;
     194    text-align:left;
    186195}
    187196
  • wp-bulletin-board/trunk/php/facebook/wpbb-facebook.php

    r607181 r637712  
    99$user_id = get_current_user_id();
    1010
    11 if ($user_id !== 0) { // User is logged in
    12 
     11if ($user_id !== 0)
     12{
     13    // User is logged in
    1314    $user_access_token = get_user_meta($user_id, 'wpbb_facebook_access_token', true);
    14 
    15     if ($user_access_token != "" && is_user_logged_in()) { // User is logged into Facebook
    16    
     15    if ($user_access_token != "" && is_user_logged_in())
     16    {
     17        // User is logged into Facebook
    1718        $logged_into_facebook = true;
    18 
    19         if (count($_GET) == 0) {
     19        if (count($_GET) == 0)
     20        {
    2021        ?>
    2122        <div class="wpbb-centered">
     
    2526        <?php
    2627        }
    27    
    28     }
    29    
    30    
    31 } else { // User is not logged in
    32    
    33     // Registering for a Wordpress account through Facebook
     28    }
     29}
     30else
     31{
     32    /*
     33        User is not logged in
     34        Registering for a Wordpress account through Facebook
     35    */
    3436    if ((isset($_GET['register'])) && (isset($_GET['method'])) && (count($_GET) == 2)) {
    3537   
     
    130132                        <br />
    131133                        <div class="wpbb-centered">
    132                             <?php printf(__('Thankyou for logging in to Facebook, %s!'), $facebook_user['name']); ?>
     134                            <?php printf(__('Thank you for logging in to Facebook, %s!'), $facebook_user['name']); ?>
    133135                            <br /><br />
    134136                            <?php _e('Please now enter the password for your Wordpress account you registered using Facebook.', 'wp-bb'); ?><br /><br /><?php
     
    238240        <div class="wpbb-message-success">
    239241            <?php
    240             _e('Thankyou for registering. Please login with your Facebook username and password you just created', 'wp-bb');
     242            _e('Thank you for registering. Please login with your Facebook username and password you just created', 'wp-bb');
    241243            ?>
    242244        </div>
  • wp-bulletin-board/trunk/php/twitter/wpbb-twitter.php

    r611368 r637712  
    55*/
    66
    7 if (count($_GET) == 0) {
     7if (count($_GET) == 0)
     8{
    89    ?>
    910    <div class="wpbb-centered">
  • wp-bulletin-board/trunk/php/wpbb-forum.php

    r607181 r637712  
    44    Checks if the plugin is deactivated
    55*/
    6 
    76
    87// Since we're not in the admin area we must require the plugin.php file
     
    1817    <div style="text-align:center;font-weight:bold;color:red;">
    1918        <?php
    20             _e('The plugin is deactivated. Please reactivate the plugin to continue using WPBB', 'wp-bb');
     19            _e('The plugin is deactivated. Please reactivate the plugin to continue using WPBB or delete this page', 'wp-bb');
    2120            wpbb_exit();
    2221        ?>
     
    3534
    3635// Sets the default timezone used by all date/time functions in a script depending on server configuration option
    37 if (ini_get('date.timezone.')) {
     36if (ini_get('date.timezone.'))
     37{
    3838    $timezone = ini_get('date.timezone');
    3939    date_default_timezone_set($timezone);
     
    4848define('POST_TABLE', $wpdb->prefix.'wpbb_posts');
    4949define('MESSAGES_TABLE', $wpdb->prefix.'wpbb_messages');
     50define('UN_READ_TABLE', $wpdb->prefix.'wpbb_topics_unread');
    5051
    5152// The WP-BB plugin url on wordpress - only used if show footer option is set to yes
     
    5354
    5455
    55 function wpbb_exit() {
     56function wpbb_exit()
     57{
    5658    get_header();
    5759    get_footer();
     
    6365    && (!is_user_logged_in())
    6466    && (!isset($_GET['method']))
    65     && (!isset($_GET['state']))) {
    66     if ($wpbb_facebook_options['allow_facebook'] == 'yes') {
     67    && (!isset($_GET['state'])))
     68    {
     69    if ($wpbb_facebook_options['allow_facebook'] == 'yes')
     70    {
    6771        require_once('facebook/wpbb-facebook.php');
    6872    }
    69     require_once('wpbb-functions.php');
     73    require_once('functions.php');
    7074    ?>
    7175    <div class="wpbb-centered-bold">
     
    7781}
    7882
    79 if ($wpbb_options['maintenance_mode'] == 'on') {
    80     if (current_user_can('manage_options')) {
     83if ($wpbb_options['maintenance_mode'] == 'on')
     84{
     85    if (current_user_can('manage_options'))
     86    {
    8187        ?>
    8288        <div class="wpbb-message-warning">
     
    8490        </div>
    8591        <?php
    86     } else {
     92    }
     93    else
     94    {
    8795        ?>
    8896        <div class="wpbb-message-warning">
     
    9098        </div>
    9199        <?php
    92         if ($wpbb_facebook_options['allow_facebook'] == 'yes') {
     100        if ($wpbb_facebook_options['allow_facebook'] == 'yes')
     101        {
    93102            require_once('facebook/wpbb-facebook.php');
    94103        }
    95         require_once('wpbb-functions.php');
     104        require_once('functions.php');
    96105        wpbb_footer();
    97106        wpbb_exit();
     
    103112*/
    104113
    105 require_once('wpbb-functions.php');
    106 
    107 /* 
     114require_once('functions.php');
     115
     116/*
    108117    Checks a page supplied exists
    109118*/
     
    115124*/
    116125
    117 if ($wpbb_facebook_options['allow_facebook'] == 'yes') {
     126if ($wpbb_facebook_options['allow_facebook'] == 'yes')
     127{
    118128    require_once('facebook/wpbb-facebook.php');
    119129}
     
    126136$wpbb_twitter_options = get_option('wpbb_twitter_options');
    127137
    128 if ($wpbb_twitter_options['allow_twitter'] == 'yes') {
     138if ($wpbb_twitter_options['allow_twitter'] == 'yes')
     139{
    129140    require_once('twitter/wpbb-twitter.php');
    130141}
     
    138149*/
    139150
     151
    140152if (empty($permalink_options))
    141153{
    142     if (count($_GET) == 1) {
    143         require_once('wpbb-index.php');
    144     }
    145 
     154    if (count($_GET) == 1)
     155    {
     156        require_once('forum-index.php');
     157    }
    146158
    147159    /*
     
    152164        && (isset($_GET['current_page']))
    153165        && (count($_GET) == 3)) {
    154         require_once('wpbb-view-forum.php');
     166        require_once('view-forum.php');
    155167    }
    156168   
     
    165177        && (isset($_GET['current_page']))
    166178        && (count($_GET) == 4)) {
    167         require_once('wpbb-view-forum-topic.php');
    168     }
    169 
     179        require_once('view-forum-topic.php');
     180    }
    170181
    171182    /*
     
    177188        && (isset($_GET['forum']) && isset($_GET['subforum']))
    178189        && (count($_GET) == 4)) {
    179         require_once('wpbb-create-topic.php');
     190        require_once('create-topic.php');
    180191    }
    181192
     
    184195        && (isset($_GET['forum']))
    185196        && (count($_GET) == 3)) {
    186         require_once('wpbb-create-topic.php');
    187     }
    188 
     197        require_once('create-topic.php');
     198    }
    189199
    190200    /*
     
    197207        && (isset($_GET['current_page']))
    198208        && (count($_GET) == 4)) {
    199         require_once('wpbb-view-subforum.php');
     209        require_once('view-subforum.php');
    200210    }
    201211
     
    211221        && (isset($_GET['current_page']))
    212222        && (count($_GET) == 5)) {
    213         require_once('wpbb-view-subforum-topic.php');
     223        require_once('view-subforum-topic.php');
    214224    }
    215225
     
    221231        && (isset($_GET['page_id']))
    222232        && (count($_GET) == 2)) {
    223         require_once('wpbb-view-profile.php');
     233        require_once('view-profile.php');
    224234    }
    225235
     
    232242        && (isset($_GET['current_page']))
    233243        && (count($_GET) == 3)) {
    234         require_once('wpbb-all-messages.php');
     244        require_once('all-messages.php');
    235245    }
    236246   
     
    243253        && (isset($_GET['page_id']))
    244254        && (count($_GET) > 1 && count($_GET) <= 3)) {
    245         require_once('wpbb-delete-message.php');
     255        require_once('delete-message.php');
    246256    }
    247257
     
    255265        && ((isset($_GET['view'])) && ($_GET['view']))
    256266        && (count($_GET) == 3)) {
    257         require_once('wpbb-view-message.php');
     267        require_once('view-message.php');
    258268    }
    259269
     
    265275        && (isset($_GET['page_id']))
    266276        && (count($_GET) == 2)) {
    267         require_once('wpbb-message-user.php');
     277        require_once('message-user.php');
    268278    }
    269279
     
    281291        && ($_GET['action'] != 'reply')
    282292        && ($_GET['action'] != 'sticky')))) {
    283         require_once('wpbb-edit-topic.php');
     293        require_once('edit-topic.php');
    284294    }
    285295
     
    297307        && ($_GET['action'] != 'reply')
    298308        && ($_GET['action'] != 'sticky')))) {
    299         require_once('wpbb-lock-topic.php');
     309        require_once('lock-topic.php');
    300310    }
    301311
     
    313323        && ($_GET['action'] != 'reply')
    314324        && ($_GET['action'] != 'edit')))) {
    315         require_once('wpbb-sticky-topic.php');
     325        require_once('sticky-topic.php');
    316326    }
    317327
     
    329339        && ($_GET['action'] != 'reply')
    330340        && ($_GET['action'] != 'sticky')))) {
    331         require_once('wpbb-delete-topic.php');
     341        require_once('delete-topic.php');
    332342    }
    333343
     
    346356        && ($_GET['action'] != 'reply')
    347357        && ($_GET['action'] != 'sticky')))) {
    348         require_once('wpbb-markread-topic.php');
     358        require_once('markread-topic.php');
    349359    }
    350360
     
    363373        && ($_GET['action'] != 'edit')
    364374        && ($_GET['action'] != 'sticky')))) {
    365         require_once('wpbb-reply-topic.php');
     375        require_once('reply-topic.php');
    366376    }
    367377
     
    375385        && (isset($_GET['current_page']))
    376386        && (count($_GET) == 3)) {
    377         require_once('wpbb-unread-topics.php');
     387        require_once('unread-topics.php');
    378388    }
    379389
     
    387397        && (isset($_GET['current_page']))
    388398        && (count($_GET) == 3)) {
    389         require_once('wpbb-unanswered-topics.php');
     399        require_once('unanswered-topics.php');
    390400    }
    391401   
    392402    // Not default or custom structure
    393403
    394 } else {
    395 
    396     if (count($_GET) == 0) {
    397         require_once('wpbb-index.php');
     404}
     405else
     406{
     407    if (count($_GET) == 0)
     408    {
     409        require_once('forum-index.php');
    398410    }
    399411
     
    405417        && (isset($_GET['current_page']))
    406418        && (count($_GET) == 2)) {
    407         require_once('wpbb-view-forum.php');
    408     }
    409 
    410 
    411 
     419        require_once('view-forum.php');
     420    }
     421   
    412422    /*
    413423        Viewing A Forum Topic
     
    418428        && (isset($_GET['current_page']))
    419429        && (count($_GET) == 3)) {
    420         require_once('wpbb-view-forum-topic.php');
     430        require_once('view-forum-topic.php');
    421431    }
    422432
     
    429439        && (isset($_GET['forum']) && isset($_GET['subforum']) || isset($_GET['forum']) && !isset($_GET['subforum']))
    430440        && (count($_GET) == 2 || count($_GET) == 3)) {
    431             require_once('wpbb-create-topic.php');
     441            require_once('create-topic.php');
    432442    }
    433443
     
    440450        && (isset($_GET['current_page']))
    441451        && (count($_GET) == 3)) {
    442         require_once('wpbb-view-subforum.php');
     452        require_once('view-subforum.php');
    443453    }
    444454
     
    453463        && (isset($_GET['current_page']))
    454464        && (count($_GET) == 4)) {
    455         require_once('wpbb-view-subforum-topic.php');
     465        require_once('view-subforum-topic.php');
    456466    }
    457467
     
    462472    if ((isset($_GET['profile']))
    463473        && (count($_GET) == 1)) {
    464         require_once('wpbb-view-profile.php');
     474        require_once('view-profile.php');
    465475    }
    466476
     
    474484        && (isset($_GET['current_page']))
    475485        && (count($_GET) == 2 || count($_GET) == 3)) {
    476         require_once('wpbb-all-messages.php');
     486        require_once('all-messages.php');
    477487    }
    478488   
     
    485495        && (isset($_GET['delete_msg']))
    486496        && (count($_GET) > 1 && count($_GET) <= 2)) {
    487         require_once('wpbb-delete-message.php');
     497        require_once('delete-message.php');
    488498    }
    489499    /*
     
    495505        && ((isset($_GET['view']))
    496506        && (count($_GET) == 2))) {
    497         require_once('wpbb-view-message.php');
     507        require_once('view-message.php');
    498508    }
    499509
     
    504514    if ((isset($_GET['message']))
    505515        && (count($_GET) == 1)) {
    506         require_once('wpbb-message-user.php');
     516        require_once('message-user.php');
    507517    }
    508518
     
    519529        && ($_GET['action'] != 'reply')
    520530        && ($_GET['action'] != 'sticky')))) {
    521         require_once('wpbb-edit-topic.php');
     531        require_once('edit-topic.php');
    522532    }
    523533
     
    534544        && ($_GET['action'] != 'reply')
    535545        && ($_GET['action'] != 'sticky')))) {
    536         require_once('wpbb-lock-topic.php');
     546        require_once('lock-topic.php');
    537547    }
    538548
     
    549559        && ($_GET['action'] != 'reply')
    550560        && ($_GET['action'] != 'edit')))) {
    551         require_once('wpbb-sticky-topic.php');
     561        require_once('sticky-topic.php');
    552562    }
    553563
     
    564574        && ($_GET['action'] != 'reply')
    565575        && ($_GET['action'] != 'sticky')))) {
    566         require_once('wpbb-delete-topic.php');
     576        require_once('delete-topic.php');
    567577    }
    568578
     
    574584        && (isset($_GET['topic']))
    575585        && ((isset($_GET['action'])
    576         && ($_GET['action'] == 'markread') 
     586        && ($_GET['action'] == 'markread')
    577587        && ($_GET['action'] != 'delete')
    578588        && ($_GET['action'] != 'lock')
     
    580590        && ($_GET['action'] != 'reply')
    581591        && ($_GET['action'] != 'sticky')))) {
    582         require_once('wpbb-markread-topic.php');
     592        require_once('markread-topic.php');
    583593    }
    584594
     
    596606        && ($_GET['action'] != 'edit')
    597607        && ($_GET['action'] != 'sticky')))) {
    598         require_once('wpbb-reply-topic.php');
     608        require_once('reply-topic.php');
    599609    }
    600610
     
    607617        && (isset($_GET['current_page']))
    608618        && (count($_GET) == 2)) {
    609         require_once('wpbb-unread-topics.php');
     619        require_once('unread-topics.php');
    610620    }
    611621
     
    618628        && (isset($_GET['current_page']))
    619629        && (count($_GET) == 2)) {
    620         require_once('wpbb-unanswered-topics.php');
     630        require_once('unanswered-topics.php');
    621631    }
    622632}
  • wp-bulletin-board/trunk/readme.txt

    r611368 r637712  
    33Donate link: http://codebycarter.x10.mx/wp/donate/
    44Tags: forum, bulletin board, twitter, facebook, discussion, discussion board, messaging, private message, topic, post, pagination, profile, subforum, wpbb
    5 Requires at least: 3.3
    6 Tested up to: 3.4.2
    7 Stable tag: 1.0.4
     5Requires at least: 3.0
     6Tested up to: 3.5
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1818
    1919= Features =
    20 * - Ease of Integration - WPBB creates a template file for your current template when you install or change your theme so you don't have to do anything. Everything can be managed from your admin area.
    21 * - Translatable - WPBB can easily be translated into your preferred language!
    22 * - Facebook registration - Allow your users to register on your Wordpress site via Facebook. This automatically creates a WP account for your Facebook users which they can then login to after authenticating.
    23 * - Twitter - Enter your twitter account in your settings and your users will be able to follow your website / personal account with the click of a button.
    24 * - Private Messaging System - Allow users to send messages to each other.
    25 * - Member Profiles - All your WP users are automatically  apart of your forum whenever you create it and have a "forum profile" which can be viewed on the forum which shows the users avatar, username, role, posts, website and signature. Signatures are apart of WPBB and allow your users to enter a signature which can be text or images and is displayed below their profile and posts.
    26 * - Categories, Forums, Sub forums - Organise your forums into categories and your sub forums into forums. There is no limit to the amount of forums its parent can have, and each are ordered by its appearance in its parent.
    27 * - Permissions system - Currently supports the ability to allow or disallow any role (even custom roles!) any specific permission (edit, view, read, post, reply, lock, delete, sticky). WPBB grabs all known roles from your WP site which you can set permissions for manually or copy existing permissions from a previous forum.
    28 * - Topics - If you have the permissions to do so you can edit, lock, delete, sticky, view, read, post or reply with a topic.
    29 * - Posts - You can edit and delete any post and the posts topic affects the posts status. You can create posts in two ways, creating a topic reply with presents the WP editor for improved formatting or you can use the quick reply feature (if it is enabled in your settings).
    30 * - Pagination System - Supports a simple pagination system which organises your topics and posts - you can set the max topics/posts per page in your wpbb settings.
    31 * - Unread Topics - WPBB collects a list of topics which have been posted when you were offline and displays them for you. You can mark any of them as read once you've read them.
    32 * - Unanswered Topics - Similar to the above feature, unanswered topics are ones which haven't yet received any replies.
    33 * - Admin area - The WPBB settings integrate with your existing WP admin area where you can easily manage your forums with ease. The WPBB overview allows you to change the order of a category, forum or sub forum, edit it and delete it with a single click. You can also create new categories, forums, sub forums and topics via the admin area.
    34 * - Settings - WPBB is jam packed with settings that you can use to customise the forum any way you want to.
     20* Compatibility - Fully compatible with 3.5, 3.4, 3.3, 3.2, 3.1 and 3.0
     21* Ease of Integration - WPBB works with any theme, you can change your theme anytime and WPBB will automatically update itself.
     22* Translatable - WPBB can easily be translated into your preferred language!
     23* Facebook registration - Allow your users to register on your Wordpress site via Facebook. This automatically creates a WP account for your Facebook users which they can then login to after authenticating.
     24* Twitter - Enter your twitter account in your settings and your users will be able to follow your website / personal account with the click of a button.
     25* Private Messaging System - Allow users to send messages to each other.
     26* Member Profiles - All your WP users are automatically  apart of your forum whenever you create it and have a "forum profile" which can be viewed on the forum which shows the users avatar, username, role, posts, website and signature. Signatures are apart of WPBB and allow your users to enter a signature which can be text or images and is displayed below their profile and posts.
     27* Categories, Forums, Sub forums - Organise your forums into categories and your sub forums into forums. There is no limit to the amount of forums its parent can have, and each are ordered by its appearance in its parent.
     28* Permissions system - Currently supports the ability to allow or disallow any role (even custom roles!) any specific permission (edit, view, read, post, reply, lock, delete, sticky). WPBB grabs all known roles from your WP site which you can set permissions for manually or copy existing permissions from a previous forum.
     29* Role Permissions - New in 1.1. Allows you to choose whether a role can only edit, lock, delete and sticky their own topics or everyones.
     30* Topics - If you have the permissions to do so you can edit, lock, delete, sticky, view, read, post or reply with a topic.
     31* Posts - You can edit and delete any post and the posts topic affects the posts status. You can create posts in two ways, creating a topic reply with presents the WP editor for improved formatting or you can use the quick reply feature (if it is enabled in your settings).
     32* Pagination System - Supports a simple pagination system which organises your topics and posts - you can set the max topics/posts per page in your wpbb settings.
     33* Unread Topics - WPBB collects a list of topics which have been posted when you were offline and displays them for you. You can mark any of them as read once you've read them.
     34* Unanswered Topics - Similar to the above feature, unanswered topics are ones which haven't yet received any replies.
     35* Admin area - The WPBB settings integrate with your existing WP admin area where you can easily manage your forums with ease. The WPBB overview allows you to change the order of a category, forum or sub forum, edit it and delete it with a single click. You can also create new categories, forums, sub forums and topics via the admin area.
     36* Settings - WPBB is jam packed with settings that you can use to customise the forum any way you want to.
     37* Tools - Tools help make your life easier. Tools such as updating your roles whenever you add, change or remove them and a tool to recreate the forum page if you ever accidentally delete it.
    3538
    36 And many more...
     39And much much more!
    3740
    3841== Installation ==
     
    6063Firstly always download the plugin again as the plugin is constantly updated. It is likely the problem you're having has been fixed already. If that doesn't work, create a topic here: http://wordpress.org/support/plugin/wp-bulletin-board
    6164
     65= How to Setup Facebook Integration =
     66
     671. https://developers.facebook.com/apps (register or login)
     682. "Create New App"
     693. Enter App Name, can be anything you want, don't worry about app namespace or web hosting. Click continue.
     704. Facebook should've created the app for you and you'll see at the top the name of your app and the default avatar, next to that there is your App ID and App Secret Key. Enter those into your WPBB facebook settings.
     715. You may want to enter a contact email and change any other settings to your liking but leave sandbox mode disabled and don't use the "Hosting URL"
     726. Click "Website with Facebook Login" under "Select how your app integrates with Facebook" then enter the URL to your wpbb forum e.g. http://mysite.com/wordpress/forum
     737. Save changes
     74
     75= When I edit and save my forum or subforum, there is an error =
     76
     77It is likely that you are updating a forum with roles that no longer exist. Go to your admin dashboard -> WPBB -> Tools -> Refresh Roles. Use this tool whenever you add, change or remove roles. Roles are like the ranks or capabilities that users have, e.g. subscriber, author, administrator, etc.
     78
    6279== Screenshots ==
    6380
     
    7188
    7289== Changelog ==
     90
     91= 1.1.0 =
     92* Role permissions added which allow you to set whether a role can edit, lock, delete or sticky only their own topics or posts or everyones.
     93* Now compatible with wordpress versions 3.0, 3.1, 3.2, 3.3 and 3.5
     94* Fixes error in topic post editor
     95* (un)read topics are now used per user instead of globally as it should be
     96* Removed unneccessary forum prefix setting as you can include 'forum' in your own title
     97* Fixed post count not changing when deleting topics and/or posts and when editing topics and posts.
     98* Fixes a number of bugs translators encountered when trying to translate wpbb
     99* Clicking the search box now clears the textbox, more javascript will be added in the future for those that use it
     100* Added useful descriptions next to all the settings in the wpbb settings.
     101* New tool added which allows you to recreate your forums page if it was accidentally deleted or didn't create for some reason
     102* Last post/reply will now take you to that topic or post
     103* You can no longer create empty topics, posts or messages or give them empty titles
     104* You can now go straight to your newly created topic or post when creating a topic or reply.
     105* Updated FAQ
     106* Minor bug fixes and typos fixed.
    73107
    74108= 1.0.4 =
  • wp-bulletin-board/trunk/wp-bb.php

    r611368 r637712  
    44    Plugin URI: http://wordpress.org/extend/plugins/wp-bulletin-board/
    55    Description: An easy to use Bulletin board for Wordpress with Facebook and Twitter integration.
    6     Version: 1.0.4
     6    Version: 1.1.0
    77    Author: Jay Carter
    88    Author URI: http://codebycarter.com
     
    2929
    3030// Sets the default timezone used by all date/time functions in a script depending on server configuration option
    31 if (ini_get('date.timezone.')) {
     31if (ini_get('date.timezone.'))
     32{
    3233    $timezone = ini_get('date.timezone');
    3334    date_default_timezone_set($timezone);
     
    3536
    3637// Define wpbb plugin directory
    37 define('WPBB_DIR', plugin_dir_path(__FILE__));
     38if (!defined('WPBB_DIR'))
     39{
     40    define('WPBB_DIR', plugin_dir_path(__FILE__));
     41}
    3842// Contains categories, forums and subforums
    39 define('CATEGORY_TABLE', $wpdb->prefix.'wpbb_categories');
     43if (!defined('CATEGORY_TABLE'))
     44{
     45    define('CATEGORY_TABLE', $wpdb->prefix.'wpbb_categories');
     46}
    4047// Contains all topics whether in a category, forum or subforum
    41 define('TOPICS_TABLE', $wpdb->prefix.'wpbb_topics');
     48if (!defined('TOPICS_TABLE'))
     49{
     50    define('TOPICS_TABLE', $wpdb->prefix.'wpbb_topics');
     51}
    4252// Contains all posts inside a specific topic
    43 define('POSTS_TABLE', $wpdb->prefix.'wpbb_posts');
     53if (!defined('POSTS_TABLE'))
     54{
     55    define('POSTS_TABLE', $wpdb->prefix.'wpbb_posts');
     56}
    4457// Contains all user messages
    45 define('MESSAGE_TABLE', $wpdb->prefix.'wpbb_messages');
     58if (!defined('MESSAGE_TABLE'))
     59{
     60    define('MESSAGE_TABLE', $wpdb->prefix.'wpbb_messages');
     61}
     62// Contains all topics for each user and whether they are read or not
     63if (!defined('UNREAD_TABLE'))
     64{
     65    define('UNREAD_TABLE', $wpdb->prefix.'wpbb_topics_unread');
     66}
    4667// Define current version
    47 define('WPBB_VERSION', 'v1.0.4');
     68if (!defined('WPBB_VERSION'))
     69{
     70    define('WPBB_VERSION', 'v1.1.0');
     71}
    4872// Define plugin url (wp plugin page)
    49 define('WPBB_PLUGIN_URL', 'http://wordpress.org/support/plugin/wp-bulletin-board');
     73if (!defined('WPBB_PLUGIN_URL'))
     74{
     75    define('WPBB_PLUGIN_URL', 'http://wordpress.org/support/plugin/wp-bulletin-board');
     76}
    5077
    5178/*
     
    5380*/
    5481
    55 function wpbb_load_language() {
    56     load_plugin_textdomain('wp-bb', false, dirname(plugin_basename(__FILE__)).'/languages/');
    57 }
    5882add_action('plugins_loaded', 'wpbb_load_language');
     83
     84if (!function_exists('wpbb_load_language'))
     85{
     86    function wpbb_load_language()
     87    {
     88        load_plugin_textdomain('wp-bb', false, dirname(plugin_basename(__FILE__)).'/languages/');
     89    }
     90}
    5991
    6092/*
     
    75107add_action('wp_enqueue_scripts', 'wpbb_register_styles');
    76108
     109$options = get_option('wpbb_options');
     110if ($options['post_to_forum'] == 'yes')
     111{
     112    add_action('add_meta_boxes', 'wpbb_create_metaboxes'); // Metaboxes
     113    add_action('save_post', 'wpbb_post_saved'); // Wordpress post saved
     114}
     115
    77116/*
    78117    All WPBB Admin (Non Page or DB related) Functions
     
    81120*/
    82121
    83 require_once('php/admin/wpbb-admin-functions.php');
     122require_once('php/admin/admin-functions.php');
    84123
    85124/*
     
    87126*/
    88127
    89 function wpbb_activate() {
    90     // Create all neccessary database tables
    91     wpbb_create_db_table();
    92     // Create options in DB for our settings
    93     wpbb_create_options();
    94     // Create the user meta for all users currently registered
    95     wpbb_setup_user_meta();
    96     // Creates the Forum page
    97     wpbb_create_page();
     128if (!function_exists('wpbb_activate'))
     129{
     130    function wpbb_activate()
     131    {
     132        // Create all neccessary database tables
     133        wpbb_create_db_table();
     134        // Create options in DB for our settings
     135        wpbb_create_options();
     136        // Create the user meta for all users currently registered
     137        wpbb_setup_user_meta();
     138        // Creates the Forum page
     139        wpbb_create_page();
     140    }
    98141}
    99142
     
    102145*/
    103146
    104 function wpbb_uninstall() {
    105     global $wpdb;
    106     // Delete main options from database
    107     delete_option('wpbb_options');
    108     // Delete theme options
    109     delete_option('wpbb_theme_options');
    110     // Delete facebook options
    111     delete_option('wpbb_facebook_options');
    112     // Delete twitter options
    113     delete_option('wpbb_twitter_options');
    114     // Delete guest options
    115     delete_option('wpbb_guest_options');
    116     // Delete the user meta
    117     wpbb_delete_user_meta();
    118     // Delete post meta (this function is in wpbb-functions.php as the page is created in wpbb-forum.php)
    119     wpbb_delete_post_meta();
    120     // Delete database tables
    121     $wpdb->query("DROP TABLE ".CATEGORY_TABLE.", ".TOPICS_TABLE.", ".POSTS_TABLE.", ".MESSAGE_TABLE.";");
    122 }
    123 
    124 function wpbb_delete_user_meta() {
    125     global $wpdb;
    126     $delete_user_meta = $wpdb->query("DELETE FROM ".$wpdb->prefix."usermeta WHERE meta_key LIKE 'wpbb_%';");
    127 }
    128 
    129 function wpbb_delete_post_meta() {
    130     global $wpdb;
    131     $post_meta = $wpdb->prefix.'postmeta';
    132     $key = '_wp_page_template';
    133     $value = 'wpbb-template.php';
    134     $post_id = $wpdb->get_var("SELECT post_id FROM $post_meta WHERE meta_key = '$key' AND meta_value = '$value';");
    135     // Delete the meta data
    136     delete_post_meta($post_id, $key, $value);
    137     // Delete the page
    138     wp_delete_post($post_id, true);
     147if (!function_exists('wpbb_uninstall'))
     148{
     149    function wpbb_uninstall()
     150    {
     151        global $wpdb;
     152        delete_option('wpbb_options');
     153        delete_option('wpbb_theme_options');
     154        delete_option('wpbb_facebook_options');
     155        delete_option('wpbb_twitter_options');
     156        delete_option('wpbb_guest_options');
     157        wpbb_delete_user_meta();
     158        wpbb_delete_post_meta();
     159        $wpdb->query("DROP TABLE ".CATEGORY_TABLE.", ".TOPICS_TABLE.", ".POSTS_TABLE.", ".MESSAGE_TABLE.", ".UNREAD_TABLE.";");
     160    }
     161}
     162
     163if (!function_exists('wpbb_delete_user_meta'))
     164{
     165    function wpbb_delete_user_meta()
     166    {
     167        global $wpdb;
     168        $delete_user_meta = $wpdb->query("DELETE FROM ".$wpdb->prefix."usermeta WHERE meta_key LIKE 'wpbb_%';");
     169    }
     170}
     171
     172if (!function_exists('wpbb_delete_post_meta'))
     173{
     174    function wpbb_delete_post_meta()
     175    {
     176        global $wpdb;
     177        $post_meta = $wpdb->prefix.'postmeta';
     178        $key = '_wp_page_template';
     179        $value = 'wpbb-template.php';
     180        $post_id = $wpdb->get_var("SELECT post_id FROM $post_meta WHERE meta_key = '$key' AND meta_value = '$value';");
     181        // Delete the meta data
     182        delete_post_meta($post_id, $key, $value);
     183        // Delete the page
     184        wp_delete_post($post_id, true);
     185    }
    139186}
    140187
     
    143190*/
    144191
    145 function wpbb_create_db_table() {
    146 
    147     global $wpdb;
    148    
    149     $options = get_option('wpbb_options');
    150    
    151     // This is not being activated the first time
    152     //if (isset($options['version']) && $options['version'] != WPBB_VERSION) {
    153     if ($options) {
    154    
    155         wpbb_refresh_roles();
    156        
    157     } else {
    158        
     192if (!function_exists('wpbb_create_db_table'))
     193{
     194    function wpbb_create_db_table()
     195    {
     196        global $wpdb;
     197        $options = get_option('wpbb_options');
     198        if ($options)
     199        {
     200            wpbb_refresh_roles();
     201        }
    159202        $roles = wpbb_admin_get_all_roles('string', true);
    160    
    161203        $perms = "SET($roles) NOT NULL";
    162        
    163204        $create_category_query = "CREATE TABLE ".CATEGORY_TABLE." (
    164205            `id` TINYINT(1) UNSIGNED NOT NULL AUTO_INCREMENT,
    165             `name` VARCHAR(25) NOT NULL,
     206            `name` VARCHAR(30) NOT NULL,
    166207            `description` VARCHAR(200) NOT NULL,
    167208            `forum` TINYINT(1) NOT NULL,
     
    183224            `id` INT(1) NOT NULL AUTO_INCREMENT,
    184225            `author` SMALLINT(1) NOT NULL,
    185             `name` VARCHAR(25) NOT NULL,
     226            `name` VARCHAR(35) NOT NULL,
    186227            `content` TEXT NULL,
    187228            `forum` TINYINT(1) NOT NULL,
     
    215256            ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
    216257        ";
     258   
     259        $create_topic_unread_query = "CREATE TABLE ".UNREAD_TABLE." (
     260            `id` INT(1) NOT NULL,
     261            `author` INT(1) NOT NULL,
     262            `read` INT(1) NOT NULL
     263            ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
     264        ";
    217265     
    218266        $create_category_table = $wpdb->query($create_category_query);
     
    220268        $create_post_table = $wpdb->query($create_post_query);
    221269        $create_message_table = $wpdb->query($create_messages_query);
     270        $create_topic_unread_table = $wpdb->query($create_topic_unread_query);
    222271   
    223         if ($create_category_table === false) {
     272        if ($create_category_table === false)
     273        {
    224274            $create_category_table_err = __('There was an error creating the table wpbb_categorie', 'wp-bb');
    225             error_log($create_category_table_err);
     275            error_log($create_category_table_err);
    226276        }
    227         if ($create_topic_table === false) {
     277        if ($create_topic_table === false)
     278        {
    228279            $create_topic_table_err = __('There was an error creating the table wpbb_topics', 'wp-bb');
    229280            error_log($create_topic_table_err);
    230281        }
    231         if ($create_post_table === false) {
     282        if ($create_post_table === false)
     283        {
    232284            $create_post_table_err = __('There was an error creating the table wpbb_posts', 'wp-bb');
    233285            error_log($create_post_table_err);
    234286        }
    235         if ($create_message_table === false) {
     287        if ($create_message_table === false)
     288        {
    236289            $create_message_table_err = __('There was an error creating the table wpbb_messages', 'wp-bb');
    237290            error_log($create_message_table_err);
    238291        }
     292        if ($create_topic_unread_table === false)
     293        {
     294            $create_topic_unread_table_err = __('There was an error creating the table wpbb_topics_unread', 'wp-bb');
     295            error_log($create_topic_unread_table_err);
     296        }
    239297    }
    240298}
     
    244302*/
    245303
    246 function wpbb_create_options() {
    247     // Retrieve options from database
    248     $old_options = get_option('wpbb_options');
    249     // If options do not exist
    250     if (!$old_options) {
    251         $maintenance_message = __('This is the message that will be displayed to users when you disable the board. Edit this in your settings.', 'wp-bb');
    252         $forum_name = __('My WPBB Forum', 'wp-bb');
    253         $options = array(
    254             'maintenance_mode' => 'off',
    255             'maintenance_message' => $maintenance_message,
    256             'forum_name' => $forum_name,
    257             'forum_prefix' => 'no',
    258             'allow_guests' => 'yes',
    259             'allow_subforums' => 'yes',
    260             'enable_quick_reply' => 'yes',
    261             'topics_per_page' => 20,
    262             'posts_per_page' => 20,
    263             'topic_cutoff' => 15,
    264             'post_cutoff' => 15,
    265             'post_to_forum' => 'yes',
    266             'show_footer' => 'no',
    267             'version' => WPBB_VERSION
    268         );
    269         $add_wpbb_options = add_option('wpbb_options', $options);
    270     } else {
    271         if (!isset($old_options['version'])) {
    272             // Attempting to update a key in the options value will remove all the other keys so we must
    273             // set all the other keys as well
     304if (!function_exists('wpbb_create_options'))
     305{
     306    function wpbb_create_options()
     307    {
     308        // Retrieve options from database
     309        $old_options = get_option('wpbb_options');
     310        /*
     311        *   Add all current roles to an array with a default value of 'yes'
     312        *   This is for our role permissions
     313        */
     314        $roles = wpbb_admin_get_all_roles();
     315        $role_array = array();
     316        if ($roles)
     317        {
     318            foreach ($roles as $role)
     319            {
     320                $role_array[$role] = 'yes';
     321            }
     322        }
     323        // If options do not exist
     324        if (!$old_options)
     325        {
     326            $maintenance_message = __('This is the message that will be displayed to users when you disable the board. Edit this in your settings.', 'wp-bb');
     327            $forum_name = __('My WPBB Forum', 'wp-bb');
    274328            $options = array(
    275                 'maintenance_mode' => $old_options['maintenance_mode'],
    276                 'maintenance_message' => $old_options['maintenance_message'],
    277                 'forum_name' => $old_options['forum_name'],
    278                 'forum_prefix' => $old_options['forum_prefix'],
    279                 'allow_guests' => $old_options['allow_guests'],
    280                 'allow_subforums' => $old_options['allow_subforums'],
    281                 'enable_quick_reply' => $old_options['enable_quick_reply'],
    282                 'topics_per_page' => $old_options['topics_per_page'],
    283                 'posts_per_page' => $old_options['posts_per_page'],
    284                 'topic_cutoff' => $old_options['topic_cutoff'],
    285                 'post_cutoff' => $old_options['post_cutoff'],
    286                 'post_to_forum' => $old_options['post_to_forum'],
    287                 'show_footer' => $old_options['show_footer'],
     329                'maintenance_mode' => 'off',
     330                'maintenance_message' => $maintenance_message,
     331                'forum_name' => $forum_name,
     332                'allow_guests' => 'yes',
     333                'allow_subforums' => 'yes',
     334                'enable_quick_reply' => 'yes',
     335                'topics_per_page' => 20,
     336                'posts_per_page' => 20,
     337                'topic_cutoff' => 15,
     338                'post_cutoff' => 15,
     339                'post_to_forum' => 'yes',
     340                'show_footer' => 'no',
     341                'role_permissions' => $role_array,
    288342                'version' => WPBB_VERSION
    289343            );
    290             update_option('wpbb_options', $options);
    291         }
    292     }
    293     /* Theme Options */
    294     $old_theme_options = get_option('wpbb_theme_options');
    295     if (!$old_theme_options) {
    296         $add_wpbb_theme_options = add_option('wpbb_theme_options', array('theme' => 'light'));
    297     }
    298     /* Facebook Options */
    299     $old_facebook_options = get_option('wpbb_facebook_options');
    300     if (!$old_facebook_options) {
    301         $facebook_app_id = __('Enter your Facebook App ID / API Key', 'wp-bb');
    302         $facebook_app_secret_key = __('Enter your App Secret Key', 'wp-bb');
    303         $facebook_redirect_uri = __('Enter your URL (Redirect URL)', 'wp-bb');
    304         $facebook_state = __('Enter a long random string', 'wp-bb');
    305         $facebook_role = __('Enter the default role for new facebook registrations');
    306         $facebook_options = array(
    307             'allow_facebook' => 'no',
    308             'facebook_app_id' => $facebook_app_id,
    309             'facebook_app_secret_key' => $facebook_app_secret_key,
    310             'facebook_redirect_uri' => $facebook_redirect_uri,
    311             'facebook_state' => $facebook_state,
    312             'facebook_default_role' => $facebook_role
    313         );
    314         $add_wpbb_facebook_options = add_option('wpbb_facebook_options', $facebook_options);
    315     }
    316     /* Twitter Options */
    317     $old_twitter_options = get_option('wpbb_twitter_options');
    318     if (!$old_twitter_options) {
    319         $twitter_account = __('Enter your website/personal Twitter Account', 'wp-bb');
    320         $twitter_options = array(
    321             'allow_twitter' => 'no',
    322             'twitter_account' => $twitter_account
    323         );
    324         $add_wpbb_twitter_options = add_option('wpbb_twitter_options', $twitter_options);
    325     }
    326     $old_guest_options = get_option('wpbb_guest_options');
    327     if (!$old_guest_options) {
    328         $guest_options = array(
    329             'guest_last_post' => '0000-00-00 00:00:00'
    330         );
    331         $add_wpbb_guest_options = add_option('wpbb_guest_options', $guest_options);
     344            $add_wpbb_options = add_option('wpbb_options', $options);
     345        }
     346        else
     347        {
     348            if (!isset($old_options['version']))
     349            {
     350                $options = array(
     351                    'maintenance_mode' => $old_options['maintenance_mode'],
     352                    'maintenance_message' => $old_options['maintenance_message'],
     353                    'forum_name' => $old_options['forum_name'],
     354                    'allow_guests' => $old_options['allow_guests'],
     355                    'allow_subforums' => $old_options['allow_subforums'],
     356                    'enable_quick_reply' => $old_options['enable_quick_reply'],
     357                    'topics_per_page' => $old_options['topics_per_page'],
     358                    'posts_per_page' => $old_options['posts_per_page'],
     359                    'topic_cutoff' => $old_options['topic_cutoff'],
     360                    'post_cutoff' => $old_options['post_cutoff'],
     361                    'post_to_forum' => $old_options['post_to_forum'],
     362                    'show_footer' => $old_options['show_footer'],
     363                    'role_permissions' => $role_array,
     364                    'version' => WPBB_VERSION
     365                );
     366                update_option('wpbb_options', $options);
     367            }
     368        }
     369        /* Theme Options */
     370        $old_theme_options = get_option('wpbb_theme_options');
     371        if (!$old_theme_options)
     372        {
     373            $add_wpbb_theme_options = add_option('wpbb_theme_options', array('theme' => 'light'));
     374        }
     375        /* Facebook Options */
     376        $old_facebook_options = get_option('wpbb_facebook_options');
     377        if (!$old_facebook_options) {
     378            $facebook_app_id = __('Enter your Facebook App ID / API Key', 'wp-bb');
     379            $facebook_app_secret_key = __('Enter your App Secret Key', 'wp-bb');
     380            $facebook_redirect_uri = __('Enter your URL (Redirect URL)', 'wp-bb');
     381            $facebook_state = __('Enter a long random string', 'wp-bb');
     382            $facebook_role = __('Enter the default role for new facebook registrations');
     383            $facebook_options = array(
     384                'allow_facebook' => 'no',
     385                'facebook_app_id' => $facebook_app_id,
     386                'facebook_app_secret_key' => $facebook_app_secret_key,
     387                'facebook_redirect_uri' => $facebook_redirect_uri,
     388                'facebook_state' => $facebook_state,
     389                'facebook_default_role' => $facebook_role
     390            );
     391            $add_wpbb_facebook_options = add_option('wpbb_facebook_options', $facebook_options);
     392        }
     393        /* Twitter Options */
     394        $old_twitter_options = get_option('wpbb_twitter_options');
     395        if (!$old_twitter_options)
     396        {
     397            $twitter_account = __('Enter your website/personal Twitter Account', 'wp-bb');
     398            $twitter_options = array(
     399                'allow_twitter' => 'no',
     400                'twitter_account' => $twitter_account
     401            );
     402            $add_wpbb_twitter_options = add_option('wpbb_twitter_options', $twitter_options);
     403        }
     404        $old_guest_options = get_option('wpbb_guest_options');
     405        if (!$old_guest_options)
     406        {
     407            $guest_options = array(
     408                'guest_last_post' => '0000-00-00 00:00:00'
     409            );
     410            $add_wpbb_guest_options = add_option('wpbb_guest_options', $guest_options);
     411        }
    332412    }
    333413}
     
    337417*/
    338418
    339 function wpbb_admin_pages() {
    340    
    341     $create_category = __('Create Category', 'wp-bb');
    342     $create_forum = __('Create Forum', 'wp-bb');
    343     $create_subforum = __('Create Subforum', 'wp-bb');
    344     $create_topic = __('Create Topic', 'wp-bb');
    345     $create_tools = __('Tools', 'wp-bb');
    346     $faq_support = __('FAQ & Support', 'wp-bb');
    347     $settings = __('WPBB Settings', 'wp-bb');
    348 
    349     // Main WPBB page
    350     add_menu_page('WPBB Overview', 'WPBB', 'manage_options', 'wpbb_admin', 'wpbb_admin_display', '', 26);
    351    
    352     // Create/Edit Category
    353     add_submenu_page('wpbb_admin', 'WPBB Categories', $create_category, 'manage_options', 'wpbb_admin_categories', 'wpbb_admin_categories');
    354    
    355     // Create/Edit Forum
    356     add_submenu_page('wpbb_admin', 'WPBB Forums', $create_forum, 'manage_options', 'wpbb_admin_forums', 'wpbb_admin_forums');
    357    
    358     // Create/Edit Subforum
    359     add_submenu_page('wpbb_admin', 'WPBB Subforums', $create_subforum, 'manage_options', 'wpbb_admin_subforums', 'wpbb_admin_subforums');
    360    
    361     // Create/Edit Topics
    362     add_submenu_page('wpbb_admin', 'WPBB Topics', $create_topic, 'manage_options', 'wpbb_admin_topics', 'wpbb_admin_topics');
    363    
    364     // Create Tools page
    365     add_submenu_page('wpbb_admin', 'WPBB Tools', $create_tools, 'manage_options', 'wpbb_admin_tools', 'wpbb_admin_tools');
    366    
    367     // FAQ / First Installation Page
    368     add_submenu_page('wpbb_admin', 'FAQ / Support', $faq_support, 'manage_options', 'wpbb_admin_help', 'wpbb_admin_help');
    369    
    370     // WPBB Settings
    371     add_options_page('WPBB Settings', $settings, 'manage_options', 'wpbb_settings_page', 'wpbb_display_settings');
    372 }
    373 
    374 function wpbb_create_template_file() {
    375     // Get current theme directory
    376     $template_directory = get_template_directory();
    377     // Check if required template file doesn't exist and if true create it
    378     if (!file_exists($template_directory.'/wpbb-template.php')) {
    379         // Check directory is writable
    380         if (is_writable($template_directory)) {
    381             // Copys wp-bb template file to your current theme
    382             $template_file_path = WPBB_DIR.'/wpbb-template.php';
    383             $move_template_file = copy($template_file_path, $template_directory.'/wpbb-template.php');
    384             if (!$move_template_file) {
    385                 $move_template_file_failed = sprintf(__('Failed to move required wp-bb template file %s to theme directory %s. Please make sure both the file and directory exist or move the wp-bb template file to your current theme directory manually'), $template_file_path, $template_directory);
    386                 error_log($move_template_file_failed);
     419if (!function_exists('wpbb_admin_pages'))
     420{
     421    function wpbb_admin_pages()
     422    {
     423        $create_category = __('Create Category', 'wp-bb');
     424        $create_forum = __('Create Forum', 'wp-bb');
     425        $create_subforum = __('Create Subforum', 'wp-bb');
     426        $create_topic = __('Create Topic', 'wp-bb');
     427        $role_permissions = __('Role Permissions', 'wp-bb');
     428        $create_tools = __('Tools', 'wp-bb');
     429        $faq_support = __('FAQ & Support', 'wp-bb');
     430        $settings = __('WPBB Settings', 'wp-bb');
     431
     432        // Main WPBB page
     433        add_menu_page('WPBB Overview', 'WPBB', 'manage_options', 'wpbb_admin', 'wpbb_admin_display', '', 27.7);
     434   
     435        // Create/Edit Category
     436        add_submenu_page('wpbb_admin', 'WPBB Categories', $create_category, 'manage_options', 'wpbb_admin_categories', 'wpbb_admin_categories');
     437   
     438        // Create/Edit Forum
     439        add_submenu_page('wpbb_admin', 'WPBB Forums', $create_forum, 'manage_options', 'wpbb_admin_forums', 'wpbb_admin_forums');
     440   
     441        // Create/Edit Subforum
     442        add_submenu_page('wpbb_admin', 'WPBB Subforums', $create_subforum, 'manage_options', 'wpbb_admin_subforums', 'wpbb_admin_subforums');
     443   
     444        // Create/Edit Topics
     445        add_submenu_page('wpbb_admin', 'WPBB Topics', $create_topic, 'manage_options', 'wpbb_admin_topics', 'wpbb_admin_topics');
     446       
     447        // Role permissions
     448        add_submenu_page('wpbb_admin', 'Role Permissions', $role_permissions, 'manage_options', 'wpbb_admin_role_permissions', 'wpbb_admin_role_permissions');
     449   
     450        // Create Tools page
     451        add_submenu_page('wpbb_admin', 'WPBB Tools', $create_tools, 'manage_options', 'wpbb_admin_tools', 'wpbb_admin_tools');
     452   
     453        // FAQ / First Installation Page
     454        add_submenu_page('wpbb_admin', 'FAQ / Support', $faq_support, 'manage_options', 'wpbb_admin_help', 'wpbb_admin_help');
     455       
     456        // Shortcut to WPBB settings - some people don't know they exist
     457        add_submenu_page('wpbb_admin', 'WPBB Settings', $settings, 'manage_options', 'wpbb_settings_page', 'wpbb_display_settings');
     458   
     459        // WPBB Settings
     460        add_options_page('WPBB Settings', $settings, 'manage_options', 'wpbb_settings_page', 'wpbb_display_settings');
     461    }
     462}
     463
     464
     465if (!function_exists('wpbb_create_template_file'))
     466{
     467    function wpbb_create_template_file()
     468    {
     469        // Get current theme directory
     470        $template_directory = get_template_directory();
     471        // Check if required template file doesn't exist and if true create it
     472        if (!file_exists($template_directory.'/wpbb-template.php'))
     473        {
     474            // Check directory is writable
     475            if (is_writable($template_directory))
     476            {
     477                // Copys wp-bb template file to your current theme
     478                $template_file_path = WPBB_DIR.'/wpbb-template.php';
     479                $move_template_file = copy($template_file_path, $template_directory.'/wpbb-template.php');
     480                if (!$move_template_file)
     481                {
     482                    $move_template_file_failed = sprintf(__('Failed to move required wp-bb template file %s to theme directory %s. Please make sure both the file and directory exist or move the wp-bb template file to your current theme directory manually'), $template_file_path, $template_directory);
     483                    error_log($move_template_file_failed);
     484                }
    387485            }
    388         } else { // Is not writable and user should change permissions accordingly
    389             $template_write_failed = sprintf(__('%s is not writable. Could not create required WPBB template file forum.php. Please change the folders permissions and visit your Wordpress site again or copy the file forum.php from your wp-bb plugin folder to your template folders directory manually.'), $template_directory);
    390             error_log($template_write_failed);
    391         }
    392     }
    393 }
    394 
    395 function wpbb_create_page() {
    396     // Check the page doesn't already exist (e.g. when reactivating)
    397     global $wpdb;
    398     $post_meta = $wpdb->prefix.'postmeta';
    399     $post_id = $wpdb->get_var("SELECT post_id FROM $post_meta WHERE meta_key = '_wp_page_template' AND meta_value = 'wpbb-template.php';");
    400     if ($post_id == NULL) {
    401         $wpbb_page_title = __('Forums', 'wp-bb');
    402         $link = site_url().'/'.strtolower($wpbb_page_title);
    403         $page = array(
    404             'post_status' => 'publish',
    405             'post_title' => $wpbb_page_title,
    406             'comment_status' => 'closed',
    407             'post_type' => 'page'
    408         );
    409         global $forum_page;
    410         $forum_page = wp_insert_post($page, false);
    411         add_post_meta($forum_page, '_wp_page_template', 'wpbb-template.php', true);
    412     }
    413     // This function checks if the template file exists before doing anything
    414     $template = wpbb_create_template_file();
    415 }
    416 
    417 function wpbb_register_styles() {
    418     $wpbb_theme_options = get_option('wpbb_theme_options');
    419     if ($wpbb_theme_options['theme'] == 'light') {
    420         wp_register_style('wpbb-light-style', plugins_url('wp-bulletin-board/css/wpbb-light-style.css'));
    421         wp_enqueue_style('wpbb-light-style');
    422     } else {
    423         wp_register_style('wpbb-dark-style', plugins_url('wp-bulletin-board/css/wpbb-dark-style.css'));
    424         wp_enqueue_style('wpbb-dark-style');
     486            else
     487            {
     488                // Is not writable and user should change permissions accordingly
     489                $template_write_failed = sprintf(__('%s is not writable. Could not create required WPBB template file forum.php. Please change the folders permissions and visit your Wordpress site again or copy the file forum.php from your wp-bb plugin folder to your template folders directory manually.'), $template_directory);
     490                error_log($template_write_failed);
     491            }
     492        }
     493    }
     494}
     495
     496if (!function_exists('wpbb_create_page'))
     497{
     498    function wpbb_create_page()
     499    {
     500        // Check the page doesn't already exist (e.g. when reactivating)
     501        global $wpdb;
     502        $post_meta = $wpdb->prefix.'postmeta';
     503        $post_id = $wpdb->get_var("SELECT post_id FROM $post_meta WHERE meta_key = '_wp_page_template' AND meta_value = 'wpbb-template.php';");
     504        if ($post_id == NULL)
     505        {
     506            $wpbb_page_title = __('Forums', 'wp-bb');
     507            $link = site_url().'/'.strtolower($wpbb_page_title);
     508            $page = array(
     509                'post_status' => 'publish',
     510                'post_title' => $wpbb_page_title,
     511                'comment_status' => 'closed',
     512                'post_type' => 'page'
     513            );
     514            global $forum_page;
     515            $forum_page = wp_insert_post($page, false);
     516            add_post_meta($forum_page, '_wp_page_template', 'wpbb-template.php', true);
     517        }
     518        // This function checks if the template file exists before doing anything
     519        $template = wpbb_create_template_file();
     520    }
     521}
     522
     523/*
     524    Wordpress post metaboxes
     525*/
     526
     527if (!function_exists('wpbb_post_saved'))
     528{
     529    function wpbb_post_saved($_post_id)
     530    {
     531        if (wp_is_post_revision($_post_id))
     532        {
     533            return;
     534        }
     535        static $first = true;
     536        if (!$first) return;
     537        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
     538        {
     539            return;
     540        }
     541        $post_metabox_nonce = isset($_POST['wpbb-post-metabox-nonce']);
     542        if (!wp_verify_nonce($post_metabox_nonce, plugin_basename(__FILE__)))
     543        {
     544            return;
     545        }
     546        $_post_type = isset($_POST['post_type']);
     547        if ('post' == $_post_type)
     548        {
     549            if (!current_user_can('edit_page', $_post_id))
     550            {
     551                return;
     552            }
     553        }
     554        $post_id = absint($_post_id);
     555        $post_data = get_post($post_id, ARRAY_A);
     556        $post_to_forum_id = NULL;
     557        if (isset($_POST['wpbb-post-to-forum']))
     558        {
     559            $post_to_forum_id = absint($_POST['wpbb-post-to-forum']);
     560        }
     561        if ($post_to_forum_id == NULL)
     562        {
     563            error_log(__('When copying the post to a WPBB forum, the wpbb-post-to-forum was NULL - a forum ID wasn\'t provided'));
     564        }
     565        $is_forum = NULL;
     566        $is_subforum = NULL;
     567        global $wpdb;
     568        // Check to see if this forum is a forum or a subforum
     569        $forum_or_subforum = $wpdb->get_results("SELECT `forum`, `subforum` FROM ".CATEGORY_TABLE." WHERE id = $post_to_forum_id;");
     570        if ($forum_or_subforum)
     571        {
     572            foreach ($forum_or_subforum as $forum)
     573            {
     574                if ($forum->forum > 0 && $forum->subforum == 0)
     575                {
     576                    // Forum
     577                    $is_forum = true;
     578                    $is_subforum = false;
     579                }
     580                else if ($forum->subforum > 0 && $forum->forum == 0)
     581                {
     582                    // Subforum
     583                    $is_subforum = true;
     584                    $is_forum = false;
     585                }
     586            }
     587        }
     588        if ($post_data)
     589        {
     590            $forum_id = ($is_forum) ? $post_to_forum_id : 0;
     591            $subforum_id = ($is_subforum) ? $post_to_forum_id : 0;
     592            $data = array(
     593                'name' => $post_data['post_title'],
     594                'author' => $post_data['post_author'],
     595                'content' => $post_data['post_content'],
     596                'forum' => $forum_id,
     597                'subforum' => $subforum_id,
     598                'status' => '',
     599                'created' => $post_data['post_date'],
     600                'last_reply' => $post_data['post_date']
     601            );
     602            $copy_post_to_forum = $wpdb->insert(TOPICS_TABLE, $data);
     603            if ($copy_post_to_forum === false)
     604            {
     605                error_log(__('Failed to copy the wordpress post to the wpbb forum', 'wp-bb'));
     606            }
     607            else
     608            {
     609                // Update authors post count
     610                wpbb_admin_update_user_meta($post_data['post_author'], 'increase');
     611                $first = false;
     612            }
     613        }
     614    }
     615}
     616
     617if (!function_exists('wpbb_display_metaboxes'))
     618{
     619    function wpbb_display_metaboxes()
     620    {
     621        global $wpdb;
     622        wp_nonce_field(plugin_basename(__FILE__), 'wpbb-post-metabox-nonce');
     623        ?>
     624        <div id="minor-publishing-actions">
     625            <p class="description">Send a copy of this post to one of your WPBB forums or subforums or check "None" or disable this in your WPBB Settings</p>
     626            <select name="wpbb-post-to-forum">
     627                <!-- Default -->
     628                <option value="0">None</option>
     629                <?php
     630                // All forums and subforums
     631                $forums = $wpdb->get_results("SELECT `id`, `name` FROM ".CATEGORY_TABLE." WHERE forum > 0 || subforum > 0;");
     632                if ($forums)
     633                {
     634                    foreach ($forums as $forum)
     635                    {
     636                        ?>
     637                        <option value="<?php echo $forum->id; ?>"><?php echo $forum->name;?></option>
     638                        <?php
     639                    }
     640                }
     641                ?>
     642            </select>
     643        </div>
     644        <?php
     645    }
     646}
     647
     648if (!function_exists('wpbb_create_metaboxes'))
     649{
     650    function wpbb_create_metaboxes()
     651    {
     652        add_meta_box('wpbb-post-to-forum-meta-box', __('Post to WPBB Forum', 'wp-bb'), 'wpbb_display_metaboxes', 'post', 'side', 'high', NULL);
     653    }
     654}
     655
     656/*
     657    Register and loads the style and javascript files depending on settings
     658*/
     659
     660if (!function_exists('wpbb_register_styles'))
     661{
     662    function wpbb_register_styles()
     663    {
     664        $wpbb_theme_options = get_option('wpbb_theme_options');
     665        if ($wpbb_theme_options['theme'] == 'light')
     666        {
     667            wp_register_style('wpbb-light-style', plugins_url('wp-bulletin-board/css/wpbb-light-style.css'));
     668            wp_enqueue_style('wpbb-light-style');
     669        }
     670        else
     671        {
     672            wp_register_style('wpbb-dark-style', plugins_url('wp-bulletin-board/css/wpbb-dark-style.css'));
     673            wp_enqueue_style('wpbb-dark-style');
     674        }
     675        wp_enqueue_script('jquery');
     676        wp_register_script('wpbb-search', plugins_url('wp-bulletin-board/js/wpbb-search.js'), 'jquery');
     677        wp_enqueue_script('wpbb-search');
    425678    }
    426679}
     
    432685*/
    433686
    434 function wpbb_admin_display() {
    435     require_once('php/admin/wpbb-admin-main.php');
    436 }
     687if (!function_exists('wpbb_admin_display'))
     688{
     689    function wpbb_admin_display()
     690    {
     691        require_once('php/admin/admin-main.php');
     692    }
     693}
     694
    437695
    438696
     
    441699*/
    442700
    443 function wpbb_admin_categories() {
    444     require_once('php/admin/wpbb-admin-categories.php');
     701if (!function_exists('wpbb_admin_categories'))
     702{
     703    function wpbb_admin_categories()
     704    {
     705        require_once('php/admin/admin-categories.php');
     706    }
    445707}
    446708
     
    449711*/
    450712
    451 function wpbb_admin_forums() {
    452     require_once('php/admin/wpbb-admin-forums.php');
     713if (!function_exists('wpbb_admin_forums'))
     714{
     715    function wpbb_admin_forums()
     716    {
     717        require_once('php/admin/admin-forums.php');
     718    }
    453719}
    454720
     
    457723*/
    458724
    459 function wpbb_admin_subforums() {
    460     require_once('php/admin/wpbb-admin-subforums.php');
     725if (!function_exists('wpbb_admin_subforums'))
     726{
     727    function wpbb_admin_subforums()
     728    {
     729        require_once('php/admin/admin-subforums.php');
     730    }
    461731}
    462732
     
    465735*/
    466736
    467 function wpbb_admin_topics() {
    468     require_once('php/admin/wpbb-admin-topics.php');
     737if (!function_exists('wpbb_admin_topics'))
     738{
     739    function wpbb_admin_topics()
     740    {
     741        require_once('php/admin/admin-topics.php');
     742    }
     743}
     744
     745/*
     746    Role Permissions
     747*/
     748
     749if (!function_exists('wpbb_admin_role_permissions'))
     750{
     751    function wpbb_admin_role_permissions()
     752    {
     753        require_once('php/admin/admin-role-permissions.php');
     754    }
    469755}
    470756
     
    473759*/
    474760
    475 function wpbb_admin_tools() {
    476     require_once('php/admin/wpbb-admin-tools.php');
     761if (!function_exists('wpbb_admin_tools'))
     762{
     763    function wpbb_admin_tools()
     764    {
     765        require_once('php/admin/admin-tools.php');
     766    }
    477767}
    478768
     
    481771*/
    482772
    483 function wpbb_admin_help() {
    484     require_once('php/admin/wpbb-admin-faq-support.php');
    485 }
    486 
     773if (!function_exists('wpbb_admin_help'))
     774{
     775    function wpbb_admin_help()
     776    {
     777        require_once('php/admin/admin-faq-support.php');
     778    }
     779}
    487780
    488781/*
     
    490783*/
    491784
    492 function wpbb_display_settings() {
    493     require_once('php/admin/wpbb-admin-settings.php');
     785if (!function_exists('wpbb_display_settings'))
     786{
     787    function wpbb_display_settings()
     788    {
     789        require_once('php/admin/admin-settings.php');
     790    }
    494791}
    495792
Note: See TracChangeset for help on using the changeset viewer.