Wordpress.php 24.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064
<?php
/**
 * Wordpress.php
 *
 * The Wordpress class file.
 *
 * PHP versions 5
 *
 * @author    Alexander Schneider <alexanderschneider85@gmail.com>
 * @copyright 2008-2017 Alexander Schneider
 * @license   http://www.gnu.org/licenses/gpl-2.0.html  GNU General Public License, version 2
 * @version   SVN: $id$
 * @link      http://wordpress.org/extend/plugins/user-access-manager/
 */

declare(strict_types=1);

namespace UserAccessManager\Wrapper;

use WP_Error;
use WP_Hook;
use WP_Post;
use WP_Post_Type;
use WP_Query;
use WP_Roles;
use WP_Taxonomy;
use WP_Term;
use WP_User;
use wpdb;
use function add_action;
use function add_filter;
use function add_menu_page;
use function add_meta_box;
use function add_option;
use function add_shortcode;
use function add_submenu_page;
use function attachment_url_to_postid;
use function current_time;
use function current_user_can;
use function date_i18n;
use function dbDelta;
use function delete_option;
use function do_action;
use function do_shortcode;
use function esc_html;
use function function_exists;
use function get_allowed_mime_types;
use function get_bloginfo;
use function get_home_path;
use function get_option;
use function get_page_by_path;
use function get_page_link;
use function get_pages;
use function get_post;
use function get_post_type_object;
use function get_post_types;
use function get_queried_object_id;
use function get_sites;
use function get_taxonomies;
use function get_taxonomy;
use function get_term;
use function get_userdata;
use function get_users;
use function got_mod_rewrite;
use function has_filter;
use function home_url;
use function is_admin;
use function is_feed;
use function is_multisite;
use function is_page;
use function is_post_type_hierarchical;
use function is_single;
use function is_super_admin;
use function is_taxonomy_hierarchical;
use function is_user_logged_in;
use function plugin_basename;
use function plugins_url;
use function register_widget;
use function remove_action;
use function remove_filter;
use function site_url;
use function switch_to_blog;
use function update_option;
use function wp_attachment_is_image;
use function wp_create_nonce;
use function wp_die;
use function wp_doing_ajax;
use function wp_enqueue_script;
use function wp_enqueue_style;
use function wp_get_current_user;
use function wp_login_url;
use function wp_logout_url;
use function wp_lostpassword_url;
use function wp_nonce_field;
use function wp_parse_id_list;
use function wp_redirect;
use function wp_register_script;
use function wp_register_style;
use function wp_registration_url;
use function wp_upload_dir;
use function wp_verify_nonce;

/**
 * Class Wordpress
 *
 * @package UserAccessManager\Wrapper
 */
class Wordpress
{
    /**
     * Returns the database.
     * @return wpdb
     */
    public function getDatabase(): wpdb
    {
        global $wpdb;
        return $wpdb;
    }

    /**
     * Returns true if web server is nginx.
     * @return bool
     */
    public function isNginx(): bool
    {
        global $is_nginx;
        return $is_nginx;
    }

    /**
     * @param string $postType
     * @return bool
     * @see \is_post_type_hierarchical()
     */
    public function isPostTypeHierarchical(string $postType): bool
    {
        return is_post_type_hierarchical($postType);
    }

    /**
     * @param string $taxonomy
     * @return bool
     * @see \is_taxonomy_hierarchical()
     */
    public function isTaxonomyHierarchical(string $taxonomy): bool
    {
        return is_taxonomy_hierarchical($taxonomy);
    }

    /**
     * @param int|string $id
     * @return false|WP_User
     * @see \get_userdata()
     */
    public function getUserData($id)
    {
        return get_userdata($id);
    }

    /**
     * @param string|array $arguments
     * @param string $output
     * @param string $operator
     * @return array
     * @see \get_post_types()
     */
    public function getPostTypes($arguments = [], $output = 'names', $operator = 'and'): array
    {
        return get_post_types($arguments, $output, $operator);
    }

