| 1 |
<?php |
| 2 |
/** |
| 3 |
* The template used to display the WP Editor in a form. |
| 4 |
* |
| 5 |
* @author Studio 164a |
| 6 |
* @package Charitable/Templates/Form Fields |
| 7 |
* @since 1.0.0 |
| 8 |
* @version 1.0.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) { |
| 12 |
return; |
| 13 |
} |
| 14 |
|
| 15 |
$form = $view_args['form']; |
| 16 |
$field = $view_args['field']; |
| 17 |
$classes = $view_args['classes']; |
| 18 |
$is_required = isset( $field['required'] ) ? $field['required'] : false; |
| 19 |
$value = isset( $field['value'] ) ? $field['value'] : ''; |
| 20 |
$editor_args = isset( $field['editor'] ) ? wpautop( $field['editor'] ) : array(); |
| 21 |
|
| 22 |
/** |
| 23 |
* Change the editor settings. |
| 24 |
* |
| 25 |
* @see https://developer.wordpress.org/reference/classes/_wp_editors/parse_settings/ |
| 26 |
* |
| 27 |
* @since 1.5.0 |
| 28 |
* |
| 29 |
* @param array $settings The default settings. |
| 30 |
*/ |
| 31 |
$default_editor_args = array( |
| 32 |
'media_buttons' => true, |
| 33 |
'teeny' => true, |
| 34 |
'quicktags' => false, |
| 35 |
'tinymce' => array( |
| 36 |
'theme_advanced_path' => false, |
| 37 |
'theme_advanced_buttons1' => 'bold,italic,bullist,numlist,blockquote,justifyleft,justifycenter,justifyright,link,unlink', |
| 38 |
), |
| 39 |
); |
| 40 |
|
| 41 |
$editor_args = wp_parse_args( $editor_args, $default_editor_args ); |
| 42 |
?> |
| 43 |
<div id="charitable_field_<?php echo esc_attr( $field['key'] ); ?>" class="<?php echo esc_attr( $classes ); ?>"> |
| 44 |
<?php if ( isset( $field['label'] ) ) : ?> |
| 45 |
<label for="<?php echo esc_attr( $field['key'] ); ?>"> |
| 46 |
<?php echo $field['label']; ?> |
| 47 |
<?php if ( $is_required ) : ?> |
| 48 |
<abbr class="required" title="required">*</abbr> |
| 49 |
<?php endif ?> |
| 50 |
</label> |
| 51 |
<?php endif ?> |
| 52 |
<?php |
| 53 |
wp_editor( $value, $field['key'], $editor_args ); |
| 54 |
?> |
| 55 |
</div> |
| 56 |
|