1 | <?php |
||
2 | /** |
||
3 | * Admin Page Framework |
||
4 | * |
||
5 | * http://admin-page-framework.michaeluno.jp/ |
||
6 | * Copyright (c) 2013-2022, Michael Uno; Licensed MIT |
||
7 | * |
||
8 | */ |
||
9 | |||
10 | /** |
||
11 | * Put deprecated utility methods together. |
||
12 | * |
||
13 | * @since 3.5.3 |
||
14 | * @package AdminPageFramework/Utility |
||
15 | * @internal |
||
16 | * @deprecated |
||
17 | */ |
||
18 | abstract class AdminPageFramework_Utility_Deprecated { |
||
19 | |||
20 | /** |
||
21 | * @deprecated 3.7.10 Use `getCSSMinified()` instead. |
||
22 | * @since 3.8.8 Moved from `AdminPageFramework_Utility_String`. |
||
23 | */ |
||
24 | static public function minifyCSS( $sCSSRules ) { |
||
25 | AdminPageFramework_Utility::showDeprecationNotice( __FUNCTION__, 'getCSSMinified()' ); |
||
26 | return AdminPageFramework_Utility_String::getCSSMinified( $sCSSRules ); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @deprecated 3.8.0 Use `getLengthSanitized()` instead. |
||
31 | * @since 3.8.8 Moved from `AdminPageFramework_Utility_String`. |
||
32 | */ |
||
33 | static public function sanitizeLength( $sLength, $sUnit='px' ) { |
||
34 | AdminPageFramework_Utility::showDeprecationNotice( __FUNCTION__, 'getLengthSanitized()' ); |
||
35 | return AdminPageFramework_Utility_String::getLengthSanitized( $sLength, $sUnit ); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Retrieves a corresponding array value from the given array. |
||
40 | * |
||
41 | * When there are multiple arrays and they have similar index structures but it's not certain if one has the key and the others, |
||
42 | * use this method to retrieve the corresponding key value. |
||
43 | * |
||
44 | * @remark This is mainly used by the field array to insert user-defined key values. |
||
45 | * @return string|array If the key does not exist in the passed array, it will return the default. If the subject value is not an array, it will return the subject value itself. |
||
46 | * @since 2.0.0 |
||
47 | * @since 2.1.3 Added the $bBlankToDefault parameter that sets the default value if the subject value is empty. |
||
48 | * @since 2.1.5 Changed the scope to public static from protected as converting all the utility methods to all public static. |
||
49 | * @since 3.5.3 Moved from `AdminPageFramework_Utility_Array`. |
||
50 | * @deprecated 3.5.3 Use `getElement()`. |
||
51 | */ |
||
52 | public static function getCorrespondingArrayValue( $vSubject, $sKey, $sDefault='', $bBlankToDefault=false ) { |
||
53 | |||
54 | AdminPageFramework_Utility::showDeprecationNotice( __FUNCTION__, 'getElement()' ); |
||
55 | |||
56 | // If $vSubject is null, |
||
57 | if ( ! isset( $vSubject ) ) { |
||
58 | return $sDefault; |
||
59 | } |
||
60 | |||
61 | // If the $bBlankToDefault flag is set and the subject value is a blank string, return the default value. |
||
62 | if ( $bBlankToDefault && $vSubject == '' ) { |
||
63 | return $sDefault; |
||
64 | } |
||
65 | |||
66 | // If $vSubject is not an array, |
||
67 | if ( ! is_array( $vSubject ) ) { |
||
68 | return ( string ) $vSubject; |
||
69 | } // consider it as string. |
||
70 | |||
71 | // Consider $vSubject as array. |
||
72 | if ( isset( $vSubject[ $sKey ] ) ) { |
||
73 | return $vSubject[ $sKey ]; |
||
74 | } |
||
75 | |||
76 | return $sDefault; |
||
77 | |||
78 | } |
||
79 | |||
80 | /** |
||
81 | * Finds the dimension depth of the given array. |
||
82 | * |
||
83 | * @since 2.0.0 |
||
84 | * @since 3.5.3 Moved from `AdminPageFramework_Utility_Array`. |
||
85 | * @remark There is a limitation that this only checks the first element so if the second or other elements have deeper dimensions, it will not be caught. |
||
86 | * @param array $array the subject array to check. |
||
87 | * @return integer returns the number of dimensions of the array. |
||
88 | * @deprecated 3.5.3 |
||
89 | */ |
||
90 | public static function getArrayDimension( $array ) { |
||
91 | AdminPageFramework_Utility::showDeprecationNotice( __FUNCTION__ ); |
||
92 | return ( is_array( reset( $array ) ) ) |
||
93 | ? self::getArrayDimension( reset( $array ) ) + 1 |
||
0 ignored issues
–
show
|
|||
94 | : 1; |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * Returns the element value of the given field element. |
||
99 | * |
||
100 | * When there are multiple input/select tags in one field such as for the radio and checkbox input type, |
||
101 | * the framework user can specify the key to apply the element value. In this case, this method will be used. |
||
102 | * |
||
103 | * @since 3.0.0 |
||
104 | * @since 3.5.3 Moved from `AdminPageFramework_FieldType_Base`. |
||
105 | * @deprecated 3.5.3 Use the `getElement()` method. |
||
106 | */ |
||
107 | protected function getFieldElementByKey( $asElement, $sKey, $asDefault='' ) { |
||
108 | |||
109 | AdminPageFramework_Utility::showDeprecationNotice( __FUNCTION__, 'getElement()' ); |
||
110 | |||
111 | if ( ! is_array( $asElement ) || ! isset( $sKey ) ) { |
||
112 | return $asElement; |
||
113 | } |
||
114 | |||
115 | $aElements = &$asElement; // it is an array |
||
116 | return isset( $aElements[ $sKey ] ) |
||
117 | ? $aElements[ $sKey ] |
||
118 | : $asDefault; |
||
119 | |||
120 | } |
||
121 | |||
122 | /** |
||
123 | * Shift array elements until it gets an element that yields true and re-index with numeric keys. |
||
124 | * |
||
125 | * @since 3.0.1 |
||
126 | * @since 3.5.3 Moved from `AdminPageFramework_Utility_Array`. |
||
127 | * @deprecated 3.5.3 This was used to sanitise dimensional key arrays but it does not seem to necessary. |
||
128 | * @return array |
||
129 | */ |
||
130 | static public function shiftTillTrue( array $aArray ) { |
||
131 | |||
132 | AdminPageFramework_Utility::showDeprecationNotice( __FUNCTION__ ); |
||
133 | |||
134 | foreach( $aArray as &$vElem ) { |
||
135 | |||
136 | if ( $vElem ) { break; } |
||
137 | unset( $vElem ); |
||
138 | |||
139 | } |
||
140 | return array_values( $aArray ); |
||
141 | |||
142 | } |
||
143 | |||
144 | } |
||
145 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.