    /**
     * @param array $arguments
     * @param string $output
     * @param string $operator
     * @return array
     * @see \get_taxonomies()
     */
    public function getTaxonomies(array $arguments = [], $output = 'names', $operator = 'and'): array
    {
        return get_taxonomies($arguments, $output, $operator);
    }

    /**
     * @param string $taxonomy
     * @return false|WP_Taxonomy
     * @see \get_taxonomy()
     */
    public function getTaxonomy(string $taxonomy)
    {
        return get_taxonomy($taxonomy);
    }

    /**
     * @param int|string $id The post id.
     * @param string $output
     * @param string $filter
     * @return WP_Post|array|null
     * @see \get_post()
     */
    public function getPost($id, $output = OBJECT, $filter = 'raw')
    {
        return get_post($id, $output, $filter);
    }

    /**
     * @param int|string $postType
     * @return null|WP_Post_Type
     * @see \get_post_type_object()
     */
    public function getPostTypeObject($postType): ?WP_Post_Type
    {
        return get_post_type_object($postType);
    }

    /**
     * @param int|string $id
     * @param string $taxonomy
     * @param string $output
     * @param string $filter
     * @return array|null|WP_Error|WP_Term
     * @see \get_term()
     */
    public function getTerm($id, string $taxonomy = '', string $output = OBJECT, string $filter = 'raw')
    {
        return get_term($id, $taxonomy, $output, $filter);
    }


    /**
     * @param array|string $queries
     * @param bool $execute
     * @return array
     * @see \dbDelta()
     */
    public function dbDelta($queries = '', $execute = true): array
    {
        if (function_exists('\dbDelta') === false) {
            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
        }

        return dbDelta($queries, $execute);
    }

    /**
     * @param integer $blogId
     * @return int|string
     * @see \switch_to_blog()
     */
    public function switchToBlog($blogId)
    {
        if (function_exists('\switch_to_blog') === true) {
            return switch_to_blog($blogId);
        }

        return true;
    }

    /**
     * @return bool
     * @see \restore_current_blog()
     */
    public function restoreCurrentBlog(): bool
    {
        if (function_exists('\restore_current_blog') === true) {
            return restore_current_blog();
        }

        return true;
    }

    /**
     * @return bool
     * @see \is_multisite()
     */
    public function isMultiSite(): bool
    {
        return is_multisite();
    }

    /**
     * @param string $tag
     * @param mixed $arguments
     * @see \do_action()
     */
    public function doAction(string $tag, $arguments = '')
    {
        do_action($tag, $arguments);
    }

    /**
     * @param string $tag
     * @param callable $functionToAdd
     * @param int $priority
     * @param int $acceptedArguments
     * @return true
     * @see \add_action()
     */
    public function addAction(string $tag, callable $functionToAdd, $priority = 10, $acceptedArguments = 1)
    {
        return add_action($tag, $functionToAdd, $priority, $acceptedArguments);
    }

    /**
     * @param string $hookName
     * @param callable $callback
     * @param $priority
     * @return bool
     * @see \remove_action()
     */
    public function removeAction(string $hookName, callable $callback, $priority = 10)
    {
        return remove_action($hookName, $callback, $priority);
    }

    /**
     * @param string $tag
     * @param bool|callable $functionToCheck
     * @return bool|false|int
     * @see \has_filter()
     */
    public function hasFilter(string $tag, $functionToCheck = false)
    {
        return has_filter($tag, $functionToCheck);
    }

    /**
     * @param string $tag
     * @param callable $functionToAdd
     * @param int $priority
     * @param int $acceptedArguments
     * @return true
     * @see \add_filter()
     */
    public function addFilter(string $tag, callable $functionToAdd, $priority = 10, $acceptedArguments = 1)
    {
        return add_filter($tag, $functionToAdd, $priority, $acceptedArguments);
    }

