PluginProbe ʕ •ᴥ•ʔ
پارسی دیت – Parsi Date / trunk
پارسی دیت – Parsi Date vtrunk
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 1 month ago Cache.php 2 months ago Date.php 1 month ago Debug.php 1 month ago FeedReader.php 1 month ago HTML.php 1 month ago Helper.php 2 months ago JSON.php 2 months ago Nonce.php 2 months ago Notice.php 1 month ago Number.php 2 months ago NumberConverter.php 1 month ago Param.php 2 months ago Sanitizing.php 1 month ago Strip.php 2 months ago Templates.php 2 months ago User.php 2 months ago Validating.php 2 months ago WooCommerce.php 2 months ago WordPress.php 1 month 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