Forked from fdaciuk/send_mail_post_pending.php
Last active
December 11, 2015 08:48
-
-
Save gugaalves/4575609 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Enviar e-mail para o administrador se houver posts para revisão | |
Dica do @GugaAlves: incluir link para a edição do post no admin, facilitando a vida do admin que receber este email. | |
Dica do Gustavo Bordoni (@webord): incluir na função o $post (objeto para WP_Query) para não ficar passando o $post_id a cada save. | |
Dica do Manoel Netto: Incluir a verificação "! wp_is_post_revision( $post )" para não enviar e-mail a cada auto save. | |
*/ | |
function send_mail_post_pending( $post_id, $post ) { | |
$post_status = get_post_status( $post ); | |
if( $post_status === 'pending' && ! wp_is_post_revision( $post ) ) { | |
$email = get_option( 'admin_email' ); | |
$subject = '[REVISAR NOVO POST] ' . get_the_title( $post_id ); | |
$message = 'Existe um novo post para revisão: ' . get_the_title( $post_id ) . "\n\n"; | |
$message .= 'Revisar o post: ' . admin_url() . 'post.php?post=' . $post_id . '&action=edit'; | |
wp_mail( $email, $subject, $message ); | |
} | |
} | |
add_action( 'save_post', 'send_mail_post_pending', 10, 2 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment