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