    /**
     * @param string $tag
     * @param callable $functionToRemove
     * @param int $priority
     * @return bool
     * @see \remove_filter()
     */
    public function removeFilter(string $tag, callable $functionToRemove, $priority = 10): bool
    {
        return remove_filter($tag, $functionToRemove, $priority);
    }

    /**
     * @param string $option
     * @param mixed $value
     * @param string $deprecated
     * @param string|bool $autoload
     * @return bool
     * @see \add_option()
     */
    public function addOption(string $option, $value = '', $deprecated = '', $autoload = 'yes'): bool
    {
        return add_option($option, $value, $deprecated, $autoload);
    }

    /**
     * @param string $option
     * @return bool
     * @see \delete_option()
     */
    public function deleteOption(string $option): bool
    {
        return delete_option($option);
    }

    /**
     * @param string $option
     * @param mixed $value
     * @param string|bool $autoload
     * @return bool
     * @see \update_option()
     */
    public function updateOption(string $option, $value = '', $autoload = 'yes'): bool
    {
        return update_option($option, $value, $autoload);
    }

    /**
     * @param string $option
     * @param mixed $default
     * @return mixed
     * @see \get_option()
     */
    public function getOption(string $option, $default = false)
    {
        return get_option($option, $default);
    }

    /**
     * @param int|bool $userId
     * @return bool
     * @see \is_super_admin()
     */
    public function isSuperAdmin($userId = false): bool
    {
        return is_super_admin($userId);
    }

    /**
     * @return WP_User
     * @see \wp_get_current_user()
     */
    public function getCurrentUser(): WP_User
    {
        if (function_exists('\wp_get_current_user') === false) {
            require_once(ABSPATH . 'wp-includes/pluggable.php');
        }

        return wp_get_current_user();
    }

    /**
     * @param int|WP_User $user
     * @return array
     * @see \get_allowed_mime_types()
     */
    public function getAllowedMimeTypes($user = null): array
    {
        return get_allowed_mime_types($user);
    }

    /**
     * @param string $time
     * @param bool $createDir
     * @param bool $refreshCache
     * @return array
     * @see \wp_upload_dir()
     */
    public function getUploadDir($time = null, $createDir = true, $refreshCache = false): array
    {
        return wp_upload_dir($time, $createDir, $refreshCache);
    }

    /**
     * @param string $path
     * @param null|string $scheme
     * @return string
     * @see \home_url()
     */
    public function getHomeUrl($path = '', $scheme = null): string
    {
        return home_url($path, $scheme);
    }

    /**
     * @param string $path
     * @param null|string $scheme
     * @return string
     * @see \site_url();
     */
    public function getSiteUrl($path = '', $scheme = null): string
    {
        return site_url($path, $scheme);
    }

    /**
     * @return string
     * @see \get_home_path()
     */
    public function getHomePath(): string
    {
        if (function_exists('\get_home_path') === false) {
            require_once(ABSPATH . 'wp-admin/includes/file.php');
        }

        return get_home_path();
    }

    /**
     * @param array|string $list
     * @return array
     * @see \wp_parse_id_list()
     */
    public function parseIdList($list): array
    {
        return wp_parse_id_list($list);
    }

    /**
     * @param string $message
     * @param string $title
     * @param array $arguments
     * @see \wp_die()
     */
    public function wpDie($message = '', $title = '', array $arguments = [])
    {
        wp_die($message, $title, $arguments);
    }

    /**
     * @param string|array $feeds
     * @return bool
     * @see \is_feed()
     */
    public function isFeed($feeds = ''): bool
    {
        return is_feed($feeds);
    }

    /**
     * @return bool
     * @see \is_user_logged_in()
     */
    public function isUserLoggedIn(): bool
    {
        return is_user_logged_in();
    }

    /**
     * @param string $pagePath
     * @param string $output
     * @param string $postType
     * @return array|null|WP_Post
     * @see \get_page_by_path()
     */
    public function getPageByPath(string $pagePath, $output = OBJECT, $postType = 'page')
    {
        return get_page_by_path($pagePath, $output, $postType);
    }

