Make WordPress Core


Ignore:
Timestamp:
10/10/2005 09:25:38 AM (18 years ago)
Author:
ryan
Message:

Code cleanups from markjaquith. fixes #1743

File:
1 edited

Legend:

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

    r2933 r2941  
    33require_once(dirname(__FILE__).'/functions-compat.php');
    44
    5 if (!function_exists('_')) {
     5if ( !function_exists('_') ) {
    66    function _($string) {
    77        return $string;
     
    1111function get_profile($field, $user = false) {
    1212    global $wpdb;
    13     if (!$user)
     13    if ( !$user )
    1414        $user = $wpdb->escape($_COOKIE[USER_COOKIE]);
    1515    return $wpdb->get_var("SELECT $field FROM $wpdb->users WHERE user_login = '$user'");
     
    1919    global $month, $weekday, $month_abbrev, $weekday_abbrev;
    2020    $m = $mysqlstring;
    21     if (empty($m)) {
     21    if ( empty($m) ) {
    2222        return false;
    2323    }
    24     $i = mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4)); 
    25     if (!empty($month) && !empty($weekday) && $translate) {
     24    $i = mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4));
     25    if ( !empty($month) && !empty($weekday) && $translate ) {
    2626        $datemonth = $month[date('m', $i)];
    2727        $datemonth_abbrev = $month_abbrev[$datemonth];
    2828        $dateweekday = $weekday[date('w', $i)];
    29         $dateweekday_abbrev = $weekday_abbrev[$dateweekday];       
     29        $dateweekday_abbrev = $weekday_abbrev[$dateweekday];
    3030        $dateformatstring = ' '.$dateformatstring;
    3131        $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
     
    3333        $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
    3434        $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
    35    
     35
    3636        $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
    3737    }
    3838    $j = @date($dateformatstring, $i);
    39     if (!$j) {
     39    if ( !$j ) {
    4040    // for debug purposes
    4141    //  echo $i." ".$mysqlstring;
     
    4747    switch ($type) {
    4848        case 'mysql':
    49             if ($gmt) $d = gmdate('Y-m-d H:i:s');
     49            if ( $gmt ) $d = gmdate('Y-m-d H:i:s');
    5050            else $d = gmdate('Y-m-d H:i:s', (time() + (get_settings('gmt_offset') * 3600)));
    5151            return $d;
    5252            break;
    5353        case 'timestamp':
    54             if ($gmt) $d = time();
     54            if ( $gmt ) $d = time();
    5555            else $d = time() + (get_settings('gmt_offset') * 3600);
    5656            return $d;
     
    6161function date_i18n($dateformatstring, $unixtimestamp) {
    6262    global $month, $weekday, $month_abbrev, $weekday_abbrev;
    63     $i = $unixtimestamp; 
    64     if ((!empty($month)) && (!empty($weekday))) {
     63    $i = $unixtimestamp;
     64    if ( (!empty($month)) && (!empty($weekday)) ) {
    6565        $datemonth = $month[date('m', $i)];
    6666        $datemonth_abbrev = $month_abbrev[$datemonth];
    6767        $dateweekday = $weekday[date('w', $i)];
    68         $dateweekday_abbrev = $weekday_abbrev[$dateweekday];       
     68        $dateweekday_abbrev = $weekday_abbrev[$dateweekday];
    6969        $dateformatstring = ' '.$dateformatstring;
    7070        $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
     
    8686    $i = 86400;
    8787
    88     if ($weekday < get_settings('start_of_week'))
     88    if ( $weekday < get_settings('start_of_week') )
    8989        $weekday = 7 - (get_settings('start_of_week') - $weekday);
    9090
    9191    while ($weekday > get_settings('start_of_week')) {
    9292        $weekday = date('w',$day);
    93         if ($weekday < get_settings('start_of_week'))
     93        if ( $weekday < get_settings('start_of_week') )
    9494            $weekday = 7 - (get_settings('start_of_week') - $weekday);
    9595
     
    9898    }
    9999    $week['start'] = $day + 86400 - $i;
    100     //$week['end']  = $day - $i + 691199;
     100    // $week['end'] = $day - $i + 691199;
    101101    $week['end'] = $week['start'] + 604799;
    102102    return $week;
     
    145145        }
    146146        $lastpostdate = get_lastpostdate($timezone);
    147         if ($lastpostdate > $lastpostmodified) {
     147        if ( $lastpostdate > $lastpostmodified ) {
    148148            $lastpostmodified = $lastpostdate;
    149149        }
     
    180180    preg_match('#[?&](p|page_id)=(\d+)#', $url, $values);
    181181    $id = intval($values[2]);
    182     if ($id) return $id;
     182    if ( $id ) return $id;
    183183
    184184    // Check to see if we are using rewrite rules
     
    188188    if ( empty($rewrite) )
    189189        return 0;
    190    
     190
    191191    // $url cleanup by Mark Jaquith
    192192    // This fixes things like #anchors, ?query=strings, missing 'www.',
    193193    // added 'www.', or added 'index.php/' that will mess up our WP_Query
    194194    // and return a false negative
    195        
     195
    196196    // Get rid of the #anchor
    197197    $url_split = explode('#', $url);
    198198    $url = $url_split[0];
    199    
     199
    200200    // Get rid of URI ?query=string
    201201    $url_split = explode('?', $url);
    202202    $url = $url_split[0];
    203        
     203
    204204    // Add 'www.' if it is absent and should be there
    205205    if ( false !== strpos(get_settings('home'), '://www.') && false === strpos($url, '://www.') )
    206206        $url = str_replace('://', '://www.', $url);
    207        
     207
    208208    // Strip 'www.' if it is present and shouldn't be
    209209    if ( false === strpos(get_settings('home'), '://www.') )
    210210        $url = str_replace('://www.', '://', $url);
    211        
     211
    212212    // Strip 'index.php/' if we're not using path info permalinks
    213213    if ( false === strpos($rewrite, 'index.php/') )
    214214        $url = str_replace('index.php/', '', $url);
    215215
    216     // Chop off http://domain.com
    217216    if ( false !== strpos($url, get_settings('home')) ) {
     217        // Chop off http://domain.com
    218218        $url = str_replace(get_settings('home'), '', $url);
    219219    } else {
    220     // Chop off /path/to/blog
     220        // Chop off /path/to/blog
    221221        $home_path = parse_url(get_settings('home'));
    222222        $home_path = $home_path['path'];
     
    226226    // Trim leading and lagging slashes
    227227    $url = trim($url, '/');
    228    
     228
    229229    $request = $url;
    230    
     230
    231231    // Done with cleanup
    232    
     232
    233233    // Look for matches.
    234234    $request_match = $request;
     
    236236        // If the requesting file is the anchor of the match, prepend it
    237237        // to the path info.
    238         if ((! empty($url)) && (strpos($match, $url) === 0)) {
     238        if ( (! empty($url)) && (strpos($match, $url) === 0) ) {
    239239            $request_match = $url . '/' . $request;
    240240        }
    241241
    242         if (preg_match("!^$match!", $request_match, $matches)) {
     242        if ( preg_match("!^$match!", $request_match, $matches) ) {
    243243            // Got a match.
    244244            // Trim the query of everything up to the '?'.
    245245            $query = preg_replace("!^.+\?!", '', $query);
    246            
     246
    247247            // Substitute the substring matches into the query.
    248248            eval("\$query = \"$query\";");
     
    254254        }
    255255    }
    256 
    257256    return 0;
    258257}
     
    262261
    263262function get_settings($setting) {
    264   global $wpdb, $cache_settings, $cache_nonexistantoptions;
     263    global $wpdb, $cache_settings, $cache_nonexistantoptions;
    265264    if ( strstr($_SERVER['REQUEST_URI'], 'wp-admin/install.php') || defined('WP_INSTALLING') )
    266265        return false;
     
    272271        $cache_nonexistantoptions = array();
    273272
    274     if ('home' == $setting && '' == $cache_settings->home)
     273    if ( 'home' == $setting && '' == $cache_settings->home )
    275274        return apply_filters('option_' . $setting, $cache_settings->siteurl);
    276275
     
    290289
    291290        @ $kellogs = unserialize($option);
    292         if ($kellogs !== FALSE)
     291        if ( $kellogs !== FALSE )
    293292            return apply_filters('option_' . $setting, $kellogs);
    294293        else return apply_filters('option_' . $setting, $option);
     
    317316    global $wpdb, $wp_queries;
    318317    $wpdb->hide_errors();
    319     if (!$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'")) {
     318    if ( !$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'") ) {
    320319        $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options");
    321320    }
     
    323322
    324323    foreach ($options as $option) {
    325         // "When trying to design a foolproof system, 
     324        // "When trying to design a foolproof system,
    326325        //  never underestimate the ingenuity of the fools :)" -- Dougal
    327         if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
    328         if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
    329         if ('category_base' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
     326        if ( 'siteurl' == $option->option_name )
     327            $option->option_value = preg_replace('|/+$|', '', $option->option_value);
     328        if ( 'home' == $option->option_name )
     329            $option->option_value = preg_replace('|/+$|', '', $option->option_value);
     330        if ( 'category_base' == $option->option_name )
     331            $option->option_value = preg_replace('|/+$|', '', $option->option_value);
    330332        @ $value = unserialize($option->option_value);
    331         if ($value === FALSE)
     333        if ( $value === FALSE )
    332334            $value = $option->option_value;
    333335        $all_options->{$option->option_name} = apply_filters('pre_option_' . $option->option_name, $value);
     
    341343    if ( is_string($newvalue) )
    342344        $newvalue = trim($newvalue);
    343    
     345
    344346    // If the new and old values are the same, no need to update.
    345347    if ( $newvalue == get_option($option_name) )
     
    379381        $value = serialize($value);
    380382
    381     if( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$name'") ) {
     383    if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$name'") ) {
    382384        $name = $wpdb->escape($name);
    383385        $value = $wpdb->escape($value);
     
    385387        $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, option_description, autoload) VALUES ('$name', '$value', '$description', '$autoload')");
    386388
    387         if($wpdb->insert_id) {
     389        if ( $wpdb->insert_id ) {
    388390            global $cache_settings;
    389391            $cache_settings->{$name} = $original;
     
    397399    // Get the ID, if no ID then return
    398400    $option_id = $wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = '$name'");
    399     if (!$option_id) return false;
     401    if ( !$option_id ) return false;
    400402    $wpdb->query("DELETE FROM $wpdb->options WHERE option_name = '$name'");
    401403    return true;
     
    404406function add_post_meta($post_id, $key, $value, $unique = false) {
    405407    global $wpdb, $post_meta_cache;
    406    
    407     if ($unique) {
    408         if( $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key
     408
     409    if ( $unique ) {
     410        if ( $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key
    409411= '$key' AND post_id = '$post_id'") ) {
    410412            return false;
     
    416418        $value = $wpdb->escape(serialize($value));
    417419
    418     $wpdb->query("INSERT INTO $wpdb->postmeta
    419                                 (post_id,meta_key,meta_value)
    420                                 VALUES ('$post_id','$key','$value')
    421                         ");
     420    $wpdb->query("INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value) VALUES ('$post_id','$key','$value')");
    422421
    423422    $post_meta_cache['$post_id'][$key][] = $original;
     
    429428    global $wpdb, $post_meta_cache;
    430429
    431     if (empty($value)) {
     430    if ( empty($value) ) {
    432431        $meta_id = $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE
    433432post_id = '$post_id' AND meta_key = '$key'");
     
    437436    }
    438437
    439     if (!$meta_id) return false;
    440 
    441     if (empty($value)) {
     438    if ( !$meta_id )
     439        return false;
     440
     441    if ( empty($value) ) {
    442442        $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id'
    443443AND meta_key = '$key'");
     
    453453
    454454    unset($post_meta_cache['$post_id'][$key]);
    455        
     455
    456456    return true;
    457457}
     
    460460    global $wpdb, $post_meta_cache;
    461461
    462     if (isset($post_meta_cache[$post_id][$key])) {
    463         if ($single) {
     462    if ( isset($post_meta_cache[$post_id][$key]) ) {
     463        if ( $single ) {
    464464            return $post_meta_cache[$post_id][$key][0];
    465465        } else {
     
    471471
    472472    $values = array();
    473     if ($metalist) {
     473    if ( $metalist ) {
    474474        foreach ($metalist as $metarow) {
    475475            $values[] = $metarow[0];
     
    477477    }
    478478
    479     if ($single) {
    480         if (count($values)) {
     479    if ( $single ) {
     480        if ( count($values) ) {
    481481            $return = $values[0];
    482482        } else {
     
    488488
    489489    @ $kellogs = unserialize($return);
    490     if ($kellogs !== FALSE)
     490    if ( $kellogs !== FALSE )
    491491        return $kellogs;
    492492    else return $return;
     
    503503    if ( is_array($prev_value) || is_object($prev_value) )
    504504        $prev_value = serialize($value);
    505        
    506     if(! $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key
     505
     506    if (! $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key
    507507= '$key' AND post_id = '$post_id'") ) {
    508508        return false;
    509509    }
    510510
    511     if (empty($prev_value)) {
     511    if ( empty($prev_value) ) {
    512512        $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE
    513513meta_key = '$key' AND post_id = '$post_id'");
     
    530530function get_postdata($postid) {
    531531    $post = &get_post($postid);
    532    
     532
    533533    $postdata = array (
    534         'ID' => $post->ID, 
    535         'Author_ID' => $post->post_author, 
    536         'Date' => $post->post_date, 
    537         'Content' => $post->post_content, 
    538         'Excerpt' => $post->post_excerpt, 
    539         'Title' => $post->post_title, 
     534        'ID' => $post->ID,
     535        'Author_ID' => $post->post_author,
     536        'Date' => $post->post_date,
     537        'Content' => $post->post_content,
     538        'Excerpt' => $post->post_excerpt,
     539        'Title' => $post->post_title,
    540540        'Category' => $post->post_category,
    541541        'post_status' => $post->post_status,
     
    551551}
    552552
    553 // Retrieves post data given a post ID or post object. 
     553// Retrieves post data given a post ID or post object.
    554554// Handles post caching.
    555555function &get_post(&$post, $output = OBJECT) {
     
    561561        else
    562562            $_post = null;
    563     } elseif (is_object($post) ) {
    564         if (! isset($post_cache[$post->ID]))
     563    } elseif ( is_object($post) ) {
     564        if ( !isset($post_cache[$post->ID]) )
    565565            $post_cache[$post->ID] = &$post;
    566566        $_post = & $post_cache[$post->ID];
    567567    } else {
    568         if (isset($post_cache[$post]))
     568        if ( isset($post_cache[$post]) )
    569569            $_post = & $post_cache[$post];
    570570        else {
     
    586586}
    587587
    588 // Retrieves page data given a page ID or page object. 
     588// Retrieves page data given a page ID or page object.
    589589// Handles page caching.
    590590function &get_page(&$page, $output = OBJECT) {
     
    596596        else
    597597            $_page = null;
    598     } elseif (is_object($page) ) {
    599         if (! isset($page_cache[$page->ID]))
     598    } elseif ( is_object($page) ) {
     599        if ( !isset($page_cache[$page->ID]) )
    600600            $page_cache[$page->ID] = &$page;
    601601        $_page = & $page_cache[$page->ID];
     
    603603        if ( isset($GLOBALS['page']) && ($page == $GLOBALS['page']->ID) )
    604604            $_page = & $GLOBALS['page'];
    605         elseif (isset($page_cache[$page]))
     605        elseif ( isset($page_cache[$page]) )
    606606            $_page = & $page_cache[$page];
    607607        else {
     
    623623}
    624624
    625 // Retrieves category data given a category ID or category object. 
     625// Retrieves category data given a category ID or category object.
    626626// Handles category caching.
    627627function &get_category(&$category, $output = OBJECT) {
     
    631631        return null;
    632632
    633     if ( ! isset($cache_categories))
     633    if ( !isset($cache_categories) )
    634634        update_category_cache();
    635635
    636     if (is_object($category)) {
    637         if ( ! isset($cache_categories[$category->cat_ID]))
     636    if ( is_object($category) ) {
     637        if ( !isset($cache_categories[$category->cat_ID]) )
    638638            $cache_categories[$category->cat_ID] = &$category;
    639639        $_category = & $cache_categories[$category->cat_ID];
     
    658658}
    659659
    660 // Retrieves comment data given a comment ID or comment object. 
     660// Retrieves comment data given a comment ID or comment object.
    661661// Handles comment caching.
    662662function &get_comment(&$comment, $output = OBJECT) {
     
    666666        return null;
    667667
    668     if (is_object($comment)) {
    669         if ( ! isset($comment_cache[$comment->comment_ID]))
     668    if ( is_object($comment) ) {
     669        if ( !isset($comment_cache[$comment->comment_ID]) )
    670670            $comment_cache[$comment->comment_ID] = &$comment;
    671671        $_comment = & $comment_cache[$comment->comment_ID];
     
    699699    if ( !get_settings('gzipcompression') ) return false;
    700700
    701     if( extension_loaded('zlib') ) {
     701    if ( extension_loaded('zlib') ) {
    702702        ob_start('ob_gzhandler');
    703703    }
     
    715715    $timeend = $mtime;
    716716    $timetotal = $timeend-$timestart;
    717     if ($display)
     717    if ( $display )
    718718        echo number_format($timetotal,$precision);
    719719    return $timetotal;
     
    740740    $services = preg_replace("|(\s)+|", '$1', $services); // Kill dupe lines
    741741    $services = trim($services);
    742     if ('' != $services) {
     742    if ( '' != $services ) {
    743743        $services = explode("\n", $services);
    744744        foreach ($services as $service) {
     
    754754    global $wpdb, $wp_version;
    755755
    756     if (empty($trackback_url))
     756    if ( empty($trackback_url) )
    757757        return;
    758758
     
    764764    $query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt";
    765765    $trackback_url = parse_url($trackback_url);
    766     $http_request  = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?'.$trackback_url['query'] : '') . " HTTP/1.0\r\n";
     766    $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?'.$trackback_url['query'] : '') . " HTTP/1.0\r\n";
    767767    $http_request .= 'Host: '.$trackback_url['host']."\r\n";
    768768    $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_settings('blog_charset')."\r\n";
     
    815815function xmlrpc_getposttitle($content) {
    816816    global $post_default_title;
    817     if (preg_match('/<title>(.+?)<\/title>/is', $content, $matchtitle)) {
     817    if ( preg_match('/<title>(.+?)<\/title>/is', $content, $matchtitle) ) {
    818818        $post_title = $matchtitle[0];
    819819        $post_title = preg_replace('/<title>/si', '', $post_title);
     
    824824    return $post_title;
    825825}
    826    
     826
    827827function xmlrpc_getpostcategory($content) {
    828828    global $post_default_category;
    829     if (preg_match('/<category>(.+?)<\/category>/is', $content, $matchcat)) {
     829    if ( preg_match('/<category>(.+?)<\/category>/is', $content, $matchcat) ) {
    830830        $post_category = trim($matchcat[1], ',');
    831831        $post_category = explode(',', $post_category);
     
    845845function debug_fopen($filename, $mode) {
    846846    global $debug;
    847     if ($debug == 1) {
     847    if ( $debug == 1 ) {
    848848        $fp = fopen($filename, $mode);
    849849        return $fp;
     
    855855function debug_fwrite($fp, $string) {
    856856    global $debug;
    857     if ($debug == 1) {
     857    if ( $debug == 1 ) {
    858858        fwrite($fp, $string);
    859859    }
     
    862862function debug_fclose($fp) {
    863863    global $debug;
    864     if ($debug == 1) {
     864    if ( $debug == 1 ) {
    865865        fclose($fp);
    866866    }
     
    870870    global $wpdb;
    871871    $doping = false;
    872     if($wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' LIMIT 1")) {
     872    if ( $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' LIMIT 1") )
    873873        $doping = true;
    874     }
    875     if($wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_pingme' OR meta_key = '_encloseme' LIMIT 1")) {
     874
     875    if ( $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_pingme' OR meta_key = '_encloseme' LIMIT 1") )
    876876        $doping = true;
    877     }
    878     if($doping)
    879         echo '<iframe id="pingcheck" src="' .  get_settings('siteurl') .'/wp-admin/execute-pings.php?time=' . time() . '" style="border:none;width:1px;height:1px;"></iframe>';
     877
     878    if ( $doping )
     879        echo '<iframe id="pingcheck" src="' . get_settings('siteurl') .'/wp-admin/execute-pings.php?time=' . time() . '" style="border:none;width:1px;height:1px;"></iframe>';
    880880}
    881881
     
    903903        if ( !in_array($link_test, $pung) ) : // If we haven't pung it already
    904904            $test = parse_url($link_test);
    905             if (isset($test['query']))
     905            if ( isset($test['query']) )
    906906                $post_links[] = $link_test;
    907             elseif(($test['path'] != '/') && ($test['path'] != ''))
     907            elseif (($test['path'] != '/') && ($test['path'] != ''))
    908908                $post_links[] = $link_test;
    909909        endif;
     
    913913        if ( $url != '' && !$wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE post_id = '$post_ID' AND meta_key = 'enclosure' AND meta_value LIKE ('$url%')") ) {
    914914            if ( $headers = wp_get_http_headers( $url) ) {
    915                 $len  = (int) $headers['content-length'];
     915                $len = (int) $headers['content-length'];
    916916                $type = $wpdb->escape( $headers['content-type'] );
    917917                $allowed_types = array( 'video', 'audio' );
    918                 if( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
     918                if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
    919919                    $meta_value = "$url\n$len\n$type\n";
    920920                    $wpdb->query( "INSERT INTO `$wpdb->postmeta` ( `post_id` , `meta_key` , `meta_value` )
     
    927927
    928928function wp_get_http_headers( $url ) {
    929     @set_time_limit( 60 ); 
     929    @set_time_limit( 60 );
    930930    $parts = parse_url( $url );
    931     $file  = $parts['path'] . ($parts['query'] ? '?'.$parts['query'] : '');
    932     $host  = $parts['host'];
     931    $file = $parts['path'] . ($parts['query'] ? '?'.$parts['query'] : '');
     932    $host = $parts['host'];
    933933    if ( !isset( $parts['port'] ) )
    934934        $parts['port'] = 80;
     
    969969// Setup global post data.
    970970function setup_postdata($post) {
    971   global $id, $postdata, $authordata, $day, $page, $pages, $multipage, $more, $numpages, $wp_query;
     971    global $id, $postdata, $authordata, $day, $page, $pages, $multipage, $more, $numpages, $wp_query;
    972972    global $pagenow;
    973973
     
    980980    $numpages = 1;
    981981    $page = get_query_var('page');
    982     if (!$page)
     982    if ( !$page )
    983983        $page = 1;
    984     if (is_single() || is_page())
     984    if ( is_single() || is_page() )
    985985        $more = 1;
    986986    $content = $post->post_content;
    987     if (preg_match('/<!--nextpage-->/', $content)) {
    988         if ($page > 1)
     987    if ( preg_match('/<!--nextpage-->/', $content) ) {
     988        if ( $page > 1 )
    989989            $more = 1;
    990990        $multipage = 1;
     
    10031003function is_new_day() {
    10041004    global $day, $previousday;
    1005     if ($day != $previousday) {
     1005    if ( $day != $previousday ) {
    10061006        return(1);
    10071007    } else {
     
    10141014function merge_filters($tag) {
    10151015    global $wp_filter;
    1016     if (isset($wp_filter['all'])) {
     1016    if ( isset($wp_filter['all']) ) {
    10171017        foreach ($wp_filter['all'] as $priority => $functions) {
    1018             if (isset($wp_filter[$tag][$priority]))
     1018            if ( isset($wp_filter[$tag][$priority]) )
    10191019                $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]);
    10201020            else
     
    10301030function apply_filters($tag, $string) {
    10311031    global $wp_filter;
    1032    
     1032
    10331033    $args = array_slice(func_get_args(), 2);
    10341034
    10351035    merge_filters($tag);
    1036    
    1037     if (!isset($wp_filter[$tag])) {
     1036
     1037    if ( !isset($wp_filter[$tag]) ) {
    10381038        return $string;
    10391039    }
    10401040    foreach ($wp_filter[$tag] as $priority => $functions) {
    1041         if (!is_null($functions)) {
     1041        if ( !is_null($functions) ) {
    10421042            foreach($functions as $function) {
    10431043
     
    10461046                $accepted_args = $function['accepted_args'];
    10471047
    1048                 if($accepted_args == 1) {
     1048                if ( $accepted_args == 1 )
    10491049                    $the_args = array($string);
    1050                 } elseif ($accepted_args > 1) {
     1050                elseif ( $accepted_args > 1 )
    10511051                    $the_args = array_slice($all_args, 0, $accepted_args);
    1052                 } elseif($accepted_args == 0) {
     1052                elseif ( $accepted_args == 0 )
    10531053                    $the_args = NULL;
    1054                 } else {
     1054                else
    10551055                    $the_args = $all_args;
    1056                 }
    10571056
    10581057                $string = call_user_func_array($function_name, $the_args);
     
    10671066
    10681067    // check that we don't already have the same filter at the same priority
    1069     if (isset($wp_filter[$tag]["$priority"])) {
     1068    if ( isset($wp_filter[$tag]["$priority"]) ) {
    10701069        foreach($wp_filter[$tag]["$priority"] as $filter) {
    10711070            // uncomment if we want to match function AND accepted_args
    1072             //if ($filter == array($function, $accepted_args)) {
    1073             if ($filter['function'] == $function_to_add) {
     1071            // if ( $filter == array($function, $accepted_args) ) {
     1072            if ( $filter['function'] == $function_to_add ) {
    10741073                return true;
    10751074            }
     
    10861085
    10871086    // rebuild the list of filters
    1088     if (isset($wp_filter[$tag]["$priority"])) {
     1087    if ( isset($wp_filter[$tag]["$priority"]) ) {
    10891088        foreach($wp_filter[$tag]["$priority"] as $filter) {
    1090             if ($filter['function'] != $function_to_remove) {
     1089            if ( $filter['function'] != $function_to_remove ) {
    10911090                $new_function_list[] = $filter;
    10921091            }
     
    11061105    else
    11071106        $args = array_merge(array($arg), $extra_args);
    1108    
     1107
    11091108    merge_filters($tag);
    1110    
    1111     if (!isset($wp_filter[$tag])) {
     1109
     1110    if ( !isset($wp_filter[$tag]) ) {
    11121111        return;
    11131112    }
    11141113    foreach ($wp_filter[$tag] as $priority => $functions) {
    1115         if (!is_null($functions)) {
     1114        if ( !is_null($functions) ) {
    11161115            foreach($functions as $function) {
    11171116
     
    11191118                $accepted_args = $function['accepted_args'];
    11201119
    1121                 if($accepted_args == 1) {
     1120                if ( $accepted_args == 1 ) {
    11221121                    if ( is_array($arg) )
    11231122                        $the_args = $arg;
    11241123                    else
    11251124                        $the_args = array($arg);
    1126                 } elseif ($accepted_args > 1) {
     1125                } elseif ( $accepted_args > 1 ) {
    11271126                    $the_args = array_slice($args, 0, $accepted_args);
    1128                 } elseif($accepted_args == 0) {
     1127                } elseif ( $accepted_args == 0 ) {
    11291128                    $the_args = NULL;
    11301129                } else {
     
    11511150
    11521151    // A page cannot be it's own parent.
    1153     if ($page->post_parent == $page->ID) {
     1152    if ( $page->post_parent == $page->ID )
    11541153        return $uri;
    1155     }
    1156    
     1154
    11571155    while ($page->post_parent != 0) {
    11581156        $page = get_page($page->post_parent);
     
    11661164    global $wpdb;
    11671165    parse_str($args, $r);
    1168     if (!isset($r['numberposts'])) $r['numberposts'] = 5;
    1169     if (!isset($r['offset'])) $r['offset'] = 0;
    1170     if (!isset($r['category'])) $r['category'] = '';
    1171     if (!isset($r['orderby'])) $r['orderby'] = 'post_date';
    1172     if (!isset($r['order'])) $r['order'] = 'DESC';
     1166    if ( !isset($r['numberposts']) )
     1167        $r['numberposts'] = 5;
     1168    if ( !isset($r['offset']) )
     1169        $r['offset'] = 0;
     1170    if ( !isset($r['category']) )
     1171        $r['category'] = '';
     1172    if ( !isset($r['orderby']) )
     1173        $r['orderby'] = 'post_date';
     1174    if ( !isset($r['order']) )
     1175        $r['order'] = 'DESC';
    11731176
    11741177    $now = current_time('mysql');
     
    11791182        " WHERE post_date <= '$now' AND (post_status = 'publish') ".
    11801183        ( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) .
    1181         " GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . "  LIMIT " . $r['offset'] . ',' . $r['numberposts'] );
    1182    
    1183     update_post_caches($posts);
    1184    
     1184        " GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . " LIMIT " . $r['offset'] . ',' . $r['numberposts'] );
     1185
     1186    update_post_caches($posts);
     1187
    11851188    return $posts;
    11861189}
     
    12041207function clean_post_cache($id) {
    12051208    global $post_cache;
    1206    
     1209
    12071210    if ( isset( $post_cache[$id] ) )
    12081211        unset( $post_cache[$id] );
     
    12231226function clean_page_cache($id) {
    12241227    global $page_cache;
    1225    
     1228
    12261229    if ( isset( $page_cache[$id] ) )
    12271230        unset( $page_cache[$id] );
     
    12311234    global $wpdb, $category_cache, $cache_categories;
    12321235
    1233     if (empty($post_ids))
     1236    if ( empty($post_ids) )
    12341237        return;
    12351238
    1236     if (is_array($post_ids))
     1239    if ( is_array($post_ids) )
    12371240        $post_ids = implode(',', $post_ids);
    12381241
     
    12411244    WHERE category_id = cat_ID AND post_id IN ($post_ids)");
    12421245
    1243     if (! isset($cache_categories))
     1246    if ( !isset($cache_categories) )
    12441247        update_category_cache();
    1245        
     1248
    12461249    if ( !empty($dogs) ) {
    12471250        foreach ($dogs as $catt) {
     
    12541257    global $post_cache, $category_cache, $comment_count_cache, $post_meta_cache;
    12551258    global $wpdb;
    1256    
     1259
    12571260    // No point in doing all this work if we didn't match any posts.
    12581261    if ( !$posts )
     
    12661269
    12671270    $post_id_list = implode(',', $post_id_list);
    1268    
     1271
    12691272    update_post_category_cache($post_id_list);
    12701273
     
    12721275    $comment_counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount
    12731276    FROM $wpdb->posts
    1274     LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID  AND comment_approved = '1')
     1277    LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID AND comment_approved = '1')
    12751278    WHERE ID IN ($post_id_list)
    12761279    GROUP BY ID");
    1277    
    1278     if ($comment_counts) {
     1280
     1281    if ( $comment_counts ) {
    12791282        foreach ($comment_counts as $comment_count)
    12801283            $comment_count_cache["$comment_count->ID"] = $comment_count->ccount;
    12811284    }
    12821285
    1283     // Get post-meta info
    1284     if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta  WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) {
     1286    // Get post-meta info
     1287    if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) {
    12851288        // Change from flat structure to hierarchical:
    12861289        $post_meta_cache = array();
     
    12911294
    12921295            // Force subkeys to be array type:
    1293             if (!isset($post_meta_cache[$mpid]) || !is_array($post_meta_cache[$mpid]))
     1296            if ( !isset($post_meta_cache[$mpid]) || !is_array($post_meta_cache[$mpid]) )
    12941297                $post_meta_cache[$mpid] = array();
    1295             if (!isset($post_meta_cache[$mpid]["$mkey"]) || !is_array($post_meta_cache[$mpid]["$mkey"]))
     1298            if ( !isset($post_meta_cache[$mpid]["$mkey"]) || !is_array($post_meta_cache[$mpid]["$mkey"]) )
    12961299                $post_meta_cache[$mpid]["$mkey"] = array();
    12971300
     
    13041307function update_category_cache() {
    13051308    global $cache_categories, $wpdb;
    1306     if($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")):
     1309    if ( $dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories") ):
    13071310    foreach ($dogs as $catt)
    13081311        $cache_categories[$catt->cat_ID] = $catt;
    13091312        return true;
    1310     else : 
     1313    else :
    13111314        return false;
    13121315    endif;
     
    13391342    $post_obj = $wp_query->get_queried_object();
    13401343
    1341     if ( $post == $post_obj->ID ) 
     1344    if ( $post == $post_obj->ID )
    13421345        return true;
    1343     elseif ( $post == $post_obj->post_title ) 
     1346    elseif ( $post == $post_obj->post_title )
    13441347        return true;
    13451348    elseif ( $post == $post_obj->post_name )
     
    13521355    global $wp_query;
    13531356
    1354     if (! $wp_query->is_page) {
     1357    if ( !$wp_query->is_page )
    13551358        return false;
    1356     }
    1357 
    1358     if (empty($page)) {
     1359
     1360    if ( empty($page) )
    13591361        return true;
    1360     }
    13611362
    13621363    $page_obj = $wp_query->get_queried_object();
    1363        
    1364     if ($page == $page_obj->ID) {
     1364
     1365    if ( $page == $page_obj->ID )
    13651366        return true;
    1366     } else if ($page == $page_obj->post_title) {
     1367    elseif ( $page == $page_obj->post_title )
    13671368        return true;
    1368     } else if ($page == $page_obj->post_name) {
     1369    else if ( $page == $page_obj->post_name )
    13691370        return true;
    1370     }
    13711371
    13721372    return false;
     
    13741374
    13751375function is_archive () {
    1376     global $wp_query;
    1377 
    1378     return $wp_query->is_archive;
     1376    global $wp_query;
     1377
     1378    return $wp_query->is_archive;
    13791379}
    13801380
    13811381function is_date () {
    1382     global $wp_query;
    1383 
    1384     return $wp_query->is_date;
     1382    global $wp_query;
     1383
     1384    return $wp_query->is_date;
    13851385}
    13861386
    13871387function is_year () {
    1388     global $wp_query;
    1389 
    1390     return $wp_query->is_year;
     1388    global $wp_query;
     1389
     1390    return $wp_query->is_year;
    13911391}
    13921392
    13931393function is_month () {
    1394     global $wp_query;
    1395 
    1396     return $wp_query->is_month;
     1394    global $wp_query;
     1395
     1396    return $wp_query->is_month;
    13971397}
    13981398
    13991399function is_day () {
    1400     global $wp_query;
    1401 
    1402     return $wp_query->is_day;
     1400    global $wp_query;
     1401
     1402    return $wp_query->is_day;
    14031403}
    14041404
    14051405function is_time () {
    1406     global $wp_query;
    1407 
    1408     return $wp_query->is_time;
     1406    global $wp_query;
     1407
     1408    return $wp_query->is_time;
    14091409}
    14101410
     
    14121412    global $wp_query;
    14131413
    1414     if (! $wp_query->is_author) {
     1414    if ( !$wp_query->is_author )
    14151415        return false;
    1416     }
    1417 
    1418     if (empty($author)) {
     1416
     1417    if ( empty($author) )
    14191418        return true;
    1420     }
    14211419
    14221420    $author_obj = $wp_query->get_queried_object();
    1423        
    1424     if ($author == $author_obj->ID) {
     1421
     1422    if ( $author == $author_obj->ID )
    14251423        return true;
    1426     } else if ($author == $author_obj->nickname) {
     1424    elseif ( $author == $author_obj->nickname )
    14271425        return true;
    1428     } else if ($author == $author_obj->user_nicename) {
     1426    elseif ( $author == $author_obj->user_nicename )
    14291427        return true;
    1430     }
    14311428
    14321429    return false;
     
    14361433    global $wp_query;
    14371434
    1438     if (! $wp_query->is_category) {
     1435    if ( !$wp_query->is_category )
    14391436        return false;
    1440     }
    1441 
    1442     if (empty($category)) {
     1437
     1438    if ( empty($category) )
    14431439        return true;
    1444     }
    14451440
    14461441    $cat_obj = $wp_query->get_queried_object();
    1447        
    1448     if ($category == $cat_obj->cat_ID) {
     1442
     1443    if ( $category == $cat_obj->cat_ID )
    14491444        return true;
    1450     } else if ($category == $cat_obj->cat_name) {
     1445    else if ( $category == $cat_obj->cat_name )
    14511446        return true;
    1452     } else if ($category == $cat_obj->category_nicename) {
     1447    elseif ( $category == $cat_obj->category_nicename )
    14531448        return true;
    1454     }
    14551449
    14561450    return false;
     
    14581452
    14591453function is_search () {
    1460     global $wp_query;
    1461 
    1462     return $wp_query->is_search;
     1454    global $wp_query;
     1455
     1456    return $wp_query->is_search;
    14631457}
    14641458
    14651459function is_feed () {
    1466     global $wp_query;
    1467 
    1468     return $wp_query->is_feed;
     1460    global $wp_query;
     1461
     1462    return $wp_query->is_feed;
    14691463}
    14701464
    14711465function is_trackback () {
    1472     global $wp_query;
    1473 
    1474     return $wp_query->is_trackback;
     1466    global $wp_query;
     1467
     1468    return $wp_query->is_trackback;
    14751469}
    14761470
    14771471function is_admin () {
    1478     global $wp_query;
    1479 
    1480     return $wp_query->is_admin;
     1472    global $wp_query;
     1473
     1474    return $wp_query->is_admin;
    14811475}
    14821476
    14831477function is_home () {
    1484     global $wp_query;
    1485 
    1486     return $wp_query->is_home;
     1478    global $wp_query;
     1479
     1480    return $wp_query->is_home;
    14871481}
    14881482
    14891483function is_404 () {
    1490     global $wp_query;
    1491 
    1492     return $wp_query->is_404;
     1484    global $wp_query;
     1485
     1486    return $wp_query->is_404;
    14931487}
    14941488
    14951489function is_comments_popup () {
    1496     global $wp_query;
    1497 
    1498     return $wp_query->is_comments_popup;
     1490    global $wp_query;
     1491
     1492    return $wp_query->is_comments_popup;
    14991493}
    15001494
    15011495function is_paged () {
    1502     global $wp_query;
    1503 
    1504     return $wp_query->is_paged;
     1496    global $wp_query;
     1497
     1498    return $wp_query->is_paged;
    15051499}
    15061500
    15071501function in_the_loop() {
    15081502    global $wp_query;
    1509    
     1503
    15101504    return $wp_query->in_the_loop;
    15111505}
    15121506
    15131507function get_query_var($var) {
    1514   global $wp_query;
    1515 
    1516   return $wp_query->get($var);
     1508    global $wp_query;
     1509
     1510    return $wp_query->get($var);
    15171511}
    15181512
    15191513function have_posts() {
    1520     global $wp_query;
    1521 
    1522     return $wp_query->have_posts();
     1514    global $wp_query;
     1515
     1516    return $wp_query->have_posts();
    15231517}
    15241518
    15251519function rewind_posts() {
    1526     global $wp_query;
    1527 
    1528     return $wp_query->rewind_posts();
     1520    global $wp_query;
     1521
     1522    return $wp_query->rewind_posts();
    15291523}
    15301524
    15311525function the_post() {
    1532     global $wp_query;
    1533     $wp_query->the_post();
     1526    global $wp_query;
     1527
     1528    $wp_query->the_post();
    15341529}
    15351530
     
    16031598    $theme = $name;
    16041599
    1605     if ('' == $author_uri[1]) {
     1600    if ( '' == $author_uri[1] ) {
    16061601        $author = $author_name[1];
    16071602    } else {
     
    16161611    global $wp_broken_themes;
    16171612
    1618     if (isset($wp_themes)) {
     1613    if ( isset($wp_themes) )
    16191614        return $wp_themes;
    1620     }
    16211615
    16221616    $themes = array();
     
    16271621    // Files in wp-content/themes directory
    16281622    $themes_dir = @ dir($theme_root);
    1629     if ($themes_dir) {
     1623    if ( $themes_dir ) {
    16301624        while(($theme_dir = $themes_dir->read()) !== false) {
    16311625            if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
    1632                 if ($theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS') {
     1626                if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) {
    16331627                    continue;
    16341628                }
    16351629                $stylish_dir = @ dir($theme_root . '/' . $theme_dir);
    16361630                $found_stylesheet = false;
    1637                 while(($theme_file = $stylish_dir->read()) !== false) {
     1631                while (($theme_file = $stylish_dir->read()) !== false) {
    16381632                    if ( $theme_file == 'style.css' ) {
    16391633                        $theme_files[] = $theme_dir . '/' . $theme_file;
     
    16421636                    }
    16431637                }
    1644                 if (!$found_stylesheet) {
     1638                if ( !$found_stylesheet ) {
    16451639                    $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
    16461640                }
     
    16491643    }
    16501644
    1651     if (!$themes_dir || !$theme_files) {
     1645    if ( !$themes_dir || !$theme_files ) {
    16521646        return $themes;
    16531647    }
     
    16581652        $theme_data = get_theme_data("$theme_root/$theme_file");
    16591653
    1660         $name = $theme_data['Name']; 
     1654        $name = $theme_data['Name'];
    16611655        $title = $theme_data['Title'];
    16621656        $description = wptexturize($theme_data['Description']);
     
    16721666            $screenshot = false;
    16731667
    1674         if (empty($name)) {
     1668        if ( empty($name) ) {
    16751669            $name = dirname($theme_file);
    16761670            $title = $name;
    16771671        }
    16781672
    1679         if (empty($template)) {
    1680             if (file_exists(dirname("$theme_root/$theme_file/index.php"))) {
     1673        if ( empty($template) ) {
     1674            if ( file_exists(dirname("$theme_root/$theme_file/index.php")) ) {
    16811675                $template = dirname($theme_file);
    16821676            } else {
     
    16871681        $template = trim($template);
    16881682
    1689         if (! file_exists("$theme_root/$template/index.php")) {
     1683        if ( !file_exists("$theme_root/$template/index.php") ) {
    16901684            $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'));
    16911685            continue;
    16921686        }
    1693        
     1687
    16941688        $stylesheet_files = array();
    16951689        $stylesheet_dir = @ dir("$theme_root/$stylesheet");
    1696         if ($stylesheet_dir) {
     1690        if ( $stylesheet_dir ) {
    16971691            while(($file = $stylesheet_dir->read()) !== false) {
    1698                 if ( !preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file) ) 
     1692                if ( !preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file) )
    16991693                    $stylesheet_files[] = "$theme_loc/$stylesheet/$file";
    17001694            }
    17011695        }
    17021696
    1703         $template_files = array();     
     1697        $template_files = array();
    17041698        $template_dir = @ dir("$theme_root/$template");
    1705         if ($template_dir) {
     1699        if ( $template_dir ) {
    17061700            while(($file = $template_dir->read()) !== false) {
    1707                 if ( !preg_match('|^\.+$|', $file) && preg_match('|\.php$|', $file) ) 
     1701                if ( !preg_match('|^\.+$|', $file) && preg_match('|\.php$|', $file) )
    17081702                    $template_files[] = "$theme_loc/$template/$file";
    17091703            }
     
    17131707        $stylesheet_dir = dirname($stylesheet_files[0]);
    17141708
    1715         if (empty($template_dir)) $template_dir = '/';
    1716         if (empty($stylesheet_dir)) $stylesheet_dir = '/';
     1709        if ( empty($template_dir) )
     1710            $template_dir = '/';
     1711        if ( empty($stylesheet_dir) )
     1712            $stylesheet_dir = '/';
    17171713
    17181714        // Check for theme name collision.  This occurs if a theme is copied to
     
    17331729            }
    17341730        }
    1735        
     1731
    17361732        $themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Stylesheet' => $stylesheet, 'Template Files' => $template_files, 'Stylesheet Files' => $stylesheet_files, 'Template Dir' => $template_dir, 'Stylesheet Dir' => $stylesheet_dir, 'Status' => $theme_data['Status'], 'Screenshot' => $screenshot);
    17371733    }
     
    17421738    foreach ($theme_names as $theme_name) {
    17431739        $themes[$theme_name]['Parent Theme'] = '';
    1744         if ($themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template']) {
     1740        if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) {
    17451741            foreach ($theme_names as $parent_theme_name) {
    1746                 if (($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template'])) {
     1742                if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) {
    17471743                    $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
    17481744                    break;
     
    17601756    $themes = get_themes();
    17611757
    1762     if (array_key_exists($theme, $themes)) {
     1758    if ( array_key_exists($theme, $themes) )
    17631759        return $themes[$theme];
    1764     }
    17651760
    17661761    return NULL;
     
    17741769    $current_theme = 'WordPress Default';
    17751770
    1776     if ($themes) {
     1771    if ( $themes ) {
    17771772        foreach ($theme_names as $theme_name) {
    1778             if ($themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
    1779                     $themes[$theme_name]['Template'] == $current_template) {
     1773            if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
     1774                    $themes[$theme_name]['Template'] == $current_template ) {
    17801775                $current_theme = $themes[$theme_name]['Name'];
    17811776                break;
     
    18351830    global $wp_query;
    18361831
    1837     $id = $wp_query->post->ID; 
     1832    $id = $wp_query->post->ID;
    18381833    $template = get_post_meta($id, '_wp_page_template', true);
    18391834
     
    18431838    if ( ! empty($template) && file_exists(TEMPLATEPATH . "/$template") )
    18441839        $template = TEMPLATEPATH . "/$template";
    1845     else if ( file_exists(TEMPLATEPATH .  "/page.php") )
    1846         $template = TEMPLATEPATH .  "/page.php";
     1840    else if ( file_exists(TEMPLATEPATH . "/page.php") )
     1841        $template = TEMPLATEPATH . "/page.php";
    18471842    else
    18481843        $template = '';
     
    18841879    global $plugin_page;
    18851880
    1886     if (isset($plugin_page)) {
     1881    if ( isset($plugin_page) )
    18871882        return true;
    1888     }
    18891883
    18901884    return false;
     
    19031897function add_query_arg() {
    19041898    $ret = '';
    1905     if(is_array(func_get_arg(0))) {
     1899    if ( is_array(func_get_arg(0)) ) {
    19061900        $uri = @func_get_arg(1);
    1907     }
    1908     else {
    1909         if (@func_num_args() < 3) {
     1901    } else {
     1902        if ( @func_num_args() < 3 )
    19101903            $uri = $_SERVER['REQUEST_URI'];
    1911         } else {
     1904        else
    19121905            $uri = @func_get_arg(2);
    1913         }
    1914     }
    1915 
    1916     if (strstr($uri, '?')) {
     1906    }
     1907
     1908    if ( strstr($uri, '?') ) {
    19171909        $parts = explode('?', $uri, 2);
    1918         if (1 == count($parts)) {
     1910        if ( 1 == count($parts) ) {
    19191911            $base = '?';
    19201912            $query = $parts[0];
    1921         }
    1922         else {
     1913        } else {
    19231914            $base = $parts[0] . '?';
    19241915            $query = $parts[1];
    19251916        }
    19261917    }
    1927     else if (strstr($uri, '/')) {
     1918    else if ( strstr($uri, '/') ) {
    19281919        $base = $uri . '?';
    19291920        $query = '';
     
    19341925
    19351926    parse_str($query, $qs);
    1936     if (is_array(func_get_arg(0))) {
     1927    if ( is_array(func_get_arg(0)) ) {
    19371928        $kayvees = func_get_arg(0);
    19381929        $qs = array_merge($qs, $kayvees);
    1939     }
    1940     else
    1941     {
    1942             $qs[func_get_arg(0)] = func_get_arg(1);
    1943     }
    1944 
    1945     foreach($qs as $k => $v)
    1946     {
    1947             if($v != '')
    1948         {
    1949                     if($ret != '') $ret .= '&';
    1950                     $ret .= "$k=$v";
    1951         }
    1952     }
    1953     $ret = $base . $ret;   
     1930    } else {
     1931        $qs[func_get_arg(0)] = func_get_arg(1);
     1932    }
     1933
     1934    foreach($qs as $k => $v) {
     1935        if ( $v != '' ) {
     1936            if ( $ret != '' )
     1937                $ret .= '&';
     1938            $ret .= "$k=$v";
     1939        }
     1940    }
     1941    $ret = $base . $ret;
    19541942    return trim($ret, '?');
    19551943}
     
    19721960
    19731961    foreach ($array as $k => $v) {
    1974         if (is_array($v)) {
     1962        if ( is_array($v) ) {
    19751963            $array[$k] = add_magic_quotes($v);
    19761964        } else {
     
    19901978            $linea .= $remote_read;
    19911979        fclose($fp);
    1992         return $linea;     
     1980        return $linea;
    19931981    } else if ( function_exists('curl_init') ) {
    19941982        $handle = curl_init();
     
    20011989    } else {
    20021990        return false;
    2003     }   
     1991    }
    20041992}
    20051993
    20061994function wp($query_vars = '') {
    20071995    global $wp;
     1996   
    20081997    $wp->main($query_vars);
    20091998}
    20101999
    20112000function status_header( $header ) {
    2012     if ( 200 == $header ) {
     2001    if ( 200 == $header )
    20132002        $text = 'OK';
    2014     } elseif ( 301 == $header ) {
     2003    elseif ( 301 == $header )
    20152004        $text = 'Moved Permanently';
    2016     } elseif ( 302 == $header ) {
     2005    elseif ( 302 == $header )
    20172006        $text = 'Moved Temporarily';
    2018     } elseif ( 304 == $header ) {
     2007    elseif ( 304 == $header )
    20192008        $text = 'Not Modified';
    2020     } elseif ( 404 == $header ) {
     2009    elseif ( 404 == $header )
    20212010        $text = 'Not Found';
    2022     } elseif ( 410 == $header ) {
     2011    elseif ( 410 == $header )
    20232012        $text = 'Gone';
    2024     }
     2013
    20252014    if ( preg_match('/cgi/',php_sapi_name()) ) {
    20262015        @header("Status: $header $text");
     
    20572046            return '';
    20582047    }
    2059    
     2048
    20602049    foreach ($metas as $index => $meta) {
    20612050        @ $value = unserialize($meta->meta_value);
    2062         if ($value === FALSE)
     2051        if ( $value === FALSE )
    20632052            $value = $meta->meta_value;
    2064            
     2053
    20652054        $values[] = $value;
    20662055    }
     
    20942083function register_activation_hook($file, $function) {
    20952084    $file = plugin_basename($file);
    2096    
     2085
    20972086    add_action('activate_' . $file, $function);
    20982087}
     
    21002089function register_deactivation_hook($file, $function) {
    21012090    $file = plugin_basename($file);
    2102    
     2091
    21032092    add_action('deactivate_' . $file, $function);
    21042093}
Note: See TracChangeset for help on using the changeset viewer.