- Timestamp:
- 04/29/2020 04:04:20 PM (6 years ago)
- Location:
- branches/5.3
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/wp-includes/class-wp-customize-manager.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/5.3
- Property svn:mergeinfo changed
/trunk merged: 47633-47638
- Property svn:mergeinfo changed
-
branches/5.3/src/wp-includes/class-wp-customize-manager.php
r46548 r47644 2924 2924 2925 2925 /* 2926 * Update the changeset post. The publish_customize_changeset action 2927 * will cause the settings in the changeset to be saved via2928 * WP_Customize_Setting::save().2926 * Update the changeset post. The publish_customize_changeset action will cause the settings in the 2927 * changeset to be saved via WP_Customize_Setting::save(). Updating a post with publish status will 2928 * trigger WP_Customize_Manager::publish_changeset_values(). 2929 2929 */ 2930 2931 // Prevent content filters from corrupting JSON in post_content. 2932 $has_kses = ( false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' ) ); 2933 if ( $has_kses ) { 2934 kses_remove_filters(); 2935 } 2936 $has_targeted_link_rel_filters = ( false !== has_filter( 'content_save_pre', 'wp_targeted_link_rel' ) ); 2937 if ( $has_targeted_link_rel_filters ) { 2938 wp_remove_targeted_link_rel_filters(); 2939 } 2940 2941 // Note that updating a post with publish status will trigger WP_Customize_Manager::publish_changeset_values(). 2930 add_filter( 'wp_insert_post_data', array( $this, 'preserve_insert_changeset_post_content' ), 5, 3 ); 2942 2931 if ( $changeset_post_id ) { 2943 2932 if ( $args['autosave'] && 'auto-draft' !== get_post_status( $changeset_post_id ) ) { … … 2966 2955 } 2967 2956 } 2968 2969 // Restore removed content filters. 2970 if ( $has_kses ) { 2971 kses_init_filters(); 2972 } 2973 if ( $has_targeted_link_rel_filters ) { 2974 wp_init_targeted_link_rel_filters(); 2975 } 2957 remove_filter( 'wp_insert_post_data', array( $this, 'preserve_insert_changeset_post_content' ), 5 ); 2976 2958 2977 2959 $this->_changeset_data = null; // Reset so WP_Customize_Manager::changeset_data() will re-populate with updated contents. … … 2989 2971 2990 2972 return $response; 2973 } 2974 2975 /** 2976 * Preserve the initial JSON post_content passed to save into the post. 2977 * 2978 * This is needed to prevent KSES and other {@see 'content_save_pre'} filters 2979 * from corrupting JSON data. 2980 * 2981 * Note that WP_Customize_Manager::validate_setting_values() have already 2982 * run on the setting values being serialized as JSON into the post content 2983 * so it is pre-sanitized. 2984 * 2985 * Also, the sanitization logic is re-run through the respective 2986 * WP_Customize_Setting::sanitize() method when being read out of the 2987 * changeset, via WP_Customize_Manager::post_value(), and this sanitized 2988 * value will also be sent into WP_Customize_Setting::update() for 2989 * persisting to the DB. 2990 * 2991 * Multiple users can collaborate on a single changeset, where one user may 2992 * have the unfiltered_html capability but another may not. A user with 2993 * unfiltered_html may add a script tag to some field which needs to be kept 2994 * intact even when another user updates the changeset to modify another field 2995 * when they do not have unfiltered_html. 2996 * 2997 * @since 5.4.1 2998 * 2999 * @param array $data An array of slashed and processed post data. 3000 * @param array $postarr An array of sanitized (and slashed) but otherwise unmodified post data. 3001 * @param array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed post data as originally passed to wp_insert_post(). 3002 * @return array Filtered post data. 3003 */ 3004 public function preserve_insert_changeset_post_content( $data, $postarr, $unsanitized_postarr ) { 3005 if ( 3006 isset( $data['post_type'] ) && 3007 isset( $unsanitized_postarr['post_content'] ) && 3008 'customize_changeset' === $data['post_type'] || 3009 ( 3010 'revision' === $data['post_type'] && 3011 ! empty( $data['post_parent'] ) && 3012 'customize_changeset' === get_post_type( $data['post_parent'] ) 3013 ) 3014 ) { 3015 $data['post_content'] = $unsanitized_postarr['post_content']; 3016 } 3017 return $data; 2991 3018 } 2992 3019
Note: See TracChangeset
for help on using the changeset viewer.