Completed
Pull Request — master (#1524)
by Naveen
01:09
created
src/includes/class-wordlift-content-filter-service.php 2 patches
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -23,264 +23,264 @@
 block discarded – undo
23 23
  */
24 24
 class Wordlift_Content_Filter_Service {
25 25
 
26
-	/**
27
-	 * The pattern to find entities in text.
28
-	 *
29
-	 * @since 3.8.0
30
-	 */
31
-	const PATTERN = '/<(\\w+)[^<]*class="([^"]*)"\\sitemid=\"([^"]+)\"[^>]*>([^<]*)<\\/\\1>/i';
32
-
33
-	/**
34
-	 * A {@link Wordlift_Entity_Service} instance.
35
-	 *
36
-	 * @since  3.8.0
37
-	 * @access private
38
-	 * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance.
39
-	 */
40
-	private $entity_service;
41
-
42
-	/**
43
-	 * The `link by default` setting.
44
-	 *
45
-	 * @since  3.13.0
46
-	 * @access private
47
-	 * @var bool True if link by default is enabled otherwise false.
48
-	 */
49
-	private $is_link_by_default;
50
-
51
-	private $linked_object_ids = array();
52
-
53
-	/**
54
-	 * The {@link Wordlift_Entity_Uri_Service} instance.
55
-	 *
56
-	 * @since  3.16.3
57
-	 * @access private
58
-	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
59
-	 */
60
-	private $entity_uri_service;
61
-
62
-	/**
63
-	 * A {@link Wordlift_Log_Service} instance.
64
-	 *
65
-	 * @since 3.16.0
66
-	 *
67
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
68
-	 */
69
-	private $log;
70
-	/**
71
-	 * @var Object_Link_Provider
72
-	 */
73
-	private $object_link_provider;
74
-
75
-	/**
76
-	 * Create a {@link Wordlift_Content_Filter_Service} instance.
77
-	 *
78
-	 * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
79
-	 * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
80
-	 *
81
-	 * @since 3.8.0
82
-	 *
83
-	 */
84
-	protected function __construct( $entity_service, $entity_uri_service ) {
85
-
86
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
87
-
88
-		$this->entity_service       = $entity_service;
89
-		$this->entity_uri_service   = $entity_uri_service;
90
-		$this->object_link_provider = Object_Link_Provider::get_instance();
91
-
92
-	}
93
-
94
-	private static $instance = null;
95
-
96
-	/**
97
-	 * Get the {@link Wordlift_Content_Filter_Service} singleton instance.
98
-	 *
99
-	 * @return \Wordlift_Content_Filter_Service The {@link Wordlift_Content_Filter_Service} singleton instance.
100
-	 * @since 3.14.2
101
-	 */
102
-	public static function get_instance() {
103
-
104
-		if ( ! isset( self::$instance ) ) {
105
-			self::$instance = new self( Wordlift_Entity_Service::get_instance(), Wordlift_Entity_Uri_Service::get_instance() );
106
-		}
107
-
108
-		return self::$instance;
109
-	}
110
-
111
-	/**
112
-	 * Mangle the content by adding links to the entity pages. This function is
113
-	 * hooked to the 'the_content' WP's filter.
114
-	 *
115
-	 * @param string $content The content being filtered.
116
-	 *
117
-	 * @return string The filtered content.
118
-	 * @since 3.8.0
119
-	 *
120
-	 */
121
-	public function the_content( $content ) {
122
-		$this->log->trace( "Filtering content [ " . ( is_singular() ? 'yes' : 'no' ) . " ]..." );
123
-
124
-		// Links should be added only on the front end and not for RSS.
125
-		if ( is_feed() ) {
126
-			return $content;
127
-		}
128
-
129
-		// Preload the `link by default` setting.
130
-		$this->is_link_by_default = Wordlift_Configuration_Service::get_instance()->is_link_by_default();
131
-
132
-		// Reset the array of of entity post ids linked from the post content.
133
-		// This is used to avoid linking more the once the same post.
134
-		$this->linked_object_ids = array();
135
-
136
-		// Preload URIs.
137
-		$matches = array();
138
-		preg_match_all( self::PATTERN, $content, $matches );
139
-
140
-		// Bail out if there are no URIs.
141
-		if ( empty( $matches[3] ) ) {
142
-			return $content;
143
-		}
144
-
145
-		// Preload the URIs.
146
-		$this->entity_uri_service->preload_uris( $matches[3] );
147
-
148
-		// Replace each match of the entity tag with the entity link. If an error
149
-		// occurs fail silently returning the original content.
150
-		$result = preg_replace_callback( self::PATTERN, array(
151
-			$this,
152
-			'link',
153
-		), $content ) ?: $content;
154
-
155
-		$this->entity_uri_service->reset_uris();
156
-
157
-		return $result;
158
-	}
159
-
160
-	/**
161
-	 * Get the entity match and replace it with a page link.
162
-	 *
163
-	 * @param array $matches An array of matches.
164
-	 *
165
-	 * @return string The replaced text with the link to the entity page.
166
-	 * @since 3.8.0
167
-	 *
168
-	 */
169
-	private function link( $matches ) {
170
-
171
-		// Get the entity itemid URI and label.
172
-		$css_class = $matches[2];
173
-		$uri       = $matches[3];
174
-		$label     = $matches[4];
175
-
176
-
177
-
178
-		$link = - 1 < strpos( $css_class, 'wl-link' );
179
-
180
-		// If the entity should not be linked and link by default is also disabled,
181
-		// then don't lookup the entity on the table.
182
-		if ( ! $this->is_link_by_default && ! $link ) {
183
-			return $label;
184
-		}
185
-
186
-		$content_service = Wordpress_Content_Service::get_instance();
187
-		$content         = $content_service->get_by_entity_id_or_same_as( $uri );
188
-
189
-		// If no content is found, return the label, that is _remove the annotation_.
190
-		if ( ! isset( $content ) ) {
191
-			return $label;
192
-		}
193
-
194
-		$object_id                   = $content->get_id();
195
-		$object_type                 = $content->get_object_type_enum();
196
-		$object_id_unique_identifier = $object_type . "_" . $object_id;
197
-
198
-
199
-		$no_link = - 1 < strpos( $css_class, 'wl-no-link' )
200
-		           // Do not link if already linked.
201
-		           || $this->is_already_linked( $object_id_unique_identifier );
202
-
203
-		// Don't link if links are disabled and the entity is not link or the
204
-		// entity is do not link.
205
-		$dont_link = ( ! $this->is_link_by_default && ! $link ) || $no_link;
206
-
207
-		// Return the label if it's don't link.
208
-		if ( $dont_link ) {
209
-			return $label;
210
-		}
211
-
212
-		/**
213
-		 * @since 3.32.0
214
-		 * Object_ids are prefixed with object_type to prevent conflicts.
215
-		 */
216
-		$this->linked_object_ids[] = $object_id_unique_identifier;
217
-
218
-		// Get the link.
219
-		$href = Wordlift_Post_Adapter::get_production_permalink( $object_id, $object_type );
220
-
221
-		// Bail out if the `$href` has been reset.
222
-		if ( empty( $href ) ) {
223
-			return $label;
224
-		}
225
-
226
-		return Link_Builder::create( $uri, $object_id )
227
-		                   ->label( $label )
228
-		                   ->href( $href )
229
-		                   ->generate_link();
230
-	}
231
-
232
-
233
-	/**
234
-	 * Get a string to be used as a title attribute in links to a post
235
-	 *
236
-	 * @param int $post_id The post id of the post being linked.
237
-	 * @param string $ignore_label A label to ignore.
238
-	 *
239
-	 * @return string    The title to be used in the link. An empty string when
240
-	 *                    there is no alternative that is not the $ignore_label.
241
-	 * @deprecated 3.32.0 Use object link provider to get the link title for getting link
242
-	 * title for different types.
243
-	 * @since 3.15.0
244
-	 *
245
-	 * As of 3.32.0 this method is not used anywhere in the core, this should be removed
246
-	 * from tests and companion plugins.
247
-	 *
248
-	 */
249
-	function get_link_title( $post_id, $ignore_label, $object_type = Object_Type_Enum::POST ) {
250
-		return $this->object_link_provider->get_link_title( $post_id, $ignore_label, $object_type );
251
-	}
252
-
253
-	/**
254
-	 * Get the entity URIs (configured in the `itemid` attribute) contained in
255
-	 * the provided content.
256
-	 *
257
-	 * @param string $content The content.
258
-	 *
259
-	 * @return array An array of URIs.
260
-	 * @since 3.14.2
261
-	 *
262
-	 */
263
-	public function get_entity_uris( $content ) {
264
-
265
-		$matches = array();
266
-		preg_match_all( Wordlift_Content_Filter_Service::PATTERN, $content, $matches );
267
-
268
-		// We need to use `array_values` here in order to avoid further `json_encode`
269
-		// to turn it into an object (since if the 3rd match isn't found the index
270
-		// is not sequential.
271
-		//
272
-		// See https://github.com/insideout10/wordlift-plugin/issues/646.
273
-		return array_values( array_unique( $matches[3] ) );
274
-	}
275
-
276
-
277
-	/**
278
-	 * @param $post_id
279
-	 *
280
-	 * @return bool
281
-	 */
282
-	private function is_already_linked( $post_id ) {
283
-		return in_array( $post_id, $this->linked_object_ids );
284
-	}
26
+    /**
27
+     * The pattern to find entities in text.
28
+     *
29
+     * @since 3.8.0
30
+     */
31
+    const PATTERN = '/<(\\w+)[^<]*class="([^"]*)"\\sitemid=\"([^"]+)\"[^>]*>([^<]*)<\\/\\1>/i';
32
+
33
+    /**
34
+     * A {@link Wordlift_Entity_Service} instance.
35
+     *
36
+     * @since  3.8.0
37
+     * @access private
38
+     * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance.
39
+     */
40
+    private $entity_service;
41
+
42
+    /**
43
+     * The `link by default` setting.
44
+     *
45
+     * @since  3.13.0
46
+     * @access private
47
+     * @var bool True if link by default is enabled otherwise false.
48
+     */
49
+    private $is_link_by_default;
50
+
51
+    private $linked_object_ids = array();
52
+
53
+    /**
54
+     * The {@link Wordlift_Entity_Uri_Service} instance.
55
+     *
56
+     * @since  3.16.3
57
+     * @access private
58
+     * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
59
+     */
60
+    private $entity_uri_service;
61
+
62
+    /**
63
+     * A {@link Wordlift_Log_Service} instance.
64
+     *
65
+     * @since 3.16.0
66
+     *
67
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
68
+     */
69
+    private $log;
70
+    /**
71
+     * @var Object_Link_Provider
72
+     */
73
+    private $object_link_provider;
74
+
75
+    /**
76
+     * Create a {@link Wordlift_Content_Filter_Service} instance.
77
+     *
78
+     * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
79
+     * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
80
+     *
81
+     * @since 3.8.0
82
+     *
83
+     */
84
+    protected function __construct( $entity_service, $entity_uri_service ) {
85
+
86
+        $this->log = Wordlift_Log_Service::get_logger( get_class() );
87
+
88
+        $this->entity_service       = $entity_service;
89
+        $this->entity_uri_service   = $entity_uri_service;
90
+        $this->object_link_provider = Object_Link_Provider::get_instance();
91
+
92
+    }
93
+
94
+    private static $instance = null;
95
+
96
+    /**
97
+     * Get the {@link Wordlift_Content_Filter_Service} singleton instance.
98
+     *
99
+     * @return \Wordlift_Content_Filter_Service The {@link Wordlift_Content_Filter_Service} singleton instance.
100
+     * @since 3.14.2
101
+     */
102
+    public static function get_instance() {
103
+
104
+        if ( ! isset( self::$instance ) ) {
105
+            self::$instance = new self( Wordlift_Entity_Service::get_instance(), Wordlift_Entity_Uri_Service::get_instance() );
106
+        }
107
+
108
+        return self::$instance;
109
+    }
110
+
111
+    /**
112
+     * Mangle the content by adding links to the entity pages. This function is
113
+     * hooked to the 'the_content' WP's filter.
114
+     *
115
+     * @param string $content The content being filtered.
116
+     *
117
+     * @return string The filtered content.
118
+     * @since 3.8.0
119
+     *
120
+     */
121
+    public function the_content( $content ) {
122
+        $this->log->trace( "Filtering content [ " . ( is_singular() ? 'yes' : 'no' ) . " ]..." );
123
+
124
+        // Links should be added only on the front end and not for RSS.
125
+        if ( is_feed() ) {
126
+            return $content;
127
+        }
128
+
129
+        // Preload the `link by default` setting.
130
+        $this->is_link_by_default = Wordlift_Configuration_Service::get_instance()->is_link_by_default();
131
+
132
+        // Reset the array of of entity post ids linked from the post content.
133
+        // This is used to avoid linking more the once the same post.
134
+        $this->linked_object_ids = array();
135
+
136
+        // Preload URIs.
137
+        $matches = array();
138
+        preg_match_all( self::PATTERN, $content, $matches );
139
+
140
+        // Bail out if there are no URIs.
141
+        if ( empty( $matches[3] ) ) {
142
+            return $content;
143
+        }
144
+
145
+        // Preload the URIs.
146
+        $this->entity_uri_service->preload_uris( $matches[3] );
147
+
148
+        // Replace each match of the entity tag with the entity link. If an error
149
+        // occurs fail silently returning the original content.
150
+        $result = preg_replace_callback( self::PATTERN, array(
151
+            $this,
152
+            'link',
153
+        ), $content ) ?: $content;
154
+
155
+        $this->entity_uri_service->reset_uris();
156
+
157
+        return $result;
158
+    }
159
+
160
+    /**
161
+     * Get the entity match and replace it with a page link.
162
+     *
163
+     * @param array $matches An array of matches.
164
+     *
165
+     * @return string The replaced text with the link to the entity page.
166
+     * @since 3.8.0
167
+     *
168
+     */
169
+    private function link( $matches ) {
170
+
171
+        // Get the entity itemid URI and label.
172
+        $css_class = $matches[2];
173
+        $uri       = $matches[3];
174
+        $label     = $matches[4];
175
+
176
+
177
+
178
+        $link = - 1 < strpos( $css_class, 'wl-link' );
179
+
180
+        // If the entity should not be linked and link by default is also disabled,
181
+        // then don't lookup the entity on the table.
182
+        if ( ! $this->is_link_by_default && ! $link ) {
183
+            return $label;
184
+        }
185
+
186
+        $content_service = Wordpress_Content_Service::get_instance();
187
+        $content         = $content_service->get_by_entity_id_or_same_as( $uri );
188
+
189
+        // If no content is found, return the label, that is _remove the annotation_.
190
+        if ( ! isset( $content ) ) {
191
+            return $label;
192
+        }
193
+
194
+        $object_id                   = $content->get_id();
195
+        $object_type                 = $content->get_object_type_enum();
196
+        $object_id_unique_identifier = $object_type . "_" . $object_id;
197
+
198
+
199
+        $no_link = - 1 < strpos( $css_class, 'wl-no-link' )
200
+                    // Do not link if already linked.
201
+                   || $this->is_already_linked( $object_id_unique_identifier );
202
+
203
+        // Don't link if links are disabled and the entity is not link or the
204
+        // entity is do not link.
205
+        $dont_link = ( ! $this->is_link_by_default && ! $link ) || $no_link;
206
+
207
+        // Return the label if it's don't link.
208
+        if ( $dont_link ) {
209
+            return $label;
210
+        }
211
+
212
+        /**
213
+         * @since 3.32.0
214
+         * Object_ids are prefixed with object_type to prevent conflicts.
215
+         */
216
+        $this->linked_object_ids[] = $object_id_unique_identifier;
217
+
218
+        // Get the link.
219
+        $href = Wordlift_Post_Adapter::get_production_permalink( $object_id, $object_type );
220
+
221
+        // Bail out if the `$href` has been reset.
222
+        if ( empty( $href ) ) {
223
+            return $label;
224
+        }
225
+
226
+        return Link_Builder::create( $uri, $object_id )
227
+                            ->label( $label )
228
+                            ->href( $href )
229
+                            ->generate_link();
230
+    }
231
+
232
+
233
+    /**
234
+     * Get a string to be used as a title attribute in links to a post
235
+     *
236
+     * @param int $post_id The post id of the post being linked.
237
+     * @param string $ignore_label A label to ignore.
238
+     *
239
+     * @return string    The title to be used in the link. An empty string when
240
+     *                    there is no alternative that is not the $ignore_label.
241
+     * @deprecated 3.32.0 Use object link provider to get the link title for getting link
242
+     * title for different types.
243
+     * @since 3.15.0
244
+     *
245
+     * As of 3.32.0 this method is not used anywhere in the core, this should be removed
246
+     * from tests and companion plugins.
247
+     *
248
+     */
249
+    function get_link_title( $post_id, $ignore_label, $object_type = Object_Type_Enum::POST ) {
250
+        return $this->object_link_provider->get_link_title( $post_id, $ignore_label, $object_type );
251
+    }
252
+
253
+    /**
254
+     * Get the entity URIs (configured in the `itemid` attribute) contained in
255
+     * the provided content.
256
+     *
257
+     * @param string $content The content.
258
+     *
259
+     * @return array An array of URIs.
260
+     * @since 3.14.2
261
+     *
262
+     */
263
+    public function get_entity_uris( $content ) {
264
+
265
+        $matches = array();
266
+        preg_match_all( Wordlift_Content_Filter_Service::PATTERN, $content, $matches );
267
+
268
+        // We need to use `array_values` here in order to avoid further `json_encode`
269
+        // to turn it into an object (since if the 3rd match isn't found the index
270
+        // is not sequential.
271
+        //
272
+        // See https://github.com/insideout10/wordlift-plugin/issues/646.
273
+        return array_values( array_unique( $matches[3] ) );
274
+    }
275
+
276
+
277
+    /**
278
+     * @param $post_id
279
+     *
280
+     * @return bool
281
+     */
282
+    private function is_already_linked( $post_id ) {
283
+        return in_array( $post_id, $this->linked_object_ids );
284
+    }
285 285
 
286 286
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 	 * @since 3.8.0
82 82
 	 *
83 83
 	 */
84
-	protected function __construct( $entity_service, $entity_uri_service ) {
84
+	protected function __construct($entity_service, $entity_uri_service) {
85 85
 
86
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
86
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
87 87
 
88 88
 		$this->entity_service       = $entity_service;
89 89
 		$this->entity_uri_service   = $entity_uri_service;
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public static function get_instance() {
103 103
 
104
-		if ( ! isset( self::$instance ) ) {
105
-			self::$instance = new self( Wordlift_Entity_Service::get_instance(), Wordlift_Entity_Uri_Service::get_instance() );
104
+		if ( ! isset(self::$instance)) {
105
+			self::$instance = new self(Wordlift_Entity_Service::get_instance(), Wordlift_Entity_Uri_Service::get_instance());
106 106
 		}
107 107
 
108 108
 		return self::$instance;
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 	 * @since 3.8.0
119 119
 	 *
120 120
 	 */
121
-	public function the_content( $content ) {
122
-		$this->log->trace( "Filtering content [ " . ( is_singular() ? 'yes' : 'no' ) . " ]..." );
121
+	public function the_content($content) {
122
+		$this->log->trace("Filtering content [ ".(is_singular() ? 'yes' : 'no')." ]...");
123 123
 
124 124
 		// Links should be added only on the front end and not for RSS.
125
-		if ( is_feed() ) {
125
+		if (is_feed()) {
126 126
 			return $content;
127 127
 		}
128 128
 
@@ -135,22 +135,22 @@  discard block
 block discarded – undo
135 135
 
136 136
 		// Preload URIs.
137 137
 		$matches = array();
138
-		preg_match_all( self::PATTERN, $content, $matches );
138
+		preg_match_all(self::PATTERN, $content, $matches);
139 139
 
140 140
 		// Bail out if there are no URIs.
141
-		if ( empty( $matches[3] ) ) {
141
+		if (empty($matches[3])) {
142 142
 			return $content;
143 143
 		}
144 144
 
145 145
 		// Preload the URIs.
146
-		$this->entity_uri_service->preload_uris( $matches[3] );
146
+		$this->entity_uri_service->preload_uris($matches[3]);
147 147
 
148 148
 		// Replace each match of the entity tag with the entity link. If an error
149 149
 		// occurs fail silently returning the original content.
150
-		$result = preg_replace_callback( self::PATTERN, array(
150
+		$result = preg_replace_callback(self::PATTERN, array(
151 151
 			$this,
152 152
 			'link',
153
-		), $content ) ?: $content;
153
+		), $content) ?: $content;
154 154
 
155 155
 		$this->entity_uri_service->reset_uris();
156 156
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * @since 3.8.0
167 167
 	 *
168 168
 	 */
169
-	private function link( $matches ) {
169
+	private function link($matches) {
170 170
 
171 171
 		// Get the entity itemid URI and label.
172 172
 		$css_class = $matches[2];
@@ -175,37 +175,37 @@  discard block
 block discarded – undo
175 175
 
176 176
 
177 177
 
178
-		$link = - 1 < strpos( $css_class, 'wl-link' );
178
+		$link = - 1 < strpos($css_class, 'wl-link');
179 179
 
180 180
 		// If the entity should not be linked and link by default is also disabled,
181 181
 		// then don't lookup the entity on the table.
182
-		if ( ! $this->is_link_by_default && ! $link ) {
182
+		if ( ! $this->is_link_by_default && ! $link) {
183 183
 			return $label;
184 184
 		}
185 185
 
186 186
 		$content_service = Wordpress_Content_Service::get_instance();
187
-		$content         = $content_service->get_by_entity_id_or_same_as( $uri );
187
+		$content         = $content_service->get_by_entity_id_or_same_as($uri);
188 188
 
189 189
 		// If no content is found, return the label, that is _remove the annotation_.
190
-		if ( ! isset( $content ) ) {
190
+		if ( ! isset($content)) {
191 191
 			return $label;
192 192
 		}
193 193
 
194 194
 		$object_id                   = $content->get_id();
195 195
 		$object_type                 = $content->get_object_type_enum();
196
-		$object_id_unique_identifier = $object_type . "_" . $object_id;
196
+		$object_id_unique_identifier = $object_type."_".$object_id;
197 197
 
198 198
 
199
-		$no_link = - 1 < strpos( $css_class, 'wl-no-link' )
199
+		$no_link = - 1 < strpos($css_class, 'wl-no-link')
200 200
 		           // Do not link if already linked.
201
-		           || $this->is_already_linked( $object_id_unique_identifier );
201
+		           || $this->is_already_linked($object_id_unique_identifier);
202 202
 
203 203
 		// Don't link if links are disabled and the entity is not link or the
204 204
 		// entity is do not link.
205
-		$dont_link = ( ! $this->is_link_by_default && ! $link ) || $no_link;
205
+		$dont_link = ( ! $this->is_link_by_default && ! $link) || $no_link;
206 206
 
207 207
 		// Return the label if it's don't link.
208
-		if ( $dont_link ) {
208
+		if ($dont_link) {
209 209
 			return $label;
210 210
 		}
211 211
 
@@ -216,16 +216,16 @@  discard block
 block discarded – undo
216 216
 		$this->linked_object_ids[] = $object_id_unique_identifier;
217 217
 
218 218
 		// Get the link.
219
-		$href = Wordlift_Post_Adapter::get_production_permalink( $object_id, $object_type );
219
+		$href = Wordlift_Post_Adapter::get_production_permalink($object_id, $object_type);
220 220
 
221 221
 		// Bail out if the `$href` has been reset.
222
-		if ( empty( $href ) ) {
222
+		if (empty($href)) {
223 223
 			return $label;
224 224
 		}
225 225
 
226
-		return Link_Builder::create( $uri, $object_id )
227
-		                   ->label( $label )
228
-		                   ->href( $href )
226
+		return Link_Builder::create($uri, $object_id)
227
+		                   ->label($label)
228
+		                   ->href($href)
229 229
 		                   ->generate_link();
230 230
 	}
231 231
 
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 * from tests and companion plugins.
247 247
 	 *
248 248
 	 */
249
-	function get_link_title( $post_id, $ignore_label, $object_type = Object_Type_Enum::POST ) {
250
-		return $this->object_link_provider->get_link_title( $post_id, $ignore_label, $object_type );
249
+	function get_link_title($post_id, $ignore_label, $object_type = Object_Type_Enum::POST) {
250
+		return $this->object_link_provider->get_link_title($post_id, $ignore_label, $object_type);
251 251
 	}
252 252
 
253 253
 	/**
@@ -260,17 +260,17 @@  discard block
 block discarded – undo
260 260
 	 * @since 3.14.2
261 261
 	 *
262 262
 	 */
263
-	public function get_entity_uris( $content ) {
263
+	public function get_entity_uris($content) {
264 264
 
265 265
 		$matches = array();
266
-		preg_match_all( Wordlift_Content_Filter_Service::PATTERN, $content, $matches );
266
+		preg_match_all(Wordlift_Content_Filter_Service::PATTERN, $content, $matches);
267 267
 
268 268
 		// We need to use `array_values` here in order to avoid further `json_encode`
269 269
 		// to turn it into an object (since if the 3rd match isn't found the index
270 270
 		// is not sequential.
271 271
 		//
272 272
 		// See https://github.com/insideout10/wordlift-plugin/issues/646.
273
-		return array_values( array_unique( $matches[3] ) );
273
+		return array_values(array_unique($matches[3]));
274 274
 	}
275 275
 
276 276
 
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @return bool
281 281
 	 */
282
-	private function is_already_linked( $post_id ) {
283
-		return in_array( $post_id, $this->linked_object_ids );
282
+	private function is_already_linked($post_id) {
283
+		return in_array($post_id, $this->linked_object_ids);
284 284
 	}
285 285
 
286 286
 }
Please login to merge, or discard this patch.