fauzanjeg

Use Category Color for Divider Elementor Color

Sep 8th, 2021 (edited)
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. /* Use Category Color for Divider Elementor Color*/
  2. function use_category_color_for_divider_elementor_elements() {
  3.     if ( is_single() ) {
  4.         $id_post = get_the_ID();
  5.         $primary_cat_id = jnews_get_primary_category( $id_post );
  6.         $category_color = null;
  7.  
  8.         if ( get_option( 'jnews_category_category_override_color' )[ $primary_cat_id ] ) {
  9.             $category_color = get_option( 'jnews_category_category_bg_color' );
  10.         }
  11.  
  12.         if ( get_theme_mod( 'jnews_category_override_color_' . $primary_cat_id ) ) {
  13.             $category_color = get_theme_mod( 'jnews_category_color_' . $primary_cat_id );
  14.         }
  15.  
  16.         if ( ! empty( $category_color[ $primary_cat_id ] ) || ! empty( $category_color ) ) {
  17.             ?>
  18.             <style scoped>
  19.                 .elementor-element {
  20.                     --divider-color: <?php echo ( is_array( $category_color ) ? $category_color[ $primary_cat_id ] : $category_color ); ?>!important;
  21.                 }
  22.             </style>
  23.             <?php
  24.         }
  25.     }
  26. }
  27. add_action( 'wp_head', 'use_category_color_for_divider_elementor_elements' );
Add Comment
Please, Sign In to add comment