Make WordPress Core


Ignore:
Timestamp:
02/01/2009 09:45:24 AM (16 years ago)
Author:
azaozz
Message:

Detect when the server compresses output, see #8628

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r10451 r10476  
    18171817    $numposts = get_usernumposts( $user_object->ID );
    18181818    $checkbox = '';
    1819     // Check if the user for this row is editable 
     1819    // Check if the user for this row is editable
    18201820    if ( current_user_can( 'edit_user', $user_object->ID ) ) {
    1821         // Set up the user editing link 
     1821        // Set up the user editing link
    18221822        // TODO: make profile/user-edit determination a seperate function
    18231823        if ($current_user->ID == $user_object->ID) {
     
    18271827        }
    18281828        $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
    1829        
     1829
    18301830        // Set up the hover actions for this user
    18311831        $actions = array();
     
    18421842        }
    18431843        $edit .= '</div>';
    1844        
     1844
    18451845        // Set up the checkbox (because the user is editable, otherwise its empty)
    18461846        $checkbox = "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />";
    1847        
     1847
    18481848    } else {
    18491849        $edit = '<strong>' . $user_object->user_login . '</strong>';
     
    19231923    $count = wp_count_comments();
    19241924    $index = '';
    1925    
     1925
    19261926    if ( 'moderated' == $status ) {
    19271927        $approved = "comment_approved = '0'";
     
    26162616}
    26172617
    2618  
     2618
    26192619/**
    26202620 * Print out <option> html elements for role selectors based on $wp_roles
     
    26312631    $p = '';
    26322632    $r = '';
    2633    
     2633
    26342634    $editable_roles = get_editable_roles();
    2635    
     2635
    26362636    foreach( $editable_roles as $role => $details ) {
    26372637        $name = translate_with_context($details['name']);
     
    34033403 * and sets an option with the result. Has no effect when the current user
    34043404 * is not an administrator. To run the test again the option 'can_compress_scripts'
    3405  * has to be deleted. 
     3405 * has to be deleted.
    34063406 *
    34073407 * @since 2.8.0
     
    34093409function compression_test() {
    34103410?>
    3411     <script type="text/javascript" src="load-scripts.php?test=1<?php echo ( defined('ENFORCE_GZIP') && ENFORCE_GZIP ) ? '&c=gzip' : ''; ?>"></script>
    34123411    <script type="text/javascript">
    34133412    /* <![CDATA[ */
    3414     (function() {
    3415         var x, test = typeof wpCompressionTest == 'undefined' ? 0 : 1;
    3416         if ( window.XMLHttpRequest ) {
    3417             x = new XMLHttpRequest();
    3418         } else {
    3419             try{x=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{x=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){};}
     3413    var testCompression = {
     3414        get : function(test) {
     3415            var x;
     3416            if ( window.XMLHttpRequest ) {
     3417                x = new XMLHttpRequest();
     3418            } else {
     3419                try{x=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{x=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){};}
     3420            }
     3421
     3422            if (x) {
     3423                x.onreadystatechange = function() {
     3424                    var r, h;
     3425                    if ( x.readyState == 4 ) {
     3426                        r = x.responseText.substr(0, 18);
     3427                        h = x.getResponseHeader('Content-Encoding');
     3428                        testCompression.check(r, h, test);
     3429                    }
     3430                }
     3431
     3432                x.open('GET', 'admin-ajax.php?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true);
     3433                x.send('');
     3434            }
     3435        },
     3436
     3437        check : function(r, h, test) {
     3438            if ( ! r && ! test )
     3439                this.get(1);
     3440
     3441            if ( 1 == test ) {
     3442                if ( h && ( h.match(/deflate/i) || h.match(/gzip/i) ) )
     3443                    this.get('no');
     3444                else
     3445                    this.get(2);
     3446
     3447                return;
     3448            }
     3449
     3450            if ( 2 == test ) {
     3451                if ( '"wpCompressionTest' == r )
     3452                    this.get('yes');
     3453                else
     3454                    this.get('no');
     3455            }
    34203456        }
    3421    
    3422         if (x) {
    3423             x.open('GET', 'admin-ajax.php?action=wp-compression-test&tested='+test+'&'+(new Date()).getTime(), true);
    3424             x.send('');
    3425         }
    3426     })();
     3457    };
     3458    testCompression.check();
    34273459    /* ]]> */
    34283460    </script>
Note: See TracChangeset for help on using the changeset viewer.