Docs: Improve comments in some `wp-admin` files per the documentation standards.
Follow-up to [47084]. Props passoniate, apedog. Fixes #49223, #49227. Built from https://develop.svn.wordpress.org/trunk@47119 git-svn-id: http://core.svn.wordpress.org/trunk@46919 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cfb79b15c3
commit
037a736757
|
@ -1,6 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* WordPress Administration Meta Boxes API.
|
||||||
|
*
|
||||||
|
* @package WordPress
|
||||||
|
* @subpackage Administration
|
||||||
|
*/
|
||||||
|
|
||||||
// -- Post related Meta Boxes
|
//
|
||||||
|
// Post-related Meta Boxes.
|
||||||
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays post submit form fields.
|
* Displays post submit form fields.
|
||||||
|
@ -30,7 +38,7 @@ function post_submit_meta_box( $post, $args = array() ) {
|
||||||
|
|
||||||
<div id="minor-publishing">
|
<div id="minor-publishing">
|
||||||
|
|
||||||
<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
|
<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key. ?>
|
||||||
<div style="display:none;">
|
<div style="display:none;">
|
||||||
<?php submit_button( __( 'Save' ), '', 'save' ); ?>
|
<?php submit_button( __( 'Save' ), '', 'save' ); ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -71,7 +79,7 @@ function post_submit_meta_box( $post, $args = array() ) {
|
||||||
<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview-<?php echo (int) $post->ID; ?>" id="post-preview"><?php echo $preview_button; ?></a>
|
<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview-<?php echo (int) $post->ID; ?>" id="post-preview"><?php echo $preview_button; ?></a>
|
||||||
<input type="hidden" name="wp-preview" id="wp-preview" value="" />
|
<input type="hidden" name="wp-preview" id="wp-preview" value="" />
|
||||||
</div>
|
</div>
|
||||||
<?php endif; // public post type ?>
|
<?php endif; // is_post_type_viewable() ?>
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Fires before the post time/date setting in the Publish meta box.
|
* Fires before the post time/date setting in the Publish meta box.
|
||||||
|
@ -202,18 +210,18 @@ function post_submit_meta_box( $post, $args = array() ) {
|
||||||
$time_format = _x( 'H:i', 'publish box time format' );
|
$time_format = _x( 'H:i', 'publish box time format' );
|
||||||
|
|
||||||
if ( 0 != $post->ID ) {
|
if ( 0 != $post->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. */
|
/* translators: Post date information. %s: Date on which the post is currently scheduled to be published. */
|
||||||
$stamp = __( 'Scheduled for: %s' );
|
$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. */
|
/* translators: Post date information. %s: Date on which the post was published. */
|
||||||
$stamp = __( 'Published on: %s' );
|
$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 <b>immediately</b>' );
|
$stamp = __( 'Publish <b>immediately</b>' );
|
||||||
} 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. */
|
/* translators: Post date information. %s: Date on which the post is to be published. */
|
||||||
$stamp = __( 'Schedule for: %s' );
|
$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. */
|
/* translators: Post date information. %s: Date on which the post is to be published. */
|
||||||
$stamp = __( 'Publish on: %s' );
|
$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( $date_format, strtotime( $post->post_date ) ),
|
||||||
date_i18n( $time_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 <b>immediately</b>' );
|
$stamp = __( 'Publish <b>immediately</b>' );
|
||||||
$date = sprintf(
|
$date = sprintf(
|
||||||
$date_string,
|
$date_string,
|
||||||
|
@ -243,7 +251,7 @@ function post_submit_meta_box( $post, $args = array() ) {
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $can_publish ) : // Contributors don't get to choose the date of publish
|
if ( $can_publish ) : // Contributors don't get to choose the date of publish.
|
||||||
?>
|
?>
|
||||||
<div class="misc-pub-section curtime misc-pub-curtime">
|
<div class="misc-pub-section curtime misc-pub-curtime">
|
||||||
<span id="timestamp">
|
<span id="timestamp">
|
||||||
|
@ -371,7 +379,7 @@ function attachment_submit_meta_box( $post ) {
|
||||||
|
|
||||||
<div id="minor-publishing">
|
<div id="minor-publishing">
|
||||||
|
|
||||||
<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
|
<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key. ?>
|
||||||
<div style="display:none;">
|
<div style="display:none;">
|
||||||
<?php submit_button( __( 'Save' ), '', 'save' ); ?>
|
<?php submit_button( __( 'Save' ), '', 'save' ); ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -462,7 +470,7 @@ function post_format_meta_box( $post, $box ) {
|
||||||
if ( ! $post_format ) {
|
if ( ! $post_format ) {
|
||||||
$post_format = '0';
|
$post_format = '0';
|
||||||
}
|
}
|
||||||
// Add in the current one if it isn't there yet, in case the current theme doesn't support it
|
// Add in the current one if it isn't there yet, in case the current theme doesn't support it.
|
||||||
if ( $post_format && ! in_array( $post_format, $post_formats[0] ) ) {
|
if ( $post_format && ! in_array( $post_format, $post_formats[0] ) ) {
|
||||||
$post_formats[0][] = $post_format;
|
$post_formats[0][] = $post_format;
|
||||||
}
|
}
|
||||||
|
@ -591,7 +599,8 @@ function post_categories_meta_box( $post, $box ) {
|
||||||
<div id="<?php echo $tax_name; ?>-all" class="tabs-panel">
|
<div id="<?php echo $tax_name; ?>-all" class="tabs-panel">
|
||||||
<?php
|
<?php
|
||||||
$name = ( $tax_name == 'category' ) ? 'post_category' : 'tax_input[' . $tax_name . ']';
|
$name = ( $tax_name == 'category' ) ? 'post_category' : 'tax_input[' . $tax_name . ']';
|
||||||
echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
|
// Allows for an empty term set to be sent. 0 is an invalid term ID and will be ignored by empty() checks.
|
||||||
|
echo "<input type='hidden' name='{$name}[]' value='0' />";
|
||||||
?>
|
?>
|
||||||
<ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear">
|
<ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear">
|
||||||
<?php
|
<?php
|
||||||
|
@ -903,7 +912,9 @@ function post_revisions_meta_box( $post ) {
|
||||||
wp_list_post_revisions( $post );
|
wp_list_post_revisions( $post );
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- Page related Meta Boxes
|
//
|
||||||
|
// Page-related Meta Boxes.
|
||||||
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display page attributes form fields.
|
* Display page attributes form fields.
|
||||||
|
@ -941,8 +952,8 @@ function page_attributes_meta_box( $post ) {
|
||||||
<p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="parent_id"><?php _e( 'Parent' ); ?></label></p>
|
<p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="parent_id"><?php _e( 'Parent' ); ?></label></p>
|
||||||
<?php echo $pages; ?>
|
<?php echo $pages; ?>
|
||||||
<?php
|
<?php
|
||||||
endif; // end empty pages check
|
endif; // End empty pages check.
|
||||||
endif; // end hierarchical check.
|
endif; // End hierarchical check.
|
||||||
|
|
||||||
if ( count( get_page_templates( $post ) ) > 0 && get_option( 'page_for_posts' ) != $post->ID ) :
|
if ( count( get_page_templates( $post ) ) > 0 && get_option( 'page_for_posts' ) != $post->ID ) :
|
||||||
$template = ! empty( $post->page_template ) ? $post->page_template : false;
|
$template = ! empty( $post->page_template ) ? $post->page_template : false;
|
||||||
|
@ -998,7 +1009,9 @@ function page_attributes_meta_box( $post ) {
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- Link related Meta Boxes
|
//
|
||||||
|
// Link-related Meta Boxes.
|
||||||
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display link create form fields.
|
* Display link create form fields.
|
||||||
|
@ -1013,7 +1026,7 @@ function link_submit_meta_box( $link ) {
|
||||||
|
|
||||||
<div id="minor-publishing">
|
<div id="minor-publishing">
|
||||||
|
|
||||||
<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
|
<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key. ?>
|
||||||
<div style="display:none;">
|
<div style="display:none;">
|
||||||
<?php submit_button( __( 'Save' ), '', 'save', false ); ?>
|
<?php submit_button( __( 'Save' ), '', 'save', false ); ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1163,7 +1176,7 @@ function xfn_check( $class, $value = '', $deprecated = '' ) {
|
||||||
global $link;
|
global $link;
|
||||||
|
|
||||||
if ( ! empty( $deprecated ) ) {
|
if ( ! empty( $deprecated ) ) {
|
||||||
_deprecated_argument( __FUNCTION__, '2.5.0' ); // Never implemented
|
_deprecated_argument( __FUNCTION__, '2.5.0' ); // Never implemented.
|
||||||
}
|
}
|
||||||
|
|
||||||
$link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
|
$link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
|
||||||
|
@ -1413,7 +1426,7 @@ function register_and_do_post_meta_boxes( $post ) {
|
||||||
|
|
||||||
// We should aim to show the revisions meta box only when there are revisions.
|
// We should aim to show the revisions meta box only when there are revisions.
|
||||||
if ( count( $revisions ) > 1 ) {
|
if ( count( $revisions ) > 1 ) {
|
||||||
reset( $revisions ); // Reset pointer for key()
|
reset( $revisions ); // Reset pointer for key().
|
||||||
$publish_callback_args = array(
|
$publish_callback_args = array(
|
||||||
'revisions_count' => count( $revisions ),
|
'revisions_count' => count( $revisions ),
|
||||||
'revision_id' => key( $revisions ),
|
'revision_id' => key( $revisions ),
|
||||||
|
@ -1440,7 +1453,7 @@ function register_and_do_post_meta_boxes( $post ) {
|
||||||
add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) );
|
add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// all taxonomies
|
// All taxonomies.
|
||||||
foreach ( get_object_taxonomies( $post ) as $tax_name ) {
|
foreach ( get_object_taxonomies( $post ) as $tax_name ) {
|
||||||
$taxonomy = get_taxonomy( $tax_name );
|
$taxonomy = get_taxonomy( $tax_name );
|
||||||
if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) {
|
if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) {
|
||||||
|
@ -1523,8 +1536,8 @@ function register_and_do_post_meta_boxes( $post ) {
|
||||||
$stati[] = 'private';
|
$stati[] = 'private';
|
||||||
|
|
||||||
if ( in_array( get_post_status( $post ), $stati ) ) {
|
if ( in_array( get_post_status( $post ), $stati ) ) {
|
||||||
// If the post type support comments, or the post has comments, allow the
|
// If the post type support comments, or the post has comments,
|
||||||
// Comments meta box.
|
// allow the Comments meta box.
|
||||||
if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) {
|
if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) {
|
||||||
add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
|
add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ Any changes to the directives between these markers will be overwritten.'
|
||||||
$lines[] = rtrim( fgets( $fp ), "\r\n" );
|
$lines[] = rtrim( fgets( $fp ), "\r\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split out the existing file into the preceding lines, and those that appear after the marker
|
// Split out the existing file into the preceding lines, and those that appear after the marker.
|
||||||
$pre_lines = array();
|
$pre_lines = array();
|
||||||
$post_lines = array();
|
$post_lines = array();
|
||||||
$existing_lines = array();
|
$existing_lines = array();
|
||||||
|
@ -201,7 +201,7 @@ Any changes to the directives between these markers will be overwritten.'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check to see if there was a change
|
// Check to see if there was a change.
|
||||||
if ( $existing_lines === $insertion ) {
|
if ( $existing_lines === $insertion ) {
|
||||||
flock( $fp, LOCK_UN );
|
flock( $fp, LOCK_UN );
|
||||||
fclose( $fp );
|
fclose( $fp );
|
||||||
|
@ -209,7 +209,7 @@ Any changes to the directives between these markers will be overwritten.'
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the new file data
|
// Generate the new file data.
|
||||||
$new_file_data = implode(
|
$new_file_data = implode(
|
||||||
"\n",
|
"\n",
|
||||||
array_merge(
|
array_merge(
|
||||||
|
@ -221,7 +221,7 @@ Any changes to the directives between these markers will be overwritten.'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Write to the start of the file, and truncate it to that length
|
// Write to the start of the file, and truncate it to that length.
|
||||||
fseek( $fp, 0 );
|
fseek( $fp, 0 );
|
||||||
$bytes = fwrite( $fp, $new_file_data );
|
$bytes = fwrite( $fp, $new_file_data );
|
||||||
if ( $bytes ) {
|
if ( $bytes ) {
|
||||||
|
@ -296,7 +296,7 @@ function iis7_save_url_rewrite_rules() {
|
||||||
$home_path = get_home_path();
|
$home_path = get_home_path();
|
||||||
$web_config_file = $home_path . 'web.config';
|
$web_config_file = $home_path . 'web.config';
|
||||||
|
|
||||||
// Using win_is_writable() instead of is_writable() because of a bug in Windows PHP
|
// Using win_is_writable() instead of is_writable() because of a bug in Windows PHP.
|
||||||
if ( iis7_supports_permalinks() && ( ( ! file_exists( $web_config_file ) && win_is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable( $web_config_file ) ) ) {
|
if ( iis7_supports_permalinks() && ( ( ! file_exists( $web_config_file ) && win_is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable( $web_config_file ) ) ) {
|
||||||
$rule = $wp_rewrite->iis7_url_rewrite_rules( false );
|
$rule = $wp_rewrite->iis7_url_rewrite_rules( false );
|
||||||
if ( ! empty( $rule ) ) {
|
if ( ! empty( $rule ) ) {
|
||||||
|
@ -598,11 +598,11 @@ function wp_doc_link_parse( $content ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( T_STRING == $tokens[ $t ][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) {
|
if ( T_STRING == $tokens[ $t ][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) {
|
||||||
// If it's a function or class defined locally, there's not going to be any docs available
|
// If it's a function or class defined locally, there's not going to be any docs available.
|
||||||
if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) {
|
if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) {
|
||||||
$ignore_functions[] = $tokens[ $t ][1];
|
$ignore_functions[] = $tokens[ $t ][1];
|
||||||
}
|
}
|
||||||
// Add this to our stack of unique references
|
// Add this to our stack of unique references.
|
||||||
$functions[] = $tokens[ $t ][1];
|
$functions[] = $tokens[ $t ][1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -673,7 +673,7 @@ function set_screen_options() {
|
||||||
case 'plugins_per_page':
|
case 'plugins_per_page':
|
||||||
case 'export_personal_data_requests_per_page':
|
case 'export_personal_data_requests_per_page':
|
||||||
case 'remove_personal_data_requests_per_page':
|
case 'remove_personal_data_requests_per_page':
|
||||||
// Network admin
|
// Network admin.
|
||||||
case 'sites_network_per_page':
|
case 'sites_network_per_page':
|
||||||
case 'users_network_per_page':
|
case 'users_network_per_page':
|
||||||
case 'site_users_network_per_page':
|
case 'site_users_network_per_page':
|
||||||
|
@ -760,7 +760,7 @@ function iis7_rewrite_rule_exists( $filename ) {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function iis7_delete_rewrite_rule( $filename ) {
|
function iis7_delete_rewrite_rule( $filename ) {
|
||||||
// If configuration file does not exist then rules also do not exist so there is nothing to delete
|
// If configuration file does not exist then rules also do not exist, so there is nothing to delete.
|
||||||
if ( ! file_exists( $filename ) ) {
|
if ( ! file_exists( $filename ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -817,13 +817,13 @@ function iis7_add_rewrite_rule( $filename, $rewrite_rule ) {
|
||||||
|
|
||||||
$xpath = new DOMXPath( $doc );
|
$xpath = new DOMXPath( $doc );
|
||||||
|
|
||||||
// First check if the rule already exists as in that case there is no need to re-add it
|
// First check if the rule already exists as in that case there is no need to re-add it.
|
||||||
$wordpress_rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
|
$wordpress_rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
|
||||||
if ( $wordpress_rules->length > 0 ) {
|
if ( $wordpress_rules->length > 0 ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the XPath to the rewrite rule and create XML nodes if they do not exist
|
// Check the XPath to the rewrite rule and create XML nodes if they do not exist.
|
||||||
$xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite/rules' );
|
$xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite/rules' );
|
||||||
if ( $xmlnodes->length > 0 ) {
|
if ( $xmlnodes->length > 0 ) {
|
||||||
$rules_node = $xmlnodes->item( 0 );
|
$rules_node = $xmlnodes->item( 0 );
|
||||||
|
|
|
@ -7,38 +7,38 @@
|
||||||
* @since 4.3.0
|
* @since 4.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Media Hooks.
|
// Media hooks.
|
||||||
add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' );
|
add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' );
|
||||||
|
|
||||||
// User Hooks
|
// User hooks.
|
||||||
add_action( 'user_admin_notices', 'new_user_email_admin_notice' );
|
add_action( 'user_admin_notices', 'new_user_email_admin_notice' );
|
||||||
add_action( 'network_admin_notices', 'new_user_email_admin_notice' );
|
add_action( 'network_admin_notices', 'new_user_email_admin_notice' );
|
||||||
|
|
||||||
add_action( 'admin_page_access_denied', '_access_denied_splash', 99 );
|
add_action( 'admin_page_access_denied', '_access_denied_splash', 99 );
|
||||||
|
|
||||||
// Site Hooks.
|
// Site hooks.
|
||||||
add_action( 'wpmueditblogaction', 'upload_space_setting' );
|
add_action( 'wpmueditblogaction', 'upload_space_setting' );
|
||||||
|
|
||||||
// Network hooks
|
// Network hooks.
|
||||||
add_action( 'update_site_option_admin_email', 'wp_network_admin_email_change_notification', 10, 4 );
|
add_action( 'update_site_option_admin_email', 'wp_network_admin_email_change_notification', 10, 4 );
|
||||||
|
|
||||||
// Taxonomy Hooks
|
// Taxonomy hooks.
|
||||||
add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
|
add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
|
||||||
|
|
||||||
// Post Hooks.
|
// Post hooks.
|
||||||
add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 );
|
add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 );
|
||||||
|
|
||||||
// Tools Hooks.
|
// Tools hooks.
|
||||||
add_filter( 'import_allow_create_users', 'check_import_new_users' );
|
add_filter( 'import_allow_create_users', 'check_import_new_users' );
|
||||||
|
|
||||||
// Notices Hooks
|
// Notices hooks.
|
||||||
add_action( 'admin_notices', 'site_admin_notice' );
|
add_action( 'admin_notices', 'site_admin_notice' );
|
||||||
add_action( 'network_admin_notices', 'site_admin_notice' );
|
add_action( 'network_admin_notices', 'site_admin_notice' );
|
||||||
|
|
||||||
// Update Hooks
|
// Update hooks.
|
||||||
add_action( 'network_admin_notices', 'update_nag', 3 );
|
add_action( 'network_admin_notices', 'update_nag', 3 );
|
||||||
add_action( 'network_admin_notices', 'maintenance_nag', 10 );
|
add_action( 'network_admin_notices', 'maintenance_nag', 10 );
|
||||||
|
|
||||||
// Network Admin Hooks
|
// Network Admin hooks.
|
||||||
add_action( 'add_site_option_new_admin_email', 'update_network_option_new_admin_email', 10, 2 );
|
add_action( 'add_site_option_new_admin_email', 'update_network_option_new_admin_email', 10, 2 );
|
||||||
add_action( 'update_site_option_new_admin_email', 'update_network_option_new_admin_email', 10, 2 );
|
add_action( 'update_site_option_new_admin_email', 'update_network_option_new_admin_email', 10, 2 );
|
||||||
|
|
|
@ -20,7 +20,7 @@ function check_upload_size( $file ) {
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $file['error'] != '0' ) { // there's already an error
|
if ( $file['error'] != '0' ) { // There's already an error.
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ function wpmu_delete_user( $id ) {
|
||||||
wp_delete_post( $post_id );
|
wp_delete_post( $post_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean links
|
// Clean links.
|
||||||
$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
|
$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
|
||||||
|
|
||||||
if ( $link_ids ) {
|
if ( $link_ids ) {
|
||||||
|
@ -220,7 +220,7 @@ function upload_is_user_over_quota( $echo = true ) {
|
||||||
|
|
||||||
$space_allowed = get_space_allowed();
|
$space_allowed = get_space_allowed();
|
||||||
if ( ! is_numeric( $space_allowed ) ) {
|
if ( ! is_numeric( $space_allowed ) ) {
|
||||||
$space_allowed = 10; // Default space allowed is 10 MB
|
$space_allowed = 10; // Default space allowed is 10 MB.
|
||||||
}
|
}
|
||||||
$space_used = get_space_used();
|
$space_used = get_space_used();
|
||||||
|
|
||||||
|
@ -644,11 +644,11 @@ function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
|
||||||
foreach ( (array) $lang_files as $val ) {
|
foreach ( (array) $lang_files as $val ) {
|
||||||
$code_lang = basename( $val, '.mo' );
|
$code_lang = basename( $val, '.mo' );
|
||||||
|
|
||||||
if ( $code_lang == 'en_US' ) { // American English
|
if ( $code_lang == 'en_US' ) { // American English.
|
||||||
$flag = true;
|
$flag = true;
|
||||||
$ae = __( 'American English' );
|
$ae = __( 'American English' );
|
||||||
$output[ $ae ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>';
|
$output[ $ae ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>';
|
||||||
} elseif ( $code_lang == 'en_GB' ) { // British English
|
} elseif ( $code_lang == 'en_GB' ) { // British English.
|
||||||
$flag = true;
|
$flag = true;
|
||||||
$be = __( 'British English' );
|
$be = __( 'British English' );
|
||||||
$output[ $be ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $be . '</option>';
|
$output[ $be ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $be . '</option>';
|
||||||
|
@ -658,11 +658,11 @@ function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $flag === false ) { // WordPress english
|
if ( $flag === false ) { // WordPress English.
|
||||||
$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . '</option>';
|
$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . '</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Order by name
|
// Order by name.
|
||||||
uksort( $output, 'strnatcasecmp' );
|
uksort( $output, 'strnatcasecmp' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1067,7 +1067,7 @@ function network_edit_site_nav( $args = array() ) {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Parse arguments
|
// Parse arguments.
|
||||||
$parsed_args = wp_parse_args(
|
$parsed_args = wp_parse_args(
|
||||||
$args,
|
$args,
|
||||||
array(
|
array(
|
||||||
|
@ -1077,36 +1077,36 @@ function network_edit_site_nav( $args = array() ) {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Setup the links array
|
// Setup the links array.
|
||||||
$screen_links = array();
|
$screen_links = array();
|
||||||
|
|
||||||
// Loop through tabs
|
// Loop through tabs.
|
||||||
foreach ( $parsed_args['links'] as $link_id => $link ) {
|
foreach ( $parsed_args['links'] as $link_id => $link ) {
|
||||||
|
|
||||||
// Skip link if user can't access
|
// Skip link if user can't access.
|
||||||
if ( ! current_user_can( $link['cap'], $parsed_args['blog_id'] ) ) {
|
if ( ! current_user_can( $link['cap'], $parsed_args['blog_id'] ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link classes
|
// Link classes.
|
||||||
$classes = array( 'nav-tab' );
|
$classes = array( 'nav-tab' );
|
||||||
|
|
||||||
// Aria-current attribute.
|
// Aria-current attribute.
|
||||||
$aria_current = '';
|
$aria_current = '';
|
||||||
|
|
||||||
// Selected is set by the parent OR assumed by the $pagenow global
|
// Selected is set by the parent OR assumed by the $pagenow global.
|
||||||
if ( $parsed_args['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) {
|
if ( $parsed_args['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) {
|
||||||
$classes[] = 'nav-tab-active';
|
$classes[] = 'nav-tab-active';
|
||||||
$aria_current = ' aria-current="page"';
|
$aria_current = ' aria-current="page"';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escape each class
|
// Escape each class.
|
||||||
$esc_classes = implode( ' ', $classes );
|
$esc_classes = implode( ' ', $classes );
|
||||||
|
|
||||||
// Get the URL for this link
|
// Get the URL for this link.
|
||||||
$url = add_query_arg( array( 'id' => $parsed_args['blog_id'] ), network_admin_url( $link['url'] ) );
|
$url = add_query_arg( array( 'id' => $parsed_args['blog_id'] ), network_admin_url( $link['url'] ) );
|
||||||
|
|
||||||
// Add link to nav links
|
// Add link to nav links.
|
||||||
$screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '"' . $aria_current . '>' . esc_html( $link['label'] ) . '</a>';
|
$screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '"' . $aria_current . '>' . esc_html( $link['label'] ) . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,12 +138,12 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
function wp_nav_menu_setup() {
|
function wp_nav_menu_setup() {
|
||||||
// Register meta boxes
|
// Register meta boxes.
|
||||||
wp_nav_menu_post_type_meta_boxes();
|
wp_nav_menu_post_type_meta_boxes();
|
||||||
add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
|
add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
|
||||||
wp_nav_menu_taxonomy_meta_boxes();
|
wp_nav_menu_taxonomy_meta_boxes();
|
||||||
|
|
||||||
// Register advanced menu items (columns)
|
// Register advanced menu items (columns).
|
||||||
add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' );
|
add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' );
|
||||||
|
|
||||||
// If first time editing, disable advanced items by default.
|
// If first time editing, disable advanced items by default.
|
||||||
|
@ -422,7 +422,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo transient caching of these results with proper invalidation on updating of a post of this type
|
// @todo Transient caching of these results with proper invalidation on updating of a post of this type.
|
||||||
$get_posts = new WP_Query;
|
$get_posts = new WP_Query;
|
||||||
$posts = $get_posts->query( $args );
|
$posts = $get_posts->query( $args );
|
||||||
|
|
||||||
|
@ -921,7 +921,8 @@ function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
|
||||||
! isset( $_item_object_data['menu-item-type'] ) ||
|
! isset( $_item_object_data['menu-item-type'] ) ||
|
||||||
// Or URL is the default.
|
// Or URL is the default.
|
||||||
in_array( $_item_object_data['menu-item-url'], array( 'https://', 'http://', '' ) ) ||
|
in_array( $_item_object_data['menu-item-url'], array( 'https://', 'http://', '' ) ) ||
|
||||||
! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // or it's not a custom menu item (but not the custom home page)
|
// Or it's not a custom menu item (but not the custom home page).
|
||||||
|
! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) ||
|
||||||
// Or it *is* a custom menu item that already exists.
|
// Or it *is* a custom menu item that already exists.
|
||||||
! empty( $_item_object_data['menu-item-db-id'] )
|
! empty( $_item_object_data['menu-item-db-id'] )
|
||||||
)
|
)
|
||||||
|
@ -1142,7 +1143,7 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
|
||||||
);
|
);
|
||||||
$messages = array();
|
$messages = array();
|
||||||
$menu_items = array();
|
$menu_items = array();
|
||||||
// Index menu items by db ID
|
// Index menu items by DB ID.
|
||||||
foreach ( $unsorted_menu_items as $_item ) {
|
foreach ( $unsorted_menu_items as $_item ) {
|
||||||
$menu_items[ $_item->db_id ] = $_item;
|
$menu_items[ $_item->db_id ] = $_item;
|
||||||
}
|
}
|
||||||
|
@ -1164,11 +1165,11 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_defer_term_counting( true );
|
wp_defer_term_counting( true );
|
||||||
// Loop through all the menu items' POST variables
|
// Loop through all the menu items' POST variables.
|
||||||
if ( ! empty( $_POST['menu-item-db-id'] ) ) {
|
if ( ! empty( $_POST['menu-item-db-id'] ) ) {
|
||||||
foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
|
foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
|
||||||
|
|
||||||
// Menu item title can't be blank
|
// Menu item title can't be blank.
|
||||||
if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) {
|
if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1188,7 +1189,7 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove menu items from the menu that weren't in $_POST
|
// Remove menu items from the menu that weren't in $_POST.
|
||||||
if ( ! empty( $menu_items ) ) {
|
if ( ! empty( $menu_items ) ) {
|
||||||
foreach ( array_keys( $menu_items ) as $menu_item_id ) {
|
foreach ( array_keys( $menu_items ) as $menu_item_id ) {
|
||||||
if ( is_nav_menu_item( $menu_item_id ) ) {
|
if ( is_nav_menu_item( $menu_item_id ) ) {
|
||||||
|
@ -1213,7 +1214,7 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
|
||||||
unset( $nav_menu_option['auto_add'][ $key ] );
|
unset( $nav_menu_option['auto_add'][ $key ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Remove nonexistent/deleted menus
|
// Remove non-existent/deleted menus.
|
||||||
$nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) );
|
$nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) );
|
||||||
update_option( 'nav_menu_options', $nav_menu_option );
|
update_option( 'nav_menu_options', $nav_menu_option );
|
||||||
|
|
||||||
|
@ -1252,7 +1253,7 @@ function _wp_expand_nav_menu_post_data() {
|
||||||
if ( ! is_null( $data ) && $data ) {
|
if ( ! is_null( $data ) && $data ) {
|
||||||
foreach ( $data as $post_input_data ) {
|
foreach ( $data as $post_input_data ) {
|
||||||
// For input names that are arrays (e.g. `menu-item-db-id[3][4][5]`),
|
// For input names that are arrays (e.g. `menu-item-db-id[3][4][5]`),
|
||||||
// derive the array path keys via regex and set the value in $_POST.
|
// derive the array path keys via regex and set the value in $_POST.
|
||||||
preg_match( '#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches );
|
preg_match( '#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches );
|
||||||
|
|
||||||
$array_bits = array( $matches[1] );
|
$array_bits = array( $matches[1] );
|
||||||
|
|
|
@ -181,14 +181,14 @@ function network_step1( $errors = false ) {
|
||||||
|
|
||||||
if ( isset( $_POST['subdomain_install'] ) ) {
|
if ( isset( $_POST['subdomain_install'] ) ) {
|
||||||
$subdomain_install = (bool) $_POST['subdomain_install'];
|
$subdomain_install = (bool) $_POST['subdomain_install'];
|
||||||
} elseif ( apache_mod_loaded( 'mod_rewrite' ) ) { // assume nothing
|
} elseif ( apache_mod_loaded( 'mod_rewrite' ) ) { // Assume nothing.
|
||||||
$subdomain_install = true;
|
$subdomain_install = true;
|
||||||
} elseif ( ! allow_subdirectory_install() ) {
|
} elseif ( ! allow_subdirectory_install() ) {
|
||||||
$subdomain_install = true;
|
$subdomain_install = true;
|
||||||
} else {
|
} else {
|
||||||
$subdomain_install = false;
|
$subdomain_install = false;
|
||||||
$got_mod_rewrite = got_mod_rewrite();
|
$got_mod_rewrite = got_mod_rewrite();
|
||||||
if ( $got_mod_rewrite ) { // dangerous assumptions
|
if ( $got_mod_rewrite ) { // Dangerous assumptions.
|
||||||
echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ';
|
echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ';
|
||||||
printf(
|
printf(
|
||||||
/* translators: %s: mod_rewrite */
|
/* translators: %s: mod_rewrite */
|
||||||
|
@ -206,7 +206,7 @@ function network_step1( $errors = false ) {
|
||||||
echo '</p>';
|
echo '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
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 '<p>';
|
echo '<p>';
|
||||||
printf(
|
printf(
|
||||||
/* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite. */
|
/* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite. */
|
||||||
|
@ -225,7 +225,7 @@ function network_step1( $errors = false ) {
|
||||||
<p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories.' ); ?>
|
<p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories.' ); ?>
|
||||||
<strong><?php _e( 'You cannot change this later.' ); ?></strong></p>
|
<strong><?php _e( 'You cannot change this later.' ); ?></strong></p>
|
||||||
<p><?php _e( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?></p>
|
<p><?php _e( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?></p>
|
||||||
<?php // @todo: Link to an MS readme? ?>
|
<?php // @todo Link to an MS readme? ?>
|
||||||
<table class="form-table" role="presentation">
|
<table class="form-table" role="presentation">
|
||||||
<tr>
|
<tr>
|
||||||
<th><label><input type="radio" name="subdomain_install" value="1"<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
|
<th><label><input type="radio" name="subdomain_install" value="1"<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
|
||||||
|
@ -547,7 +547,7 @@ define('BLOG_ID_CURRENT_SITE', 1);
|
||||||
</li>
|
</li>
|
||||||
<?php
|
<?php
|
||||||
if ( iis7_supports_permalinks() ) :
|
if ( iis7_supports_permalinks() ) :
|
||||||
// IIS doesn't support RewriteBase, all your RewriteBase are belong to us
|
// IIS doesn't support RewriteBase, all your RewriteBase are belong to us.
|
||||||
$iis_subdir_match = ltrim( $base, '/' ) . $subdir_match;
|
$iis_subdir_match = ltrim( $base, '/' ) . $subdir_match;
|
||||||
$iis_rewrite_base = ltrim( $base, '/' ) . $rewrite_base;
|
$iis_rewrite_base = ltrim( $base, '/' ) . $rewrite_base;
|
||||||
$iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
|
$iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
|
||||||
|
@ -616,7 +616,7 @@ define('BLOG_ID_CURRENT_SITE', 1);
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
else : // end iis7_supports_permalinks(). construct an htaccess file instead:
|
else : // End iis7_supports_permalinks(). Construct an .htaccess file instead:
|
||||||
|
|
||||||
$ms_files_rewriting = '';
|
$ms_files_rewriting = '';
|
||||||
if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
|
if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
|
||||||
|
@ -658,7 +658,7 @@ EOF;
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
endif; // end IIS/Apache code branches.
|
endif; // End IIS/Apache code branches.
|
||||||
|
|
||||||
if ( ! is_multisite() ) {
|
if ( ! is_multisite() ) {
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -100,7 +100,7 @@
|
||||||
* for more information on the make-up of possible return values depending on the value of `$action`.
|
* for more information on the make-up of possible return values depending on the value of `$action`.
|
||||||
*/
|
*/
|
||||||
function plugins_api( $action, $args = array() ) {
|
function plugins_api( $action, $args = array() ) {
|
||||||
// include an unmodified $wp_version
|
// Include an unmodified $wp_version.
|
||||||
include( ABSPATH . WPINC . '/version.php' );
|
include( ABSPATH . WPINC . '/version.php' );
|
||||||
|
|
||||||
if ( is_array( $args ) ) {
|
if ( is_array( $args ) ) {
|
||||||
|
@ -118,7 +118,7 @@ function plugins_api( $action, $args = array() ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! isset( $args->wp_version ) ) {
|
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 ) ) {
|
if ( is_wp_error( $api_tags ) ) {
|
||||||
echo $api_tags->get_error_message();
|
echo $api_tags->get_error_message();
|
||||||
} else {
|
} 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();
|
$tags = array();
|
||||||
foreach ( (array) $api_tags as $tag ) {
|
foreach ( (array) $api_tags as $tag ) {
|
||||||
$url = self_admin_url( 'plugin-install.php?tab=search&type=tag&s=' . urlencode( $tag['name'] ) );
|
$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;
|
$api = (object) $api;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default to a "new" plugin
|
// Default to a "new" plugin.
|
||||||
$status = 'install';
|
$status = 'install';
|
||||||
$url = false;
|
$url = false;
|
||||||
$update_file = false;
|
$update_file = false;
|
||||||
|
@ -471,7 +471,10 @@ function install_plugin_install_status( $api, $loop = false ) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$key = array_keys( $installed_plugin );
|
$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
|
// 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;
|
$update_file = $api->slug . '/' . $key;
|
||||||
if ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '=' ) ) {
|
if ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '=' ) ) {
|
||||||
$status = 'latest_installed';
|
$status = 'latest_installed';
|
||||||
|
@ -479,7 +482,7 @@ function install_plugin_install_status( $api, $loop = false ) {
|
||||||
$status = 'newer_installed';
|
$status = 'newer_installed';
|
||||||
$version = $installed_plugin[ $key ]['Version'];
|
$version = $installed_plugin[ $key ]['Version'];
|
||||||
} else {
|
} 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 ) {
|
if ( ! $loop ) {
|
||||||
delete_site_transient( 'update_plugins' );
|
delete_site_transient( 'update_plugins' );
|
||||||
wp_update_plugins();
|
wp_update_plugins();
|
||||||
|
@ -488,7 +491,7 @@ function install_plugin_install_status( $api, $loop = false ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// "install" & no directory with that slug
|
// "install" & no directory with that slug.
|
||||||
if ( current_user_can( 'install_plugins' ) ) {
|
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 );
|
$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' ),
|
'other_notes' => _x( 'Other Notes', 'Plugin installer section title' ),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Sanitize HTML
|
// Sanitize HTML.
|
||||||
foreach ( (array) $api->sections as $section_name => $content ) {
|
foreach ( (array) $api->sections as $section_name => $content ) {
|
||||||
$api->sections[ $section_name ] = wp_kses( $content, $plugins_allowedtags );
|
$api->sections[ $section_name ] = wp_kses( $content, $plugins_allowedtags );
|
||||||
}
|
}
|
||||||
|
@ -583,7 +586,8 @@ function install_plugin_information() {
|
||||||
|
|
||||||
$_tab = esc_attr( $tab );
|
$_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 ] ) ) {
|
if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) {
|
||||||
$section_titles = array_keys( (array) $api->sections );
|
$section_titles = array_keys( (array) $api->sections );
|
||||||
$section = reset( $section_titles );
|
$section = reset( $section_titles );
|
||||||
|
|
|
@ -331,7 +331,8 @@ function get_plugins( $plugin_folder = '' ) {
|
||||||
continue;
|
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'] ) ) {
|
if ( empty( $plugin_data['Name'] ) ) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -358,12 +359,13 @@ function get_plugins( $plugin_folder = '' ) {
|
||||||
*/
|
*/
|
||||||
function get_mu_plugins() {
|
function get_mu_plugins() {
|
||||||
$wp_plugins = array();
|
$wp_plugins = array();
|
||||||
// Files in wp-content/mu-plugins directory.
|
|
||||||
$plugin_files = array();
|
$plugin_files = array();
|
||||||
|
|
||||||
if ( ! is_dir( WPMU_PLUGIN_DIR ) ) {
|
if ( ! is_dir( WPMU_PLUGIN_DIR ) ) {
|
||||||
return $wp_plugins;
|
return $wp_plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Files in wp-content/mu-plugins directory.
|
||||||
$plugins_dir = @opendir( WPMU_PLUGIN_DIR );
|
$plugins_dir = @opendir( WPMU_PLUGIN_DIR );
|
||||||
if ( $plugins_dir ) {
|
if ( $plugins_dir ) {
|
||||||
while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
|
while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
|
||||||
|
@ -386,7 +388,8 @@ function get_mu_plugins() {
|
||||||
continue;
|
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'] ) ) {
|
if ( empty( $plugin_data['Name'] ) ) {
|
||||||
$plugin_data['Name'] = $plugin_file;
|
$plugin_data['Name'] = $plugin_file;
|
||||||
|
@ -395,7 +398,8 @@ function get_mu_plugins() {
|
||||||
$wp_plugins[ $plugin_file ] = $plugin_data;
|
$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'] );
|
unset( $wp_plugins['index.php'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +435,7 @@ function get_dropins() {
|
||||||
|
|
||||||
$_dropins = _get_dropins();
|
$_dropins = _get_dropins();
|
||||||
|
|
||||||
// These exist in the wp-content directory.
|
// Files in wp-content directory.
|
||||||
$plugins_dir = @opendir( WP_CONTENT_DIR );
|
$plugins_dir = @opendir( WP_CONTENT_DIR );
|
||||||
if ( $plugins_dir ) {
|
if ( $plugins_dir ) {
|
||||||
while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
|
while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
|
||||||
|
@ -453,10 +457,14 @@ function get_dropins() {
|
||||||
if ( ! is_readable( WP_CONTENT_DIR . "/$plugin_file" ) ) {
|
if ( ! is_readable( WP_CONTENT_DIR . "/$plugin_file" ) ) {
|
||||||
continue;
|
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'] ) ) {
|
if ( empty( $plugin_data['Name'] ) ) {
|
||||||
$plugin_data['Name'] = $plugin_file;
|
$plugin_data['Name'] = $plugin_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dropins[ $plugin_file ] = $plugin_data;
|
$dropins[ $plugin_file ] = $plugin_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,20 +486,20 @@ function get_dropins() {
|
||||||
function _get_dropins() {
|
function _get_dropins() {
|
||||||
$dropins = array(
|
$dropins = array(
|
||||||
'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE
|
'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE
|
||||||
'db.php' => array( __( 'Custom database class.' ), true ), // auto on load
|
'db.php' => array( __( 'Custom database class.' ), true ), // Auto on load.
|
||||||
'db-error.php' => array( __( 'Custom database error message.' ), true ), // auto on error
|
'db-error.php' => array( __( 'Custom database error message.' ), true ), // Auto on error.
|
||||||
'install.php' => array( __( 'Custom installation script.' ), true ), // auto on installation
|
'install.php' => array( __( 'Custom installation script.' ), true ), // Auto on installation.
|
||||||
'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // auto on maintenance
|
'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // Auto on maintenance.
|
||||||
'object-cache.php' => array( __( 'External object cache.' ), true ), // auto on load
|
'object-cache.php' => array( __( 'External object cache.' ), true ), // Auto on load.
|
||||||
'php-error.php' => array( __( 'Custom PHP error message.' ), true ), // auto on error
|
'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
|
'fatal-error-handler.php' => array( __( 'Custom PHP fatal error handler.' ), true ), // Auto on error.
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( is_multisite() ) {
|
if ( is_multisite() ) {
|
||||||
$dropins['sunrise.php'] = array( __( 'Executed before Multisite is loaded.' ), 'SUNRISE' ); // SUNRISE
|
$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-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-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-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // Auto on archived or spammed blog.
|
||||||
}
|
}
|
||||||
|
|
||||||
return $dropins;
|
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 ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current ) ) ) {
|
||||||
if ( ! empty( $redirect ) ) {
|
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();
|
ob_start();
|
||||||
|
@ -908,7 +917,8 @@ function delete_plugins( $plugins, $deprecated = '' ) {
|
||||||
|
|
||||||
if ( ! WP_Filesystem( $credentials ) ) {
|
if ( ! WP_Filesystem( $credentials ) ) {
|
||||||
ob_start();
|
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();
|
$data = ob_get_clean();
|
||||||
|
|
||||||
if ( ! empty( $data ) ) {
|
if ( ! empty( $data ) ) {
|
||||||
|
@ -958,7 +968,8 @@ function delete_plugins( $plugins, $deprecated = '' ) {
|
||||||
$this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) );
|
$this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) );
|
||||||
|
|
||||||
// If plugin is in its own directory, recursively delete the directory.
|
// 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 );
|
$deleted = $wp_filesystem->delete( $this_plugin_dir, true );
|
||||||
} else {
|
} else {
|
||||||
$deleted = $wp_filesystem->delete( $plugins_dir . $plugin_file );
|
$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;
|
$_registered_pages[ $hookname ] = true;
|
||||||
|
|
||||||
// No parent as top level
|
// No parent as top level.
|
||||||
$_parent_pages[ $menu_slug ] = false;
|
$_parent_pages[ $menu_slug ] = false;
|
||||||
|
|
||||||
return $hookname;
|
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 ] );
|
ksort( $submenu[ $parent_slug ] );
|
||||||
|
|
||||||
$hookname = get_plugin_page_hookname( $menu_slug, $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.
|
* Gets the parent file of the current admin page.
|
||||||
|
@ -1932,7 +1943,7 @@ function get_admin_page_title() {
|
||||||
return $submenu_array[3];
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
|
||||||
if ( ! empty( $post_data['post_status'] ) ) {
|
if ( ! empty( $post_data['post_status'] ) ) {
|
||||||
$post_data['post_status'] = sanitize_key( $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'] ) {
|
if ( 'auto-draft' === $post_data['post_status'] ) {
|
||||||
$post_data['post_status'] = 'draft';
|
$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'] ) {
|
if ( isset( $post_data['saveasdraft'] ) && '' != $post_data['saveasdraft'] ) {
|
||||||
$post_data['post_status'] = 'draft';
|
$post_data['post_status'] = 'draft';
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
|
||||||
|
|
||||||
$published_statuses = array( 'publish', 'future' );
|
$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.
|
// 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 ( 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 ) ) {
|
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;
|
$post_data = $_POST;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass through errors
|
// Pass through errors.
|
||||||
if ( is_wp_error( $post_data ) ) {
|
if ( is_wp_error( $post_data ) ) {
|
||||||
return $post_data;
|
return $post_data;
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ function edit_post( $post_data = null ) {
|
||||||
);
|
);
|
||||||
$revision = current( $revisions );
|
$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 ) {
|
if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) {
|
||||||
_wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) );
|
_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 );
|
$translated = _wp_get_allowed_postdata( $post_data );
|
||||||
|
|
||||||
// Post Formats
|
// Post formats.
|
||||||
if ( isset( $post_data['post_format'] ) ) {
|
if ( isset( $post_data['post_format'] ) ) {
|
||||||
set_post_format( $post_ID, $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 );
|
wp_update_attachment_metadata( $post_ID, $id3data );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Meta Stuff
|
// Meta stuff.
|
||||||
if ( isset( $post_data['meta'] ) && $post_data['meta'] ) {
|
if ( isset( $post_data['meta'] ) && $post_data['meta'] ) {
|
||||||
foreach ( $post_data['meta'] as $key => $value ) {
|
foreach ( $post_data['meta'] as $key => $value ) {
|
||||||
$meta = get_post_meta_by_id( $key );
|
$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 ( 'attachment' == $post_data['post_type'] ) {
|
||||||
if ( isset( $post_data['_wp_attachment_image_alt'] ) ) {
|
if ( isset( $post_data['_wp_attachment_image_alt'] ) ) {
|
||||||
$image_alt = wp_unslash( $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 ) ) {
|
if ( $image_alt != get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) ) {
|
||||||
$image_alt = wp_strip_all_tags( $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 ) );
|
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() );
|
update_post_meta( $post_ID, '_edit_last', get_current_user_id() );
|
||||||
|
|
||||||
$success = wp_update_post( $translated );
|
$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' ) ) ) {
|
if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) {
|
||||||
$fields = array( 'post_title', 'post_content', 'post_excerpt' );
|
$fields = array( 'post_title', 'post_content', 'post_excerpt' );
|
||||||
|
|
||||||
|
@ -418,7 +421,7 @@ function edit_post( $post_data = null ) {
|
||||||
wp_update_post( $translated );
|
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 );
|
_fix_attachment_links( $post_ID );
|
||||||
|
|
||||||
wp_set_post_lock( $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' ) );
|
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' ) ) {
|
if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) {
|
||||||
wp_schedule_event( time(), 'daily', '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.
|
// Clear out any data in internal vars.
|
||||||
unset( $_POST['filter'] );
|
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'] ) ) {
|
if ( isset( $_POST['post_ID'] ) ) {
|
||||||
return edit_post();
|
return edit_post();
|
||||||
}
|
}
|
||||||
|
@ -857,7 +860,7 @@ function wp_write_post() {
|
||||||
|
|
||||||
add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
|
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 );
|
_fix_attachment_links( $post_ID );
|
||||||
|
|
||||||
wp_set_post_lock( $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 ) {
|
if ( $metakeyinput ) {
|
||||||
$metakey = $metakeyinput; // default
|
$metakey = $metakeyinput; // Default.
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) {
|
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;
|
return false;
|
||||||
} // add_meta
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete post meta data by meta ID.
|
* 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;
|
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( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) {
|
if ( ! strpos( $content, '?attachment_id=' ) || ! preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$site_url = get_bloginfo( 'url' );
|
$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 = '';
|
$replace = '';
|
||||||
|
|
||||||
foreach ( $link_matches[1] as $key => $value ) {
|
foreach ( $link_matches[1] as $key => $value ) {
|
||||||
|
@ -1054,7 +1057,7 @@ function _fix_attachment_links( $post ) {
|
||||||
continue;
|
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];
|
$url_id = (int) $url_match[2];
|
||||||
$rel_id = (int) $rel_match[1];
|
$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 );
|
$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
|
// 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
|
// Note: if empty name is supplied -- use the title instead, see #6072.
|
||||||
if ( ! is_null( $name ) ) {
|
if ( ! is_null( $name ) ) {
|
||||||
$post->post_name = sanitize_title( $name ? $name : $title, $post->ID );
|
$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 );
|
$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 );
|
$permalink = str_replace( "%$post->post_type%", '%pagename%', $permalink );
|
||||||
|
|
||||||
// Handle page hierarchy
|
// Handle page hierarchy.
|
||||||
if ( $ptype->hierarchical ) {
|
if ( $ptype->hierarchical ) {
|
||||||
$uri = get_page_uri( $post );
|
$uri = get_page_uri( $post );
|
||||||
if ( $uri ) {
|
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 ) {
|
if ( 'publish' === $post->post_status || 'attachment' === $post->post_type ) {
|
||||||
$view_link = get_permalink( $post );
|
$view_link = get_permalink( $post );
|
||||||
} else {
|
} 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 );
|
$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%' ) ) {
|
if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) {
|
||||||
$return = '<strong>' . __( 'Permalink:' ) . "</strong>\n";
|
$return = '<strong>' . __( 'Permalink:' ) . "</strong>\n";
|
||||||
|
|
||||||
|
@ -1448,7 +1451,7 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
|
||||||
$return .= '<span id="sample-permalink">' . $permalink . "</span>\n";
|
$return .= '<span id="sample-permalink">' . $permalink . "</span>\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' ) ) ) {
|
if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && ! ( 'page' == get_option( 'show_on_front' ) && $id == get_option( 'page_on_front' ) ) ) {
|
||||||
$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __( 'Change Permalinks' ) . "</a></span>\n";
|
$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __( 'Change Permalinks' ) . "</a></span>\n";
|
||||||
}
|
}
|
||||||
|
@ -1692,7 +1695,7 @@ function _admin_notice_post_locked() {
|
||||||
$query_args = array();
|
$query_args = array();
|
||||||
if ( get_post_type_object( $post->post_type )->public ) {
|
if ( get_post_type_object( $post->post_type )->public ) {
|
||||||
if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) {
|
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 );
|
$nonce = wp_create_nonce( 'post_preview_' . $post->ID );
|
||||||
$query_args['preview_id'] = $post->ID;
|
$query_args['preview_id'] = $post->ID;
|
||||||
$query_args['preview_nonce'] = $nonce;
|
$query_args['preview_nonce'] = $nonce;
|
||||||
|
@ -1747,7 +1750,7 @@ function _admin_notice_post_locked() {
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow plugins to prevent some users overriding the post lock
|
// Allow plugins to prevent some users overriding the post lock.
|
||||||
if ( $override ) {
|
if ( $override ) {
|
||||||
?>
|
?>
|
||||||
<a class="button button-primary wp-tab-last" href="<?php echo esc_url( add_query_arg( 'get-post-lock', '1', wp_nonce_url( get_edit_post_link( $post->ID, 'url' ), 'lock-post_' . $post->ID ) ) ); ?>"><?php _e( 'Take over' ); ?></a>
|
<a class="button button-primary wp-tab-last" href="<?php echo esc_url( add_query_arg( 'get-post-lock', '1', wp_nonce_url( get_edit_post_link( $post->ID, 'url' ), 'lock-post_' . $post->ID ) ) ); ?>"><?php _e( 'Take over' ); ?></a>
|
||||||
|
@ -1819,8 +1822,9 @@ function wp_create_post_autosave( $post_data ) {
|
||||||
$new_autosave['ID'] = $old_autosave->ID;
|
$new_autosave['ID'] = $old_autosave->ID;
|
||||||
$new_autosave['post_author'] = $post_author;
|
$new_autosave['post_author'] = $post_author;
|
||||||
|
|
||||||
// If the new autosave has the same content as the post, delete the autosave.
|
|
||||||
$post = get_post( $post_id );
|
$post = get_post( $post_id );
|
||||||
|
|
||||||
|
// If the new autosave has the same content as the post, delete the autosave.
|
||||||
$autosave_is_different = false;
|
$autosave_is_different = false;
|
||||||
foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) {
|
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 ) ) {
|
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.
|
// _wp_put_post_revision() expects unescaped.
|
||||||
$post_data = wp_unslash( $post_data );
|
$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 );
|
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.
|
* The ID can be the draft post_id or the autosave revision post_id.
|
||||||
*/
|
*/
|
||||||
function wp_autosave( $post_data ) {
|
function wp_autosave( $post_data ) {
|
||||||
// Back-compat
|
// Back-compat.
|
||||||
if ( ! defined( 'DOING_AUTOSAVE' ) ) {
|
if ( ! defined( 'DOING_AUTOSAVE' ) ) {
|
||||||
define( 'DOING_AUTOSAVE', true );
|
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 ) ) {
|
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 ) );
|
return edit_post( wp_slash( $post_data ) );
|
||||||
} else {
|
} 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 ) );
|
return wp_create_post_autosave( wp_slash( $post_data ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.4-alpha-47118';
|
$wp_version = '5.4-alpha-47119';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue