There is always a strange situation, that is, you cannot add videos to Wordpress.CodeAfter you add the video code in the text mode of the background editor, you can switch to the visualization mode to see the video box normally, but save the video code message.
After careful observation, it is found that the author cannot be added, but the editing and administrator can be added.
No appetite. First, let's talk about the solution: simply put it out, install a plug-in "User Role Editor", and check "Do not filter HTML tags" under the author role.
The following is a tossing process:
1. debug, the following code call sequence is found:
Wp_update_post->
Wp_insert_post->
Sanitize_post->
Sanitize_post_field->
2.Call in sanitize_post_field
$ Value = apply_filters ("{$ field_no_prefix} _ save_pre", $ value );
Filter calledContent_save_pre.
After searching this string, it is loaded in the core function kses_init_filters, as shown below:
Add_filter ('content _ save_pre ','Wp_filter_post_kses');.
It is loaded in kses_init_filters.
It is finally called by the following code:
Function kses_init (){
Kses_remove_filters ();
If (Current_user_can ('unfiltered _ HTML ')= False)
Kses_init_filterS ();
}
Add_action ('init ', 'kses _ init ');
Add_action ('set _ CURRENT_USER ', 'kses _ init ');
At this time, it is found that the current user does not have the unfilter_html permission.
Solution
1. TryWp_filter_post_kses is removed using the remove_filter function, but this shows a problem of the sequential relationship between add_filter and remove_filter,I added remove_filter before add_filter.
In this way, even if you find a clever place to add the remove feature, it is too dependent on this successive relationship to ensure that no one is confused.
2. Grant the user the pre-unfilter_html permission directly. The disadvantage is thatKses_init_filterAll the functions in S are deleted. Considering that this is my blog, the author is a designated person, and the solution is easy to understand. If there are not so many bypasses, I decided to use this method.
WordPress is so powerful that it is really tough.