Inventory_Presser_Admin_Photo_Arranger::add_hooks()
Adds hooks that power the feature.
Return Return
(void)
Source Source
File: includes/admin/class-admin-photo-arranger.php
public function add_hooks() {
if ( ! self::is_enabled() ) {
return;
}
// Make sure all attachment IDs are stored in the Gallery block when photos are attached, detached, or deleted.
add_action( 'add_attachment', array( $this, 'add_attachment_to_gallery' ), 11, 1 );
add_action( 'delete_attachment', array( $this, 'delete_attachment_handler' ), 10, 2 );
add_action( 'wp_media_attach_action', array( $this, 'maintain_gallery_during_attach_and_detach' ), 10, 3 );
// When a vehicle is saved, the gallery should be examined and...
// - change their post_parent values to the vehicle post ID
// - make sure they have sequence numbers and VINs
// - update all the sequence numbers to match the gallery order.
add_action( 'edit_post_' . INVP::POST_TYPE, array( $this, 'change_parents_and_sequence' ), 10, 2 );
// - unattach photos that are no longer in the gallery
add_action( 'edit_post_' . INVP::POST_TYPE, array( $this, 'unattach_when_removed' ), 10, 2 );
/**
* When the vehicle is opened in the block editor, make sure the
* gallery block is there waiting for the user.
*/
add_action( 'the_post', array( $this, 'create_gallery' ), 10, 1 );
}
Expand full source codeCollapse full source codeView on Github