-
publish ) {
@@ -298,7 +298,7 @@ function wp_dashboard_right_now() {
}
}
}
- // Comments
+ // Comments.
$num_comm = wp_count_comments();
if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) {
/* translators: %s: Number of comments. */
@@ -506,21 +506,21 @@ function wp_dashboard_quick_press( $error_msg = false ) {
}
/* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
- $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
+ $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID.
if ( $last_post_id ) {
$post = get_post( $last_post_id );
- if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
+ if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore.
$post = get_default_post_to_edit( 'post', true );
- update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
+ update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID.
} else {
- $post->post_title = ''; // Remove the auto draft title
+ $post->post_title = ''; // Remove the auto draft title.
}
} else {
$post = get_default_post_to_edit( 'post', true );
$user_id = get_current_user_id();
// Don't create an option if this is a super admin who does not belong to this site.
if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) {
- update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
+ update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID.
}
}
@@ -760,7 +760,7 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
++$i;
( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
- // Reply and quickedit need a hide-if-no-js span
+ // Reply and quickedit need a hide-if-no-js span.
if ( 'reply' == $action || 'quickedit' == $action ) {
$action .= ' hide-if-no-js';
}
@@ -1108,7 +1108,8 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar
array_unshift( $args, $widget_id, $check_urls );
ob_start();
call_user_func_array( $callback, $args );
- set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
+ // Default lifetime in cache of 12 hours (same as the feeds).
+ set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS );
}
return true;
@@ -1163,7 +1164,8 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
$widget_options[ $widget_id ] = array();
}
- $number = 1; // Hack to use wp_widget_rss_form()
+ $number = 1; // Hack to use wp_widget_rss_form().
+
$widget_options[ $widget_id ]['number'] = $number;
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) {
@@ -1662,7 +1664,7 @@ function wp_check_browser_version() {
$response = get_site_transient( 'browser_' . $key );
if ( false === $response ) {
- // include an unmodified $wp_version
+ // Include an unmodified $wp_version.
include( ABSPATH . WPINC . '/version.php' );
$url = 'http://api.wordpress.org/core/browse-happy/1.1/';
diff --git a/wp-admin/includes/deprecated.php b/wp-admin/includes/deprecated.php
index 5df3b87403..a16f0e98c7 100644
--- a/wp-admin/includes/deprecated.php
+++ b/wp-admin/includes/deprecated.php
@@ -233,7 +233,7 @@ function get_author_user_ids() {
if ( !is_multisite() )
$level_key = $wpdb->get_blog_prefix() . 'user_level';
else
- $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
+ $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
}
@@ -295,7 +295,7 @@ function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'p
if ( !is_multisite() )
$level_key = $wpdb->get_blog_prefix() . 'user_level';
else
- $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
+ $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
if ( $exclude_zeros )
@@ -319,7 +319,7 @@ function get_nonauthor_user_ids() {
if ( !is_multisite() )
$level_key = $wpdb->get_blog_prefix() . 'user_level';
else
- $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
+ $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
}
@@ -544,7 +544,7 @@ class WP_User_Search {
$this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
$this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
} elseif ( is_multisite() ) {
- $level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
+ $level_key = $wpdb->prefix . 'capabilities'; // WPMU site admins don't have user_levels.
$this->query_from .= ", $wpdb->usermeta";
$this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
}
@@ -564,7 +564,7 @@ class WP_User_Search {
$this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
if ( $this->results )
- $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
+ $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // No limit.
else
$this->search_errors = new WP_Error('no_matching_users_found', __('No users found.'));
}
@@ -584,7 +584,7 @@ class WP_User_Search {
* @access public
*/
public function do_paging() {
- if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
+ if ( $this->total_users_for_query > $this->users_per_page ) { // Have to page the results.
$args = array();
if ( ! empty($this->search_term) )
$args['usersearch'] = urlencode($this->search_term);
@@ -1319,7 +1319,7 @@ function wp_dashboard_secondary_control() {}
function wp_dashboard_plugins_output( $rss, $args = array() ) {
_deprecated_function( __FUNCTION__, '4.8.0' );
- // Plugin feeds plus link to install them
+ // Plugin feeds plus link to install them.
$popular = fetch_feed( $args['url']['popular'] );
if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
@@ -1335,9 +1335,9 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) {
$items = $feed->get_items(0, 5);
- // Pick a random, non-installed plugin
+ // Pick a random, non-installed plugin.
while ( true ) {
- // Abort this foreach loop iteration if there's no plugins left of this type
+ // Abort this foreach loop iteration if there's no plugins left of this type.
if ( 0 == count($items) )
continue 2;
@@ -1367,7 +1367,7 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) {
break;
}
- // Eliminate some common badly formed plugin descriptions
+ // Eliminate some common badly formed plugin descriptions.
while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
unset($items[$item_key]);
diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php
index a6b38b9291..0c65f2c6e3 100644
--- a/wp-admin/includes/file.php
+++ b/wp-admin/includes/file.php
@@ -21,7 +21,7 @@ $wp_file_descriptions = array(
'searchform.php' => __( 'Search Form' ),
'404.php' => __( '404 Template' ),
'link.php' => __( 'Links Template' ),
- // Archives
+ // Archives.
'index.php' => __( 'Main Index Template' ),
'archive.php' => __( 'Archives' ),
'author.php' => __( 'Author Template' ),
@@ -31,33 +31,33 @@ $wp_file_descriptions = array(
'home.php' => __( 'Posts Page' ),
'search.php' => __( 'Search Results' ),
'date.php' => __( 'Date Template' ),
- // Content
+ // Content.
'singular.php' => __( 'Singular Template' ),
'single.php' => __( 'Single Post' ),
'page.php' => __( 'Single Page' ),
'front-page.php' => __( 'Homepage' ),
'privacy-policy.php' => __( 'Privacy Policy Page' ),
- // Attachments
+ // Attachments.
'attachment.php' => __( 'Attachment Template' ),
'image.php' => __( 'Image Attachment Template' ),
'video.php' => __( 'Video Attachment Template' ),
'audio.php' => __( 'Audio Attachment Template' ),
'application.php' => __( 'Application Attachment Template' ),
- // Embeds
+ // Embeds.
'embed.php' => __( 'Embed Template' ),
'embed-404.php' => __( 'Embed 404 Template' ),
'embed-content.php' => __( 'Embed Content Template' ),
'header-embed.php' => __( 'Embed Header Template' ),
'footer-embed.php' => __( 'Embed Footer Template' ),
- // Stylesheets
+ // Stylesheets.
'style.css' => __( 'Stylesheet' ),
'editor-style.css' => __( 'Visual Editor Stylesheet' ),
'editor-style-rtl.css' => __( 'Visual Editor RTL Stylesheet' ),
'rtl.css' => __( 'RTL Stylesheet' ),
- // Other
+ // Other.
'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ),
'.htaccess' => __( '.htaccess (for rewrite rules )' ),
- // Deprecated files
+ // Deprecated files.
'wp-layout.css' => __( 'Stylesheet' ),
'wp-comments.php' => __( 'Comments Template' ),
'wp-comments-popup.php' => __( 'Popup Comments Template' ),
@@ -455,7 +455,7 @@ function wp_edit_theme_plugin_file( $args ) {
}
}
- // Compare based on relative paths
+ // Compare based on relative paths.
if ( 0 !== validate_file( $file, array_keys( $allowed_files ) ) ) {
return new WP_Error( 'disallowed_theme_file', __( 'Sorry, that file cannot be edited.' ) );
}
@@ -507,7 +507,8 @@ function wp_edit_theme_plugin_file( $args ) {
$scrape_key = md5( rand() );
$transient = 'scrape_key_' . $scrape_key;
$scrape_nonce = strval( rand() );
- set_transient( $transient, $scrape_nonce, 60 ); // It shouldn't take more than 60 seconds to make the two loopback requests.
+ // It shouldn't take more than 60 seconds to make the two loopback requests.
+ set_transient( $transient, $scrape_nonce, 60 );
$cookies = wp_unslash( $_COOKIE );
$scrape_params = array(
@@ -644,7 +645,7 @@ function wp_tempnam( $filename = '', $dir = '' ) {
$filename = uniqid();
}
- // Use the basename of the given file without the extension as the name for the temporary directory
+ // Use the basename of the given file without the extension as the name for the temporary directory.
$temp_filename = basename( $filename );
$temp_filename = preg_replace( '|\.[^.]*$|', '', $temp_filename );
@@ -653,7 +654,7 @@ function wp_tempnam( $filename = '', $dir = '' ) {
return wp_tempnam( dirname( $filename ), $dir );
}
- // Suffix some random data to avoid filename conflicts
+ // Suffix some random data to avoid filename conflicts.
$temp_filename .= '-' . wp_generate_password( 6, false );
$temp_filename .= '.tmp';
$temp_filename = $dir . wp_unique_filename( $dir, $temp_filename );
@@ -735,7 +736,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
*/
$file = apply_filters( "{$action}_prefilter", $file );
- // You may define your own function and pass the name in $overrides['upload_error_handler']
+ // You may define your own function and pass the name in $overrides['upload_error_handler'].
$upload_error_handler = 'wp_handle_upload_error';
if ( isset( $overrides['upload_error_handler'] ) ) {
$upload_error_handler = $overrides['upload_error_handler'];
@@ -748,7 +749,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
// Install user overrides. Did we mention that this voids your warranty?
- // You may define your own function and pass the name in $overrides['unique_filename_callback']
+ // You may define your own function and pass the name in $overrides['unique_filename_callback'].
$unique_filename_callback = null;
if ( isset( $overrides['unique_filename_callback'] ) ) {
$unique_filename_callback = $overrides['unique_filename_callback'];
@@ -822,7 +823,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
$type = empty( $wp_filetype['type'] ) ? '' : $wp_filetype['type'];
$proper_filename = empty( $wp_filetype['proper_filename'] ) ? '' : $wp_filetype['proper_filename'];
- // Check to see if wp_check_filetype_and_ext() determined the filename was incorrect
+ // Check to see if wp_check_filetype_and_ext() determined the filename was incorrect.
if ( $proper_filename ) {
$file['name'] = $proper_filename;
}
@@ -869,7 +870,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
if ( 'wp_handle_upload' === $action ) {
$move_new_file = @move_uploaded_file( $file['tmp_name'], $new_file );
} else {
- // use copy and unlink because rename breaks streams.
+ // Use copy and unlink because rename breaks streams.
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
$move_new_file = @copy( $file['tmp_name'], $new_file );
unlink( $file['tmp_name'] );
@@ -1001,7 +1002,7 @@ function wp_handle_sideload( &$file, $overrides = false, $time = null ) {
* @return string|WP_Error Filename on success, WP_Error on failure.
*/
function download_url( $url, $timeout = 300, $signature_verification = false ) {
- //WARNING: The file is not automatically deleted, The script must unlink() the file.
+ // WARNING: The file is not automatically deleted, the script must unlink() the file.
if ( ! $url ) {
return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.' ) );
}
@@ -1082,7 +1083,7 @@ function download_url( $url, $timeout = 300, $signature_verification = false ) {
$signature = wp_remote_retrieve_header( $response, 'x-content-signature' );
if ( ! $signature ) {
// Retrieve signatures from a file if the header wasn't included.
- // WordPress.org stores signatures at $package_url.sig
+ // WordPress.org stores signatures at $package_url.sig.
$signature_url = false;
$url_path = parse_url( $url, PHP_URL_PATH );
@@ -1104,7 +1105,7 @@ function download_url( $url, $timeout = 300, $signature_verification = false ) {
$signature_request = wp_safe_remote_get(
$signature_url,
array(
- 'limit_response_size' => 10 * 1024, // 10KB should be large enough for quite a few signatures.
+ 'limit_response_size' => 10 * KB_IN_BYTES, // 10KB should be large enough for quite a few signatures.
)
);
@@ -1161,7 +1162,7 @@ function verify_file_md5( $filename, $expected_md5 ) {
} elseif ( 24 == strlen( $expected_md5 ) ) {
$expected_raw_md5 = base64_decode( $expected_md5 );
} else {
- return false; // unknown format
+ return false; // Unknown format.
}
$file_md5 = md5_file( $filename, true );
@@ -1210,7 +1211,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f
);
}
- // Check for a edge-case affecting PHP Maths abilities
+ // Check for a edge-case affecting PHP Maths abilities.
if (
! extension_loaded( 'sodium' ) &&
in_array( PHP_VERSION_ID, [ 70200, 70201, 70202 ], true ) &&
@@ -1250,7 +1251,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f
// phpcs:enable
}
- // This cannot be performed in a reasonable amount of time
+ // This cannot be performed in a reasonable amount of time.
// https://github.com/paragonie/sodium_compat#help-sodium_compat-is-slow-how-can-i-make-it-fast
if ( ! $sodium_compat_is_fast ) {
return new WP_Error(
@@ -1478,7 +1479,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
}
- if ( '__MACOSX/' === substr( $info['name'], 0, 9 ) ) { // Skip the OS X-created __MACOSX directory
+ if ( '__MACOSX/' === substr( $info['name'], 0, 9 ) ) { // Skip the OS X-created __MACOSX directory.
continue;
}
@@ -1515,10 +1516,10 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
$needed_dirs = array_unique( $needed_dirs );
foreach ( $needed_dirs as $dir ) {
// Check the parent folders of the folders all exist within the creation array.
- if ( untrailingslashit( $to ) == $dir ) { // Skip over the working directory, We know this exists (or will exist)
+ if ( untrailingslashit( $to ) == $dir ) { // Skip over the working directory, we know this exists (or will exist).
continue;
}
- if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, Skip it
+ if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, skip it.
continue;
}
@@ -1549,7 +1550,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
continue;
}
- if ( '__MACOSX/' === substr( $info['name'], 0, 9 ) ) { // Don't extract the OS X-created __MACOSX directory files
+ if ( '__MACOSX/' === substr( $info['name'], 0, 9 ) ) { // Don't extract the OS X-created __MACOSX directory files.
continue;
}
@@ -1615,9 +1616,9 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
$uncompressed_size = 0;
- // Determine any children directories needed (From within the archive)
+ // Determine any children directories needed (From within the archive).
foreach ( $archive_files as $file ) {
- if ( '__MACOSX/' === substr( $file['filename'], 0, 9 ) ) { // Skip the OS X-created __MACOSX directory
+ if ( '__MACOSX/' === substr( $file['filename'], 0, 9 ) ) { // Skip the OS X-created __MACOSX directory.
continue;
}
@@ -1641,10 +1642,10 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
$needed_dirs = array_unique( $needed_dirs );
foreach ( $needed_dirs as $dir ) {
// Check the parent folders of the folders all exist within the creation array.
- if ( untrailingslashit( $to ) == $dir ) { // Skip over the working directory, We know this exists (or will exist)
+ if ( untrailingslashit( $to ) == $dir ) { // Skip over the working directory, we know this exists (or will exist).
continue;
}
- if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, Skip it
+ if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, skip it.
continue;
}
@@ -1665,13 +1666,13 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
}
unset( $needed_dirs );
- // Extract the files from the zip
+ // Extract the files from the zip.
foreach ( $archive_files as $file ) {
if ( $file['folder'] ) {
continue;
}
- if ( '__MACOSX/' === substr( $file['filename'], 0, 9 ) ) { // Don't extract the OS X-created __MACOSX directory files
+ if ( '__MACOSX/' === substr( $file['filename'], 0, 9 ) ) { // Don't extract the OS X-created __MACOSX directory files.
continue;
}
@@ -1730,7 +1731,7 @@ function copy_dir( $from, $to, $skip_list = array() ) {
}
}
- // generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list
+ // Generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list.
$sub_skip_list = array();
foreach ( $skip_list as $skip_item ) {
if ( 0 === strpos( $skip_item, $filename . '/' ) ) {
@@ -1748,7 +1749,7 @@ function copy_dir( $from, $to, $skip_list = array() ) {
}
/**
- * Initialises and connects the WordPress Filesystem Abstraction classes.
+ * Initializes and connects the WordPress Filesystem Abstraction classes.
*
* This function will include the chosen transport and attempt connecting.
*
@@ -1800,7 +1801,10 @@ function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_own
$wp_filesystem = new $method( $args );
- //Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default.
+ /*
+ * Define the timeouts for the connections. Only available after the constructor is called
+ * to allow for per-transport overriding of the default.
+ */
if ( ! defined( 'FS_CONNECT_TIMEOUT' ) ) {
define( 'FS_CONNECT_TIMEOUT', 30 );
}
@@ -1813,7 +1817,7 @@ function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_own
}
if ( ! $wp_filesystem->connect() ) {
- return false; //There was an error connecting to the server.
+ return false; // There was an error connecting to the server.
}
// Set the permission constants if not already set.
@@ -1854,7 +1858,8 @@ function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_own
* @return string The transport to use, see description for valid return values.
*/
function get_filesystem_method( $args = array(), $context = '', $allow_relaxed_file_ownership = false ) {
- $method = defined( 'FS_METHOD' ) ? FS_METHOD : false; // Please ensure that this is either 'direct', 'ssh2', 'ftpext' or 'ftpsockets'
+ // Please ensure that this is either 'direct', 'ssh2', 'ftpext', or 'ftpsockets'.
+ $method = defined( 'FS_METHOD' ) ? FS_METHOD : false;
if ( ! $context ) {
$context = WP_CONTENT_DIR;
@@ -1873,7 +1878,7 @@ function get_filesystem_method( $args = array(), $context = '', $allow_relaxed_f
$temp_handle = @fopen( $temp_file_name, 'w' );
if ( $temp_handle ) {
- // Attempt to determine the file owner of the WordPress files, and that of newly created files
+ // Attempt to determine the file owner of the WordPress files, and that of newly created files.
$wp_file_owner = false;
$temp_file_owner = false;
if ( function_exists( 'fileowner' ) ) {
@@ -1882,13 +1887,18 @@ function get_filesystem_method( $args = array(), $context = '', $allow_relaxed_f
}
if ( $wp_file_owner !== false && $wp_file_owner === $temp_file_owner ) {
- // WordPress is creating files as the same owner as the WordPress files,
- // this means it's safe to modify & create new files via PHP.
+ /*
+ * WordPress is creating files as the same owner as the WordPress files,
+ * this means it's safe to modify & create new files via PHP.
+ */
$method = 'direct';
$GLOBALS['_wp_filesystem_direct_method'] = 'file_owner';
} elseif ( $allow_relaxed_file_ownership ) {
- // The $context directory is writable, and $allow_relaxed_file_ownership is set, this means we can modify files
- // safely in this directory. This mode doesn't create new files, only alter existing ones.
+ /*
+ * The $context directory is writable, and $allow_relaxed_file_ownership is set,
+ * this means we can modify files safely in this directory.
+ * This mode doesn't create new files, only alter existing ones.
+ */
$method = 'direct';
$GLOBALS['_wp_filesystem_direct_method'] = 'relaxed_ownership';
}
@@ -1905,7 +1915,7 @@ function get_filesystem_method( $args = array(), $context = '', $allow_relaxed_f
$method = 'ftpext';
}
if ( ! $method && ( extension_loaded( 'sockets' ) || function_exists( 'fsockopen' ) ) ) {
- $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
+ $method = 'ftpsockets'; // Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread.
}
/**
@@ -1998,7 +2008,7 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
$submitted_form = wp_unslash( $_POST );
- // Verify nonce, or unset submitted form field values on failure
+ // Verify nonce, or unset submitted form field values on failure.
if ( ! isset( $_POST['_fs_nonce'] ) || ! wp_verify_nonce( $_POST['_fs_nonce'], 'filesystem-credentials' ) ) {
unset(
$submitted_form['hostname'],
@@ -2010,17 +2020,17 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
);
}
- // 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)
+ // 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).
$credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : ( ! empty( $submitted_form['hostname'] ) ? $submitted_form['hostname'] : $credentials['hostname'] );
$credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : ( ! empty( $submitted_form['username'] ) ? $submitted_form['username'] : $credentials['username'] );
$credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : ( ! empty( $submitted_form['password'] ) ? $submitted_form['password'] : '' );
- // Check to see if we are setting the public/private keys for ssh
+ // Check to see if we are setting the public/private keys for ssh.
$credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : ( ! empty( $submitted_form['public_key'] ) ? $submitted_form['public_key'] : '' );
$credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : ( ! empty( $submitted_form['private_key'] ) ? $submitted_form['private_key'] : '' );
- // Sanitize the hostname, Some people might pass in odd-data:
- $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off
+ // Sanitize the hostname, some people might pass in odd data.
+ $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); // Strip any schemes off.
if ( strpos( $credentials['hostname'], ':' ) ) {
list( $credentials['hostname'], $credentials['port'] ) = explode( ':', $credentials['hostname'], 2 );
@@ -2033,11 +2043,11 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' == FS_METHOD ) ) {
$credentials['connection_type'] = 'ssh';
- } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { //Only the FTP Extension understands SSL
+ } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { // Only the FTP Extension understands SSL.
$credentials['connection_type'] = 'ftps';
} elseif ( ! empty( $submitted_form['connection_type'] ) ) {
$credentials['connection_type'] = $submitted_form['connection_type'];
- } elseif ( ! isset( $credentials['connection_type'] ) ) { //All else fails (And it's not defaulted to something else saved), Default to FTP
+ } elseif ( ! isset( $credentials['connection_type'] ) ) { // All else fails (and it's not defaulted to something else saved), default to FTP.
$credentials['connection_type'] = 'ftp';
}
if ( ! $error &&
@@ -2046,7 +2056,7 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
( 'ssh' == $credentials['connection_type'] && ! empty( $credentials['public_key'] ) && ! empty( $credentials['private_key'] ) )
) ) {
$stored_credentials = $credentials;
- if ( ! empty( $stored_credentials['port'] ) ) { //save port as part of hostname to simplify above code.
+ if ( ! empty( $stored_credentials['port'] ) ) { // Save port as part of hostname to simplify above code.
$stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
}
@@ -2075,7 +2085,7 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
if ( extension_loaded( 'ftp' ) || extension_loaded( 'sockets' ) || function_exists( 'fsockopen' ) ) {
$types['ftp'] = __( 'FTP' );
}
- if ( extension_loaded( 'ftp' ) ) { //Only this supports FTPS
+ if ( extension_loaded( 'ftp' ) ) { // Only this supports FTPS.
$types['ftps'] = __( 'FTPS (SSL)' );
}
if ( extension_loaded( 'ssh2' ) && function_exists( 'stream_get_contents' ) ) {
diff --git a/wp-admin/includes/image-edit.php b/wp-admin/includes/image-edit.php
index 2b0040a07b..72f4256333 100644
--- a/wp-admin/includes/image-edit.php
+++ b/wp-admin/includes/image-edit.php
@@ -199,7 +199,7 @@ function wp_image_editor( $post_id, $msg = false ) {
get_post_mime_type( $post_id ),
@@ -601,10 +601,10 @@ function image_edit_apply_changes( $image, $changes ) {
$w = $size['width'];
$h = $size['height'];
- $scale = 1 / _image_get_preview_ratio( $w, $h ); // discard preview scaling
+ $scale = 1 / _image_get_preview_ratio( $w, $h ); // Discard preview scaling.
$image->crop( $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale );
} else {
- $scale = 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // discard preview scaling
+ $scale = 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // Discard preview scaling.
$image = _crop_image_resource( $image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale );
}
break;
@@ -955,7 +955,7 @@ function wp_save_image( $post_id ) {
update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes );
if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) {
- // Check if it's an image edit from attachment edit screen
+ // Check if it's an image edit from attachment edit screen.
if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' == $_REQUEST['context'] ) {
$thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );
$return->thumbnail = $thumb_url[0];
diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php
index 215aed389a..5ea668c0a2 100644
--- a/wp-admin/includes/image.php
+++ b/wp-admin/includes/image.php
@@ -24,7 +24,7 @@
*/
function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
$src_file = $src;
- if ( is_numeric( $src ) ) { // Handle int as attachment ID
+ if ( is_numeric( $src ) ) { // Handle int as attachment ID.
$src_file = get_attached_file( $src );
if ( ! file_exists( $src_file ) ) {
@@ -117,11 +117,13 @@ function wp_get_missing_image_subsizes( $attachment_id ) {
$image_meta['sizes'] = array();
}
- // Remove sizes that already exist. Only checks for matching "size names".
- // It is possible that the dimensions for a particular size name have changed.
- // For example the user has changed the values on the Settings -> Media screen.
- // However we keep the old sub-sizes with the previous dimensions
- // as the image may have been used in an older post.
+ /*
+ * Remove sizes that already exist. Only checks for matching "size names".
+ * It is possible that the dimensions for a particular size name have changed.
+ * For example the user has changed the values on the Settings -> Media screen.
+ * However we keep the old sub-sizes with the previous dimensions
+ * as the image may have been used in an older post.
+ */
$missing_sizes = array_diff_key( $possible_sizes, $image_meta['sizes'] );
/**
@@ -229,7 +231,7 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
return array();
}
- // Default image meta
+ // Default image meta.
$image_meta = array(
'width' => $imagesize[0],
'height' => $imagesize[1],
@@ -318,7 +320,7 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
return $image_meta;
}
- // Rotate the image
+ // Rotate the image.
$rotated = $editor->maybe_exif_rotate();
if ( true === $rotated ) {
@@ -339,9 +341,11 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
}
}
- // Initial save of the new metadata.
- // At this point the file was uploaded and moved to the uploads directory
- // but the image sub-sizes haven't been created yet and the `sizes` array is empty.
+ /*
+ * Initial save of the new metadata.
+ * At this point the file was uploaded and moved to the uploads directory
+ * but the image sub-sizes haven't been created yet and the `sizes` array is empty.
+ */
wp_update_attachment_metadata( $attachment_id, $image_meta );
$new_sizes = wp_get_registered_image_subsizes();
@@ -386,9 +390,11 @@ function _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ) {
// Check if any of the new sizes already exist.
if ( isset( $image_meta['sizes'] ) && is_array( $image_meta['sizes'] ) ) {
foreach ( $image_meta['sizes'] as $size_name => $size_meta ) {
- // Only checks "size name" so we don't override existing images even if the dimensions
- // don't match the currently defined size with the same name.
- // To change the behavior, unset changed/mismatched sizes in the `sizes` array in image meta.
+ /*
+ * Only checks "size name" so we don't override existing images even if the dimensions
+ * don't match the currently defined size with the same name.
+ * To change the behavior, unset changed/mismatched sizes in the `sizes` array in image meta.
+ */
if ( array_key_exists( $size_name, $new_sizes ) ) {
unset( $new_sizes[ $size_name ] );
}
@@ -402,9 +408,11 @@ function _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ) {
return $image_meta;
}
- // Sort the image sub-sizes in order of priority when creating them.
- // This ensures there is an appropriate sub-size the user can access immediately
- // even when there was an error and not all sub-sizes were created.
+ /*
+ * Sort the image sub-sizes in order of priority when creating them.
+ * This ensures there is an appropriate sub-size the user can access immediately
+ * even when there was an error and not all sub-sizes were created.
+ */
$priority = array(
'medium' => null,
'large' => null,
@@ -733,21 +741,21 @@ function wp_read_image_metadata( $file ) {
$meta['caption'] = $caption;
}
- if ( ! empty( $iptc['2#110'][0] ) ) { // credit
+ if ( ! empty( $iptc['2#110'][0] ) ) { // Credit.
$meta['credit'] = trim( $iptc['2#110'][0] );
- } elseif ( ! empty( $iptc['2#080'][0] ) ) { // creator / legacy byline
+ } elseif ( ! empty( $iptc['2#080'][0] ) ) { // Creator / legacy byline.
$meta['credit'] = trim( $iptc['2#080'][0] );
}
- if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) { // created date and time
+ if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) { // Created date and time.
$meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] );
}
- if ( ! empty( $iptc['2#116'][0] ) ) { // copyright
+ if ( ! empty( $iptc['2#116'][0] ) ) { // Copyright.
$meta['copyright'] = trim( $iptc['2#116'][0] );
}
- if ( ! empty( $iptc['2#025'][0] ) ) { // keywords array
+ if ( ! empty( $iptc['2#025'][0] ) ) { // Keywords array.
$meta['keywords'] = array_values( $iptc['2#025'] );
}
}
@@ -773,7 +781,7 @@ function wp_read_image_metadata( $file ) {
reset_mbstring_encoding();
if ( empty( $meta['title'] ) && $description_length < 80 ) {
- // Assume the title is stored in ImageDescription
+ // Assume the title is stored in ImageDescription.
$meta['title'] = trim( $exif['ImageDescription'] );
}
diff --git a/wp-admin/includes/import.php b/wp-admin/includes/import.php
index 27aa8aa4f2..52b623a447 100644
--- a/wp-admin/includes/import.php
+++ b/wp-admin/includes/import.php
@@ -103,7 +103,7 @@ function wp_import_handle_upload() {
return $upload;
}
- // Construct the object array
+ // Construct the object array.
$object = array(
'post_title' => wp_basename( $upload['file'] ),
'post_content' => $upload['url'],
@@ -113,7 +113,7 @@ function wp_import_handle_upload() {
'post_status' => 'private',
);
- // Save the data
+ // Save the data.
$id = wp_insert_attachment( $object, $upload['file'] );
/*
@@ -136,7 +136,7 @@ function wp_import_handle_upload() {
* @return array Importers with metadata for each.
*/
function wp_get_popular_importers() {
- include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
+ include( ABSPATH . WPINC . '/version.php' ); // Include an unmodified $wp_version.
$locale = get_user_locale();
$cache_key = 'popular_importers_' . md5( $locale . $wp_version );
@@ -184,7 +184,7 @@ function wp_get_popular_importers() {
}
return array(
- // slug => name, description, plugin slug, and register_importer() slug
+ // slug => name, description, plugin slug, and register_importer() slug.
'blogger' => array(
'name' => __( 'Blogger' ),
'description' => __( 'Import posts, comments, and users from a Blogger blog.' ),
diff --git a/wp-admin/includes/list-table.php b/wp-admin/includes/list-table.php
index 07fcce6793..881bb37388 100644
--- a/wp-admin/includes/list-table.php
+++ b/wp-admin/includes/list-table.php
@@ -21,7 +21,7 @@
*/
function _get_list_table( $class, $args = array() ) {
$core_classes = array(
- //Site Admin
+ // Site Admin.
'WP_Posts_List_Table' => 'posts',
'WP_Media_List_Table' => 'media',
'WP_Terms_List_Table' => 'terms',
@@ -34,12 +34,12 @@ function _get_list_table( $class, $args = array() ) {
'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ),
'WP_Plugins_List_Table' => 'plugins',
- // Network Admin
+ // Network Admin.
'WP_MS_Sites_List_Table' => 'ms-sites',
'WP_MS_Users_List_Table' => 'ms-users',
'WP_MS_Themes_List_Table' => 'ms-themes',
- // Privacy requests tables
+ // Privacy requests tables.
'WP_Privacy_Data_Export_Requests_List_Table' => 'privacy-data-export-requests',
'WP_Privacy_Data_Removal_Requests_List_Table' => 'privacy-data-removal-requests',
);
diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php
index 68675f7bfe..f52e9a4704 100644
--- a/wp-admin/includes/media.php
+++ b/wp-admin/includes/media.php
@@ -15,7 +15,7 @@
*/
function media_upload_tabs() {
$_default_tabs = array(
- 'type' => __( 'From Computer' ), // handler action suffix => tab text
+ 'type' => __( 'From Computer' ), // Handler action suffix => tab text.
'type_url' => __( 'From URL' ),
'gallery' => __( 'Gallery' ),
'library' => __( 'Media Library' ),
@@ -226,7 +226,7 @@ function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $
$caption = str_replace( array( "\r\n", "\r" ), "\n", $caption );
$caption = preg_replace_callback( '/<[a-zA-Z0-9]+(?: [^<>]+>)*/', '_cleanup_image_add_caption', $caption );
- // Convert any remaining line breaks to
. + // Convert any remaining line breaks to
. $caption = preg_replace( '/[ \n\t]*\n[ \t]*/', '
', $caption ); $html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html ); @@ -388,7 +388,7 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid } } - // Construct the attachment array + // Construct the attachment array. $attachment = array_merge( array( 'post_mime_type' => $type, @@ -404,7 +404,7 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid // This should never be set as it would then overwrite an existing attachment. unset( $attachment['ID'] ); - // Save the data + // Save the data. $attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true ); if ( ! is_wp_error( $attachment_id ) ) { @@ -490,7 +490,7 @@ function media_handle_sideload( $file_array, $post_id = 0, $desc = null, $post_d // This should never be set as it would then overwrite an existing attachment. unset( $attachment['ID'] ); - // Save the attachment metadata + // Save the attachment metadata. $attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true ); if ( ! is_wp_error( $attachment_id ) ) { @@ -519,7 +519,7 @@ function wp_iframe( $content_func, ...$args ) { " . wp_html_excerpt( $display_title, 60, '…' ) . '