WordPress.org

Make WordPress Core

Changeset 47084


Ignore:
Timestamp:
01/18/2020 12:52:28 AM (23 months ago)
Author:
SergeyBiryukov
Message:

Docs: Improve comments in some wp-admin files per the documentation standards.

Props passoniate.
Fixes #49215, #49216.

Location:
trunk/src/wp-admin/includes
Files:
10 edited

Legend:

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

    r45583 r47084  
    166166    $pending_keyed = array();
    167167
    168     // Default to zero pending for all posts in request
     168    // Default to zero pending for all posts in request.
    169169    foreach ( $post_id_array as $id ) {
    170170        $pending_keyed[ $id ] = 0;
  • trunk/src/wp-admin/includes/dashboard.php

    r47069 r47084  
    5757    }
    5858
    59     // Right Now
     59    // Right Now.
    6060    if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) {
    6161        wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' );
     
    6666    }
    6767
    68     // Activity Widget
     68    // Activity Widget.
    6969    if ( is_blog_admin() ) {
    7070        wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' );
    7171    }
    7272
    73     // QuickPress Widget
     73    // QuickPress Widget.
    7474    if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
    7575        $quick_draft_title = sprintf( '<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __( 'Quick Draft' ), __( 'Your Recent Drafts' ) );
     
    7777    }
    7878
    79     // WordPress Events and News
     79    // WordPress Events and News.
    8080    wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' );
    8181
     
    140140    if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget_id'] ) ) {
    141141        check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' );
    142         ob_start(); // hack - but the same hack wp-admin/widgets.php uses
     142        ob_start(); // Hack - but the same hack wp-admin/widgets.php uses.
    143143        wp_dashboard_trigger_widget_control( $_POST['widget_id'] );
    144144        ob_end_clean();
     
    279279    <ul>
    280280    <?php
    281     // Posts and Pages
     281    // Posts and Pages.
    282282    foreach ( array( 'post', 'page' ) as $post_type ) {
    283283        $num_posts = wp_count_posts( $post_type );
     
    299299        }
    300300    }
    301     // Comments
     301    // Comments.
    302302    $num_comm = wp_count_comments();
    303303    if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) {
     
    507507
    508508    /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
    509     $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
     509    $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID.
    510510    if ( $last_post_id ) {
    511511        $post = get_post( $last_post_id );
    512         if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
     512        if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore.
    513513            $post = get_default_post_to_edit( 'post', true );
    514             update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
     514            update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID.
    515515        } else {
    516             $post->post_title = ''; // Remove the auto draft title
     516            $post->post_title = ''; // Remove the auto draft title.
    517517        }
    518518    } else {
     
    521521        // Don't create an option if this is a super admin who does not belong to this site.
    522522        if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) {
    523             update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
     523            update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID.
    524524        }
    525525    }
     
    761761            ( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
    762762
    763             // Reply and quickedit need a hide-if-no-js span
     763            // Reply and quickedit need a hide-if-no-js span.
    764764            if ( 'reply' == $action || 'quickedit' == $action ) {
    765765                $action .= ' hide-if-no-js';
     
    11091109        ob_start();
    11101110        call_user_func_array( $callback, $args );
    1111         set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
     1111        // Default lifetime in cache of 12 hours (same as the feeds).
     1112        set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS );
    11121113    }
    11131114
     
    11641165    }
    11651166
    1166     $number                                 = 1; // Hack to use wp_widget_rss_form()
     1167    $number = 1; // Hack to use wp_widget_rss_form().
     1168
    11671169    $widget_options[ $widget_id ]['number'] = $number;
    11681170
     
    16631665    $response = get_site_transient( 'browser_' . $key );
    16641666    if ( false === $response ) {
    1665         // include an unmodified $wp_version
     1667        // Include an unmodified $wp_version.
    16661668        include( ABSPATH . WPINC . '/version.php' );
    16671669
  • trunk/src/wp-admin/includes/deprecated.php

    r46644 r47084  
    234234        $level_key = $wpdb->get_blog_prefix() . 'user_level';
    235235    else
    236         $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
     236        $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
    237237
    238238    return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
     
    296296        $level_key = $wpdb->get_blog_prefix() . 'user_level';
    297297    else
    298         $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
     298        $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
    299299
    300300    $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
     
    320320        $level_key = $wpdb->get_blog_prefix() . 'user_level';
    321321    else
    322         $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
     322        $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
    323323
    324324    return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
     
    545545            $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
    546546        } elseif ( is_multisite() ) {
    547             $level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
     547            $level_key = $wpdb->prefix . 'capabilities'; // WPMU site admins don't have user_levels.
    548548            $this->query_from .= ", $wpdb->usermeta";
    549549            $this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
     
    565565
    566566        if ( $this->results )
    567             $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
     567            $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // No limit.
    568568        else
    569569            $this->search_errors = new WP_Error('no_matching_users_found', __('No users found.'));
     
    585585     */
    586586    public function do_paging() {
    587         if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
     587        if ( $this->total_users_for_query > $this->users_per_page ) { // Have to page the results.
    588588            $args = array();
    589589            if ( ! empty($this->search_term) )
     
    13201320    _deprecated_function( __FUNCTION__, '4.8.0' );
    13211321
    1322     // Plugin feeds plus link to install them
     1322    // Plugin feeds plus link to install them.
    13231323    $popular = fetch_feed( $args['url']['popular'] );
    13241324
     
    13361336        $items = $feed->get_items(0, 5);
    13371337
    1338         // Pick a random, non-installed plugin
     1338        // Pick a random, non-installed plugin.
    13391339        while ( true ) {
    1340             // Abort this foreach loop iteration if there's no plugins left of this type
     1340            // Abort this foreach loop iteration if there's no plugins left of this type.
    13411341            if ( 0 == count($items) )
    13421342                continue 2;
     
    13681368        }
    13691369
    1370         // Eliminate some common badly formed plugin descriptions
     1370        // Eliminate some common badly formed plugin descriptions.
    13711371        while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
    13721372            unset($items[$item_key]);
  • trunk/src/wp-admin/includes/file.php

    r47060 r47084  
    2222    '404.php'               => __( '404 Template' ),
    2323    'link.php'              => __( 'Links Template' ),
    24     // Archives
     24    // Archives.
    2525    'index.php'             => __( 'Main Index Template' ),
    2626    'archive.php'           => __( 'Archives' ),
     
    3232    'search.php'            => __( 'Search Results' ),
    3333    'date.php'              => __( 'Date Template' ),
    34     // Content
     34    // Content.
    3535    'singular.php'          => __( 'Singular Template' ),
    3636    'single.php'            => __( 'Single Post' ),
     
    3838    'front-page.php'        => __( 'Homepage' ),
    3939    'privacy-policy.php'    => __( 'Privacy Policy Page' ),
    40     // Attachments
     40    // Attachments.
    4141    'attachment.php'        => __( 'Attachment Template' ),
    4242    'image.php'             => __( 'Image Attachment Template' ),
     
    4444    'audio.php'             => __( 'Audio Attachment Template' ),
    4545    'application.php'       => __( 'Application Attachment Template' ),
    46     // Embeds
     46    // Embeds.
    4747    'embed.php'             => __( 'Embed Template' ),
    4848    'embed-404.php'         => __( 'Embed 404 Template' ),
     
    5050    'header-embed.php'      => __( 'Embed Header Template' ),
    5151    'footer-embed.php'      => __( 'Embed Footer Template' ),
    52     // Stylesheets
     52    // Stylesheets.
    5353    'style.css'             => __( 'Stylesheet' ),
    5454    'editor-style.css'      => __( 'Visual Editor Stylesheet' ),
    5555    'editor-style-rtl.css'  => __( 'Visual Editor RTL Stylesheet' ),
    5656    'rtl.css'               => __( 'RTL Stylesheet' ),
    57     // Other
     57    // Other.
    5858    'my-hacks.php'          => __( 'my-hacks.php (legacy hacks support)' ),
    5959    '.htaccess'             => __( '.htaccess (for rewrite rules )' ),
    60     // Deprecated files
     60    // Deprecated files.
    6161    'wp-layout.css'         => __( 'Stylesheet' ),
    6262    'wp-comments.php'       => __( 'Comments Template' ),
     
    456456        }
    457457
    458         // Compare based on relative paths
     458        // Compare based on relative paths.
    459459        if ( 0 !== validate_file( $file, array_keys( $allowed_files ) ) ) {
    460460            return new WP_Error( 'disallowed_theme_file', __( 'Sorry, that file cannot be edited.' ) );
     
    508508        $transient    = 'scrape_key_' . $scrape_key;
    509509        $scrape_nonce = strval( rand() );
    510         set_transient( $transient, $scrape_nonce, 60 ); // It shouldn't take more than 60 seconds to make the two loopback requests.
     510        // It shouldn't take more than 60 seconds to make the two loopback requests.
     511        set_transient( $transient, $scrape_nonce, 60 );
    511512
    512513        $cookies       = wp_unslash( $_COOKIE );
     
    645646    }
    646647
    647     // Use the basename of the given file without the extension as the name for the temporary directory
     648    // Use the basename of the given file without the extension as the name for the temporary directory.
    648649    $temp_filename = basename( $filename );
    649650    $temp_filename = preg_replace( '|\.[^.]*$|', '', $temp_filename );
     
    654655    }
    655656
    656     // Suffix some random data to avoid filename conflicts
     657    // Suffix some random data to avoid filename conflicts.
    657658    $temp_filename .= '-' . wp_generate_password( 6, false );
    658659    $temp_filename .= '.tmp';
     
    736737    $file = apply_filters( "{$action}_prefilter", $file );
    737738
    738     // You may define your own function and pass the name in $overrides['upload_error_handler']
     739    // You may define your own function and pass the name in $overrides['upload_error_handler'].
    739740    $upload_error_handler = 'wp_handle_upload_error';
    740741    if ( isset( $overrides['upload_error_handler'] ) ) {
     
    749750    // Install user overrides. Did we mention that this voids your warranty?
    750751
    751     // You may define your own function and pass the name in $overrides['unique_filename_callback']
     752    // You may define your own function and pass the name in $overrides['unique_filename_callback'].
    752753    $unique_filename_callback = null;
    753754    if ( isset( $overrides['unique_filename_callback'] ) ) {
     
    823824        $proper_filename = empty( $wp_filetype['proper_filename'] ) ? '' : $wp_filetype['proper_filename'];
    824825
    825         // Check to see if wp_check_filetype_and_ext() determined the filename was incorrect
     826        // Check to see if wp_check_filetype_and_ext() determined the filename was incorrect.
    826827        if ( $proper_filename ) {
    827828            $file['name'] = $proper_filename;
     
    870871            $move_new_file = @move_uploaded_file( $file['tmp_name'], $new_file );
    871872        } else {
    872             // use copy and unlink because rename breaks streams.
     873            // Use copy and unlink because rename breaks streams.
    873874            // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    874875            $move_new_file = @copy( $file['tmp_name'], $new_file );
     
    10021003 */
    10031004function download_url( $url, $timeout = 300, $signature_verification = false ) {
    1004     //WARNING: The file is not automatically deleted, The script must unlink() the file.
     1005    // WARNING: The file is not automatically deleted, the script must unlink() the file.
    10051006    if ( ! $url ) {
    10061007        return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.' ) );
     
    10831084        if ( ! $signature ) {
    10841085            // Retrieve signatures from a file if the header wasn't included.
    1085             // WordPress.org stores signatures at $package_url.sig
     1086            // WordPress.org stores signatures at $package_url.sig.
    10861087
    10871088            $signature_url = false;
     
    11051106                    $signature_url,
    11061107                    array(
    1107                         'limit_response_size' => 10 * 1024, // 10KB should be large enough for quite a few signatures.
     1108                        'limit_response_size' => 10 * KB_IN_BYTES, // 10KB should be large enough for quite a few signatures.
    11081109                    )
    11091110                );
     
    11621163        $expected_raw_md5 = base64_decode( $expected_md5 );
    11631164    } else {
    1164         return false; // unknown format
     1165        return false; // Unknown format.
    11651166    }
    11661167
     
    12111212    }
    12121213
    1213     // Check for a edge-case affecting PHP Maths abilities
     1214    // Check for a edge-case affecting PHP Maths abilities.
    12141215    if (
    12151216        ! extension_loaded( 'sodium' ) &&
     
    12511252        }
    12521253
    1253         // This cannot be performed in a reasonable amount of time
     1254        // This cannot be performed in a reasonable amount of time.
    12541255        // https://github.com/paragonie/sodium_compat#help-sodium_compat-is-slow-how-can-i-make-it-fast
    12551256        if ( ! $sodium_compat_is_fast ) {
     
    14791480        }
    14801481
    1481         if ( '__MACOSX/' === substr( $info['name'], 0, 9 ) ) { // Skip the OS X-created __MACOSX directory
     1482        if ( '__MACOSX/' === substr( $info['name'], 0, 9 ) ) { // Skip the OS X-created __MACOSX directory.
    14821483            continue;
    14831484        }
     
    15161517    foreach ( $needed_dirs as $dir ) {
    15171518        // Check the parent folders of the folders all exist within the creation array.
    1518         if ( untrailingslashit( $to ) == $dir ) { // Skip over the working directory, We know this exists (or will exist)
     1519        if ( untrailingslashit( $to ) == $dir ) { // Skip over the working directory, we know this exists (or will exist).
    15191520            continue;
    15201521        }
    1521         if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, Skip it
     1522        if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, skip it.
    15221523            continue;
    15231524        }
     
    15501551        }
    15511552
    1552         if ( '__MACOSX/' === substr( $info['name'], 0, 9 ) ) { // Don't extract the OS X-created __MACOSX directory files
     1553        if ( '__MACOSX/' === substr( $info['name'], 0, 9 ) ) { // Don't extract the OS X-created __MACOSX directory files.
    15531554            continue;
    15541555        }
     
    16161617    $uncompressed_size = 0;
    16171618
    1618     // Determine any children directories needed (From within the archive)
     1619    // Determine any children directories needed (From within the archive).
    16191620    foreach ( $archive_files as $file ) {
    1620         if ( '__MACOSX/' === substr( $file['filename'], 0, 9 ) ) { // Skip the OS X-created __MACOSX directory
     1621        if ( '__MACOSX/' === substr( $file['filename'], 0, 9 ) ) { // Skip the OS X-created __MACOSX directory.
    16211622            continue;
    16221623        }
     
    16421643    foreach ( $needed_dirs as $dir ) {
    16431644        // Check the parent folders of the folders all exist within the creation array.
    1644         if ( untrailingslashit( $to ) == $dir ) { // Skip over the working directory, We know this exists (or will exist)
     1645        if ( untrailingslashit( $to ) == $dir ) { // Skip over the working directory, we know this exists (or will exist).
    16451646            continue;
    16461647        }
    1647         if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, Skip it
     1648        if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, skip it.
    16481649            continue;
    16491650        }
     
    16661667    unset( $needed_dirs );
    16671668
    1668     // Extract the files from the zip
     1669    // Extract the files from the zip.
    16691670    foreach ( $archive_files as $file ) {
    16701671        if ( $file['folder'] ) {
     
    16721673        }
    16731674
    1674         if ( '__MACOSX/' === substr( $file['filename'], 0, 9 ) ) { // Don't extract the OS X-created __MACOSX directory files
     1675        if ( '__MACOSX/' === substr( $file['filename'], 0, 9 ) ) { // Don't extract the OS X-created __MACOSX directory files.
    16751676            continue;
    16761677        }
     
    17311732            }
    17321733
    1733             // generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list
     1734            // Generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list.
    17341735            $sub_skip_list = array();
    17351736            foreach ( $skip_list as $skip_item ) {
     
    17491750
    17501751/**
    1751  * Initialises and connects the WordPress Filesystem Abstraction classes.
     1752 * Initializes and connects the WordPress Filesystem Abstraction classes.
    17521753 *
    17531754 * This function will include the chosen transport and attempt connecting.
     
    18011802    $wp_filesystem = new $method( $args );
    18021803
    1803     //Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default.
     1804    /*
     1805     * Define the timeouts for the connections. Only available after the constructor is called
     1806     * to allow for per-transport overriding of the default.
     1807     */
    18041808    if ( ! defined( 'FS_CONNECT_TIMEOUT' ) ) {
    18051809        define( 'FS_CONNECT_TIMEOUT', 30 );
     
    18141818
    18151819    if ( ! $wp_filesystem->connect() ) {
    1816         return false; //There was an error connecting to the server.
     1820        return false; // There was an error connecting to the server.
    18171821    }
    18181822
     
    18551859 */
    18561860function get_filesystem_method( $args = array(), $context = '', $allow_relaxed_file_ownership = false ) {
    1857     $method = defined( 'FS_METHOD' ) ? FS_METHOD : false; // Please ensure that this is either 'direct', 'ssh2', 'ftpext' or 'ftpsockets'
     1861    // Please ensure that this is either 'direct', 'ssh2', 'ftpext', or 'ftpsockets'.
     1862    $method = defined( 'FS_METHOD' ) ? FS_METHOD : false;
    18581863
    18591864    if ( ! $context ) {
     
    18741879        if ( $temp_handle ) {
    18751880
    1876             // Attempt to determine the file owner of the WordPress files, and that of newly created files
     1881            // Attempt to determine the file owner of the WordPress files, and that of newly created files.
    18771882            $wp_file_owner   = false;
    18781883            $temp_file_owner = false;
     
    18831888
    18841889            if ( $wp_file_owner !== false && $wp_file_owner === $temp_file_owner ) {
    1885                 // WordPress is creating files as the same owner as the WordPress files,
    1886                 // this means it's safe to modify & create new files via PHP.
     1890                /*
     1891                 * WordPress is creating files as the same owner as the WordPress files,
     1892                 * this means it's safe to modify & create new files via PHP.
     1893                 */
    18871894                $method                                  = 'direct';
    18881895                $GLOBALS['_wp_filesystem_direct_method'] = 'file_owner';
    18891896            } elseif ( $allow_relaxed_file_ownership ) {
    1890                 // The $context directory is writable, and $allow_relaxed_file_ownership is set, this means we can modify files
    1891                 // safely in this directory. This mode doesn't create new files, only alter existing ones.
     1897                /*
     1898                 * The $context directory is writable, and $allow_relaxed_file_ownership is set,
     1899                 * this means we can modify files safely in this directory.
     1900                 * This mode doesn't create new files, only alter existing ones.
     1901                 */
    18921902                $method                                  = 'direct';
    18931903                $GLOBALS['_wp_filesystem_direct_method'] = 'relaxed_ownership';
     
    19061916    }
    19071917    if ( ! $method && ( extension_loaded( 'sockets' ) || function_exists( 'fsockopen' ) ) ) {
    1908         $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
     1918        $method = 'ftpsockets'; // Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread.
    19091919    }
    19101920
     
    19992009    $submitted_form = wp_unslash( $_POST );
    20002010
    2001     // Verify nonce, or unset submitted form field values on failure
     2011    // Verify nonce, or unset submitted form field values on failure.
    20022012    if ( ! isset( $_POST['_fs_nonce'] ) || ! wp_verify_nonce( $_POST['_fs_nonce'], 'filesystem-credentials' ) ) {
    20032013        unset(
     
    20112021    }
    20122022
    2013     // If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option)
     2023    // If defined, set it to that. Else, if POST'd, set it to that. If not, set it to whatever it previously was (saved details in option).
    20142024    $credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : ( ! empty( $submitted_form['hostname'] ) ? $submitted_form['hostname'] : $credentials['hostname'] );
    20152025    $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : ( ! empty( $submitted_form['username'] ) ? $submitted_form['username'] : $credentials['username'] );
    20162026    $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : ( ! empty( $submitted_form['password'] ) ? $submitted_form['password'] : '' );
    20172027
    2018     // Check to see if we are setting the public/private keys for ssh
     2028    // Check to see if we are setting the public/private keys for ssh.
    20192029    $credentials['public_key']  = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : ( ! empty( $submitted_form['public_key'] ) ? $submitted_form['public_key'] : '' );
    20202030    $credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : ( ! empty( $submitted_form['private_key'] ) ? $submitted_form['private_key'] : '' );
    20212031
    2022     // Sanitize the hostname, Some people might pass in odd-data:
    2023     $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off
     2032    // Sanitize the hostname, some people might pass in odd data.
     2033    $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); // Strip any schemes off.
    20242034
    20252035    if ( strpos( $credentials['hostname'], ':' ) ) {
     
    20342044    if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' == FS_METHOD ) ) {
    20352045        $credentials['connection_type'] = 'ssh';
    2036     } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { //Only the FTP Extension understands SSL
     2046    } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { // Only the FTP Extension understands SSL.
    20372047        $credentials['connection_type'] = 'ftps';
    20382048    } elseif ( ! empty( $submitted_form['connection_type'] ) ) {
    20392049        $credentials['connection_type'] = $submitted_form['connection_type'];
    2040     } elseif ( ! isset( $credentials['connection_type'] ) ) { //All else fails (And it's not defaulted to something else saved), Default to FTP
     2050    } elseif ( ! isset( $credentials['connection_type'] ) ) { // All else fails (and it's not defaulted to something else saved), default to FTP.
    20412051        $credentials['connection_type'] = 'ftp';
    20422052    }
     
    20472057            ) ) {
    20482058        $stored_credentials = $credentials;
    2049         if ( ! empty( $stored_credentials['port'] ) ) { //save port as part of hostname to simplify above code.
     2059        if ( ! empty( $stored_credentials['port'] ) ) { // Save port as part of hostname to simplify above code.
    20502060            $stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
    20512061        }
     
    20762086        $types['ftp'] = __( 'FTP' );
    20772087    }
    2078     if ( extension_loaded( 'ftp' ) ) { //Only this supports FTPS
     2088    if ( extension_loaded( 'ftp' ) ) { // Only this supports FTPS.
    20792089        $types['ftps'] = __( 'FTPS (SSL)' );
    20802090    }
  • trunk/src/wp-admin/includes/image-edit.php

    r47065 r47084  
    200200            <?php
    201201
    202             // On some setups GD library does not provide imagerotate() - Ticket #11536
     202            // On some setups GD library does not provide imagerotate() - Ticket #11536.
    203203            if ( wp_image_editor_supports(
    204204                array(
     
    602602                    $h    = $size['height'];
    603603
    604                     $scale = 1 / _image_get_preview_ratio( $w, $h ); // discard preview scaling
     604                    $scale = 1 / _image_get_preview_ratio( $w, $h ); // Discard preview scaling.
    605605                    $image->crop( $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale );
    606606                } else {
    607                     $scale = 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // discard preview scaling
     607                    $scale = 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // Discard preview scaling.
    608608                    $image = _crop_image_resource( $image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale );
    609609                }
     
    956956
    957957        if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) {
    958             // Check if it's an image edit from attachment edit screen
     958            // Check if it's an image edit from attachment edit screen.
    959959            if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' == $_REQUEST['context'] ) {
    960960                $thumb_url         = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );
  • trunk/src/wp-admin/includes/image.php

    r46809 r47084  
    2525function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
    2626    $src_file = $src;
    27     if ( is_numeric( $src ) ) { // Handle int as attachment ID
     27    if ( is_numeric( $src ) ) { // Handle int as attachment ID.
    2828        $src_file = get_attached_file( $src );
    2929
     
    118118    }
    119119
    120     // Remove sizes that already exist. Only checks for matching "size names".
    121     // It is possible that the dimensions for a particular size name have changed.
    122     // For example the user has changed the values on the Settings -> Media screen.
    123     // However we keep the old sub-sizes with the previous dimensions
    124     // as the image may have been used in an older post.
     120    /*
     121     * Remove sizes that already exist. Only checks for matching "size names".
     122     * It is possible that the dimensions for a particular size name have changed.
     123     * For example the user has changed the values on the Settings -> Media screen.
     124     * However we keep the old sub-sizes with the previous dimensions
     125     * as the image may have been used in an older post.
     126     */
    125127    $missing_sizes = array_diff_key( $possible_sizes, $image_meta['sizes'] );
    126128
     
    230232    }
    231233
    232     // Default image meta
     234    // Default image meta.
    233235    $image_meta = array(
    234236        'width'  => $imagesize[0],
     
    319321            }
    320322
    321             // Rotate the image
     323            // Rotate the image.
    322324            $rotated = $editor->maybe_exif_rotate();
    323325
     
    340342    }
    341343
    342     // Initial save of the new metadata.
    343     // At this point the file was uploaded and moved to the uploads directory
    344     // but the image sub-sizes haven't been created yet and the `sizes` array is empty.
     344    /*
     345     * Initial save of the new metadata.
     346     * At this point the file was uploaded and moved to the uploads directory
     347     * but the image sub-sizes haven't been created yet and the `sizes` array is empty.
     348     */
    345349    wp_update_attachment_metadata( $attachment_id, $image_meta );
    346350
     
    387391    if ( isset( $image_meta['sizes'] ) && is_array( $image_meta['sizes'] ) ) {
    388392        foreach ( $image_meta['sizes'] as $size_name => $size_meta ) {
    389             // Only checks "size name" so we don't override existing images even if the dimensions
    390             // don't match the currently defined size with the same name.
    391             // To change the behavior, unset changed/mismatched sizes in the `sizes` array in image meta.
     393            /*
     394             * Only checks "size name" so we don't override existing images even if the dimensions
     395             * don't match the currently defined size with the same name.
     396             * To change the behavior, unset changed/mismatched sizes in the `sizes` array in image meta.
     397             */
    392398            if ( array_key_exists( $size_name, $new_sizes ) ) {
    393399                unset( $new_sizes[ $size_name ] );
     
    403409    }
    404410
    405     // Sort the image sub-sizes in order of priority when creating them.
    406     // This ensures there is an appropriate sub-size the user can access immediately
    407     // even when there was an error and not all sub-sizes were created.
     411    /*
     412     * Sort the image sub-sizes in order of priority when creating them.
     413     * This ensures there is an appropriate sub-size the user can access immediately
     414     * even when there was an error and not all sub-sizes were created.
     415     */
    408416    $priority = array(
    409417        'medium'       => null,
     
    734742            }
    735743
    736             if ( ! empty( $iptc['2#110'][0] ) ) { // credit
     744            if ( ! empty( $iptc['2#110'][0] ) ) { // Credit.
    737745                $meta['credit'] = trim( $iptc['2#110'][0] );
    738             } elseif ( ! empty( $iptc['2#080'][0] ) ) { // creator / legacy byline
     746            } elseif ( ! empty( $iptc['2#080'][0] ) ) { // Creator / legacy byline.
    739747                $meta['credit'] = trim( $iptc['2#080'][0] );
    740748            }
    741749
    742             if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) { // created date and time
     750            if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) { // Created date and time.
    743751                $meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] );
    744752            }
    745753
    746             if ( ! empty( $iptc['2#116'][0] ) ) { // copyright
     754            if ( ! empty( $iptc['2#116'][0] ) ) { // Copyright.
    747755                $meta['copyright'] = trim( $iptc['2#116'][0] );
    748756            }
    749757
    750             if ( ! empty( $iptc['2#025'][0] ) ) { // keywords array
     758            if ( ! empty( $iptc['2#025'][0] ) ) { // Keywords array.
    751759                $meta['keywords'] = array_values( $iptc['2#025'] );
    752760            }
     
    774782
    775783            if ( empty( $meta['title'] ) && $description_length < 80 ) {
    776                 // Assume the title is stored in ImageDescription
     784                // Assume the title is stored in ImageDescription.
    777785                $meta['title'] = trim( $exif['ImageDescription'] );
    778786            }
  • trunk/src/wp-admin/includes/import.php

    r47043 r47084  
    104104    }
    105105
    106     // Construct the object array
     106    // Construct the object array.
    107107    $object = array(
    108108        'post_title'     => wp_basename( $upload['file'] ),
     
    114114    );
    115115
    116     // Save the data
     116    // Save the data.
    117117    $id = wp_insert_attachment( $object, $upload['file'] );
    118118
     
    137137 */
    138138function wp_get_popular_importers() {
    139     include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
     139    include( ABSPATH . WPINC . '/version.php' ); // Include an unmodified $wp_version.
    140140
    141141    $locale            = get_user_locale();
     
    185185
    186186    return array(
    187         // slug => name, description, plugin slug, and register_importer() slug
     187        // slug => name, description, plugin slug, and register_importer() slug.
    188188        'blogger'     => array(
    189189            'name'        => __( 'Blogger' ),
  • trunk/src/wp-admin/includes/list-table.php

    r46596 r47084  
    2222function _get_list_table( $class, $args = array() ) {
    2323    $core_classes = array(
    24         //Site Admin
     24        // Site Admin.
    2525        'WP_Posts_List_Table'                         => 'posts',
    2626        'WP_Media_List_Table'                         => 'media',
     
    3535        'WP_Plugins_List_Table'                       => 'plugins',
    3636
    37         // Network Admin
     37        // Network Admin.
    3838        'WP_MS_Sites_List_Table'                      => 'ms-sites',
    3939        'WP_MS_Users_List_Table'                      => 'ms-users',
    4040        'WP_MS_Themes_List_Table'                     => 'ms-themes',
    4141
    42         // Privacy requests tables
     42        // Privacy requests tables.
    4343        'WP_Privacy_Data_Export_Requests_List_Table'  => 'privacy-data-export-requests',
    4444        'WP_Privacy_Data_Removal_Requests_List_Table' => 'privacy-data-removal-requests',
  • trunk/src/wp-admin/includes/media.php

    r47039 r47084  
    1616function media_upload_tabs() {
    1717    $_default_tabs = array(
    18         'type'     => __( 'From Computer' ), // handler action suffix => tab text
     18        'type'     => __( 'From Computer' ), // Handler action suffix => tab text.
    1919        'type_url' => __( 'From URL' ),
    2020        'gallery'  => __( 'Gallery' ),
     
    227227    $caption = preg_replace_callback( '/<[a-zA-Z0-9]+(?: [^<>]+>)*/', '_cleanup_image_add_caption', $caption );
    228228
    229     // Convert any remaining line breaks to <br>.
     229    // Convert any remaining line breaks to <br />.
    230230    $caption = preg_replace( '/[ \n\t]*\n[ \t]*/', '<br />', $caption );
    231231
     
    389389    }
    390390
    391     // Construct the attachment array
     391    // Construct the attachment array.
    392392    $attachment = array_merge(
    393393        array(
     
    405405    unset( $attachment['ID'] );
    406406
    407     // Save the data
     407    // Save the data.
    408408    $attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true );
    409409
     
    491491    unset( $attachment['ID'] );
    492492
    493     // Save the attachment metadata
     493    // Save the attachment metadata.
    494494    $attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true );
    495495
     
    520520
    521521    wp_enqueue_style( 'colors' );
    522     // Check callback name for 'media'
     522    // Check callback name for 'media'.
    523523    if (
    524524        ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) ) ||
     
    850850    if ( isset( $_POST['html-upload'] ) && ! empty( $_FILES ) ) {
    851851        check_admin_referer( 'media-form' );
    852         // Upload File button was clicked
     852        // Upload File button was clicked.
    853853        $id = media_handle_upload( 'async-upload', $_REQUEST['post_id'] );
    854854        unset( $_FILES );
     
    14221422    }
    14231423
    1424     // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default
    1425     // The recursive merge is easily traversed with array casting: foreach ( (array) $things as $thing )
     1424    /*
     1425     * Merge default fields with their errors, so any key passed with the error
     1426     * (e.g. 'error', 'helps', 'value') will replace the default.
     1427     * The recursive merge is easily traversed with array casting:
     1428     * foreach ( (array) $things as $thing )
     1429     */
    14261430    $form_fields = array_merge_recursive( $form_fields, (array) $errors );
    14271431
     
    15971601    }
    15981602
    1599     $display_title = ( ! empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
     1603    $display_title = ( ! empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case.
    16001604    $display_title = $parsed_args['show_title'] ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60, '&hellip;' ) . '</span></div>' : '';
    16011605
     
    17111715    if ( isset( $_GET['post_id'] ) ) {
    17121716        $calling_post_id = absint( $_GET['post_id'] );
    1713     } elseif ( isset( $_POST ) && count( $_POST ) ) {// Like for async-upload where $_GET['post_id'] isn't set
     1717    } elseif ( isset( $_POST ) && count( $_POST ) ) {// Like for async-upload where $_GET['post_id'] isn't set.
    17141718        $calling_post_id = $post->post_parent;
    17151719    }
     
    18761880    }
    18771881
    1878     // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default
    1879     // The recursive merge is easily traversed with array casting: foreach ( (array) $things as $thing )
     1882    /*
     1883     * Merge default fields with their errors, so any key passed with the error
     1884     * (e.g. 'error', 'helps', 'value') will replace the default.
     1885     * The recursive merge is easily traversed with array casting:
     1886     * foreach ( (array) $things as $thing )
     1887     */
    18801888    $form_fields = array_merge_recursive( $form_fields, (array) $args['errors'] );
    18811889
     
    21332141    );
    21342142
    2135     // Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos
    2136     // when enabled. See #29602.
     2143    /*
     2144     * Currently only iOS Safari supports multiple files uploading,
     2145     * but iOS 7.x has a bug that prevents uploading of videos when enabled.
     2146     * See #29602.
     2147     */
    21372148    if (
    21382149        wp_is_mobile() &&
     
    27012712            }
    27022713        }
    2703         // If available type specified by media button clicked, filter by that type
     2714        // If available type specified by media button clicked, filter by that type.
    27042715        if ( empty( $_GET['post_mime_type'] ) && ! empty( $num_posts[ $type ] ) ) {
    27052716            $_GET['post_mime_type']                        = $type;
  • trunk/src/wp-admin/includes/menu.php

    r45583 r47084  
    209209        $i++;
    210210
    211         if ( 0 == $order ) { // dashboard is always shown/single
     211        if ( 0 == $order ) { // Dashboard is always shown/single.
    212212            $menu[0][4] = add_cssclass( 'menu-top-first', $top[4] );
    213213            $lastorder  = 0;
     
    215215        }
    216216
    217         if ( 0 === strpos( $top[2], 'separator' ) && false !== $lastorder ) { // if separator
     217        if ( 0 === strpos( $top[2], 'separator' ) && false !== $lastorder ) { // If separator.
    218218            $first                 = true;
    219219            $c                     = $menu[ $lastorder ][4];
     
    228228        }
    229229
    230         if ( $mc == $i ) { // last item
     230        if ( $mc == $i ) { // Last item.
    231231            $c                 = $menu[ $order ][4];
    232232            $menu[ $order ][4] = add_cssclass( 'menu-top-last', $c );
     
    246246}
    247247
    248 uksort( $menu, 'strnatcasecmp' ); // make it all pretty
     248uksort( $menu, 'strnatcasecmp' ); // Make it all pretty.
    249249
    250250/**
     
    311311}
    312312
    313 // Prevent adjacent separators
     313// Prevent adjacent separators.
    314314$prev_menu_was_separator = false;
    315315foreach ( $menu as $id => $data ) {
    316316    if ( false === stristr( $data[4], 'wp-menu-separator' ) ) {
    317317
    318         // This item is not a separator, so falsey the toggler and do nothing
     318        // This item is not a separator, so falsey the toggler and do nothing.
    319319        $prev_menu_was_separator = false;
    320320    } else {
    321321
    322         // The previous item was a separator, so unset this one
     322        // The previous item was a separator, so unset this one.
    323323        if ( true === $prev_menu_was_separator ) {
    324324            unset( $menu[ $id ] );
    325325        }
    326326
    327         // This item is a separator, so truthy the toggler and move on
     327        // This item is a separator, so truthy the toggler and move on.
    328328        $prev_menu_was_separator = true;
    329329    }
Note: See TracChangeset for help on using the changeset viewer.