wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema



block_core_calendar_update_has_published_post_on_transition_post_status › WordPress Function

Desden/a
Obsoleton/a
block_core_calendar_update_has_published_post_on_transition_post_status ( $new_status, $old_status, $post )
Parâmetros: (3)
  • (string) $new_status The status the post is changing to.
    Required: Yes
  • (string) $old_status The status the post is changing from.
    Required: Yes
  • (WP_Post) $post Post object.
    Required: Yes
Definido em:
Codex:

Handler for updating the has published posts flag when a post status changes.



Fonte

function block_core_calendar_update_has_published_post_on_transition_post_status( $new_status, $old_status, $post ) {
		if ( $new_status === $old_status ) {
			return;
		}

		if ( 'post' !== get_post_type( $post ) ) {
			return;
		}

		if ( 'publish' !== $new_status && 'publish' !== $old_status ) {
			return;
		}

		block_core_calendar_update_has_published_posts();
	}

	add_action( 'delete_post', 'block_core_calendar_update_has_published_post_on_delete' );
	add_action( 'transition_post_status', 'block_core_calendar_update_has_published_post_on_transition_post_status', 10, 3 );
}