WordPress(Gutenberg)块编辑器从嵌入的代理端点请求数据,该端点使用Transients API. 似乎清除所有oembed缓存并不能同时清除oembed临时缓存。
以下数据库查询无法从Posteta表中清除oembed缓存:
global $wpdb;
$meta_key_1 = "|_oembed|_%%";
$meta_key_2 = "|_oembed|_time|_%%";
$wpdb->query(
$query = $wpdb->prepare(
"DELETE FROM `".$wpdb->postmeta."`
WHERE `meta_key` LIKE %s ESCAPE \'|\'
OR `meta_key` LIKE %s ESCAPE \'|\'",
$meta_key_1,
$meta_key_2
)
);
您还需要从选项表中清除临时缓存,如下所示:
$option_name_1 = "|_transient|_oembed|_%%";
$option_name_2 = "|_transient|_timeout|_oembed|_%%";
$wpdb->query(
$query = $wpdb->prepare(
"DELETE FROM `".$wpdb->options."`
WHERE `option_name` LIKE %s ESCAPE \'|\'
OR `option_name` LIKE %s ESCAPE \'|\'",
$option_name_1,
$option_name_2
)
);