- Timestamp:
- 04/29/2020 04:05:32 PM (6 years ago)
- Location:
- branches/5.2
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/wp-includes/class-wp-customize-manager.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/5.2
- Property svn:mergeinfo changed
/trunk merged: 47633-47638
- Property svn:mergeinfo changed
-
branches/5.2/src/wp-includes/class-wp-customize-manager.php
r45232 r47645 2887 2887 2888 2888 /* 2889 * Update the changeset post. The publish_customize_changeset action 2890 * will cause the settings in the changeset to be saved via2891 * WP_Customize_Setting::save().2889 * Update the changeset post. The publish_customize_changeset action will cause the settings in the 2890 * changeset to be saved via WP_Customize_Setting::save(). Updating a post with publish status will 2891 * trigger WP_Customize_Manager::publish_changeset_values(). 2892 2892 */ 2893 2894 // Prevent content filters from corrupting JSON in post_content. 2895 $has_kses = ( false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' ) ); 2896 if ( $has_kses ) { 2897 kses_remove_filters(); 2898 } 2899 $has_targeted_link_rel_filters = ( false !== has_filter( 'content_save_pre', 'wp_targeted_link_rel' ) ); 2900 if ( $has_targeted_link_rel_filters ) { 2901 wp_remove_targeted_link_rel_filters(); 2902 } 2903 2904 // Note that updating a post with publish status will trigger WP_Customize_Manager::publish_changeset_values(). 2893 add_filter( 'wp_insert_post_data', array( $this, 'preserve_insert_changeset_post_content' ), 5, 3 ); 2905 2894 if ( $changeset_post_id ) { 2906 2895 if ( $args['autosave'] && 'auto-draft' !== get_post_status( $changeset_post_id ) ) { … … 2929 2918 } 2930 2919 } 2931 2932 // Restore removed content filters. 2933 if ( $has_kses ) { 2934 kses_init_filters(); 2935 } 2936 if ( $has_targeted_link_rel_filters ) { 2937 wp_init_targeted_link_rel_filters(); 2938 } 2920 remove_filter( 'wp_insert_post_data', array( $this, 'preserve_insert_changeset_post_content' ), 5 ); 2939 2921 2940 2922 $this->_changeset_data = null; // Reset so WP_Customize_Manager::changeset_data() will re-populate with updated contents. … … 2952 2934 2953 2935 return $response; 2936 } 2937 2938 /** 2939 * Preserve the initial JSON post_content passed to save into the post. 2940 * 2941 * This is needed to prevent KSES and other {@see 'content_save_pre'} filters 2942 * from corrupting JSON data. 2943 * 2944 * Note that WP_Customize_Manager::validate_setting_values() have already 2945 * run on the setting values being serialized as JSON into the post content 2946 * so it is pre-sanitized. 2947 * 2948 * Also, the sanitization logic is re-run through the respective 2949 * WP_Customize_Setting::sanitize() method when being read out of the 2950 * changeset, via WP_Customize_Manager::post_value(), and this sanitized 2951 * value will also be sent into WP_Customize_Setting::update() for 2952 * persisting to the DB. 2953 * 2954 * Multiple users can collaborate on a single changeset, where one user may 2955 * have the unfiltered_html capability but another may not. A user with 2956 * unfiltered_html may add a script tag to some field which needs to be kept 2957 * intact even when another user updates the changeset to modify another field 2958 * when they do not have unfiltered_html. 2959 * 2960 * @since 5.4.1 2961 * 2962 * @param array $data An array of slashed and processed post data. 2963 * @param array $postarr An array of sanitized (and slashed) but otherwise unmodified post data. 2964 * @param array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed post data as originally passed to wp_insert_post(). 2965 * @return array Filtered post data. 2966 */ 2967 public function preserve_insert_changeset_post_content( $data, $postarr, $unsanitized_postarr ) { 2968 if ( 2969 isset( $data['post_type'] ) && 2970 isset( $unsanitized_postarr['post_content'] ) && 2971 'customize_changeset' === $data['post_type'] || 2972 ( 2973 'revision' === $data['post_type'] && 2974 ! empty( $data['post_parent'] ) && 2975 'customize_changeset' === get_post_type( $data['post_parent'] ) 2976 ) 2977 ) { 2978 $data['post_content'] = $unsanitized_postarr['post_content']; 2979 } 2980 return $data; 2954 2981 } 2955 2982
Note: See TracChangeset
for help on using the changeset viewer.