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