    /**
     * @param string $location
     * @param int $status
     * @return bool
     * @see \wp_redirect()
     */
    public function wpRedirect(string $location, $status = 302): bool
    {
        return wp_redirect($location, $status);
    }

    /**
     * @param bool|int|WP_Post $post
     * @param bool $leaveName
     * @param bool $sample
     * @return string The page permalink.
     */
    public function getPageLink($post = false, $leaveName = false, $sample = false): string
    {
        return get_page_link($post, $leaveName, $sample);
    }

    /**
     * Returns the wp_query object.
     * @return WP_Query
     */
    public function getWpQuery(): WP_Query
    {
        global $wp_query;
        return $wp_query;
    }

    /**
     * @return bool
     * @see \is_admin()
     */
    public function isAdmin(): bool
    {
        //Ajax request are always identified as administrative interface page
        if (wp_doing_ajax() === true || defined('REST_REQUEST') && REST_REQUEST) {
            //So let's check if we are calling the ajax data for the frontend or backend
            //If the referer is an admin url we are requesting the data for the backend
            $adminUrl = get_admin_url();
            return (substr((string) ($_SERVER['HTTP_REFERER'] ?? ''), 0, strlen((string) $adminUrl)) === $adminUrl);
        }

        //No ajax request just use the normal function
        return is_admin();
    }

    /**
     * @param int|string $action
     * @return string
     * @see \wp_create_nonce()
     */
    public function createNonce($action): string
    {
        return wp_create_nonce($action);
    }

    /**
     * @param int|string $action
     * @param string $name
     * @param bool $referrer
     * @param bool $echo
     * @return string
     * @see \wp_nonce_field()
     */
    public function getNonceField($action = -1, $name = '_wpnonce', $referrer = true, $echo = true): string
    {
        return wp_nonce_field($action, $name, $referrer, $echo);
    }

    /**
     * @param string|null $nonce
     * @param string|int $action
     * @return false|int
     * @see \wp_verify_nonce()
     */
    public function verifyNonce(?string $nonce, $action = -1)
    {
        return wp_verify_nonce($nonce, $action);
    }

    /**
     * Returns the wordpress roles.
     * @return WP_Roles
     */
    public function getRoles(): WP_Roles
    {
        global $wp_roles;
        return $wp_roles;
    }

    /**
     * @param string $pageTitle
     * @param string $menuTitle
     * @param string $capability
     * @param string $menuSlug
     * @param mixed $function
     * @param string $iconUrl
     * @param null $position
     * @return string
     * @see \add_menu_page()
     */
    public function addMenuPage(
        string $pageTitle,
        string $menuTitle,
        string $capability,
        string $menuSlug,
        $function = '',
        $iconUrl = '',
        $position = null
    ): string {
        return add_menu_page($pageTitle, $menuTitle, $capability, $menuSlug, $function, $iconUrl, $position);
    }

    /**
     * @param string $parentSlug
     * @param string $pageTitle
     * @param string $menuTitle
     * @param string $capability
     * @param string $menuSlug
     * @param string|callable $function
     * @return false|string
     * @see \add_submenu_page()
     */
    public function addSubMenuPage(
        string $parentSlug,
        string $pageTitle,
        string $menuTitle,
        string $capability,
        string $menuSlug,
        $function = ''
    ) {
        return add_submenu_page($parentSlug, $pageTitle, $menuTitle, $capability, $menuSlug, $function);
    }

    /**
     * @param string $id
     * @param string $title
     * @param callable $callback
     * @param null $screen
     * @param string $context
     * @param string $priority
     * @param null $callbackArguments
     * @see \add_meta_box()
     */
    public function addMetaBox(
        string $id,
        string $title,
        callable $callback,
        $screen = null,
        $context = 'advanced',
        $priority = 'default',
        $callbackArguments = null
    ) {
        add_meta_box($id, $title, $callback, $screen, $context, $priority, $callbackArguments);
    }

