Multisite: Change `WP_Network` `id` property to an integer.

For consistency and developer sanity.

Props flixos90.
Fixes #37050.

Built from https://develop.svn.wordpress.org/trunk@37870


git-svn-id: http://core.svn.wordpress.org/trunk@37811 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Jeremy Felt 2016-06-26 14:26:29 +00:00
parent c5d9d5cc18
commit 6f3f00ea97
27 changed files with 525 additions and 270 deletions

View File

@ -412,31 +412,56 @@ class WP_Posts_List_Table extends WP_List_Table {
}
/**
* @global int $cat
* Displays a categories drop-down for filtering on the Posts list table.
*
* @since 4.6.0
* @access protected
*
* @global int $cat Currently selected category.
*
* @param string $post_type The Post Type.
*/
protected function categories_dropdown( $post_type ) {
global $cat;
/**
* Filters whether to remove the 'Categories' drop-down from the post list table.
*
* @since 4.6.0
*
* @param bool $disable Whether to disable the categories drop-down. Default false.
* @param string $post_type The post type.
*/
if ( false !== apply_filters( 'disable_categories_dropdown', false, $post_type ) ) {
return;
}
if ( is_object_in_taxonomy( $post_type, 'category' ) ) {
$dropdown_options = array(
'show_option_all' => get_taxonomy( 'category' )->labels->all_items,
'hide_empty' => 0,
'hierarchical' => 1,
'show_count' => 0,
'orderby' => 'name',
'selected' => $cat
);
echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>';
wp_dropdown_categories( $dropdown_options );
}
}
/**
* @param string $which
*/
protected function extra_tablenav( $which ) {
global $cat;
?>
<div class="alignleft actions">
<?php
if ( 'top' === $which && !is_singular() ) {
$this->months_dropdown( $this->screen->post_type );
if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) {
$dropdown_options = array(
'show_option_all' => get_taxonomy( 'category' )->labels->all_items,
'hide_empty' => 0,
'hierarchical' => 1,
'show_count' => 0,
'orderby' => 'name',
'selected' => $cat
);
echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>';
wp_dropdown_categories( $dropdown_options );
}
$this->categories_dropdown( $this->screen->post_type );
/**
* Fires before the Filter button on the Posts and Pages list tables.

View File

@ -552,6 +552,9 @@ function upgrade_all() {
if ( $wp_current_db_version < 36686 )
upgrade_450();
if ( $wp_current_db_version < 37854 )
upgrade_460();
maybe_disable_link_manager();
maybe_disable_automattic_widgets();
@ -1687,6 +1690,19 @@ function upgrade_450() {
delete_user_setting( 'wplink' );
}
/**
* Executes changes made in WordPress 4.6.0.
*
* @ignore
* @since 4.6.0
*
* @global int $wp_current_db_version Current database version.
* @global wpdb $wpdb WordPress database abstraction object.
*/
function upgrade_460() {
delete_post_meta_by_key( '_post_restored_from' );
}
/**
* Executes network-level upgrade routines.
*

View File

@ -3419,6 +3419,174 @@
themes: api.ThemesSection
};
/**
* Handle setting_validities in an error response for the customize-save request.
*
* Add notifications to the settings and focus on the first control that has an invalid setting.
*
* @since 4.6.0
* @private
*
* @param {object} args
* @param {object} args.settingValidities
* @param {boolean} [args.focusInvalidControl=false]
* @returns {void}
*/
api._handleSettingValidities = function handleSettingValidities( args ) {
var invalidSettingControls, invalidSettings = [], wasFocused = false;
// Find the controls that correspond to each invalid setting.
_.each( args.settingValidities, function( validity, settingId ) {
var setting = api( settingId );
if ( setting ) {
// Add notifications for invalidities.
if ( _.isObject( validity ) ) {
_.each( validity, function( params, code ) {
var notification = new api.Notification( code, params ), existingNotification, needsReplacement = false;
// Remove existing notification if already exists for code but differs in parameters.
existingNotification = setting.notifications( notification.code );
if ( existingNotification ) {
needsReplacement = ( notification.type !== existingNotification.type ) || ! _.isEqual( notification.data, existingNotification.data );
}
if ( needsReplacement ) {
setting.notifications.remove( code );
}
if ( ! setting.notifications.has( notification.code ) ) {
setting.notifications.add( code, notification );
}
invalidSettings.push( setting.id );
} );
}
// Remove notification errors that are no longer valid.
setting.notifications.each( function( notification ) {
if ( 'error' === notification.type && ( true === validity || ! validity[ notification.code ] ) ) {
setting.notifications.remove( notification.code );
}
} );
}
} );
if ( args.focusInvalidControl ) {
invalidSettingControls = api.findControlsForSettings( invalidSettings );
// Focus on the first control that is inside of an expanded section (one that is visible).
_( _.values( invalidSettingControls ) ).find( function( controls ) {
return _( controls ).find( function( control ) {
var isExpanded = control.section() && api.section.has( control.section() ) && api.section( control.section() ).expanded();
if ( isExpanded && control.expanded ) {
isExpanded = control.expanded();
}
if ( isExpanded ) {
control.focus();
wasFocused = true;
}
return wasFocused;
} );
} );
// Focus on the first invalid control.
if ( ! wasFocused && ! _.isEmpty( invalidSettingControls ) ) {
_.values( invalidSettingControls )[0][0].focus();
}
}
};
/**
* Find all controls associated with the given settings.
*
* @since 4.6.0
* @param {string[]} settingIds Setting IDs.
* @returns {object<string, wp.customize.Control>} Mapping setting ids to arrays of controls.
*/
api.findControlsForSettings = function findControlsForSettings( settingIds ) {
var controls = {}, settingControls;
_.each( _.unique( settingIds ), function( settingId ) {
var setting = api( settingId );
if ( setting ) {
settingControls = setting.findControls();
if ( settingControls && settingControls.length > 0 ) {
controls[ settingId ] = settingControls;
}
}
} );
return controls;
};
/**
* Sort panels, sections, controls by priorities. Hide empty sections and panels.
*
* @since 4.1.0
*/
api.reflowPaneContents = _.bind( function () {
var appendContainer, activeElement, rootContainers, rootNodes = [], wasReflowed = false;
if ( document.activeElement ) {
activeElement = $( document.activeElement );
}
// Sort the sections within each panel
api.panel.each( function ( panel ) {
var sections = panel.sections(),
sectionContainers = _.pluck( sections, 'container' );
rootNodes.push( panel );
appendContainer = panel.container.find( 'ul:first' );
if ( ! api.utils.areElementListsEqual( sectionContainers, appendContainer.children( '[id]' ) ) ) {
_( sections ).each( function ( section ) {
appendContainer.append( section.container );
} );
wasReflowed = true;
}
} );
// Sort the controls within each section
api.section.each( function ( section ) {
var controls = section.controls(),
controlContainers = _.pluck( controls, 'container' );
if ( ! section.panel() ) {
rootNodes.push( section );
}
appendContainer = section.container.find( 'ul:first' );
if ( ! api.utils.areElementListsEqual( controlContainers, appendContainer.children( '[id]' ) ) ) {
_( controls ).each( function ( control ) {
appendContainer.append( control.container );
} );
wasReflowed = true;
}
} );
// Sort the root panels and sections
rootNodes.sort( api.utils.prioritySort );
rootContainers = _.pluck( rootNodes, 'container' );
appendContainer = $( '#customize-theme-controls' ).children( 'ul' ); // @todo This should be defined elsewhere, and to be configurable
if ( ! api.utils.areElementListsEqual( rootContainers, appendContainer.children() ) ) {
_( rootNodes ).each( function ( rootNode ) {
appendContainer.append( rootNode.container );
} );
wasReflowed = true;
}
// Now re-trigger the active Value callbacks to that the panels and sections can decide whether they can be rendered
api.panel.each( function ( panel ) {
var value = panel.active();
panel.active.callbacks.fireWith( panel.active, [ value, value ] );
} );
api.section.each( function ( section ) {
var value = section.active();
section.active.callbacks.fireWith( section.active, [ value, value ] );
} );
// Restore focus if there was a reflow and there was an active (focused) element
if ( wasReflowed && activeElement ) {
activeElement.focus();
}
api.trigger( 'pane-contents-reflowed' );
}, api );
$( function() {
api.settings = window._wpCustomizeSettings;
api.l10n = window._wpCustomizeControlsL10n;
@ -3709,179 +3877,12 @@
});
});
/**
* Handle setting_validities in an error response for the customize-save request.
*
* Add notifications to the settings and focus on the first control that has an invalid setting.
*
* @since 4.6.0
* @private
*
* @param {object} args
* @param {object} args.settingValidities
* @param {boolean} [args.focusInvalidControl=false]
* @returns {void}
*/
api._handleSettingValidities = function handleSettingValidities( args ) {
var invalidSettingControls, invalidSettings = [], wasFocused = false;
// Find the controls that correspond to each invalid setting.
_.each( args.settingValidities, function( validity, settingId ) {
var setting = api( settingId );
if ( setting ) {
// Add notifications for invalidities.
if ( _.isObject( validity ) ) {
_.each( validity, function( params, code ) {
var notification = new api.Notification( code, params ), existingNotification, needsReplacement = false;
// Remove existing notification if already exists for code but differs in parameters.
existingNotification = setting.notifications( notification.code );
if ( existingNotification ) {
needsReplacement = ( notification.type !== existingNotification.type ) || ! _.isEqual( notification.data, existingNotification.data );
}
if ( needsReplacement ) {
setting.notifications.remove( code );
}
if ( ! setting.notifications.has( notification.code ) ) {
setting.notifications.add( code, notification );
}
invalidSettings.push( setting.id );
} );
}
// Remove notification errors that are no longer valid.
setting.notifications.each( function( notification ) {
if ( 'error' === notification.type && ( true === validity || ! validity[ notification.code ] ) ) {
setting.notifications.remove( notification.code );
}
} );
}
} );
if ( args.focusInvalidControl ) {
invalidSettingControls = api.findControlsForSettings( invalidSettings );
// Focus on the first control that is inside of an expanded section (one that is visible).
_( _.values( invalidSettingControls ) ).find( function( controls ) {
return _( controls ).find( function( control ) {
var isExpanded = control.section() && api.section.has( control.section() ) && api.section( control.section() ).expanded();
if ( isExpanded && control.expanded ) {
isExpanded = control.expanded();
}
if ( isExpanded ) {
control.focus();
wasFocused = true;
}
return wasFocused;
} );
} );
// Focus on the first invalid control.
if ( ! wasFocused && ! _.isEmpty( invalidSettingControls ) ) {
_.values( invalidSettingControls )[0][0].focus();
}
}
};
/**
* Find all controls associated with the given settings.
*
* @since 4.6.0
* @param {string[]} settingIds Setting IDs.
* @returns {object<string, wp.customize.Control>} Mapping setting ids to arrays of controls.
*/
api.findControlsForSettings = function findControlsForSettings( settingIds ) {
var controls = {}, settingControls;
_.each( _.unique( settingIds ), function( settingId ) {
var setting = api( settingId );
if ( setting ) {
settingControls = setting.findControls();
if ( settingControls && settingControls.length > 0 ) {
controls[ settingId ] = settingControls;
}
}
} );
return controls;
};
/**
* Sort panels, sections, controls by priorities. Hide empty sections and panels.
*
* @since 4.1.0
*/
api.reflowPaneContents = _.bind( function () {
var appendContainer, activeElement, rootContainers, rootNodes = [], wasReflowed = false;
if ( document.activeElement ) {
activeElement = $( document.activeElement );
}
// Sort the sections within each panel
api.panel.each( function ( panel ) {
var sections = panel.sections(),
sectionContainers = _.pluck( sections, 'container' );
rootNodes.push( panel );
appendContainer = panel.container.find( 'ul:first' );
if ( ! api.utils.areElementListsEqual( sectionContainers, appendContainer.children( '[id]' ) ) ) {
_( sections ).each( function ( section ) {
appendContainer.append( section.container );
} );
wasReflowed = true;
}
} );
// Sort the controls within each section
api.section.each( function ( section ) {
var controls = section.controls(),
controlContainers = _.pluck( controls, 'container' );
if ( ! section.panel() ) {
rootNodes.push( section );
}
appendContainer = section.container.find( 'ul:first' );
if ( ! api.utils.areElementListsEqual( controlContainers, appendContainer.children( '[id]' ) ) ) {
_( controls ).each( function ( control ) {
appendContainer.append( control.container );
} );
wasReflowed = true;
}
} );
// Sort the root panels and sections
rootNodes.sort( api.utils.prioritySort );
rootContainers = _.pluck( rootNodes, 'container' );
appendContainer = $( '#customize-theme-controls' ).children( 'ul' ); // @todo This should be defined elsewhere, and to be configurable
if ( ! api.utils.areElementListsEqual( rootContainers, appendContainer.children() ) ) {
_( rootNodes ).each( function ( rootNode ) {
appendContainer.append( rootNode.container );
} );
wasReflowed = true;
}
// Now re-trigger the active Value callbacks to that the panels and sections can decide whether they can be rendered
api.panel.each( function ( panel ) {
var value = panel.active();
panel.active.callbacks.fireWith( panel.active, [ value, value ] );
} );
api.section.each( function ( section ) {
var value = section.active();
section.active.callbacks.fireWith( section.active, [ value, value ] );
} );
// Restore focus if there was a reflow and there was an active (focused) element
if ( wasReflowed && activeElement ) {
activeElement.focus();
}
api.trigger( 'pane-contents-reflowed' );
}, api );
api.bind( 'ready', api.reflowPaneContents );
api.reflowPaneContents = _.debounce( api.reflowPaneContents, 100 );
$( [ api.panel, api.section, api.control ] ).each( function ( i, values ) {
values.bind( 'add', api.reflowPaneContents );
values.bind( 'change', api.reflowPaneContents );
values.bind( 'remove', api.reflowPaneContents );
var debouncedReflowPaneContents = _.debounce( api.reflowPaneContents, 100 );
values.bind( 'add', debouncedReflowPaneContents );
values.bind( 'change', debouncedReflowPaneContents );
values.bind( 'remove', debouncedReflowPaneContents );
} );
// Check if preview url is valid and load the preview frame.
@ -3928,8 +3929,9 @@
});
activated.bind( function( to ) {
if ( to )
if ( to ) {
api.trigger( 'activated' );
}
});
// Expose states to the API.

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/* global ajaxurl, attachMediaBoxL10n, _wpMediaGridSettings */
/* global ajaxurl, attachMediaBoxL10n, _wpMediaGridSettings, showNotice */
var findPosts;
( function( $ ){
@ -99,9 +99,15 @@ var findPosts;
$( '#find-posts-close' ).click( findPosts.close );
$( '#doaction, #doaction2' ).click( function( event ) {
$( 'select[name^="action"]' ).each( function() {
if ( $(this).val() === 'attach' ) {
var optionValue = $( this ).val();
if ( 'attach' === optionValue ) {
event.preventDefault();
findPosts.open();
} else if ( 'delete' === optionValue ) {
if ( ! showNotice.warn() ) {
event.preventDefault();
}
}
});
});

View File

@ -1 +1 @@
var findPosts;!function(a){findPosts={open:function(b,c){var d=a(".ui-find-overlay");return 0===d.length&&(a("body").append('<div class="ui-find-overlay"></div>'),findPosts.overlay()),d.show(),b&&c&&a("#affected").attr("name",b).val(c),a("#find-posts").show(),a("#find-posts-input").focus().keyup(function(a){27==a.which&&findPosts.close()}),findPosts.send(),!1},close:function(){a("#find-posts-response").empty(),a("#find-posts").hide(),a(".ui-find-overlay").hide()},overlay:function(){a(".ui-find-overlay").on("click",function(){findPosts.close()})},send:function(){var b={ps:a("#find-posts-input").val(),action:"find_posts",_ajax_nonce:a("#_ajax_nonce").val()},c=a(".find-box-search .spinner");c.addClass("is-active"),a.ajax(ajaxurl,{type:"POST",data:b,dataType:"json"}).always(function(){c.removeClass("is-active")}).done(function(b){b.success||a("#find-posts-response").text(attachMediaBoxL10n.error),a("#find-posts-response").html(b.data)}).fail(function(){a("#find-posts-response").text(attachMediaBoxL10n.error)})}},a(document).ready(function(){var b,c=a("#wp-media-grid");c.length&&window.wp&&window.wp.media&&(b=_wpMediaGridSettings,window.wp.media({frame:"manage",container:c,library:b.queryVars}).open()),a("#find-posts-submit").click(function(b){a('#find-posts-response input[type="radio"]:checked').length||b.preventDefault()}),a("#find-posts .find-box-search :input").keypress(function(a){return 13==a.which?(findPosts.send(),!1):void 0}),a("#find-posts-search").click(findPosts.send),a("#find-posts-close").click(findPosts.close),a("#doaction, #doaction2").click(function(b){a('select[name^="action"]').each(function(){"attach"===a(this).val()&&(b.preventDefault(),findPosts.open())})}),a(".find-box-inside").on("click","tr",function(){a(this).find(".found-radio input").prop("checked",!0)})})}(jQuery);
var findPosts;!function(a){findPosts={open:function(b,c){var d=a(".ui-find-overlay");return 0===d.length&&(a("body").append('<div class="ui-find-overlay"></div>'),findPosts.overlay()),d.show(),b&&c&&a("#affected").attr("name",b).val(c),a("#find-posts").show(),a("#find-posts-input").focus().keyup(function(a){27==a.which&&findPosts.close()}),findPosts.send(),!1},close:function(){a("#find-posts-response").empty(),a("#find-posts").hide(),a(".ui-find-overlay").hide()},overlay:function(){a(".ui-find-overlay").on("click",function(){findPosts.close()})},send:function(){var b={ps:a("#find-posts-input").val(),action:"find_posts",_ajax_nonce:a("#_ajax_nonce").val()},c=a(".find-box-search .spinner");c.addClass("is-active"),a.ajax(ajaxurl,{type:"POST",data:b,dataType:"json"}).always(function(){c.removeClass("is-active")}).done(function(b){b.success||a("#find-posts-response").text(attachMediaBoxL10n.error),a("#find-posts-response").html(b.data)}).fail(function(){a("#find-posts-response").text(attachMediaBoxL10n.error)})}},a(document).ready(function(){var b,c=a("#wp-media-grid");c.length&&window.wp&&window.wp.media&&(b=_wpMediaGridSettings,window.wp.media({frame:"manage",container:c,library:b.queryVars}).open()),a("#find-posts-submit").click(function(b){a('#find-posts-response input[type="radio"]:checked').length||b.preventDefault()}),a("#find-posts .find-box-search :input").keypress(function(a){return 13==a.which?(findPosts.send(),!1):void 0}),a("#find-posts-search").click(findPosts.send),a("#find-posts-close").click(findPosts.close),a("#doaction, #doaction2").click(function(b){a('select[name^="action"]').each(function(){var c=a(this).val();"attach"===c?(b.preventDefault(),findPosts.open()):"delete"===c&&(showNotice.warn()||b.preventDefault())})}),a(".find-box-inside").on("click","tr",function(){a(this).find(".found-radio input").prop("checked",!0)})})}(jQuery);

View File

@ -31,7 +31,13 @@ if ( ! defined( 'WP_ALLOW_REPAIR' ) ) {
echo '<h1 class="screen-reader-text">' . __( 'Allow automatic database repair' ) . '</h1>';
echo '<p>' . __( 'To allow use of this page to automatically repair database problems, please add the following line to your <code>wp-config.php</code> file. Once this line is added to your config, reload this page.' ) . "</p><p><code>define('WP_ALLOW_REPAIR', true);</code></p>";
echo '<p>';
printf(
/* translators: %s: File name. */
__( 'To allow use of this page to automatically repair database problems, please add the following line to your %s file. Once this line is added to your config, reload this page.' ),
'<code>wp-config.php</code>'
);
echo "</p><p><code>define('WP_ALLOW_REPAIR', true);</code></p>";
$default_key = 'put your unique phrase here';
$missing_key = false;

View File

@ -327,6 +327,8 @@ class WP_Meta_Query {
return false;
}
$this->table_aliases = array();
$this->meta_table = $meta_table;
$this->meta_id_column = sanitize_key( $type . '_id' );

View File

@ -18,6 +18,7 @@
*
* @since 4.4.0
*
* @property int $id
* @property int $site_id
*/
class WP_Network {
@ -25,13 +26,12 @@ class WP_Network {
/**
* Network ID.
*
* A numeric string, for compatibility reasons.
*
* @since 4.4.0
* @access public
* @var string
* @since 4.6.0 Type changed from string to int.
* @access private
* @var int
*/
public $id;
private $id;
/**
* Domain of the network.
@ -152,6 +152,8 @@ class WP_Network {
*/
public function __get( $key ) {
switch ( $key ) {
case 'id';
return (int) $this->id;
case 'blog_id':
return $this->blog_id;
case 'site_id':
@ -174,6 +176,7 @@ class WP_Network {
*/
public function __isset( $key ) {
switch ( $key ) {
case 'id':
case 'blog_id':
case 'site_id':
return true;
@ -195,6 +198,9 @@ class WP_Network {
*/
public function __set( $key, $value ) {
switch ( $key ) {
case 'id':
$this->id = (int) $value;
break;
case 'blog_id':
case 'site_id':
$this->blog_id = (string) $value;

View File

@ -231,13 +231,9 @@ class WP_Site_Query {
* @since 4.6.0
* @access public
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @return array|int List of sites, or number of sites when 'count' is passed as a query var.
*/
public function get_sites() {
global $wpdb;
$this->parse_query();
/**
@ -256,12 +252,26 @@ class WP_Site_Query {
$last_changed = microtime();
wp_cache_set( 'last_changed', $last_changed, 'sites' );
}
$cache_key = "get_site_ids:$key:$last_changed";
$site_ids = wp_cache_get( $cache_key, 'sites' );
if ( false === $site_ids ) {
$cache_key = "get_sites:$key:$last_changed";
$cache_value = wp_cache_get( $cache_key, 'sites' );
if ( false === $cache_value ) {
$site_ids = $this->get_site_ids();
wp_cache_add( $cache_key, $site_ids, 'sites' );
if ( $site_ids ) {
$this->set_found_sites();
}
$cache_value = array(
'site_ids' => $site_ids,
'found_sites' => $this->found_sites,
'max_num_pages' => $this->max_num_pages,
);
wp_cache_add( $cache_key, $cache_value, 'sites' );
} else {
$site_ids = $cache_value['site_ids'];
$this->found_sites = $cache_value['found_sites'];
$this->max_num_pages = $cache_value['max_num_pages'];
}
// If querying for a count only, there's nothing more to do.
@ -274,21 +284,6 @@ class WP_Site_Query {
$this->site_count = count( $this->sites );
if ( $site_ids && $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) {
/**
* Filters the query used to retrieve found site count.
*
* @since 4.6.0
*
* @param string $found_sites_query SQL query. Default 'SELECT FOUND_ROWS()'.
* @param WP_Site_Query $site_query The `WP_Site_Query` instance.
*/
$found_sites_query = apply_filters( 'found_sites_query', 'SELECT FOUND_ROWS()', $this );
$this->found_sites = (int) $wpdb->get_var( $found_sites_query );
$this->max_num_pages = ceil( $this->found_sites / $this->query_vars['number'] );
}
if ( 'ids' == $this->query_vars['fields'] ) {
$this->sites = $site_ids;
@ -571,6 +566,34 @@ class WP_Site_Query {
return array_map( 'intval', $site_ids );
}
/**
* Populates found_sites and max_num_pages properties for the current query
* if the limit clause was used.
*
* @since 4.6.0
* @access private
*
* @global wpdb $wpdb WordPress database abstraction object.
*/
private function set_found_sites() {
global $wpdb;
if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) {
/**
* Filters the query used to retrieve found site count.
*
* @since 4.6.0
*
* @param string $found_sites_query SQL query. Default 'SELECT FOUND_ROWS()'.
* @param WP_Site_Query $site_query The `WP_Site_Query` instance.
*/
$found_sites_query = apply_filters( 'found_sites_query', 'SELECT FOUND_ROWS()', $this );
$this->found_sites = (int) $wpdb->get_var( $found_sites_query );
$this->max_num_pages = ceil( $this->found_sites / $this->query_vars['number'] );
}
}
/**
* Used internally to generate an SQL string for searching across multiple columns.
*

View File

@ -814,6 +814,8 @@ class WP_Term_Query {
protected function parse_orderby_meta( $orderby_raw ) {
$orderby = '';
// Tell the meta query to generate its SQL, so we have access to table aliases.
$this->meta_query->get_sql( 'term', 't', 'term_id' );
$meta_clauses = $this->meta_query->get_clauses();
if ( ! $meta_clauses || ! $orderby_raw ) {
return $orderby;

View File

@ -1484,8 +1484,14 @@ function utf8_uri_encode( $utf8_string, $length = 0 ) {
* | U+00C5 | Å | Aa | Latin capital letter A with ring above |
* | U+00E5 | å | aa | Latin small letter a with ring above |
*
* Catalan (`ca`) locale:
*
* | Code | Glyph | Replacement | Description |
* | -------- | ----- | ----------- | --------------------------------------- |
* | U+00B7 | l·l | ll | Flown dot (between two Ls) |
*
* @since 1.2.1
* @since 4.6.0 Locale support was added for `de_CH` and `de_CH_informal`.
* @since 4.6.0 Locale support was added for `de_CH`, `de_CH_informal`, and `ca`.
*
* @param string $string Text that might have accent characters
* @return string Filtered string with replaced "nice" characters.
@ -1689,6 +1695,8 @@ function remove_accents( $string ) {
$chars[ chr(195).chr(184) ] = 'oe';
$chars[ chr(195).chr(133) ] = 'Aa';
$chars[ chr(195).chr(165) ] = 'aa';
} elseif ( 'ca' === $locale ) {
$chars[ chr(108).chr(194).chr(183).chr(108) ] = 'll';
}
$string = strtr($string, $chars);
@ -4624,18 +4632,21 @@ function wp_strip_all_tags($string, $remove_breaks = false) {
}
/**
* Sanitize a string from user input or from the db
* Sanitizes a string from user input or from the database.
*
* check for invalid UTF-8,
* Convert single < characters to entity,
* strip all tags,
* remove line breaks, tabs and extra white space,
* strip octets.
* - Checks for invalid UTF-8,
* - Converts single `<` characters to entities
* - Strips all tags
* - Removes line breaks, tabs, and extra whitespace
* - Strips octets
*
* @since 2.9.0
*
* @param string $str
* @return string
* @see wp_check_invalid_utf8()
* @see wp_strip_all_tags()
*
* @param string $str String to sanitize.
* @return string Sanitized string.
*/
function sanitize_text_field( $str ) {
$filtered = wp_check_invalid_utf8( $str );

View File

@ -3892,6 +3892,56 @@ function _deprecated_argument( $function, $version, $message = null ) {
}
}
/**
* Marks a deprecated action or filter hook as deprecated and throws a notice.
*
* Use the 'deprecated_hook_run' action to get the backtrace describing where the
* deprecated hook was called.
*
* Default behavior is to trigger a user error if WP_DEBUG is true.
*
* This function is called by the do_action_deprecated() and apply_filters_deprecated()
* functions, and so generally does not need to be called directly.
*
* @since 4.6.0
* @access private
*
* @param string $hook The hook that was used.
* @param string $version The version of WordPress that deprecated the hook.
* @param string $replacement Optional. The hook that should have been used.
* @param string $message Optional. A message regarding the change.
*/
function _deprecated_hook( $hook, $version, $replacement = null, $message = null ) {
/**
* Fires when a deprecated hook is called.
*
* @since 4.6.0
*
* @param string $hook The hook that was called.
* @param string $replacement The hook that should be used as a replacement.
* @param string $version The version of WordPress that deprecated the argument used.
* @param string $message A message regarding the change.
*/
do_action( 'deprecated_hook_run', $hook, $replacement, $version, $message );
/**
* Filter whether to trigger deprecated hook errors.
*
* @since 4.6.0
*
* @param bool $trigger Whether to trigger deprecated hook errors. Requires
* `WP_DEBUG` to be defined true.
*/
if ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) {
$message = empty( $message ) ? '' : ' ' . $message;
if ( ! is_null( $replacement ) ) {
trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $hook, $version, $replacement ) . $message );
} else {
trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $hook, $version ) . $message );
}
}
}
/**
* Mark something as being incorrectly called.
*

View File

@ -2265,10 +2265,9 @@ function get_the_modified_date( $d = '', $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
}
if ( empty( $d ) ) {
// For backward compatibility, failures go through the filter below.
$the_time = false;
} elseif ( empty( $d ) ) {
$the_time = get_post_modified_time( get_option( 'date_format' ), false, $post, true );
} else {
$the_time = get_post_modified_time( $d, false, $post, true );
@ -2421,10 +2420,9 @@ function get_the_modified_time( $d = '', $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
}
if ( empty( $d ) ) {
// For backward compatibility, failures go through the filter below.
$the_time = false;
} elseif ( empty( $d ) ) {
$the_time = get_post_modified_time( get_option( 'time_format' ), false, $post, true );
} else {
$the_time = get_post_modified_time( $d, false, $post, true );

View File

@ -30,7 +30,7 @@ window.wp = window.wp || {};
};
return function ( data ) {
compiled = compiled || _.template( $( '#tmpl-' + id ).html(), null, options );
compiled = compiled || _.template( $( '#tmpl-' + id ).html(), options );
return compiled( data );
};
});

View File

@ -1 +1 @@
window.wp=window.wp||{},function(a){var b="undefined"==typeof _wpUtilSettings?{}:_wpUtilSettings;wp.template=_.memoize(function(b){var c,d={evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"};return function(e){return(c=c||_.template(a("#tmpl-"+b).html(),null,d))(e)}}),wp.ajax={settings:b.ajax||{},post:function(a,b){return wp.ajax.send({data:_.isObject(a)?a:_.extend(b||{},{action:a})})},send:function(b,c){var d,e;return _.isObject(b)?c=b:(c=c||{},c.data=_.extend(c.data||{},{action:b})),c=_.defaults(c||{},{type:"POST",url:wp.ajax.settings.url,context:this}),e=a.Deferred(function(b){c.success&&b.done(c.success),c.error&&b.fail(c.error),delete c.success,delete c.error,b.jqXHR=a.ajax(c).done(function(a){"1"!==a&&1!==a||(a={success:!0}),_.isObject(a)&&!_.isUndefined(a.success)?b[a.success?"resolveWith":"rejectWith"](this,[a.data]):b.rejectWith(this,[a])}).fail(function(){b.rejectWith(this,arguments)})}),d=e.promise(),d.abort=function(){return e.jqXHR.abort(),this},d}}}(jQuery);
window.wp=window.wp||{},function(a){var b="undefined"==typeof _wpUtilSettings?{}:_wpUtilSettings;wp.template=_.memoize(function(b){var c,d={evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"};return function(e){return(c=c||_.template(a("#tmpl-"+b).html(),d))(e)}}),wp.ajax={settings:b.ajax||{},post:function(a,b){return wp.ajax.send({data:_.isObject(a)?a:_.extend(b||{},{action:a})})},send:function(b,c){var d,e;return _.isObject(b)?c=b:(c=c||{},c.data=_.extend(c.data||{},{action:b})),c=_.defaults(c||{},{type:"POST",url:wp.ajax.settings.url,context:this}),e=a.Deferred(function(b){c.success&&b.done(c.success),c.error&&b.fail(c.error),delete c.success,delete c.error,b.jqXHR=a.ajax(c).done(function(a){"1"!==a&&1!==a||(a={success:!0}),_.isObject(a)&&!_.isUndefined(a.success)?b[a.success?"resolveWith":"rejectWith"](this,[a.data]):b.rejectWith(this,[a])}).fail(function(){b.rejectWith(this,arguments)})}),d=e.promise(),d.abort=function(){return e.jqXHR.abort(),this},d}}}(jQuery);

View File

@ -509,14 +509,17 @@ function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' )
*
* @since 1.5.0
*
* @global array $l10n
* @global array $l10n An array of all currently loaded text domains.
* @global array $l10n_unloaded An array of all text domains that have been unloaded again.
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @param string $mofile Path to the .mo file.
* @return bool True on success, false on failure.
*/
function load_textdomain( $domain, $mofile ) {
global $l10n;
global $l10n, $l10n_unloaded;
$l10n_unloaded = (array) $l10n_unloaded;
/**
* Filters whether to override the .mo file loading.
@ -530,6 +533,8 @@ function load_textdomain( $domain, $mofile ) {
$plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile );
if ( true == $plugin_override ) {
unset( $l10n_unloaded[ $domain ] );
return true;
}
@ -561,6 +566,8 @@ function load_textdomain( $domain, $mofile ) {
if ( isset( $l10n[$domain] ) )
$mo->merge_with( $l10n[$domain] );
unset( $l10n_unloaded[ $domain ] );
$l10n[$domain] = &$mo;
return true;
@ -571,13 +578,16 @@ function load_textdomain( $domain, $mofile ) {
*
* @since 3.0.0
*
* @global array $l10n
* @global array $l10n An array of all currently loaded text domains.
* @global array $l10n_unloaded An array of all text domains that have been unloaded again.
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return bool Whether textdomain was unloaded.
*/
function unload_textdomain( $domain ) {
global $l10n;
global $l10n, $l10n_unloaded;
$l10n_unloaded = (array) $l10n_unloaded;
/**
* Filters whether to override the text domain unloading.
@ -589,8 +599,11 @@ function unload_textdomain( $domain ) {
*/
$plugin_override = apply_filters( 'override_unload_textdomain', false, $domain );
if ( $plugin_override )
if ( $plugin_override ) {
$l10n_unloaded[ $domain ] = true;
return true;
}
/**
* Fires before the text domain is unloaded.
@ -603,6 +616,9 @@ function unload_textdomain( $domain ) {
if ( isset( $l10n[$domain] ) ) {
unset( $l10n[$domain] );
$l10n_unloaded[ $domain ] = true;
return true;
}
@ -793,15 +809,20 @@ function load_child_theme_textdomain( $domain, $path = false ) {
* @access private
*
* @see get_translations_for_domain()
* @global array $l10n_unloaded An array of all text domains that have been unloaded again.
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return bool True when the textdomain is successfully loaded, false otherwise.
*/
function _load_textdomain_just_in_time( $domain ) {
global $l10n_unloaded;
$l10n_unloaded = (array) $l10n_unloaded;
static $cached_mofiles = null;
// Short-circuit if domain is 'default' which is reserved for core.
if ( 'default' === $domain ) {
if ( 'default' === $domain || isset( $l10n_unloaded[ $domain ] ) ) {
return false;
}

View File

@ -68,7 +68,6 @@ function wp_get_active_network_plugins() {
* @return true|string Returns true on success, or drop-in file to include.
*/
function ms_site_check() {
$blog = get_blog_details();
/**
* Filters checking the status of the current blog.
@ -85,6 +84,8 @@ function ms_site_check() {
if ( is_super_admin() )
return true;
$blog = get_blog_details();
if ( '1' == $blog->deleted ) {
if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) )
return WP_CONTENT_DIR . '/blog-deleted.php';

View File

@ -1127,6 +1127,19 @@ if ( !function_exists('wp_redirect') ) :
/**
* Redirects to another page.
*
* Note: wp_redirect() does not exit automatically, and should almost always be
* followed by a call to `exit;`:
*
* wp_redirect( $url );
* exit;
*
* Exiting can also be selectively manipulated by using wp_redirect() as a conditional
* in conjunction with the {@see 'wp_redirect'} and {@see 'wp_redirect_location'} hooks:
*
* if ( wp_redirect( $url ) {
* exit;
* }
*
* @since 1.5.1
*
* @global bool $is_IIS

View File

@ -655,6 +655,60 @@ function remove_all_actions($tag, $priority = false) {
return remove_all_filters($tag, $priority);
}
/**
* Fires functions attached to a deprecated filter hook.
*
* When a filter hook is deprecated, the apply_filters() call is replaced with
* apply_filters_deprecated(), which triggers a deprecation notice and then fires
* the original filter hook.
*
* @since 4.6.0
*
* @see _deprecated_hook()
*
* @param string $tag The name of the filter hook.
* @param array $args Array of additional function arguments to be passed to apply_filters().
* @param string $version The version of WordPress that deprecated the hook.
* @param string $replacement Optional. The hook that should have been used.
* @param string $message Optional. A message regarding the change.
*/
function apply_filters_deprecated( $tag, $args, $version, $replacement = false, $message = null ) {
if ( ! has_filter( $tag ) ) {
return;
}
_deprecated_hook( $tag, $version, $replacement, $message );
return apply_filters_ref_array( $tag, $args );
}
/**
* Fires functions attached to a deprecated action hook.
*
* When an action hook is deprecated, the do_action() call is replaced with
* do_action_deprecated(), which triggers a deprecation notice and then fires
* the original hook.
*
* @since 4.6.0
*
* @see _deprecated_hook()
*
* @param string $tag The name of the action hook.
* @param array $args Array of additional function arguments to be passed to do_action().
* @param string $version The version of WordPress that deprecated the hook.
* @param string $replacement Optional. The hook that should have been used.
* @param string $message Optional. A message regarding the change.
*/
function do_action_deprecated( $tag, $args, $version, $replacement = false, $message = null ) {
if ( ! has_action( $tag ) ) {
return;
}
_deprecated_hook( $tag, $version, $replacement, $message );
do_action_ref_array( $tag, $args );
}
//
// Functions for handling plugins.
//

View File

@ -2169,7 +2169,18 @@ function stick_post( $post_id ) {
if ( ! in_array($post_id, $stickies) )
$stickies[] = $post_id;
update_option('sticky_posts', $stickies);
$updated = update_option( 'sticky_posts', $stickies );
if ( $updated ) {
/**
* Fires once a post has been added to the sticky list.
*
* @since 4.6.0
*
* @param int $post_id ID of the post that was stuck.
*/
do_action( 'post_stuck', $post_id );
}
}
/**
@ -2196,7 +2207,18 @@ function unstick_post( $post_id ) {
array_splice($stickies, $offset, 1);
update_option('sticky_posts', $stickies);
$updated = update_option( 'sticky_posts', $stickies );
if ( $updated ) {
/**
* Fires once a post has been removed from the sticky list.
*
* @since 4.6.0
*
* @param int $post_id ID of the post that was unstuck.
*/
do_action( 'post_unstuck', $post_id );
}
}
/**

View File

@ -407,22 +407,22 @@ function is_front_page() {
}
/**
* Is the query for the blog homepage?
* Determines if the query is for the blog homepage.
*
* This is the page which shows the time based blog content of your site.
* The blog homepage is the page that shows the time-based blog content of the site.
*
* Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_for_posts'.
* is_home() is dependent on the site's "Front page displays" Reading Settings 'show_on_front'
* and 'page_for_posts'.
*
* If you set a static page for the front page of your site, this function will return
* true only on the page you set as the "Posts page".
*
* @see is_front_page()
* If a static page is set for the front page of the site, this function will return true only
* on the page you set as the "Posts page".
*
* @since 1.5.0
*
* @see is_front_page()
* @global WP_Query $wp_query Global WP_Query instance.
*
* @return bool True if blog view homepage.
* @return bool True if blog view homepage, otherwise false.
*/
function is_home() {
global $wp_query;
@ -3550,7 +3550,7 @@ class WP_Query {
*
* @since 2.0.0
*
* @param array $request The complete SQL query.
* @param string $request The complete SQL query.
* @param WP_Query &$this The WP_Query instance (passed by reference).
*/
$this->request = apply_filters_ref_array( 'posts_request', array( $this->request, &$this ) );

View File

@ -378,14 +378,6 @@ function wp_restore_post_revision( $revision_id, $fields = null ) {
if ( ! $post_id || is_wp_error( $post_id ) )
return $post_id;
// Add restore from details
$restore_details = array(
'restored_revision_id' => $revision_id,
'restored_by_user' => get_current_user_id(),
'restored_time' => time()
);
update_post_meta( $post_id, '_post_restored_from', $restore_details );
// Update last edit user
update_post_meta( $post_id, '_edit_last', get_current_user_id() );

View File

@ -1,7 +1,7 @@
<?php
/**
* WordPress API for creating bbcode like tags or what WordPress calls
* "shortcodes." The tag and attribute parsing or regular expression code is
* WordPress API for creating bbcode-like tags or what WordPress calls
* "shortcodes". The tag and attribute parsing or regular expression code is
* based on the Textpattern tag parser.
*
* A few examples are below:

View File

@ -1521,6 +1521,10 @@ function get_editor_stylesheets() {
* The {@see 'init'} hook may be too late for some features.
*
* @since 2.9.0
* @since 3.6.0 The `html5` feature was added
* @since 3.9.0 The `html5` feature now also accepts 'gallery' and 'caption'
* @since 4.1.0 The `title-tag` feature was added
* @since 4.5.0 The `customize-selective-refresh-widgets` feature was added
*
* @global array $_wp_theme_features
*

View File

@ -4,14 +4,14 @@
*
* @global string $wp_version
*/
$wp_version = '4.6-alpha-37801';
$wp_version = '4.6-alpha-37870';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
*
* @global int $wp_db_version
*/
$wp_db_version = 36686;
$wp_db_version = 37854;
/**
* Holds the TinyMCE version

View File

@ -99,6 +99,7 @@ require( ABSPATH . WPINC . '/class-wp-error.php' );
require( ABSPATH . WPINC . '/pomo/mo.php' );
// Include the wpdb class and, if present, a db.php database drop-in.
global $wpdb;
require_wp_db();
// Set the database table prefix and the format specifiers for database table columns.