Changeset 544

Show
Ignore:
Timestamp:
11/07/06 00:16:18 (2 years ago)
Author:
mdawaffe
Message:

More options cleanup. Fixes #478 and #479 and #480

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bb-includes/functions.php

    r528 r544  
    293293 
    294294        switch ( $option ) : 
    295         case 'url' : 
    296         case 'uri' : 
    297                 $r = $bb->domain . $bb->path; 
    298                 break; 
    299295        case 'language': 
    300296                $r = str_replace('_', '-', get_locale()); 
     
    307303                return '0.73'; // Don't filter 
    308304                break; 
     305        case 'url' : 
     306                $option = 'uri'; 
    309307        default : 
    310                 $option = preg_replace('|[^a-z0-9_]|i', '', $option); 
    311  
    312308                if ( isset($bb->$option) ) { 
    313309                        $r = $bb->$option; 
     
    315311                } 
    316312 
    317                 global $bbdb, $bb_topic_cache; 
    318                 if ( isset($bb_topic_cache[0]->$option) ) { 
    319                         $r = $bb_topic_cache[0]->$option; 
    320                         if ( is_wp_error( $r ) && 'bb_get_option' == $r->get_error_code() ) 
    321                                 $r = null; // see WP_Error below 
    322                         break; 
    323                 } 
    324  
     313                $r = bb_get_option_from_db( $option ); 
     314                break; 
     315        endswitch; 
     316        return apply_filters( 'bb_get_option_' . $option, $r, $option); 
     317
     318 
     319function bb_get_option_from_db( $option ) { 
     320        global $bbdb, $bb_topic_cache; 
     321        $option = preg_replace('|[^a-z0-9_]|i', '', $option); 
     322 
     323        if ( isset($bb_topic_cache[0]->$option) ) { 
     324                $r = $bb_topic_cache[0]->$option; 
     325                if ( is_wp_error( $r ) && 'bb_get_option' == $r->get_error_code() ) 
     326                        $r = null; // see WP_Error below 
     327        } else { 
    325328                $row = $bbdb->get_row("SELECT meta_value FROM $bbdb->topicmeta WHERE topic_id = 0 AND meta_key = '$option'"); 
     329 
    326330                if ( is_object($row) ) { 
    327331                        $bb_topic_cache[0]->$option = $r = bb_maybe_unserialize( $row->meta_value ); 
     
    330334                        $bb_topic_cache[0]->$option = new WP_Error( 'bb_get_option' ); // Used internally for caching.  See above. 
    331335                } 
    332                 break; 
    333         endswitch; 
    334         return apply_filters( 'bb_get_option_' . $option, $r, $option); 
     336        } 
     337        return apply_filters( 'bb_get_option_from_db_' . $option, $r, $option ); 
    335338} 
    336339 
  • trunk/bb-includes/template-functions.php

    r535 r544  
    287287 
    288288function bb_get_title() { 
    289         global $topic, $forum, $static_title, $tag, $user; 
     289        global $topic, $forum, $tag, $user; 
    290290        $title = ''; 
    291291        if ( is_topic() ) 
     
    297297        if ( is_bb_profile() ) 
    298298                $title = get_user_name( $user->ID ) . ' « '; 
    299         if ( !empty($static_title) ) 
    300                 $title = $static_title . ' « '
     299        if ( $st = bb_get_option( 'static_title' ) ) 
     300                $title = $st
    301301        $title .= bb_get_option('name'); 
    302302        return apply_filters( 'bb_get_title', $title ); 
  • trunk/bb-settings.php

    r540 r544  
    6868$bbdb->tagged    = $bb_table_prefix . 'tagged'; 
    6969 
     70foreach ( array('use_cache', 'secret', 'debug', 'wp_table_prefix', 'wp_home', 'wp_siteurl', 'cookiedomain', 'static_title', 'load_options') as $o ) 
     71        if ( !isset($bb->$o) ) 
     72                $bb->$o = false; 
     73unset($o); 
     74 
    7075require( BBPATH . BBINC . '/functions.php'); 
    7176require( BBPATH . BBINC . '/formatting-functions.php'); 
     
    9499$bbdb->show_errors(); 
    95100 
    96 $static_title = ''; 
     101if ( $bb->load_options ) 
     102        bb_cache_all_options(); 
    97103 
    98104$_GET    = bb_global_sanitize($_GET   ); 
     
    116122define('BBHASH', $bb->wp_siteurl ? md5($bb->wp_siteurl) : md5($bb_table_prefix) ); 
    117123 
     124$bb->uri = $bb->domain . $bb->path; 
    118125if ( !isset( $bb->usercookie ) ) 
    119126        $bb->usercookie = ( $bb->wp_table_prefix ? 'wordpressuser_' : 'bb_user_' ) . BBHASH; 
     
    121128        $bb->passcookie = ( $bb->wp_table_prefix ? 'wordpresspass_' : 'bb_pass_' ) . BBHASH; 
    122129if ( !isset( $bb->cookiepath ) ) 
    123         $bb->cookiepath = $bb->wp_home ? preg_replace('|https?://[^/]+|i', '', "$bb->wp_home/" ) : bb_get_option('path')
     130        $bb->cookiepath = $bb->wp_home ? preg_replace('|https?://[^/]+|i', '', $bb->wp_home . '/' ) : $bb->path
    124131if ( !isset( $bb->sitecookiepath ) ) 
    125         $bb->sitecookiepath = $bb->wp_siteurl ? preg_replace('|https?://[^/]+|i', '', "$bb->wp_site/" ) : bb_get_option('path')
     132        $bb->sitecookiepath = $bb->wp_siteurl ? preg_replace('|https?://[^/]+|i', '', $bb->wp_siteurl . '/' ) : $bb->path
    126133if ( !isset( $bb->tagpath ) ) 
    127134        $bb->tagpath = $bb->path; 
  • trunk/config-sample.php

    r516 r544  
    4444// of Akismet's powerful spam blocking, you'll need one.  You can get an Akismet key at 
    4545// http://wordpress.com/api-keys/ 
    46 $bb->akismet_key = false; 
     46$bb->akismet_key = ''; // Example: '0123456789ab' 
    4747 
    4848 
     
    5050// If you're not, just leave the rest as it is. 
    5151 
    52 $bb->wp_table_prefix = false;  // WordPress table prefix.  Example: 'wp_'; 
    53 $bb->wp_home = false;  // WordPress - Options->General: Blog address (URL) // No trailing slash 
    54 $bb->wp_siteurl = false;  // WordPress - Options->General: WordPress address (URL) // No trailing slash 
     52$bb->wp_table_prefix = '';  // WordPress table prefix.  Example: 'wp_'; 
     53$bb->wp_home = '';  // WordPress - Options->General: Blog address (URL) // No trailing slash.  Example: 'http://example.com' 
     54$bb->wp_siteurl = '';  // WordPress - Options->General: WordPress address (URL) // No trailing slash. Example: 'http://example.com' 
    5555 
    5656/* Stop editing */ 
  • trunk/statistics.php

    r516 r544  
    77$popular = get_popular_topics(); 
    88 
    9 $static_title = __('Statistics')
     9$bb->static_title = __('Statistics') . ' «'
    1010 
    1111if (file_exists( BBPATH . 'my-templates/stats.php' ))