'method_name', 'init' => 'init', ]; } /** * Initialize class */ public function init() { add_action('admin_print_footer_scripts', [$this, 'remove_default_taxonomy_description']); add_action('admin_print_styles', [$this, 'add_inline_style']); /** * Get the taxonomy array * * @var array */ $taxonomies = get_taxonomies(); /** * Unset some default value in which there * isn't needed to display TinyMCE editor */ unset($taxonomies['nav_menu']); unset($taxonomies['link_category']); unset($taxonomies['post_format']); foreach ($taxonomies as $taxonomy) { add_filter($taxonomy . '_edit_form_fields', [$this, 'taxonomy_description']); add_filter($taxonomy . '_add_form_fields', [$this, 'taxonomies_description']); } /** * Because the TinyMce editors allow freeform HTML we should * remove these filters from the term description element. */ remove_filter('pre_term_description', 'wp_filter_kses'); remove_filter('term_description', 'wp_kses_data'); } /** * Print the WordPress TinyMCE editor * * @param object $tax Object of taxonomy informations. */ public function print_wp_editor($tax = '') { $settings = ['wpautop' => true, 'media_buttons' => true, 'quicktags' => true, 'textarea_rows' => '15', 'textarea_name' => 'description']; $description = $tax->description ?? ''; wp_editor(wp_kses_post($description, ENT_QUOTES, 'UTF-8'), 'cat_description', $settings); } /** * Display new filed in list page of taxonomy * * @param object $tax Taxonomy object. */ public function taxonomies_description($tax) { ?>
|
print_wp_editor($tax); ?>
|