Last active
May 10, 2016 08:24
-
-
Save avillegasn/ef17cfa7017a885643720f9f1cfd554f 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 // 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