get_fields( $taxonomy ); if ( empty( $fields ) ) return; foreach ( $fields as $field ) : $meta_value = ''; $toggle_class = ''; $ext_attr = ''; if( isset($field['toggle']) ) { $toggle_class .= 'themify-toggle '; $toggle_class .= (is_array($field['toggle'])) ? implode(' ', $field['toggle']) : $field['toggle']; if ( is_array( $field['toggle'] ) && in_array( '0-toggle', $field['toggle'] ) ) { $toggle_class .= ' default-toggle'; } } if ( isset( $field['class'] ) ) { $toggle_class .= ' '; $toggle_class .= is_array( $field['class'] ) ? implode( ' ', $field['class'] ) : $field['class']; } $data_hide = ''; if ( isset( $field['hide'] ) ) { $data_hide = is_array( $field['hide'] ) ? implode( ' ', $field['hide'] ) : $field['hide']; } if( isset($field['default_toggle']) && $field['default_toggle'] == 'hidden' ){ $ext_attr = 'style="display:none;"'; } if( isset($field['enable_toggle']) && $field['enable_toggle'] == true ) { $toggle_class .= ' enable_toggle'; } ?>
$field, 'meta_value' => $meta_value, 'toggle_class' => $toggle_class, 'data_hide' => $data_hide, 'ext_attr' => $ext_attr, 'post_id' => 0, 'themify_custom_panel_nonce' => wp_create_nonce( 'tf_nonce' ), ) ); // backward compatibility: allow custom function calls in the fields array if( isset( $field['function'] ) && is_callable( $field['function'] ) ) { call_user_func( $field['function'], $field ); } ?>
get_fields( $taxonomy ); if( empty( $fields ) ) return; foreach( $fields as $field ) : $meta_value = isset( $field['name'] ) ? get_term_meta( $tag->term_id, $field['name'], true ) : ''; $toggle_class = ''; $ext_attr = ''; if( isset($field['toggle']) ) { $toggle_class .= 'themify-toggle '; $toggle_class .= (is_array($field['toggle'])) ? implode(' ', $field['toggle']) : $field['toggle']; if ( is_array( $field['toggle'] ) && in_array( '0-toggle', $field['toggle'] ) ) { $toggle_class .= ' default-toggle'; } } if ( isset( $field['class'] ) ) { $toggle_class .= ' '; $toggle_class .= is_array( $field['class'] ) ? implode( ' ', $field['class'] ) : $field['class']; } $data_hide = ''; if ( isset( $field['hide'] ) ) { $data_hide = is_array( $field['hide'] ) ? implode( ' ', $field['hide'] ) : $field['hide']; } if( isset($field['default_toggle']) && $field['default_toggle'] == 'hidden' ){ $ext_attr = 'style="display:none;"'; } if( isset($field['enable_toggle']) && $field['enable_toggle'] == true ) { $toggle_class .= ' enable_toggle'; } ?> $field, 'meta_value' => $meta_value, 'toggle_class' => $toggle_class, 'data_hide' => $data_hide, 'ext_attr' => $ext_attr, 'post_id' => 0, 'themify_custom_panel_nonce' => wp_create_nonce( 'tf_nonce' ), ) ); // backward compatibility: allow custom function calls in the fields array if( isset( $field['function'] ) && is_callable( $field['function'] ) ) { call_user_func( $field['function'], $field ); } ?> fields[ $taxonomy ] ) ) { $this->fields[ $taxonomy ] = apply_filters( "themify_metabox/taxonomy/{$taxonomy}/fields", array() ); } return $this->fields[ $taxonomy ]; } /** * Save custom fields when a term is edited */ function save_fields( $term_id, $taxonomy_term_id, $taxonomy ) { $fields = $this->get_fields( $taxonomy ); if ( empty( $fields ) ) { return false; } foreach ( $fields as $field ) { if ( isset($field['name'] ) ) { $new_meta = isset( $_POST[ $field['name'] ] ) ? $_POST[ $field['name'] ] : ''; $old_meta = get_term_meta( $term_id, $field['name'], true ); // when a default value is set for the field and it's the same as $new_meta, do not bother with saving the field if( isset( $field['default'] ) && $new_meta == $field['default'] ) { $new_meta = ''; } // remove empty meta fields from database if ( '' == $new_meta && metadata_exists( 'term', $term_id, $field['name'] ) ) { delete_term_meta( $term_id, $field['name'] ); } if ( $new_meta !== '' && $new_meta != $old_meta ) { update_term_meta( $term_id, $field['name'], $new_meta ); } } } } /** * Enqueues Themify Metabox assets on term edit pages * * @since 1.0.1 */ function enqueue() { if ( in_array( get_current_screen()->base, array( 'term', 'edit-tags' ),true ) ) { Themify_Metabox::get_instance()->admin_enqueue_scripts(); Themify_Metabox::get_instance()->enqueue(); } } } endif; Themify_Term_Meta::get_instance();