Ticket #50781: 50781.3.patch
File 50781.3.patch, 1.5 KB (added by , 4 years ago) |
---|
-
src/wp-includes/class-wp-customize-manager.php
492 492 493 493 return '_default_wp_die_handler'; 494 494 } 495 /** 496 * Redirects a URL to the 404 page if changeset UUID does not exists 497 * 498 * @since 5.6.0 499 * 500 * @param bool $bypass Pass-through of the pre_handle_404 filter value. 501 * @param WP_Query $query The WP_Query object. 502 * @return bool Bypass value. 503 */ 504 public function customize_changeset_preview_redirect( $bypass, $query ) { 505 // If a theme/plugin has already utilized the pre_handle_404 function, return without action to avoid conflicts. 506 if ( $bypass ) { 507 return $bypass; 508 } 495 509 510 $query->set_404(); 511 status_header( 404 ); 512 return $bypass; 513 } 496 514 /** 497 515 * Start preview and customize theme. 498 516 * … … 521 539 522 540 // If a changeset was provided is invalid. 523 541 if ( isset( $this->_changeset_uuid ) && false !== $this->_changeset_uuid && ! wp_is_uuid( $this->_changeset_uuid ) ) { 542 if ( ! current_user_can( 'customize' ) && ! $this->changeset_post_id() ) { //Adding pre_handle_404 for unauthenticated Invalid changeset UUID 543 add_filter( 'pre_handle_404', array( $this, 'customize_changeset_preview_redirect' ), 10, 2 ); 544 } else { 524 545 $this->wp_die( -1, __( 'Invalid changeset UUID' ) ); 546 } 525 547 } 526 548 527 549 /*