    /**
     * @param array|string $arguments
     * @return array|false
     * @see \get_pages()
     */
    public function getPages($arguments)
    {
        return get_pages($arguments);
    }

    /**
     * @param string $handle
     * @param string $source
     * @param array $depends
     * @param string|bool|null $version
     * @param string $media
     * @return bool
     * @see \wp_register_style()
     */
    public function registerStyle(string $handle, string $source, $depends = [], $version = false, $media = 'all'): bool
    {
        return wp_register_style($handle, $source, $depends, $version, $media);
    }

    /**
     * @param string $handle
     * @param string $source
     * @param array $depends
     * @param string|bool|null $version
     * @param bool $inFooter
     * @return bool
     * @see \wp_register_script()
     */
    public function registerScript(
        string $handle,
        string $source,
        $depends = [],
        $version = false,
        $inFooter = false
    ): bool {
        return wp_register_script($handle, $source, $depends, $version, $inFooter);
    }

    /**
     * @param string $handle
     * @param string $source
     * @param array $depends
     * @param string|bool|null $version
     * @param string $media
     * @see \wp_enqueue_style()
     */
    public function enqueueStyle(string $handle, $source = '', $depends = [], $version = false, $media = 'all')
    {
        wp_enqueue_style($handle, $source, $depends, $version, $media);
    }

    /**
     * @param string $handle
     * @param string $source
     * @param array $depends
     * @param string|bool|null $version
     * @param bool $inFooter
     * @see \wp_enqueue_script()
     */
    public function enqueueScript(string $handle, $source = '', $depends = [], $version = false, $inFooter = false)
    {
        wp_enqueue_script($handle, $source, $depends, $version, $inFooter);
    }

    /**
     * Returns the wordpress meta boxes.
     * @return array
     */
    public function getMetaBoxes(): array
    {
        global $wp_meta_boxes;
        return $wp_meta_boxes;
    }

    /**
     * Sets the wordpress meta boxes.
     * @param array $wpMetaBoxes
     */
    public function setMetaBoxes(array $wpMetaBoxes)
    {
        global $wp_meta_boxes;
        $wp_meta_boxes = $wpMetaBoxes;
    }

    /**
     * @param array $arguments
     * @return array
     * @see \get_sites()
     */
    public function getSites(array $arguments = []): array
    {
        if (function_exists('\get_sites') === true && class_exists('\WP_Site_Query') === true) {
            return get_sites($arguments);
        }

        return [];
    }

    /**
     * @param string $tag
     * @param mixed $value
     * @return mixed
     * @see \apply_filters()
     */
    public function applyFilters(string $tag, $value)
    {
        return call_user_func_array('\apply_filters', func_get_args());
    }

    /**
     * @param string $show
     * @param string $filter
     * @return string
     * @see \get_bloginfo()
     */
    public function getBlogInfo($show = '', $filter = 'raw'): string
    {
        return get_bloginfo($show, $filter);
    }

    /**
     * @param string $text
     * @return string
     * @see \esc_html()
     */
    public function escHtml(string $text): string
    {
        return esc_html($text);
    }

    /**
     * @param int|string|array $post
     * @return bool
     * @see \is_single()
     */
    public function isSingle($post = ''): bool
    {
        return is_single($post);
    }

    /**
     * @param int|string|array $page
     * @return bool
     * @see \is_page()
     */
    public function isPage($page = ''): bool
    {
        return is_page($page);
    }

    /**
     * @return string
     * @see \WP_PLUGIN_DIR
     */
    public function getPluginDir(): string
    {
        return WP_PLUGIN_DIR;
    }

    /**
     * @param string $path
     * @param string $plugin
     * @return string
     * @see \plugins_url()
     */
    public function pluginsUrl($path = '', $plugin = ''): string
    {
        return plugins_url($path, $plugin);
    }

