Php 动态显示管理通知

Php 动态显示管理通知,php,wordpress,plugins,Php,Wordpress,Plugins,我想在编辑帖子文本时(保存帖子之前)显示管理员通知。我想管理员通知钩子在这里不起作用(它不适合我)。你知道如何显示一些错误消息来提醒用户帖子内容不会被接受吗 我更喜欢像管理员通知这样的内联显示,而不是可能被阻止的弹出窗口 跟随不起作用 function secure_oembed_filter($html, $url, $attr, $post_ID) { if (strlen($html) > 0 && strpos($html, "http://")) {

我想在编辑帖子文本时(保存帖子之前)显示管理员通知。我想管理员通知钩子在这里不起作用(它不适合我)。你知道如何显示一些错误消息来提醒用户帖子内容不会被接受吗

我更喜欢像管理员通知这样的内联显示,而不是可能被阻止的弹出窗口

跟随不起作用

function secure_oembed_filter($html, $url, $attr, $post_ID) {

    if (strlen($html) > 0 && strpos($html, "http://")) {
        //wp_die("Unsecure link in embeds", "Unsecured post");
    } else {
        add_action('admin_notices', array($this, 'show_error'));
    }
    return $html;
}

private function show_error () {

    echo '<div class="error"><p>This is an error</p></div>';
}
函数安全嵌入过滤器($html、$url、$attr、$post\u ID){
if(strlen($html)>0&&strpos($html,“http:/”){
//wp_die(“嵌入中的不安全链接”、“不安全的帖子”);
}否则{
添加动作('admin_notices',数组('this',show_error');
}
返回$html;
}
私有函数显示错误(){
回显“这是一个错误”

; }
在这种情况下,
wp\u remote\u get()
可以正常工作

创建一个notice.php文件并上传到我的服务器上

然后,我将这些代码添加到我的插件中,它对我很有用

<?php
$remote_data = wp_remote_get( 'http://example.com/notice.php' );
$remote_body = wp_remote_retrieve_datat( $remote_data );
?>

<div class="notice">
    <?php echo $remote_body ?>
</div>

希望有帮助