| 1 |
<?php |
| 2 |
/** |
| 3 |
* Handle functions for options |
| 4 |
* |
| 5 |
* @package UpStream |
| 6 |
*/ |
| 7 |
|
| 8 |
// Exit if accessed directly. |
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* Returns colorpicker default colors. |
| 15 |
*/ |
| 16 |
function upstream_colorpicker_default_colors() { |
| 17 |
$array = array( |
| 18 |
'#D15C9C', |
| 19 |
'#9A5CD1', |
| 20 |
'#5C75D1', |
| 21 |
'#5CBFD1', |
| 22 |
'#5CD165', |
| 23 |
'#D1D15C', |
| 24 |
'#D1A65C', |
| 25 |
'#D17F5C', |
| 26 |
'#D15D5C', |
| 27 |
); |
| 28 |
|
| 29 |
return apply_filters( 'upstream_colorpicker_default_colors', $array ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Upstream Render Labels Field Callback |
| 34 |
* |
| 35 |
* @param mixed $field Field. |
| 36 |
* @param mixed $value Value. |
| 37 |
* @param mixed $object_id Object Id. |
| 38 |
* @param mixed $object_type Object Type. |
| 39 |
* @param mixed $field_type Field Type. |
| 40 |
* @return void |
| 41 |
*/ |
| 42 |
function upstream_render_labels_field_callback( $field, $value, $object_id, $object_type, $field_type ) { |
| 43 |
// make sure we specify each part of the value we need. |
| 44 |
$value = wp_parse_args( |
| 45 |
$value, |
| 46 |
array( |
| 47 |
'single' => '', |
| 48 |
'plural' => '', |
| 49 |
) |
| 50 |
); |
| 51 |
|
| 52 |
// allowed html tags for wp_kses input form. |
| 53 |
$allowed_html_tags = array( |
| 54 |
'input' => array( |
| 55 |
'type' => array(), |
| 56 |
'class' => array(), |
| 57 |
'name' => array(), |
| 58 |
'id' => array(), |
| 59 |
'value' => array(), |
| 60 |
'desc' => array(), |
| 61 |
), |
| 62 |
); |
| 63 |
?> |
| 64 |
<div class="alignleft"><p> |
| 65 |
<label for="<?php echo esc_attr( $field_type->_id( '_single' ) ); ?>'"> |
| 66 |
<?php |
| 67 |
esc_html_e( |
| 68 |
'Single', |
| 69 |
'upstream' |
| 70 |
); |
| 71 |
?> |
| 72 |
</label></p> |
| 73 |
<?php |
| 74 |
echo wp_kses( |
| 75 |
$field_type->input( |
| 76 |
array( |
| 77 |
'name' => $field_type->_name( '[single]' ), |
| 78 |
'id' => $field_type->_id( '_single' ), |
| 79 |
'value' => $value['single'], |
| 80 |
'desc' => '', |
| 81 |
) |
| 82 |
), |
| 83 |
$allowed_html_tags |
| 84 |
); |
| 85 |
?> |
| 86 |
</div> |
| 87 |
<div class="alignleft"><p> |
| 88 |
<label for="<?php echo esc_attr( $field_type->_id( '_plural' ) ); ?>'"> |
| 89 |
<?php |
| 90 |
esc_html_e( |
| 91 |
'Plural', |
| 92 |
'upstream' |
| 93 |
); |
| 94 |
?> |
| 95 |
</label></p> |
| 96 |
<?php |
| 97 |
echo wp_kses( |
| 98 |
$field_type->input( |
| 99 |
array( |
| 100 |
'name' => $field_type->_name( '[plural]' ), |
| 101 |
'id' => $field_type->_id( '_plural' ), |
| 102 |
'value' => $value['plural'], |
| 103 |
'desc' => '', |
| 104 |
) |
| 105 |
), |
| 106 |
$allowed_html_tags |
| 107 |
) |
| 108 |
?> |
| 109 |
</div> |
| 110 |
<br class="clear"> |
| 111 |
<?php |
| 112 |
echo esc_html( $field_type->_desc( true ) ); |
| 113 |
} |
| 114 |
add_filter( 'cmb2_render_labels', 'upstream_render_labels_field_callback', 10, 5 ); |
| 115 |
|