Skip to:
Content

bbPress.org

Changeset 1174


Ignore:
Timestamp:
03/02/2008 06:34:21 AM (19 years ago)
Author:
sambauers
Message:

Make Bozo and Akismet plugins. Add bb-plugins directory. Let's see how it feels for a day or two then keep or dump.

Location:
trunk
Files:
3 added
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-admin/admin-functions.php

    r1160 r1174  
    760760/* Pluigns */
    761761
     762function bb_get_plugins_callback( $f, $_f ) {
     763        if ( ".php" != substr($f,-4) || "_" == substr($_f, 0, 1) )
     764                return false;
     765        return bb_get_plugin_data( $f );
     766}
     767
    762768function bb_get_plugins() {
    763         $dir = new BB_Dir_Map( BBPLUGINDIR, array(
    764                 'callback' => create_function('$f,$_f', 'if ( ".php" != substr($f,-4) || "_" == substr($_f, 0, 1) ) return false; return bb_get_plugin_data( $f );'),
     769        $dir = new BB_Dir_Map( BBDEFAULTPLUGINDIR, array(
     770                'callback' => 'bb_get_plugins_callback',
    765771                'recurse' => 1
    766772        ) );
    767         $r = $dir->get_results();
    768         return is_wp_error($r) ? array() : $r;
     773        $r1 = $dir->get_results();
     774        $r1 = is_wp_error($r1) ? array() : $r1;
     775        $dir = new BB_Dir_Map( BBPLUGINDIR, array(
     776                'callback' => 'bb_get_plugins_callback',
     777                'recurse' => 1
     778        ) );
     779        $r2 = $dir->get_results();
     780        $r2 = is_wp_error($r2) ? array() : $r2;
     781        return array_merge($r1, $r2);
    769782}
    770783
  • trunk/bb-admin/options-general.php

    r1160 r1174  
    122122        </fieldset>
    123123        <fieldset>
    124                 <legend><?php _e('Anti-spam') ?></legend>
    125                 <label for="akismet_key">
    126                         <?php _e('Akismet Key:') ?>
    127                 </label>
    128                 <div>
    129                         <input class="text" name="akismet_key" id="akismet_key" value="<?php bb_form_option('akismet_key'); ?>" />
    130                         <p><?php _e('You do not need a key to run bbPress, but if you want to take advantage of Akismet\'s powerful spam blocking, you\'ll need one.'); ?></p>
    131                         <p><?php _e('You can get an Akismet key at <a href="http://wordpress.com/api-keys/">WordPress.com</a>') ?></p>
    132                 </div>
    133         </fieldset>
    134         <fieldset>
    135124                <?php bb_nonce_field( 'options-general-update' ); ?>
    136125                <input type="hidden" name="action" id="action" value="update" />
  • trunk/bb-admin/plugins.php

    r1125 r1174  
    44$plugins = bb_get_plugins();
    55$_plugins = array();
    6 if ( function_exists( 'glob' ) && is_callable( 'glob' ) && $_plugins_glob = glob(BBPLUGINDIR . '_*.php') ) {
     6if ( function_exists( 'glob' ) && is_callable( 'glob' ) ) {
     7        $_plugins_glob = glob(BBDEFAULTPLUGINDIR . '_*.php');
    78        foreach ( $_plugins_glob as $_plugin ) {
    89                $_data = bb_get_plugin_data( $_plugin );
    910                $_plugins[$_plugin] = $_data ? $_data : true;
    1011        }
     12        unset($_plugins_glob, $_data, $_plugin);
     13       
     14        $_plugins_glob = glob(BBPLUGINDIR . '_*.php');
     15        foreach ( $_plugins_glob as $_plugin ) {
     16                $_data = bb_get_plugin_data( $_plugin );
     17                $_plugins[$_plugin] = $_data ? $_data : true;
     18        }
     19        unset($_plugins_glob, $_data, $_plugin);
    1120}
    12 unset($_plugins_glob, $_plugin);
     21
    1322
    1423$current = (array) bb_get_option( 'active_plugins' );
    … …  
    1625$update = false;
    1726foreach ( $current as $c => $cur )
    18         if ( !file_exists(BBPLUGINDIR . $cur) ) {
     27        if ( !file_exists(BBPLUGINDIR . $cur) && !file_exists(BBDEFAULTPLUGINDIR . $cur) ) {
    1928                $update = true;
    2029                unset($current[$c]);
  • trunk/bb-admin/upgrade-functions.php

    r1058 r1174  
    2525        $bb_upgrade[] = bb_upgrade_1020(); // Add a user_nicename to existing users
    2626        $bb_upgrade[] = bb_upgrade_1030(); // Move admin_email option to from_email
     27        $bb_upgrade[] = bb_upgrade_1040(); // Activate Akismet and bozo plugins on upgrade only
    2728        bb_update_db_version();
    2829        return $bb_upgrade;
    … …  
    520521}
    521522
     523// Activate Akismet and bozo plugins on upgrade only
     524function bb_upgrade_1040() {
     525        if ( ( $dbv = bb_get_option_from_db( 'bb_db_version' ) ) && $dbv >= 1174 )
     526                return;
     527       
     528        // Only do this when upgrading
     529        if ( defined( 'BB_UPGRADING' ) && BB_UPGRADING ) {
     530                $plugins = bb_get_option('active_plugins')
     531                if ( bb_get_option('akismet_key') && !in_array('akismet.php', $plugins) ) {
     532                        $plugins[] = 'akismet.php';
     533                }
     534                if ( !in_array('bozo.php', $plugins) ) {
     535                        $plugins[] = 'bozo.php';
     536                }
     537                ksort($plugins);
     538                bb_update_option( 'active_plugins', $plugins );
     539        }
     540       
     541        bb_update_option( 'bb_db_version', 1174 );
     542}
     543
    522544function bb_deslash($content) {
    523545    // Note: \\\ inside a regex denotes a single backslash.
  • trunk/bb-includes/functions.php

    r1140 r1174  
    14411441                break;
    14421442        case 'bb_db_version' :
    1443                 return '1058'; // Don't filter
     1443                return '1174'; // Don't filter
    14441444                break;
    14451445        case 'html_type' :
  • trunk/bb-settings.php

    r1153 r1174  
    133133require( BBPATH . BBINC . 'deprecated.php');
    134134
    135 if ( defined('BB_DISABLE_BOZO_CHECKS') && !BB_DISABLE_BOZO_CHECKS )
    136         require( BBPATH . BBINC . 'bozo.php');
    137 
    138135require( BBPATH . BBINC . 'default-filters.php');
    139136require( BBPATH . BBINC . 'script-loader.php');
    … …  
    146143        $bbdb->show_errors();
    147144}
    148 
    149 if ( bb_get_option( 'akismet_key' ) )
    150         require( BBPATH . BBINC . 'akismet.php');
    151145
    152146$_GET    = bb_global_sanitize($_GET   );
    … …  
    188182if ( !defined('BBPLUGINURL') )
    189183        define('BBPLUGINURL', $bb->uri . 'my-plugins/');
     184if ( !defined('BBDEFAULTPLUGINDIR') )
     185        define('BBDEFAULTPLUGINDIR', BBPATH . 'bb-plugins/');
     186if ( !defined('BBDEFAULTPLUGINURL') )
     187        define('BBDEFAULTPLUGINURL', $bb->uri . 'bb-plugins/');
    190188if ( !defined('BBTHEMEDIR') )
    191189        define('BBTHEMEDIR', BBPATH . 'my-templates/');
    … …  
    377375
    378376// Load Plugins
    379 if ( function_exists( 'glob' ) && is_callable( 'glob' ) && $_plugins_glob = glob(BBPLUGINDIR . '_*.php') )
     377
     378// Underscore plugins
     379if ( function_exists( 'glob' ) && is_callable( 'glob' ) ) {
     380        // First BBDEFAULTPLUGINDIR
     381        $_plugins_glob = glob(BBDEFAULTPLUGINDIR . '_*.php');
    380382        foreach ( $_plugins_glob as $_plugin )
    381383                require($_plugin);
    382 unset($_plugins_glob, $_plugin);
     384        unset($_plugins_glob, $_plugin);
     385       
     386        // Second BBPLUGINDIR, with no name clash testing
     387        $_plugins_glob = glob(BBPLUGINDIR . '_*.php');
     388        foreach ( $_plugins_glob as $_plugin )
     389                require($_plugin);
     390        unset($_plugins_glob, $_plugin);
     391}
    383392do_action( 'bb_underscore_plugins_loaded' );
    384393
     394// Plugins in BBPLUGINDIR take precedence over BBDEFAULTPLUGINDIR when names collide
    385395if ( $plugins = bb_get_option( 'active_plugins' ) )
    386396        foreach ( (array) $plugins as $plugin )
    387                 if ( file_exists(BBPLUGINDIR . $plugin) )
     397                if ( file_exists(BBPLUGINDIR . $plugin) ) {
    388398                        require( BBPLUGINDIR . $plugin );
     399                } elseif ( file_exists(BBDEFAULTPLUGINDIR . $plugin) ) {
     400                        require( BBDEFAULTPLUGINDIR . $plugin );
     401                }
    389402do_action( 'bb_plugins_loaded' );
    390403unset($plugins, $plugin);
Note: See TracChangeset for help on using the changeset viewer.