Completed
Push — develop ( d86f0d...0a9e6f )
by David
03:31
created

Wordlift_Uri_Service::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Define the {@link Wordlift_Uri_Service} responsible for managing entity URIs
4
 * (for posts, entities, authors, ...).
5
 */
6
7
/**
8
 */
9
class Wordlift_Uri_Service {
10
11
	/**
12
	 * A {@link Wordlift_Log_Service} instance.
13
	 *
14
	 * @since 3.6.0
15
	 * @access private
16
	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
17
	 */
18
	private $log;
19
20
	/**
21
	 * The global WordPress database connection.
22
	 *
23
	 * @since 3.6.0
24
	 * @access private
25
	 * @var \wpdb $wpdb The global WordPress database connection.
26
	 */
27
	private $wpdb;
28
29
	/**
30
	 * Create an instance of Wordlift_Uri_Service.
31
	 *
32
	 * @since 3.6.0
33
	 *
34
	 * @param wpdb $wpdb The global WordPress database connection.
35
	 */
36
	public function __construct( $wpdb ) {
37
38
		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Uri_Service' );
39
40
		$this->wpdb = $wpdb;
41
42
	}
43
44
	/**
45
	 * Delete all generated URIs from the database.
46
	 *
47
	 * @since 3.6.0
48
	 */
49
	public function delete_all() {
50
51
		// Delete URIs associated with posts/entities.
52
		$this->wpdb->delete( $this->wpdb->postmeta, array( 'meta_key' => 'entity_url' ) );
53
54
		// Delete URIs associated with authors.
55
		$this->wpdb->delete( $this->wpdb->usermeta, array( 'meta_key' => '_wl_uri' ) );
56
57
	}
58
59
}
60