diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index 94d7cbbd59..6307035f3a 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/wp-admin/includes/meta-boxes.php @@ -1,6 +1,14 @@ - +
@@ -71,7 +79,7 @@ function post_submit_meta_box( $post, $args = array() ) { - + ID ) { - if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date + if ( 'future' == $post->post_status ) { // Scheduled for publishing at a future date. /* translators: Post date information. %s: Date on which the post is currently scheduled to be published. */ $stamp = __( 'Scheduled for: %s' ); - } elseif ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published + } elseif ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // Already published. /* translators: Post date information. %s: Date on which the post was published. */ $stamp = __( 'Published on: %s' ); - } elseif ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified + } elseif ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // Draft, 1 or more saves, no date specified. $stamp = __( 'Publish immediately' ); - } elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified + } elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // Draft, 1 or more saves, future date specified. /* translators: Post date information. %s: Date on which the post is to be published. */ $stamp = __( 'Schedule for: %s' ); - } else { // draft, 1 or more saves, date specified + } else { // Draft, 1 or more saves, date specified. /* translators: Post date information. %s: Date on which the post is to be published. */ $stamp = __( 'Publish on: %s' ); } @@ -222,7 +230,7 @@ function post_submit_meta_box( $post, $args = array() ) { date_i18n( $date_format, strtotime( $post->post_date ) ), date_i18n( $time_format, strtotime( $post->post_date ) ) ); - } else { // draft (no saves, and thus no date specified) + } else { // Draft (no saves, and thus no date specified). $stamp = __( 'Publish immediately' ); $date = sprintf( $date_string, @@ -243,7 +251,7 @@ function post_submit_meta_box( $post, $args = array() ) {' . __( 'Note:' ) . ' '; printf( /* translators: %s: mod_rewrite */ @@ -206,7 +206,7 @@ function network_step1( $errors = false ) { echo '
'; } - if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache) + if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache). echo ''; printf( /* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite. */ @@ -225,7 +225,7 @@ function network_step1( $errors = false ) {
- +
| @@ -547,7 +547,7 @@ define('BLOG_ID_CURRENT_SITE', 1); diff --git a/src/wp-admin/includes/plugin-install.php b/src/wp-admin/includes/plugin-install.php index 6e56b33669..d15a9aaf32 100644 --- a/src/wp-admin/includes/plugin-install.php +++ b/src/wp-admin/includes/plugin-install.php @@ -100,7 +100,7 @@ * for more information on the make-up of possible return values depending on the value of `$action`. */ function plugins_api( $action, $args = array() ) { - // include an unmodified $wp_version + // Include an unmodified $wp_version. include( ABSPATH . WPINC . '/version.php' ); if ( is_array( $args ) ) { @@ -118,7 +118,7 @@ function plugins_api( $action, $args = array() ) { } if ( ! isset( $args->wp_version ) ) { - $args->wp_version = substr( $wp_version, 0, 3 ); // X.y + $args->wp_version = substr( $wp_version, 0, 3 ); // x.y } /** @@ -285,7 +285,7 @@ function install_dashboard() { if ( is_wp_error( $api_tags ) ) { echo $api_tags->get_error_message(); } else { - //Set up the tags in a way which can be interpreted by wp_generate_tag_cloud() + // Set up the tags in a way which can be interpreted by wp_generate_tag_cloud(). $tags = array(); foreach ( (array) $api_tags as $tag ) { $url = self_admin_url( 'plugin-install.php?tab=search&type=tag&s=' . urlencode( $tag['name'] ) ); @@ -437,7 +437,7 @@ function install_plugin_install_status( $api, $loop = false ) { $api = (object) $api; } - // Default to a "new" plugin + // Default to a "new" plugin. $status = 'install'; $url = false; $update_file = false; @@ -470,8 +470,11 @@ function install_plugin_install_status( $api, $loop = false ) { $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug ); } } else { - $key = array_keys( $installed_plugin ); - $key = reset( $key ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers + $key = array_keys( $installed_plugin ); + // Use the first plugin regardless of the name. + // Could have issues for multiple plugins in one directory if they share different version numbers. + $key = reset( $key ); + $update_file = $api->slug . '/' . $key; if ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '=' ) ) { $status = 'latest_installed'; @@ -479,7 +482,7 @@ function install_plugin_install_status( $api, $loop = false ) { $status = 'newer_installed'; $version = $installed_plugin[ $key ]['Version']; } else { - //If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh + // If the above update check failed, then that probably means that the update checker has out-of-date information, force a refresh. if ( ! $loop ) { delete_site_transient( 'update_plugins' ); wp_update_plugins(); @@ -488,7 +491,7 @@ function install_plugin_install_status( $api, $loop = false ) { } } } else { - // "install" & no directory with that slug + // "install" & no directory with that slug. if ( current_user_can( 'install_plugins' ) ) { $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug ); } @@ -570,7 +573,7 @@ function install_plugin_information() { 'other_notes' => _x( 'Other Notes', 'Plugin installer section title' ), ); - // Sanitize HTML + // Sanitize HTML. foreach ( (array) $api->sections as $section_name => $content ) { $api->sections[ $section_name ] = wp_kses( $content, $plugins_allowedtags ); } @@ -583,7 +586,8 @@ function install_plugin_information() { $_tab = esc_attr( $tab ); - $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English. + // Default to the Description tab, Do not translate, API returns English. + $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) { $section_titles = array_keys( (array) $api->sections ); $section = reset( $section_titles ); diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index 76d2dcb480..ca8bb51e8b 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/wp-admin/includes/plugin.php @@ -331,7 +331,8 @@ function get_plugins( $plugin_folder = '' ) { continue; } - $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. + // Do not apply markup/translate as it will be cached. + $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); if ( empty( $plugin_data['Name'] ) ) { continue; @@ -357,13 +358,14 @@ function get_plugins( $plugin_folder = '' ) { * @return array[] Array of arrays of mu-plugin data, keyed by plugin file name. See `get_plugin_data()`. */ function get_mu_plugins() { - $wp_plugins = array(); - // Files in wp-content/mu-plugins directory. + $wp_plugins = array(); $plugin_files = array(); if ( ! is_dir( WPMU_PLUGIN_DIR ) ) { return $wp_plugins; } + + // Files in wp-content/mu-plugins directory. $plugins_dir = @opendir( WPMU_PLUGIN_DIR ); if ( $plugins_dir ) { while ( ( $file = readdir( $plugins_dir ) ) !== false ) { @@ -386,7 +388,8 @@ function get_mu_plugins() { continue; } - $plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. + // Do not apply markup/translate as it will be cached. + $plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false ); if ( empty( $plugin_data['Name'] ) ) { $plugin_data['Name'] = $plugin_file; @@ -395,7 +398,8 @@ function get_mu_plugins() { $wp_plugins[ $plugin_file ] = $plugin_data; } - if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php' ) <= 30 ) { // silence is golden + if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php' ) <= 30 ) { + // Silence is golden. unset( $wp_plugins['index.php'] ); } @@ -431,7 +435,7 @@ function get_dropins() { $_dropins = _get_dropins(); - // These exist in the wp-content directory. + // Files in wp-content directory. $plugins_dir = @opendir( WP_CONTENT_DIR ); if ( $plugins_dir ) { while ( ( $file = readdir( $plugins_dir ) ) !== false ) { @@ -453,10 +457,14 @@ function get_dropins() { if ( ! is_readable( WP_CONTENT_DIR . "/$plugin_file" ) ) { continue; } - $plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. + + // Do not apply markup/translate as it will be cached. + $plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false ); + if ( empty( $plugin_data['Name'] ) ) { $plugin_data['Name'] = $plugin_file; } + $dropins[ $plugin_file ] = $plugin_data; } @@ -477,21 +485,21 @@ function get_dropins() { */ function _get_dropins() { $dropins = array( - 'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE - 'db.php' => array( __( 'Custom database class.' ), true ), // auto on load - 'db-error.php' => array( __( 'Custom database error message.' ), true ), // auto on error - 'install.php' => array( __( 'Custom installation script.' ), true ), // auto on installation - 'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // auto on maintenance - 'object-cache.php' => array( __( 'External object cache.' ), true ), // auto on load - 'php-error.php' => array( __( 'Custom PHP error message.' ), true ), // auto on error - 'fatal-error-handler.php' => array( __( 'Custom PHP fatal error handler.' ), true ), // auto on error + 'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE + 'db.php' => array( __( 'Custom database class.' ), true ), // Auto on load. + 'db-error.php' => array( __( 'Custom database error message.' ), true ), // Auto on error. + 'install.php' => array( __( 'Custom installation script.' ), true ), // Auto on installation. + 'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // Auto on maintenance. + 'object-cache.php' => array( __( 'External object cache.' ), true ), // Auto on load. + 'php-error.php' => array( __( 'Custom PHP error message.' ), true ), // Auto on error. + 'fatal-error-handler.php' => array( __( 'Custom PHP fatal error handler.' ), true ), // Auto on error. ); if ( is_multisite() ) { $dropins['sunrise.php'] = array( __( 'Executed before Multisite is loaded.' ), 'SUNRISE' ); // SUNRISE - $dropins['blog-deleted.php'] = array( __( 'Custom site deleted message.' ), true ); // auto on deleted blog - $dropins['blog-inactive.php'] = array( __( 'Custom site inactive message.' ), true ); // auto on inactive blog - $dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // auto on archived or spammed blog + $dropins['blog-deleted.php'] = array( __( 'Custom site deleted message.' ), true ); // Auto on deleted blog. + $dropins['blog-inactive.php'] = array( __( 'Custom site inactive message.' ), true ); // Auto on inactive blog. + $dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // Auto on archived or spammed blog. } return $dropins; @@ -638,7 +646,8 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current ) ) ) { if ( ! empty( $redirect ) ) { - wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) ); // we'll override this later if the plugin can be included without fatal error + // We'll override this later if the plugin can be included without fatal error. + wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) ); } ob_start(); @@ -908,7 +917,8 @@ function delete_plugins( $plugins, $deprecated = '' ) { if ( ! WP_Filesystem( $credentials ) ) { ob_start(); - request_filesystem_credentials( $url, '', true ); // Failed to connect, Error and request again. + // Failed to connect. Error and request again. + request_filesystem_credentials( $url, '', true ); $data = ob_get_clean(); if ( ! empty( $data ) ) { @@ -958,7 +968,8 @@ function delete_plugins( $plugins, $deprecated = '' ) { $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) ); // If plugin is in its own directory, recursively delete the directory. - if ( strpos( $plugin_file, '/' ) && $this_plugin_dir != $plugins_dir ) { //base check on if plugin includes directory separator AND that it's not the root plugin folder + // Base check on if plugin includes directory separator AND that it's not the root plugin folder. + if ( strpos( $plugin_file, '/' ) && $this_plugin_dir != $plugins_dir ) { $deleted = $wp_filesystem->delete( $this_plugin_dir, true ); } else { $deleted = $wp_filesystem->delete( $plugins_dir . $plugin_file ); @@ -1237,7 +1248,7 @@ function uninstall_plugin( $plugin ) { } // -// Menu +// Menu. // /** @@ -1306,7 +1317,7 @@ function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $func $_registered_pages[ $hookname ] = true; - // No parent as top level + // No parent as top level. $_parent_pages[ $menu_slug ] = false; return $hookname; @@ -1412,7 +1423,7 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, } } } - // Sort the parent array + // Sort the parent array. ksort( $submenu[ $parent_slug ] ); $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug ); @@ -1793,7 +1804,7 @@ function menu_page_url( $menu_slug, $echo = true ) { } // -// Pluggable Menu Support -- Private +// Pluggable Menu Support -- Private. // /** * Gets the parent file of the current admin page. @@ -1932,7 +1943,7 @@ function get_admin_page_title() { return $submenu_array[3]; } - if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) { // not the current page + if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) { // Not the current page. continue; } diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index 075edb159e..279a86567e 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -92,7 +92,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) { if ( ! empty( $post_data['post_status'] ) ) { $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); - // No longer an auto-draft + // No longer an auto-draft. if ( 'auto-draft' === $post_data['post_status'] ) { $post_data['post_status'] = 'draft'; } @@ -102,7 +102,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) { } } - // What to do based on which button they pressed + // What to do based on which button they pressed. if ( isset( $post_data['saveasdraft'] ) && '' != $post_data['saveasdraft'] ) { $post_data['post_status'] = 'draft'; } @@ -132,7 +132,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) { $published_statuses = array( 'publish', 'future' ); - // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published. + // Posts 'submitted for approval' are submitted to $_POST the same as if they were being published. // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts. if ( isset( $post_data['post_status'] ) && ( in_array( $post_data['post_status'], $published_statuses ) && ! current_user_can( $ptype->cap->publish_posts ) ) ) { if ( ! in_array( $previous_status, $published_statuses ) || ! current_user_can( 'edit_post', $post_id ) ) { @@ -208,7 +208,7 @@ function _wp_get_allowed_postdata( $post_data = null ) { $post_data = $_POST; } - // Pass through errors + // Pass through errors. if ( is_wp_error( $post_data ) ) { return $post_data; } @@ -268,7 +268,7 @@ function edit_post( $post_data = null ) { ); $revision = current( $revisions ); - // Check if the revisions have been upgraded + // Check if the revisions have been upgraded. if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) { _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); } @@ -296,7 +296,7 @@ function edit_post( $post_data = null ) { } $translated = _wp_get_allowed_postdata( $post_data ); - // Post Formats + // Post formats. if ( isset( $post_data['post_format'] ) ) { set_post_format( $post_ID, $post_data['post_format'] ); } @@ -336,7 +336,7 @@ function edit_post( $post_data = null ) { wp_update_attachment_metadata( $post_ID, $id3data ); } - // Meta Stuff + // Meta stuff. if ( isset( $post_data['meta'] ) && $post_data['meta'] ) { foreach ( $post_data['meta'] as $key => $value ) { $meta = get_post_meta_by_id( $key ); @@ -372,13 +372,15 @@ function edit_post( $post_data = null ) { } } - // Attachment stuff + // Attachment stuff. if ( 'attachment' == $post_data['post_type'] ) { if ( isset( $post_data['_wp_attachment_image_alt'] ) ) { $image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] ); + if ( $image_alt != get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) ) { $image_alt = wp_strip_all_tags( $image_alt, true ); - // update_meta expects slashed. + + // update_post_meta() expects slashed. update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) ); } } @@ -405,7 +407,8 @@ function edit_post( $post_data = null ) { update_post_meta( $post_ID, '_edit_last', get_current_user_id() ); $success = wp_update_post( $translated ); - // If the save failed, see if we can sanity check the main fields and try again + + // If the save failed, see if we can sanity check the main fields and try again. if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) { $fields = array( 'post_title', 'post_content', 'post_excerpt' ); @@ -418,7 +421,7 @@ function edit_post( $post_data = null ) { wp_update_post( $translated ); } - // Now that we have an ID we can fix any attachment anchor hrefs + // Now that we have an ID we can fix any attachment anchor hrefs. _fix_attachment_links( $post_ID ); wp_set_post_lock( $post_ID ); @@ -676,7 +679,7 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) set_post_format( $post, get_option( 'default_post_format' ) ); } - // Schedule auto-draft cleanup + // Schedule auto-draft cleanup. if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) { wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' ); } @@ -816,7 +819,7 @@ function wp_write_post() { // Clear out any data in internal vars. unset( $_POST['filter'] ); - // Edit don't write if we have a post id. + // Edit, don't write, if we have a post ID. if ( isset( $_POST['post_ID'] ) ) { return edit_post(); } @@ -857,7 +860,7 @@ function wp_write_post() { add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); - // Now that we have an ID we can fix any attachment anchor hrefs + // Now that we have an ID we can fix any attachment anchor hrefs. _fix_attachment_links( $post_ID ); wp_set_post_lock( $post_ID ); @@ -882,7 +885,7 @@ function write_post() { } // -// Post Meta +// Post Meta. // /** @@ -913,7 +916,7 @@ function add_meta( $post_ID ) { } if ( $metakeyinput ) { - $metakey = $metakeyinput; // default + $metakey = $metakeyinput; // Default. } if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) { @@ -926,7 +929,7 @@ function add_meta( $post_ID ) { } return false; -} // add_meta +} /** * Delete post meta data by meta ID. @@ -1017,7 +1020,7 @@ function update_meta( $meta_id, $meta_key, $meta_value ) { } // -// Private +// Private. // /** @@ -1038,13 +1041,13 @@ function _fix_attachment_links( $post ) { return; } - // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero) + // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero). if ( ! strpos( $content, '?attachment_id=' ) || ! preg_match_all( '/]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) { return; } $site_url = get_bloginfo( 'url' ); - $site_url = substr( $site_url, (int) strpos( $site_url, '://' ) ); // remove the http(s) + $site_url = substr( $site_url, (int) strpos( $site_url, '://' ) ); // Remove the http(s). $replace = ''; foreach ( $link_matches[1] as $key => $value ) { @@ -1054,7 +1057,7 @@ function _fix_attachment_links( $post ) { continue; } - $quote = $url_match[1]; // the quote (single or double) + $quote = $url_match[1]; // The quote (single or double). $url_id = (int) $url_match[2]; $rel_id = (int) $rel_match[1]; @@ -1344,8 +1347,8 @@ function get_sample_permalink( $id, $title = null, $name = null ) { $post->post_name = sanitize_title( $post->post_name ? $post->post_name : $post->post_title, $post->ID ); } - // If the user wants to set a new name -- override the current one - // Note: if empty name is supplied -- use the title instead, see #6072 + // If the user wants to set a new name -- override the current one. + // Note: if empty name is supplied -- use the title instead, see #6072. if ( ! is_null( $name ) ) { $post->post_name = sanitize_title( $name ? $name : $title, $post->ID ); } @@ -1356,10 +1359,10 @@ function get_sample_permalink( $id, $title = null, $name = null ) { $permalink = get_permalink( $post, true ); - // Replace custom post_type Token with generic pagename token for ease of use. + // Replace custom post_type token with generic pagename token for ease of use. $permalink = str_replace( "%$post->post_type%", '%pagename%', $permalink ); - // Handle page hierarchy + // Handle page hierarchy. if ( $ptype->hierarchical ) { $uri = get_page_uri( $post ); if ( $uri ) { @@ -1431,13 +1434,13 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { if ( 'publish' === $post->post_status || 'attachment' === $post->post_type ) { $view_link = get_permalink( $post ); } else { - // Allow non-published (private, future) to be viewed at a pretty permalink, in case $post->post_name is set + // Allow non-published (private, future) to be viewed at a pretty permalink, in case $post->post_name is set. $view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, $permalink ); } } } - // Permalinks without a post/page name placeholder don't have anything to edit + // Permalinks without a post/page name placeholder don't have anything to edit. if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) { $return = '' . __( 'Permalink:' ) . "\n"; @@ -1448,7 +1451,7 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { $return .= '' . $permalink . "\n"; } - // Encourage a pretty permalink setting + // Encourage a pretty permalink setting. if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && ! ( 'page' == get_option( 'show_on_front' ) && $id == get_option( 'page_on_front' ) ) ) { $return .= '' . __( 'Change Permalinks' ) . "\n"; } @@ -1692,7 +1695,7 @@ function _admin_notice_post_locked() { $query_args = array(); if ( get_post_type_object( $post->post_type )->public ) { if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) { - // Latest content is in autosave + // Latest content is in autosave. $nonce = wp_create_nonce( 'post_preview_' . $post->ID ); $query_args['preview_id'] = $post->ID; $query_args['preview_nonce'] = $nonce; @@ -1747,7 +1750,7 @@ function _admin_notice_post_locked() { @@ -1819,8 +1822,9 @@ function wp_create_post_autosave( $post_data ) { $new_autosave['ID'] = $old_autosave->ID; $new_autosave['post_author'] = $post_author; + $post = get_post( $post_id ); + // If the new autosave has the same content as the post, delete the autosave. - $post = get_post( $post_id ); $autosave_is_different = false; foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) { if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) { @@ -1849,7 +1853,7 @@ function wp_create_post_autosave( $post_data ) { // _wp_put_post_revision() expects unescaped. $post_data = wp_unslash( $post_data ); - // Otherwise create the new autosave as a special post revision + // Otherwise create the new autosave as a special post revision. return _wp_put_post_revision( $post_data, true ); } @@ -1922,7 +1926,7 @@ function post_preview() { * The ID can be the draft post_id or the autosave revision post_id. */ function wp_autosave( $post_data ) { - // Back-compat + // Back-compat. if ( ! defined( 'DOING_AUTOSAVE' ) ) { define( 'DOING_AUTOSAVE', true ); } @@ -1950,10 +1954,11 @@ function wp_autosave( $post_data ) { } if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) { - // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked + // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked. return edit_post( wp_slash( $post_data ) ); } else { - // Non drafts or other users drafts are not overwritten. The autosave is stored in a special post revision for each user. + // Non-drafts or other users' drafts are not overwritten. + // The autosave is stored in a special post revision for each user. return wp_create_post_autosave( wp_slash( $post_data ) ); } } |
|---|