Completed
Push — master ( 1a5c7a...6c7ea1 )
by David
01:03 queued 12s
created
wordlift/content/wordpress/class-wordpress-post-content-table-service.php 2 patches
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -15,158 +15,158 @@
 block discarded – undo
15 15
 
16 16
 class Wordpress_Post_Content_Table_Service extends Abstract_Wordpress_Content_Service {
17 17
 
18
-	private static $instance = null;
19
-
20
-	/**
21
-	 * The singleton instance. We use this only to provide this instance to those classes where we have no access to
22
-	 * the constructor.
23
-	 *
24
-	 * @return Wordpress_Post_Content_Table_Service
25
-	 */
26
-	public static function get_instance() {
27
-
28
-		if ( ! isset( self::$instance ) ) {
29
-			self::$instance = new self();
30
-		}
31
-
32
-		return self::$instance;
33
-	}
34
-
35
-	/**
36
-	 * @param string $uri An absolute or relative URI. When absolute it must be within the dataset URI scope.
37
-	 *
38
-	 * @return Wordpress_Content|null
39
-	 * @throws Exception when the URI is not within the dataset URI.
40
-	 */
41
-	function get_by_entity_id( $uri ) {
42
-		Assertions::is_string( $uri, '`uri` must be a string.' );
43
-		Assertions::not_empty( $uri, '`uri` cannot be empty.' );
44
-		Assertions::not_empty( $this->get_dataset_uri(), '`dataset_uri` cannot be empty.' );
45
-
46
-		if ( $this->is_absolute( $uri ) && ! $this->is_internal( $uri ) ) {
47
-			throw new Exception( '`uri` must be within the dataset URI scope.' );
48
-		}
49
-
50
-		$rel_uri = $this->make_relative( $uri );
51
-
52
-		global $wpdb;
53
-		$row = $wpdb->get_row( $wpdb->prepare( "
18
+    private static $instance = null;
19
+
20
+    /**
21
+     * The singleton instance. We use this only to provide this instance to those classes where we have no access to
22
+     * the constructor.
23
+     *
24
+     * @return Wordpress_Post_Content_Table_Service
25
+     */
26
+    public static function get_instance() {
27
+
28
+        if ( ! isset( self::$instance ) ) {
29
+            self::$instance = new self();
30
+        }
31
+
32
+        return self::$instance;
33
+    }
34
+
35
+    /**
36
+     * @param string $uri An absolute or relative URI. When absolute it must be within the dataset URI scope.
37
+     *
38
+     * @return Wordpress_Content|null
39
+     * @throws Exception when the URI is not within the dataset URI.
40
+     */
41
+    function get_by_entity_id( $uri ) {
42
+        Assertions::is_string( $uri, '`uri` must be a string.' );
43
+        Assertions::not_empty( $uri, '`uri` cannot be empty.' );
44
+        Assertions::not_empty( $this->get_dataset_uri(), '`dataset_uri` cannot be empty.' );
45
+
46
+        if ( $this->is_absolute( $uri ) && ! $this->is_internal( $uri ) ) {
47
+            throw new Exception( '`uri` must be within the dataset URI scope.' );
48
+        }
49
+
50
+        $rel_uri = $this->make_relative( $uri );
51
+
52
+        global $wpdb;
53
+        $row = $wpdb->get_row( $wpdb->prepare( "
54 54
 			SELECT content_type, content_id
55 55
 			FROM {$wpdb->prefix}wl_entities
56 56
 			WHERE rel_uri = %s
57 57
 		", $rel_uri ) );
58 58
 
59
-		if ( ! isset( $row ) || Object_Type_Enum::POST !== (int) $row->content_type ) {
60
-			return null;
61
-		}
62
-
63
-		return new Wordpress_Content( get_post( $row->content_id ) );
64
-	}
65
-
66
-	/**
67
-	 * @throws Exception when `$uri` is not a string.
68
-	 */
69
-	function get_by_entity_id_or_same_as( $uri ) {
70
-		Assertions::is_string( $uri, '`uri` must be a string.' );
71
-		Assertions::not_empty( '`uri` cannot be empty.' );
72
-
73
-		// If it's a relative URI, or it's an internal URI, look in entity ID.
74
-		if ( ! $this->is_absolute( $uri ) || $this->is_internal( $uri ) ) {
75
-			return $this->get_by_entity_id( $uri );
76
-		}
77
-
78
-		// Look in sameAs.
79
-		$query_args = array(
80
-			// See https://github.com/insideout10/wordlift-plugin/issues/654.
81
-			'ignore_sticky_posts' => 1,
82
-			'posts_per_page'      => 1,
83
-			'post_status'         => 'any',
84
-			'post_type'           => Wordlift_Entity_Service::valid_entity_post_types(),
85
-			'meta_query'          => array(
86
-				array(
87
-					'key'     => Wordlift_Schema_Service::FIELD_SAME_AS,
88
-					'value'   => $uri,
89
-					'compare' => '=',
90
-				)
91
-			),
92
-		);
93
-
94
-		$posts = get_posts( $query_args );
95
-
96
-		// Get the current post or allow 3rd parties to provide a replacement.
97
-		$post = current( $posts ) ?: apply_filters( 'wl_content_service__post__not_found', null, $uri );
98
-
99
-		if ( is_a( $post, 'WP_Post' ) ) {
100
-			return new Wordpress_Content( current( $posts ) );
101
-		}
102
-
103
-		return null;
104
-	}
105
-
106
-	/**
107
-	 * @param Wordpress_Content_Id $content_id
108
-	 *
109
-	 * @return string|null The entity ID.
110
-	 * @throws Exception
111
-	 */
112
-	function get_entity_id( $content_id ) {
113
-		Assertions::equals( $content_id->get_type(), Object_Type_Enum::POST, '`content_id` must be of type post.' );
114
-
115
-		global $wpdb;
116
-		$rel_uri = $wpdb->get_var( $wpdb->prepare( "
59
+        if ( ! isset( $row ) || Object_Type_Enum::POST !== (int) $row->content_type ) {
60
+            return null;
61
+        }
62
+
63
+        return new Wordpress_Content( get_post( $row->content_id ) );
64
+    }
65
+
66
+    /**
67
+     * @throws Exception when `$uri` is not a string.
68
+     */
69
+    function get_by_entity_id_or_same_as( $uri ) {
70
+        Assertions::is_string( $uri, '`uri` must be a string.' );
71
+        Assertions::not_empty( '`uri` cannot be empty.' );
72
+
73
+        // If it's a relative URI, or it's an internal URI, look in entity ID.
74
+        if ( ! $this->is_absolute( $uri ) || $this->is_internal( $uri ) ) {
75
+            return $this->get_by_entity_id( $uri );
76
+        }
77
+
78
+        // Look in sameAs.
79
+        $query_args = array(
80
+            // See https://github.com/insideout10/wordlift-plugin/issues/654.
81
+            'ignore_sticky_posts' => 1,
82
+            'posts_per_page'      => 1,
83
+            'post_status'         => 'any',
84
+            'post_type'           => Wordlift_Entity_Service::valid_entity_post_types(),
85
+            'meta_query'          => array(
86
+                array(
87
+                    'key'     => Wordlift_Schema_Service::FIELD_SAME_AS,
88
+                    'value'   => $uri,
89
+                    'compare' => '=',
90
+                )
91
+            ),
92
+        );
93
+
94
+        $posts = get_posts( $query_args );
95
+
96
+        // Get the current post or allow 3rd parties to provide a replacement.
97
+        $post = current( $posts ) ?: apply_filters( 'wl_content_service__post__not_found', null, $uri );
98
+
99
+        if ( is_a( $post, 'WP_Post' ) ) {
100
+            return new Wordpress_Content( current( $posts ) );
101
+        }
102
+
103
+        return null;
104
+    }
105
+
106
+    /**
107
+     * @param Wordpress_Content_Id $content_id
108
+     *
109
+     * @return string|null The entity ID.
110
+     * @throws Exception
111
+     */
112
+    function get_entity_id( $content_id ) {
113
+        Assertions::equals( $content_id->get_type(), Object_Type_Enum::POST, '`content_id` must be of type post.' );
114
+
115
+        global $wpdb;
116
+        $rel_uri = $wpdb->get_var( $wpdb->prepare( "
117 117
 			SELECT rel_uri
118 118
 			FROM {$wpdb->prefix}wl_entities
119 119
 			WHERE content_id = %d AND content_type = %d
120 120
 		", $content_id->get_id(), $content_id->get_type() ) );
121 121
 
122
-		return $rel_uri ? $this->make_absolute( $rel_uri ) : null;
123
-	}
122
+        return $rel_uri ? $this->make_absolute( $rel_uri ) : null;
123
+    }
124 124
 
125
-	/**
126
-	 * @param Wordpress_Content_Id $content_id
127
-	 * @param string $uri
128
-	 *
129
-	 * @return void
130
-	 * @throws Exception
131
-	 */
132
-	function set_entity_id( $content_id, $uri ) {
133
-		Assertions::equals( $content_id->get_type(), Object_Type_Enum::POST, '`content_id` must be of type post.' );
134
-		Assertions::not_empty( $uri, "`uri` can't be empty" );
125
+    /**
126
+     * @param Wordpress_Content_Id $content_id
127
+     * @param string $uri
128
+     *
129
+     * @return void
130
+     * @throws Exception
131
+     */
132
+    function set_entity_id( $content_id, $uri ) {
133
+        Assertions::equals( $content_id->get_type(), Object_Type_Enum::POST, '`content_id` must be of type post.' );
134
+        Assertions::not_empty( $uri, "`uri` can't be empty" );
135 135
 
136
-		if ( $this->is_absolute( $uri ) && ! $this->is_internal( $uri ) ) {
137
-			throw new Exception( '`uri` must be within the dataset URI scope.' );
138
-		}
136
+        if ( $this->is_absolute( $uri ) && ! $this->is_internal( $uri ) ) {
137
+            throw new Exception( '`uri` must be within the dataset URI scope.' );
138
+        }
139 139
 
140
-		$rel_url = $this->make_relative( $uri );
140
+        $rel_url = $this->make_relative( $uri );
141 141
 
142
-		global $wpdb;
143
-		$wpdb->query( $wpdb->prepare( "
142
+        global $wpdb;
143
+        $wpdb->query( $wpdb->prepare( "
144 144
 			INSERT INTO {$wpdb->prefix}wl_entities( content_id, content_type, rel_uri, rel_uri_hash )
145 145
 			VALUES( %d, %d, %s, SHA1( %s ) )
146 146
 			ON DUPLICATE KEY UPDATE rel_uri = VALUES( rel_uri ), rel_uri_hash = SHA1( VALUES( rel_uri ) );
147 147
 		", $content_id->get_id(), $content_id->get_type(), $rel_url, $rel_url ) );
148
-	}
149
-
150
-	/**
151
-	 * @param Wordpress_Content_Id $content_id
152
-	 *
153
-	 * @return bool
154
-	 */
155
-	function supports( $content_id ) {
156
-		return $content_id->get_type() === Object_Type_Enum::POST;
157
-	}
158
-
159
-	/**
160
-	 * @param Wordpress_Content_Id $content_id
161
-	 *
162
-	 * @return void
163
-	 */
164
-	function delete( $content_id ) {
165
-		global $wpdb;
166
-
167
-		$wpdb->query( $wpdb->prepare( "
148
+    }
149
+
150
+    /**
151
+     * @param Wordpress_Content_Id $content_id
152
+     *
153
+     * @return bool
154
+     */
155
+    function supports( $content_id ) {
156
+        return $content_id->get_type() === Object_Type_Enum::POST;
157
+    }
158
+
159
+    /**
160
+     * @param Wordpress_Content_Id $content_id
161
+     *
162
+     * @return void
163
+     */
164
+    function delete( $content_id ) {
165
+        global $wpdb;
166
+
167
+        $wpdb->query( $wpdb->prepare( "
168 168
 			DELETE FROM {$wpdb->prefix}wl_entities
169 169
 			WHERE content_id = %d AND content_type = %d
170 170
 		", $content_id->get_id(), $content_id->get_type() ) );
171
-	}
171
+    }
172 172
 }
173 173
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 */
26 26
 	public static function get_instance() {
27 27
 
28
-		if ( ! isset( self::$instance ) ) {
28
+		if ( ! isset(self::$instance)) {
29 29
 			self::$instance = new self();
30 30
 		}
31 31
 
@@ -38,41 +38,41 @@  discard block
 block discarded – undo
38 38
 	 * @return Wordpress_Content|null
39 39
 	 * @throws Exception when the URI is not within the dataset URI.
40 40
 	 */
41
-	function get_by_entity_id( $uri ) {
42
-		Assertions::is_string( $uri, '`uri` must be a string.' );
43
-		Assertions::not_empty( $uri, '`uri` cannot be empty.' );
44
-		Assertions::not_empty( $this->get_dataset_uri(), '`dataset_uri` cannot be empty.' );
41
+	function get_by_entity_id($uri) {
42
+		Assertions::is_string($uri, '`uri` must be a string.');
43
+		Assertions::not_empty($uri, '`uri` cannot be empty.');
44
+		Assertions::not_empty($this->get_dataset_uri(), '`dataset_uri` cannot be empty.');
45 45
 
46
-		if ( $this->is_absolute( $uri ) && ! $this->is_internal( $uri ) ) {
47
-			throw new Exception( '`uri` must be within the dataset URI scope.' );
46
+		if ($this->is_absolute($uri) && ! $this->is_internal($uri)) {
47
+			throw new Exception('`uri` must be within the dataset URI scope.');
48 48
 		}
49 49
 
50
-		$rel_uri = $this->make_relative( $uri );
50
+		$rel_uri = $this->make_relative($uri);
51 51
 
52 52
 		global $wpdb;
53
-		$row = $wpdb->get_row( $wpdb->prepare( "
53
+		$row = $wpdb->get_row($wpdb->prepare("
54 54
 			SELECT content_type, content_id
55 55
 			FROM {$wpdb->prefix}wl_entities
56 56
 			WHERE rel_uri = %s
57
-		", $rel_uri ) );
57
+		", $rel_uri));
58 58
 
59
-		if ( ! isset( $row ) || Object_Type_Enum::POST !== (int) $row->content_type ) {
59
+		if ( ! isset($row) || Object_Type_Enum::POST !== (int) $row->content_type) {
60 60
 			return null;
61 61
 		}
62 62
 
63
-		return new Wordpress_Content( get_post( $row->content_id ) );
63
+		return new Wordpress_Content(get_post($row->content_id));
64 64
 	}
65 65
 
66 66
 	/**
67 67
 	 * @throws Exception when `$uri` is not a string.
68 68
 	 */
69
-	function get_by_entity_id_or_same_as( $uri ) {
70
-		Assertions::is_string( $uri, '`uri` must be a string.' );
71
-		Assertions::not_empty( '`uri` cannot be empty.' );
69
+	function get_by_entity_id_or_same_as($uri) {
70
+		Assertions::is_string($uri, '`uri` must be a string.');
71
+		Assertions::not_empty('`uri` cannot be empty.');
72 72
 
73 73
 		// If it's a relative URI, or it's an internal URI, look in entity ID.
74
-		if ( ! $this->is_absolute( $uri ) || $this->is_internal( $uri ) ) {
75
-			return $this->get_by_entity_id( $uri );
74
+		if ( ! $this->is_absolute($uri) || $this->is_internal($uri)) {
75
+			return $this->get_by_entity_id($uri);
76 76
 		}
77 77
 
78 78
 		// Look in sameAs.
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 			),
92 92
 		);
93 93
 
94
-		$posts = get_posts( $query_args );
94
+		$posts = get_posts($query_args);
95 95
 
96 96
 		// Get the current post or allow 3rd parties to provide a replacement.
97
-		$post = current( $posts ) ?: apply_filters( 'wl_content_service__post__not_found', null, $uri );
97
+		$post = current($posts) ?: apply_filters('wl_content_service__post__not_found', null, $uri);
98 98
 
99
-		if ( is_a( $post, 'WP_Post' ) ) {
100
-			return new Wordpress_Content( current( $posts ) );
99
+		if (is_a($post, 'WP_Post')) {
100
+			return new Wordpress_Content(current($posts));
101 101
 		}
102 102
 
103 103
 		return null;
@@ -109,17 +109,17 @@  discard block
 block discarded – undo
109 109
 	 * @return string|null The entity ID.
110 110
 	 * @throws Exception
111 111
 	 */
112
-	function get_entity_id( $content_id ) {
113
-		Assertions::equals( $content_id->get_type(), Object_Type_Enum::POST, '`content_id` must be of type post.' );
112
+	function get_entity_id($content_id) {
113
+		Assertions::equals($content_id->get_type(), Object_Type_Enum::POST, '`content_id` must be of type post.');
114 114
 
115 115
 		global $wpdb;
116
-		$rel_uri = $wpdb->get_var( $wpdb->prepare( "
116
+		$rel_uri = $wpdb->get_var($wpdb->prepare("
117 117
 			SELECT rel_uri
118 118
 			FROM {$wpdb->prefix}wl_entities
119 119
 			WHERE content_id = %d AND content_type = %d
120
-		", $content_id->get_id(), $content_id->get_type() ) );
120
+		", $content_id->get_id(), $content_id->get_type()));
121 121
 
122
-		return $rel_uri ? $this->make_absolute( $rel_uri ) : null;
122
+		return $rel_uri ? $this->make_absolute($rel_uri) : null;
123 123
 	}
124 124
 
125 125
 	/**
@@ -129,22 +129,22 @@  discard block
 block discarded – undo
129 129
 	 * @return void
130 130
 	 * @throws Exception
131 131
 	 */
132
-	function set_entity_id( $content_id, $uri ) {
133
-		Assertions::equals( $content_id->get_type(), Object_Type_Enum::POST, '`content_id` must be of type post.' );
134
-		Assertions::not_empty( $uri, "`uri` can't be empty" );
132
+	function set_entity_id($content_id, $uri) {
133
+		Assertions::equals($content_id->get_type(), Object_Type_Enum::POST, '`content_id` must be of type post.');
134
+		Assertions::not_empty($uri, "`uri` can't be empty");
135 135
 
136
-		if ( $this->is_absolute( $uri ) && ! $this->is_internal( $uri ) ) {
137
-			throw new Exception( '`uri` must be within the dataset URI scope.' );
136
+		if ($this->is_absolute($uri) && ! $this->is_internal($uri)) {
137
+			throw new Exception('`uri` must be within the dataset URI scope.');
138 138
 		}
139 139
 
140
-		$rel_url = $this->make_relative( $uri );
140
+		$rel_url = $this->make_relative($uri);
141 141
 
142 142
 		global $wpdb;
143
-		$wpdb->query( $wpdb->prepare( "
143
+		$wpdb->query($wpdb->prepare("
144 144
 			INSERT INTO {$wpdb->prefix}wl_entities( content_id, content_type, rel_uri, rel_uri_hash )
145 145
 			VALUES( %d, %d, %s, SHA1( %s ) )
146 146
 			ON DUPLICATE KEY UPDATE rel_uri = VALUES( rel_uri ), rel_uri_hash = SHA1( VALUES( rel_uri ) );
147
-		", $content_id->get_id(), $content_id->get_type(), $rel_url, $rel_url ) );
147
+		", $content_id->get_id(), $content_id->get_type(), $rel_url, $rel_url));
148 148
 	}
149 149
 
150 150
 	/**
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @return bool
154 154
 	 */
155
-	function supports( $content_id ) {
155
+	function supports($content_id) {
156 156
 		return $content_id->get_type() === Object_Type_Enum::POST;
157 157
 	}
158 158
 
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
 	 *
162 162
 	 * @return void
163 163
 	 */
164
-	function delete( $content_id ) {
164
+	function delete($content_id) {
165 165
 		global $wpdb;
166 166
 
167
-		$wpdb->query( $wpdb->prepare( "
167
+		$wpdb->query($wpdb->prepare("
168 168
 			DELETE FROM {$wpdb->prefix}wl_entities
169 169
 			WHERE content_id = %d AND content_type = %d
170
-		", $content_id->get_id(), $content_id->get_type() ) );
170
+		", $content_id->get_id(), $content_id->get_type()));
171 171
 	}
172 172
 }
173 173
\ No newline at end of file
Please login to merge, or discard this patch.
content/wordpress/class-abstract-wordpress-content-legacy-service.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@
 block discarded – undo
8 8
 abstract class Abstract_Wordpress_Content_Legacy_Service extends Abstract_Wordpress_Content_Service {
9 9
 
10 10
 
11
-	private $expected_object_type;
12
-	private $get_meta_fn;
11
+    private $expected_object_type;
12
+    private $get_meta_fn;
13 13
 
14
-	protected function __construct( $expected_object_type, $get_meta_fn ) {
15
-		parent::__construct();
14
+    protected function __construct( $expected_object_type, $get_meta_fn ) {
15
+        parent::__construct();
16 16
 
17
-		$this->expected_object_type = $expected_object_type;
18
-		$this->get_meta_fn          = $get_meta_fn;
19
-	}
17
+        $this->expected_object_type = $expected_object_type;
18
+        $this->get_meta_fn          = $get_meta_fn;
19
+    }
20 20
 
21
-	public function get_entity_id( $content_id ) {
22
-		Assertions::equals( $content_id->get_type(), $this->expected_object_type,
23
-			sprintf( '`content_id` must be of type `%s`.', Object_Type_Enum::to_string( $this->expected_object_type ) ) );
21
+    public function get_entity_id( $content_id ) {
22
+        Assertions::equals( $content_id->get_type(), $this->expected_object_type,
23
+            sprintf( '`content_id` must be of type `%s`.', Object_Type_Enum::to_string( $this->expected_object_type ) ) );
24 24
 
25
-		return call_user_func( $this->get_meta_fn, $content_id->get_id(), 'entity_url', true ) ?: null;
26
-	}
25
+        return call_user_func( $this->get_meta_fn, $content_id->get_id(), 'entity_url', true ) ?: null;
26
+    }
27 27
 
28
-	public function delete( $content_id ) {
29
-		// do nothing, WP deletes the post meta for us.
30
-	}
28
+    public function delete( $content_id ) {
29
+        // do nothing, WP deletes the post meta for us.
30
+    }
31 31
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,21 +11,21 @@
 block discarded – undo
11 11
 	private $expected_object_type;
12 12
 	private $get_meta_fn;
13 13
 
14
-	protected function __construct( $expected_object_type, $get_meta_fn ) {
14
+	protected function __construct($expected_object_type, $get_meta_fn) {
15 15
 		parent::__construct();
16 16
 
17 17
 		$this->expected_object_type = $expected_object_type;
18 18
 		$this->get_meta_fn          = $get_meta_fn;
19 19
 	}
20 20
 
21
-	public function get_entity_id( $content_id ) {
22
-		Assertions::equals( $content_id->get_type(), $this->expected_object_type,
23
-			sprintf( '`content_id` must be of type `%s`.', Object_Type_Enum::to_string( $this->expected_object_type ) ) );
21
+	public function get_entity_id($content_id) {
22
+		Assertions::equals($content_id->get_type(), $this->expected_object_type,
23
+			sprintf('`content_id` must be of type `%s`.', Object_Type_Enum::to_string($this->expected_object_type)));
24 24
 
25
-		return call_user_func( $this->get_meta_fn, $content_id->get_id(), 'entity_url', true ) ?: null;
25
+		return call_user_func($this->get_meta_fn, $content_id->get_id(), 'entity_url', true) ?: null;
26 26
 	}
27 27
 
28
-	public function delete( $content_id ) {
28
+	public function delete($content_id) {
29 29
 		// do nothing, WP deletes the post meta for us.
30 30
 	}
31 31
 }
Please login to merge, or discard this patch.
wordlift/content/wordpress/class-wordpress-permalink-content-service.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -8,62 +8,62 @@  discard block
 block discarded – undo
8 8
 
9 9
 class Wordpress_Permalink_Content_Service implements Content_Service {
10 10
 
11
-	private static $instance = null;
12
-
13
-	protected function __construct() {
14
-	}
15
-
16
-	/**
17
-	 * The singleton instance.
18
-	 *
19
-	 * @return Content_Service
20
-	 */
21
-	public static function get_instance() {
22
-		if ( ! isset( self::$instance ) ) {
23
-			self::$instance = new self();
24
-		}
25
-
26
-		return self::$instance;
27
-	}
28
-
29
-	/**
30
-	 * @param $uri string In the form https://example.org/path/post#post/1
31
-	 *
32
-	 * @return Wordpress_Content|null
33
-	 */
34
-	function get_by_entity_id( $uri ) {
35
-		if ( ! preg_match( '@.*#(\w+)/(\d+)@', $uri, $matches ) ) {
36
-			return null;
37
-		}
38
-
39
-		$type_name = $matches[1];
40
-		$id        = $matches[2];
41
-		switch ( Object_Type_Enum::from_string( $type_name ) ) {
42
-			case Object_Type_Enum::POST:
43
-				return new Wordpress_Content( get_post( $id ) );
44
-			case Object_Type_Enum::TERM:
45
-				return new Wordpress_Content( get_term( $id ) );
46
-			case Object_Type_Enum::USER:
47
-				return new Wordpress_Content( get_user_by( 'ID', $id ) );
48
-		}
49
-
50
-		return null;
51
-	}
52
-
53
-	/**
54
-	 * Get a
55
-	 * @throws Exception
56
-	 */
57
-	function get_by_entity_id_or_same_as( $uri ) {
58
-		// If the URL is in the local site URL, then try to find a corresponding post.
59
-		if ( 0 === strpos( $uri, site_url() ) ) {
60
-			return $this->get_by_entity_id( $uri );
61
-		}
62
-
63
-		// Otherwise look in sameAs.
64
-		global $wpdb;
65
-
66
-		$row = $wpdb->get_row( $wpdb->prepare( "
11
+    private static $instance = null;
12
+
13
+    protected function __construct() {
14
+    }
15
+
16
+    /**
17
+     * The singleton instance.
18
+     *
19
+     * @return Content_Service
20
+     */
21
+    public static function get_instance() {
22
+        if ( ! isset( self::$instance ) ) {
23
+            self::$instance = new self();
24
+        }
25
+
26
+        return self::$instance;
27
+    }
28
+
29
+    /**
30
+     * @param $uri string In the form https://example.org/path/post#post/1
31
+     *
32
+     * @return Wordpress_Content|null
33
+     */
34
+    function get_by_entity_id( $uri ) {
35
+        if ( ! preg_match( '@.*#(\w+)/(\d+)@', $uri, $matches ) ) {
36
+            return null;
37
+        }
38
+
39
+        $type_name = $matches[1];
40
+        $id        = $matches[2];
41
+        switch ( Object_Type_Enum::from_string( $type_name ) ) {
42
+            case Object_Type_Enum::POST:
43
+                return new Wordpress_Content( get_post( $id ) );
44
+            case Object_Type_Enum::TERM:
45
+                return new Wordpress_Content( get_term( $id ) );
46
+            case Object_Type_Enum::USER:
47
+                return new Wordpress_Content( get_user_by( 'ID', $id ) );
48
+        }
49
+
50
+        return null;
51
+    }
52
+
53
+    /**
54
+     * Get a
55
+     * @throws Exception
56
+     */
57
+    function get_by_entity_id_or_same_as( $uri ) {
58
+        // If the URL is in the local site URL, then try to find a corresponding post.
59
+        if ( 0 === strpos( $uri, site_url() ) ) {
60
+            return $this->get_by_entity_id( $uri );
61
+        }
62
+
63
+        // Otherwise look in sameAs.
64
+        global $wpdb;
65
+
66
+        $row = $wpdb->get_row( $wpdb->prepare( "
67 67
 			SELECT content_type, content_id
68 68
 			FROM (
69 69
 			    SELECT %d AS content_type, post_id AS content_id
@@ -80,73 +80,73 @@  discard block
 block discarded – undo
80 80
 			) _tmp_same_as 
81 81
 			LIMIT 1
82 82
 		",
83
-			Object_Type_Enum::POST, $uri,
84
-			Object_Type_Enum::TERM, $uri,
85
-			Object_Type_Enum::USER, $uri ) );
86
-
87
-		if ( ! isset( $row ) ) {
88
-			return null;
89
-		}
90
-
91
-		switch ( (int) $row->content_type ) {
92
-			case Object_Type_Enum::POST:
93
-				return new Wordpress_Content( get_post( $row->content_id ) );
94
-			case Object_Type_Enum::TERM:
95
-				return new Wordpress_Content( get_term( $row->content_id ) );
96
-			case Object_Type_Enum::USER:
97
-				return new Wordpress_Content( get_user_by( 'ID', $row->content_id ) );
98
-			default:
99
-				return null;
100
-		}
101
-
102
-	}
103
-
104
-	/**
105
-	 * @param Wordpress_Content_Id $content_id
106
-	 *
107
-	 * @return string|void|null
108
-	 */
109
-	function get_entity_id( $content_id ) {
110
-		$type = $content_id->get_type();
111
-		$id   = $content_id->get_id();
112
-
113
-		switch ( $type ) {
114
-			case Object_Type_Enum::POST:
115
-				$base_uri = get_permalink( $id );
116
-				break;
117
-			case Object_Type_Enum::TERM:
118
-				$base_uri = get_term_link( $id );
119
-				break;
120
-			case Object_Type_Enum::USER:
121
-				$base_uri = get_author_posts_url( $id );
122
-				break;
123
-			default:
124
-				return null;
125
-		}
126
-
127
-		$type_name = Object_Type_Enum::to_string( $type );
128
-
129
-		return "$base_uri#$type_name/$id";
130
-	}
131
-
132
-	function set_entity_id( $content_id, $uri ) {
133
-		throw new Exception( 'Not supported' );
134
-	}
135
-
136
-	/**
137
-	 * @param Wordpress_Content_Id $content_id
138
-	 *
139
-	 * @return bool|void
140
-	 */
141
-	function supports( $content_id ) {
142
-		return in_array( $content_id->get_type(), array(
143
-			Object_Type_Enum::POST,
144
-			Object_Type_Enum::TERM,
145
-			Object_Type_Enum::USER,
146
-		) );
147
-	}
148
-
149
-	function delete( $content_id ) {
150
-		// Ignore, we don't store any data.
151
-	}
83
+            Object_Type_Enum::POST, $uri,
84
+            Object_Type_Enum::TERM, $uri,
85
+            Object_Type_Enum::USER, $uri ) );
86
+
87
+        if ( ! isset( $row ) ) {
88
+            return null;
89
+        }
90
+
91
+        switch ( (int) $row->content_type ) {
92
+            case Object_Type_Enum::POST:
93
+                return new Wordpress_Content( get_post( $row->content_id ) );
94
+            case Object_Type_Enum::TERM:
95
+                return new Wordpress_Content( get_term( $row->content_id ) );
96
+            case Object_Type_Enum::USER:
97
+                return new Wordpress_Content( get_user_by( 'ID', $row->content_id ) );
98
+            default:
99
+                return null;
100
+        }
101
+
102
+    }
103
+
104
+    /**
105
+     * @param Wordpress_Content_Id $content_id
106
+     *
107
+     * @return string|void|null
108
+     */
109
+    function get_entity_id( $content_id ) {
110
+        $type = $content_id->get_type();
111
+        $id   = $content_id->get_id();
112
+
113
+        switch ( $type ) {
114
+            case Object_Type_Enum::POST:
115
+                $base_uri = get_permalink( $id );
116
+                break;
117
+            case Object_Type_Enum::TERM:
118
+                $base_uri = get_term_link( $id );
119
+                break;
120
+            case Object_Type_Enum::USER:
121
+                $base_uri = get_author_posts_url( $id );
122
+                break;
123
+            default:
124
+                return null;
125
+        }
126
+
127
+        $type_name = Object_Type_Enum::to_string( $type );
128
+
129
+        return "$base_uri#$type_name/$id";
130
+    }
131
+
132
+    function set_entity_id( $content_id, $uri ) {
133
+        throw new Exception( 'Not supported' );
134
+    }
135
+
136
+    /**
137
+     * @param Wordpress_Content_Id $content_id
138
+     *
139
+     * @return bool|void
140
+     */
141
+    function supports( $content_id ) {
142
+        return in_array( $content_id->get_type(), array(
143
+            Object_Type_Enum::POST,
144
+            Object_Type_Enum::TERM,
145
+            Object_Type_Enum::USER,
146
+        ) );
147
+    }
148
+
149
+    function delete( $content_id ) {
150
+        // Ignore, we don't store any data.
151
+    }
152 152
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @return Content_Service
20 20
 	 */
21 21
 	public static function get_instance() {
22
-		if ( ! isset( self::$instance ) ) {
22
+		if ( ! isset(self::$instance)) {
23 23
 			self::$instance = new self();
24 24
 		}
25 25
 
@@ -31,20 +31,20 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @return Wordpress_Content|null
33 33
 	 */
34
-	function get_by_entity_id( $uri ) {
35
-		if ( ! preg_match( '@.*#(\w+)/(\d+)@', $uri, $matches ) ) {
34
+	function get_by_entity_id($uri) {
35
+		if ( ! preg_match('@.*#(\w+)/(\d+)@', $uri, $matches)) {
36 36
 			return null;
37 37
 		}
38 38
 
39 39
 		$type_name = $matches[1];
40 40
 		$id        = $matches[2];
41
-		switch ( Object_Type_Enum::from_string( $type_name ) ) {
41
+		switch (Object_Type_Enum::from_string($type_name)) {
42 42
 			case Object_Type_Enum::POST:
43
-				return new Wordpress_Content( get_post( $id ) );
43
+				return new Wordpress_Content(get_post($id));
44 44
 			case Object_Type_Enum::TERM:
45
-				return new Wordpress_Content( get_term( $id ) );
45
+				return new Wordpress_Content(get_term($id));
46 46
 			case Object_Type_Enum::USER:
47
-				return new Wordpress_Content( get_user_by( 'ID', $id ) );
47
+				return new Wordpress_Content(get_user_by('ID', $id));
48 48
 		}
49 49
 
50 50
 		return null;
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
54 54
 	 * Get a
55 55
 	 * @throws Exception
56 56
 	 */
57
-	function get_by_entity_id_or_same_as( $uri ) {
57
+	function get_by_entity_id_or_same_as($uri) {
58 58
 		// If the URL is in the local site URL, then try to find a corresponding post.
59
-		if ( 0 === strpos( $uri, site_url() ) ) {
60
-			return $this->get_by_entity_id( $uri );
59
+		if (0 === strpos($uri, site_url())) {
60
+			return $this->get_by_entity_id($uri);
61 61
 		}
62 62
 
63 63
 		// Otherwise look in sameAs.
64 64
 		global $wpdb;
65 65
 
66
-		$row = $wpdb->get_row( $wpdb->prepare( "
66
+		$row = $wpdb->get_row($wpdb->prepare("
67 67
 			SELECT content_type, content_id
68 68
 			FROM (
69 69
 			    SELECT %d AS content_type, post_id AS content_id
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
 		",
83 83
 			Object_Type_Enum::POST, $uri,
84 84
 			Object_Type_Enum::TERM, $uri,
85
-			Object_Type_Enum::USER, $uri ) );
85
+			Object_Type_Enum::USER, $uri));
86 86
 
87
-		if ( ! isset( $row ) ) {
87
+		if ( ! isset($row)) {
88 88
 			return null;
89 89
 		}
90 90
 
91
-		switch ( (int) $row->content_type ) {
91
+		switch ((int) $row->content_type) {
92 92
 			case Object_Type_Enum::POST:
93
-				return new Wordpress_Content( get_post( $row->content_id ) );
93
+				return new Wordpress_Content(get_post($row->content_id));
94 94
 			case Object_Type_Enum::TERM:
95
-				return new Wordpress_Content( get_term( $row->content_id ) );
95
+				return new Wordpress_Content(get_term($row->content_id));
96 96
 			case Object_Type_Enum::USER:
97
-				return new Wordpress_Content( get_user_by( 'ID', $row->content_id ) );
97
+				return new Wordpress_Content(get_user_by('ID', $row->content_id));
98 98
 			default:
99 99
 				return null;
100 100
 		}
@@ -106,31 +106,31 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @return string|void|null
108 108
 	 */
109
-	function get_entity_id( $content_id ) {
109
+	function get_entity_id($content_id) {
110 110
 		$type = $content_id->get_type();
111 111
 		$id   = $content_id->get_id();
112 112
 
113
-		switch ( $type ) {
113
+		switch ($type) {
114 114
 			case Object_Type_Enum::POST:
115
-				$base_uri = get_permalink( $id );
115
+				$base_uri = get_permalink($id);
116 116
 				break;
117 117
 			case Object_Type_Enum::TERM:
118
-				$base_uri = get_term_link( $id );
118
+				$base_uri = get_term_link($id);
119 119
 				break;
120 120
 			case Object_Type_Enum::USER:
121
-				$base_uri = get_author_posts_url( $id );
121
+				$base_uri = get_author_posts_url($id);
122 122
 				break;
123 123
 			default:
124 124
 				return null;
125 125
 		}
126 126
 
127
-		$type_name = Object_Type_Enum::to_string( $type );
127
+		$type_name = Object_Type_Enum::to_string($type);
128 128
 
129 129
 		return "$base_uri#$type_name/$id";
130 130
 	}
131 131
 
132
-	function set_entity_id( $content_id, $uri ) {
133
-		throw new Exception( 'Not supported' );
132
+	function set_entity_id($content_id, $uri) {
133
+		throw new Exception('Not supported');
134 134
 	}
135 135
 
136 136
 	/**
@@ -138,15 +138,15 @@  discard block
 block discarded – undo
138 138
 	 *
139 139
 	 * @return bool|void
140 140
 	 */
141
-	function supports( $content_id ) {
142
-		return in_array( $content_id->get_type(), array(
141
+	function supports($content_id) {
142
+		return in_array($content_id->get_type(), array(
143 143
 			Object_Type_Enum::POST,
144 144
 			Object_Type_Enum::TERM,
145 145
 			Object_Type_Enum::USER,
146
-		) );
146
+		));
147 147
 	}
148 148
 
149
-	function delete( $content_id ) {
149
+	function delete($content_id) {
150 150
 		// Ignore, we don't store any data.
151 151
 	}
152 152
 }
Please login to merge, or discard this patch.
src/wordlift/content/wordpress/class-wordpress-dataset-content-service.php 2 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -8,106 +8,106 @@
 block discarded – undo
8 8
 
9 9
 class Wordpress_Dataset_Content_Service implements Content_Service {
10 10
 
11
-	/**
12
-	 * @var Content_Service[]
13
-	 */
14
-	private $delegates = array();
15
-
16
-	protected function __construct() {
17
-
18
-	}
19
-
20
-	private static $instance = null;
21
-
22
-	/**
23
-	 * The singleton instance.
24
-	 *
25
-	 * @return Content_Service
26
-	 */
27
-	public static function get_instance() {
28
-		if ( ! isset( self::$instance ) ) {
29
-			self::$instance = new self();
30
-
31
-			self::$instance->register_delegate( Wordpress_Post_Content_Service::get_instance() );
32
-			self::$instance->register_delegate( Wordpress_Term_Content_Legacy_Service::get_instance() );
33
-			self::$instance->register_delegate( Wordpress_User_Content_Legacy_Service::get_instance() );
34
-
35
-			Wordpress_Dataset_Content_Service_Hooks::register();
36
-		}
37
-
38
-		return self::$instance;
39
-	}
40
-
41
-	public function register_delegate( $delegate ) {
42
-		Assertions::is_a( $delegate, 'Wordlift\Content\Content_Service', 'A `delegate` must implement the `Wordlift\Content\Content_Service` interface.' );
43
-
44
-		$this->delegates[] = $delegate;
45
-	}
46
-
47
-	function get_by_entity_id( $uri ) {
48
-		foreach ( $this->delegates as $delegate ) {
49
-			$content = $delegate->get_by_entity_id_or_same_as( $uri );
50
-			if ( isset( $content ) ) {
51
-				return $content;
52
-			}
53
-		}
54
-
55
-		return null;
56
-	}
57
-
58
-	/**
59
-	 * Get a
60
-	 * @throws Exception
61
-	 */
62
-	function get_by_entity_id_or_same_as( $uri ) {
63
-		foreach ( $this->delegates as $delegate ) {
64
-			$content = $delegate->get_by_entity_id_or_same_as( $uri );
65
-			if ( isset( $content ) ) {
66
-				return $content;
67
-			}
68
-		}
69
-
70
-		return null;
71
-	}
72
-
73
-	function get_entity_id( $content_id ) {
74
-		foreach ( $this->delegates as $delegate ) {
75
-			if ( $delegate->supports( $content_id ) && $uri = $delegate->get_entity_id( $content_id ) ) {
76
-				return $uri;
77
-			}
78
-		}
79
-
80
-		return null;
81
-	}
82
-
83
-	function set_entity_id( $content_id, $uri ) {
84
-		foreach ( $this->delegates as $delegate ) {
85
-			if ( $delegate->supports( $content_id ) ) {
86
-				$delegate->set_entity_id( $content_id, $uri );
87
-
88
-				return;
89
-			}
90
-		}
91
-
92
-		throw new Exception( 'Not supported' );
93
-	}
94
-
95
-	function supports( $content_id ) {
96
-		foreach ( $this->delegates as $delegate ) {
97
-			if ( $delegate->supports( $content_id ) ) {
98
-				return true;
99
-			}
100
-		}
101
-
102
-		return false;
103
-	}
104
-
105
-	function delete( $content_id ) {
106
-		foreach ( $this->delegates as $delegate ) {
107
-			if ( $delegate->supports( $content_id ) ) {
108
-				$delegate->delete( $content_id );
109
-				break;
110
-			}
111
-		}
112
-	}
11
+    /**
12
+     * @var Content_Service[]
13
+     */
14
+    private $delegates = array();
15
+
16
+    protected function __construct() {
17
+
18
+    }
19
+
20
+    private static $instance = null;
21
+
22
+    /**
23
+     * The singleton instance.
24
+     *
25
+     * @return Content_Service
26
+     */
27
+    public static function get_instance() {
28
+        if ( ! isset( self::$instance ) ) {
29
+            self::$instance = new self();
30
+
31
+            self::$instance->register_delegate( Wordpress_Post_Content_Service::get_instance() );
32
+            self::$instance->register_delegate( Wordpress_Term_Content_Legacy_Service::get_instance() );
33
+            self::$instance->register_delegate( Wordpress_User_Content_Legacy_Service::get_instance() );
34
+
35
+            Wordpress_Dataset_Content_Service_Hooks::register();
36
+        }
37
+
38
+        return self::$instance;
39
+    }
40
+
41
+    public function register_delegate( $delegate ) {
42
+        Assertions::is_a( $delegate, 'Wordlift\Content\Content_Service', 'A `delegate` must implement the `Wordlift\Content\Content_Service` interface.' );
43
+
44
+        $this->delegates[] = $delegate;
45
+    }
46
+
47
+    function get_by_entity_id( $uri ) {
48
+        foreach ( $this->delegates as $delegate ) {
49
+            $content = $delegate->get_by_entity_id_or_same_as( $uri );
50
+            if ( isset( $content ) ) {
51
+                return $content;
52
+            }
53
+        }
54
+
55
+        return null;
56
+    }
57
+
58
+    /**
59
+     * Get a
60
+     * @throws Exception
61
+     */
62
+    function get_by_entity_id_or_same_as( $uri ) {
63
+        foreach ( $this->delegates as $delegate ) {
64
+            $content = $delegate->get_by_entity_id_or_same_as( $uri );
65
+            if ( isset( $content ) ) {
66
+                return $content;
67
+            }
68
+        }
69
+
70
+        return null;
71
+    }
72
+
73
+    function get_entity_id( $content_id ) {
74
+        foreach ( $this->delegates as $delegate ) {
75
+            if ( $delegate->supports( $content_id ) && $uri = $delegate->get_entity_id( $content_id ) ) {
76
+                return $uri;
77
+            }
78
+        }
79
+
80
+        return null;
81
+    }
82
+
83
+    function set_entity_id( $content_id, $uri ) {
84
+        foreach ( $this->delegates as $delegate ) {
85
+            if ( $delegate->supports( $content_id ) ) {
86
+                $delegate->set_entity_id( $content_id, $uri );
87
+
88
+                return;
89
+            }
90
+        }
91
+
92
+        throw new Exception( 'Not supported' );
93
+    }
94
+
95
+    function supports( $content_id ) {
96
+        foreach ( $this->delegates as $delegate ) {
97
+            if ( $delegate->supports( $content_id ) ) {
98
+                return true;
99
+            }
100
+        }
101
+
102
+        return false;
103
+    }
104
+
105
+    function delete( $content_id ) {
106
+        foreach ( $this->delegates as $delegate ) {
107
+            if ( $delegate->supports( $content_id ) ) {
108
+                $delegate->delete( $content_id );
109
+                break;
110
+            }
111
+        }
112
+    }
113 113
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
 	 * @return Content_Service
26 26
 	 */
27 27
 	public static function get_instance() {
28
-		if ( ! isset( self::$instance ) ) {
28
+		if ( ! isset(self::$instance)) {
29 29
 			self::$instance = new self();
30 30
 
31
-			self::$instance->register_delegate( Wordpress_Post_Content_Service::get_instance() );
32
-			self::$instance->register_delegate( Wordpress_Term_Content_Legacy_Service::get_instance() );
33
-			self::$instance->register_delegate( Wordpress_User_Content_Legacy_Service::get_instance() );
31
+			self::$instance->register_delegate(Wordpress_Post_Content_Service::get_instance());
32
+			self::$instance->register_delegate(Wordpress_Term_Content_Legacy_Service::get_instance());
33
+			self::$instance->register_delegate(Wordpress_User_Content_Legacy_Service::get_instance());
34 34
 
35 35
 			Wordpress_Dataset_Content_Service_Hooks::register();
36 36
 		}
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 		return self::$instance;
39 39
 	}
40 40
 
41
-	public function register_delegate( $delegate ) {
42
-		Assertions::is_a( $delegate, 'Wordlift\Content\Content_Service', 'A `delegate` must implement the `Wordlift\Content\Content_Service` interface.' );
41
+	public function register_delegate($delegate) {
42
+		Assertions::is_a($delegate, 'Wordlift\Content\Content_Service', 'A `delegate` must implement the `Wordlift\Content\Content_Service` interface.');
43 43
 
44 44
 		$this->delegates[] = $delegate;
45 45
 	}
46 46
 
47
-	function get_by_entity_id( $uri ) {
48
-		foreach ( $this->delegates as $delegate ) {
49
-			$content = $delegate->get_by_entity_id_or_same_as( $uri );
50
-			if ( isset( $content ) ) {
47
+	function get_by_entity_id($uri) {
48
+		foreach ($this->delegates as $delegate) {
49
+			$content = $delegate->get_by_entity_id_or_same_as($uri);
50
+			if (isset($content)) {
51 51
 				return $content;
52 52
 			}
53 53
 		}
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 	 * Get a
60 60
 	 * @throws Exception
61 61
 	 */
62
-	function get_by_entity_id_or_same_as( $uri ) {
63
-		foreach ( $this->delegates as $delegate ) {
64
-			$content = $delegate->get_by_entity_id_or_same_as( $uri );
65
-			if ( isset( $content ) ) {
62
+	function get_by_entity_id_or_same_as($uri) {
63
+		foreach ($this->delegates as $delegate) {
64
+			$content = $delegate->get_by_entity_id_or_same_as($uri);
65
+			if (isset($content)) {
66 66
 				return $content;
67 67
 			}
68 68
 		}
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 		return null;
71 71
 	}
72 72
 
73
-	function get_entity_id( $content_id ) {
74
-		foreach ( $this->delegates as $delegate ) {
75
-			if ( $delegate->supports( $content_id ) && $uri = $delegate->get_entity_id( $content_id ) ) {
73
+	function get_entity_id($content_id) {
74
+		foreach ($this->delegates as $delegate) {
75
+			if ($delegate->supports($content_id) && $uri = $delegate->get_entity_id($content_id)) {
76 76
 				return $uri;
77 77
 			}
78 78
 		}
@@ -80,21 +80,21 @@  discard block
 block discarded – undo
80 80
 		return null;
81 81
 	}
82 82
 
83
-	function set_entity_id( $content_id, $uri ) {
84
-		foreach ( $this->delegates as $delegate ) {
85
-			if ( $delegate->supports( $content_id ) ) {
86
-				$delegate->set_entity_id( $content_id, $uri );
83
+	function set_entity_id($content_id, $uri) {
84
+		foreach ($this->delegates as $delegate) {
85
+			if ($delegate->supports($content_id)) {
86
+				$delegate->set_entity_id($content_id, $uri);
87 87
 
88 88
 				return;
89 89
 			}
90 90
 		}
91 91
 
92
-		throw new Exception( 'Not supported' );
92
+		throw new Exception('Not supported');
93 93
 	}
94 94
 
95
-	function supports( $content_id ) {
96
-		foreach ( $this->delegates as $delegate ) {
97
-			if ( $delegate->supports( $content_id ) ) {
95
+	function supports($content_id) {
96
+		foreach ($this->delegates as $delegate) {
97
+			if ($delegate->supports($content_id)) {
98 98
 				return true;
99 99
 			}
100 100
 		}
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
 		return false;
103 103
 	}
104 104
 
105
-	function delete( $content_id ) {
106
-		foreach ( $this->delegates as $delegate ) {
107
-			if ( $delegate->supports( $content_id ) ) {
108
-				$delegate->delete( $content_id );
105
+	function delete($content_id) {
106
+		foreach ($this->delegates as $delegate) {
107
+			if ($delegate->supports($content_id)) {
108
+				$delegate->delete($content_id);
109 109
 				break;
110 110
 			}
111 111
 		}
Please login to merge, or discard this patch.
src/wordlift/content/class-content-service.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -10,59 +10,59 @@
 block discarded – undo
10 10
 
11 11
 interface Content_Service {
12 12
 
13
-	/**
14
-	 * Get an {@link Content} given a URI.
15
-	 *
16
-	 * @param string $uri The URI.
17
-	 *
18
-	 * @return Content|null The found {@link Content} or null if not found.
19
-	 * @throws Exception if the URI is absolute and not within the dataset URI scope or the dataset URI isn't set.
20
-	 *
21
-	 */
22
-	function get_by_entity_id( $uri );
13
+    /**
14
+     * Get an {@link Content} given a URI.
15
+     *
16
+     * @param string $uri The URI.
17
+     *
18
+     * @return Content|null The found {@link Content} or null if not found.
19
+     * @throws Exception if the URI is absolute and not within the dataset URI scope or the dataset URI isn't set.
20
+     *
21
+     */
22
+    function get_by_entity_id( $uri );
23 23
 
24
-	/**
25
-	 * Get an {@link Content} given a URI. The search is performed also in sameAs.
26
-	 *
27
-	 * @param string $uri The URI.
28
-	 *
29
-	 * @return Content|null The found {@link Content} or null if not found.
30
-	 */
31
-	function get_by_entity_id_or_same_as( $uri );
24
+    /**
25
+     * Get an {@link Content} given a URI. The search is performed also in sameAs.
26
+     *
27
+     * @param string $uri The URI.
28
+     *
29
+     * @return Content|null The found {@link Content} or null if not found.
30
+     */
31
+    function get_by_entity_id_or_same_as( $uri );
32 32
 
33
-	/**
34
-	 * Get the {@link Content}'s URI given an {@link Content_Id}.
35
-	 *
36
-	 * @param Content_Id $content_id An {@link Content_Id}.
37
-	 *
38
-	 * @return string|null An absolute URI or null if not found.
39
-	 */
40
-	function get_entity_id( $content_id );
33
+    /**
34
+     * Get the {@link Content}'s URI given an {@link Content_Id}.
35
+     *
36
+     * @param Content_Id $content_id An {@link Content_Id}.
37
+     *
38
+     * @return string|null An absolute URI or null if not found.
39
+     */
40
+    function get_entity_id( $content_id );
41 41
 
42
-	/**
43
-	 * Set the {@link Content}'s URI for the specified {@link Content_Id}.
44
-	 *
45
-	 * @param Content_Id $content_id An {@link Content_Id}.
46
-	 * @param string $uri The URI.
47
-	 *
48
-	 * @return void
49
-	 * @throws Exception if the URI is absolute and not within the dataset URI scope or the dataset URI isn't set.
50
-	 */
51
-	function set_entity_id( $content_id, $uri );
42
+    /**
43
+     * Set the {@link Content}'s URI for the specified {@link Content_Id}.
44
+     *
45
+     * @param Content_Id $content_id An {@link Content_Id}.
46
+     * @param string $uri The URI.
47
+     *
48
+     * @return void
49
+     * @throws Exception if the URI is absolute and not within the dataset URI scope or the dataset URI isn't set.
50
+     */
51
+    function set_entity_id( $content_id, $uri );
52 52
 
53
-	/**
54
-	 * Whether the {@link Content_Service} supports the provided {@link Content_Id}.
55
-	 *
56
-	 * @param Content_Id $content_id
57
-	 *
58
-	 * @return bool
59
-	 */
60
-	function supports( $content_id );
53
+    /**
54
+     * Whether the {@link Content_Service} supports the provided {@link Content_Id}.
55
+     *
56
+     * @param Content_Id $content_id
57
+     *
58
+     * @return bool
59
+     */
60
+    function supports( $content_id );
61 61
 
62
-	/**
63
-	 * Delete the content with the specified ID.
64
-	 *
65
-	 * @param Content_Id $content_id
66
-	 */
67
-	function delete( $content_id );
62
+    /**
63
+     * Delete the content with the specified ID.
64
+     *
65
+     * @param Content_Id $content_id
66
+     */
67
+    function delete( $content_id );
68 68
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @throws Exception if the URI is absolute and not within the dataset URI scope or the dataset URI isn't set.
20 20
 	 *
21 21
 	 */
22
-	function get_by_entity_id( $uri );
22
+	function get_by_entity_id($uri);
23 23
 
24 24
 	/**
25 25
 	 * Get an {@link Content} given a URI. The search is performed also in sameAs.
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @return Content|null The found {@link Content} or null if not found.
30 30
 	 */
31
-	function get_by_entity_id_or_same_as( $uri );
31
+	function get_by_entity_id_or_same_as($uri);
32 32
 
33 33
 	/**
34 34
 	 * Get the {@link Content}'s URI given an {@link Content_Id}.
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @return string|null An absolute URI or null if not found.
39 39
 	 */
40
-	function get_entity_id( $content_id );
40
+	function get_entity_id($content_id);
41 41
 
42 42
 	/**
43 43
 	 * Set the {@link Content}'s URI for the specified {@link Content_Id}.
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @return void
49 49
 	 * @throws Exception if the URI is absolute and not within the dataset URI scope or the dataset URI isn't set.
50 50
 	 */
51
-	function set_entity_id( $content_id, $uri );
51
+	function set_entity_id($content_id, $uri);
52 52
 
53 53
 	/**
54 54
 	 * Whether the {@link Content_Service} supports the provided {@link Content_Id}.
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 	 *
58 58
 	 * @return bool
59 59
 	 */
60
-	function supports( $content_id );
60
+	function supports($content_id);
61 61
 
62 62
 	/**
63 63
 	 * Delete the content with the specified ID.
64 64
 	 *
65 65
 	 * @param Content_Id $content_id
66 66
 	 */
67
-	function delete( $content_id );
67
+	function delete($content_id);
68 68
 }
Please login to merge, or discard this patch.
src/wordlift.php 2 patches
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 // If this file is called directly, abort.
35 35
 if ( ! defined( 'WPINC' ) ) {
36
-	die;
36
+    die;
37 37
 }
38 38
 
39 39
 /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  *
43 43
  */
44 44
 if ( ! apply_filters( 'wl_is_enabled', true ) ) {
45
-	return;
45
+    return;
46 46
 }
47 47
 
48 48
 require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
@@ -72,29 +72,29 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function activate_wordlift() {
74 74
 
75
-	$log = Wordlift_Log_Service::get_logger( 'activate_wordlift' );
76
-
77
-	$log->info( 'Activating WordLift...' );
78
-
79
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
80
-	Wordlift_Activator::activate();
81
-
82
-	/**
83
-	 * Tell the {@link Wordlift_Http_Api} class that we're activating, to let it run activation tasks.
84
-	 *
85
-	 * @see https://github.com/insideout10/wordlift-plugin/issues/820 related issue.
86
-	 * @since 3.19.2
87
-	 */
88
-	Wordlift_Http_Api::activate();
89
-
90
-	// Ensure the post type is registered before flushing the rewrite rules.
91
-	Wordlift_Entity_Post_Type_Service::get_instance()->register();
92
-	flush_rewrite_rules();
93
-	/**
94
-	 * @since 3.27.7
95
-	 * @see https://github.com/insideout10/wordlift-plugin/issues/1214
96
-	 */
97
-	Top_Entities::activate();
75
+    $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' );
76
+
77
+    $log->info( 'Activating WordLift...' );
78
+
79
+    require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
80
+    Wordlift_Activator::activate();
81
+
82
+    /**
83
+     * Tell the {@link Wordlift_Http_Api} class that we're activating, to let it run activation tasks.
84
+     *
85
+     * @see https://github.com/insideout10/wordlift-plugin/issues/820 related issue.
86
+     * @since 3.19.2
87
+     */
88
+    Wordlift_Http_Api::activate();
89
+
90
+    // Ensure the post type is registered before flushing the rewrite rules.
91
+    Wordlift_Entity_Post_Type_Service::get_instance()->register();
92
+    flush_rewrite_rules();
93
+    /**
94
+     * @since 3.27.7
95
+     * @see https://github.com/insideout10/wordlift-plugin/issues/1214
96
+     */
97
+    Top_Entities::activate();
98 98
 }
99 99
 
100 100
 /**
@@ -103,21 +103,21 @@  discard block
 block discarded – undo
103 103
  */
104 104
 function deactivate_wordlift() {
105 105
 
106
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
107
-	Wordlift_Deactivator::deactivate();
108
-	Wordlift_Http_Api::deactivate();
109
-	Ttl_Cache_Cleaner::deactivate();
110
-	/**
111
-	 * @since 3.27.7
112
-	 * @see https://github.com/insideout10/wordlift-plugin/issues/1214
113
-	 */
114
-	Top_Entities::deactivate();
115
-	/**
116
-	 * @since 3.27.8
117
-	 * Remove notification flag on deactivation.
118
-	 */
119
-	Key_Validation_Notice::remove_notification_flag();
120
-	flush_rewrite_rules();
106
+    require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
107
+    Wordlift_Deactivator::deactivate();
108
+    Wordlift_Http_Api::deactivate();
109
+    Ttl_Cache_Cleaner::deactivate();
110
+    /**
111
+     * @since 3.27.7
112
+     * @see https://github.com/insideout10/wordlift-plugin/issues/1214
113
+     */
114
+    Top_Entities::deactivate();
115
+    /**
116
+     * @since 3.27.8
117
+     * Remove notification flag on deactivation.
118
+     */
119
+    Key_Validation_Notice::remove_notification_flag();
120
+    flush_rewrite_rules();
121 121
 
122 122
 }
123 123
 
@@ -140,70 +140,70 @@  discard block
 block discarded – undo
140 140
  * @since    1.0.0
141 141
  */
142 142
 function run_wordlift() {
143
-	/**
144
-	 * Filter: wl_feature__enable__widgets.
145
-	 *
146
-	 * @param bool whether the widgets needed to be registered, defaults to true.
147
-	 *
148
-	 * @return bool
149
-	 * @since 3.27.6
150
-	 */
151
-	if ( apply_filters( 'wl_feature__enable__widgets', true ) ) {
152
-		add_action( 'widgets_init', 'wl_register_chord_widget' );
153
-		add_action( 'widgets_init', 'wl_register_geo_widget' );
154
-		add_action( 'widgets_init', 'wl_register_timeline_widget' );
155
-	}
156
-	add_filter( 'widget_text', 'do_shortcode' );
157
-
158
-
159
-	/**
160
-	 * Filter: wl_feature__enable__analysis
161
-	 *
162
-	 * @param bool Whether to send api request to analysis or not
163
-	 *
164
-	 * @return bool
165
-	 * @since 3.27.6
166
-	 */
167
-	if ( apply_filters( 'wl_feature__enable__analysis', true ) ) {
168
-		add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' );
169
-	} else {
170
-		add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' );
171
-	}
172
-
173
-	$plugin = new Wordlift();
174
-	$plugin->run();
175
-
176
-	// Initialize the TTL Cache Cleaner.
177
-	new Ttl_Cache_Cleaner();
178
-
179
-	// Load the new Post Adapter.
180
-	new Post_Adapter();
181
-
182
-	// Load the API Data Hooks.
183
-	new Api_Data_Hooks();
184
-
185
-	add_action( 'plugins_loaded', function () {
186
-		// All features from registry should be initialized here.
187
-		$features_registry = Features_Registry::get_instance();
188
-		$features_registry->initialize_all_features();
189
-	}, 5 );
190
-
191
-	add_action( 'plugins_loaded', function () use ( $plugin ) {
192
-
193
-		new Wordlift_Products_Navigator_Shortcode_REST();
194
-
195
-		// Register the Dataset module, requires `$api_service`.
196
-		require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php';
197
-		require_once plugin_dir_path( __FILE__ ) . 'wordlift/shipping-data/index.php';
198
-
199
-		/*
143
+    /**
144
+     * Filter: wl_feature__enable__widgets.
145
+     *
146
+     * @param bool whether the widgets needed to be registered, defaults to true.
147
+     *
148
+     * @return bool
149
+     * @since 3.27.6
150
+     */
151
+    if ( apply_filters( 'wl_feature__enable__widgets', true ) ) {
152
+        add_action( 'widgets_init', 'wl_register_chord_widget' );
153
+        add_action( 'widgets_init', 'wl_register_geo_widget' );
154
+        add_action( 'widgets_init', 'wl_register_timeline_widget' );
155
+    }
156
+    add_filter( 'widget_text', 'do_shortcode' );
157
+
158
+
159
+    /**
160
+     * Filter: wl_feature__enable__analysis
161
+     *
162
+     * @param bool Whether to send api request to analysis or not
163
+     *
164
+     * @return bool
165
+     * @since 3.27.6
166
+     */
167
+    if ( apply_filters( 'wl_feature__enable__analysis', true ) ) {
168
+        add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' );
169
+    } else {
170
+        add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' );
171
+    }
172
+
173
+    $plugin = new Wordlift();
174
+    $plugin->run();
175
+
176
+    // Initialize the TTL Cache Cleaner.
177
+    new Ttl_Cache_Cleaner();
178
+
179
+    // Load the new Post Adapter.
180
+    new Post_Adapter();
181
+
182
+    // Load the API Data Hooks.
183
+    new Api_Data_Hooks();
184
+
185
+    add_action( 'plugins_loaded', function () {
186
+        // All features from registry should be initialized here.
187
+        $features_registry = Features_Registry::get_instance();
188
+        $features_registry->initialize_all_features();
189
+    }, 5 );
190
+
191
+    add_action( 'plugins_loaded', function () use ( $plugin ) {
192
+
193
+        new Wordlift_Products_Navigator_Shortcode_REST();
194
+
195
+        // Register the Dataset module, requires `$api_service`.
196
+        require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php';
197
+        require_once plugin_dir_path( __FILE__ ) . 'wordlift/shipping-data/index.php';
198
+
199
+        /*
200 200
 		 * Require the Entity annotation cleanup module.
201 201
 		 *
202 202
 		 * @since 3.34.6
203 203
 		 */
204
-		require_once plugin_dir_path( __FILE__ ) . 'wordlift/cleanup/index.php';
204
+        require_once plugin_dir_path( __FILE__ ) . 'wordlift/cleanup/index.php';
205 205
 
206
-	} );
206
+    } );
207 207
 
208 208
 }
209 209
 
@@ -217,50 +217,50 @@  discard block
 block discarded – undo
217 217
  */
218 218
 function wordlift_plugin_autoload_register() {
219 219
 
220
-	spl_autoload_register( function ( $class_name ) {
220
+    spl_autoload_register( function ( $class_name ) {
221 221
 
222
-		// Bail out if these are not our classes.
223
-		if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) {
224
-			return false;
225
-		}
222
+        // Bail out if these are not our classes.
223
+        if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) {
224
+            return false;
225
+        }
226 226
 
227
-		$class_name_lc = strtolower( str_replace( '_', '-', $class_name ) );
227
+        $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) );
228 228
 
229
-		preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches );
229
+        preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches );
230 230
 
231
-		$path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] );
232
-		$file = 'class-' . $matches[2] . '.php';
231
+        $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] );
232
+        $file = 'class-' . $matches[2] . '.php';
233 233
 
234
-		$full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file;
234
+        $full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file;
235 235
 
236
-		if ( ! file_exists( $full_path ) ) {
237
-			echo esc_html( "Class $class_name not found at $full_path." );
236
+        if ( ! file_exists( $full_path ) ) {
237
+            echo esc_html( "Class $class_name not found at $full_path." );
238 238
 
239
-			return false;
240
-		}
239
+            return false;
240
+        }
241 241
 
242
-		require_once $full_path;
242
+        require_once $full_path;
243 243
 
244
-		return true;
245
-	} );
244
+        return true;
245
+    } );
246 246
 
247 247
 }
248 248
 
249 249
 function wl_block_categories( $categories, $post ) {
250
-	return array_merge(
251
-		$categories,
252
-		array(
253
-			array(
254
-				'slug'  => 'wordlift',
255
-				'title' => __( 'WordLift', 'wordlift' ),
256
-			),
257
-		)
258
-	);
250
+    return array_merge(
251
+        $categories,
252
+        array(
253
+            array(
254
+                'slug'  => 'wordlift',
255
+                'title' => __( 'WordLift', 'wordlift' ),
256
+            ),
257
+        )
258
+    );
259 259
 }
260 260
 
261 261
 add_filter( 'block_categories', 'wl_block_categories', 10, 2 );
262 262
 
263 263
 // Temporary fix for a typo in WooCommerce Extension.
264 264
 add_filter( 'wl_feature__enable__dataset', function ( $value ) {
265
-	return apply_filters( 'wl_features__enable__dataset', $value );
265
+    return apply_filters( 'wl_features__enable__dataset', $value );
266 266
 } );
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 use Wordlift\Post\Post_Adapter;
33 33
 
34 34
 // If this file is called directly, abort.
35
-if ( ! defined( 'WPINC' ) ) {
35
+if ( ! defined('WPINC')) {
36 36
 	die;
37 37
 }
38 38
 
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
  * @since 3.33.6
42 42
  *
43 43
  */
44
-if ( ! apply_filters( 'wl_is_enabled', true ) ) {
44
+if ( ! apply_filters('wl_is_enabled', true)) {
45 45
 	return;
46 46
 }
47 47
 
48
-require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
48
+require_once plugin_dir_path(__FILE__).'vendor/autoload.php';
49 49
 
50 50
 /*
51 51
 	 * We introduce the WordLift autoloader, since we start using classes in namespaces, i.e. Wordlift\Http.
@@ -56,15 +56,15 @@  discard block
 block discarded – undo
56 56
 
57 57
 
58 58
 // Include WordLift constants.
59
-require_once( 'wordlift_constants.php' );
59
+require_once('wordlift_constants.php');
60 60
 
61 61
 // Load modules.
62
-require_once( 'modules/core/wordlift_core.php' );
62
+require_once('modules/core/wordlift_core.php');
63 63
 
64
-require_once( 'deprecations.php' );
64
+require_once('deprecations.php');
65 65
 
66 66
 // Load early to enable/disable features.
67
-require_once plugin_dir_path( __FILE__ ) . 'wordlift/features/index.php';
67
+require_once plugin_dir_path(__FILE__).'wordlift/features/index.php';
68 68
 
69 69
 /**
70 70
  * The code that runs during plugin activation.
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function activate_wordlift() {
74 74
 
75
-	$log = Wordlift_Log_Service::get_logger( 'activate_wordlift' );
75
+	$log = Wordlift_Log_Service::get_logger('activate_wordlift');
76 76
 
77
-	$log->info( 'Activating WordLift...' );
77
+	$log->info('Activating WordLift...');
78 78
 
79
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
79
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php';
80 80
 	Wordlift_Activator::activate();
81 81
 
82 82
 	/**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
  */
104 104
 function deactivate_wordlift() {
105 105
 
106
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
106
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php';
107 107
 	Wordlift_Deactivator::deactivate();
108 108
 	Wordlift_Http_Api::deactivate();
109 109
 	Ttl_Cache_Cleaner::deactivate();
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
 
122 122
 }
123 123
 
124
-register_activation_hook( __FILE__, 'activate_wordlift' );
125
-register_deactivation_hook( __FILE__, 'deactivate_wordlift' );
124
+register_activation_hook(__FILE__, 'activate_wordlift');
125
+register_deactivation_hook(__FILE__, 'deactivate_wordlift');
126 126
 
127 127
 /**
128 128
  * The core plugin class that is used to define internationalization,
129 129
  * admin-specific hooks, and public-facing site hooks.
130 130
  */
131
-require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php';
131
+require plugin_dir_path(__FILE__).'includes/class-wordlift.php';
132 132
 
133 133
 /**
134 134
  * Begins execution of the plugin.
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
 	 * @return bool
149 149
 	 * @since 3.27.6
150 150
 	 */
151
-	if ( apply_filters( 'wl_feature__enable__widgets', true ) ) {
152
-		add_action( 'widgets_init', 'wl_register_chord_widget' );
153
-		add_action( 'widgets_init', 'wl_register_geo_widget' );
154
-		add_action( 'widgets_init', 'wl_register_timeline_widget' );
151
+	if (apply_filters('wl_feature__enable__widgets', true)) {
152
+		add_action('widgets_init', 'wl_register_chord_widget');
153
+		add_action('widgets_init', 'wl_register_geo_widget');
154
+		add_action('widgets_init', 'wl_register_timeline_widget');
155 155
 	}
156
-	add_filter( 'widget_text', 'do_shortcode' );
156
+	add_filter('widget_text', 'do_shortcode');
157 157
 
158 158
 
159 159
 	/**
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
 	 * @return bool
165 165
 	 * @since 3.27.6
166 166
 	 */
167
-	if ( apply_filters( 'wl_feature__enable__analysis', true ) ) {
168
-		add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' );
167
+	if (apply_filters('wl_feature__enable__analysis', true)) {
168
+		add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_action');
169 169
 	} else {
170
-		add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' );
170
+		add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action');
171 171
 	}
172 172
 
173 173
 	$plugin = new Wordlift();
@@ -182,26 +182,26 @@  discard block
 block discarded – undo
182 182
 	// Load the API Data Hooks.
183 183
 	new Api_Data_Hooks();
184 184
 
185
-	add_action( 'plugins_loaded', function () {
185
+	add_action('plugins_loaded', function() {
186 186
 		// All features from registry should be initialized here.
187 187
 		$features_registry = Features_Registry::get_instance();
188 188
 		$features_registry->initialize_all_features();
189
-	}, 5 );
189
+	}, 5);
190 190
 
191
-	add_action( 'plugins_loaded', function () use ( $plugin ) {
191
+	add_action('plugins_loaded', function() use ($plugin) {
192 192
 
193 193
 		new Wordlift_Products_Navigator_Shortcode_REST();
194 194
 
195 195
 		// Register the Dataset module, requires `$api_service`.
196
-		require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php';
197
-		require_once plugin_dir_path( __FILE__ ) . 'wordlift/shipping-data/index.php';
196
+		require_once plugin_dir_path(__FILE__).'wordlift/dataset/index.php';
197
+		require_once plugin_dir_path(__FILE__).'wordlift/shipping-data/index.php';
198 198
 
199 199
 		/*
200 200
 		 * Require the Entity annotation cleanup module.
201 201
 		 *
202 202
 		 * @since 3.34.6
203 203
 		 */
204
-		require_once plugin_dir_path( __FILE__ ) . 'wordlift/cleanup/index.php';
204
+		require_once plugin_dir_path(__FILE__).'wordlift/cleanup/index.php';
205 205
 
206 206
 	} );
207 207
 
@@ -217,24 +217,24 @@  discard block
 block discarded – undo
217 217
  */
218 218
 function wordlift_plugin_autoload_register() {
219 219
 
220
-	spl_autoload_register( function ( $class_name ) {
220
+	spl_autoload_register(function($class_name) {
221 221
 
222 222
 		// Bail out if these are not our classes.
223
-		if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) {
223
+		if (0 !== strpos($class_name, 'Wordlift\\')) {
224 224
 			return false;
225 225
 		}
226 226
 
227
-		$class_name_lc = strtolower( str_replace( '_', '-', $class_name ) );
227
+		$class_name_lc = strtolower(str_replace('_', '-', $class_name));
228 228
 
229
-		preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches );
229
+		preg_match('|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches);
230 230
 
231
-		$path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] );
232
-		$file = 'class-' . $matches[2] . '.php';
231
+		$path = str_replace('\\', DIRECTORY_SEPARATOR, $matches[1]);
232
+		$file = 'class-'.$matches[2].'.php';
233 233
 
234
-		$full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file;
234
+		$full_path = plugin_dir_path(__FILE__).$path.DIRECTORY_SEPARATOR.$file;
235 235
 
236
-		if ( ! file_exists( $full_path ) ) {
237
-			echo esc_html( "Class $class_name not found at $full_path." );
236
+		if ( ! file_exists($full_path)) {
237
+			echo esc_html("Class $class_name not found at $full_path.");
238 238
 
239 239
 			return false;
240 240
 		}
@@ -246,21 +246,21 @@  discard block
 block discarded – undo
246 246
 
247 247
 }
248 248
 
249
-function wl_block_categories( $categories, $post ) {
249
+function wl_block_categories($categories, $post) {
250 250
 	return array_merge(
251 251
 		$categories,
252 252
 		array(
253 253
 			array(
254 254
 				'slug'  => 'wordlift',
255
-				'title' => __( 'WordLift', 'wordlift' ),
255
+				'title' => __('WordLift', 'wordlift'),
256 256
 			),
257 257
 		)
258 258
 	);
259 259
 }
260 260
 
261
-add_filter( 'block_categories', 'wl_block_categories', 10, 2 );
261
+add_filter('block_categories', 'wl_block_categories', 10, 2);
262 262
 
263 263
 // Temporary fix for a typo in WooCommerce Extension.
264
-add_filter( 'wl_feature__enable__dataset', function ( $value ) {
265
-	return apply_filters( 'wl_features__enable__dataset', $value );
264
+add_filter('wl_feature__enable__dataset', function($value) {
265
+	return apply_filters('wl_features__enable__dataset', $value);
266 266
 } );
Please login to merge, or discard this patch.
src/wordlift/task/class-all-posts-task.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -11,46 +11,46 @@
 block discarded – undo
11 11
 
12 12
 class All_Posts_Task implements Task {
13 13
 
14
-	private $callable;
15
-
16
-	public function __construct( $callable ) {
17
-		$this->callable = $callable;
18
-	}
19
-
20
-	public function starting() {
21
-		global $wpdb;
22
-
23
-		// Try to get the count from transient, or load it from database.
24
-		if ( false === ( $count = get_transient( '_wl_task__all_posts_task__count' ) ) ) {
25
-			$count = $wpdb->get_var( "SELECT COUNT( 1 ) FROM $wpdb->posts" );
26
-			set_transient( '_wl_task__all_posts_task__count', $count, HOUR_IN_SECONDS );
27
-		}
28
-
29
-		return $count;
30
-	}
31
-
32
-	/**
33
-	 * @param $value mixed The incoming value.
34
-	 * @param $args {
35
-	 *
36
-	 * @type int $offset The index of the current item.
37
-	 * @type int $count The total number of items as provided by the `starting` function.
38
-	 * @type int $batch_size The number of items to process within this call.
39
-	 * }
40
-	 *
41
-	 * @return void
42
-	 */
43
-	public function tick( $value, $args ) {
44
-		global $wpdb;
45
-
46
-		$ids = $wpdb->get_col( $wpdb->prepare( "
14
+    private $callable;
15
+
16
+    public function __construct( $callable ) {
17
+        $this->callable = $callable;
18
+    }
19
+
20
+    public function starting() {
21
+        global $wpdb;
22
+
23
+        // Try to get the count from transient, or load it from database.
24
+        if ( false === ( $count = get_transient( '_wl_task__all_posts_task__count' ) ) ) {
25
+            $count = $wpdb->get_var( "SELECT COUNT( 1 ) FROM $wpdb->posts" );
26
+            set_transient( '_wl_task__all_posts_task__count', $count, HOUR_IN_SECONDS );
27
+        }
28
+
29
+        return $count;
30
+    }
31
+
32
+    /**
33
+     * @param $value mixed The incoming value.
34
+     * @param $args {
35
+     *
36
+     * @type int $offset The index of the current item.
37
+     * @type int $count The total number of items as provided by the `starting` function.
38
+     * @type int $batch_size The number of items to process within this call.
39
+     * }
40
+     *
41
+     * @return void
42
+     */
43
+    public function tick( $value, $args ) {
44
+        global $wpdb;
45
+
46
+        $ids = $wpdb->get_col( $wpdb->prepare( "
47 47
 			SELECT ID FROM wp_posts ORDER BY ID LIMIT %d,%d;
48 48
 		", $args['offset'], $args['batch_size'] ) );
49 49
 
50
-		foreach ( $ids as $id ) {
51
-			call_user_func( $this->callable, $id );
52
-		}
50
+        foreach ( $ids as $id ) {
51
+            call_user_func( $this->callable, $id );
52
+        }
53 53
 
54
-	}
54
+    }
55 55
 
56 56
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 	private $callable;
15 15
 
16
-	public function __construct( $callable ) {
16
+	public function __construct($callable) {
17 17
 		$this->callable = $callable;
18 18
 	}
19 19
 
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 		global $wpdb;
22 22
 
23 23
 		// Try to get the count from transient, or load it from database.
24
-		if ( false === ( $count = get_transient( '_wl_task__all_posts_task__count' ) ) ) {
25
-			$count = $wpdb->get_var( "SELECT COUNT( 1 ) FROM $wpdb->posts" );
26
-			set_transient( '_wl_task__all_posts_task__count', $count, HOUR_IN_SECONDS );
24
+		if (false === ($count = get_transient('_wl_task__all_posts_task__count'))) {
25
+			$count = $wpdb->get_var("SELECT COUNT( 1 ) FROM $wpdb->posts");
26
+			set_transient('_wl_task__all_posts_task__count', $count, HOUR_IN_SECONDS);
27 27
 		}
28 28
 
29 29
 		return $count;
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return void
42 42
 	 */
43
-	public function tick( $value, $args ) {
43
+	public function tick($value, $args) {
44 44
 		global $wpdb;
45 45
 
46
-		$ids = $wpdb->get_col( $wpdb->prepare( "
46
+		$ids = $wpdb->get_col($wpdb->prepare("
47 47
 			SELECT ID FROM wp_posts ORDER BY ID LIMIT %d,%d;
48
-		", $args['offset'], $args['batch_size'] ) );
48
+		", $args['offset'], $args['batch_size']));
49 49
 
50
-		foreach ( $ids as $id ) {
51
-			call_user_func( $this->callable, $id );
50
+		foreach ($ids as $id) {
51
+			call_user_func($this->callable, $id);
52 52
 		}
53 53
 
54 54
 	}
Please login to merge, or discard this patch.
src/wordlift/task/background/class-background-task-route.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -8,71 +8,71 @@
 block discarded – undo
8 8
 
9 9
 class Background_Task_Route {
10 10
 
11
-	const VERSION_STRING = 'wordlift/v1';
12
-
13
-	/**
14
-	 * @var Background_Task
15
-	 */
16
-	private $background_task;
17
-
18
-	/**
19
-	 * @var string
20
-	 */
21
-	private $route_name;
22
-
23
-	public function __construct( $background_task, $route_name ) {
24
-		$this->background_task = $background_task;
25
-		$this->route_name      = $route_name;
26
-	}
27
-
28
-	public static function create( $task, $route_name ) {
29
-		$route = new self( $task, $route_name );
30
-
31
-		add_action( 'rest_api_init', array( $route, 'register' ) );
32
-
33
-		return $route;
34
-	}
35
-
36
-	/**
37
-	 * @throws Exception if the input value is invalid.
38
-	 */
39
-	public function register() {
40
-		Assertions::starts_with( $this->route_name, '/', 'The route name must start with a slash.' );
41
-
42
-		register_rest_route( self::VERSION_STRING, $this->route_name, array(
43
-			'methods'             => WP_REST_Server::CREATABLE,
44
-			'callback'            => array( $this->background_task, 'start' ),
45
-			'permission_callback' => array( $this, 'permission_callback' ),
46
-		) );
47
-
48
-		register_rest_route( self::VERSION_STRING, $this->route_name, array(
49
-			'methods'             => WP_REST_Server::READABLE,
50
-			'callback'            => array( $this->background_task, 'get_info' ),
51
-			'permission_callback' => array( $this, 'permission_callback' ),
52
-		) );
53
-
54
-		register_rest_route( self::VERSION_STRING, $this->route_name, array(
55
-			'methods'             => WP_REST_Server::DELETABLE,
56
-			'callback'            => array( $this->background_task, 'stop' ),
57
-			'permission_callback' => array( $this, 'permission_callback' ),
58
-		) );
59
-
60
-		register_rest_route( self::VERSION_STRING, $this->route_name, array(
61
-			'methods'             => 'PUT',
62
-			'callback'            => array( $this->background_task, 'resume' ),
63
-			'permission_callback' => array( $this, 'permission_callback' ),
64
-		) );
65
-
66
-	}
67
-
68
-	public function permission_callback() {
69
-		$user = wp_get_current_user();
70
-
71
-		return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles );
72
-	}
73
-
74
-	public function get_rest_path() {
75
-		return self::VERSION_STRING . $this->route_name;
76
-	}
11
+    const VERSION_STRING = 'wordlift/v1';
12
+
13
+    /**
14
+     * @var Background_Task
15
+     */
16
+    private $background_task;
17
+
18
+    /**
19
+     * @var string
20
+     */
21
+    private $route_name;
22
+
23
+    public function __construct( $background_task, $route_name ) {
24
+        $this->background_task = $background_task;
25
+        $this->route_name      = $route_name;
26
+    }
27
+
28
+    public static function create( $task, $route_name ) {
29
+        $route = new self( $task, $route_name );
30
+
31
+        add_action( 'rest_api_init', array( $route, 'register' ) );
32
+
33
+        return $route;
34
+    }
35
+
36
+    /**
37
+     * @throws Exception if the input value is invalid.
38
+     */
39
+    public function register() {
40
+        Assertions::starts_with( $this->route_name, '/', 'The route name must start with a slash.' );
41
+
42
+        register_rest_route( self::VERSION_STRING, $this->route_name, array(
43
+            'methods'             => WP_REST_Server::CREATABLE,
44
+            'callback'            => array( $this->background_task, 'start' ),
45
+            'permission_callback' => array( $this, 'permission_callback' ),
46
+        ) );
47
+
48
+        register_rest_route( self::VERSION_STRING, $this->route_name, array(
49
+            'methods'             => WP_REST_Server::READABLE,
50
+            'callback'            => array( $this->background_task, 'get_info' ),
51
+            'permission_callback' => array( $this, 'permission_callback' ),
52
+        ) );
53
+
54
+        register_rest_route( self::VERSION_STRING, $this->route_name, array(
55
+            'methods'             => WP_REST_Server::DELETABLE,
56
+            'callback'            => array( $this->background_task, 'stop' ),
57
+            'permission_callback' => array( $this, 'permission_callback' ),
58
+        ) );
59
+
60
+        register_rest_route( self::VERSION_STRING, $this->route_name, array(
61
+            'methods'             => 'PUT',
62
+            'callback'            => array( $this->background_task, 'resume' ),
63
+            'permission_callback' => array( $this, 'permission_callback' ),
64
+        ) );
65
+
66
+    }
67
+
68
+    public function permission_callback() {
69
+        $user = wp_get_current_user();
70
+
71
+        return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles );
72
+    }
73
+
74
+    public function get_rest_path() {
75
+        return self::VERSION_STRING . $this->route_name;
76
+    }
77 77
 
78 78
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	private $route_name;
22 22
 
23
-	public function __construct( $background_task, $route_name ) {
23
+	public function __construct($background_task, $route_name) {
24 24
 		$this->background_task = $background_task;
25 25
 		$this->route_name      = $route_name;
26 26
 	}
27 27
 
28
-	public static function create( $task, $route_name ) {
29
-		$route = new self( $task, $route_name );
28
+	public static function create($task, $route_name) {
29
+		$route = new self($task, $route_name);
30 30
 
31
-		add_action( 'rest_api_init', array( $route, 'register' ) );
31
+		add_action('rest_api_init', array($route, 'register'));
32 32
 
33 33
 		return $route;
34 34
 	}
@@ -37,42 +37,42 @@  discard block
 block discarded – undo
37 37
 	 * @throws Exception if the input value is invalid.
38 38
 	 */
39 39
 	public function register() {
40
-		Assertions::starts_with( $this->route_name, '/', 'The route name must start with a slash.' );
40
+		Assertions::starts_with($this->route_name, '/', 'The route name must start with a slash.');
41 41
 
42
-		register_rest_route( self::VERSION_STRING, $this->route_name, array(
42
+		register_rest_route(self::VERSION_STRING, $this->route_name, array(
43 43
 			'methods'             => WP_REST_Server::CREATABLE,
44
-			'callback'            => array( $this->background_task, 'start' ),
45
-			'permission_callback' => array( $this, 'permission_callback' ),
46
-		) );
44
+			'callback'            => array($this->background_task, 'start'),
45
+			'permission_callback' => array($this, 'permission_callback'),
46
+		));
47 47
 
48
-		register_rest_route( self::VERSION_STRING, $this->route_name, array(
48
+		register_rest_route(self::VERSION_STRING, $this->route_name, array(
49 49
 			'methods'             => WP_REST_Server::READABLE,
50
-			'callback'            => array( $this->background_task, 'get_info' ),
51
-			'permission_callback' => array( $this, 'permission_callback' ),
52
-		) );
50
+			'callback'            => array($this->background_task, 'get_info'),
51
+			'permission_callback' => array($this, 'permission_callback'),
52
+		));
53 53
 
54
-		register_rest_route( self::VERSION_STRING, $this->route_name, array(
54
+		register_rest_route(self::VERSION_STRING, $this->route_name, array(
55 55
 			'methods'             => WP_REST_Server::DELETABLE,
56
-			'callback'            => array( $this->background_task, 'stop' ),
57
-			'permission_callback' => array( $this, 'permission_callback' ),
58
-		) );
56
+			'callback'            => array($this->background_task, 'stop'),
57
+			'permission_callback' => array($this, 'permission_callback'),
58
+		));
59 59
 
60
-		register_rest_route( self::VERSION_STRING, $this->route_name, array(
60
+		register_rest_route(self::VERSION_STRING, $this->route_name, array(
61 61
 			'methods'             => 'PUT',
62
-			'callback'            => array( $this->background_task, 'resume' ),
63
-			'permission_callback' => array( $this, 'permission_callback' ),
64
-		) );
62
+			'callback'            => array($this->background_task, 'resume'),
63
+			'permission_callback' => array($this, 'permission_callback'),
64
+		));
65 65
 
66 66
 	}
67 67
 
68 68
 	public function permission_callback() {
69 69
 		$user = wp_get_current_user();
70 70
 
71
-		return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles );
71
+		return is_super_admin($user->ID) || in_array('administrator', (array) $user->roles);
72 72
 	}
73 73
 
74 74
 	public function get_rest_path() {
75
-		return self::VERSION_STRING . $this->route_name;
75
+		return self::VERSION_STRING.$this->route_name;
76 76
 	}
77 77
 
78 78
 }
Please login to merge, or discard this patch.
src/wordlift/task/background/class-background-task-page.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -8,63 +8,63 @@  discard block
 block discarded – undo
8 8
 
9 9
 class Background_Task_Page {
10 10
 
11
-	private $title;
12
-
13
-	private $menu_slug;
14
-
15
-	/**
16
-	 * @var Background_Task_Route $background_task_route
17
-	 */
18
-	private $background_task_route;
19
-
20
-	/**
21
-	 * @throws Exception if one or more parameters are invalid.
22
-	 */
23
-	public function __construct( $title, $menu_slug, $background_task_route ) {
24
-		Assertions::not_empty( $title, '`$title` cannot be empty.' );
25
-		Assertions::not_empty( $menu_slug, '`$menu_slug` cannot be empty.' );
26
-		Assertions::is_a( $background_task_route, 'Wordlift\Task\Background\Background_Task_Route', '`Background_Task_Route` must be of type `Wordlift\Task\Background\Background_Route`.' );
27
-
28
-		add_action( 'admin_menu', array( $this, 'admin_menu' ) );
29
-
30
-		$this->title                 = $title;
31
-		$this->menu_slug             = $menu_slug;
32
-		$this->background_task_route = $background_task_route;
33
-	}
34
-
35
-	/**
36
-	 * @throws Exception if one or more parameters are invalid.
37
-	 */
38
-	public static function create( $title, $menu_slug, $background_route ) {
39
-		return new self( $title, $menu_slug, $background_route );
40
-	}
41
-
42
-	public function admin_menu() {
43
-
44
-		add_submenu_page( 'wl_admin_menu', $this->title, $this->title, 'manage_options', $this->menu_slug, array(
45
-			$this,
46
-			'render'
47
-		) );
48
-
49
-	}
50
-
51
-	public function render() {
52
-
53
-		wp_enqueue_style(
54
-			'wl-task-page',
55
-			plugin_dir_url( __FILE__ ) . 'assets/task-page.css',
56
-			array(),
57
-			Wordlift::get_instance()->get_version(),
58
-			'all' );
59
-
60
-		wp_enqueue_script(
61
-			'wl-task-page',
62
-			plugin_dir_url( __FILE__ ) . 'assets/task-page.js',
63
-			array( 'wp-api' ),
64
-			Wordlift::get_instance()->get_version() );
65
-
66
-		wp_localize_script( 'wl-task-page', '_wlTaskPageSettings', array( 'rest_path' => $this->background_task_route->get_rest_path() ) );
67
-		?>
11
+    private $title;
12
+
13
+    private $menu_slug;
14
+
15
+    /**
16
+     * @var Background_Task_Route $background_task_route
17
+     */
18
+    private $background_task_route;
19
+
20
+    /**
21
+     * @throws Exception if one or more parameters are invalid.
22
+     */
23
+    public function __construct( $title, $menu_slug, $background_task_route ) {
24
+        Assertions::not_empty( $title, '`$title` cannot be empty.' );
25
+        Assertions::not_empty( $menu_slug, '`$menu_slug` cannot be empty.' );
26
+        Assertions::is_a( $background_task_route, 'Wordlift\Task\Background\Background_Task_Route', '`Background_Task_Route` must be of type `Wordlift\Task\Background\Background_Route`.' );
27
+
28
+        add_action( 'admin_menu', array( $this, 'admin_menu' ) );
29
+
30
+        $this->title                 = $title;
31
+        $this->menu_slug             = $menu_slug;
32
+        $this->background_task_route = $background_task_route;
33
+    }
34
+
35
+    /**
36
+     * @throws Exception if one or more parameters are invalid.
37
+     */
38
+    public static function create( $title, $menu_slug, $background_route ) {
39
+        return new self( $title, $menu_slug, $background_route );
40
+    }
41
+
42
+    public function admin_menu() {
43
+
44
+        add_submenu_page( 'wl_admin_menu', $this->title, $this->title, 'manage_options', $this->menu_slug, array(
45
+            $this,
46
+            'render'
47
+        ) );
48
+
49
+    }
50
+
51
+    public function render() {
52
+
53
+        wp_enqueue_style(
54
+            'wl-task-page',
55
+            plugin_dir_url( __FILE__ ) . 'assets/task-page.css',
56
+            array(),
57
+            Wordlift::get_instance()->get_version(),
58
+            'all' );
59
+
60
+        wp_enqueue_script(
61
+            'wl-task-page',
62
+            plugin_dir_url( __FILE__ ) . 'assets/task-page.js',
63
+            array( 'wp-api' ),
64
+            Wordlift::get_instance()->get_version() );
65
+
66
+        wp_localize_script( 'wl-task-page', '_wlTaskPageSettings', array( 'rest_path' => $this->background_task_route->get_rest_path() ) );
67
+        ?>
68 68
         <div class="wrap">
69 69
             <h2><?php echo esc_html( $this->title ); ?></h2>
70 70
 
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
             </div>
75 75
 
76 76
             <button id="wl-start-btn" type="button" class="button button-large button-primary"><?php
77
-				esc_html_e( 'Start', 'wordlift-framework' ); ?></button>
77
+                esc_html_e( 'Start', 'wordlift-framework' ); ?></button>
78 78
             <button id="wl-stop-btn" type="button" class="button button-large button-primary hidden"><?php
79
-				esc_html_e( 'Stop', 'wordlift-framework' ); ?></button>
79
+                esc_html_e( 'Stop', 'wordlift-framework' ); ?></button>
80 80
 
81 81
         </div>
82 82
 		<?php
83
-	}
83
+    }
84 84
 
85 85
 }
86 86
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 	/**
21 21
 	 * @throws Exception if one or more parameters are invalid.
22 22
 	 */
23
-	public function __construct( $title, $menu_slug, $background_task_route ) {
24
-		Assertions::not_empty( $title, '`$title` cannot be empty.' );
25
-		Assertions::not_empty( $menu_slug, '`$menu_slug` cannot be empty.' );
26
-		Assertions::is_a( $background_task_route, 'Wordlift\Task\Background\Background_Task_Route', '`Background_Task_Route` must be of type `Wordlift\Task\Background\Background_Route`.' );
23
+	public function __construct($title, $menu_slug, $background_task_route) {
24
+		Assertions::not_empty($title, '`$title` cannot be empty.');
25
+		Assertions::not_empty($menu_slug, '`$menu_slug` cannot be empty.');
26
+		Assertions::is_a($background_task_route, 'Wordlift\Task\Background\Background_Task_Route', '`Background_Task_Route` must be of type `Wordlift\Task\Background\Background_Route`.');
27 27
 
28
-		add_action( 'admin_menu', array( $this, 'admin_menu' ) );
28
+		add_action('admin_menu', array($this, 'admin_menu'));
29 29
 
30 30
 		$this->title                 = $title;
31 31
 		$this->menu_slug             = $menu_slug;
@@ -35,16 +35,16 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * @throws Exception if one or more parameters are invalid.
37 37
 	 */
38
-	public static function create( $title, $menu_slug, $background_route ) {
39
-		return new self( $title, $menu_slug, $background_route );
38
+	public static function create($title, $menu_slug, $background_route) {
39
+		return new self($title, $menu_slug, $background_route);
40 40
 	}
41 41
 
42 42
 	public function admin_menu() {
43 43
 
44
-		add_submenu_page( 'wl_admin_menu', $this->title, $this->title, 'manage_options', $this->menu_slug, array(
44
+		add_submenu_page('wl_admin_menu', $this->title, $this->title, 'manage_options', $this->menu_slug, array(
45 45
 			$this,
46 46
 			'render'
47
-		) );
47
+		));
48 48
 
49 49
 	}
50 50
 
@@ -52,21 +52,21 @@  discard block
 block discarded – undo
52 52
 
53 53
 		wp_enqueue_style(
54 54
 			'wl-task-page',
55
-			plugin_dir_url( __FILE__ ) . 'assets/task-page.css',
55
+			plugin_dir_url(__FILE__).'assets/task-page.css',
56 56
 			array(),
57 57
 			Wordlift::get_instance()->get_version(),
58 58
 			'all' );
59 59
 
60 60
 		wp_enqueue_script(
61 61
 			'wl-task-page',
62
-			plugin_dir_url( __FILE__ ) . 'assets/task-page.js',
63
-			array( 'wp-api' ),
62
+			plugin_dir_url(__FILE__).'assets/task-page.js',
63
+			array('wp-api'),
64 64
 			Wordlift::get_instance()->get_version() );
65 65
 
66
-		wp_localize_script( 'wl-task-page', '_wlTaskPageSettings', array( 'rest_path' => $this->background_task_route->get_rest_path() ) );
66
+		wp_localize_script('wl-task-page', '_wlTaskPageSettings', array('rest_path' => $this->background_task_route->get_rest_path()));
67 67
 		?>
68 68
         <div class="wrap">
69
-            <h2><?php echo esc_html( $this->title ); ?></h2>
69
+            <h2><?php echo esc_html($this->title); ?></h2>
70 70
 
71 71
             <div class="wl-task__progress" style="border: 1px solid #23282D; height: 20px; margin: 8px 0;">
72 72
                 <div class="wl-task__progress__bar"
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
             </div>
75 75
 
76 76
             <button id="wl-start-btn" type="button" class="button button-large button-primary"><?php
77
-				esc_html_e( 'Start', 'wordlift-framework' ); ?></button>
77
+				esc_html_e('Start', 'wordlift-framework'); ?></button>
78 78
             <button id="wl-stop-btn" type="button" class="button button-large button-primary hidden"><?php
79
-				esc_html_e( 'Stop', 'wordlift-framework' ); ?></button>
79
+				esc_html_e('Stop', 'wordlift-framework'); ?></button>
80 80
 
81 81
         </div>
82 82
 		<?php
Please login to merge, or discard this patch.