/
home
/
henzagold
/
blog
/
wp-content
/
themes
/
gillion
/
inc
/
plugins
/
metaboxes
/
File Upload :
llllll
Current File: /home/henzagold/blog/wp-content/themes/gillion/inc/plugins/metaboxes/metaboxes-taxanomy.php
<?php function gillion_metaboxes_taxonomy_fields( $term ) { $term = (object)[ 'ID' => isset( $term->term_id ) ? $term->term_id : 0 ]; ?> <div class="form-field input"> <tr> <th scope="row" valign="top"> <label> <?php echo esc_attr__( 'Image', 'gillion' ); ?> </label> </th> <td> <div style="margin-left: -15px;"> <?php $field = (object)[ 'id' => 'image', 'type' => 'media', ]; Shufflehound_Metaboxes::field( $term, $field, 'term' ); ?> </div> </td> </tr> </div> <div class="form-field input"> <tr> <th scope="row" valign="top"> <label> <?php echo esc_attr__( 'Icon', 'gillion' ); ?> </label> </th> <td> <div style="margin-left: -15px;"> <?php $field = (object)[ 'id' => 'icon', 'type' => 'text', ]; Shufflehound_Metaboxes::field( $term, $field, 'term' ); ?> </div> </td> </tr> </div> <?php } add_action( 'category_add_form_fields', 'gillion_metaboxes_taxonomy_fields', 10, 2 ); add_action( 'category_edit_form_fields', 'gillion_metaboxes_taxonomy_fields', 10, 2 ); function gillion_metaboxes_taxonomy_save( $term_id ) { if( !empty( $_POST ) ) : $term_id = $term_id; $meta_fields = $_POST; if( is_array( $meta_fields ) ) : foreach( $meta_fields as $key => $meta_field ) : if( $key && in_array( $key, [ 'icon', 'image' ] ) ) : if( $meta_field ) : update_term_meta( $term_id, sanitize_text_field( $key ), sanitize_text_field( $meta_field ) ); elseif( $key ) : delete_term_meta( $term_id, sanitize_text_field( $key ) ); endif; endif; endforeach; endif; endif; } add_action( 'edited_category', 'gillion_metaboxes_taxonomy_save', 10, 2 ); add_action( 'create_category', 'gillion_metaboxes_taxonomy_save', 10, 2 );
Copyright ©2k19 -
Hexid
|
Tex7ure