Completed
Push — fix/inline-docs-410 ( f96891...63b75c )
by
unknown
43:24 queued 33:40
created

Jetpack_Sync_Module_Attachments   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 3
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 3 1
A init_listeners() 0 6 1
A send_attachment_info() 0 13 1
1
<?php
2
3
class Jetpack_Sync_Module_Attachments extends Jetpack_Sync_Module {
4
	function name() {
5
		return "attachments";
6
	}
7
8
	public function init_listeners( $callable ) {
9
		add_action( 'edit_attachment', array( $this, 'send_attachment_info' ) );
10
		// Once we don't have to support 4.3 we can start using add_action( 'attachment_updated', $handler, 10, 3 ); instead
11
		add_action( 'add_attachment', array( $this, 'send_attachment_info' ) );
12
		add_action( 'jetpack_sync_save_add_attachment', $callable, 10, 2 );
13
	}
14
15
	function send_attachment_info( $attachment_id ) {
16
		$attachment = get_post( $attachment_id );
17
18
		/**
19
		 * Fires when the client needs to sync an attachment for a post
20
		 *
21
		 * @since 4.2.0
22
		 *
23
		 * @param int The attachment ID
24
		 * @param object The attachment
25
		 */
26
		do_action( 'jetpack_sync_save_add_attachment', $attachment_id, $attachment );
27
	}
28
}