Skip to content

Instantly share code, notes, and snippets.

@avillegasn
Last active May 10, 2016 08:24
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/ef17cfa7017a885643720f9f1cfd554f to your computer and use it in GitHub Desktop.
Save avillegasn/ef17cfa7017a885643720f9f1cfd554f to your computer and use it in GitHub Desktop.
<?php // no copies esta línea
add_action( 'transition_post_status', 'comprueba_publicacion', 10, 3 );
function comprueba_publicacion( $new_status, $old_status, $post ) {
if ( 'publish' === $new_status ) {
// Comprueba que existe una imagen destacada
if ( !tiene_imagen_destacada( $post ) ) {
wp_die( 'Has olvidado incluir una imagen destacada.' );
}
// Comprueba que tiene etiquetas
if ( !tiene_etiquetas( $post ) ) {
wp_die( 'Has olvidado poner etiquetas.' );
}
// ... añade más condiciones aquí si quieres
}
}
function tiene_imagen_destacada( $post ) {
return has_post_thumbnail( $post );
}
function tiene_etiquetas( $post ) {
return has_tag( '', $post );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment