PluginProbe
User Access Manager / 2.2.2
User Access Manager v2.2.2
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | src/Wrapper/Wordpress.php +405 -243 2.3.13 → 2.2.2 View file →
@@ -1,11 +1,23 @@
1 1 <?php
2 +/**
3 + * Wordpress.php
4 + *
5 + * The Wordpress class file.
6 + *
7 + * PHP versions 5
8 + *
9 + * @author Alexander Schneider <[email protected]>
10 + * @copyright 2008-2017 Alexander Schneider
11 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 + * @version SVN: $id$
13 + * @link http://wordpress.org/extend/plugins/user-access-manager/
14 + */
2 15
3 16 declare(strict_types=1);
4 17
5 18 namespace UserAccessManager\Wrapper;
6 19
7 -use JetBrains\PhpStorm\NoReturn;
8 20 use WP_Error;
9 21 use WP_Hook;
10 22 use WP_Post;
11 23 use WP_Post_Type;
@@ -41,9 +53,8 @@
41 53 use function get_pages;
42 54 use function get_post;
43 55 use function get_post_type_object;
44 56 use function get_post_types;
45 -use function get_queried_object_id;
46 57 use function get_sites;
47 58 use function get_taxonomies;
48 59 use function get_taxonomy;
49 60 use function get_term;
@@ -63,9 +74,8 @@
63 74 use function is_user_logged_in;
64 75 use function plugin_basename;
65 76 use function plugins_url;
66 77 use function register_widget;
67 -use function remove_action;
68 78 use function remove_filter;
69 79 use function site_url;
70 80 use function switch_to_blog;
71 81 use function update_option;
@@ -87,10 +97,19 @@
87 97 use function wp_registration_url;
88 98 use function wp_upload_dir;
89 99 use function wp_verify_nonce;
90 100
101 +/**
102 + * Class Wordpress
103 + *
104 + * @package UserAccessManager\Wrapper
105 + */
91 106 class Wordpress
92 107 {
108 + /**
109 + * Returns the database.
110 + * @return wpdb
111 + */
93 112 public function getDatabase(): wpdb
94 113 {
95 114 global $wpdb;
96 115 return $wpdb;
@@ -95,8 +114,12 @@
95 114 global $wpdb;
96 115 return $wpdb;
97 116 }
98 117
118 + /**
119 + * Returns true if web server is nginx.
120 + * @return bool
121 + */
99 122 public function isNginx(): bool
100 123 {
101 124 global $is_nginx;
102 125 return $is_nginx;
@@ -102,26 +125,12 @@
102 125 return $is_nginx;
103 126 }
104 127
105 128 /**
106 - * @see wp_using_ext_object_cache
129 + * @param string $postType
130 + * @return bool
131 + * @see \is_post_type_hierarchical()
107 132 */
108 - public function isUsingExtObjectCache(): bool
109 - {
110 - return function_exists('wp_using_ext_object_cache') && wp_using_ext_object_cache() === true;
111 - }
112 -
113 - /**
114 - * @see apache_get_modules
115 - */
116 - public function isApacheModuleLoaded(string $module): bool
117 - {
118 - return function_exists('apache_get_modules') && in_array($module, apache_get_modules(), true);
119 - }
120 -
121 - /**
122 - * @see is_post_type_hierarchical
123 - */
124 133 public function isPostTypeHierarchical(string $postType): bool
125 134 {
126 135 return is_post_type_hierarchical($postType);
127 136 }
@@ -126,9 +135,11 @@
126 135 return is_post_type_hierarchical($postType);
127 136 }
128 137
129 138 /**
130 - * @see is_taxonomy_hierarchical
139 + * @param string $taxonomy
140 + * @return bool
141 + * @see \is_taxonomy_hierarchical()
131 142 */
132 143 public function isTaxonomyHierarchical(string $taxonomy): bool
133 144 {
134 145 return is_taxonomy_hierarchical($taxonomy);
@@ -134,81 +145,99 @@
134 145 return is_taxonomy_hierarchical($taxonomy);
135 146 }
136 147
137 148 /**
138 - * @see get_userdata
149 + * @param int|string $id
150 + * @return false|WP_User
151 + * @see \get_userdata()
139 152 */
140 - public function getUserData(int|string|null $id): WP_User|bool
153 + public function getUserData($id)
141 154 {
142 155 return get_userdata($id);
143 156 }
144 157
145 158 /**
146 - * @see get_post_types
159 + * @param string|array $arguments
160 + * @param string $output
161 + * @param string $operator
162 + * @return array
163 + * @see \get_post_types()
147 164 */
148 - public function getPostTypes(
149 - array|string|int $arguments = [],
150 - string $output = 'names',
151 - string $operator = 'and'
152 - ): array {
165 + public function getPostTypes($arguments = [], $output = 'names', $operator = 'and'): array
166 + {
153 167 return get_post_types($arguments, $output, $operator);
154 168 }
155 169
156 170 /**
157 - * @return string[]|WP_Taxonomy[]
158 - * @see get_taxonomies
171 + * @param array $arguments
172 + * @param string $output
173 + * @param string $operator
174 + * @return array
175 + * @see \get_taxonomies()
159 176 */
160 - public function getTaxonomies(array $arguments = [], string $output = 'names', string $operator = 'and'): array
177 + public function getTaxonomies(array $arguments = [], $output = 'names', $operator = 'and'): array
161 178 {
162 179 return get_taxonomies($arguments, $output, $operator);
163 180 }
164 181
165 182 /**
166 - * @see get_taxonomy
183 + * @param string $taxonomy
184 + * @return false|WP_Taxonomy
185 + * @see \get_taxonomy()
167 186 */
168 - public function getTaxonomy(string $taxonomy): WP_Taxonomy|bool
187 + public function getTaxonomy(string $taxonomy)
169 188 {
170 189 return get_taxonomy($taxonomy);
171 190 }
172 191
173 192 /**
174 - * @see get_post
193 + * @param int|string $id The post id.
194 + * @param string $output
195 + * @param string $filter
196 + * @return WP_Post|array|null
197 + * @see \get_post()
175 198 */
176 - public function getPost(
177 - int|string|null $id,
178 - string $output = OBJECT,
179 - string $filter = 'raw'
180 - ): WP_Post|array|bool|null {
199 + public function getPost($id, $output = OBJECT, $filter = 'raw')
200 + {
181 201 return get_post($id, $output, $filter);
182 202 }
183 203
184 204 /**
185 - * @see get_post_type_object
205 + * @param string $postType
206 + * @return null|WP_Post_Type
207 + * @see \get_post_type_object()
186 208 */
187 - public function getPostTypeObject(int|string $postType): ?WP_Post_Type
209 + public function getPostTypeObject(string $postType): ?WP_Post_Type
188 210 {
189 211 return get_post_type_object($postType);
190 212 }
191 213
192 214 /**
193 - * @see get_term
215 + * @param int|string $id
216 + * @param string $taxonomy
217 + * @param string $output
218 + * @param string $filter
219 + * @return array|null|WP_Error|WP_Term
220 + * @see \get_term()
194 221 */
195 - public function getTerm(
196 - int|string $id,
197 - string $taxonomy = '',
198 - string $output = OBJECT,
199 - string $filter = 'raw'
200 - ): WP_Term|WP_Error|array|bool|null {
222 + public function getTerm($id, string $taxonomy = '', string $output = OBJECT, string $filter = 'raw')
223 + {
201 224 return get_term($id, $taxonomy, $output, $filter);
202 225 }
203 226
204 227
205 228 /**
206 - * @see dbDelta
229 + * @param array|string $queries
230 + * @param bool $execute
231 + * @return array
232 + * @see \dbDelta()
207 233 */
208 - public function dbDelta(array|string $queries = '', bool $execute = true): array
234 + public function dbDelta($queries = '', $execute = true): array
209 235 {
210 236 if (function_exists('\dbDelta') === false) {
237 + /**
238 + * @noinspection PhpIncludeInspection
239 + */
211 240 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
212 241 }
213 242
214 243 return dbDelta($queries, $execute);
@@ -214,11 +243,13 @@
214 243 return dbDelta($queries, $execute);
215 244 }
216 245
217 246 /**
218 - * @see switch_to_blog
247 + * @param integer $blogId
248 + * @return int|true
249 + * @see \switch_to_blog()
219 250 */
220 - public function switchToBlog(int|string|null $blogId): bool
251 + public function switchToBlog(int $blogId)
221 252 {
222 253 if (function_exists('\switch_to_blog') === true) {
223 254 return switch_to_blog($blogId);
224 255 }
@@ -226,8 +257,9 @@
226 257 return true;
227 258 }
228 259
229 260 /**
261 + * @return bool
230 262 * @see \restore_current_blog()
231 263 */
232 264 public function restoreCurrentBlog(): bool
233 265 {
@@ -238,9 +270,10 @@
238 270 return true;
239 271 }
240 272
241 273 /**
242 - * @see is_multisite
274 + * @return bool
275 + * @see \is_multisite()
243 276 */
244 277 public function isMultiSite(): bool
245 278 {
246 279 return is_multisite();
@@ -246,77 +279,83 @@
246 279 return is_multisite();
247 280 }
248 281
249 282 /**
250 - * @see do_action
283 + * @param string $tag
284 + * @param mixed $arguments
285 + * @see \do_action()
251 286 */
252 - public function doAction(string $tag, mixed $arguments = ''): void
287 + public function doAction(string $tag, $arguments = '')
253 288 {
254 289 do_action($tag, $arguments);
255 290 }
256 291
257 292 /**
258 - * @see add_action
293 + * @param string $tag
294 + * @param callable $functionToAdd
295 + * @param int $priority
296 + * @param int $acceptedArguments
297 + * @return true
298 + * @see \add_action()
259 299 */
260 - public function addAction(
261 - string $tag,
262 - callable $functionToAdd,
263 - int $priority = 10,
264 - int $acceptedArguments = 1
265 - ): bool {
300 + public function addAction(string $tag, callable $functionToAdd, $priority = 10, $acceptedArguments = 1)
301 + {
266 302 return add_action($tag, $functionToAdd, $priority, $acceptedArguments);
267 303 }
268 304
269 305 /**
270 - * @see remove_action
306 + * @param string $tag
307 + * @param bool|callable $functionToCheck
308 + * @return bool|false|int
309 + * @see \has_filter()
271 310 */
272 - public function removeAction(string $hookName, callable $callback, int $priority = 10): bool
311 + public function hasFilter(string $tag, $functionToCheck = false)
273 312 {
274 - return remove_action($hookName, $callback, $priority);
313 + return has_filter($tag, $functionToCheck);
275 314 }
276 315
277 316 /**
278 - * @see has_filter
317 + * @param string $tag
318 + * @param callable $functionToAdd
319 + * @param int $priority
320 + * @param int $acceptedArguments
321 + * @return true
322 + * @see \add_filter()
279 323 */
280 - public function hasFilter(string $tag, callable|bool $functionToCheck = false): bool|int
324 + public function addFilter(string $tag, callable $functionToAdd, $priority = 10, $acceptedArguments = 1)
281 325 {
282 - return has_filter($tag, $functionToCheck);
283 - }
284 -
285 - /**
286 - * @see add_filter
287 - */
288 - public function addFilter(
289 - string $tag,
290 - callable $functionToAdd,
291 - int $priority = 10,
292 - int $acceptedArguments = 1
293 - ): bool {
294 326 return add_filter($tag, $functionToAdd, $priority, $acceptedArguments);
295 327 }
296 328
297 329 /**
298 - * @see remove_filter
330 + * @param string $tag
331 + * @param callable $functionToRemove
332 + * @param int $priority
333 + * @return bool
334 + * @see \remove_filter()
299 335 */
300 - public function removeFilter(string $tag, callable $functionToRemove, int $priority = 10): bool
336 + public function removeFilter(string $tag, callable $functionToRemove, $priority = 10): bool
301 337 {
302 338 return remove_filter($tag, $functionToRemove, $priority);
303 339 }
304 340
305 341 /**
306 - * @see add_option
342 + * @param string $option
343 + * @param mixed $value
344 + * @param string $deprecated
345 + * @param string|bool $autoload
346 + * @return bool
347 + * @see \add_option()
307 348 */
308 - public function addOption(
309 - string $option,
310 - mixed $value = '',
311 - string $deprecated = '',
312 - bool|string $autoload = 'yes'
313 - ): bool {
349 + public function addOption(string $option, $value = '', $deprecated = '', $autoload = 'yes'): bool
350 + {
314 351 return add_option($option, $value, $deprecated, $autoload);
315 352 }
316 353
317 354 /**
318 - * @see delete_option
355 + * @param string $option
356 + * @return bool
357 + * @see \delete_option()
319 358 */
320 359 public function deleteOption(string $option): bool
321 360 {
322 361 return delete_option($option);
@@ -322,33 +361,43 @@
322 361 return delete_option($option);
323 362 }
324 363
325 364 /**
326 - * @see update_option
365 + * @param string $option
366 + * @param mixed $value
367 + * @param string|bool $autoload
368 + * @return bool
369 + * @see \update_option()
327 370 */
328 - public function updateOption(string $option, mixed $value = '', bool|string $autoload = 'yes'): bool
371 + public function updateOption(string $option, $value = '', $autoload = 'yes'): bool
329 372 {
330 373 return update_option($option, $value, $autoload);
331 374 }
332 375
333 376 /**
334 - * @see get_option
377 + * @param string $option
378 + * @param mixed $default
379 + * @return mixed
380 + * @see \get_option()
335 381 */
336 - public function getOption(string $option, mixed $default = false)
382 + public function getOption(string $option, $default = false)
337 383 {
338 384 return get_option($option, $default);
339 385 }
340 386
341 387 /**
342 - * @see is_super_admin
388 + * @param int|bool $userId
389 + * @return bool
390 + * @see \is_super_admin()
343 391 */
344 - public function isSuperAdmin(bool|int|string|null $userId = false): bool
392 + public function isSuperAdmin($userId = false): bool
345 393 {
346 394 return is_super_admin($userId);
347 395 }
348 396
349 397 /**
350 - * @see wp_get_current_user
398 + * @return WP_User
399 + * @see \wp_get_current_user()
351 400 */
352 401 public function getCurrentUser(): WP_User
353 402 {
354 403 if (function_exists('\wp_get_current_user') === false) {
@@ -358,41 +407,54 @@
358 407 return wp_get_current_user();
359 408 }
360 409
361 410 /**
362 - * @see get_allowed_mime_types
411 + * @param int|WP_User $user
412 + * @return array
413 + * @see \get_allowed_mime_types()
363 414 */
364 - public function getAllowedMimeTypes(WP_User|int|string|null $user = null): array
415 + public function getAllowedMimeTypes($user = null): array
365 416 {
366 417 return get_allowed_mime_types($user);
367 418 }
368 419
369 420 /**
370 - * @see wp_upload_dir
421 + * @param string $time
422 + * @param bool $createDir
423 + * @param bool $refreshCache
424 + * @return array
425 + * @see \wp_upload_dir()
371 426 */
372 - public function getUploadDir(?string $time = null, bool $createDir = true, bool $refreshCache = false): array
427 + public function getUploadDir($time = null, $createDir = true, $refreshCache = false): array
373 428 {
374 429 return wp_upload_dir($time, $createDir, $refreshCache);
375 430 }
376 431
377 432 /**
378 - * @see home_url
433 + * @param string $path
434 + * @param null|string $scheme
435 + * @return string
436 + * @see \home_url()
379 437 */
380 - public function getHomeUrl(string $path = '', ?string $scheme = null): string
438 + public function getHomeUrl($path = '', $scheme = null): string
381 439 {
382 440 return home_url($path, $scheme);
383 441 }
384 442
385 443 /**
386 - * @see site_url
444 + * @param string $path
445 + * @param null|string $scheme
446 + * @return string
447 + * @see \site_url();
387 448 */
388 - public function getSiteUrl(string $path = '', ?string $scheme = null): string
449 + public function getSiteUrl($path = '', $scheme = null): string
389 450 {
390 451 return site_url($path, $scheme);
391 452 }
392 453
393 454 /**
394 - * @see get_home_path
455 + * @return string
456 + * @see \get_home_path()
395 457 */
396 458 public function getHomePath(): string
397 459 {
398 460 if (function_exists('\get_home_path') === false) {
@@ -402,34 +464,41 @@
402 464 return get_home_path();
403 465 }
404 466
405 467 /**
406 - * @see wp_parse_id_list
468 + * @param array|string $list
469 + * @return array
470 + * @see \wp_parse_id_list()
407 471 */
408 - public function parseIdList(array|string|int $list): array
472 + public function parseIdList($list): array
409 473 {
410 474 return wp_parse_id_list($list);
411 475 }
412 476
413 477 /**
414 - * @see wp_die
478 + * @param string $message
479 + * @param string $title
480 + * @param array $arguments
481 + * @see \wp_die()
415 482 */
416 - #[NoReturn]
417 - public function wpDie(string $message = '', string $title = '', array $arguments = []): void
483 + public function wpDie($message = '', $title = '', array $arguments = [])
418 484 {
419 485 wp_die($message, $title, $arguments);
420 486 }
421 487
422 488 /**
423 - * @see is_feed
489 + * @param string|array $feeds
490 + * @return bool
491 + * @see \is_feed()
424 492 */
425 - public function isFeed(array|string|int $feeds = ''): bool
493 + public function isFeed($feeds = ''): bool
426 494 {
427 495 return is_feed($feeds);
428 496 }
429 497
430 498 /**
431 - * @see is_user_logged_in
499 + * @return bool
500 + * @see \is_user_logged_in()
432 501 */
433 502 public function isUserLoggedIn(): bool
434 503 {
435 504 return is_user_logged_in();
@@ -435,34 +504,45 @@
435 504 return is_user_logged_in();
436 505 }
437 506
438 507 /**
439 - * @see get_page_by_path
508 + * @param string $pagePath
509 + * @param string $output
510 + * @param string $postType
511 + * @return array|null|WP_Post
512 + * @see \get_page_by_path()
440 513 */
441 - public function getPageByPath(
442 - string $pagePath,
443 - string $output = OBJECT,
444 - string $postType = 'page'
445 - ): array|WP_Post|null {
514 + public function getPageByPath(string $pagePath, $output = OBJECT, $postType = 'page')
515 + {
446 516 return get_page_by_path($pagePath, $output, $postType);
447 517 }
448 518
449 519 /**
450 - * @see wp_redirect
520 + * @param string $location
521 + * @param int $status
522 + * @return bool
523 + * @see \wp_redirect()
451 524 */
452 - public function wpRedirect(string $location, int $status = 302): bool
525 + public function wpRedirect(string $location, $status = 302): bool
453 526 {
454 527 return wp_redirect($location, $status);
455 528 }
456 529
457 - public function getPageLink(
458 - bool|int|string|WP_Post $post = false,
459 - bool $leaveName = false,
460 - bool $sample = false
461 - ): string {
530 + /**
531 + * @param bool|int|WP_Post $post
532 + * @param bool $leaveName
533 + * @param bool $sample
534 + * @return string The page permalink.
535 + */
536 + public function getPageLink($post = false, $leaveName = false, $sample = false): string
537 + {
462 538 return get_page_link($post, $leaveName, $sample);
463 539 }
464 540
541 + /**
542 + * Returns the wp_query object.
543 + * @return WP_Query
544 + */
465 545 public function getWpQuery(): WP_Query
466 546 {
467 547 global $wp_query;
468 548 return $wp_query;
@@ -468,52 +548,63 @@
468 548 return $wp_query;
469 549 }
470 550
471 551 /**
472 - * @see is_admin
552 + * @return bool
553 + * @see \is_admin()
473 554 */
474 555 public function isAdmin(): bool
475 556 {
476 - //Ajax request are always identified as an administrative interface page
477 - if (wp_doing_ajax() === true || defined('REST_REQUEST') && REST_REQUEST) {
557 + //Ajax request are always identified as administrative interface page
558 + if (wp_doing_ajax() === true) {
478 559 //So let's check if we are calling the ajax data for the frontend or backend
479 560 //If the referer is an admin url we are requesting the data for the backend
480 561 $adminUrl = get_admin_url();
481 - return str_starts_with((string)($_SERVER['HTTP_REFERER'] ?? ''), $adminUrl);
562 + return (substr($_SERVER['HTTP_REFERER'], 0, strlen($adminUrl)) === $adminUrl);
482 563 }
483 564
484 - //No ajax request just uses the normal function
565 + //No ajax request just use the normal function
485 566 return is_admin();
486 567 }
487 568
488 569 /**
489 - * @see wp_create_nonce
570 + * @param int|string $action
571 + * @return string
572 + * @see \wp_create_nonce()
490 573 */
491 - public function createNonce(int|string $action): string
574 + public function createNonce($action): string
492 575 {
493 576 return wp_create_nonce($action);
494 577 }
495 578
496 579 /**
497 - * @see wp_nonce_field
580 + * @param int|string $action
581 + * @param string $name
582 + * @param bool $referrer
583 + * @param bool $echo
584 + * @return string
585 + * @see \wp_nonce_field()
498 586 */
499 - public function getNonceField(
500 - int|string $action = -1,
501 - string $name = '_wpnonce',
502 - bool $referrer = true,
503 - bool $echo = true
504 - ): string {
587 + public function getNonceField($action = -1, $name = '_wpnonce', $referrer = true, $echo = true): string
588 + {
505 589 return wp_nonce_field($action, $name, $referrer, $echo);
506 590 }
507 591
508 592 /**
509 - * @see wp_verify_nonce
593 + * @param string|null $nonce
594 + * @param string|int $action
595 + * @return false|int
596 + * @see \wp_verify_nonce()
510 597 */
511 - public function verifyNonce(?string $nonce, int|string $action = -1): bool|int
598 + public function verifyNonce(?string $nonce, $action = -1)
512 599 {
513 600 return wp_verify_nonce($nonce, $action);
514 601 }
515 602
603 + /**
604 + * Returns the wordpress roles.
605 + * @return WP_Roles
606 + */
516 607 public function getRoles(): WP_Roles
517 608 {
518 609 global $wp_roles;
519 610 return $wp_roles;
@@ -519,9 +610,17 @@
519 610 return $wp_roles;
520 611 }
521 612
522 613 /**
523 - * @see add_menu_page
614 + * @param string $pageTitle
615 + * @param string $menuTitle
616 + * @param string $capability
617 + * @param string $menuSlug
618 + * @param mixed $function
619 + * @param string $iconUrl
620 + * @param null $position
621 + * @return string
622 + * @see \add_menu_page()
524 623 */
525 624 public function addMenuPage(
526 625 string $pageTitle,
527 626 string $menuTitle,
@@ -526,17 +625,24 @@
526 625 string $pageTitle,
527 626 string $menuTitle,
528 627 string $capability,
529 628 string $menuSlug,
530 - mixed $function = '',
531 - string $iconUrl = '',
532 - int|float|null $position = null
629 + $function = '',
630 + $iconUrl = '',
631 + $position = null
533 632 ): string {
534 633 return add_menu_page($pageTitle, $menuTitle, $capability, $menuSlug, $function, $iconUrl, $position);
535 634 }
536 635
537 636 /**
538 - * @see add_submenu_page
637 + * @param string $parentSlug
638 + * @param string $pageTitle
639 + * @param string $menuTitle
640 + * @param string $capability
641 + * @param string $menuSlug
642 + * @param string|callable $function
643 + * @return false|string
644 + * @see \add_submenu_page()
539 645 */
540 646 public function addSubMenuPage(
541 647 string $parentSlug,
542 648 string $pageTitle,
@@ -542,15 +648,22 @@
542 648 string $pageTitle,
543 649 string $menuTitle,
544 650 string $capability,
545 651 string $menuSlug,
546 - callable|string $function = ''
547 - ): bool|string {
652 + $function = ''
653 + ) {
548 654 return add_submenu_page($parentSlug, $pageTitle, $menuTitle, $capability, $menuSlug, $function);
549 655 }
550 656
551 657 /**
552 - * @see add_meta_box
658 + * @param string $id
659 + * @param string $title
660 + * @param callable $callback
661 + * @param null $screen
662 + * @param string $context
663 + * @param string $priority
664 + * @param null $callbackArguments
665 + * @see \add_meta_box()
553 666 */
554 667 public function addMetaBox(
555 668 string $id,
556 669 string $title,
@@ -555,75 +668,88 @@
555 668 string $id,
556 669 string $title,
557 670 callable $callback,
558 671 $screen = null,
559 - string $context = 'advanced',
560 - string $priority = 'default',
672 + $context = 'advanced',
673 + $priority = 'default',
561 674 $callbackArguments = null
562 - ): void {
675 + ) {
563 676 add_meta_box($id, $title, $callback, $screen, $context, $priority, $callbackArguments);
564 677 }
565 678
566 679 /**
567 - * @see get_pages
680 + * @param array|string $arguments
681 + * @return array|false
682 + * @see \get_pages()
568 683 */
569 - public function getPages(array|string|int $arguments): bool|array
684 + public function getPages($arguments)
570 685 {
571 686 return get_pages($arguments);
572 687 }
573 688
574 689 /**
575 - * @see wp_register_style
690 + * @param string $handle
691 + * @param string $source
692 + * @param array $depends
693 + * @param string|bool|null $version
694 + * @param string $media
695 + * @return bool
696 + * @see \wp_register_style()
576 697 */
577 - public function registerStyle(
578 - string $handle,
579 - string $source,
580 - array $depends = [],
581 - bool|string|null $version = false,
582 - string $media = 'all'
583 - ): bool {
698 + public function registerStyle(string $handle, string $source, $depends = [], $version = false, $media = 'all'): bool
699 + {
584 700 return wp_register_style($handle, $source, $depends, $version, $media);
585 701 }
586 702
587 703 /**
588 - * @see wp_register_script
704 + * @param string $handle
705 + * @param string $source
706 + * @param array $depends
707 + * @param string|bool|null $version
708 + * @param bool $inFooter
709 + * @return bool
710 + * @see \wp_register_script()
589 711 */
590 712 public function registerScript(
591 713 string $handle,
592 714 string $source,
593 - array $depends = [],
594 - bool|string|null $version = false,
595 - bool $inFooter = false
715 + $depends = [],
716 + $version = false,
717 + $inFooter = false
596 718 ): bool {
597 719 return wp_register_script($handle, $source, $depends, $version, $inFooter);
598 720 }
599 721
600 722 /**
601 - * @see wp_enqueue_style
723 + * @param string $handle
724 + * @param string $source
725 + * @param array $depends
726 + * @param string|bool|null $version
727 + * @param string $media
728 + * @see \wp_enqueue_style()
602 729 */
603 - public function enqueueStyle(
604 - string $handle,
605 - string $source = '',
606 - array $depends = [],
607 - bool|string|null $version = false,
608 - string $media = 'all'
609 - ): void {
730 + public function enqueueStyle(string $handle, $source = '', $depends = [], $version = false, $media = 'all')
731 + {
610 732 wp_enqueue_style($handle, $source, $depends, $version, $media);
611 733 }
612 734
613 735 /**
614 - * @see wp_enqueue_script
736 + * @param string $handle
737 + * @param string $source
738 + * @param array $depends
739 + * @param string|bool|null $version
740 + * @param bool $inFooter
741 + * @see \wp_enqueue_script()
615 742 */
616 - public function enqueueScript(
617 - string $handle,
618 - string $source = '',
619 - array $depends = [],
620 - bool|string|null $version = false,
621 - bool $inFooter = false
622 - ): void {
743 + public function enqueueScript(string $handle, $source = '', $depends = [], $version = false, $inFooter = false)
744 + {
623 745 wp_enqueue_script($handle, $source, $depends, $version, $inFooter);
624 746 }
625 747
748 + /**
749 + * Returns the wordpress meta boxes.
750 + * @return array
751 + */
626 752 public function getMetaBoxes(): array
627 753 {
628 754 global $wp_meta_boxes;
629 755 return $wp_meta_boxes;
@@ -628,9 +754,13 @@
628 754 global $wp_meta_boxes;
629 755 return $wp_meta_boxes;
630 756 }
631 757
632 - public function setMetaBoxes(array $wpMetaBoxes): void
758 + /**
759 + * Sets the wordpress meta boxes.
760 + * @param array $wpMetaBoxes
761 + */
762 + public function setMetaBoxes(array $wpMetaBoxes)
633 763 {
634 764 global $wp_meta_boxes;
635 765 $wp_meta_boxes = $wpMetaBoxes;
636 766 }
@@ -635,9 +765,11 @@
635 765 $wp_meta_boxes = $wpMetaBoxes;
636 766 }
637 767
638 768 /**
639 - * @see get_sites
769 + * @param array $arguments
770 + * @return array
771 + * @see \get_sites()
640 772 */
641 773 public function getSites(array $arguments = []): array
642 774 {
643 775 if (function_exists('\get_sites') === true && class_exists('\WP_Site_Query') === true) {
@@ -647,25 +779,33 @@
647 779 return [];
648 780 }
649 781
650 782 /**
651 - * @see apply_filters()
783 + * @param string $tag
784 + * @param mixed $value
785 + * @return mixed
786 + * @see \apply_filters()
652 787 */
653 - public function applyFilters(string $tag, mixed $value): mixed
788 + public function applyFilters(string $tag, $value)
654 789 {
655 790 return call_user_func_array('\apply_filters', func_get_args());
656 791 }
657 792
658 793 /**
659 - * @see get_bloginfo
794 + * @param string $show
795 + * @param string $filter
796 + * @return string
797 + * @see \get_bloginfo()
660 798 */
661 - public function getBlogInfo(string $show = '', string $filter = 'raw'): string
799 + public function getBlogInfo($show = '', $filter = 'raw'): string
662 800 {
663 801 return get_bloginfo($show, $filter);
664 802 }
665 803
666 804 /**
667 - * @see esc_html
805 + * @param string $text
806 + * @return string
807 + * @see \esc_html()
668 808 */
669 809 public function escHtml(string $text): string
670 810 {
671 811 return esc_html($text);
@@ -671,24 +811,29 @@
671 811 return esc_html($text);
672 812 }
673 813
674 814 /**
675 - * @see is_single
815 + * @param int|string|array $post
816 + * @return bool
817 + * @see \is_single()
676 818 */
677 - public function isSingle(array|string|int $post = ''): bool
819 + public function isSingle($post = ''): bool
678 820 {
679 821 return is_single($post);
680 822 }
681 823
682 824 /**
683 - * @see is_page
825 + * @param int|string|array $page
826 + * @return bool
827 + * @see \is_page()
684 828 */
685 - public function isPage(array|string|int $page = ''): bool
829 + public function isPage($page = ''): bool
686 830 {
687 831 return is_page($page);
688 832 }
689 833
690 834 /**
835 + * @return string
691 836 * @see \WP_PLUGIN_DIR
692 837 */
693 838 public function getPluginDir(): string
694 839 {
@@ -695,33 +840,42 @@
695 840 return WP_PLUGIN_DIR;
696 841 }
697 842
698 843 /**
699 - * @see plugins_url
844 + * @param string $path
845 + * @param string $plugin
846 + * @return string
847 + * @see \plugins_url()
700 848 */
701 - public function pluginsUrl(string $path = '', string $plugin = ''): string
849 + public function pluginsUrl($path = '', $plugin = ''): string
702 850 {
703 851 return plugins_url($path, $plugin);
704 852 }
705 853
706 854 /**
707 - * @see plugin_basename
855 + * @param $file
856 + * @return string
857 + * @see \plugin_basename()
708 858 */
709 - public function pluginBasename(string $file): string
859 + public function pluginBasename($file): string
710 860 {
711 861 return plugin_basename($file);
712 862 }
713 863
714 864 /**
715 - * @see wp_attachment_is_image
865 + * @param int|WP_Post $post
866 + * @return bool
867 + * @see \wp_attachment_is_image()
716 868 */
717 - public function attachmentIsImage(int|WP_Post $post): bool
869 + public function attachmentIsImage($post): bool
718 870 {
719 871 return wp_attachment_is_image($post);
720 872 }
721 873
722 874 /**
723 - * @see current_user_can
875 + * @param string $capability
876 + * @return bool
877 + * @see \current_user_can()
724 878 */
725 879 public function currentUserCan(string $capability): bool
726 880 {
727 881 return current_user_can($capability);
@@ -727,9 +881,11 @@
727 881 return current_user_can($capability);
728 882 }
729 883
730 884 /**
731 - * @see get_users
885 + * @param array $arguments
886 + * @return array
887 + * @see \get_users()
732 888 */
733 889 public function getUsers(array $arguments = []): array
734 890 {
735 891 return get_users($arguments);
@@ -743,9 +899,12 @@
743 899 global $wp_filter;
744 900 return $wp_filter;
745 901 }
746 902
747 - public function setFilters(array $filters): void
903 + /**
904 + * @param array $filters
905 + */
906 + public function setFilters(array $filters)
748 907 {
749 908 global $wp_filter;
750 909 $wp_filter = $filters;
751 910 }
@@ -750,15 +909,23 @@
750 909 $wp_filter = $filters;
751 910 }
752 911
753 912 /**
754 - * @see current_time
913 + * @param string $type
914 + * @param int $gmt
915 + * @return int|string
916 + * @see \current_time()
755 917 */
756 - public function currentTime(string $type, int $gmt = 0): int|string
918 + public function currentTime(string $type, $gmt = 0)
757 919 {
758 920 return current_time($type, $gmt);
759 921 }
760 922
923 + /**
924 + * Formats the date like wordpress does it.
925 + * @param string $date
926 + * @return string
927 + */
761 928 public function formatDate(string $date): string
762 929 {
763 930 $dateFormat = __('M j, Y @ H:i');
764 931 return date_i18n($dateFormat, strtotime($date));
@@ -764,33 +931,40 @@
764 931 return date_i18n($dateFormat, strtotime($date));
765 932 }
766 933
767 934 /**
768 - * @see register_widget
935 + * @param mixed $widgetClass
936 + * @see \register_widget()
769 937 */
770 - public function registerWidget(mixed $widgetClass): void
938 + public function registerWidget($widgetClass)
771 939 {
772 940 register_widget($widgetClass);
773 941 }
774 942
775 943 /**
776 - * @see wp_login_url
944 + * @param string $redirect
945 + * @param bool $forceReauth
946 + * @return string
947 + * @see \wp_login_url()
777 948 */
778 - public function wpLoginUrl(string $redirect = '', bool $forceReauth = false): string
949 + public function wpLoginUrl($redirect = '', $forceReauth = false): string
779 950 {
780 951 return wp_login_url($redirect, $forceReauth);
781 952 }
782 953
783 954 /**
784 - * @see wp_logout_url
955 + * @param string $redirect
956 + * @return string
957 + * @see \wp_logout_url()
785 958 */
786 - public function wpLogoutUrl(string $redirect = ''): string
959 + public function wpLogoutUrl($redirect = ''): string
787 960 {
788 961 return wp_logout_url($redirect);
789 962 }
790 963
791 964 /**
792 - * @see wp_registration_url
965 + * @return string
966 + * @see \wp_registration_url()
793 967 */
794 968 public function wpRegistrationUrl(): string
795 969 {
796 970 return wp_registration_url();
@@ -796,33 +970,42 @@
796 970 return wp_registration_url();
797 971 }
798 972
799 973 /**
800 - * @see wp_lostpassword_url
974 + * @param string $redirect
975 + * @return string
976 + * @see \wp_lostpassword_url()
801 977 */
802 - public function wpLostPasswordUrl(string $redirect = ''): string
978 + public function wpLostPasswordUrl($redirect = ''): string
803 979 {
804 980 return wp_lostpassword_url($redirect);
805 981 }
806 982
807 983 /**
808 - * @see add_shortcode
984 + * @param string $tag
985 + * @param callable $function
986 + * @see \add_shortcode()
809 987 */
810 - public function addShortCode(string $tag, callable $function): void
988 + public function addShortCode(string $tag, callable $function)
811 989 {
812 990 add_shortcode($tag, $function);
813 991 }
814 992
815 993 /**
816 - * @see do_shortcode
994 + * @param string $content
995 + * @param bool $ignoreHtml
996 + * @return string
997 + * @see \do_shortcode()
817 998 */
818 - public function doShortCode(string $content, bool $ignoreHtml = false): string
999 + public function doShortCode(string $content, $ignoreHtml = false): string
819 1000 {
820 1001 return do_shortcode($content, $ignoreHtml);
821 1002 }
822 1003
823 1004 /**
824 - * @see attachment_url_to_postid
1005 + * @param string $url
1006 + * @return int
1007 + * @see \attachment_url_to_postid()
825 1008 */
826 1009 public function attachmentUrlToPostId(string $url): int
827 1010 {
828 1011 return attachment_url_to_postid($url);
@@ -828,9 +1011,10 @@
828 1011 return attachment_url_to_postid($url);
829 1012 }
830 1013
831 1014 /**
832 - * @see got_mod_rewrite
1015 + * @return bool
1016 + * @see \got_mod_rewrite()
833 1017 */
834 1018 public function gotModRewrite(): bool
835 1019 {
836 1020 if (function_exists('\got_mod_rewirte') === false) {
@@ -837,28 +1021,6 @@
837 1021 require_once(ABSPATH . 'wp-admin/includes/misc.php');
838 1022 }
839 1023
840 1024 return got_mod_rewrite();
841 - }
842 -
843 - /**
844 - * @see is_user_member_of_blog()
845 - */
846 - public function isUserMemberOfBlog(): bool
847 - {
848 - return is_user_member_of_blog();
849 - }
850 -
851 - /**
852 - * @see get_queried_object_id
853 - */
854 - public function getQueriedObjectId(): int
855 - {
856 - return get_queried_object_id();
857 - }
858 -
859 - public function getCurrentPost(): array|WP_Post|null
860 - {
861 - global $post;
862 - return $post;
863 1025 }
864 1026 }