Make WordPress Core

Ticket #45484: 45484.diff

File 45484.diff, 2.7 KB (added by timph, 6 years ago)
  • src/wp-includes/class-wp-customize-manager.php

     
    15231523
    15241524                // Options.
    15251525                foreach ( $options as $name => $value ) {
    1526                         if ( preg_match( '/^{{(?P<symbol>.+)}}$/', $value, $matches ) ) {
     1526
     1527                        // Serialize values for search.
     1528                        $value = maybe_serialize( $value );
     1529
     1530                        if ( preg_match( '/s:\d+:"{{(?P<symbol>.+)}}"/', $value, $matches ) ) {
    15271531                                if ( isset( $posts[ $matches['symbol'] ] ) ) {
    1528                                         $value = $posts[ $matches['symbol'] ]['ID'];
     1532                                        $symbol_match = $posts[ $matches['symbol'] ]['ID'];
    15291533                                } elseif ( isset( $attachment_ids[ $matches['symbol'] ] ) ) {
    1530                                         $value = $attachment_ids[ $matches['symbol'] ];
     1534                                        $symbol_match = $attachment_ids[ $matches['symbol'] ];
     1535                                }
     1536
     1537                                // If we have any symbol matches, update the values.
     1538                                if ( isset( $symbol_match ) ) {
     1539
     1540                                        // Replace found string matches with post ID ints.
     1541                                        $value = str_replace( $matches[0], "i:{$symbol_match}", $value );
    15311542                                } else {
    15321543                                        continue;
    15331544                                }
    15341545                        }
    15351546
     1547                        // Unserialize values after checking for post symbols, so they can be properly referenced.
     1548                        $value = maybe_unserialize( $value );
     1549
    15361550                        if ( empty( $changeset_data[ $name ] ) || ! empty( $changeset_data[ $name ]['starter_content'] ) ) {
    15371551                                $this->set_post_value( $name, $value );
    15381552                                $this->pending_starter_content_settings_ids[] = $name;
     
    15411555
    15421556                // Theme mods.
    15431557                foreach ( $theme_mods as $name => $value ) {
    1544                         if ( preg_match( '/^{{(?P<symbol>.+)}}$/', $value, $matches ) ) {
     1558
     1559                        // Serialize values for search.
     1560                        $value = maybe_serialize( $value );
     1561
     1562                        if ( preg_match( '/s:\d+:"{{(?P<symbol>.+)}}"/', $value, $matches ) ) {
    15451563                                if ( isset( $posts[ $matches['symbol'] ] ) ) {
    1546                                         $value = $posts[ $matches['symbol'] ]['ID'];
     1564                                        $symbol_match = $posts[ $matches['symbol'] ]['ID'];
    15471565                                } elseif ( isset( $attachment_ids[ $matches['symbol'] ] ) ) {
    1548                                         $value = $attachment_ids[ $matches['symbol'] ];
     1566                                        $symbol_match = $attachment_ids[ $matches['symbol'] ];
     1567                                }
     1568
     1569                                // If we have any symbol matches, update the values.
     1570                                if ( isset( $symbol_match ) ) {
     1571
     1572                                        // Replace found string matches with post ID ints.
     1573                                        $value = str_replace( $matches[0], "i:{$symbol_match}", $value );
    15491574                                } else {
    15501575                                        continue;
    15511576                                }
    15521577                        }
    15531578
     1579                        // Unserialize values after checking for post symbols, so they can be properly referenced.
     1580                        $value = maybe_unserialize( $value );
     1581
    15541582                        // Handle header image as special case since setting has a legacy format.
    15551583                        if ( 'header_image' === $name ) {
    15561584                                $name     = 'header_image_data';