    /**
     * @param $file
     * @return string
     * @see \plugin_basename()
     */
    public function pluginBasename($file): string
    {
        return plugin_basename($file);
    }

    /**
     * @param int|WP_Post $post
     * @return bool
     * @see \wp_attachment_is_image()
     */
    public function attachmentIsImage($post): bool
    {
        return wp_attachment_is_image($post);
    }

    /**
     * @param string $capability
     * @return bool
     * @see \current_user_can()
     */
    public function currentUserCan(string $capability): bool
    {
        return current_user_can($capability);
    }

    /**
     * @param array $arguments
     * @return array
     * @see \get_users()
     */
    public function getUsers(array $arguments = []): array
    {
        return get_users($arguments);
    }

    /**
     * @return WP_Hook[]
     */
    public function getFilters(): array
    {
        global $wp_filter;
        return $wp_filter;
    }

    /**
     * @param array $filters
     */
    public function setFilters(array $filters)
    {
        global $wp_filter;
        $wp_filter = $filters;
    }

    /**
     * @param string $type
     * @param int $gmt
     * @return int|string
     * @see \current_time()
     */
    public function currentTime(string $type, $gmt = 0)
    {
        return current_time($type, $gmt);
    }

    /**
     * Formats the date like wordpress does it.
     * @param string $date
     * @return string
     */
    public function formatDate(string $date): string
    {
        $dateFormat = __('M j, Y @ H:i');
        return date_i18n($dateFormat, strtotime($date));
    }

    /**
     * @param mixed $widgetClass
     * @see \register_widget()
     */
    public function registerWidget($widgetClass)
    {
        register_widget($widgetClass);
    }

    /**
     * @param string $redirect
     * @param bool $forceReauth
     * @return string
     * @see \wp_login_url()
     */
    public function wpLoginUrl($redirect = '', $forceReauth = false): string
    {
        return wp_login_url($redirect, $forceReauth);
    }

    /**
     * @param string $redirect
     * @return string
     * @see \wp_logout_url()
     */
    public function wpLogoutUrl($redirect = ''): string
    {
        return wp_logout_url($redirect);
    }

    /**
     * @return string
     * @see \wp_registration_url()
     */
    public function wpRegistrationUrl(): string
    {
        return wp_registration_url();
    }

    /**
     * @param string $redirect
     * @return string
     * @see \wp_lostpassword_url()
     */
    public function wpLostPasswordUrl($redirect = ''): string
    {
        return wp_lostpassword_url($redirect);
    }

    /**
     * @param string $tag
     * @param callable $function
     * @see \add_shortcode()
     */
    public function addShortCode(string $tag, callable $function)
    {
        add_shortcode($tag, $function);
    }

    /**
     * @param string $content
     * @param bool $ignoreHtml
     * @return string
     * @see \do_shortcode()
     */
    public function doShortCode(string $content, $ignoreHtml = false): string
    {
        return do_shortcode($content, $ignoreHtml);
    }

    /**
     * @param string $url
     * @return int
     * @see \attachment_url_to_postid()
     */
    public function attachmentUrlToPostId(string $url): int
    {
        return attachment_url_to_postid($url);
    }

    /**
     * @return bool
     * @see \got_mod_rewrite()
     */
    public function gotModRewrite(): bool
    {
        if (function_exists('\got_mod_rewirte') === false) {
            require_once(ABSPATH . 'wp-admin/includes/misc.php');
        }

        return got_mod_rewrite();
    }

    /**
     * @return bool
     * @see \is_user_member_of_blog()
     */
    public function isUserMemberOfBlog(): bool
    {
        return (bool) is_user_member_of_blog();
    }

    /**
     * @return int
     * @see \get_queried_object_id()
     */
    public function getQueriedObjectId(): int
    {
        return (int) get_queried_object_id();
    }

    /**
     * @return WP_Post|array|null
     */
    public function getCurrentPost()
    {
        global $post;
        return $post;
    }
}