| 87 | * Unslashed GET superglobal |
| 88 | * |
| 89 | * @since 4.4.0 |
| 90 | * @var array |
| 91 | */ |
| 92 | private static $_GET = array(); |
| 93 | |
| 94 | /** |
| 95 | * Unslashed POST superglobal |
| 96 | * |
| 97 | * @since 4.4.0 |
| 98 | * @var array |
| 99 | */ |
| 100 | private static $_POST = array(); |
| 101 | |
| 102 | /** |
| 103 | * Unslashed REQUEST superglobal |
| 104 | * |
| 105 | * @since 4.4.0 |
| 106 | * @var array |
| 107 | */ |
| 108 | private static $_REQUEST = array(); |
| 109 | |
| 110 | /** |
| 111 | * Unslashed COOKIE superglobal |
| 112 | * |
| 113 | * @since 4.4.0 |
| 114 | * @var array |
| 115 | */ |
| 116 | private static $_COOKIE = array(); |
| 117 | |
| 118 | /** |
| 119 | * Unslashed SERVER superglobal |
| 120 | * |
| 121 | * @since 4.4.0 |
| 122 | * @var array |
| 123 | */ |
| 124 | private static $_SERVER = array(); |
| 125 | |
| 126 | /** |
| 723 | |
| 724 | /** |
| 725 | * Initialize self::GET(), self::POST() and self::REQUEST(). |
| 726 | * |
| 727 | * @note Can only be called once. |
| 728 | * |
| 729 | * @since 4.4.0 |
| 730 | */ |
| 731 | public static function _initialize_superglobals() { |
| 732 | |
| 733 | static $initialized = false; |
| 734 | |
| 735 | if ( ! $initialized ) { |
| 736 | |
| 737 | /** |
| 738 | * Store the unslashed superglobals |
| 739 | */ |
| 740 | self::$_GET = $_GET; |
| 741 | self::$_POST = $_POST; |
| 742 | self::$_REQUEST = array_merge( $_GET, $_POST ); |
| 743 | self::$_COOKIE = $_COOKIE; |
| 744 | self::$_SERVER = $_SERVER; |
| 745 | |
| 746 | /** |
| 747 | * Disallow this method to be called again |
| 748 | */ |
| 749 | $initialized = true; |
| 750 | |
| 751 | } |
| 752 | |
| 753 | } |
| 754 | |
| 755 | /** |
| 756 | * Retrieve an unslashed GET variable |
| 757 | * |
| 758 | * @since 4.4.0 |
| 759 | * |
| 760 | * @param string $key GET variable string |
| 761 | * @param mixed $default Default value to return |
| 762 | * |
| 763 | * @return string|array GET variable if one is set, default otherwise |
| 764 | */ |
| 765 | public static function GET( $key, $default = null) { |
| 766 | |
| 767 | return isset( self::$_GET[ $key ] ) ? self::$_GET[ $key ] : $default; |
| 768 | |
| 769 | } |
| 770 | |
| 771 | /** |
| 772 | * Retrieve an unslashed POST variable |
| 773 | * |
| 774 | * @since 4.4.0 |
| 775 | * @param string $key POST variable string |
| 776 | * @param mixed $default Default value to return |
| 777 | * @return string|array POST variable if one is set, default otherwise |
| 778 | */ |
| 779 | public static function POST( $key, $default = null) { |
| 780 | |
| 781 | return isset( self::$_POST[ $key ] ) ? self::$_POST[ $key ] : $default; |
| 782 | |
| 783 | } |
| 784 | |
| 785 | /** |
| 786 | * Retrieve an unslashed REQUEST variable |
| 787 | * |
| 788 | * @since 4.4.0 |
| 789 | * @param string $key REQUEST variable string |
| 790 | * @param mixed $default Default value to return |
| 791 | * @return string|array REQUEST variable if one is set, default otherwise |
| 792 | */ |
| 793 | public static function REQUEST( $key, $default = null) { |
| 794 | |
| 795 | return isset( self::$_REQUEST[ $key ] ) ? self::$_REQUEST[ $key ] : $default; |
| 796 | |
| 797 | } |
| 798 | |
| 799 | /** |
| 800 | * Retrieve an unslashed COOKIE variable |
| 801 | * |
| 802 | * @since 4.4.0 |
| 803 | * @param string $key COOKIE variable string |
| 804 | * @param mixed $default Default value to return |
| 805 | * @return string|array COOKIE variable if one is set, default otherwise |
| 806 | */ |
| 807 | public static function COOKIE( $key, $default = null) { |
| 808 | |
| 809 | return isset( self::$_COOKIE[ $key ] ) ? self::$_COOKIE[ $key ] : $default; |
| 810 | |
| 811 | } |
| 812 | |
| 813 | /** |
| 814 | * Retrieve an unslashed SERVER variable |
| 815 | * |
| 816 | * @since 4.4.0 |
| 817 | * @param string $key SERVER variable string |
| 818 | * @param mixed $default Default value to return |
| 819 | * @return string|array SERVER variable if one is set, default otherwise |
| 820 | */ |
| 821 | public static function SERVER( $key, $default = null) { |
| 822 | |
| 823 | return isset( self::$_SERVER[ $key ] ) ? self::$_SERVER[ $key ] : $default; |
| 824 | |
| 825 | } |
| 826 | |