Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r42199 r42343  
    1515 */
    1616function got_mod_rewrite() {
    17     $got_rewrite = apache_mod_loaded('mod_rewrite', true);
     17    $got_rewrite = apache_mod_loaded( 'mod_rewrite', true );
    1818
    1919    /**
     
    6666 */
    6767function extract_from_markers( $filename, $marker ) {
    68     $result = array ();
     68    $result = array();
    6969
    7070    if ( ! file_exists( $filename ) ) {
     
    137137
    138138    // Split out the existing file into the preceding lines, and those that appear after the marker
    139     $pre_lines = $post_lines = $existing_lines = array();
     139    $pre_lines    = $post_lines = $existing_lines = array();
    140140    $found_marker = $found_end_marker = false;
    141141    foreach ( $lines as $line ) {
     
    165165
    166166    // Generate the new file data
    167     $new_file_data = implode( "\n", array_merge(
    168         $pre_lines,
    169         array( $start_marker ),
    170         $insertion,
    171         array( $end_marker ),
    172         $post_lines
    173     ) );
     167    $new_file_data = implode(
     168        "\n", array_merge(
     169            $pre_lines,
     170            array( $start_marker ),
     171            $insertion,
     172            array( $end_marker ),
     173            $post_lines
     174        )
     175    );
    174176
    175177    // Write to the start of the file, and truncate it to that length
     
    197199 */
    198200function save_mod_rewrite_rules() {
    199     if ( is_multisite() )
     201    if ( is_multisite() ) {
    200202        return;
     203    }
    201204
    202205    global $wp_rewrite;
    203206
    204     $home_path = get_home_path();
    205     $htaccess_file = $home_path.'.htaccess';
     207    $home_path     = get_home_path();
     208    $htaccess_file = $home_path . '.htaccess';
    206209
    207210    /*
     
    209212     * and whether we have some rules. Else check for write access to the file.
    210213     */
    211     if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
     214    if ( ( ! file_exists( $htaccess_file ) && is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks() ) || is_writable( $htaccess_file ) ) {
    212215        if ( got_mod_rewrite() ) {
    213216            $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
     
    229232 * @return bool True if web.config was updated successfully
    230233 */
    231 function iis7_save_url_rewrite_rules(){
    232     if ( is_multisite() )
     234function iis7_save_url_rewrite_rules() {
     235    if ( is_multisite() ) {
    233236        return;
     237    }
    234238
    235239    global $wp_rewrite;
    236240
    237     $home_path = get_home_path();
     241    $home_path       = get_home_path();
    238242    $web_config_file = $home_path . 'web.config';
    239243
    240244    // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP
    241     if ( iis7_supports_permalinks() && ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) ) {
    242         $rule = $wp_rewrite->iis7_url_rewrite_rules(false, '', '');
    243         if ( ! empty($rule) ) {
    244             return iis7_add_rewrite_rule($web_config_file, $rule);
     245    if ( iis7_supports_permalinks() && ( ( ! file_exists( $web_config_file ) && win_is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable( $web_config_file ) ) ) {
     246        $rule = $wp_rewrite->iis7_url_rewrite_rules( false, '', '' );
     247        if ( ! empty( $rule ) ) {
     248            return iis7_add_rewrite_rule( $web_config_file, $rule );
    245249        } else {
    246             return iis7_delete_rewrite_rule($web_config_file);
     250            return iis7_delete_rewrite_rule( $web_config_file );
    247251        }
    248252    }
     
    258262 */
    259263function update_recently_edited( $file ) {
    260     $oldfiles = (array ) get_option( 'recently_edited' );
     264    $oldfiles = (array) get_option( 'recently_edited' );
    261265    if ( $oldfiles ) {
    262         $oldfiles = array_reverse( $oldfiles );
     266        $oldfiles   = array_reverse( $oldfiles );
    263267        $oldfiles[] = $file;
    264         $oldfiles = array_reverse( $oldfiles );
    265         $oldfiles = array_unique( $oldfiles );
    266         if ( 5 < count( $oldfiles ))
     268        $oldfiles   = array_reverse( $oldfiles );
     269        $oldfiles   = array_unique( $oldfiles );
     270        if ( 5 < count( $oldfiles ) ) {
    267271            array_pop( $oldfiles );
     272        }
    268273    } else {
    269274        $oldfiles[] = $file;
     
    284289    $tree_list = array();
    285290    foreach ( $allowed_files as $file_name => $absolute_filename ) {
    286         $list = explode( '/', $file_name );
     291        $list     = explode( '/', $file_name );
    287292        $last_dir = &$tree_list;
    288293        foreach ( $list as $dir ) {
     
    310315    if ( is_array( $tree ) ) {
    311316        $index = 0;
    312         $size = count( $tree );
     317        $size  = count( $tree );
    313318        foreach ( $tree as $label => $theme_file ) :
    314319            $index++;
     
    329334    } else {
    330335        $filename = $tree;
    331         $url = add_query_arg(
     336        $url      = add_query_arg(
    332337            array(
    333                 'file' => rawurlencode( $tree ),
     338                'file'  => rawurlencode( $tree ),
    334339                'theme' => rawurlencode( $stylesheet ),
    335340            ),
     
    373378    $tree_list = array();
    374379    foreach ( $plugin_editable_files as $plugin_file ) {
    375         $list = explode( '/', preg_replace( '#^.+?/#', '', $plugin_file ) );
     380        $list     = explode( '/', preg_replace( '#^.+?/#', '', $plugin_file ) );
    376381        $last_dir = &$tree_list;
    377382        foreach ( $list as $dir ) {
     
    399404    if ( is_array( $tree ) ) {
    400405        $index = 0;
    401         $size = count( $tree );
     406        $size  = count( $tree );
    402407        foreach ( $tree as $label => $plugin_file ) :
    403408            $index++;
     
    419424        $url = add_query_arg(
    420425            array(
    421                 'file' => rawurlencode( $tree ),
     426                'file'   => rawurlencode( $tree ),
    422427                'plugin' => rawurlencode( $plugin ),
    423428            ),
     
    453458 */
    454459function update_home_siteurl( $old_value, $value ) {
    455     if ( wp_installing() )
     460    if ( wp_installing() ) {
    456461        return;
     462    }
    457463
    458464    if ( is_multisite() && ms_is_switched() ) {
     
    496502 * @param string|WP_Error $message
    497503 */
    498 function show_message($message) {
    499     if ( is_wp_error($message) ){
    500         if ( $message->get_error_data() && is_string( $message->get_error_data() ) )
     504function show_message( $message ) {
     505    if ( is_wp_error( $message ) ) {
     506        if ( $message->get_error_data() && is_string( $message->get_error_data() ) ) {
    501507            $message = $message->get_error_message() . ': ' . $message->get_error_data();
    502         else
     508        } else {
    503509            $message = $message->get_error_message();
     510        }
    504511    }
    505512    echo "<p>$message</p>\n";
     
    515522 */
    516523function wp_doc_link_parse( $content ) {
    517     if ( !is_string( $content ) || empty( $content ) )
     524    if ( ! is_string( $content ) || empty( $content ) ) {
    518525        return array();
    519 
    520     if ( !function_exists('token_get_all') )
     526    }
     527
     528    if ( ! function_exists( 'token_get_all' ) ) {
    521529        return array();
    522 
    523     $tokens = token_get_all( $content );
    524     $count = count( $tokens );
    525     $functions = array();
     530    }
     531
     532    $tokens           = token_get_all( $content );
     533    $count            = count( $tokens );
     534    $functions        = array();
    526535    $ignore_functions = array();
    527536    for ( $t = 0; $t < $count - 2; $t++ ) {
     
    533542            // If it's a function or class defined locally, there's not going to be any docs available
    534543            if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) {
    535                 $ignore_functions[] = $tokens[$t][1];
     544                $ignore_functions[] = $tokens[ $t ][1];
    536545            }
    537546            // Add this to our stack of unique references
    538             $functions[] = $tokens[$t][1];
     547            $functions[] = $tokens[ $t ][1];
    539548        }
    540549    }
     
    556565    $out = array();
    557566    foreach ( $functions as $function ) {
    558         if ( in_array( $function, $ignore_functions ) )
     567        if ( in_array( $function, $ignore_functions ) ) {
    559568            continue;
     569        }
    560570        $out[] = $function;
    561571    }
     
    571581function set_screen_options() {
    572582
    573     if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) {
     583    if ( isset( $_POST['wp_screen_options'] ) && is_array( $_POST['wp_screen_options'] ) ) {
    574584        check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
    575585
    576         if ( !$user = wp_get_current_user() )
     586        if ( ! $user = wp_get_current_user() ) {
    577587            return;
     588        }
    578589        $option = $_POST['wp_screen_options']['option'];
    579         $value = $_POST['wp_screen_options']['value'];
    580 
    581         if ( $option != sanitize_key( $option ) )
     590        $value  = $_POST['wp_screen_options']['value'];
     591
     592        if ( $option != sanitize_key( $option ) ) {
    582593            return;
     594        }
    583595
    584596        $map_option = $option;
    585         $type = str_replace('edit_', '', $map_option);
    586         $type = str_replace('_per_page', '', $type);
    587         if ( in_array( $type, get_taxonomies() ) )
     597        $type       = str_replace( 'edit_', '', $map_option );
     598        $type       = str_replace( '_per_page', '', $type );
     599        if ( in_array( $type, get_taxonomies() ) ) {
    588600            $map_option = 'edit_tags_per_page';
    589         elseif ( in_array( $type, get_post_types() ) )
     601        } elseif ( in_array( $type, get_post_types() ) ) {
    590602            $map_option = 'edit_per_page';
    591         else
    592             $option = str_replace('-', '_', $option);
     603        } else {
     604            $option = str_replace( '-', '_', $option );
     605        }
    593606
    594607        switch ( $map_option ) {
     
    599612            case 'edit_tags_per_page':
    600613            case 'plugins_per_page':
    601             // Network admin
     614                // Network admin
    602615            case 'sites_network_per_page':
    603616            case 'users_network_per_page':
     
    607620            case 'site_themes_network_per_page':
    608621                $value = (int) $value;
    609                 if ( $value < 1 || $value > 999 )
     622                if ( $value < 1 || $value > 999 ) {
    610623                    return;
     624                }
    611625                break;
    612626            default:
    613 
    614627                /**
    615628                 * Filters a screen option value before it is set.
     
    630643                $value = apply_filters( 'set-screen-option', false, $option, $value );
    631644
    632                 if ( false === $value )
     645                if ( false === $value ) {
    633646                    return;
     647                }
    634648                break;
    635649        }
    636650
    637         update_user_meta($user->ID, $option, $value);
     651        update_user_meta( $user->ID, $option, $value );
    638652
    639653        $url = remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() );
     
    655669 * @param string $filename The file path to the configuration file
    656670 */
    657 function iis7_rewrite_rule_exists($filename) {
    658     if ( ! file_exists($filename) )
     671function iis7_rewrite_rule_exists( $filename ) {
     672    if ( ! file_exists( $filename ) ) {
    659673        return false;
     674    }
    660675    if ( ! class_exists( 'DOMDocument', false ) ) {
    661676        return false;
     
    663678
    664679    $doc = new DOMDocument();
    665     if ( $doc->load($filename) === false )
     680    if ( $doc->load( $filename ) === false ) {
    666681        return false;
    667     $xpath = new DOMXPath($doc);
    668     $rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
    669     if ( $rules->length == 0 )
     682    }
     683    $xpath = new DOMXPath( $doc );
     684    $rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
     685    if ( $rules->length == 0 ) {
    670686        return false;
    671     else
     687    } else {
    672688        return true;
     689    }
    673690}
    674691
     
    681698 * @return bool
    682699 */
    683 function iis7_delete_rewrite_rule($filename) {
     700function iis7_delete_rewrite_rule( $filename ) {
    684701    // If configuration file does not exist then rules also do not exist so there is nothing to delete
    685     if ( ! file_exists($filename) )
     702    if ( ! file_exists( $filename ) ) {
    686703        return true;
     704    }
    687705
    688706    if ( ! class_exists( 'DOMDocument', false ) ) {
     
    690708    }
    691709
    692     $doc = new DOMDocument();
     710    $doc                     = new DOMDocument();
    693711    $doc->preserveWhiteSpace = false;
    694712
    695     if ( $doc -> load($filename) === false )
     713    if ( $doc->load( $filename ) === false ) {
    696714        return false;
    697     $xpath = new DOMXPath($doc);
    698     $rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
     715    }
     716    $xpath = new DOMXPath( $doc );
     717    $rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
    699718    if ( $rules->length > 0 ) {
    700         $child = $rules->item(0);
     719        $child  = $rules->item( 0 );
    701720        $parent = $child->parentNode;
    702         $parent->removeChild($child);
     721        $parent->removeChild( $child );
    703722        $doc->formatOutput = true;
    704         saveDomDocument($doc, $filename);
     723        saveDomDocument( $doc, $filename );
    705724    }
    706725    return true;
     
    716735 * @return bool
    717736 */
    718 function iis7_add_rewrite_rule($filename, $rewrite_rule) {
     737function iis7_add_rewrite_rule( $filename, $rewrite_rule ) {
    719738    if ( ! class_exists( 'DOMDocument', false ) ) {
    720739        return false;
     
    722741
    723742    // If configuration file does not exist then we create one.
    724     if ( ! file_exists($filename) ) {
    725         $fp = fopen( $filename, 'w');
    726         fwrite($fp, '<configuration/>');
    727         fclose($fp);
    728     }
    729 
    730     $doc = new DOMDocument();
     743    if ( ! file_exists( $filename ) ) {
     744        $fp = fopen( $filename, 'w' );
     745        fwrite( $fp, '<configuration/>' );
     746        fclose( $fp );
     747    }
     748
     749    $doc                     = new DOMDocument();
    731750    $doc->preserveWhiteSpace = false;
    732751
    733     if ( $doc->load($filename) === false )
     752    if ( $doc->load( $filename ) === false ) {
    734753        return false;
    735 
    736     $xpath = new DOMXPath($doc);
     754    }
     755
     756    $xpath = new DOMXPath( $doc );
    737757
    738758    // First check if the rule already exists as in that case there is no need to re-add it
    739     $wordpress_rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
    740     if ( $wordpress_rules->length > 0 )
     759    $wordpress_rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
     760    if ( $wordpress_rules->length > 0 ) {
    741761        return true;
     762    }
    742763
    743764    // Check the XPath to the rewrite rule and create XML nodes if they do not exist
    744     $xmlnodes = $xpath->query('/configuration/system.webServer/rewrite/rules');
     765    $xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite/rules' );
    745766    if ( $xmlnodes->length > 0 ) {
    746         $rules_node = $xmlnodes->item(0);
     767        $rules_node = $xmlnodes->item( 0 );
    747768    } else {
    748         $rules_node = $doc->createElement('rules');
    749 
    750         $xmlnodes = $xpath->query('/configuration/system.webServer/rewrite');
     769        $rules_node = $doc->createElement( 'rules' );
     770
     771        $xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite' );
    751772        if ( $xmlnodes->length > 0 ) {
    752             $rewrite_node = $xmlnodes->item(0);
    753             $rewrite_node->appendChild($rules_node);
     773            $rewrite_node = $xmlnodes->item( 0 );
     774            $rewrite_node->appendChild( $rules_node );
    754775        } else {
    755             $rewrite_node = $doc->createElement('rewrite');
    756             $rewrite_node->appendChild($rules_node);
    757 
    758             $xmlnodes = $xpath->query('/configuration/system.webServer');
     776            $rewrite_node = $doc->createElement( 'rewrite' );
     777            $rewrite_node->appendChild( $rules_node );
     778
     779            $xmlnodes = $xpath->query( '/configuration/system.webServer' );
    759780            if ( $xmlnodes->length > 0 ) {
    760                 $system_webServer_node = $xmlnodes->item(0);
    761                 $system_webServer_node->appendChild($rewrite_node);
     781                $system_webServer_node = $xmlnodes->item( 0 );
     782                $system_webServer_node->appendChild( $rewrite_node );
    762783            } else {
    763                 $system_webServer_node = $doc->createElement('system.webServer');
    764                 $system_webServer_node->appendChild($rewrite_node);
    765 
    766                 $xmlnodes = $xpath->query('/configuration');
     784                $system_webServer_node = $doc->createElement( 'system.webServer' );
     785                $system_webServer_node->appendChild( $rewrite_node );
     786
     787                $xmlnodes = $xpath->query( '/configuration' );
    767788                if ( $xmlnodes->length > 0 ) {
    768                     $config_node = $xmlnodes->item(0);
    769                     $config_node->appendChild($system_webServer_node);
     789                    $config_node = $xmlnodes->item( 0 );
     790                    $config_node->appendChild( $system_webServer_node );
    770791                } else {
    771                     $config_node = $doc->createElement('configuration');
    772                     $doc->appendChild($config_node);
    773                     $config_node->appendChild($system_webServer_node);
     792                    $config_node = $doc->createElement( 'configuration' );
     793                    $doc->appendChild( $config_node );
     794                    $config_node->appendChild( $system_webServer_node );
    774795                }
    775796            }
     
    778799
    779800    $rule_fragment = $doc->createDocumentFragment();
    780     $rule_fragment->appendXML($rewrite_rule);
    781     $rules_node->appendChild($rule_fragment);
    782 
    783     $doc->encoding = "UTF-8";
     801    $rule_fragment->appendXML( $rewrite_rule );
     802    $rules_node->appendChild( $rule_fragment );
     803
     804    $doc->encoding     = 'UTF-8';
    784805    $doc->formatOutput = true;
    785     saveDomDocument($doc, $filename);
     806    saveDomDocument( $doc, $filename );
    786807
    787808    return true;
     
    796817 * @param string $filename
    797818 */
    798 function saveDomDocument($doc, $filename) {
     819function saveDomDocument( $doc, $filename ) {
    799820    $config = $doc->saveXML();
    800     $config = preg_replace("/([^\r])\n/", "$1\r\n", $config);
    801     $fp = fopen($filename, 'w');
    802     fwrite($fp, $config);
    803     fclose($fp);
     821    $config = preg_replace( "/([^\r])\n/", "$1\r\n", $config );
     822    $fp     = fopen( $filename, 'w' );
     823    fwrite( $fp, $config );
     824    fclose( $fp );
    804825}
    805826
     
    820841    if ( isset( $_wp_admin_css_colors['fresh'] ) ) {
    821842        // Set Default ('fresh') and Light should go first.
    822         $_wp_admin_css_colors = array_filter( array_merge( array( 'fresh' => '', 'light' => '' ), $_wp_admin_css_colors ) );
     843        $_wp_admin_css_colors = array_filter(
     844            array_merge(
     845                array(
     846                    'fresh' => '',
     847                    'light' => '',
     848                ), $_wp_admin_css_colors
     849            )
     850        );
    823851    }
    824852
     
    866894
    867895/**
    868  *
    869896 * @global array $_wp_admin_css_colors
    870897 */
     
    885912    } else {
    886913        // Fall back to the default set of icon colors if the default scheme is missing.
    887         $icon_colors = array( 'base' => '#82878c', 'focus' => '#00a0d2', 'current' => '#fff' );
     914        $icon_colors = array(
     915            'base'    => '#82878c',
     916            'focus'   => '#00a0d2',
     917            'current' => '#fff',
     918        );
    888919    }
    889920
     
    917948    if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
    918949        foreach ( $data['wp-check-locked-posts'] as $key ) {
    919             if ( ! $post_id = absint( substr( $key, 5 ) ) )
     950            if ( ! $post_id = absint( substr( $key, 5 ) ) ) {
    920951                continue;
     952            }
    921953
    922954            if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) && current_user_can( 'edit_post', $post_id ) ) {
    923955                $send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) );
    924956
    925                 if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) )
     957                if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) {
    926958                    $send['avatar_src'] = $matches[1];
    927 
    928                 $checked[$key] = $send;
     959                }
     960
     961                $checked[ $key ] = $send;
    929962            }
    930963        }
    931964    }
    932965
    933     if ( ! empty( $checked ) )
     966    if ( ! empty( $checked ) ) {
    934967        $response['wp-check-locked-posts'] = $checked;
     968    }
    935969
    936970    return $response;
     
    950984    if ( array_key_exists( 'wp-refresh-post-lock', $data ) ) {
    951985        $received = $data['wp-refresh-post-lock'];
    952         $send = array();
    953 
    954         if ( ! $post_id = absint( $received['post_id'] ) )
     986        $send     = array();
     987
     988        if ( ! $post_id = absint( $received['post_id'] ) ) {
    955989            return $response;
    956 
    957         if ( ! current_user_can('edit_post', $post_id) )
     990        }
     991
     992        if ( ! current_user_can( 'edit_post', $post_id ) ) {
    958993            return $response;
     994        }
    959995
    960996        if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) {
    961997            $error = array(
    962                 'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name )
     998                'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name ),
    963999            );
    9641000
    9651001            if ( $avatar = get_avatar( $user->ID, 64 ) ) {
    966                 if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) )
     1002                if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) {
    9671003                    $error['avatar_src'] = $matches[1];
     1004                }
    9681005            }
    9691006
    9701007            $send['lock_error'] = $error;
    9711008        } else {
    972             if ( $new_lock = wp_set_post_lock( $post_id ) )
     1009            if ( $new_lock = wp_set_post_lock( $post_id ) ) {
    9731010                $send['new_lock'] = implode( ':', $new_lock );
     1011            }
    9741012        }
    9751013
     
    9921030function wp_refresh_post_nonces( $response, $data, $screen_id ) {
    9931031    if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) {
    994         $received = $data['wp-refresh-post-nonces'];
     1032        $received                           = $data['wp-refresh-post-nonces'];
    9951033        $response['wp-refresh-post-nonces'] = array( 'check' => 1 );
    9961034
     
    10041042
    10051043        $response['wp-refresh-post-nonces'] = array(
    1006             'replace' => array(
    1007                 'getpermalinknonce' => wp_create_nonce('getpermalink'),
    1008                 'samplepermalinknonce' => wp_create_nonce('samplepermalink'),
    1009                 'closedpostboxesnonce' => wp_create_nonce('closedpostboxes'),
    1010                 '_ajax_linking_nonce' => wp_create_nonce( 'internal-linking' ),
    1011                 '_wpnonce' => wp_create_nonce( 'update-post_' . $post_id ),
     1044            'replace'        => array(
     1045                'getpermalinknonce'    => wp_create_nonce( 'getpermalink' ),
     1046                'samplepermalinknonce' => wp_create_nonce( 'samplepermalink' ),
     1047                'closedpostboxesnonce' => wp_create_nonce( 'closedpostboxes' ),
     1048                '_ajax_linking_nonce'  => wp_create_nonce( 'internal-linking' ),
     1049                '_wpnonce'             => wp_create_nonce( 'update-post_' . $post_id ),
    10121050            ),
    10131051            'heartbeatNonce' => wp_create_nonce( 'heartbeat-nonce' ),
     
    10521090
    10531091        if ( is_wp_error( $saved ) ) {
    1054             $response['wp_autosave'] = array( 'success' => false, 'message' => $saved->get_error_message() );
     1092            $response['wp_autosave'] = array(
     1093                'success' => false,
     1094                'message' => $saved->get_error_message(),
     1095            );
    10551096        } elseif ( empty( $saved ) ) {
    1056             $response['wp_autosave'] = array( 'success' => false, 'message' => __( 'Error while saving.' ) );
     1097            $response['wp_autosave'] = array(
     1098                'success' => false,
     1099                'message' => __( 'Error while saving.' ),
     1100            );
    10571101        } else {
    10581102            /* translators: draft saved date format, see https://secure.php.net/date */
    10591103            $draft_saved_date_format = __( 'g:i:s a' );
    10601104            /* translators: %s: date and time */
    1061             $response['wp_autosave'] = array( 'success' => true, 'message' => sprintf( __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ) );
     1105            $response['wp_autosave'] = array(
     1106                'success' => true,
     1107                'message' => sprintf( __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ),
     1108            );
    10621109        }
    10631110    }
     
    11491196    }
    11501197
    1151     $hash = md5( $value . time() . mt_rand() );
     1198    $hash            = md5( $value . time() . mt_rand() );
    11521199    $new_admin_email = array(
    11531200        'hash'     => $hash,
     
    11591206
    11601207    /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
    1161     $email_text = __( 'Howdy ###USERNAME###,
     1208    $email_text = __(
     1209        'Howdy ###USERNAME###,
    11621210
    11631211You recently requested to have the administration email address on
     
    11741222Regards,
    11751223All at ###SITENAME###
    1176 ###SITEURL###' );
     1224###SITEURL###'
     1225    );
    11771226
    11781227    /**
     
    12001249
    12011250    $current_user = wp_get_current_user();
    1202     $content = str_replace( '###USERNAME###', $current_user->user_login, $content );
    1203     $content = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash=' . $hash ) ), $content );
    1204     $content = str_replace( '###EMAIL###', $value, $content );
    1205     $content = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content );
    1206     $content = str_replace( '###SITEURL###', home_url(), $content );
     1251    $content      = str_replace( '###USERNAME###', $current_user->user_login, $content );
     1252    $content      = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash=' . $hash ) ), $content );
     1253    $content      = str_replace( '###EMAIL###', $value, $content );
     1254    $content      = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content );
     1255    $content      = str_replace( '###SITEURL###', home_url(), $content );
    12071256
    12081257    wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ), $content );
Note: See TracChangeset for help on using the changeset viewer.