Skip to content

Commit 2cc9b42

Browse files
2 parents f694f7f + e799a8f commit 2cc9b42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1903
-255
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ before_install:
5252
echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
5353
fi
5454
before_script:
55+
- stable='^[0-9\.]+$'; if [[ "$TRAVIS_PHP_VERSION" =~ $stable ]]; then phpenv config-rm xdebug.ini; fi
5556
- npm install -g npm
5657
- npm install -g grunt-cli
5758
- npm install
5859
- npm prune
5960
- mysql --version
6061
- phpenv versions
62+
- php --version
6163
- npm --version
6264
- node --version
6365
script: grunt $WP_TRAVISCI

src/wp-admin/about.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@
7878
echo wp_video_shortcode( array(
7979
'mp4' => 'https://s.w.org/images/core/4.7/starter-content-v1.mp4',
8080
'poster' => 'https://s.w.org/images/core/4.7/starter-content.jpg?v2',
81-
'loop' => true,
82-
'autoplay' => true,
8381
'width' => 1140,
8482
'height' => 624,
8583
// 'class' => 'wp-video-shortcode feature-video',
@@ -95,8 +93,6 @@
9593
echo wp_video_shortcode( array(
9694
'mp4' => 'https://s.w.org/images/core/4.7/edit-shortcuts-v1.mp4',
9795
'poster' => 'https://s.w.org/images/core/4.7/edit-shortcuts.jpg?v2',
98-
'loop' => true,
99-
'autoplay' => true,
10096
'width' => 2520,
10197
'height' => 1454,
10298
// 'class' => 'wp-video-shortcode feature-video',
@@ -110,8 +106,6 @@
110106
echo wp_video_shortcode( array(
111107
'mp4' => 'https://s.w.org/images/core/4.7/header-video-v1.mp4',
112108
'poster' => 'https://s.w.org/images/core/4.7/header-video.jpg?v2',
113-
'loop' => true,
114-
'autoplay' => true,
115109
'width' => 2520,
116110
'height' => 1454,
117111
// 'class' => 'wp-video-shortcode feature-video',

src/wp-admin/includes/image.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,15 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
251251
$editor = wp_get_image_editor( $file );
252252

253253
if ( ! is_wp_error( $editor ) ) { // No support for this type of file
254-
$uploaded = $editor->save( $file, 'image/jpeg' );
254+
/*
255+
* PDFs may have the same file filename as JPEGs.
256+
* Ensure the PDF preview image does not overwrite any JPEG images that already exist.
257+
*/
258+
$dirname = dirname( $file ) . '/';
259+
$ext = '.' . pathinfo( $file, PATHINFO_EXTENSION );
260+
$preview_file = $dirname . wp_unique_filename( $dirname, wp_basename( $file, $ext ) . '-pdf.jpg' );
261+
262+
$uploaded = $editor->save( $preview_file, 'image/jpeg' );
255263
unset( $editor );
256264

257265
// Resize based on the full size image, rather than the source.

src/wp-admin/includes/user.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,5 +535,5 @@ function admin_created_user_email( $text ) {
535535
this email. This invitation will expire in a few days.
536536
537537
Please click the following link to activate your user account:
538-
%%s' ), get_bloginfo( 'name' ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ) );
538+
%%s' ), wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ) );
539539
}

src/wp-admin/js/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ $document.ready( function() {
418418
screenMeta.init();
419419

420420
// This event needs to be delegated. Ticket #37973.
421-
$body.on( 'click', 'tbody .check-column :checkbox', function( event ) {
421+
$body.on( 'click', 'tbody > .check-column :checkbox', function( event ) {
422422
// Shift click to select a range of checkboxes.
423423
if ( 'undefined' == event.shiftKey ) { return true; }
424424
if ( event.shiftKey ) {

src/wp-admin/js/revisions.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ window.wp = window.wp || {};
411411
// Start the router if browser supports History API
412412
if ( window.history && window.history.pushState ) {
413413
this.router = new revisions.Router({ model: this });
414+
if ( Backbone.History.started ) {
415+
Backbone.history.stop();
416+
}
414417
Backbone.history.start({ pushState: true });
415418
}
416419
},

src/wp-admin/js/theme.js

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ themes.view.Theme = wp.Backbone.View.extend({
492492
themes.focusedTheme = this.$el;
493493

494494
// Construct a new Preview view.
495-
preview = new themes.view.Preview({
495+
themes.currentPreview = preview = new themes.view.Preview({
496496
model: this.model
497497
});
498498

@@ -572,6 +572,11 @@ themes.view.Theme = wp.Backbone.View.extend({
572572
this.listenTo( preview, 'preview:close', function() {
573573
self.current = self.model;
574574
});
575+
576+
// Listen for closepreview events, closing the preview.
577+
this.listenTo( preview, 'closepreview', function() {
578+
preview.close();
579+
});
575580
},
576581

577582
// Handles .disabled classes for previous/next buttons in theme installer preview
@@ -885,7 +890,7 @@ themes.view.Preview = themes.view.Details.extend({
885890
self.tooglePreviewDeviceButtons( currentPreviewDevice );
886891
}
887892

888-
themes.router.navigate( themes.router.baseUrl( themes.router.themePath + this.model.get( 'id' ) ), { replace: true } );
893+
themes.router.navigate( themes.router.baseUrl( themes.router.themePath + this.model.get( 'id' ) ), { replace: false } );
889894

890895
this.$el.fadeIn( 200, function() {
891896
$body.addClass( 'theme-installer-active full-overlay-active' );
@@ -1431,6 +1436,9 @@ themes.Run = {
14311436
this.view.render();
14321437
this.routes();
14331438

1439+
if ( Backbone.History.started ) {
1440+
Backbone.history.stop();
1441+
}
14341442
Backbone.history.start({
14351443
root: themes.data.settings.adminUrl,
14361444
pushState: true,
@@ -1884,6 +1892,9 @@ themes.RunInstaller = {
18841892
this.view.render();
18851893
this.routes();
18861894

1895+
if ( Backbone.History.started ) {
1896+
Backbone.history.stop();
1897+
}
18871898
Backbone.history.start({
18881899
root: themes.data.settings.adminUrl,
18891900
pushState: true,
@@ -1902,11 +1913,24 @@ themes.RunInstaller = {
19021913
// Handles `theme` route event
19031914
// Queries the API for the passed theme slug
19041915
themes.router.on( 'route:preview', function( slug ) {
1905-
request.theme = slug;
1906-
self.view.collection.query( request );
1907-
self.view.collection.once( 'update', function() {
1916+
1917+
// If the theme preview is active, set the current theme.
1918+
if ( self.view.view.theme && self.view.view.theme.preview ) {
1919+
self.view.view.theme.model = self.view.collection.findWhere( { 'slug': slug } );
19081920
self.view.view.theme.preview();
1909-
});
1921+
} else {
1922+
1923+
// Select the theme by slug.
1924+
request.theme = slug;
1925+
self.view.collection.query( request );
1926+
self.view.collection.trigger( 'update' );
1927+
1928+
// Open the theme preview.
1929+
self.view.collection.once( 'query:success', function() {
1930+
$( 'div[data-slug="' + slug + '"]' ).trigger( 'click' );
1931+
});
1932+
1933+
}
19101934
});
19111935

19121936
// Handles sorting / browsing routes
@@ -1917,7 +1941,11 @@ themes.RunInstaller = {
19171941
sort = 'featured';
19181942
}
19191943
self.view.sort( sort );
1920-
self.view.trigger( 'theme:close' );
1944+
1945+
// Close the preview if open.
1946+
if ( themes.currentPreview ) {
1947+
themes.currentPreview.trigger( 'closepreview' );
1948+
}
19211949
});
19221950

19231951
// The `search` route event. The router populates the input field.

src/wp-includes/class-wp-image-editor-imagick.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,11 @@ public function rotate( $angle ) {
549549
try {
550550
$this->image->rotateImage( new ImagickPixel('none'), 360-$angle );
551551

552+
// Normalise Exif orientation data so that display is consistent across devices.
553+
if ( is_callable( array( $this->image, 'setImageOrientation' ) ) && defined( 'Imagick::ORIENTATION_TOPLEFT' ) ) {
554+
$this->image->setImageOrientation( Imagick::ORIENTATION_TOPLEFT );
555+
}
556+
552557
// Since this changes the dimensions of the image, update the size.
553558
$result = $this->update_size();
554559
if ( is_wp_error( $result ) )

src/wp-includes/class-wp-network.php

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,6 @@ private function _set_cookie_domain() {
267267
* @return WP_Network|bool Network object if successful. False when no network is found.
268268
*/
269269
public static function get_by_path( $domain = '', $path = '', $segments = null ) {
270-
global $wpdb;
271-
272270
$domains = array( $domain );
273271
$pieces = explode( '.', $domain );
274272

@@ -295,7 +293,11 @@ public static function get_by_path( $domain = '', $path = '', $segments = null )
295293
if ( wp_using_ext_object_cache() ) {
296294
$using_paths = wp_cache_get( 'networks_have_paths', 'site-options' );
297295
if ( false === $using_paths ) {
298-
$using_paths = (int) $wpdb->get_var( "SELECT id FROM {$wpdb->site} WHERE path <> '/' LIMIT 1" );
296+
$using_paths = get_networks( array(
297+
'number' => 1,
298+
'count' => true,
299+
'path__not_in' => '/',
300+
) );
299301
wp_cache_add( 'networks_have_paths', $using_paths, 'site-options' );
300302
}
301303
}
@@ -353,35 +355,31 @@ public static function get_by_path( $domain = '', $path = '', $segments = null )
353355
return $pre;
354356
}
355357

356-
// @todo Consider additional optimization routes, perhaps as an opt-in for plugins.
357-
// We already have paths covered. What about how far domains should be drilled down (including www)?
358-
359-
$search_domains = "'" . implode( "', '", $wpdb->_escape( $domains ) ) . "'";
360-
361358
if ( ! $using_paths ) {
362-
$network = $wpdb->get_row( "
363-
SELECT * FROM {$wpdb->site}
364-
WHERE domain IN ({$search_domains})
365-
ORDER BY CHAR_LENGTH(domain)
366-
DESC LIMIT 1
367-
" );
368-
369-
if ( ! empty( $network ) && ! is_wp_error( $network ) ) {
370-
return new WP_Network( $network );
359+
$networks = get_networks( array(
360+
'number' => 1,
361+
'orderby' => array(
362+
'domain_length' => 'DESC',
363+
),
364+
'domain__in' => $domains,
365+
) );
366+
367+
if ( ! empty( $networks ) ) {
368+
return array_shift( $networks );
371369
}
372370

373371
return false;
374-
375-
} else {
376-
$search_paths = "'" . implode( "', '", $wpdb->_escape( $paths ) ) . "'";
377-
$networks = $wpdb->get_results( "
378-
SELECT * FROM {$wpdb->site}
379-
WHERE domain IN ({$search_domains})
380-
AND path IN ({$search_paths})
381-
ORDER BY CHAR_LENGTH(domain) DESC, CHAR_LENGTH(path) DESC
382-
" );
383372
}
384373

374+
$networks = get_networks( array(
375+
'orderby' => array(
376+
'domain_length' => 'DESC',
377+
'path_length' => 'DESC',
378+
),
379+
'domain__in' => $domains,
380+
'path__in' => $paths,
381+
) );
382+
385383
/*
386384
* Domains are sorted by length of domain, then by length of path.
387385
* The domain must match for the path to be considered. Otherwise,
@@ -402,7 +400,7 @@ public static function get_by_path( $domain = '', $path = '', $segments = null )
402400
}
403401

404402
if ( true === $found ) {
405-
return new WP_Network( $network );
403+
return $network;
406404
}
407405

408406
return false;

src/wp-includes/class-wp-query.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3872,7 +3872,8 @@ public function is_single( $post = '' ) {
38723872
}
38733873

38743874
/**
3875-
* Is the query for an existing single post of any post type (post, attachment, page, ... )?
3875+
* Is the query for an existing single post of any post type (post, attachment, page,
3876+
* custom post types)?
38763877
*
38773878
* If the $post_types parameter is specified, this function will additionally
38783879
* check if the query is for one of the Posts Types specified.

0 commit comments

Comments
 (0)