Last active
November 13, 2015 22:26
-
-
Save Deaner666/e881ed7351b5a7f1f132 to your computer and use it in GitHub Desktop.
Add a text area for details meta on a WooCommerce product category edit term page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'product_cat_edit_form_fields', 'wpm_product_cat_edit_details_meta' ); | |
/** | |
* Add a details metabox to the Edit Product Category page. | |
* | |
* For adding a details metabox to the WordPress admin when | |
* editing an existing product category in WooCommerce. | |
* | |
* @param object $term The existing term object. | |
*/ | |
function wpm_product_cat_edit_details_meta( $term ) { | |
$product_cat_details = get_term_meta( $term->term_id, 'details', true ); | |
if ( ! $product_cat_details ) { | |
$product_cat_details = ''; | |
} | |
$settings = array( 'textarea_name' => 'wpm-product-cat-details' ); | |
?> | |
<tr class="form-field"> | |
<th scope="row" valign="top"><label for="wpm-product-cat-details"><?php esc_html_e( 'Details', 'wpm' ); ?></label></th> | |
<td> | |
<?php wp_nonce_field( basename( __FILE__ ), 'wpm_product_cat_details_nonce' ); ?> | |
<?php wp_editor( wpm_sanitize_details( $product_cat_details ), 'product_cat_details', $settings ); ?> | |
<p class="description"><?php esc_html_e( 'Detailed category info to appear below the product list','wpm' ); ?></p> | |
</td> | |
</tr> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment