PHP Snippet 1:
if ( is_admin( ) && isset( $_GET['taxonomy'], $_GET['post_type'] ) && $_GET['post_type'] === 'product' ) {
$taxonomy_name = sanitize_text_field( $_GET['taxonomy'] );
add_action( $taxonomy_name.'_edit_form_fields', 'etoiles_add_priority_field', 10, 2 );
function etoiles_add_priority_field($term, $taxonomy) {
?>
<tr class="form-field">
<th>
<label for="term_priority"><?php echo esc_html__( 'Priority', 'etoiles' ); ?></label>
</th>
<td>
<input name="term_priority" id="term_priority" type="number" value="" />
<p class="description"><?php echo esc_html__( 'The more the priority, the first it will come in product filter items.', 'etoiles' ); ?></p>
</td>
</tr>
<?php
}
}
PHP Snippet 2:
if (isset($_GET['taxonomy']) && !empty($_GET['taxonomy'])) {
$taxonomy_name = $_GET['taxonomy'];
if (strpos($taxonomy_name, 'pa_') !== false) {
add_action( $taxonomy_name.'_add_form_fields', array ( $this, 'add_category_image' ), 10, 2 );
add_action( 'created_'.$taxonomy_name, array ( $this, 'save_category_image' ), 10, 2 );
add_action( $taxonomy_name.'_edit_form_fields', array ( $this, 'update_category_image' ), 10, 2 );
add_action( 'edited_'.$taxonomy_name, array ( $this, 'updated_category_image' ), 10, 2 );
}
}