Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Product Cat Create page
- function taxonomy_add_new_meta_field() {
- ?>
- <div class="form-field">
- <label for="meta-field"><?php echo __( 'Extra Meta Field', 'woocommerce' ); ?></label>
- <?php
- $name = 'meta-field';
- $settings = array(
- 'wpautop' => true,
- 'media_buttons' => true,
- 'textarea_name' => $name,
- 'textarea_rows' => 10,
- 'tabindex' => '',
- 'editor_css' => '',
- 'teeny' => false,
- 'dfw' => false,
- 'tinymce' => true,
- 'quicktags' => true,
- 'drag_drop_upload' => false
- );
- wp_editor( '', $name, $settings );
- ?>
- </div>
- <?php
- }
- //Product Cat Edit page
- function taxonomy_add_edit_meta_field($term) {
- //getting term ID
- $term_id = $term->term_id;
- // retrieve the existing value(s) for this meta field.
- $meta_tynmc = get_term_meta($term_id, 'meta-field', true);
- ?>
- <tr class="form-field">
- <th scope="row" valign="top"><label for="meta-field"><?php echo __( 'Extra Meta Field', 'woocommerce' ); ?></label></th>
- <td>
- <?php
- $name = 'meta-field';
- $settings = array(
- 'wpautop' => true,
- 'media_buttons' => true,
- 'textarea_name' => $name,
- 'textarea_rows' => 10,
- 'tabindex' => '',
- 'editor_css' => '',
- 'editor_class' => '',
- 'teeny' => false,
- 'dfw' => false,
- 'tinymce' => true,
- 'quicktags' => true,
- 'drag_drop_upload' => false
- );
- wp_editor( $meta_tynmc, $name, $settings );
- ?>
- </td>
- </tr>
- <?php
- }
- add_action('product_cat_add_form_fields', 'taxonomy_add_new_meta_field', 10, 1);
- add_action('product_cat_edit_form_fields', 'taxonomy_add_edit_meta_field', 10, 1);
- // Save extra taxonomy fields callback function.
- function save_taxonomy_custom_meta($term_id) {
- $tyn = filter_input(INPUT_POST, 'meta-field');
- update_term_meta($term_id, 'meta-field', $tyn);
- }
- add_action('edited_product_cat', 'save_taxonomy_custom_meta', 10, 1);
- add_action('create_product_cat', 'save_taxonomy_custom_meta', 10, 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement