Changeset 47084
- Timestamp:
- 01/18/2020 12:52:28 AM (5 years ago)
- Location:
- trunk/src/wp-admin/includes
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/comment.php
r45583 r47084 166 166 $pending_keyed = array(); 167 167 168 // Default to zero pending for all posts in request 168 // Default to zero pending for all posts in request. 169 169 foreach ( $post_id_array as $id ) { 170 170 $pending_keyed[ $id ] = 0; -
trunk/src/wp-admin/includes/dashboard.php
r47069 r47084 57 57 } 58 58 59 // Right Now 59 // Right Now. 60 60 if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) { 61 61 wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' ); … … 66 66 } 67 67 68 // Activity Widget 68 // Activity Widget. 69 69 if ( is_blog_admin() ) { 70 70 wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' ); 71 71 } 72 72 73 // QuickPress Widget 73 // QuickPress Widget. 74 74 if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { 75 75 $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' ) ); … … 77 77 } 78 78 79 // WordPress Events and News 79 // WordPress Events and News. 80 80 wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' ); 81 81 … … 140 140 if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget_id'] ) ) { 141 141 check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' ); 142 ob_start(); // hack - but the same hack wp-admin/widgets.php uses142 ob_start(); // Hack - but the same hack wp-admin/widgets.php uses. 143 143 wp_dashboard_trigger_widget_control( $_POST['widget_id'] ); 144 144 ob_end_clean(); … … 279 279 <ul> 280 280 <?php 281 // Posts and Pages 281 // Posts and Pages. 282 282 foreach ( array( 'post', 'page' ) as $post_type ) { 283 283 $num_posts = wp_count_posts( $post_type ); … … 299 299 } 300 300 } 301 // Comments 301 // Comments. 302 302 $num_comm = wp_count_comments(); 303 303 if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) { … … 507 507 508 508 /* 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. 510 510 if ( $last_post_id ) { 511 511 $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. 513 513 $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. 515 515 } else { 516 $post->post_title = ''; // Remove the auto draft title 516 $post->post_title = ''; // Remove the auto draft title. 517 517 } 518 518 } else { … … 521 521 // Don't create an option if this is a super admin who does not belong to this site. 522 522 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. 524 524 } 525 525 } … … 761 761 ( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; 762 762 763 // Reply and quickedit need a hide-if-no-js span 763 // Reply and quickedit need a hide-if-no-js span. 764 764 if ( 'reply' == $action || 'quickedit' == $action ) { 765 765 $action .= ' hide-if-no-js'; … … 1109 1109 ob_start(); 1110 1110 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 ); 1112 1113 } 1113 1114 … … 1164 1165 } 1165 1166 1166 $number = 1; // Hack to use wp_widget_rss_form() 1167 $number = 1; // Hack to use wp_widget_rss_form(). 1168 1167 1169 $widget_options[ $widget_id ]['number'] = $number; 1168 1170 … … 1663 1665 $response = get_site_transient( 'browser_' . $key ); 1664 1666 if ( false === $response ) { 1665 // include an unmodified $wp_version1667 // Include an unmodified $wp_version. 1666 1668 include( ABSPATH . WPINC . '/version.php' ); 1667 1669 -
trunk/src/wp-admin/includes/deprecated.php
r46644 r47084 234 234 $level_key = $wpdb->get_blog_prefix() . 'user_level'; 235 235 else 236 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels236 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels. 237 237 238 238 return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) ); … … 296 296 $level_key = $wpdb->get_blog_prefix() . 'user_level'; 297 297 else 298 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels298 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels. 299 299 300 300 $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key); … … 320 320 $level_key = $wpdb->get_blog_prefix() . 'user_level'; 321 321 else 322 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels322 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels. 323 323 324 324 return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) ); … … 545 545 $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%'); 546 546 } elseif ( is_multisite() ) { 547 $level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels547 $level_key = $wpdb->prefix . 'capabilities'; // WPMU site admins don't have user_levels. 548 548 $this->query_from .= ", $wpdb->usermeta"; 549 549 $this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'"; … … 565 565 566 566 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 limit567 $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // No limit. 568 568 else 569 569 $this->search_errors = new WP_Error('no_matching_users_found', __('No users found.')); … … 585 585 */ 586 586 public function do_paging() { 587 if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results587 if ( $this->total_users_for_query > $this->users_per_page ) { // Have to page the results. 588 588 $args = array(); 589 589 if ( ! empty($this->search_term) ) … … 1320 1320 _deprecated_function( __FUNCTION__, '4.8.0' ); 1321 1321 1322 // Plugin feeds plus link to install them 1322 // Plugin feeds plus link to install them. 1323 1323 $popular = fetch_feed( $args['url']['popular'] ); 1324 1324 … … 1336 1336 $items = $feed->get_items(0, 5); 1337 1337 1338 // Pick a random, non-installed plugin 1338 // Pick a random, non-installed plugin. 1339 1339 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. 1341 1341 if ( 0 == count($items) ) 1342 1342 continue 2; … … 1368 1368 } 1369 1369 1370 // Eliminate some common badly formed plugin descriptions 1370 // Eliminate some common badly formed plugin descriptions. 1371 1371 while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) ) 1372 1372 unset($items[$item_key]); -
trunk/src/wp-admin/includes/file.php
r47060 r47084 22 22 '404.php' => __( '404 Template' ), 23 23 'link.php' => __( 'Links Template' ), 24 // Archives 24 // Archives. 25 25 'index.php' => __( 'Main Index Template' ), 26 26 'archive.php' => __( 'Archives' ), … … 32 32 'search.php' => __( 'Search Results' ), 33 33 'date.php' => __( 'Date Template' ), 34 // Content 34 // Content. 35 35 'singular.php' => __( 'Singular Template' ), 36 36 'single.php' => __( 'Single Post' ), … … 38 38 'front-page.php' => __( 'Homepage' ), 39 39 'privacy-policy.php' => __( 'Privacy Policy Page' ), 40 // Attachments 40 // Attachments. 41 41 'attachment.php' => __( 'Attachment Template' ), 42 42 'image.php' => __( 'Image Attachment Template' ), … … 44 44 'audio.php' => __( 'Audio Attachment Template' ), 45 45 'application.php' => __( 'Application Attachment Template' ), 46 // Embeds 46 // Embeds. 47 47 'embed.php' => __( 'Embed Template' ), 48 48 'embed-404.php' => __( 'Embed 404 Template' ), … … 50 50 'header-embed.php' => __( 'Embed Header Template' ), 51 51 'footer-embed.php' => __( 'Embed Footer Template' ), 52 // Stylesheets 52 // Stylesheets. 53 53 'style.css' => __( 'Stylesheet' ), 54 54 'editor-style.css' => __( 'Visual Editor Stylesheet' ), 55 55 'editor-style-rtl.css' => __( 'Visual Editor RTL Stylesheet' ), 56 56 'rtl.css' => __( 'RTL Stylesheet' ), 57 // Other 57 // Other. 58 58 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ), 59 59 '.htaccess' => __( '.htaccess (for rewrite rules )' ), 60 // Deprecated files 60 // Deprecated files. 61 61 'wp-layout.css' => __( 'Stylesheet' ), 62 62 'wp-comments.php' => __( 'Comments Template' ), … … 456 456 } 457 457 458 // Compare based on relative paths 458 // Compare based on relative paths. 459 459 if ( 0 !== validate_file( $file, array_keys( $allowed_files ) ) ) { 460 460 return new WP_Error( 'disallowed_theme_file', __( 'Sorry, that file cannot be edited.' ) ); … … 508 508 $transient = 'scrape_key_' . $scrape_key; 509 509 $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 ); 511 512 512 513 $cookies = wp_unslash( $_COOKIE ); … … 645 646 } 646 647 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. 648 649 $temp_filename = basename( $filename ); 649 650 $temp_filename = preg_replace( '|\.[^.]*$|', '', $temp_filename ); … … 654 655 } 655 656 656 // Suffix some random data to avoid filename conflicts 657 // Suffix some random data to avoid filename conflicts. 657 658 $temp_filename .= '-' . wp_generate_password( 6, false ); 658 659 $temp_filename .= '.tmp'; … … 736 737 $file = apply_filters( "{$action}_prefilter", $file ); 737 738 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']. 739 740 $upload_error_handler = 'wp_handle_upload_error'; 740 741 if ( isset( $overrides['upload_error_handler'] ) ) { … … 749 750 // Install user overrides. Did we mention that this voids your warranty? 750 751 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']. 752 753 $unique_filename_callback = null; 753 754 if ( isset( $overrides['unique_filename_callback'] ) ) { … … 823 824 $proper_filename = empty( $wp_filetype['proper_filename'] ) ? '' : $wp_filetype['proper_filename']; 824 825 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. 826 827 if ( $proper_filename ) { 827 828 $file['name'] = $proper_filename; … … 870 871 $move_new_file = @move_uploaded_file( $file['tmp_name'], $new_file ); 871 872 } else { 872 // use copy and unlink because rename breaks streams.873 // Use copy and unlink because rename breaks streams. 873 874 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged 874 875 $move_new_file = @copy( $file['tmp_name'], $new_file ); … … 1002 1003 */ 1003 1004 function 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. 1005 1006 if ( ! $url ) { 1006 1007 return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.' ) ); … … 1083 1084 if ( ! $signature ) { 1084 1085 // 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. 1086 1087 1087 1088 $signature_url = false; … … 1105 1106 $signature_url, 1106 1107 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. 1108 1109 ) 1109 1110 ); … … 1162 1163 $expected_raw_md5 = base64_decode( $expected_md5 ); 1163 1164 } else { 1164 return false; // unknown format1165 return false; // Unknown format. 1165 1166 } 1166 1167 … … 1211 1212 } 1212 1213 1213 // Check for a edge-case affecting PHP Maths abilities 1214 // Check for a edge-case affecting PHP Maths abilities. 1214 1215 if ( 1215 1216 ! extension_loaded( 'sodium' ) && … … 1251 1252 } 1252 1253 1253 // This cannot be performed in a reasonable amount of time 1254 // This cannot be performed in a reasonable amount of time. 1254 1255 // https://github.com/paragonie/sodium_compat#help-sodium_compat-is-slow-how-can-i-make-it-fast 1255 1256 if ( ! $sodium_compat_is_fast ) { … … 1479 1480 } 1480 1481 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. 1482 1483 continue; 1483 1484 } … … 1516 1517 foreach ( $needed_dirs as $dir ) { 1517 1518 // 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). 1519 1520 continue; 1520 1521 } 1521 if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, Skip it1522 if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, skip it. 1522 1523 continue; 1523 1524 } … … 1550 1551 } 1551 1552 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. 1553 1554 continue; 1554 1555 } … … 1616 1617 $uncompressed_size = 0; 1617 1618 1618 // Determine any children directories needed (From within the archive) 1619 // Determine any children directories needed (From within the archive). 1619 1620 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. 1621 1622 continue; 1622 1623 } … … 1642 1643 foreach ( $needed_dirs as $dir ) { 1643 1644 // 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). 1645 1646 continue; 1646 1647 } 1647 if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, Skip it1648 if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, skip it. 1648 1649 continue; 1649 1650 } … … 1666 1667 unset( $needed_dirs ); 1667 1668 1668 // Extract the files from the zip 1669 // Extract the files from the zip. 1669 1670 foreach ( $archive_files as $file ) { 1670 1671 if ( $file['folder'] ) { … … 1672 1673 } 1673 1674 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. 1675 1676 continue; 1676 1677 } … … 1731 1732 } 1732 1733 1733 // generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list1734 // Generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list. 1734 1735 $sub_skip_list = array(); 1735 1736 foreach ( $skip_list as $skip_item ) { … … 1749 1750 1750 1751 /** 1751 * Initiali ses and connects the WordPress Filesystem Abstraction classes.1752 * Initializes and connects the WordPress Filesystem Abstraction classes. 1752 1753 * 1753 1754 * This function will include the chosen transport and attempt connecting. … … 1801 1802 $wp_filesystem = new $method( $args ); 1802 1803 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 */ 1804 1808 if ( ! defined( 'FS_CONNECT_TIMEOUT' ) ) { 1805 1809 define( 'FS_CONNECT_TIMEOUT', 30 ); … … 1814 1818 1815 1819 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. 1817 1821 } 1818 1822 … … 1855 1859 */ 1856 1860 function 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; 1858 1863 1859 1864 if ( ! $context ) { … … 1874 1879 if ( $temp_handle ) { 1875 1880 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. 1877 1882 $wp_file_owner = false; 1878 1883 $temp_file_owner = false; … … 1883 1888 1884 1889 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 */ 1887 1894 $method = 'direct'; 1888 1895 $GLOBALS['_wp_filesystem_direct_method'] = 'file_owner'; 1889 1896 } 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 */ 1892 1902 $method = 'direct'; 1893 1903 $GLOBALS['_wp_filesystem_direct_method'] = 'relaxed_ownership'; … … 1906 1916 } 1907 1917 if ( ! $method && ( extension_loaded( 'sockets' ) || function_exists( 'fsockopen' ) ) ) { 1908 $method = 'ftpsockets'; // Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread1918 $method = 'ftpsockets'; // Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread. 1909 1919 } 1910 1920 … … 1999 2009 $submitted_form = wp_unslash( $_POST ); 2000 2010 2001 // Verify nonce, or unset submitted form field values on failure 2011 // Verify nonce, or unset submitted form field values on failure. 2002 2012 if ( ! isset( $_POST['_fs_nonce'] ) || ! wp_verify_nonce( $_POST['_fs_nonce'], 'filesystem-credentials' ) ) { 2003 2013 unset( … … 2011 2021 } 2012 2022 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). 2014 2024 $credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : ( ! empty( $submitted_form['hostname'] ) ? $submitted_form['hostname'] : $credentials['hostname'] ); 2015 2025 $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : ( ! empty( $submitted_form['username'] ) ? $submitted_form['username'] : $credentials['username'] ); 2016 2026 $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : ( ! empty( $submitted_form['password'] ) ? $submitted_form['password'] : '' ); 2017 2027 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. 2019 2029 $credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : ( ! empty( $submitted_form['public_key'] ) ? $submitted_form['public_key'] : '' ); 2020 2030 $credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : ( ! empty( $submitted_form['private_key'] ) ? $submitted_form['private_key'] : '' ); 2021 2031 2022 // Sanitize the hostname, Some people might pass in odd-data:2023 $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); // Strip any schemes off2032 // Sanitize the hostname, some people might pass in odd data. 2033 $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); // Strip any schemes off. 2024 2034 2025 2035 if ( strpos( $credentials['hostname'], ':' ) ) { … … 2034 2044 if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' == FS_METHOD ) ) { 2035 2045 $credentials['connection_type'] = 'ssh'; 2036 } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { // Only the FTP Extension understands SSL2046 } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { // Only the FTP Extension understands SSL. 2037 2047 $credentials['connection_type'] = 'ftps'; 2038 2048 } elseif ( ! empty( $submitted_form['connection_type'] ) ) { 2039 2049 $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 FTP2050 } elseif ( ! isset( $credentials['connection_type'] ) ) { // All else fails (and it's not defaulted to something else saved), default to FTP. 2041 2051 $credentials['connection_type'] = 'ftp'; 2042 2052 } … … 2047 2057 ) ) { 2048 2058 $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. 2050 2060 $stored_credentials['hostname'] .= ':' . $stored_credentials['port']; 2051 2061 } … … 2076 2086 $types['ftp'] = __( 'FTP' ); 2077 2087 } 2078 if ( extension_loaded( 'ftp' ) ) { // Only this supports FTPS2088 if ( extension_loaded( 'ftp' ) ) { // Only this supports FTPS. 2079 2089 $types['ftps'] = __( 'FTPS (SSL)' ); 2080 2090 } -
trunk/src/wp-admin/includes/image-edit.php
r47065 r47084 200 200 <?php 201 201 202 // On some setups GD library does not provide imagerotate() - Ticket #11536 202 // On some setups GD library does not provide imagerotate() - Ticket #11536. 203 203 if ( wp_image_editor_supports( 204 204 array( … … 602 602 $h = $size['height']; 603 603 604 $scale = 1 / _image_get_preview_ratio( $w, $h ); // discard preview scaling604 $scale = 1 / _image_get_preview_ratio( $w, $h ); // Discard preview scaling. 605 605 $image->crop( $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale ); 606 606 } else { 607 $scale = 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // discard preview scaling607 $scale = 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // Discard preview scaling. 608 608 $image = _crop_image_resource( $image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale ); 609 609 } … … 956 956 957 957 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. 959 959 if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' == $_REQUEST['context'] ) { 960 960 $thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true ); -
trunk/src/wp-admin/includes/image.php
r46809 r47084 25 25 function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) { 26 26 $src_file = $src; 27 if ( is_numeric( $src ) ) { // Handle int as attachment ID 27 if ( is_numeric( $src ) ) { // Handle int as attachment ID. 28 28 $src_file = get_attached_file( $src ); 29 29 … … 118 118 } 119 119 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 */ 125 127 $missing_sizes = array_diff_key( $possible_sizes, $image_meta['sizes'] ); 126 128 … … 230 232 } 231 233 232 // Default image meta 234 // Default image meta. 233 235 $image_meta = array( 234 236 'width' => $imagesize[0], … … 319 321 } 320 322 321 // Rotate the image 323 // Rotate the image. 322 324 $rotated = $editor->maybe_exif_rotate(); 323 325 … … 340 342 } 341 343 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 */ 345 349 wp_update_attachment_metadata( $attachment_id, $image_meta ); 346 350 … … 387 391 if ( isset( $image_meta['sizes'] ) && is_array( $image_meta['sizes'] ) ) { 388 392 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 */ 392 398 if ( array_key_exists( $size_name, $new_sizes ) ) { 393 399 unset( $new_sizes[ $size_name ] ); … … 403 409 } 404 410 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 */ 408 416 $priority = array( 409 417 'medium' => null, … … 734 742 } 735 743 736 if ( ! empty( $iptc['2#110'][0] ) ) { // credit744 if ( ! empty( $iptc['2#110'][0] ) ) { // Credit. 737 745 $meta['credit'] = trim( $iptc['2#110'][0] ); 738 } elseif ( ! empty( $iptc['2#080'][0] ) ) { // creator / legacy byline746 } elseif ( ! empty( $iptc['2#080'][0] ) ) { // Creator / legacy byline. 739 747 $meta['credit'] = trim( $iptc['2#080'][0] ); 740 748 } 741 749 742 if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) { // created date and time750 if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) { // Created date and time. 743 751 $meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] ); 744 752 } 745 753 746 if ( ! empty( $iptc['2#116'][0] ) ) { // copyright754 if ( ! empty( $iptc['2#116'][0] ) ) { // Copyright. 747 755 $meta['copyright'] = trim( $iptc['2#116'][0] ); 748 756 } 749 757 750 if ( ! empty( $iptc['2#025'][0] ) ) { // keywords array758 if ( ! empty( $iptc['2#025'][0] ) ) { // Keywords array. 751 759 $meta['keywords'] = array_values( $iptc['2#025'] ); 752 760 } … … 774 782 775 783 if ( empty( $meta['title'] ) && $description_length < 80 ) { 776 // Assume the title is stored in ImageDescription 784 // Assume the title is stored in ImageDescription. 777 785 $meta['title'] = trim( $exif['ImageDescription'] ); 778 786 } -
trunk/src/wp-admin/includes/import.php
r47043 r47084 104 104 } 105 105 106 // Construct the object array 106 // Construct the object array. 107 107 $object = array( 108 108 'post_title' => wp_basename( $upload['file'] ), … … 114 114 ); 115 115 116 // Save the data 116 // Save the data. 117 117 $id = wp_insert_attachment( $object, $upload['file'] ); 118 118 … … 137 137 */ 138 138 function wp_get_popular_importers() { 139 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version139 include( ABSPATH . WPINC . '/version.php' ); // Include an unmodified $wp_version. 140 140 141 141 $locale = get_user_locale(); … … 185 185 186 186 return array( 187 // slug => name, description, plugin slug, and register_importer() slug 187 // slug => name, description, plugin slug, and register_importer() slug. 188 188 'blogger' => array( 189 189 'name' => __( 'Blogger' ), -
trunk/src/wp-admin/includes/list-table.php
r46596 r47084 22 22 function _get_list_table( $class, $args = array() ) { 23 23 $core_classes = array( 24 // Site Admin24 // Site Admin. 25 25 'WP_Posts_List_Table' => 'posts', 26 26 'WP_Media_List_Table' => 'media', … … 35 35 'WP_Plugins_List_Table' => 'plugins', 36 36 37 // Network Admin 37 // Network Admin. 38 38 'WP_MS_Sites_List_Table' => 'ms-sites', 39 39 'WP_MS_Users_List_Table' => 'ms-users', 40 40 'WP_MS_Themes_List_Table' => 'ms-themes', 41 41 42 // Privacy requests tables 42 // Privacy requests tables. 43 43 'WP_Privacy_Data_Export_Requests_List_Table' => 'privacy-data-export-requests', 44 44 'WP_Privacy_Data_Removal_Requests_List_Table' => 'privacy-data-removal-requests', -
trunk/src/wp-admin/includes/media.php
r47039 r47084 16 16 function media_upload_tabs() { 17 17 $_default_tabs = array( 18 'type' => __( 'From Computer' ), // handler action suffix => tab text18 'type' => __( 'From Computer' ), // Handler action suffix => tab text. 19 19 'type_url' => __( 'From URL' ), 20 20 'gallery' => __( 'Gallery' ), … … 227 227 $caption = preg_replace_callback( '/<[a-zA-Z0-9]+(?: [^<>]+>)*/', '_cleanup_image_add_caption', $caption ); 228 228 229 // Convert any remaining line breaks to <br >.229 // Convert any remaining line breaks to <br />. 230 230 $caption = preg_replace( '/[ \n\t]*\n[ \t]*/', '<br />', $caption ); 231 231 … … 389 389 } 390 390 391 // Construct the attachment array 391 // Construct the attachment array. 392 392 $attachment = array_merge( 393 393 array( … … 405 405 unset( $attachment['ID'] ); 406 406 407 // Save the data 407 // Save the data. 408 408 $attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true ); 409 409 … … 491 491 unset( $attachment['ID'] ); 492 492 493 // Save the attachment metadata 493 // Save the attachment metadata. 494 494 $attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true ); 495 495 … … 520 520 521 521 wp_enqueue_style( 'colors' ); 522 // Check callback name for 'media' 522 // Check callback name for 'media'. 523 523 if ( 524 524 ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) ) || … … 850 850 if ( isset( $_POST['html-upload'] ) && ! empty( $_FILES ) ) { 851 851 check_admin_referer( 'media-form' ); 852 // Upload File button was clicked 852 // Upload File button was clicked. 853 853 $id = media_handle_upload( 'async-upload', $_REQUEST['post_id'] ); 854 854 unset( $_FILES ); … … 1422 1422 } 1423 1423 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 */ 1426 1430 $form_fields = array_merge_recursive( $form_fields, (array) $errors ); 1427 1431 … … 1597 1601 } 1598 1602 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. 1600 1604 $display_title = $parsed_args['show_title'] ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60, '…' ) . '</span></div>' : ''; 1601 1605 … … 1711 1715 if ( isset( $_GET['post_id'] ) ) { 1712 1716 $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. 1714 1718 $calling_post_id = $post->post_parent; 1715 1719 } … … 1876 1880 } 1877 1881 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 */ 1880 1888 $form_fields = array_merge_recursive( $form_fields, (array) $args['errors'] ); 1881 1889 … … 2133 2141 ); 2134 2142 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 */ 2137 2148 if ( 2138 2149 wp_is_mobile() && … … 2701 2712 } 2702 2713 } 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. 2704 2715 if ( empty( $_GET['post_mime_type'] ) && ! empty( $num_posts[ $type ] ) ) { 2705 2716 $_GET['post_mime_type'] = $type; -
trunk/src/wp-admin/includes/menu.php
r45583 r47084 209 209 $i++; 210 210 211 if ( 0 == $order ) { // dashboard is always shown/single211 if ( 0 == $order ) { // Dashboard is always shown/single. 212 212 $menu[0][4] = add_cssclass( 'menu-top-first', $top[4] ); 213 213 $lastorder = 0; … … 215 215 } 216 216 217 if ( 0 === strpos( $top[2], 'separator' ) && false !== $lastorder ) { // if separator217 if ( 0 === strpos( $top[2], 'separator' ) && false !== $lastorder ) { // If separator. 218 218 $first = true; 219 219 $c = $menu[ $lastorder ][4]; … … 228 228 } 229 229 230 if ( $mc == $i ) { // last item230 if ( $mc == $i ) { // Last item. 231 231 $c = $menu[ $order ][4]; 232 232 $menu[ $order ][4] = add_cssclass( 'menu-top-last', $c ); … … 246 246 } 247 247 248 uksort( $menu, 'strnatcasecmp' ); // make it all pretty248 uksort( $menu, 'strnatcasecmp' ); // Make it all pretty. 249 249 250 250 /** … … 311 311 } 312 312 313 // Prevent adjacent separators 313 // Prevent adjacent separators. 314 314 $prev_menu_was_separator = false; 315 315 foreach ( $menu as $id => $data ) { 316 316 if ( false === stristr( $data[4], 'wp-menu-separator' ) ) { 317 317 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. 319 319 $prev_menu_was_separator = false; 320 320 } else { 321 321 322 // The previous item was a separator, so unset this one 322 // The previous item was a separator, so unset this one. 323 323 if ( true === $prev_menu_was_separator ) { 324 324 unset( $menu[ $id ] ); 325 325 } 326 326 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. 328 328 $prev_menu_was_separator = true; 329 329 }
Note: See TracChangeset
for help on using the changeset viewer.