Changeset 44714
- Timestamp:
- 01/29/2019 09:28:57 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-customize-manager.php
r44580 r44714 2886 2886 add_filter( 'wp_save_post_revision_post_has_changed', array( $this, '_filter_revision_post_has_changed' ), 5, 3 ); 2887 2887 2888 // Update the changeset post. The publish_customize_changeset action will cause the settings in the changeset to be saved via WP_Customize_Setting::save(). 2888 /* 2889 * Update the changeset post. The publish_customize_changeset action 2890 * will cause the settings in the changeset to be saved via 2891 * WP_Customize_Setting::save(). 2892 */ 2893 2894 // Prevent content filters from corrupting JSON in post_content. 2889 2895 $has_kses = ( false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' ) ); 2890 2896 if ( $has_kses ) { 2891 kses_remove_filters(); // Prevent KSES from corrupting JSON in post_content. 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(); 2892 2902 } 2893 2903 … … 2919 2929 } 2920 2930 } 2931 2932 // Restore removed content filters. 2921 2933 if ( $has_kses ) { 2922 2934 kses_init_filters(); 2923 2935 } 2936 if ( $has_targeted_link_rel_filters ) { 2937 wp_init_targeted_link_rel_filters(); 2938 } 2939 2924 2940 $this->_changeset_data = null; // Reset so WP_Customize_Manager::changeset_data() will re-populate with updated contents. 2925 2941 -
trunk/src/wp-includes/default-filters.php
r44157 r44714 129 129 130 130 // Add proper rel values for links with target. 131 foreach ( array( 132 'title_save_pre', 133 'content_save_pre', 134 'excerpt_save_pre', 135 'content_filtered_save_pre', 136 'pre_comment_content', 137 'pre_term_description', 138 'pre_link_description', 139 'pre_link_notes', 140 'pre_user_description', 141 ) as $filter ) { 142 add_filter( $filter, 'wp_targeted_link_rel' ); 143 }; 131 add_action( 'init', 'wp_init_targeted_link_rel_filters' ); 144 132 145 133 // Format strings for display. -
trunk/src/wp-includes/formatting.php
r44691 r44714 3097 3097 3098 3098 /** 3099 * Adds all filters modifying the rel attribute of targeted links. 3100 * 3101 * @since 5.1.0 3102 */ 3103 function wp_init_targeted_link_rel_filters() { 3104 $filters = array( 3105 'title_save_pre', 3106 'content_save_pre', 3107 'excerpt_save_pre', 3108 'content_filtered_save_pre', 3109 'pre_comment_content', 3110 'pre_term_description', 3111 'pre_link_description', 3112 'pre_link_notes', 3113 'pre_user_description', 3114 ); 3115 3116 foreach ( $filters as $filter ) { 3117 add_filter( $filter, 'wp_targeted_link_rel' ); 3118 }; 3119 } 3120 3121 /** 3122 * Removes all filters modifying the rel attribute of targeted links. 3123 * 3124 * @since 5.1.0 3125 */ 3126 function wp_remove_targeted_link_rel_filters() { 3127 $filters = array( 3128 'title_save_pre', 3129 'content_save_pre', 3130 'excerpt_save_pre', 3131 'content_filtered_save_pre', 3132 'pre_comment_content', 3133 'pre_term_description', 3134 'pre_link_description', 3135 'pre_link_notes', 3136 'pre_user_description', 3137 ); 3138 3139 foreach ( $filters as $filter ) { 3140 remove_filter( $filter, 'wp_targeted_link_rel' ); 3141 }; 3142 } 3143 3144 /** 3099 3145 * Convert one smiley code to the icon graphic file equivalent. 3100 3146 * -
trunk/tests/phpunit/tests/formatting/WPTargetedLinkRel.php
r44691 r44714 84 84 $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); 85 85 } 86 87 /** 88 * Ensure default content filters are added. 89 * 90 * @ticket 45292. 91 */ 92 public function test_wp_targeted_link_rel_filters_run() { 93 $content = '<p>Links: <a href="/" target="_blank">No rel</a></p>'; 94 $expected = '<p>Links: <a href="/" target="_blank" rel="noopener noreferrer">No rel</a></p>'; 95 96 $post = $this->factory()->post->create_and_get( 97 array( 98 'post_content' => $content, 99 ) 100 ); 101 102 $this->assertEquals( $expected, $post->post_content ); 103 } 86 104 }
Note: See TracChangeset
for help on using the changeset viewer.