Jetpack_Sync_Module_Attachments

The WordPress Core Jetpack Sync Module Attachments class.

Defined (1)

The class is defined in the following location(s).

/sync/class.jetpack-sync-module-attachments.php  
  1. class Jetpack_Sync_Module_Attachments extends Jetpack_Sync_Module { 
  2. function name() { 
  3. return 'attachments'; 
  4.  
  5. public function init_listeners( $callable ) { 
  6. add_action( 'edit_attachment', array( $this, 'send_attachment_info' ) ); 
  7. // Once we don't have to support 4.3 we can start using add_action( 'attachment_updated', $handler, 10, 3 ); instead 
  8. add_action( 'add_attachment', array( $this, 'send_attachment_info' ) ); 
  9. add_action( 'jetpack_sync_save_update_attachment', $callable, 10, 2 ); 
  10. add_action( 'jetpack_sync_save_add_attachment', $callable, 10, 2 ); 
  11.  
  12. function send_attachment_info( $attachment_id ) { 
  13. $attachment = get_post( $attachment_id ); 
  14. if ( 'add_attachment' === current_filter() ) { 
  15. /** 
  16. * Fires when the client needs to sync an new attachment 
  17. * @since 4.2.0 
  18. * @param int The attachment ID 
  19. * @param object The attachment 
  20. */ 
  21. do_action( 'jetpack_sync_save_add_attachment', $attachment_id, $attachment ); 
  22. } else { 
  23. /** 
  24. * Fires when the client needs to sync an updated attachment 
  25. * @since 4.9.0 
  26. * @param int The attachment ID 
  27. * @param object The attachment 
  28. * Previously this action was synced using jetpack_sync_save_add_attachment action. 
  29. */ 
  30. do_action( 'jetpack_sync_save_update_attachment', $attachment_id, $attachment ); 
  31.