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.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1404 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-06-10 10:01:45 +00:00
parent 8357db3dcf
commit 4f6e367f90
3 changed files with 35 additions and 56 deletions

View File

@ -178,10 +178,8 @@ if ($pagenow != 'wp-trackback.php' && $tb == 1) {
}
if ($pagenow != 'post.php' && $pagenow != 'edit.php') {
if ($use_gzipcompression) {
// gzipping the output of the script
if ( get_settings('gzipcompression') )
gzip_compression();
}
}
?>

View File

@ -445,4 +445,12 @@ function iso8601_to_datetime($date_string, $timezone = USER) {
}
}
function popuplinks($text) {
// Comment text in popup windows should be filtered through this.
// Right now it's a moderately dumb function, ideally it would detect whether
// a target or rel attribute was already there and adjust its actions accordingly.
$text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
return $text;
}
?>

View File

@ -12,14 +12,6 @@ if (!function_exists('floatval')) {
}
}
function popuplinks($text) {
// Comment text in popup windows should be filtered through this.
// Right now it's a moderately dumb function, ideally it would detect whether
// a target or rel attribute was already there and adjust its actions accordingly.
$text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
return $text;
}
function mysql2date($dateformatstring, $mysqlstring, $use_b2configmonthsdays = 1) {
global $month, $weekday;
$m = $mysqlstring;
@ -300,21 +292,18 @@ function url_to_postid($url = '') {
function get_settings($setting) {
global $wpdb, $cache_settings;
if ( strstr($_SERVER['REQUEST_URI'], 'install.php') || strstr($_SERVER['REQUEST_URI'], 'upgrade.php') ) {
if ( strstr($_SERVER['REQUEST_URI'], 'install.php') || strstr($_SERVER['REQUEST_URI'], 'upgrade.php') )
return false;
}
if ( empty($cache_settings) ) {
if ( empty($cache_settings) )
$cache_settings = get_alloptions();
}
if ('home' == $setting && '' == $cache_settings->home) return $cache_settings->siteurl;
if (!isset($cache_settings->$setting)) {
return $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
} else {
if ( isset($cache_settings->$setting) )
return $cache_settings->$setting;
}
else
return $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
}
function get_alloptions() {
@ -326,7 +315,6 @@ function get_alloptions() {
if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
if ('category_base' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
$all_options->{$option->option_name} = stripslashes($option->option_value);
}
}
@ -439,26 +427,11 @@ function get_catname($cat_ID) {
}
function gzip_compression() {
global $gzip_compressed;
if (strstr($_SERVER['PHP_SELF'], 'wp-admin')) return true;
if (!$gzip_compressed) {
$phpver = phpversion(); //start gzip compression
if($phpver >= "4.0.4pl1") {
if(extension_loaded("zlib")) {
ob_start("ob_gzhandler");
}
} else if($phpver > "4.0") {
if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
if(extension_loaded("zlib")) {
$do_gzip_compress = TRUE;
ob_start();
ob_implicit_flush(0);
header("Content-Encoding: gzip");
}
}
} //end gzip compression - that piece of script courtesy of the phpBB dev team
$gzip_compressed=1;
}
if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') ) return false;
if ( !get_settings('gzipcompression') ) return false;
if( extension_loaded('zlib') )
ob_start('ob_gzhandler');
}
@ -468,7 +441,7 @@ function gzip_compression() {
function timer_start() {
global $timestart;
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = explode(' ',$mtime);
$mtime = $mtime[1] + $mtime[0];
$timestart = $mtime;
return true;
@ -477,7 +450,7 @@ function timer_start() {
function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal
global $timestart, $timeend;
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = explode(' ',$mtime);
$mtime = $mtime[1] + $mtime[0];
$timeend = $mtime;
$timetotal = $timeend-$timestart;