Make WordPress Core

Ticket #50781: 50781.3.patch

File 50781.3.patch, 1.5 KB (added by sumanm, 4 years ago)

added additional check for a theme or plugin has made changes

  • src/wp-includes/class-wp-customize-manager.php

     
    492492
    493493                return '_default_wp_die_handler';
    494494        }
     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                }
    495509
     510                $query->set_404();
     511                status_header( 404 );
     512                return $bypass;
     513        }
    496514        /**
    497515         * Start preview and customize theme.
    498516         *
     
    521539
    522540                // If a changeset was provided is invalid.
    523541                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 {
    524545                        $this->wp_die( -1, __( 'Invalid changeset UUID' ) );
     546                    }
    525547                }
    526548
    527549                /*