Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hamidrezayazdani/c4d03e1648c208ec06a2cc59aa30aaf3 to your computer and use it in GitHub Desktop.
Save hamidrezayazdani/c4d03e1648c208ec06a2cc59aa30aaf3 to your computer and use it in GitHub Desktop.
Activate the visual editor in admin taxonomies pages
<?php
$taxonomies = array(
'category', // for posts categories
'post_tag', // for posts tags
'product_tag', // for wc products tags
'product_cat', // for wc products categories
'product_brand', // for woocommerce brand plugin
'brand', // for yith product brand
);
foreach ( $taxonomies as $taxonomy ) {
add_action( "{$taxonomy}_edit_form_fields", 'ywp_add_visual_editor_to_edit_taxonomy_page', 10, 2 );
add_action( "{$taxonomy}_add_form_fields", 'ywp_add_visual_editor_to_add_taxonomy_page', 10 );
}
/**
* Change taxonomy description editor to visual editor
* in edit taxonomy page
*
* @param $term
* @param $taxonomy
*/
function ywp_add_visual_editor_to_edit_taxonomy_page( $term, $taxonomy ) { ?>
<tr class="form-field term-ywp-description-wrap">
<th scope="row">توضیح</th>
<td>
<?php wp_editor( html_entity_decode( $term->description ), 'tag-description', array(
'textarea_name' => 'description',
'media_buttons' => true
) ); ?>
<script>
jQuery(function ($) {
$('label[for=description]').parent().parent().remove();
});
</script>
</td>
</tr>
<?php
}
/**
* Change taxonomy description editor to visual editor
* in add new taxonomy page
*
* @param $taxonomy
*/
function ywp_add_visual_editor_to_add_taxonomy_page( $taxonomy ) { ?>
<div class="form-field term-ywp-description-wrap">
<label for="description">توضیح</label>
<?php wp_editor( '', 'description', array( 'media_buttons' => true ) ); ?>
<script>
jQuery(function ($) {
$('label[for=tag-description]').parent().remove();
});
</script>
</div>
<?php
}
/**
* The code goes to your active theme (or child theme) functions.php file or use the code snippets plugin (recommanded)
* code snippets plugin: https://wordpress.org/plugins/code-snippets/
*/
@mejora
Copy link

mejora commented May 24, 2024

Hi. It is working. But it does not save headline or List items tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment