/* 
Theme Name: Hello Elementor Child
Theme URI: https://github.com/elementor/hello-theme/
Description: Hello Elementor Child is a child theme of Hello Elementor, created by Elementor team
Author: Elementor Team
Author URI: https://elementor.com/
Template: hello-elementor
Version: 1.0.1
Text Domain: hello-elementor-child
License: GNU General Public License v3 or later.
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Tags: flexible-header, custom-colors, custom-menu, custom-logo, editor-style, featured-images, rtl-language-support, threaded-comments, translation-ready
*/

/*
    Add your custom styles here
*/
// Replace product category description field with a WYSIWYG editor
add_filter('product_cat_edit_form_fields', 'convert_category_description_to_editor', 10, 2);
add_action('product_cat_add_form_fields', 'convert_category_description_to_editor_add');

function convert_category_description_to_editor($term, $taxonomy) {
    ?>
    <tr class="form-field">
        <th scope="row" valign="top"><label for="description"><?php _e('Description'); ?></label></th>
        <td>
            <?php
            $settings = array(
                'textarea_name' => 'description',
                'quicktags' => true,
                'media_buttons' => true,
                'textarea_rows' => 10,
                'editor_class' => 'wp-editor-area'
            );
            wp_editor(htmlspecialchars_decode($term->description), 'description', $settings);
            ?>
            <p class="description"><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p>
        </td>
    </tr>
    <?php
}

function convert_category_description_to_editor_add($taxonomy) {
    ?>
    <div class="form-field">
        <label for="description"><?php _e('Description'); ?></label>
        <?php
        $settings = array(
            'textarea_name' => 'description',
            'quicktags' => true,
            'media_buttons' => true,
            'textarea_rows' => 10,
            'editor_class' => 'wp-editor-area'
        );
        wp_editor('', 'description', $settings);
        ?>
        <p class="description"><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p>
    </div>
    <?php
}

