'string', 'description' => __( 'Category color', 'flex-posts' ), 'single' => true, 'sanitize_callback' => 'sanitize_hex_color', 'show_in_rest' => true, ) ); } add_action( 'init', 'flex_posts_register_color_meta' ); /** * Add color field to category edit form * * @param obj $term Term object. */ function flex_posts_edit_color_field( $term ) { $color = get_term_meta( $term->term_id, 'fp_color', true ); ?>
taxonomy ) { return; } wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_script( 'wp-color-picker' ); add_action( 'admin_footer', function() { /** * Filter: flex_posts_color_palettes * * If a theme or plugin wants to supply custom palettes, return a * non-empty indexed array of hex color strings. If the filter * returns null or an empty value, the picker will use WordPress's * built-in default palettes. * * @param array|null $palettes Array of hex colors or null to use WP defaults. */ $palettes = apply_filters( 'flex_posts_color_palettes', null ); $fp_palettes = array(); if ( is_array( $palettes ) && ! empty( $palettes ) ) { foreach ( $palettes as $color ) { $color = sanitize_hex_color( $color ); if ( ! empty( $color ) ) { $fp_palettes[] = $color; } } } ?> ' . esc_html( $color ) . ''; } add_action( 'manage_category_custom_column', 'flex_posts_render_category_color_column', 10, 3 );