Inventory_Presser_Admin_Photo_Arranger::safe_update_post( WP_Post $post )

Removes our edit_post_{post-type} hooks, calls wp_update_post(), and re-adds the hooks.


Parameters Parameters

$post

(WP_Post) (Required) The post to update.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/admin/class-admin-photo-arranger.php

	protected function safe_update_post( $post ) {

		// Do not allow inserts!
		if ( 0 === $post->ID ) {
			return;
		}

		// Don't cause hooks to fire themselves.
		remove_action( 'edit_post_' . INVP::POST_TYPE, array( $this, 'change_parents_and_sequence' ), 10, 2 );
		remove_action( 'edit_post_' . INVP::POST_TYPE, array( $this, 'unattach_when_removed' ), 10, 2 );

		wp_update_post( $post );

		// Re-add the hooks now that we're done making changes.
		add_action( 'edit_post_' . INVP::POST_TYPE, array( $this, 'change_parents_and_sequence' ), 10, 2 );
		add_action( 'edit_post_' . INVP::POST_TYPE, array( $this, 'unattach_when_removed' ), 10, 2 );
	}