PluginProbe
User Access Manager / 2.2.11
User Access Manager v2.2.11
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 +402 -243 2.3.132.2.11 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 <alexanderschneider85@gmail.com>
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,79 +145,94 @@
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 int|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($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) {
211 237 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
212 238 }
@@ -214,11 +240,13 @@
214 240 return dbDelta($queries, $execute);
215 241 }
216 242
217 243 /**
218 - * @see switch_to_blog
244 + * @param integer $blogId
245 + * @return int|string
246 + * @see \switch_to_blog()
219 247 */
220 - public function switchToBlog(int|string|null $blogId): bool
248 + public function switchToBlog($blogId)
221 249 {
222 250 if (function_exists('\switch_to_blog') === true) {
223 251 return switch_to_blog($blogId);
224 252 }
@@ -226,8 +254,9 @@
226 254 return true;
227 255 }
228 256
229 257 /**
258 + * @return bool
230 259 * @see \restore_current_blog()
231 260 */
232 261 public function restoreCurrentBlog(): bool
233 262 {
@@ -238,9 +267,10 @@
238 267 return true;
239 268 }
240 269
241 270 /**
242 - * @see is_multisite
271 + * @return bool
272 + * @see \is_multisite()
243 273 */
244 274 public function isMultiSite(): bool
245 275 {
246 276 return is_multisite();
@@ -246,77 +276,83 @@
246 276 return is_multisite();
247 277 }
248 278
249 279 /**
250 - * @see do_action
280 + * @param string $tag
281 + * @param mixed $arguments
282 + * @see \do_action()
251 283 */
252 - public function doAction(string $tag, mixed $arguments = ''): void
284 + public function doAction(string $tag, $arguments = '')
253 285 {
254 286 do_action($tag, $arguments);
255 287 }
256 288
257 289 /**
258 - * @see add_action
290 + * @param string $tag
291 + * @param callable $functionToAdd
292 + * @param int $priority
293 + * @param int $acceptedArguments
294 + * @return true
295 + * @see \add_action()
259 296 */
260 - public function addAction(
261 - string $tag,
262 - callable $functionToAdd,
263 - int $priority = 10,
264 - int $acceptedArguments = 1
265 - ): bool {
297 + public function addAction(string $tag, callable $functionToAdd, $priority = 10, $acceptedArguments = 1)
298 + {
266 299 return add_action($tag, $functionToAdd, $priority, $acceptedArguments);
267 300 }
268 301
269 302 /**
270 - * @see remove_action
303 + * @param string $tag
304 + * @param bool|callable $functionToCheck
305 + * @return bool|false|int
306 + * @see \has_filter()
271 307 */
272 - public function removeAction(string $hookName, callable $callback, int $priority = 10): bool
308 + public function hasFilter(string $tag, $functionToCheck = false)
273 309 {
274 - return remove_action($hookName, $callback, $priority);
310 + return has_filter($tag, $functionToCheck);
275 311 }
276 312
277 313 /**
278 - * @see has_filter
314 + * @param string $tag
315 + * @param callable $functionToAdd
316 + * @param int $priority
317 + * @param int $acceptedArguments
318 + * @return true
319 + * @see \add_filter()
279 320 */
280 - public function hasFilter(string $tag, callable|bool $functionToCheck = false): bool|int
321 + public function addFilter(string $tag, callable $functionToAdd, $priority = 10, $acceptedArguments = 1)
281 322 {
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 323 return add_filter($tag, $functionToAdd, $priority, $acceptedArguments);
295 324 }
296 325
297 326 /**
298 - * @see remove_filter
327 + * @param string $tag
328 + * @param callable $functionToRemove
329 + * @param int $priority
330 + * @return bool
331 + * @see \remove_filter()
299 332 */
300 - public function removeFilter(string $tag, callable $functionToRemove, int $priority = 10): bool
333 + public function removeFilter(string $tag, callable $functionToRemove, $priority = 10): bool
301 334 {
302 335 return remove_filter($tag, $functionToRemove, $priority);
303 336 }
304 337
305 338 /**
306 - * @see add_option
339 + * @param string $option
340 + * @param mixed $value
341 + * @param string $deprecated
342 + * @param string|bool $autoload
343 + * @return bool
344 + * @see \add_option()
307 345 */
308 - public function addOption(
309 - string $option,
310 - mixed $value = '',
311 - string $deprecated = '',
312 - bool|string $autoload = 'yes'
313 - ): bool {
346 + public function addOption(string $option, $value = '', $deprecated = '', $autoload = 'yes'): bool
347 + {
314 348 return add_option($option, $value, $deprecated, $autoload);
315 349 }
316 350
317 351 /**
318 - * @see delete_option
352 + * @param string $option
353 + * @return bool
354 + * @see \delete_option()
319 355 */
320 356 public function deleteOption(string $option): bool
321 357 {
322 358 return delete_option($option);
@@ -322,33 +358,43 @@
322 358 return delete_option($option);
323 359 }
324 360
325 361 /**
326 - * @see update_option
362 + * @param string $option
363 + * @param mixed $value
364 + * @param string|bool $autoload
365 + * @return bool
366 + * @see \update_option()
327 367 */
328 - public function updateOption(string $option, mixed $value = '', bool|string $autoload = 'yes'): bool
368 + public function updateOption(string $option, $value = '', $autoload = 'yes'): bool
329 369 {
330 370 return update_option($option, $value, $autoload);
331 371 }
332 372
333 373 /**
334 - * @see get_option
374 + * @param string $option
375 + * @param mixed $default
376 + * @return mixed
377 + * @see \get_option()
335 378 */
336 - public function getOption(string $option, mixed $default = false)
379 + public function getOption(string $option, $default = false)
337 380 {
338 381 return get_option($option, $default);
339 382 }
340 383
341 384 /**
342 - * @see is_super_admin
385 + * @param int|bool $userId
386 + * @return bool
387 + * @see \is_super_admin()
343 388 */
344 - public function isSuperAdmin(bool|int|string|null $userId = false): bool
389 + public function isSuperAdmin($userId = false): bool
345 390 {
346 391 return is_super_admin($userId);
347 392 }
348 393
349 394 /**
350 - * @see wp_get_current_user
395 + * @return WP_User
396 + * @see \wp_get_current_user()
351 397 */
352 398 public function getCurrentUser(): WP_User
353 399 {
354 400 if (function_exists('\wp_get_current_user') === false) {
@@ -358,41 +404,54 @@
358 404 return wp_get_current_user();
359 405 }
360 406
361 407 /**
362 - * @see get_allowed_mime_types
408 + * @param int|WP_User $user
409 + * @return array
410 + * @see \get_allowed_mime_types()
363 411 */
364 - public function getAllowedMimeTypes(WP_User|int|string|null $user = null): array
412 + public function getAllowedMimeTypes($user = null): array
365 413 {
366 414 return get_allowed_mime_types($user);
367 415 }
368 416
369 417 /**
370 - * @see wp_upload_dir
418 + * @param string $time
419 + * @param bool $createDir
420 + * @param bool $refreshCache
421 + * @return array
422 + * @see \wp_upload_dir()
371 423 */
372 - public function getUploadDir(?string $time = null, bool $createDir = true, bool $refreshCache = false): array
424 + public function getUploadDir($time = null, $createDir = true, $refreshCache = false): array
373 425 {
374 426 return wp_upload_dir($time, $createDir, $refreshCache);
375 427 }
376 428
377 429 /**
378 - * @see home_url
430 + * @param string $path
431 + * @param null|string $scheme
432 + * @return string
433 + * @see \home_url()
379 434 */
380 - public function getHomeUrl(string $path = '', ?string $scheme = null): string
435 + public function getHomeUrl($path = '', $scheme = null): string
381 436 {
382 437 return home_url($path, $scheme);
383 438 }
384 439
385 440 /**
386 - * @see site_url
441 + * @param string $path
442 + * @param null|string $scheme
443 + * @return string
444 + * @see \site_url();
387 445 */
388 - public function getSiteUrl(string $path = '', ?string $scheme = null): string
446 + public function getSiteUrl($path = '', $scheme = null): string
389 447 {
390 448 return site_url($path, $scheme);
391 449 }
392 450
393 451 /**
394 - * @see get_home_path
452 + * @return string
453 + * @see \get_home_path()
395 454 */
396 455 public function getHomePath(): string
397 456 {
398 457 if (function_exists('\get_home_path') === false) {
@@ -402,34 +461,41 @@
402 461 return get_home_path();
403 462 }
404 463
405 464 /**
406 - * @see wp_parse_id_list
465 + * @param array|string $list
466 + * @return array
467 + * @see \wp_parse_id_list()
407 468 */
408 - public function parseIdList(array|string|int $list): array
469 + public function parseIdList($list): array
409 470 {
410 471 return wp_parse_id_list($list);
411 472 }
412 473
413 474 /**
414 - * @see wp_die
475 + * @param string $message
476 + * @param string $title
477 + * @param array $arguments
478 + * @see \wp_die()
415 479 */
416 - #[NoReturn]
417 - public function wpDie(string $message = '', string $title = '', array $arguments = []): void
480 + public function wpDie($message = '', $title = '', array $arguments = [])
418 481 {
419 482 wp_die($message, $title, $arguments);
420 483 }
421 484
422 485 /**
423 - * @see is_feed
486 + * @param string|array $feeds
487 + * @return bool
488 + * @see \is_feed()
424 489 */
425 - public function isFeed(array|string|int $feeds = ''): bool
490 + public function isFeed($feeds = ''): bool
426 491 {
427 492 return is_feed($feeds);
428 493 }
429 494
430 495 /**
431 - * @see is_user_logged_in
496 + * @return bool
497 + * @see \is_user_logged_in()
432 498 */
433 499 public function isUserLoggedIn(): bool
434 500 {
435 501 return is_user_logged_in();
@@ -435,34 +501,45 @@
435 501 return is_user_logged_in();
436 502 }
437 503
438 504 /**
439 - * @see get_page_by_path
505 + * @param string $pagePath
506 + * @param string $output
507 + * @param string $postType
508 + * @return array|null|WP_Post
509 + * @see \get_page_by_path()
440 510 */
441 - public function getPageByPath(
442 - string $pagePath,
443 - string $output = OBJECT,
444 - string $postType = 'page'
445 - ): array|WP_Post|null {
511 + public function getPageByPath(string $pagePath, $output = OBJECT, $postType = 'page')
512 + {
446 513 return get_page_by_path($pagePath, $output, $postType);
447 514 }
448 515
449 516 /**
450 - * @see wp_redirect
517 + * @param string $location
518 + * @param int $status
519 + * @return bool
520 + * @see \wp_redirect()
451 521 */
452 - public function wpRedirect(string $location, int $status = 302): bool
522 + public function wpRedirect(string $location, $status = 302): bool
453 523 {
454 524 return wp_redirect($location, $status);
455 525 }
456 526
457 - public function getPageLink(
458 - bool|int|string|WP_Post $post = false,
459 - bool $leaveName = false,
460 - bool $sample = false
461 - ): string {
527 + /**
528 + * @param bool|int|WP_Post $post
529 + * @param bool $leaveName
530 + * @param bool $sample
531 + * @return string The page permalink.
532 + */
533 + public function getPageLink($post = false, $leaveName = false, $sample = false): string
534 + {
462 535 return get_page_link($post, $leaveName, $sample);
463 536 }
464 537
538 + /**
539 + * Returns the wp_query object.
540 + * @return WP_Query
541 + */
465 542 public function getWpQuery(): WP_Query
466 543 {
467 544 global $wp_query;
468 545 return $wp_query;
@@ -468,52 +545,63 @@
468 545 return $wp_query;
469 546 }
470 547
471 548 /**
472 - * @see is_admin
549 + * @return bool
550 + * @see \is_admin()
473 551 */
474 552 public function isAdmin(): bool
475 553 {
476 - //Ajax request are always identified as an administrative interface page
477 - if (wp_doing_ajax() === true || defined('REST_REQUEST') && REST_REQUEST) {
554 + //Ajax request are always identified as administrative interface page
555 + if (wp_doing_ajax() === true) {
478 556 //So let's check if we are calling the ajax data for the frontend or backend
479 557 //If the referer is an admin url we are requesting the data for the backend
480 558 $adminUrl = get_admin_url();
481 - return str_starts_with((string)($_SERVER['HTTP_REFERER'] ?? ''), $adminUrl);
559 + return (substr((string) $_SERVER['HTTP_REFERER'], 0, strlen((string) $adminUrl)) === $adminUrl);
482 560 }
483 561
484 - //No ajax request just uses the normal function
562 + //No ajax request just use the normal function
485 563 return is_admin();
486 564 }
487 565
488 566 /**
489 - * @see wp_create_nonce
567 + * @param int|string $action
568 + * @return string
569 + * @see \wp_create_nonce()
490 570 */
491 - public function createNonce(int|string $action): string
571 + public function createNonce($action): string
492 572 {
493 573 return wp_create_nonce($action);
494 574 }
495 575
496 576 /**
497 - * @see wp_nonce_field
577 + * @param int|string $action
578 + * @param string $name
579 + * @param bool $referrer
580 + * @param bool $echo
581 + * @return string
582 + * @see \wp_nonce_field()
498 583 */
499 - public function getNonceField(
500 - int|string $action = -1,
501 - string $name = '_wpnonce',
502 - bool $referrer = true,
503 - bool $echo = true
504 - ): string {
584 + public function getNonceField($action = -1, $name = '_wpnonce', $referrer = true, $echo = true): string
585 + {
505 586 return wp_nonce_field($action, $name, $referrer, $echo);
506 587 }
507 588
508 589 /**
509 - * @see wp_verify_nonce
590 + * @param string|null $nonce
591 + * @param string|int $action
592 + * @return false|int
593 + * @see \wp_verify_nonce()
510 594 */
511 - public function verifyNonce(?string $nonce, int|string $action = -1): bool|int
595 + public function verifyNonce(?string $nonce, $action = -1)
512 596 {
513 597 return wp_verify_nonce($nonce, $action);
514 598 }
515 599
600 + /**
601 + * Returns the wordpress roles.
602 + * @return WP_Roles
603 + */
516 604 public function getRoles(): WP_Roles
517 605 {
518 606 global $wp_roles;
519 607 return $wp_roles;
@@ -519,9 +607,17 @@
519 607 return $wp_roles;
520 608 }
521 609
522 610 /**
523 - * @see add_menu_page
611 + * @param string $pageTitle
612 + * @param string $menuTitle
613 + * @param string $capability
614 + * @param string $menuSlug
615 + * @param mixed $function
616 + * @param string $iconUrl
617 + * @param null $position
618 + * @return string
619 + * @see \add_menu_page()
524 620 */
525 621 public function addMenuPage(
526 622 string $pageTitle,
527 623 string $menuTitle,
@@ -526,17 +622,24 @@
526 622 string $pageTitle,
527 623 string $menuTitle,
528 624 string $capability,
529 625 string $menuSlug,
530 - mixed $function = '',
531 - string $iconUrl = '',
532 - int|float|null $position = null
626 + $function = '',
627 + $iconUrl = '',
628 + $position = null
533 629 ): string {
534 630 return add_menu_page($pageTitle, $menuTitle, $capability, $menuSlug, $function, $iconUrl, $position);
535 631 }
536 632
537 633 /**
538 - * @see add_submenu_page
634 + * @param string $parentSlug
635 + * @param string $pageTitle
636 + * @param string $menuTitle
637 + * @param string $capability
638 + * @param string $menuSlug
639 + * @param string|callable $function
640 + * @return false|string
641 + * @see \add_submenu_page()
539 642 */
540 643 public function addSubMenuPage(
541 644 string $parentSlug,
542 645 string $pageTitle,
@@ -542,15 +645,22 @@
542 645 string $pageTitle,
543 646 string $menuTitle,
544 647 string $capability,
545 648 string $menuSlug,
546 - callable|string $function = ''
547 - ): bool|string {
649 + $function = ''
650 + ) {
548 651 return add_submenu_page($parentSlug, $pageTitle, $menuTitle, $capability, $menuSlug, $function);
549 652 }
550 653
551 654 /**
552 - * @see add_meta_box
655 + * @param string $id
656 + * @param string $title
657 + * @param callable $callback
658 + * @param null $screen
659 + * @param string $context
660 + * @param string $priority
661 + * @param null $callbackArguments
662 + * @see \add_meta_box()
553 663 */
554 664 public function addMetaBox(
555 665 string $id,
556 666 string $title,
@@ -555,75 +665,88 @@
555 665 string $id,
556 666 string $title,
557 667 callable $callback,
558 668 $screen = null,
559 - string $context = 'advanced',
560 - string $priority = 'default',
669 + $context = 'advanced',
670 + $priority = 'default',
561 671 $callbackArguments = null
562 - ): void {
672 + ) {
563 673 add_meta_box($id, $title, $callback, $screen, $context, $priority, $callbackArguments);
564 674 }
565 675
566 676 /**
567 - * @see get_pages
677 + * @param array|string $arguments
678 + * @return array|false
679 + * @see \get_pages()
568 680 */
569 - public function getPages(array|string|int $arguments): bool|array
681 + public function getPages($arguments)
570 682 {
571 683 return get_pages($arguments);
572 684 }
573 685
574 686 /**
575 - * @see wp_register_style
687 + * @param string $handle
688 + * @param string $source
689 + * @param array $depends
690 + * @param string|bool|null $version
691 + * @param string $media
692 + * @return bool
693 + * @see \wp_register_style()
576 694 */
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 {
695 + public function registerStyle(string $handle, string $source, $depends = [], $version = false, $media = 'all'): bool
696 + {
584 697 return wp_register_style($handle, $source, $depends, $version, $media);
585 698 }
586 699
587 700 /**
588 - * @see wp_register_script
701 + * @param string $handle
702 + * @param string $source
703 + * @param array $depends
704 + * @param string|bool|null $version
705 + * @param bool $inFooter
706 + * @return bool
707 + * @see \wp_register_script()
589 708 */
590 709 public function registerScript(
591 710 string $handle,
592 711 string $source,
593 - array $depends = [],
594 - bool|string|null $version = false,
595 - bool $inFooter = false
712 + $depends = [],
713 + $version = false,
714 + $inFooter = false
596 715 ): bool {
597 716 return wp_register_script($handle, $source, $depends, $version, $inFooter);
598 717 }
599 718
600 719 /**
601 - * @see wp_enqueue_style
720 + * @param string $handle
721 + * @param string $source
722 + * @param array $depends
723 + * @param string|bool|null $version
724 + * @param string $media
725 + * @see \wp_enqueue_style()
602 726 */
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 {
727 + public function enqueueStyle(string $handle, $source = '', $depends = [], $version = false, $media = 'all')
728 + {
610 729 wp_enqueue_style($handle, $source, $depends, $version, $media);
611 730 }
612 731
613 732 /**
614 - * @see wp_enqueue_script
733 + * @param string $handle
734 + * @param string $source
735 + * @param array $depends
736 + * @param string|bool|null $version
737 + * @param bool $inFooter
738 + * @see \wp_enqueue_script()
615 739 */
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 {
740 + public function enqueueScript(string $handle, $source = '', $depends = [], $version = false, $inFooter = false)
741 + {
623 742 wp_enqueue_script($handle, $source, $depends, $version, $inFooter);
624 743 }
625 744
745 + /**
746 + * Returns the wordpress meta boxes.
747 + * @return array
748 + */
626 749 public function getMetaBoxes(): array
627 750 {
628 751 global $wp_meta_boxes;
629 752 return $wp_meta_boxes;
@@ -628,9 +751,13 @@
628 751 global $wp_meta_boxes;
629 752 return $wp_meta_boxes;
630 753 }
631 754
632 - public function setMetaBoxes(array $wpMetaBoxes): void
755 + /**
756 + * Sets the wordpress meta boxes.
757 + * @param array $wpMetaBoxes
758 + */
759 + public function setMetaBoxes(array $wpMetaBoxes)
633 760 {
634 761 global $wp_meta_boxes;
635 762 $wp_meta_boxes = $wpMetaBoxes;
636 763 }
@@ -635,9 +762,11 @@
635 762 $wp_meta_boxes = $wpMetaBoxes;
636 763 }
637 764
638 765 /**
639 - * @see get_sites
766 + * @param array $arguments
767 + * @return array
768 + * @see \get_sites()
640 769 */
641 770 public function getSites(array $arguments = []): array
642 771 {
643 772 if (function_exists('\get_sites') === true && class_exists('\WP_Site_Query') === true) {
@@ -647,25 +776,33 @@
647 776 return [];
648 777 }
649 778
650 779 /**
651 - * @see apply_filters()
780 + * @param string $tag
781 + * @param mixed $value
782 + * @return mixed
783 + * @see \apply_filters()
652 784 */
653 - public function applyFilters(string $tag, mixed $value): mixed
785 + public function applyFilters(string $tag, $value)
654 786 {
655 787 return call_user_func_array('\apply_filters', func_get_args());
656 788 }
657 789
658 790 /**
659 - * @see get_bloginfo
791 + * @param string $show
792 + * @param string $filter
793 + * @return string
794 + * @see \get_bloginfo()
660 795 */
661 - public function getBlogInfo(string $show = '', string $filter = 'raw'): string
796 + public function getBlogInfo($show = '', $filter = 'raw'): string
662 797 {
663 798 return get_bloginfo($show, $filter);
664 799 }
665 800
666 801 /**
667 - * @see esc_html
802 + * @param string $text
803 + * @return string
804 + * @see \esc_html()
668 805 */
669 806 public function escHtml(string $text): string
670 807 {
671 808 return esc_html($text);
@@ -671,24 +808,29 @@
671 808 return esc_html($text);
672 809 }
673 810
674 811 /**
675 - * @see is_single
812 + * @param int|string|array $post
813 + * @return bool
814 + * @see \is_single()
676 815 */
677 - public function isSingle(array|string|int $post = ''): bool
816 + public function isSingle($post = ''): bool
678 817 {
679 818 return is_single($post);
680 819 }
681 820
682 821 /**
683 - * @see is_page
822 + * @param int|string|array $page
823 + * @return bool
824 + * @see \is_page()
684 825 */
685 - public function isPage(array|string|int $page = ''): bool
826 + public function isPage($page = ''): bool
686 827 {
687 828 return is_page($page);
688 829 }
689 830
690 831 /**
832 + * @return string
691 833 * @see \WP_PLUGIN_DIR
692 834 */
693 835 public function getPluginDir(): string
694 836 {
@@ -695,33 +837,42 @@
695 837 return WP_PLUGIN_DIR;
696 838 }
697 839
698 840 /**
699 - * @see plugins_url
841 + * @param string $path
842 + * @param string $plugin
843 + * @return string
844 + * @see \plugins_url()
700 845 */
701 - public function pluginsUrl(string $path = '', string $plugin = ''): string
846 + public function pluginsUrl($path = '', $plugin = ''): string
702 847 {
703 848 return plugins_url($path, $plugin);
704 849 }
705 850
706 851 /**
707 - * @see plugin_basename
852 + * @param $file
853 + * @return string
854 + * @see \plugin_basename()
708 855 */
709 - public function pluginBasename(string $file): string
856 + public function pluginBasename($file): string
710 857 {
711 858 return plugin_basename($file);
712 859 }
713 860
714 861 /**
715 - * @see wp_attachment_is_image
862 + * @param int|WP_Post $post
863 + * @return bool
864 + * @see \wp_attachment_is_image()
716 865 */
717 - public function attachmentIsImage(int|WP_Post $post): bool
866 + public function attachmentIsImage($post): bool
718 867 {
719 868 return wp_attachment_is_image($post);
720 869 }
721 870
722 871 /**
723 - * @see current_user_can
872 + * @param string $capability
873 + * @return bool
874 + * @see \current_user_can()
724 875 */
725 876 public function currentUserCan(string $capability): bool
726 877 {
727 878 return current_user_can($capability);
@@ -727,9 +878,11 @@
727 878 return current_user_can($capability);
728 879 }
729 880
730 881 /**
731 - * @see get_users
882 + * @param array $arguments
883 + * @return array
884 + * @see \get_users()
732 885 */
733 886 public function getUsers(array $arguments = []): array
734 887 {
735 888 return get_users($arguments);
@@ -743,9 +896,12 @@
743 896 global $wp_filter;
744 897 return $wp_filter;
745 898 }
746 899
747 - public function setFilters(array $filters): void
900 + /**
901 + * @param array $filters
902 + */
903 + public function setFilters(array $filters)
748 904 {
749 905 global $wp_filter;
750 906 $wp_filter = $filters;
751 907 }
@@ -750,15 +906,23 @@
750 906 $wp_filter = $filters;
751 907 }
752 908
753 909 /**
754 - * @see current_time
910 + * @param string $type
911 + * @param int $gmt
912 + * @return int|string
913 + * @see \current_time()
755 914 */
756 - public function currentTime(string $type, int $gmt = 0): int|string
915 + public function currentTime(string $type, $gmt = 0)
757 916 {
758 917 return current_time($type, $gmt);
759 918 }
760 919
920 + /**
921 + * Formats the date like wordpress does it.
922 + * @param string $date
923 + * @return string
924 + */
761 925 public function formatDate(string $date): string
762 926 {
763 927 $dateFormat = __('M j, Y @ H:i');
764 928 return date_i18n($dateFormat, strtotime($date));
@@ -764,33 +928,40 @@
764 928 return date_i18n($dateFormat, strtotime($date));
765 929 }
766 930
767 931 /**
768 - * @see register_widget
932 + * @param mixed $widgetClass
933 + * @see \register_widget()
769 934 */
770 - public function registerWidget(mixed $widgetClass): void
935 + public function registerWidget($widgetClass)
771 936 {
772 937 register_widget($widgetClass);
773 938 }
774 939
775 940 /**
776 - * @see wp_login_url
941 + * @param string $redirect
942 + * @param bool $forceReauth
943 + * @return string
944 + * @see \wp_login_url()
777 945 */
778 - public function wpLoginUrl(string $redirect = '', bool $forceReauth = false): string
946 + public function wpLoginUrl($redirect = '', $forceReauth = false): string
779 947 {
780 948 return wp_login_url($redirect, $forceReauth);
781 949 }
782 950
783 951 /**
784 - * @see wp_logout_url
952 + * @param string $redirect
953 + * @return string
954 + * @see \wp_logout_url()
785 955 */
786 - public function wpLogoutUrl(string $redirect = ''): string
956 + public function wpLogoutUrl($redirect = ''): string
787 957 {
788 958 return wp_logout_url($redirect);
789 959 }
790 960
791 961 /**
792 - * @see wp_registration_url
962 + * @return string
963 + * @see \wp_registration_url()
793 964 */
794 965 public function wpRegistrationUrl(): string
795 966 {
796 967 return wp_registration_url();
@@ -796,33 +967,42 @@
796 967 return wp_registration_url();
797 968 }
798 969
799 970 /**
800 - * @see wp_lostpassword_url
971 + * @param string $redirect
972 + * @return string
973 + * @see \wp_lostpassword_url()
801 974 */
802 - public function wpLostPasswordUrl(string $redirect = ''): string
975 + public function wpLostPasswordUrl($redirect = ''): string
803 976 {
804 977 return wp_lostpassword_url($redirect);
805 978 }
806 979
807 980 /**
808 - * @see add_shortcode
981 + * @param string $tag
982 + * @param callable $function
983 + * @see \add_shortcode()
809 984 */
810 - public function addShortCode(string $tag, callable $function): void
985 + public function addShortCode(string $tag, callable $function)
811 986 {
812 987 add_shortcode($tag, $function);
813 988 }
814 989
815 990 /**
816 - * @see do_shortcode
991 + * @param string $content
992 + * @param bool $ignoreHtml
993 + * @return string
994 + * @see \do_shortcode()
817 995 */
818 - public function doShortCode(string $content, bool $ignoreHtml = false): string
996 + public function doShortCode(string $content, $ignoreHtml = false): string
819 997 {
820 998 return do_shortcode($content, $ignoreHtml);
821 999 }
822 1000
823 1001 /**
824 - * @see attachment_url_to_postid
1002 + * @param string $url
1003 + * @return int
1004 + * @see \attachment_url_to_postid()
825 1005 */
826 1006 public function attachmentUrlToPostId(string $url): int
827 1007 {
828 1008 return attachment_url_to_postid($url);
@@ -828,9 +1008,10 @@
828 1008 return attachment_url_to_postid($url);
829 1009 }
830 1010
831 1011 /**
832 - * @see got_mod_rewrite
1012 + * @return bool
1013 + * @see \got_mod_rewrite()
833 1014 */
834 1015 public function gotModRewrite(): bool
835 1016 {
836 1017 if (function_exists('\got_mod_rewirte') === false) {
@@ -837,28 +1018,6 @@
837 1018 require_once(ABSPATH . 'wp-admin/includes/misc.php');
838 1019 }
839 1020
840 1021 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 1022 }
864 1023 }