- Timestamp:
- 04/29/2020 04:18:07 PM (6 years ago)
- Location:
- branches/4.8
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/wp-includes/class-wp-customize-manager.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/4.8
- Property svn:mergeinfo changed
/trunk merged: 47633-47635,47637-47638
- Property svn:mergeinfo changed
-
branches/4.8/src/wp-includes/class-wp-customize-manager.php
r41429 r47649 2528 2528 add_filter( 'wp_save_post_revision_post_has_changed', array( $this, '_filter_revision_post_has_changed' ), 5, 3 ); 2529 2529 2530 // Update the changeset post. The publish_customize_changeset action will cause the settings in the changeset to be saved via WP_Customize_Setting::save(). 2531 $has_kses = ( false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' ) ); 2532 if ( $has_kses ) { 2533 kses_remove_filters(); // Prevent KSES from corrupting JSON in post_content. 2534 } 2535 2536 // Note that updating a post with publish status will trigger WP_Customize_Manager::publish_changeset_values(). 2530 /* 2531 * Update the changeset post. The publish_customize_changeset action will cause the settings in the 2532 * changeset to be saved via WP_Customize_Setting::save(). Updating a post with publish status will 2533 * trigger WP_Customize_Manager::publish_changeset_values(). 2534 */ 2535 add_filter( 'wp_insert_post_data', array( $this, 'preserve_insert_changeset_post_content' ), 5, 3 ); 2537 2536 if ( $changeset_post_id ) { 2538 2537 $post_array['edit_date'] = true; // Prevent date clearing. … … 2544 2543 } 2545 2544 } 2546 if ( $has_kses ) { 2547 kses_init_filters();2548 } 2545 2546 remove_filter( 'wp_insert_post_data', array( $this, 'preserve_insert_changeset_post_content' ), 5 ); 2547 2549 2548 $this->_changeset_data = null; // Reset so WP_Customize_Manager::changeset_data() will re-populate with updated contents. 2550 2549 … … 2561 2560 2562 2561 return $response; 2562 } 2563 2564 /** 2565 * Preserve the initial JSON post_content passed to save into the post. 2566 * 2567 * This is needed to prevent KSES and other {@see 'content_save_pre'} filters 2568 * from corrupting JSON data. 2569 * 2570 * Note that WP_Customize_Manager::validate_setting_values() have already 2571 * run on the setting values being serialized as JSON into the post content 2572 * so it is pre-sanitized. 2573 * 2574 * Also, the sanitization logic is re-run through the respective 2575 * WP_Customize_Setting::sanitize() method when being read out of the 2576 * changeset, via WP_Customize_Manager::post_value(), and this sanitized 2577 * value will also be sent into WP_Customize_Setting::update() for 2578 * persisting to the DB. 2579 * 2580 * Multiple users can collaborate on a single changeset, where one user may 2581 * have the unfiltered_html capability but another may not. A user with 2582 * unfiltered_html may add a script tag to some field which needs to be kept 2583 * intact even when another user updates the changeset to modify another field 2584 * when they do not have unfiltered_html. 2585 * 2586 * @since 5.4.1 2587 * 2588 * @param array $data An array of slashed and processed post data. 2589 * @param array $postarr An array of sanitized (and slashed) but otherwise unmodified post data. 2590 * @param array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed post data as originally passed to wp_insert_post(). 2591 * @return array Filtered post data. 2592 */ 2593 public function preserve_insert_changeset_post_content( $data, $postarr, $unsanitized_postarr ) { 2594 if ( 2595 isset( $data['post_type'] ) && 2596 isset( $unsanitized_postarr['post_content'] ) && 2597 'customize_changeset' === $data['post_type'] || 2598 ( 2599 'revision' === $data['post_type'] && 2600 ! empty( $data['post_parent'] ) && 2601 'customize_changeset' === get_post_type( $data['post_parent'] ) 2602 ) 2603 ) { 2604 $data['post_content'] = $unsanitized_postarr['post_content']; 2605 } 2606 return $data; 2563 2607 } 2564 2608
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)