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