@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @since 3.9.0 |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | public static function get_languages() { |
86 | 86 | |
87 | 87 | // Lazily load the languages. |
88 | - if ( null === self::$languages ) { |
|
88 | + if (null === self::$languages) { |
|
89 | 89 | |
90 | 90 | // Get the language names from WP's own (multisite) function. |
91 | - foreach ( self::$codes as $key ) { |
|
92 | - self::$languages[ $key ] = self::get_language_name( $key ); |
|
91 | + foreach (self::$codes as $key) { |
|
92 | + self::$languages[$key] = self::get_language_name($key); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // Sort by language name. |
96 | - asort( self::$languages ); |
|
96 | + asort(self::$languages); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | return self::$languages; |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * @return string The language corresponding to $code if it exists. If it does not exist, |
110 | 110 | * then the first two letters of $code is returned. |
111 | 111 | */ |
112 | - public static function get_language_name( $code = '' ) { |
|
113 | - $code = strtolower( substr( $code, 0, 2 ) ); |
|
112 | + public static function get_language_name($code = '') { |
|
113 | + $code = strtolower(substr($code, 0, 2)); |
|
114 | 114 | $lang_codes = array( |
115 | 115 | 'aa' => 'Afar', |
116 | 116 | 'ab' => 'Abkhazian', |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | * @param array $lang_codes Key/value pair of language codes where key is the short version. |
308 | 308 | * @param string $code A two-letter designation of the language. |
309 | 309 | */ |
310 | - $lang_codes = apply_filters( 'lang_codes', $lang_codes, $code ); |
|
310 | + $lang_codes = apply_filters('lang_codes', $lang_codes, $code); |
|
311 | 311 | |
312 | - return strtr( $code, $lang_codes ); |
|
312 | + return strtr($code, $lang_codes); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
14 | - exit; |
|
14 | + exit; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -21,295 +21,295 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class Wordlift_Languages { |
23 | 23 | |
24 | - /** |
|
25 | - * An array that will contain language codes => language names pairs. It gets lazily loaded the first time by the |
|
26 | - * `get_languages` function. |
|
27 | - * |
|
28 | - * @since 3.9.0 |
|
29 | - * @var array|null An array of language codes => language names pairs or NULL if not initialized yet. |
|
30 | - */ |
|
31 | - private static $languages = null; |
|
24 | + /** |
|
25 | + * An array that will contain language codes => language names pairs. It gets lazily loaded the first time by the |
|
26 | + * `get_languages` function. |
|
27 | + * |
|
28 | + * @since 3.9.0 |
|
29 | + * @var array|null An array of language codes => language names pairs or NULL if not initialized yet. |
|
30 | + */ |
|
31 | + private static $languages = null; |
|
32 | 32 | |
33 | - /** |
|
34 | - * The list of supported language codes. |
|
35 | - * |
|
36 | - * @since 3.9.0 |
|
37 | - * |
|
38 | - * @var array An array of language codes. |
|
39 | - */ |
|
40 | - private static $codes = array( |
|
41 | - 'ar', |
|
42 | - 'be', |
|
43 | - 'bg', |
|
44 | - 'ca', |
|
45 | - 'cs', |
|
46 | - 'da', |
|
47 | - 'de', |
|
48 | - 'el', |
|
49 | - 'en', |
|
50 | - 'es', |
|
51 | - 'et', |
|
52 | - 'fi', |
|
53 | - 'fr', |
|
54 | - 'he', |
|
55 | - 'hr', |
|
56 | - 'hu', |
|
57 | - 'id', |
|
58 | - 'is', |
|
59 | - 'it', |
|
60 | - 'lt', |
|
61 | - 'lv', |
|
62 | - 'nl', |
|
63 | - 'no', |
|
64 | - 'pl', |
|
65 | - 'pt', |
|
66 | - 'ro', |
|
67 | - 'ru', |
|
68 | - 'sk', |
|
69 | - 'sl', |
|
70 | - 'sq', |
|
71 | - 'sr', |
|
72 | - 'sv', |
|
73 | - 'tr', |
|
74 | - 'uk', |
|
75 | - 'zh-cn', |
|
76 | - ); |
|
33 | + /** |
|
34 | + * The list of supported language codes. |
|
35 | + * |
|
36 | + * @since 3.9.0 |
|
37 | + * |
|
38 | + * @var array An array of language codes. |
|
39 | + */ |
|
40 | + private static $codes = array( |
|
41 | + 'ar', |
|
42 | + 'be', |
|
43 | + 'bg', |
|
44 | + 'ca', |
|
45 | + 'cs', |
|
46 | + 'da', |
|
47 | + 'de', |
|
48 | + 'el', |
|
49 | + 'en', |
|
50 | + 'es', |
|
51 | + 'et', |
|
52 | + 'fi', |
|
53 | + 'fr', |
|
54 | + 'he', |
|
55 | + 'hr', |
|
56 | + 'hu', |
|
57 | + 'id', |
|
58 | + 'is', |
|
59 | + 'it', |
|
60 | + 'lt', |
|
61 | + 'lv', |
|
62 | + 'nl', |
|
63 | + 'no', |
|
64 | + 'pl', |
|
65 | + 'pt', |
|
66 | + 'ro', |
|
67 | + 'ru', |
|
68 | + 'sk', |
|
69 | + 'sl', |
|
70 | + 'sq', |
|
71 | + 'sr', |
|
72 | + 'sv', |
|
73 | + 'tr', |
|
74 | + 'uk', |
|
75 | + 'zh-cn', |
|
76 | + ); |
|
77 | 77 | |
78 | - /** |
|
79 | - * Get the list of WordLift's supported languages in an array with language code => language name pairs. |
|
80 | - * |
|
81 | - * @since 3.9.0 |
|
82 | - * |
|
83 | - * @return array An array with language code => language name pairs. |
|
84 | - */ |
|
85 | - public static function get_languages() { |
|
78 | + /** |
|
79 | + * Get the list of WordLift's supported languages in an array with language code => language name pairs. |
|
80 | + * |
|
81 | + * @since 3.9.0 |
|
82 | + * |
|
83 | + * @return array An array with language code => language name pairs. |
|
84 | + */ |
|
85 | + public static function get_languages() { |
|
86 | 86 | |
87 | - // Lazily load the languages. |
|
88 | - if ( null === self::$languages ) { |
|
87 | + // Lazily load the languages. |
|
88 | + if ( null === self::$languages ) { |
|
89 | 89 | |
90 | - // Get the language names from WP's own (multisite) function. |
|
91 | - foreach ( self::$codes as $key ) { |
|
92 | - self::$languages[ $key ] = self::get_language_name( $key ); |
|
93 | - } |
|
90 | + // Get the language names from WP's own (multisite) function. |
|
91 | + foreach ( self::$codes as $key ) { |
|
92 | + self::$languages[ $key ] = self::get_language_name( $key ); |
|
93 | + } |
|
94 | 94 | |
95 | - // Sort by language name. |
|
96 | - asort( self::$languages ); |
|
97 | - } |
|
95 | + // Sort by language name. |
|
96 | + asort( self::$languages ); |
|
97 | + } |
|
98 | 98 | |
99 | - return self::$languages; |
|
100 | - } |
|
99 | + return self::$languages; |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Returns the language for a language code. This function is a clone of WP's function provided in `ms.php`. |
|
104 | - * |
|
105 | - * @since 3.9.3 |
|
106 | - * |
|
107 | - * @param string $code Optional. The two-letter language code. Default empty. |
|
108 | - * |
|
109 | - * @return string The language corresponding to $code if it exists. If it does not exist, |
|
110 | - * then the first two letters of $code is returned. |
|
111 | - */ |
|
112 | - public static function get_language_name( $code = '' ) { |
|
113 | - $code = strtolower( substr( $code, 0, 2 ) ); |
|
114 | - $lang_codes = array( |
|
115 | - 'aa' => 'Afar', |
|
116 | - 'ab' => 'Abkhazian', |
|
117 | - 'af' => 'Afrikaans', |
|
118 | - 'ak' => 'Akan', |
|
119 | - 'sq' => 'Albanian', |
|
120 | - 'am' => 'Amharic', |
|
121 | - 'ar' => 'Arabic', |
|
122 | - 'an' => 'Aragonese', |
|
123 | - 'hy' => 'Armenian', |
|
124 | - 'as' => 'Assamese', |
|
125 | - 'av' => 'Avaric', |
|
126 | - 'ae' => 'Avestan', |
|
127 | - 'ay' => 'Aymara', |
|
128 | - 'az' => 'Azerbaijani', |
|
129 | - 'ba' => 'Bashkir', |
|
130 | - 'bm' => 'Bambara', |
|
131 | - 'eu' => 'Basque', |
|
132 | - 'be' => 'Belarusian', |
|
133 | - 'bn' => 'Bengali', |
|
134 | - 'bh' => 'Bihari', |
|
135 | - 'bi' => 'Bislama', |
|
136 | - 'bs' => 'Bosnian', |
|
137 | - 'br' => 'Breton', |
|
138 | - 'bg' => 'Bulgarian', |
|
139 | - 'my' => 'Burmese', |
|
140 | - 'ca' => 'Catalan; Valencian', |
|
141 | - 'ch' => 'Chamorro', |
|
142 | - 'ce' => 'Chechen', |
|
143 | - 'zh' => 'Chinese', |
|
144 | - 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', |
|
145 | - 'cv' => 'Chuvash', |
|
146 | - 'kw' => 'Cornish', |
|
147 | - 'co' => 'Corsican', |
|
148 | - 'cr' => 'Cree', |
|
149 | - 'cs' => 'Czech', |
|
150 | - 'da' => 'Danish', |
|
151 | - 'dv' => 'Divehi; Dhivehi; Maldivian', |
|
152 | - 'nl' => 'Dutch; Flemish', |
|
153 | - 'dz' => 'Dzongkha', |
|
154 | - 'en' => 'English', |
|
155 | - 'eo' => 'Esperanto', |
|
156 | - 'et' => 'Estonian', |
|
157 | - 'ee' => 'Ewe', |
|
158 | - 'fo' => 'Faroese', |
|
159 | - 'fj' => 'Fijjian', |
|
160 | - 'fi' => 'Finnish', |
|
161 | - 'fr' => 'French', |
|
162 | - 'fy' => 'Western Frisian', |
|
163 | - 'ff' => 'Fulah', |
|
164 | - 'ka' => 'Georgian', |
|
165 | - 'de' => 'German', |
|
166 | - 'gd' => 'Gaelic; Scottish Gaelic', |
|
167 | - 'ga' => 'Irish', |
|
168 | - 'gl' => 'Galician', |
|
169 | - 'gv' => 'Manx', |
|
170 | - 'el' => 'Greek, Modern', |
|
171 | - 'gn' => 'Guarani', |
|
172 | - 'gu' => 'Gujarati', |
|
173 | - 'ht' => 'Haitian; Haitian Creole', |
|
174 | - 'ha' => 'Hausa', |
|
175 | - 'he' => 'Hebrew', |
|
176 | - 'hz' => 'Herero', |
|
177 | - 'hi' => 'Hindi', |
|
178 | - 'ho' => 'Hiri Motu', |
|
179 | - 'hu' => 'Hungarian', |
|
180 | - 'ig' => 'Igbo', |
|
181 | - 'is' => 'Icelandic', |
|
182 | - 'io' => 'Ido', |
|
183 | - 'ii' => 'Sichuan Yi', |
|
184 | - 'iu' => 'Inuktitut', |
|
185 | - 'ie' => 'Interlingue', |
|
186 | - 'ia' => 'Interlingua (International Auxiliary Language Association)', |
|
187 | - 'id' => 'Indonesian', |
|
188 | - 'ik' => 'Inupiaq', |
|
189 | - 'it' => 'Italian', |
|
190 | - 'jv' => 'Javanese', |
|
191 | - 'ja' => 'Japanese', |
|
192 | - 'kl' => 'Kalaallisut; Greenlandic', |
|
193 | - 'kn' => 'Kannada', |
|
194 | - 'ks' => 'Kashmiri', |
|
195 | - 'kr' => 'Kanuri', |
|
196 | - 'kk' => 'Kazakh', |
|
197 | - 'km' => 'Central Khmer', |
|
198 | - 'ki' => 'Kikuyu; Gikuyu', |
|
199 | - 'rw' => 'Kinyarwanda', |
|
200 | - 'ky' => 'Kirghiz; Kyrgyz', |
|
201 | - 'kv' => 'Komi', |
|
202 | - 'kg' => 'Kongo', |
|
203 | - 'ko' => 'Korean', |
|
204 | - 'kj' => 'Kuanyama; Kwanyama', |
|
205 | - 'ku' => 'Kurdish', |
|
206 | - 'lo' => 'Lao', |
|
207 | - 'la' => 'Latin', |
|
208 | - 'lv' => 'Latvian', |
|
209 | - 'li' => 'Limburgan; Limburger; Limburgish', |
|
210 | - 'ln' => 'Lingala', |
|
211 | - 'lt' => 'Lithuanian', |
|
212 | - 'lb' => 'Luxembourgish; Letzeburgesch', |
|
213 | - 'lu' => 'Luba-Katanga', |
|
214 | - 'lg' => 'Ganda', |
|
215 | - 'mk' => 'Macedonian', |
|
216 | - 'mh' => 'Marshallese', |
|
217 | - 'ml' => 'Malayalam', |
|
218 | - 'mi' => 'Maori', |
|
219 | - 'mr' => 'Marathi', |
|
220 | - 'ms' => 'Malay', |
|
221 | - 'mg' => 'Malagasy', |
|
222 | - 'mt' => 'Maltese', |
|
223 | - 'mo' => 'Moldavian', |
|
224 | - 'mn' => 'Mongolian', |
|
225 | - 'na' => 'Nauru', |
|
226 | - 'nv' => 'Navajo; Navaho', |
|
227 | - 'nr' => 'Ndebele, South; South Ndebele', |
|
228 | - 'nd' => 'Ndebele, North; North Ndebele', |
|
229 | - 'ng' => 'Ndonga', |
|
230 | - 'ne' => 'Nepali', |
|
231 | - 'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian', |
|
232 | - 'nb' => 'Bokmål, Norwegian, Norwegian Bokmål', |
|
233 | - 'no' => 'Norwegian', |
|
234 | - 'ny' => 'Chichewa; Chewa; Nyanja', |
|
235 | - 'oc' => 'Occitan, Provençal', |
|
236 | - 'oj' => 'Ojibwa', |
|
237 | - 'or' => 'Oriya', |
|
238 | - 'om' => 'Oromo', |
|
239 | - 'os' => 'Ossetian; Ossetic', |
|
240 | - 'pa' => 'Panjabi; Punjabi', |
|
241 | - 'fa' => 'Persian', |
|
242 | - 'pi' => 'Pali', |
|
243 | - 'pl' => 'Polish', |
|
244 | - 'pt' => 'Portuguese', |
|
245 | - 'ps' => 'Pushto', |
|
246 | - 'qu' => 'Quechua', |
|
247 | - 'rm' => 'Romansh', |
|
248 | - 'ro' => 'Romanian', |
|
249 | - 'rn' => 'Rundi', |
|
250 | - 'ru' => 'Russian', |
|
251 | - 'sg' => 'Sango', |
|
252 | - 'sa' => 'Sanskrit', |
|
253 | - 'sr' => 'Serbian', |
|
254 | - 'hr' => 'Croatian', |
|
255 | - 'si' => 'Sinhala; Sinhalese', |
|
256 | - 'sk' => 'Slovak', |
|
257 | - 'sl' => 'Slovenian', |
|
258 | - 'se' => 'Northern Sami', |
|
259 | - 'sm' => 'Samoan', |
|
260 | - 'sn' => 'Shona', |
|
261 | - 'sd' => 'Sindhi', |
|
262 | - 'so' => 'Somali', |
|
263 | - 'st' => 'Sotho, Southern', |
|
264 | - 'es' => 'Spanish; Castilian', |
|
265 | - 'sc' => 'Sardinian', |
|
266 | - 'ss' => 'Swati', |
|
267 | - 'su' => 'Sundanese', |
|
268 | - 'sw' => 'Swahili', |
|
269 | - 'sv' => 'Swedish', |
|
270 | - 'ty' => 'Tahitian', |
|
271 | - 'ta' => 'Tamil', |
|
272 | - 'tt' => 'Tatar', |
|
273 | - 'te' => 'Telugu', |
|
274 | - 'tg' => 'Tajik', |
|
275 | - 'tl' => 'Tagalog', |
|
276 | - 'th' => 'Thai', |
|
277 | - 'bo' => 'Tibetan', |
|
278 | - 'ti' => 'Tigrinya', |
|
279 | - 'to' => 'Tonga (Tonga Islands)', |
|
280 | - 'tn' => 'Tswana', |
|
281 | - 'ts' => 'Tsonga', |
|
282 | - 'tk' => 'Turkmen', |
|
283 | - 'tr' => 'Turkish', |
|
284 | - 'tw' => 'Twi', |
|
285 | - 'ug' => 'Uighur; Uyghur', |
|
286 | - 'uk' => 'Ukrainian', |
|
287 | - 'ur' => 'Urdu', |
|
288 | - 'uz' => 'Uzbek', |
|
289 | - 've' => 'Venda', |
|
290 | - 'vi' => 'Vietnamese', |
|
291 | - 'vo' => 'Volapük', |
|
292 | - 'cy' => 'Welsh', |
|
293 | - 'wa' => 'Walloon', |
|
294 | - 'wo' => 'Wolof', |
|
295 | - 'xh' => 'Xhosa', |
|
296 | - 'yi' => 'Yiddish', |
|
297 | - 'yo' => 'Yoruba', |
|
298 | - 'za' => 'Zhuang; Chuang', |
|
299 | - 'zu' => 'Zulu', |
|
300 | - ); |
|
102 | + /** |
|
103 | + * Returns the language for a language code. This function is a clone of WP's function provided in `ms.php`. |
|
104 | + * |
|
105 | + * @since 3.9.3 |
|
106 | + * |
|
107 | + * @param string $code Optional. The two-letter language code. Default empty. |
|
108 | + * |
|
109 | + * @return string The language corresponding to $code if it exists. If it does not exist, |
|
110 | + * then the first two letters of $code is returned. |
|
111 | + */ |
|
112 | + public static function get_language_name( $code = '' ) { |
|
113 | + $code = strtolower( substr( $code, 0, 2 ) ); |
|
114 | + $lang_codes = array( |
|
115 | + 'aa' => 'Afar', |
|
116 | + 'ab' => 'Abkhazian', |
|
117 | + 'af' => 'Afrikaans', |
|
118 | + 'ak' => 'Akan', |
|
119 | + 'sq' => 'Albanian', |
|
120 | + 'am' => 'Amharic', |
|
121 | + 'ar' => 'Arabic', |
|
122 | + 'an' => 'Aragonese', |
|
123 | + 'hy' => 'Armenian', |
|
124 | + 'as' => 'Assamese', |
|
125 | + 'av' => 'Avaric', |
|
126 | + 'ae' => 'Avestan', |
|
127 | + 'ay' => 'Aymara', |
|
128 | + 'az' => 'Azerbaijani', |
|
129 | + 'ba' => 'Bashkir', |
|
130 | + 'bm' => 'Bambara', |
|
131 | + 'eu' => 'Basque', |
|
132 | + 'be' => 'Belarusian', |
|
133 | + 'bn' => 'Bengali', |
|
134 | + 'bh' => 'Bihari', |
|
135 | + 'bi' => 'Bislama', |
|
136 | + 'bs' => 'Bosnian', |
|
137 | + 'br' => 'Breton', |
|
138 | + 'bg' => 'Bulgarian', |
|
139 | + 'my' => 'Burmese', |
|
140 | + 'ca' => 'Catalan; Valencian', |
|
141 | + 'ch' => 'Chamorro', |
|
142 | + 'ce' => 'Chechen', |
|
143 | + 'zh' => 'Chinese', |
|
144 | + 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', |
|
145 | + 'cv' => 'Chuvash', |
|
146 | + 'kw' => 'Cornish', |
|
147 | + 'co' => 'Corsican', |
|
148 | + 'cr' => 'Cree', |
|
149 | + 'cs' => 'Czech', |
|
150 | + 'da' => 'Danish', |
|
151 | + 'dv' => 'Divehi; Dhivehi; Maldivian', |
|
152 | + 'nl' => 'Dutch; Flemish', |
|
153 | + 'dz' => 'Dzongkha', |
|
154 | + 'en' => 'English', |
|
155 | + 'eo' => 'Esperanto', |
|
156 | + 'et' => 'Estonian', |
|
157 | + 'ee' => 'Ewe', |
|
158 | + 'fo' => 'Faroese', |
|
159 | + 'fj' => 'Fijjian', |
|
160 | + 'fi' => 'Finnish', |
|
161 | + 'fr' => 'French', |
|
162 | + 'fy' => 'Western Frisian', |
|
163 | + 'ff' => 'Fulah', |
|
164 | + 'ka' => 'Georgian', |
|
165 | + 'de' => 'German', |
|
166 | + 'gd' => 'Gaelic; Scottish Gaelic', |
|
167 | + 'ga' => 'Irish', |
|
168 | + 'gl' => 'Galician', |
|
169 | + 'gv' => 'Manx', |
|
170 | + 'el' => 'Greek, Modern', |
|
171 | + 'gn' => 'Guarani', |
|
172 | + 'gu' => 'Gujarati', |
|
173 | + 'ht' => 'Haitian; Haitian Creole', |
|
174 | + 'ha' => 'Hausa', |
|
175 | + 'he' => 'Hebrew', |
|
176 | + 'hz' => 'Herero', |
|
177 | + 'hi' => 'Hindi', |
|
178 | + 'ho' => 'Hiri Motu', |
|
179 | + 'hu' => 'Hungarian', |
|
180 | + 'ig' => 'Igbo', |
|
181 | + 'is' => 'Icelandic', |
|
182 | + 'io' => 'Ido', |
|
183 | + 'ii' => 'Sichuan Yi', |
|
184 | + 'iu' => 'Inuktitut', |
|
185 | + 'ie' => 'Interlingue', |
|
186 | + 'ia' => 'Interlingua (International Auxiliary Language Association)', |
|
187 | + 'id' => 'Indonesian', |
|
188 | + 'ik' => 'Inupiaq', |
|
189 | + 'it' => 'Italian', |
|
190 | + 'jv' => 'Javanese', |
|
191 | + 'ja' => 'Japanese', |
|
192 | + 'kl' => 'Kalaallisut; Greenlandic', |
|
193 | + 'kn' => 'Kannada', |
|
194 | + 'ks' => 'Kashmiri', |
|
195 | + 'kr' => 'Kanuri', |
|
196 | + 'kk' => 'Kazakh', |
|
197 | + 'km' => 'Central Khmer', |
|
198 | + 'ki' => 'Kikuyu; Gikuyu', |
|
199 | + 'rw' => 'Kinyarwanda', |
|
200 | + 'ky' => 'Kirghiz; Kyrgyz', |
|
201 | + 'kv' => 'Komi', |
|
202 | + 'kg' => 'Kongo', |
|
203 | + 'ko' => 'Korean', |
|
204 | + 'kj' => 'Kuanyama; Kwanyama', |
|
205 | + 'ku' => 'Kurdish', |
|
206 | + 'lo' => 'Lao', |
|
207 | + 'la' => 'Latin', |
|
208 | + 'lv' => 'Latvian', |
|
209 | + 'li' => 'Limburgan; Limburger; Limburgish', |
|
210 | + 'ln' => 'Lingala', |
|
211 | + 'lt' => 'Lithuanian', |
|
212 | + 'lb' => 'Luxembourgish; Letzeburgesch', |
|
213 | + 'lu' => 'Luba-Katanga', |
|
214 | + 'lg' => 'Ganda', |
|
215 | + 'mk' => 'Macedonian', |
|
216 | + 'mh' => 'Marshallese', |
|
217 | + 'ml' => 'Malayalam', |
|
218 | + 'mi' => 'Maori', |
|
219 | + 'mr' => 'Marathi', |
|
220 | + 'ms' => 'Malay', |
|
221 | + 'mg' => 'Malagasy', |
|
222 | + 'mt' => 'Maltese', |
|
223 | + 'mo' => 'Moldavian', |
|
224 | + 'mn' => 'Mongolian', |
|
225 | + 'na' => 'Nauru', |
|
226 | + 'nv' => 'Navajo; Navaho', |
|
227 | + 'nr' => 'Ndebele, South; South Ndebele', |
|
228 | + 'nd' => 'Ndebele, North; North Ndebele', |
|
229 | + 'ng' => 'Ndonga', |
|
230 | + 'ne' => 'Nepali', |
|
231 | + 'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian', |
|
232 | + 'nb' => 'Bokmål, Norwegian, Norwegian Bokmål', |
|
233 | + 'no' => 'Norwegian', |
|
234 | + 'ny' => 'Chichewa; Chewa; Nyanja', |
|
235 | + 'oc' => 'Occitan, Provençal', |
|
236 | + 'oj' => 'Ojibwa', |
|
237 | + 'or' => 'Oriya', |
|
238 | + 'om' => 'Oromo', |
|
239 | + 'os' => 'Ossetian; Ossetic', |
|
240 | + 'pa' => 'Panjabi; Punjabi', |
|
241 | + 'fa' => 'Persian', |
|
242 | + 'pi' => 'Pali', |
|
243 | + 'pl' => 'Polish', |
|
244 | + 'pt' => 'Portuguese', |
|
245 | + 'ps' => 'Pushto', |
|
246 | + 'qu' => 'Quechua', |
|
247 | + 'rm' => 'Romansh', |
|
248 | + 'ro' => 'Romanian', |
|
249 | + 'rn' => 'Rundi', |
|
250 | + 'ru' => 'Russian', |
|
251 | + 'sg' => 'Sango', |
|
252 | + 'sa' => 'Sanskrit', |
|
253 | + 'sr' => 'Serbian', |
|
254 | + 'hr' => 'Croatian', |
|
255 | + 'si' => 'Sinhala; Sinhalese', |
|
256 | + 'sk' => 'Slovak', |
|
257 | + 'sl' => 'Slovenian', |
|
258 | + 'se' => 'Northern Sami', |
|
259 | + 'sm' => 'Samoan', |
|
260 | + 'sn' => 'Shona', |
|
261 | + 'sd' => 'Sindhi', |
|
262 | + 'so' => 'Somali', |
|
263 | + 'st' => 'Sotho, Southern', |
|
264 | + 'es' => 'Spanish; Castilian', |
|
265 | + 'sc' => 'Sardinian', |
|
266 | + 'ss' => 'Swati', |
|
267 | + 'su' => 'Sundanese', |
|
268 | + 'sw' => 'Swahili', |
|
269 | + 'sv' => 'Swedish', |
|
270 | + 'ty' => 'Tahitian', |
|
271 | + 'ta' => 'Tamil', |
|
272 | + 'tt' => 'Tatar', |
|
273 | + 'te' => 'Telugu', |
|
274 | + 'tg' => 'Tajik', |
|
275 | + 'tl' => 'Tagalog', |
|
276 | + 'th' => 'Thai', |
|
277 | + 'bo' => 'Tibetan', |
|
278 | + 'ti' => 'Tigrinya', |
|
279 | + 'to' => 'Tonga (Tonga Islands)', |
|
280 | + 'tn' => 'Tswana', |
|
281 | + 'ts' => 'Tsonga', |
|
282 | + 'tk' => 'Turkmen', |
|
283 | + 'tr' => 'Turkish', |
|
284 | + 'tw' => 'Twi', |
|
285 | + 'ug' => 'Uighur; Uyghur', |
|
286 | + 'uk' => 'Ukrainian', |
|
287 | + 'ur' => 'Urdu', |
|
288 | + 'uz' => 'Uzbek', |
|
289 | + 've' => 'Venda', |
|
290 | + 'vi' => 'Vietnamese', |
|
291 | + 'vo' => 'Volapük', |
|
292 | + 'cy' => 'Welsh', |
|
293 | + 'wa' => 'Walloon', |
|
294 | + 'wo' => 'Wolof', |
|
295 | + 'xh' => 'Xhosa', |
|
296 | + 'yi' => 'Yiddish', |
|
297 | + 'yo' => 'Yoruba', |
|
298 | + 'za' => 'Zhuang; Chuang', |
|
299 | + 'zu' => 'Zulu', |
|
300 | + ); |
|
301 | 301 | |
302 | - /** |
|
303 | - * Filters the language codes. |
|
304 | - * |
|
305 | - * @since MU |
|
306 | - * |
|
307 | - * @param array $lang_codes Key/value pair of language codes where key is the short version. |
|
308 | - * @param string $code A two-letter designation of the language. |
|
309 | - */ |
|
310 | - $lang_codes = apply_filters( 'lang_codes', $lang_codes, $code ); |
|
302 | + /** |
|
303 | + * Filters the language codes. |
|
304 | + * |
|
305 | + * @since MU |
|
306 | + * |
|
307 | + * @param array $lang_codes Key/value pair of language codes where key is the short version. |
|
308 | + * @param string $code A two-letter designation of the language. |
|
309 | + */ |
|
310 | + $lang_codes = apply_filters( 'lang_codes', $lang_codes, $code ); |
|
311 | 311 | |
312 | - return strtr( $code, $lang_codes ); |
|
313 | - } |
|
312 | + return strtr( $code, $lang_codes ); |
|
313 | + } |
|
314 | 314 | |
315 | 315 | } |
@@ -8,8 +8,8 @@ |
||
8 | 8 | ?> |
9 | 9 | <form method="post" action="options.php"> |
10 | 10 | <?php |
11 | - settings_fields( 'wl_settings__webhooks' ); |
|
12 | - do_settings_sections( 'wl_settings__webhooks' ); |
|
13 | - submit_button( 'Save Settings' ); |
|
14 | - ?> |
|
11 | + settings_fields( 'wl_settings__webhooks' ); |
|
12 | + do_settings_sections( 'wl_settings__webhooks' ); |
|
13 | + submit_button( 'Save Settings' ); |
|
14 | + ?> |
|
15 | 15 | </form> |
@@ -3,12 +3,12 @@ |
||
3 | 3 | * HTML for Webhook Settings Tab. |
4 | 4 | * Added for feature request 1496 |
5 | 5 | */ |
6 | -settings_errors( 'wl_webhook_error' ); |
|
6 | +settings_errors('wl_webhook_error'); |
|
7 | 7 | ?> |
8 | 8 | <form method="post" action="options.php"> |
9 | 9 | <?php |
10 | - settings_fields( 'wl_settings__webhooks' ); |
|
11 | - do_settings_sections( 'wl_settings__webhooks' ); |
|
12 | - submit_button( 'Save Settings' ); |
|
10 | + settings_fields('wl_settings__webhooks'); |
|
11 | + do_settings_sections('wl_settings__webhooks'); |
|
12 | + submit_button('Save Settings'); |
|
13 | 13 | ?> |
14 | 14 | </form> |
@@ -7,14 +7,14 @@ |
||
7 | 7 | */ |
8 | 8 | class Webhooks_Loader { |
9 | 9 | |
10 | - const URLS_OPTION_NAME = 'wl_webhooks_urls'; |
|
10 | + const URLS_OPTION_NAME = 'wl_webhooks_urls'; |
|
11 | 11 | |
12 | - public function init() { |
|
12 | + public function init() { |
|
13 | 13 | |
14 | - $settings_tab = new Webhooks_Settings(); |
|
15 | - $settings_tab->init(); |
|
14 | + $settings_tab = new Webhooks_Settings(); |
|
15 | + $settings_tab->init(); |
|
16 | 16 | |
17 | - new Webhooks_Manager(); |
|
18 | - } |
|
17 | + new Webhooks_Manager(); |
|
18 | + } |
|
19 | 19 | |
20 | 20 | } |
@@ -3,7 +3,7 @@ |
||
3 | 3 | use Wordlift\Features\Response_Adapter; |
4 | 4 | |
5 | 5 | if ( ! defined( 'ABSPATH' ) ) { |
6 | - exit; |
|
6 | + exit; |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | new Response_Adapter(); |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | use Wordlift\Features\Response_Adapter; |
4 | 4 | |
5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
5 | +if ( ! defined('ABSPATH')) { |
|
6 | 6 | exit; |
7 | 7 | } |
8 | 8 |
@@ -21,23 +21,23 @@ |
||
21 | 21 | */ |
22 | 22 | private $type; |
23 | 23 | |
24 | - public static function create_post( $id ) { |
|
25 | - return new self( $id, Object_Type_Enum::POST ); |
|
24 | + public static function create_post($id) { |
|
25 | + return new self($id, Object_Type_Enum::POST); |
|
26 | 26 | } |
27 | 27 | |
28 | - public static function create_term( $id ) { |
|
29 | - return new self( $id, Object_Type_Enum::TERM ); |
|
28 | + public static function create_term($id) { |
|
29 | + return new self($id, Object_Type_Enum::TERM); |
|
30 | 30 | } |
31 | 31 | |
32 | - public static function create_user( $id ) { |
|
33 | - return new self( $id, Object_Type_Enum::USER ); |
|
32 | + public static function create_user($id) { |
|
33 | + return new self($id, Object_Type_Enum::USER); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @param int $id The post/page/term/user ID. |
38 | 38 | * @param int $type The content type, post/page/term/user. |
39 | 39 | */ |
40 | - public function __construct( $id, $type ) { |
|
40 | + public function __construct($id, $type) { |
|
41 | 41 | $this->id = $id; |
42 | 42 | $this->type = $type; |
43 | 43 | } |
@@ -12,43 +12,43 @@ |
||
12 | 12 | // phpcs:ignore WordPress.WP.CapitalPDangit.MisspelledClassName |
13 | 13 | class Wordpress_Content_Id implements Content_Id { |
14 | 14 | |
15 | - /** |
|
16 | - * @var int $id The post/page/term/user ID. |
|
17 | - */ |
|
18 | - private $id; |
|
19 | - |
|
20 | - /** |
|
21 | - * @var Object_Type_Enum $type The content type, post/page/term/user. |
|
22 | - */ |
|
23 | - private $type; |
|
24 | - |
|
25 | - public static function create_post( $id ) { |
|
26 | - return new self( $id, Object_Type_Enum::POST ); |
|
27 | - } |
|
28 | - |
|
29 | - public static function create_term( $id ) { |
|
30 | - return new self( $id, Object_Type_Enum::TERM ); |
|
31 | - } |
|
32 | - |
|
33 | - public static function create_user( $id ) { |
|
34 | - return new self( $id, Object_Type_Enum::USER ); |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * @param int $id The post/page/term/user ID. |
|
39 | - * @param int $type The content type, post/page/term/user. |
|
40 | - */ |
|
41 | - public function __construct( $id, $type ) { |
|
42 | - $this->id = $id; |
|
43 | - $this->type = $type; |
|
44 | - } |
|
45 | - |
|
46 | - public function get_id() { |
|
47 | - return $this->id; |
|
48 | - } |
|
49 | - |
|
50 | - public function get_type() { |
|
51 | - return $this->type; |
|
52 | - } |
|
15 | + /** |
|
16 | + * @var int $id The post/page/term/user ID. |
|
17 | + */ |
|
18 | + private $id; |
|
19 | + |
|
20 | + /** |
|
21 | + * @var Object_Type_Enum $type The content type, post/page/term/user. |
|
22 | + */ |
|
23 | + private $type; |
|
24 | + |
|
25 | + public static function create_post( $id ) { |
|
26 | + return new self( $id, Object_Type_Enum::POST ); |
|
27 | + } |
|
28 | + |
|
29 | + public static function create_term( $id ) { |
|
30 | + return new self( $id, Object_Type_Enum::TERM ); |
|
31 | + } |
|
32 | + |
|
33 | + public static function create_user( $id ) { |
|
34 | + return new self( $id, Object_Type_Enum::USER ); |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * @param int $id The post/page/term/user ID. |
|
39 | + * @param int $type The content type, post/page/term/user. |
|
40 | + */ |
|
41 | + public function __construct( $id, $type ) { |
|
42 | + $this->id = $id; |
|
43 | + $this->type = $type; |
|
44 | + } |
|
45 | + |
|
46 | + public function get_id() { |
|
47 | + return $this->id; |
|
48 | + } |
|
49 | + |
|
50 | + public function get_type() { |
|
51 | + return $this->type; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | } |
@@ -13,33 +13,33 @@ |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | protected function get_dataset_uri() { |
16 | - return trailingslashit( Wordlift_Configuration_Service::get_instance()->get_dataset_uri() ); |
|
16 | + return trailingslashit(Wordlift_Configuration_Service::get_instance()->get_dataset_uri()); |
|
17 | 17 | } |
18 | 18 | |
19 | - protected function is_absolute( $uri ) { |
|
20 | - return 1 === preg_match( '@^https?://@', $uri ); |
|
19 | + protected function is_absolute($uri) { |
|
20 | + return 1 === preg_match('@^https?://@', $uri); |
|
21 | 21 | } |
22 | 22 | |
23 | - protected function is_internal( $uri ) { |
|
23 | + protected function is_internal($uri) { |
|
24 | 24 | $dataset_uri = $this->get_dataset_uri(); |
25 | 25 | |
26 | - return ! empty( $dataset_uri ) && 0 === strpos( $uri, $dataset_uri ); |
|
26 | + return ! empty($dataset_uri) && 0 === strpos($uri, $dataset_uri); |
|
27 | 27 | } |
28 | 28 | |
29 | - protected function make_absolute( $uri ) { |
|
30 | - Assertions::not_empty( $this->get_dataset_uri(), '`dataset_uri` cannot be empty.' ); |
|
29 | + protected function make_absolute($uri) { |
|
30 | + Assertions::not_empty($this->get_dataset_uri(), '`dataset_uri` cannot be empty.'); |
|
31 | 31 | |
32 | - if ( 1 !== preg_match( '@^https?://@', $uri ) ) { |
|
33 | - return $this->get_dataset_uri() . $uri; |
|
32 | + if (1 !== preg_match('@^https?://@', $uri)) { |
|
33 | + return $this->get_dataset_uri().$uri; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | return $uri; |
37 | 37 | } |
38 | 38 | |
39 | - protected function make_relative( $uri ) { |
|
39 | + protected function make_relative($uri) { |
|
40 | 40 | $dataset_uri = $this->get_dataset_uri(); |
41 | - if ( 0 === strpos( $uri, $dataset_uri ) ) { |
|
42 | - return substr( $uri, strlen( $dataset_uri ) ); |
|
41 | + if (0 === strpos($uri, $dataset_uri)) { |
|
42 | + return substr($uri, strlen($dataset_uri)); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | return $uri; |
@@ -9,41 +9,41 @@ |
||
9 | 9 | // phpcs:ignore WordPress.WP.CapitalPDangit.MisspelledClassName |
10 | 10 | abstract class Abstract_Wordpress_Content_Service implements Content_Service { |
11 | 11 | |
12 | - protected function __construct() { |
|
12 | + protected function __construct() { |
|
13 | 13 | |
14 | - } |
|
14 | + } |
|
15 | 15 | |
16 | - protected function get_dataset_uri() { |
|
17 | - return trailingslashit( Wordlift_Configuration_Service::get_instance()->get_dataset_uri() ); |
|
18 | - } |
|
16 | + protected function get_dataset_uri() { |
|
17 | + return trailingslashit( Wordlift_Configuration_Service::get_instance()->get_dataset_uri() ); |
|
18 | + } |
|
19 | 19 | |
20 | - protected function is_absolute( $uri ) { |
|
21 | - return 1 === preg_match( '@^https?://@', $uri ); |
|
22 | - } |
|
20 | + protected function is_absolute( $uri ) { |
|
21 | + return 1 === preg_match( '@^https?://@', $uri ); |
|
22 | + } |
|
23 | 23 | |
24 | - protected function is_internal( $uri ) { |
|
25 | - $dataset_uri = $this->get_dataset_uri(); |
|
24 | + protected function is_internal( $uri ) { |
|
25 | + $dataset_uri = $this->get_dataset_uri(); |
|
26 | 26 | |
27 | - return ! empty( $dataset_uri ) && 0 === strpos( $uri, $dataset_uri ); |
|
28 | - } |
|
27 | + return ! empty( $dataset_uri ) && 0 === strpos( $uri, $dataset_uri ); |
|
28 | + } |
|
29 | 29 | |
30 | - protected function make_absolute( $uri ) { |
|
31 | - Assertions::not_empty( $this->get_dataset_uri(), '`dataset_uri` cannot be empty.' ); |
|
30 | + protected function make_absolute( $uri ) { |
|
31 | + Assertions::not_empty( $this->get_dataset_uri(), '`dataset_uri` cannot be empty.' ); |
|
32 | 32 | |
33 | - if ( 1 !== preg_match( '@^https?://@', $uri ) ) { |
|
34 | - return $this->get_dataset_uri() . $uri; |
|
35 | - } |
|
33 | + if ( 1 !== preg_match( '@^https?://@', $uri ) ) { |
|
34 | + return $this->get_dataset_uri() . $uri; |
|
35 | + } |
|
36 | 36 | |
37 | - return $uri; |
|
38 | - } |
|
37 | + return $uri; |
|
38 | + } |
|
39 | 39 | |
40 | - protected function make_relative( $uri ) { |
|
41 | - $dataset_uri = $this->get_dataset_uri(); |
|
42 | - if ( 0 === strpos( $uri, $dataset_uri ) ) { |
|
43 | - return substr( $uri, strlen( $dataset_uri ) ); |
|
44 | - } |
|
40 | + protected function make_relative( $uri ) { |
|
41 | + $dataset_uri = $this->get_dataset_uri(); |
|
42 | + if ( 0 === strpos( $uri, $dataset_uri ) ) { |
|
43 | + return substr( $uri, strlen( $dataset_uri ) ); |
|
44 | + } |
|
45 | 45 | |
46 | - return $uri; |
|
47 | - } |
|
46 | + return $uri; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | private static $instance = null; |
29 | 29 | |
30 | 30 | public static function get_instance() { |
31 | - if ( ! isset( self::$instance ) ) { |
|
31 | + if ( ! isset(self::$instance)) { |
|
32 | 32 | self::$instance = new self(); |
33 | 33 | |
34 | 34 | $providers = array( |
@@ -39,16 +39,16 @@ discard block |
||
39 | 39 | new Term_Entity_Provider(), |
40 | 40 | ); |
41 | 41 | |
42 | - foreach ( apply_filters( 'wl_analysis_entity_providers', $providers ) as $provider ) { |
|
43 | - self::$instance->register_provider( $provider ); |
|
42 | + foreach (apply_filters('wl_analysis_entity_providers', $providers) as $provider) { |
|
43 | + self::$instance->register_provider($provider); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | 47 | return self::$instance; |
48 | 48 | } |
49 | 49 | |
50 | - public function register_provider( $provider ) { |
|
51 | - Assertions::is_a( $provider, 'Wordlift\Analysis\Entity_Provider\Entity_Provider', '`provider` must implement the `Wordlift\Analysis\Entity_Provider` interface.' ); |
|
50 | + public function register_provider($provider) { |
|
51 | + Assertions::is_a($provider, 'Wordlift\Analysis\Entity_Provider\Entity_Provider', '`provider` must implement the `Wordlift\Analysis\Entity_Provider` interface.'); |
|
52 | 52 | |
53 | 53 | $this->entity_providers[] = $provider; |
54 | 54 | } |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return array|bool |
61 | 61 | */ |
62 | - public function get_local_entity( $uri ) { |
|
62 | + public function get_local_entity($uri) { |
|
63 | 63 | |
64 | - if ( count( $this->entity_providers ) === 0 ) { |
|
64 | + if (count($this->entity_providers) === 0) { |
|
65 | 65 | return false; |
66 | 66 | } |
67 | 67 | |
68 | - foreach ( $this->entity_providers as $entity_provider ) { |
|
69 | - $entity_data = $entity_provider->get_entity( $uri ); |
|
70 | - if ( $entity_data ) { |
|
68 | + foreach ($this->entity_providers as $entity_provider) { |
|
69 | + $entity_data = $entity_provider->get_entity($uri); |
|
70 | + if ($entity_data) { |
|
71 | 71 | return $entity_data; |
72 | 72 | } |
73 | 73 | } |
@@ -17,62 +17,62 @@ |
||
17 | 17 | |
18 | 18 | class Entity_Provider_Registry { |
19 | 19 | |
20 | - /** |
|
21 | - * @var Entity_Provider[] |
|
22 | - */ |
|
23 | - private $entity_providers = array(); |
|
24 | - |
|
25 | - protected function __construct() { |
|
26 | - } |
|
27 | - |
|
28 | - private static $instance = null; |
|
29 | - |
|
30 | - public static function get_instance() { |
|
31 | - if ( ! isset( self::$instance ) ) { |
|
32 | - self::$instance = new self(); |
|
33 | - |
|
34 | - $providers = array( |
|
35 | - new Post_Entity_Provider( |
|
36 | - Wordlift_Entity_Uri_Service::get_instance(), |
|
37 | - Wordlift_Entity_Type_Service::get_instance(), |
|
38 | - new Wordlift_Post_Image_Storage() |
|
39 | - ), |
|
40 | - new Term_Entity_Provider(), |
|
41 | - ); |
|
42 | - |
|
43 | - foreach ( apply_filters( 'wl_analysis_entity_providers', $providers ) as $provider ) { |
|
44 | - self::$instance->register_provider( $provider ); |
|
45 | - } |
|
46 | - } |
|
47 | - |
|
48 | - return self::$instance; |
|
49 | - } |
|
50 | - |
|
51 | - public function register_provider( $provider ) { |
|
52 | - Assertions::is_a( $provider, 'Wordlift\Analysis\Entity_Provider\Entity_Provider', '`provider` must implement the `Wordlift\Analysis\Entity_Provider` interface.' ); |
|
53 | - |
|
54 | - $this->entity_providers[] = $provider; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param $uri |
|
59 | - * |
|
60 | - * @return array|bool |
|
61 | - */ |
|
62 | - public function get_local_entity( $uri ) { |
|
63 | - |
|
64 | - if ( count( $this->entity_providers ) === 0 ) { |
|
65 | - return false; |
|
66 | - } |
|
67 | - |
|
68 | - foreach ( $this->entity_providers as $entity_provider ) { |
|
69 | - $entity_data = $entity_provider->get_entity( $uri ); |
|
70 | - if ( $entity_data ) { |
|
71 | - return $entity_data; |
|
72 | - } |
|
73 | - } |
|
74 | - |
|
75 | - return false; |
|
76 | - } |
|
20 | + /** |
|
21 | + * @var Entity_Provider[] |
|
22 | + */ |
|
23 | + private $entity_providers = array(); |
|
24 | + |
|
25 | + protected function __construct() { |
|
26 | + } |
|
27 | + |
|
28 | + private static $instance = null; |
|
29 | + |
|
30 | + public static function get_instance() { |
|
31 | + if ( ! isset( self::$instance ) ) { |
|
32 | + self::$instance = new self(); |
|
33 | + |
|
34 | + $providers = array( |
|
35 | + new Post_Entity_Provider( |
|
36 | + Wordlift_Entity_Uri_Service::get_instance(), |
|
37 | + Wordlift_Entity_Type_Service::get_instance(), |
|
38 | + new Wordlift_Post_Image_Storage() |
|
39 | + ), |
|
40 | + new Term_Entity_Provider(), |
|
41 | + ); |
|
42 | + |
|
43 | + foreach ( apply_filters( 'wl_analysis_entity_providers', $providers ) as $provider ) { |
|
44 | + self::$instance->register_provider( $provider ); |
|
45 | + } |
|
46 | + } |
|
47 | + |
|
48 | + return self::$instance; |
|
49 | + } |
|
50 | + |
|
51 | + public function register_provider( $provider ) { |
|
52 | + Assertions::is_a( $provider, 'Wordlift\Analysis\Entity_Provider\Entity_Provider', '`provider` must implement the `Wordlift\Analysis\Entity_Provider` interface.' ); |
|
53 | + |
|
54 | + $this->entity_providers[] = $provider; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param $uri |
|
59 | + * |
|
60 | + * @return array|bool |
|
61 | + */ |
|
62 | + public function get_local_entity( $uri ) { |
|
63 | + |
|
64 | + if ( count( $this->entity_providers ) === 0 ) { |
|
65 | + return false; |
|
66 | + } |
|
67 | + |
|
68 | + foreach ( $this->entity_providers as $entity_provider ) { |
|
69 | + $entity_data = $entity_provider->get_entity( $uri ); |
|
70 | + if ( $entity_data ) { |
|
71 | + return $entity_data; |
|
72 | + } |
|
73 | + } |
|
74 | + |
|
75 | + return false; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | } |
@@ -17,9 +17,9 @@ |
||
17 | 17 | * @return Content_Service |
18 | 18 | */ |
19 | 19 | public static function get_instance() { |
20 | - if ( ! isset( self::$instance ) ) { |
|
20 | + if ( ! isset(self::$instance)) { |
|
21 | 21 | |
22 | - if ( apply_filters( 'wl_feature__enable__dataset', true ) ) { |
|
22 | + if (apply_filters('wl_feature__enable__dataset', true)) { |
|
23 | 23 | self::$instance = Wordpress_Dataset_Content_Service::get_instance(); |
24 | 24 | } else { |
25 | 25 | self::$instance = Wordpress_Permalink_Content_Service::get_instance(); |
@@ -7,27 +7,27 @@ |
||
7 | 7 | // phpcs:ignore WordPress.WP.CapitalPDangit.MisspelledClassName |
8 | 8 | class Wordpress_Content_Service { |
9 | 9 | |
10 | - protected function __construct() { |
|
11 | - } |
|
12 | - |
|
13 | - private static $instance = null; |
|
14 | - |
|
15 | - /** |
|
16 | - * The singleton instance. |
|
17 | - * |
|
18 | - * @return Content_Service |
|
19 | - */ |
|
20 | - public static function get_instance() { |
|
21 | - if ( ! isset( self::$instance ) ) { |
|
22 | - |
|
23 | - if ( apply_filters( 'wl_feature__enable__dataset', true ) ) { |
|
24 | - self::$instance = Wordpress_Dataset_Content_Service::get_instance(); |
|
25 | - } else { |
|
26 | - self::$instance = Wordpress_Permalink_Content_Service::get_instance(); |
|
27 | - } |
|
28 | - } |
|
29 | - |
|
30 | - return self::$instance; |
|
31 | - } |
|
10 | + protected function __construct() { |
|
11 | + } |
|
12 | + |
|
13 | + private static $instance = null; |
|
14 | + |
|
15 | + /** |
|
16 | + * The singleton instance. |
|
17 | + * |
|
18 | + * @return Content_Service |
|
19 | + */ |
|
20 | + public static function get_instance() { |
|
21 | + if ( ! isset( self::$instance ) ) { |
|
22 | + |
|
23 | + if ( apply_filters( 'wl_feature__enable__dataset', true ) ) { |
|
24 | + self::$instance = Wordpress_Dataset_Content_Service::get_instance(); |
|
25 | + } else { |
|
26 | + self::$instance = Wordpress_Permalink_Content_Service::get_instance(); |
|
27 | + } |
|
28 | + } |
|
29 | + |
|
30 | + return self::$instance; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | } |
@@ -15,41 +15,41 @@ discard block |
||
15 | 15 | |
16 | 16 | class Post_Entity_Provider implements Entity_Provider { |
17 | 17 | |
18 | - /** |
|
19 | - * @var \Wordlift_Entity_Uri_Service |
|
20 | - */ |
|
21 | - private $entity_uri_service; |
|
22 | - /** |
|
23 | - * @var \Wordlift_Entity_Type_Service |
|
24 | - */ |
|
25 | - private $entity_type_service; |
|
26 | - /** |
|
27 | - * @var \Wordlift_Post_Image_Storage |
|
28 | - */ |
|
29 | - private $post_image_storage; |
|
18 | + /** |
|
19 | + * @var \Wordlift_Entity_Uri_Service |
|
20 | + */ |
|
21 | + private $entity_uri_service; |
|
22 | + /** |
|
23 | + * @var \Wordlift_Entity_Type_Service |
|
24 | + */ |
|
25 | + private $entity_type_service; |
|
26 | + /** |
|
27 | + * @var \Wordlift_Post_Image_Storage |
|
28 | + */ |
|
29 | + private $post_image_storage; |
|
30 | 30 | |
31 | - public function __construct( $entity_uri_service, $entity_type_service, $post_image_storage ) { |
|
32 | - $this->entity_uri_service = $entity_uri_service; |
|
33 | - $this->entity_type_service = $entity_type_service; |
|
34 | - $this->post_image_storage = $post_image_storage; |
|
35 | - } |
|
31 | + public function __construct( $entity_uri_service, $entity_type_service, $post_image_storage ) { |
|
32 | + $this->entity_uri_service = $entity_uri_service; |
|
33 | + $this->entity_type_service = $entity_type_service; |
|
34 | + $this->post_image_storage = $post_image_storage; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - public function get_entity( $uri ) { |
|
39 | - $content = Wordpress_Content_Service::get_instance()->get_by_entity_id_or_same_as( $uri ); |
|
38 | + public function get_entity( $uri ) { |
|
39 | + $content = Wordpress_Content_Service::get_instance()->get_by_entity_id_or_same_as( $uri ); |
|
40 | 40 | |
41 | - if ( ! isset( $content ) || ! is_a( $content->get_bag(), '\WP_Post' ) ) { |
|
42 | - return false; |
|
43 | - } |
|
41 | + if ( ! isset( $content ) || ! is_a( $content->get_bag(), '\WP_Post' ) ) { |
|
42 | + return false; |
|
43 | + } |
|
44 | 44 | |
45 | - $entity = $content->get_bag(); |
|
46 | - $type = $this->entity_type_service->get( $entity->ID ); |
|
47 | - $images = $this->post_image_storage->get( $entity->ID ); |
|
45 | + $entity = $content->get_bag(); |
|
46 | + $type = $this->entity_type_service->get( $entity->ID ); |
|
47 | + $images = $this->post_image_storage->get( $entity->ID ); |
|
48 | 48 | |
49 | - return (object) array( |
|
50 | - 'id' => $uri, |
|
51 | - 'label' => $entity->post_title, |
|
52 | - /* |
|
49 | + return (object) array( |
|
50 | + 'id' => $uri, |
|
51 | + 'label' => $entity->post_title, |
|
52 | + /* |
|
53 | 53 | * As of 2020.06.29 we're comment out the `post_content` because Gutenberg posts will return here |
54 | 54 | * the whole Gutenberg source including potentially our own wordlift/classification block, which means |
55 | 55 | * that data may grow quickly to more than a 100 KBytes and could break web servers. |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | * |
62 | 62 | * PS: We didn't test using the WordLift Post Excerpt Helper. |
63 | 63 | */ |
64 | - // 'description' => $entity->post_content, |
|
65 | - 'description' => '', |
|
66 | - 'sameAs' => wl_schema_get_value( $entity->ID, 'sameAs' ), |
|
67 | - 'mainType' => str_replace( 'wl-', '', $type['css_class'] ), |
|
68 | - 'types' => wl_get_entity_rdf_types( $entity->ID ), |
|
69 | - 'images' => $images, |
|
70 | - ); |
|
71 | - } |
|
64 | + // 'description' => $entity->post_content, |
|
65 | + 'description' => '', |
|
66 | + 'sameAs' => wl_schema_get_value( $entity->ID, 'sameAs' ), |
|
67 | + 'mainType' => str_replace( 'wl-', '', $type['css_class'] ), |
|
68 | + 'types' => wl_get_entity_rdf_types( $entity->ID ), |
|
69 | + 'images' => $images, |
|
70 | + ); |
|
71 | + } |
|
72 | 72 | |
73 | 73 | } |
@@ -28,23 +28,23 @@ discard block |
||
28 | 28 | */ |
29 | 29 | private $post_image_storage; |
30 | 30 | |
31 | - public function __construct( $entity_uri_service, $entity_type_service, $post_image_storage ) { |
|
31 | + public function __construct($entity_uri_service, $entity_type_service, $post_image_storage) { |
|
32 | 32 | $this->entity_uri_service = $entity_uri_service; |
33 | 33 | $this->entity_type_service = $entity_type_service; |
34 | 34 | $this->post_image_storage = $post_image_storage; |
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | - public function get_entity( $uri ) { |
|
39 | - $content = Wordpress_Content_Service::get_instance()->get_by_entity_id_or_same_as( $uri ); |
|
38 | + public function get_entity($uri) { |
|
39 | + $content = Wordpress_Content_Service::get_instance()->get_by_entity_id_or_same_as($uri); |
|
40 | 40 | |
41 | - if ( ! isset( $content ) || ! is_a( $content->get_bag(), '\WP_Post' ) ) { |
|
41 | + if ( ! isset($content) || ! is_a($content->get_bag(), '\WP_Post')) { |
|
42 | 42 | return false; |
43 | 43 | } |
44 | 44 | |
45 | 45 | $entity = $content->get_bag(); |
46 | - $type = $this->entity_type_service->get( $entity->ID ); |
|
47 | - $images = $this->post_image_storage->get( $entity->ID ); |
|
46 | + $type = $this->entity_type_service->get($entity->ID); |
|
47 | + $images = $this->post_image_storage->get($entity->ID); |
|
48 | 48 | |
49 | 49 | return (object) array( |
50 | 50 | 'id' => $uri, |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | */ |
64 | 64 | // 'description' => $entity->post_content, |
65 | 65 | 'description' => '', |
66 | - 'sameAs' => wl_schema_get_value( $entity->ID, 'sameAs' ), |
|
67 | - 'mainType' => str_replace( 'wl-', '', $type['css_class'] ), |
|
68 | - 'types' => wl_get_entity_rdf_types( $entity->ID ), |
|
66 | + 'sameAs' => wl_schema_get_value($entity->ID, 'sameAs'), |
|
67 | + 'mainType' => str_replace('wl-', '', $type['css_class']), |
|
68 | + 'types' => wl_get_entity_rdf_types($entity->ID), |
|
69 | 69 | 'images' => $images, |
70 | 70 | ); |
71 | 71 | } |