wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



block_core_calendar_update_has_published_post_on_transition_post_status › WordPress Function

Odn/a
Przestarzałyn/a
block_core_calendar_update_has_published_post_on_transition_post_status ( $new_status, $old_status, $post )
Parametry: (3)
  • (string) $new_status The status the post is changing to.
    Wymagane: Tak
  • (string) $old_status The status the post is changing from.
    Wymagane: Tak
  • (WP_Post) $post Post object.
    Wymagane: Tak
Zdefiniowane na:
Codex:

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



Źródło

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 );
}