| 1 | <?php |
||
| 17 | abstract class AdminPageFramework_Utility_HTMLAttribute extends AdminPageFramework_Utility_SystemInformation { |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Generates inline CSS rules from the given array. |
||
| 21 | * |
||
| 22 | * For example, |
||
| 23 | * <code> |
||
| 24 | * array( |
||
| 25 | * 'width' => '32px', |
||
| 26 | * 'height' => '32px', |
||
| 27 | * ) |
||
| 28 | * </code> |
||
| 29 | * will be |
||
| 30 | * <code> |
||
| 31 | * 'width: 32px; height: 32px;' |
||
| 32 | * </code> |
||
| 33 | * |
||
| 34 | * @since 3.6.0 |
||
| 35 | * @return string |
||
| 36 | */ |
||
| 37 | static public function getInlineCSS( array $aCSSRules ) { |
||
|
1 ignored issue
–
show
|
|||
| 38 | $_aOutput = array(); |
||
| 39 | foreach( $aCSSRules as $_sProperty => $_sValue ) { |
||
| 40 | if ( is_null( $_sValue ) ) { |
||
| 41 | continue; |
||
| 42 | } |
||
| 43 | $_aOutput[] = $_sProperty . ': ' . $_sValue; |
||
| 44 | } |
||
| 45 | return implode( '; ', $_aOutput ); |
||
| 46 | } |
||
| 47 | /** |
||
| 48 | * @since 3.2.0 |
||
| 49 | * @deprecated 3.6.0 Use `getInlineCSS()` instead. |
||
| 50 | */ |
||
| 51 | static public function generateInlineCSS( array $aCSSRules ) { |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Generates a string of inline styles for the style attribute value from multiple arguments. |
||
| 57 | * |
||
| 58 | * Duplicated items will be merged. |
||
| 59 | * |
||
| 60 | * For example, |
||
| 61 | * ` |
||
| 62 | * getStyleAttribute( array( 'margin-top' => '10px', 'display: inline-block' ), 'float:right; display: none;' ) |
||
| 63 | * ` |
||
| 64 | * will generate |
||
| 65 | * ` |
||
| 66 | * margin-top: 10px; display: inline-block; float:right; |
||
| 67 | * ` |
||
| 68 | * @since 3.6.0 |
||
| 69 | * @return string |
||
| 70 | */ |
||
| 71 | static public function getStyleAttribute( $asInlineCSSes ) { |
||
| 96 | /** |
||
| 97 | * @since 3.3.1 |
||
| 98 | * @deprecated 3.6.0 Use `getStyleAttribute()` instead. |
||
| 99 | */ |
||
| 100 | static public function generateStyleAttribute( $asInlineCSSes ) { |
||
| 103 | |||
| 104 | /** |
||
| 105 | * Generates a string of class selectors from multiple arguments. |
||
| 106 | * |
||
| 107 | * For example, |
||
| 108 | * <code> |
||
| 109 | * $sClasses = getClassAttribute( array( 'button, button-primary' ), 'remove_button button' ); |
||
| 110 | * </code> |
||
| 111 | * Will generates |
||
| 112 | * <code> |
||
| 113 | * button button-primary remove_button |
||
| 114 | * </code> |
||
| 115 | * |
||
| 116 | * @remark Duplicated items will be merged. |
||
| 117 | * @since 3.6.0 |
||
| 118 | * @todo Fix an issue that when a multidimensional array is passed, it causes a warning: Notice: Array to string conversion. |
||
| 119 | * @return string |
||
| 120 | */ |
||
| 121 | static public function getClassAttribute( /* $asClassSelectors1, $asClassSelectors12, ... */ ) { |
||
| 141 | /** |
||
| 142 | * Generates a string of class selectors from multiple arguments. |
||
| 143 | * |
||
| 144 | * @since 3.2.0 |
||
| 145 | * @return string |
||
| 146 | * @deprecated 3.6.0 |
||
| 147 | */ |
||
| 148 | static public function generateClassAttribute( /* $asClassSelectors1, $asClassSelectors12 ... */ ) { |
||
| 155 | |||
| 156 | /** |
||
| 157 | * Returns an array for generating a data attribute from the given associative array. |
||
| 158 | * |
||
| 159 | * @since 3.4.0 |
||
| 160 | * @return array |
||
| 161 | */ |
||
| 162 | static public function getDataAttributeArray( array $aArray ) { |
||
| 181 | |||
| 182 | } |
||
| 183 |