Skip to content

Instantly share code, notes, and snippets.

@avillegasn
Last active October 19, 2015 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avillegasn/cb1bd3bff7ccb2944591 to your computer and use it in GitHub Desktop.
Save avillegasn/cb1bd3bff7ccb2944591 to your computer and use it in GitHub Desktop.
<?php
function notifica_al_autor( $ID, $post ) {
$autor = $post->post_author; /* ID del autor */
$nombre = get_the_author_meta( 'display_name', $autor );
$email = get_the_author_meta( 'user_email', $autor );
$titulo = $post->post_title;
$enlace = get_permalink( $ID );
$destinatario[] = sprintf( '%s <%s>', $nombre, $email );
$asunto = sprintf( 'Entrada Publicada: %s', $titulo );
$mensaje = sprintf ('¡Felicidades, %s! Tu entrada “%s” has sido publicada.' . "\n\n", $nombre, $titulo );
$mensaje .= sprintf( 'Ver: %s', $enlace );
$cabeceras[] = '';
wp_mail( $destinatario, $asunto, $mensaje, $cabeceras );
}
add_action( 'publish_post', 'notifica_al_autor', 10, 2 );
?>
<?php
function incluye_exclusiva( $title, $id = null ) {
if ( in_category( 'Exclusiva', $id ) ) {
return '¡Exclusiva! '.title;
}
return $title;
}
add_filter( 'the_title', 'incluye_exclusiva', 10, 2 );
?>
<?php
remove_action( 'publish_post', 'notifica_al_autor' );
remove_filter( 'the_title', 'incluye_exclusiva' );
?>
<?php
function mi_funcion () {
// ell código que queramos
}
add_action( 'nombre_del_hook', 'mi_funcion', [prioridad], [parametros] );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment