
如何实现WordPress网站降级(用于解决插件和主题问题)
wp_filter_global_styles_post ( $data )
wp_filter_global_styles_post:当全局样式被添加到一个文章时,这个动作钩子被调用。开发人员可以使用这个钩子来修改或删除应用于文章的全局样式。
净化全局样式的用户内容,去除不安全的规则。
function wp_filter_global_styles_post( $data ) { $decoded_data = json_decode( wp_unslash( $data ), true ); $json_decoding_error = json_last_error(); if ( JSON_ERROR_NONE === $json_decoding_error && is_array( $decoded_data ) && isset( $decoded_data['isGlobalStylesUserThemeJSON'] ) && $decoded_data['isGlobalStylesUserThemeJSON'] ) { unset( $decoded_data['isGlobalStylesUserThemeJSON'] ); $data_to_encode = WP_Theme_JSON::remove_insecure_properties( $decoded_data ); $data_to_encode['isGlobalStylesUserThemeJSON'] = true; return wp_slash( wp_json_encode( $data_to_encode ) ); } return $data; }