Completed
Pull Request — develop (#1317)
by
unknown
03:49
created
src/includes/class-wordlift-post-adapter.php 2 patches
Indentation   +247 added lines, -247 removed lines patch added patch discarded remove patch
@@ -16,257 +16,257 @@
 block discarded – undo
16 16
  */
17 17
 class Wordlift_Post_Adapter {
18 18
 
19
-	/**
20
-	 * The post id to which the adopter relates.
21
-	 *
22
-	 * @since 3.14.0
23
-	 *
24
-	 * @var integer $post_id .
25
-	 */
26
-	private $post_id;
27
-
28
-	const TYPE_ENTITY_LINK = 0;
29
-	const TYPE_TERM_LINK = 1;
30
-
31
-	/**
32
-	 * Create the {@link Wordlift_Post_Adatpter} instance.
33
-	 *
34
-	 * @param integer $post_id the post ID of the post the adopter relates to.
35
-	 *
36
-	 * @since 3.14.0
37
-	 *
38
-	 */
39
-	public function __construct( $post_id ) {
40
-
41
-		$this->post_id = $post_id;
42
-
43
-	}
44
-
45
-	/**
46
-	 * Get the word count of the post content.
47
-	 *
48
-	 * The count is calculated over the post content after stripping shortcodes and html tags.
49
-	 *
50
-	 * @return integer the number of words in the content after stripping shortcodes and html tags..
51
-	 * @since 3.14.0
52
-	 *
53
-	 */
54
-	public function word_count() {
55
-
56
-		$post = get_post( $this->post_id );
57
-
58
-		/*
19
+    /**
20
+     * The post id to which the adopter relates.
21
+     *
22
+     * @since 3.14.0
23
+     *
24
+     * @var integer $post_id .
25
+     */
26
+    private $post_id;
27
+
28
+    const TYPE_ENTITY_LINK = 0;
29
+    const TYPE_TERM_LINK = 1;
30
+
31
+    /**
32
+     * Create the {@link Wordlift_Post_Adatpter} instance.
33
+     *
34
+     * @param integer $post_id the post ID of the post the adopter relates to.
35
+     *
36
+     * @since 3.14.0
37
+     *
38
+     */
39
+    public function __construct( $post_id ) {
40
+
41
+        $this->post_id = $post_id;
42
+
43
+    }
44
+
45
+    /**
46
+     * Get the word count of the post content.
47
+     *
48
+     * The count is calculated over the post content after stripping shortcodes and html tags.
49
+     *
50
+     * @return integer the number of words in the content after stripping shortcodes and html tags..
51
+     * @since 3.14.0
52
+     *
53
+     */
54
+    public function word_count() {
55
+
56
+        $post = get_post( $this->post_id );
57
+
58
+        /*
59 59
 		 * Apply the `wl_post_content` filter, in case 3rd parties want to change the post content, e.g.
60 60
 		 * because the content is written elsewhere.
61 61
 		 *
62 62
 		 * @since 3.20.0
63 63
 		 */
64
-		$post_content = apply_filters( 'wl_post_content', $post->post_content, $post );
65
-
66
-		return self::str_word_count_utf8( strip_tags( strip_shortcodes( $post_content ) ) );
67
-	}
68
-
69
-	/**
70
-	 * Count words in the string, taking into account UTF-8 characters.
71
-	 *
72
-	 * @see https://github.com/insideout10/wordlift-plugin/issues/884
73
-	 *
74
-	 * @since 3.20.0
75
-	 *
76
-	 * @param string $str The target string.
77
-	 *
78
-	 * @return int The number of words.
79
-	 */
80
-	private static function str_word_count_utf8( $str ) {
81
-
82
-		return count( preg_split( '~[^\p{L}\p{N}\']+~u', $str ) );
83
-	}
84
-
85
-	/**
86
-	 * Get the {@link WP_Post} permalink allowing 3rd parties to alter the URL.
87
-	 *
88
-	 * @param int $post_id Post ID.
89
-	 *
90
-	 * @return string The post permalink.
91
-	 * @since 3.20.0
92
-	 *
93
-	 */
94
-	public static function get_production_permalink( $post_id ) {
95
-
96
-		/**
97
-		 * WordPress 4.4 doesn't support meta queries for terms, therefore we only support post permalinks here.
98
-		 *
99
-		 * Later on for WordPress 4.5+ we look for terms bound to the entity and we use the term link instead of the
100
-		 * post permalink if we find them.
101
-		 */
102
-		global $wp_version;
103
-		if ( version_compare( $wp_version, '4.5', '<' ) ) {
104
-			$permalink = get_permalink( $post_id );
105
-
106
-			return apply_filters( 'wl_production_permalink', $permalink, $post_id, self::TYPE_ENTITY_LINK, null );
107
-		}
108
-
109
-		/**
110
-		 * The `wl_production_permalink` filter allows to change the permalink, this is useful in contexts
111
-		 * when the production environment is copied over from a staging environment with staging
112
-		 * URLs.
113
-		 *
114
-		 * @param string $permalink_url The default permalink.
115
-		 * @param int $post_id The post id.
116
-		 *
117
-		 * @since 3.23.0 we check whether the entity is bound to a term and, in that case, we link to the term.
118
-		 * @since 3.20.0
119
-		 *
120
-		 * @see https://github.com/insideout10/wordlift-plugin/issues/850
121
-		 *
122
-		 */
123
-
124
-		// Get all the URIs for the entity, i.e. itemid and sameAs.
125
-		$uris = array_merge(
126
-			(array) Wordlift_Entity_Service::get_instance()->get_uri( $post_id ),
127
-			get_post_meta( $post_id, Wordlift_Schema_Service::FIELD_SAME_AS )
128
-		);
129
-
130
-		// Only try to link a term if `WL_ENABLE_TERM_LINKING` is enabled.
131
-		$terms = array();
132
-		if ( defined( 'WL_ENABLE_TERM_LINKING' ) && WL_ENABLE_TERM_LINKING ) {
133
-			// Try to find one term matching the entity.
134
-			$terms = get_terms( array(
135
-				'number'                 => 1,
136
-				'hide_empty'             => false,
137
-				'update_term_meta_cache' => false,
138
-				'meta_key'               => '_wl_entity_id',
139
-				'meta_value'             => $uris,
140
-				'meta_compare'           => 'IN',
141
-			) );
142
-		}
143
-
144
-		// If found use the term link, otherwise the permalink.
145
-		if ( 1 === count( $terms ) ) {
146
-			$term      = current( $terms );
147
-			$permalink = get_term_link( $term );
148
-			$type      = self::TYPE_TERM_LINK;
149
-		} else {
150
-			$term      = null;
151
-			$permalink = get_permalink( $post_id );
152
-			$type      = self::TYPE_ENTITY_LINK;
153
-		}
154
-
155
-		/**
156
-		 * Apply the `wl_production_permalink` filter.
157
-		 *
158
-		 * @param string $permalink The permalink.
159
-		 * @param int $post_id The post id.
160
-		 * @param int $type The permalink type: 0 = entity permalink, 1 = term link.
161
-		 * @param WP_Term $term The term if type is term link, otherwise null.
162
-		 *
163
-		 * @since 3.23.0 add the permalink type and term parameters.
164
-		 *
165
-		 */
166
-		return apply_filters( 'wl_production_permalink', $permalink, $post_id, $type, $term );
167
-	}
168
-
169
-	/**
170
-	 * Get comma separated tags to be used as keywords
171
-	 *
172
-	 * @return string|void Comma separated tags
173
-	 *
174
-	 * @since 3.27.2
175
-	 */
176
-	public function keywords() {
177
-		$tags = get_the_tags( $this->post_id );
178
-
179
-		if ( empty( $tags ) ) {
180
-			return;
181
-		}
182
-
183
-		return implode( ',', array_map( function ( $tag ) {
184
-			return $tag->name;
185
-		}, $tags ) );
186
-	}
187
-
188
-	/**
189
-	 * Get comma separated categories to be used as article section
190
-	 *
191
-	 * @return string|void Comma separated categories
192
-	 *
193
-	 * @since 3.27.2
194
-	 */
195
-	public function article_section() {
196
-		$categories = get_the_category( $this->post_id );
197
-
198
-		if ( empty( $categories ) ) {
199
-			return;
200
-		}
201
-
202
-		return implode( ',', array_map( function ( $tag ) {
203
-			return $tag->cat_name;
204
-		}, $categories ) );
205
-	}
206
-
207
-	/**
208
-	 * Get comment count
209
-	 *
210
-	 * @return string|void Comment count
211
-	 *
212
-	 * @since 3.27.2
213
-	 */
214
-	public function comment_count() {
215
-		return get_comments_number( $this->post_id );
216
-	}
217
-
218
-	/**
219
-	 * Get Language
220
-	 * Try WPML, Polylang for post specific languages, else fallback on get_locale()
221
-	 *
222
-	 * @return string|void Language code (locale)
223
-	 *
224
-	 * @since 3.27.2
225
-	 */
226
-	public function locale() {
227
-		$language = 'en-US';
228
-
229
-		if ( function_exists( 'wpml_get_language_information' ) ) {
230
-			// WPML handling
231
-			$post_language = wpml_get_language_information( $this->post_id );
232
-			$language = $post_language['locale'];
233
-		} else if ( function_exists( 'pll_get_post_language' ) ) {
234
-			// Polylang handling
235
-			$language = pll_get_post_language( $this->post_id, 'locale' );
236
-		} else {
237
-			$language = get_locale();
238
-		}
239
-
240
-		return str_replace('_','-',$language );
241
-	}
242
-
243
-	/**
244
-	 * Add mentions to an article.
245
-	 * To add mentions we just push the referenced entities to mentions.
246
-	 *
247
-	 * @param $post_id int
248
-	 * @param $references int[]
249
-	 */
250
-	public function add_mentions( $post_id, &$references ) {
251
-		$tags = get_the_tags( $post_id );
252
-
253
-		if ( $tags && ! is_wp_error( $tags ) ) {
254
-			// Loop through the tags and push it to references.
255
-			foreach ( $tags as $tag ) {
256
-				/**
257
-				 * @var $tag WP_Term
258
-				 */
259
-				$entity_uris = get_term_meta( $tag->term_id, '_wl_entity_id' );
260
-				foreach ( $entity_uris as $uri ) {
261
-					$referenced_entity = Wordlift_Entity_Uri_Service::get_instance()->get_entity( $uri );
262
-					if ( $referenced_entity instanceof WP_Post ) {
263
-						// push the referenced entities to references.
264
-						$references[] = $referenced_entity->ID;
265
-					}
266
-				}
267
-			}
268
-		}
269
-
270
-	}
64
+        $post_content = apply_filters( 'wl_post_content', $post->post_content, $post );
65
+
66
+        return self::str_word_count_utf8( strip_tags( strip_shortcodes( $post_content ) ) );
67
+    }
68
+
69
+    /**
70
+     * Count words in the string, taking into account UTF-8 characters.
71
+     *
72
+     * @see https://github.com/insideout10/wordlift-plugin/issues/884
73
+     *
74
+     * @since 3.20.0
75
+     *
76
+     * @param string $str The target string.
77
+     *
78
+     * @return int The number of words.
79
+     */
80
+    private static function str_word_count_utf8( $str ) {
81
+
82
+        return count( preg_split( '~[^\p{L}\p{N}\']+~u', $str ) );
83
+    }
84
+
85
+    /**
86
+     * Get the {@link WP_Post} permalink allowing 3rd parties to alter the URL.
87
+     *
88
+     * @param int $post_id Post ID.
89
+     *
90
+     * @return string The post permalink.
91
+     * @since 3.20.0
92
+     *
93
+     */
94
+    public static function get_production_permalink( $post_id ) {
95
+
96
+        /**
97
+         * WordPress 4.4 doesn't support meta queries for terms, therefore we only support post permalinks here.
98
+         *
99
+         * Later on for WordPress 4.5+ we look for terms bound to the entity and we use the term link instead of the
100
+         * post permalink if we find them.
101
+         */
102
+        global $wp_version;
103
+        if ( version_compare( $wp_version, '4.5', '<' ) ) {
104
+            $permalink = get_permalink( $post_id );
105
+
106
+            return apply_filters( 'wl_production_permalink', $permalink, $post_id, self::TYPE_ENTITY_LINK, null );
107
+        }
108
+
109
+        /**
110
+         * The `wl_production_permalink` filter allows to change the permalink, this is useful in contexts
111
+         * when the production environment is copied over from a staging environment with staging
112
+         * URLs.
113
+         *
114
+         * @param string $permalink_url The default permalink.
115
+         * @param int $post_id The post id.
116
+         *
117
+         * @since 3.23.0 we check whether the entity is bound to a term and, in that case, we link to the term.
118
+         * @since 3.20.0
119
+         *
120
+         * @see https://github.com/insideout10/wordlift-plugin/issues/850
121
+         *
122
+         */
123
+
124
+        // Get all the URIs for the entity, i.e. itemid and sameAs.
125
+        $uris = array_merge(
126
+            (array) Wordlift_Entity_Service::get_instance()->get_uri( $post_id ),
127
+            get_post_meta( $post_id, Wordlift_Schema_Service::FIELD_SAME_AS )
128
+        );
129
+
130
+        // Only try to link a term if `WL_ENABLE_TERM_LINKING` is enabled.
131
+        $terms = array();
132
+        if ( defined( 'WL_ENABLE_TERM_LINKING' ) && WL_ENABLE_TERM_LINKING ) {
133
+            // Try to find one term matching the entity.
134
+            $terms = get_terms( array(
135
+                'number'                 => 1,
136
+                'hide_empty'             => false,
137
+                'update_term_meta_cache' => false,
138
+                'meta_key'               => '_wl_entity_id',
139
+                'meta_value'             => $uris,
140
+                'meta_compare'           => 'IN',
141
+            ) );
142
+        }
143
+
144
+        // If found use the term link, otherwise the permalink.
145
+        if ( 1 === count( $terms ) ) {
146
+            $term      = current( $terms );
147
+            $permalink = get_term_link( $term );
148
+            $type      = self::TYPE_TERM_LINK;
149
+        } else {
150
+            $term      = null;
151
+            $permalink = get_permalink( $post_id );
152
+            $type      = self::TYPE_ENTITY_LINK;
153
+        }
154
+
155
+        /**
156
+         * Apply the `wl_production_permalink` filter.
157
+         *
158
+         * @param string $permalink The permalink.
159
+         * @param int $post_id The post id.
160
+         * @param int $type The permalink type: 0 = entity permalink, 1 = term link.
161
+         * @param WP_Term $term The term if type is term link, otherwise null.
162
+         *
163
+         * @since 3.23.0 add the permalink type and term parameters.
164
+         *
165
+         */
166
+        return apply_filters( 'wl_production_permalink', $permalink, $post_id, $type, $term );
167
+    }
168
+
169
+    /**
170
+     * Get comma separated tags to be used as keywords
171
+     *
172
+     * @return string|void Comma separated tags
173
+     *
174
+     * @since 3.27.2
175
+     */
176
+    public function keywords() {
177
+        $tags = get_the_tags( $this->post_id );
178
+
179
+        if ( empty( $tags ) ) {
180
+            return;
181
+        }
182
+
183
+        return implode( ',', array_map( function ( $tag ) {
184
+            return $tag->name;
185
+        }, $tags ) );
186
+    }
187
+
188
+    /**
189
+     * Get comma separated categories to be used as article section
190
+     *
191
+     * @return string|void Comma separated categories
192
+     *
193
+     * @since 3.27.2
194
+     */
195
+    public function article_section() {
196
+        $categories = get_the_category( $this->post_id );
197
+
198
+        if ( empty( $categories ) ) {
199
+            return;
200
+        }
201
+
202
+        return implode( ',', array_map( function ( $tag ) {
203
+            return $tag->cat_name;
204
+        }, $categories ) );
205
+    }
206
+
207
+    /**
208
+     * Get comment count
209
+     *
210
+     * @return string|void Comment count
211
+     *
212
+     * @since 3.27.2
213
+     */
214
+    public function comment_count() {
215
+        return get_comments_number( $this->post_id );
216
+    }
217
+
218
+    /**
219
+     * Get Language
220
+     * Try WPML, Polylang for post specific languages, else fallback on get_locale()
221
+     *
222
+     * @return string|void Language code (locale)
223
+     *
224
+     * @since 3.27.2
225
+     */
226
+    public function locale() {
227
+        $language = 'en-US';
228
+
229
+        if ( function_exists( 'wpml_get_language_information' ) ) {
230
+            // WPML handling
231
+            $post_language = wpml_get_language_information( $this->post_id );
232
+            $language = $post_language['locale'];
233
+        } else if ( function_exists( 'pll_get_post_language' ) ) {
234
+            // Polylang handling
235
+            $language = pll_get_post_language( $this->post_id, 'locale' );
236
+        } else {
237
+            $language = get_locale();
238
+        }
239
+
240
+        return str_replace('_','-',$language );
241
+    }
242
+
243
+    /**
244
+     * Add mentions to an article.
245
+     * To add mentions we just push the referenced entities to mentions.
246
+     *
247
+     * @param $post_id int
248
+     * @param $references int[]
249
+     */
250
+    public function add_mentions( $post_id, &$references ) {
251
+        $tags = get_the_tags( $post_id );
252
+
253
+        if ( $tags && ! is_wp_error( $tags ) ) {
254
+            // Loop through the tags and push it to references.
255
+            foreach ( $tags as $tag ) {
256
+                /**
257
+                 * @var $tag WP_Term
258
+                 */
259
+                $entity_uris = get_term_meta( $tag->term_id, '_wl_entity_id' );
260
+                foreach ( $entity_uris as $uri ) {
261
+                    $referenced_entity = Wordlift_Entity_Uri_Service::get_instance()->get_entity( $uri );
262
+                    if ( $referenced_entity instanceof WP_Post ) {
263
+                        // push the referenced entities to references.
264
+                        $references[] = $referenced_entity->ID;
265
+                    }
266
+                }
267
+            }
268
+        }
269
+
270
+    }
271 271
 
272 272
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @since 3.14.0
37 37
 	 *
38 38
 	 */
39
-	public function __construct( $post_id ) {
39
+	public function __construct($post_id) {
40 40
 
41 41
 		$this->post_id = $post_id;
42 42
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function word_count() {
55 55
 
56
-		$post = get_post( $this->post_id );
56
+		$post = get_post($this->post_id);
57 57
 
58 58
 		/*
59 59
 		 * Apply the `wl_post_content` filter, in case 3rd parties want to change the post content, e.g.
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 		 *
62 62
 		 * @since 3.20.0
63 63
 		 */
64
-		$post_content = apply_filters( 'wl_post_content', $post->post_content, $post );
64
+		$post_content = apply_filters('wl_post_content', $post->post_content, $post);
65 65
 
66
-		return self::str_word_count_utf8( strip_tags( strip_shortcodes( $post_content ) ) );
66
+		return self::str_word_count_utf8(strip_tags(strip_shortcodes($post_content)));
67 67
 	}
68 68
 
69 69
 	/**
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @return int The number of words.
79 79
 	 */
80
-	private static function str_word_count_utf8( $str ) {
80
+	private static function str_word_count_utf8($str) {
81 81
 
82
-		return count( preg_split( '~[^\p{L}\p{N}\']+~u', $str ) );
82
+		return count(preg_split('~[^\p{L}\p{N}\']+~u', $str));
83 83
 	}
84 84
 
85 85
 	/**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @since 3.20.0
92 92
 	 *
93 93
 	 */
94
-	public static function get_production_permalink( $post_id ) {
94
+	public static function get_production_permalink($post_id) {
95 95
 
96 96
 		/**
97 97
 		 * WordPress 4.4 doesn't support meta queries for terms, therefore we only support post permalinks here.
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 		 * post permalink if we find them.
101 101
 		 */
102 102
 		global $wp_version;
103
-		if ( version_compare( $wp_version, '4.5', '<' ) ) {
104
-			$permalink = get_permalink( $post_id );
103
+		if (version_compare($wp_version, '4.5', '<')) {
104
+			$permalink = get_permalink($post_id);
105 105
 
106
-			return apply_filters( 'wl_production_permalink', $permalink, $post_id, self::TYPE_ENTITY_LINK, null );
106
+			return apply_filters('wl_production_permalink', $permalink, $post_id, self::TYPE_ENTITY_LINK, null);
107 107
 		}
108 108
 
109 109
 		/**
@@ -123,32 +123,32 @@  discard block
 block discarded – undo
123 123
 
124 124
 		// Get all the URIs for the entity, i.e. itemid and sameAs.
125 125
 		$uris = array_merge(
126
-			(array) Wordlift_Entity_Service::get_instance()->get_uri( $post_id ),
127
-			get_post_meta( $post_id, Wordlift_Schema_Service::FIELD_SAME_AS )
126
+			(array) Wordlift_Entity_Service::get_instance()->get_uri($post_id),
127
+			get_post_meta($post_id, Wordlift_Schema_Service::FIELD_SAME_AS)
128 128
 		);
129 129
 
130 130
 		// Only try to link a term if `WL_ENABLE_TERM_LINKING` is enabled.
131 131
 		$terms = array();
132
-		if ( defined( 'WL_ENABLE_TERM_LINKING' ) && WL_ENABLE_TERM_LINKING ) {
132
+		if (defined('WL_ENABLE_TERM_LINKING') && WL_ENABLE_TERM_LINKING) {
133 133
 			// Try to find one term matching the entity.
134
-			$terms = get_terms( array(
134
+			$terms = get_terms(array(
135 135
 				'number'                 => 1,
136 136
 				'hide_empty'             => false,
137 137
 				'update_term_meta_cache' => false,
138 138
 				'meta_key'               => '_wl_entity_id',
139 139
 				'meta_value'             => $uris,
140 140
 				'meta_compare'           => 'IN',
141
-			) );
141
+			));
142 142
 		}
143 143
 
144 144
 		// If found use the term link, otherwise the permalink.
145
-		if ( 1 === count( $terms ) ) {
146
-			$term      = current( $terms );
147
-			$permalink = get_term_link( $term );
145
+		if (1 === count($terms)) {
146
+			$term      = current($terms);
147
+			$permalink = get_term_link($term);
148 148
 			$type      = self::TYPE_TERM_LINK;
149 149
 		} else {
150 150
 			$term      = null;
151
-			$permalink = get_permalink( $post_id );
151
+			$permalink = get_permalink($post_id);
152 152
 			$type      = self::TYPE_ENTITY_LINK;
153 153
 		}
154 154
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		 * @since 3.23.0 add the permalink type and term parameters.
164 164
 		 *
165 165
 		 */
166
-		return apply_filters( 'wl_production_permalink', $permalink, $post_id, $type, $term );
166
+		return apply_filters('wl_production_permalink', $permalink, $post_id, $type, $term);
167 167
 	}
168 168
 
169 169
 	/**
@@ -174,15 +174,15 @@  discard block
 block discarded – undo
174 174
 	 * @since 3.27.2
175 175
 	 */
176 176
 	public function keywords() {
177
-		$tags = get_the_tags( $this->post_id );
177
+		$tags = get_the_tags($this->post_id);
178 178
 
179
-		if ( empty( $tags ) ) {
179
+		if (empty($tags)) {
180 180
 			return;
181 181
 		}
182 182
 
183
-		return implode( ',', array_map( function ( $tag ) {
183
+		return implode(',', array_map(function($tag) {
184 184
 			return $tag->name;
185
-		}, $tags ) );
185
+		}, $tags));
186 186
 	}
187 187
 
188 188
 	/**
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
 	 * @since 3.27.2
194 194
 	 */
195 195
 	public function article_section() {
196
-		$categories = get_the_category( $this->post_id );
196
+		$categories = get_the_category($this->post_id);
197 197
 
198
-		if ( empty( $categories ) ) {
198
+		if (empty($categories)) {
199 199
 			return;
200 200
 		}
201 201
 
202
-		return implode( ',', array_map( function ( $tag ) {
202
+		return implode(',', array_map(function($tag) {
203 203
 			return $tag->cat_name;
204
-		}, $categories ) );
204
+		}, $categories));
205 205
 	}
206 206
 
207 207
 	/**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 * @since 3.27.2
213 213
 	 */
214 214
 	public function comment_count() {
215
-		return get_comments_number( $this->post_id );
215
+		return get_comments_number($this->post_id);
216 216
 	}
217 217
 
218 218
 	/**
@@ -226,18 +226,18 @@  discard block
 block discarded – undo
226 226
 	public function locale() {
227 227
 		$language = 'en-US';
228 228
 
229
-		if ( function_exists( 'wpml_get_language_information' ) ) {
229
+		if (function_exists('wpml_get_language_information')) {
230 230
 			// WPML handling
231
-			$post_language = wpml_get_language_information( $this->post_id );
231
+			$post_language = wpml_get_language_information($this->post_id);
232 232
 			$language = $post_language['locale'];
233
-		} else if ( function_exists( 'pll_get_post_language' ) ) {
233
+		} else if (function_exists('pll_get_post_language')) {
234 234
 			// Polylang handling
235
-			$language = pll_get_post_language( $this->post_id, 'locale' );
235
+			$language = pll_get_post_language($this->post_id, 'locale');
236 236
 		} else {
237 237
 			$language = get_locale();
238 238
 		}
239 239
 
240
-		return str_replace('_','-',$language );
240
+		return str_replace('_', '-', $language);
241 241
 	}
242 242
 
243 243
 	/**
@@ -247,19 +247,19 @@  discard block
 block discarded – undo
247 247
 	 * @param $post_id int
248 248
 	 * @param $references int[]
249 249
 	 */
250
-	public function add_mentions( $post_id, &$references ) {
251
-		$tags = get_the_tags( $post_id );
250
+	public function add_mentions($post_id, &$references) {
251
+		$tags = get_the_tags($post_id);
252 252
 
253
-		if ( $tags && ! is_wp_error( $tags ) ) {
253
+		if ($tags && ! is_wp_error($tags)) {
254 254
 			// Loop through the tags and push it to references.
255
-			foreach ( $tags as $tag ) {
255
+			foreach ($tags as $tag) {
256 256
 				/**
257 257
 				 * @var $tag WP_Term
258 258
 				 */
259
-				$entity_uris = get_term_meta( $tag->term_id, '_wl_entity_id' );
260
-				foreach ( $entity_uris as $uri ) {
261
-					$referenced_entity = Wordlift_Entity_Uri_Service::get_instance()->get_entity( $uri );
262
-					if ( $referenced_entity instanceof WP_Post ) {
259
+				$entity_uris = get_term_meta($tag->term_id, '_wl_entity_id');
260
+				foreach ($entity_uris as $uri) {
261
+					$referenced_entity = Wordlift_Entity_Uri_Service::get_instance()->get_entity($uri);
262
+					if ($referenced_entity instanceof WP_Post) {
263 263
 						// push the referenced entities to references.
264 264
 						$references[] = $referenced_entity->ID;
265 265
 					}
Please login to merge, or discard this patch.