PluginProbe ʕ •ᴥ•ʔ
پارسی دیت – Parsi Date / 6.2.1
پارسی دیت – Parsi Date v6.2.1
6.2.1 6.2 6.1 5.1.6 5.1.7 5.1.8 5.1.8.2 6.0 trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.0.0-alpha 2.1 2.1.1 2.1.2 2.1.3 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0.1 2.3.0.2 2.3.1 2.3.2 2.3.3 2.3.4 3.0.1 3.0.2 3.0.3 4.0.0 4.0.1 4.0.2 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5
wp-parsidate / inc / Helper / Param.php
wp-parsidate / inc / Helper Last commit date
Assets.php 3 weeks ago Cache.php 3 weeks ago Date.php 3 weeks ago Debug.php 3 weeks ago FeedReader.php 3 weeks ago HTML.php 3 weeks ago Helper.php 3 weeks ago JSON.php 3 weeks ago Nonce.php 3 weeks ago Notice.php 3 weeks ago Number.php 3 weeks ago NumberConverter.php 3 weeks ago Param.php 3 weeks ago Sanitizing.php 3 weeks ago Strip.php 3 weeks ago Templates.php 3 weeks ago User.php 3 weeks ago Validating.php 3 weeks ago WooCommerce.php 3 weeks ago WordPress.php 3 weeks ago
Param.php
108 lines
1 <?php
2
3 namespace WPParsidate\Helper;
4
5 defined( 'ABSPATH' ) || exit;
6
7 /**
8 * Param class.
9 */
10 class Param {
11
12 /**
13 * Get field from query string.
14 *
15 * @param string $id Field id to get.
16 * @param mixed $default Default value to return if field is not found.
17 * @param int $filter The ID of the filter to apply.
18 * @param int $flag The ID of the flag to apply.
19 *
20 * @return mixed
21 */
22 public static function get( $id, $default = false, $filter = FILTER_DEFAULT, $flag = [] ) {
23 // PHPCS ignore reason: Nonce check is already happening before this logic in `AdminPages` class.
24 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
25 return isset( $_GET[ $id ] ) ? filter_var( wp_unslash( $_GET[ $id ] ), $filter, $flag ) : $default;
26 }
27
28 /**
29 * Get field from FORM post.
30 *
31 * @param string $id Field id to get.
32 * @param mixed $default Default value to return if field is not found.
33 * @param int $filter The ID of the filter to apply.
34 * @param int $flag The ID of the flag to apply.
35 *
36 * @return mixed
37 */
38 public static function post( $id, $default = false, $filter = FILTER_DEFAULT, $flag = [] ) {
39 // PHPCS ignore reason: Nonce check is already happening before this logic in `AdminPages` class.
40 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
41 if ( isset( $_POST[ $id ] ) ) {
42 // PHPCS ignore reason: Sanitize posted data with `Sanitizing` class
43 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
44 return is_array( $_POST[ $id ] ) ? filter_var_array( $_POST[ $id ], $filter ) : filter_var( $_POST[ $id ],
45 $filter, $flag );
46 }
47
48 return $default;
49 }
50
51 /**
52 * Get field from request.
53 *
54 * @param string $id Field id to get.
55 * @param mixed $default Default value to return if field is not found.
56 * @param int $filter The ID of the filter to apply.
57 * @param int $flag The ID of the flag to apply.
58 *
59 * @return mixed
60 */
61 public static function request( $id, $default = false, $filter = FILTER_DEFAULT, $flag = [] ) {
62 // PHPCS ignore reason: Nonce check is already happening before this logic in `AdminPages` class.
63 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
64 return isset( $_REQUEST[ $id ] ) ? filter_var( wp_unslash( $_REQUEST[ $id ] ), $filter, $flag ) : $default;
65 }
66
67 /**
68 * Get field from FORM server.
69 *
70 * @param string $id Field id to get.
71 * @param mixed $default Default value to return if field is not found.
72 * @param int $filter The ID of the filter to apply.
73 * @param int $flag The ID of the flag to apply.
74 *
75 * @return mixed
76 */
77 public static function server( $id, $default = false, $filter = FILTER_DEFAULT, $flag = [] ) {
78 return isset( $_SERVER[ $id ] ) ? filter_var( wp_unslash( $_SERVER[ $id ] ), $filter, $flag ) : $default;
79 }
80
81 /**
82 * Decode form.serelize() jQuery Post String
83 * Return like $_POST['Form_Input_Name or ID']
84 *
85 * @source https://stackoverflow.com/a/5788352/3224296
86 */
87 public static function decodeSerialize( $queryString ): array {
88 $a = explode( '&', $queryString );
89 $i = 0;
90 $store = array();
91 while ( $i < count( $a ) ) {
92 $b = explode( '=', $a[ $i ] );
93 $arrayName = htmlspecialchars( urldecode( $b[0] ) );
94 $cleanArrayName = str_replace( '[]', '', $arrayName );
95 $arrayValue = htmlspecialchars( urldecode( $b[1] ) );
96
97 if ( strpos( $arrayName, '[]' ) !== false ) {
98 $store[ $cleanArrayName ][] = $arrayValue;
99 } else {
100 $store[ $cleanArrayName ] = $arrayValue;
101 }
102 $i ++;
103 }
104
105 return $store;
106 }
107 }
108