2017-06-04 52 views
1

每次我使用wordpress中的文章编辑器中的保存按钮,我的浏览器问我是否要离开页面。WordPress的保存按钮正在做一些奇怪的事

我有几个插件安装,我正在开发一个新的。在使用wordpress之前,我从来没有遇到过这种情况。

我使用wp_insert_post钩子每次保存帖子/页面时都会执行一些操作。

编辑1

我每次更新一个帖子,浏览器显示我的警告,告诉我如果我要离开这个页面。我发现,导致此警报的插件显示它是YOAST。

您可以请一个手,告诉我该怎么做才能解决这个问题?

感谢,

伊斯梅尔

+0

当您禁用所有插件(包括正在开发的插件)时,问题是否仍然存在? –

+0

我发现了导致此问题的插件,但我不知道如何解决此问题。 –

回答

1

为了每次在WordPress发布或更新后,你必须使用save_post时间做一些事情:如果你想发送一封电子邮件每次

例如时间在您的网站上更新信息或页面。

function my_project_updated_send_email($post_id) { 

    // If this is just a revision, don't send the email. 
    if (wp_is_post_revision($post_id)) 
     return; 

    $post_title = get_the_title($post_id); 
    $post_url = get_permalink($post_id); 
    $subject = 'A post has been updated'; 

    $message = "A post has been updated on your website:\n\n"; 
    $message .= $post_title . ": " . $post_url; 

    // Send email to admin. 
    wp_mail('[email protected]', $subject, $message); 

} 
add_action('save_post', 'my_project_updated_send_email'); 
+0

我放弃了这个钩子,因为它不适用于我使用的库。 –

+0

我可以知道你的库或者你想实现什么,'wp_insert_post'不是钩子,@IsmaelMoral –

+0

我使用'Timber'来启用WordPress内核中的树枝,'wp_insert_post'是一个钩子https: //developer.wordpress.org/reference/hooks/wp_insert_post/ –