Make WordPress Core


Ignore:
Timestamp:
06/10/2004 10:01:45 AM (20 years ago)
Author:
saxmatt
Message:

Gzip cleanup, debugged wacky options problem, some cleanup and reorg. We need to split up functions.php more logically, and kill some of the useless functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r1401 r1404  
    1111        return ((float) $string);
    1212    }
    13 }
    14 
    15 function popuplinks($text) {
    16     // Comment text in popup windows should be filtered through this.
    17     // Right now it's a moderately dumb function, ideally it would detect whether
    18     // a target or rel attribute was already there and adjust its actions accordingly.
    19     $text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
    20     return $text;
    2113}
    2214
     
    301293function get_settings($setting) {
    302294    global $wpdb, $cache_settings;
    303     if ( strstr($_SERVER['REQUEST_URI'], 'install.php') || strstr($_SERVER['REQUEST_URI'], 'upgrade.php') ) {
     295    if ( strstr($_SERVER['REQUEST_URI'], 'install.php') || strstr($_SERVER['REQUEST_URI'], 'upgrade.php') )
    304296        return false;
    305     }
    306 
    307     if ( empty($cache_settings) ) {
     297
     298    if ( empty($cache_settings) )
    308299        $cache_settings = get_alloptions();
    309     }
    310300
    311301    if ('home' == $setting && '' == $cache_settings->home) return $cache_settings->siteurl;
    312302
    313     if (!isset($cache_settings->$setting)) {
     303    if ( isset($cache_settings->$setting) )
     304        return $cache_settings->$setting;
     305    else
    314306        return $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
    315     } else {
    316         return $cache_settings->$setting;
    317     }
    318307}
    319308
     
    327316            if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
    328317            if ('category_base' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
    329 
    330318            $all_options->{$option->option_name} = stripslashes($option->option_value);
    331319        }
     
    440428
    441429function gzip_compression() {
    442     global $gzip_compressed;
    443     if (strstr($_SERVER['PHP_SELF'], 'wp-admin')) return true;
    444         if (!$gzip_compressed) {
    445         $phpver = phpversion(); //start gzip compression
    446         if($phpver >= "4.0.4pl1") {
    447             if(extension_loaded("zlib")) {
    448                 ob_start("ob_gzhandler");
    449             }
    450         } else if($phpver > "4.0") {
    451             if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
    452                 if(extension_loaded("zlib")) {
    453                     $do_gzip_compress = TRUE;
    454                     ob_start();
    455                     ob_implicit_flush(0);
    456                     header("Content-Encoding: gzip");
    457                 }
    458             }
    459         } //end gzip compression - that piece of script courtesy of the phpBB dev team
    460         $gzip_compressed=1;
    461     }
     430    if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') ) return false;
     431    if ( !get_settings('gzipcompression') ) return false;
     432
     433    if( extension_loaded('zlib') )
     434        ob_start('ob_gzhandler');
    462435}
    463436
     
    467440
    468441function timer_start() {
    469     global $timestart;
    470     $mtime = microtime();
    471     $mtime = explode(" ",$mtime);
    472     $mtime = $mtime[1] + $mtime[0];
    473     $timestart = $mtime;
    474     return true;
    475 }
    476 
    477 function timer_stop($display=0,$precision=3) { //if called like timer_stop(1), will echo $timetotal
    478     global $timestart,$timeend;
    479     $mtime = microtime();
    480     $mtime = explode(" ",$mtime);
    481     $mtime = $mtime[1] + $mtime[0];
    482     $timeend = $mtime;
    483     $timetotal = $timeend-$timestart;
    484     if ($display)
    485         echo number_format($timetotal,$precision);
    486     return $timetotal;
     442    global $timestart;
     443    $mtime = microtime();
     444    $mtime = explode(' ',$mtime);
     445    $mtime = $mtime[1] + $mtime[0];
     446    $timestart = $mtime;
     447    return true;
     448}
     449
     450function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal
     451    global $timestart, $timeend;
     452    $mtime = microtime();
     453    $mtime = explode(' ',$mtime);
     454    $mtime = $mtime[1] + $mtime[0];
     455    $timeend = $mtime;
     456    $timetotal = $timeend-$timestart;
     457    if ($display)
     458        echo number_format($timetotal,$precision);
     459    return $timetotal;
    487460}
    488461
Note: See TracChangeset for help on using the changeset viewer.