| 1 |
<?php |
| 2 |
/** |
| 3 |
* Form field description. |
| 4 |
* |
| 5 |
* @package ghostkit |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Class GhostKit_Form_Field_Description |
| 14 |
*/ |
| 15 |
class GhostKit_Form_Field_Description { |
| 16 |
/** |
| 17 |
* Prepare description for field. |
| 18 |
* |
| 19 |
* @param array $attributes block attributes. |
| 20 |
*/ |
| 21 |
public static function get( $attributes ) { |
| 22 |
$attributes = array_merge( |
| 23 |
array( |
| 24 |
'description' => '', |
| 25 |
'hideDescription' => false, |
| 26 |
), |
| 27 |
$attributes |
| 28 |
); |
| 29 |
|
| 30 |
$description = $attributes['description']; |
| 31 |
$hide_description = $attributes['hideDescription']; |
| 32 |
$class = 'ghostkit-form-field-description'; |
| 33 |
|
| 34 |
if ( $hide_description ) { |
| 35 |
$class .= ' ghostkit-form-field-description-hidden'; |
| 36 |
} |
| 37 |
|
| 38 |
if ( $description ) { |
| 39 |
?> |
| 40 |
<small class="<?php echo esc_attr( $class ); ?>"> |
| 41 |
<?php echo wp_kses_post( $description ); ?> |
| 42 |
</small> |
| 43 |
<input type="hidden" name="<?php echo esc_attr( $attributes['slug'] ); ?>[description]" value="<?php echo esc_attr( $description ); ?>" /> |
| 44 |
<?php |
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
new GhostKit_Form_Field_Description(); |
| 49 |
|