term_id );
$default_image = $category_meta['image'] ? $category_meta['image'] : '';
$default_url = $category_meta['url'] ? $category_meta['url'] : '';
$html = '
';
$html .= '| ';
$html .= sprintf( '', __( 'Imagem', 'cif' ) );
$html .= ' | ';
$html .= '';
$html .= sprintf( '', $default_image );
$html .= sprintf( ' ', __( 'Selecionar arquivo', 'cif' ) );
$html .= '';
$html .= ' | ';
$html .= '
';
$html .= '';
$html .= '| ';
$html .= sprintf( '', __( 'URL', 'cif' ) );
$html .= ' | ';
$html .= '';
$html .= sprintf( '', $default_url );
$html .= ' | ';
$html .= '
';
echo $html;
}
/**
* Save category custom fields.
*
* @param int $term_id Term ID.
*
* @return update term fields.
*/
public function save_fileds( $term_id ) {
if ( isset( $_POST['category_meta'] ) ) {
$category_meta = get_option( 'category_' . $term_id );
$keys = array_keys( $_POST['category_meta'] );
foreach ( $keys as $key ) {
if ( isset( $_POST['category_meta'][$key] ) ) {
$category_meta[$key] = $_POST['category_meta'][$key];
}
}
// Save the option array.
update_option( 'category_' . $term_id , $category_meta );
}
}
} // close Category_Image_Field class.
$cs_category_image_field = new Category_Image_Field;
/**
* Get category image URL.
*
* @return string Image URL.
*/
function get_cat_image_url() {
// Get the current category ID.
$term_id = get_query_var( 'cat' );
// Get options.
$meta = get_option( 'category_' . $term_id );
if ( isset( $meta['image'] ) ) {
return esc_url( $meta['image'] );
}
}
/**
* Get category meta url.
*
* @return string Meta URL.
*/
function get_cat_url() {
// Get the current category ID.
$term_id = get_query_var( 'cat' );
// Get options.
$meta = get_option( 'category_' . $term_id );
if ( isset( $meta['url'] ) ) {
return esc_url( $meta['url'] );
}
}
/**
* Get category image HTML.
*
* @return string Image HTML.
*/
function get_cat_image() {
// Get the current category ID.
$term_id = get_query_var( 'cat' );
// Get options.
$meta = get_option( 'category_' . $term_id );
if ( isset( $meta['image'] ) ) {
return sprintf( '
', esc_url( $meta['image'] ), single_cat_title( '', false ), esc_url( $meta['url'] ) );
}
}