Categories::image_field_edit( object $term )
Description #
Image field in category form.
Parameters #
- $termobject (Required) Term.
Source #
File: addons/categories/categories.php
public function image_field_edit( $term ) {
$term_meta = get_term_meta( $term->term_id, 'ap_category', true );
$term_meta = wp_parse_args(
$term_meta,
array(
'image' => array(
'id' => '',
'url' => '',
),
'icon' => '',
'color' => '',
)
);
?>
<tr class='form-field form-required term-name-wrap'>
<th scope='row'>
<label for='custom-field'><?php esc_attr_e( 'Image', 'anspress-question-answer' ); ?></label>
</th>
<td>
<a href="#" id="ap-category-upload" class="button" data-action="ap_media_uplaod" data-title="<?php esc_attr_e( 'Upload image', 'anspress-question-answer' ); ?>" data-idc="#ap_category_media_id" data-urlc="#ap_category_media_url"><?php esc_attr_e( 'Upload image', 'anspress-question-answer' ); ?></a>
<?php if ( ! empty( $term_meta['image'] ) && ! empty( $term_meta['image']['url'] ) ) { ?>
<img id="ap_category_media_preview" data-action="ap_media_value" src="<?php echo esc_url( $term_meta['image']['url'] ); ?>" />
<?php } ?>
<input id="ap_category_media_url" type="hidden" data-action="ap_media_value" name="ap_category_image_url" value="<?php echo esc_url( $term_meta['image']['url'] ); ?>">
<input id="ap_category_media_id" type="hidden" data-action="ap_media_value" name="ap_category_image_id" value="<?php echo esc_attr( $term_meta['image']['id'] ); ?>">
<?php if ( is_array( $term_meta ) && ! empty( $term_meta['image'] ) && ! empty( $term_meta['image']['url'] ) ) { ?>
<a href="#" id="ap-category-upload-remove" data-action="ap_media_remove"><?php esc_attr_e( 'Remove image', 'anspress-question-answer' ); ?></a>
<?php } ?>
<p class='description'><?php esc_attr_e( 'Featured image for category', 'anspress-question-answer' ); ?></p>
</td>
</tr>
<tr class='form-field term-name-wrap'>
<th scope='row'>
<label for='custom-field'><?php esc_attr_e( 'Category icon class', 'anspress-question-answer' ); ?></label>
</th>
<td>
<input id="ap_icon" type="text" name="ap_icon" value="<?php echo esc_attr( $term_meta['icon'] ); ?>">
<p class="description">
<?php
echo wp_kses(
sprintf(
/* translators: %s Link to font icon class. */
__( 'Font icon class, if image not set. Find our official list of icons from <a href="%s" target="_blank">here</a>.', 'anspress-question-answer' ),
esc_url( 'https://htmlpreview.github.io/?https://github.com/anspress/anspress/blob/3.0.7/theme/default/fonts/demo.html' )
),
array(
'a' => array(
'href' => array(),
'target' => array(),
),
)
);
?>
</p>
</td>
</tr>
<tr class='form-field term-name-wrap'>
<th scope='row'>
<label for='ap-category-color'><?php esc_attr_e( 'Icon background color', 'anspress-question-answer' ); ?></label>
</th>
<td>
<input id="ap-category-color" type="text" name="ap_color" value="<?php echo esc_attr( $term_meta['color'] ); ?>">
<p class="description"><?php esc_attr_e( 'Set background color to be used with icon', 'anspress-question-answer' ); ?></p>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#ap-category-color').wpColorPicker();
});
</script>
</td>
</tr>
<?php
}
Expand full source code Collapse full source code View on GitHub: addons/categories/categories.php:612
Add your comment