| 1 |
<?php |
| 2 |
/** |
| 3 |
* HTML Functions |
| 4 |
* |
| 5 |
* @package GamiPress\HTML_Functions |
| 6 |
* @author GamiPress <contact@gamipress.com>, Ruben Garcia <rubengcdev@gmail.com> |
| 7 |
* @since 1.7.1 |
| 8 |
*/ |
| 9 |
// Exit if accessed directly |
| 10 |
if( !defined( 'ABSPATH' ) ) exit; |
| 11 |
|
| 12 |
/** |
| 13 |
* Turn an array into a HTML list of hidden inputs |
| 14 |
* |
| 15 |
* @since 1.6.5 |
| 16 |
* |
| 17 |
* @param array $array Array of elements to render |
| 18 |
* @param array $excluded Optional, elements excluded for being rendered |
| 19 |
* |
| 20 |
* @return string |
| 21 |
*/ |
| 22 |
function gamipress_array_as_hidden_inputs( $array, $excluded = array() ) { |
| 23 |
|
| 24 |
$html = ''; |
| 25 |
|
| 26 |
foreach( $array as $key => $value ) { |
| 27 |
// Skip excluded keys |
| 28 |
if( in_array( $key, $excluded ) ) continue; |
| 29 |
|
| 30 |
// Sanitize value |
| 31 |
$value = is_array( $value ) ? implode(',', $value ) : $value; |
| 32 |
|
| 33 |
$html .= '<input type="hidden" name="' . esc_attr( $key ) . '" value="' . esc_attr( $value ) . '">'; |
| 34 |
} |
| 35 |
|
| 36 |
return $html; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Generates the required HTML with the dashicon provided |
| 41 |
* |
| 42 |
* @since 1.7.1 |
| 43 |
* |
| 44 |
* @param string $dashicon Dashicon class |
| 45 |
* @param string $tag Optional, tag used (recommended i or span) |
| 46 |
* |
| 47 |
* @return string |
| 48 |
*/ |
| 49 |
function gamipress_dashicon( $dashicon = 'gamipress', $tag = 'i' ) { |
| 50 |
|
| 51 |
return '<' . $tag . ' class="dashicons dashicons-' . $dashicon . '"></' . $tag . '>'; |
| 52 |
|
| 53 |
} |