fauzanjeg

Change Logo for Header, Mobile, and Sticky Logo || Example for Spesific Category

Nov 8th, 2021 (edited)
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.26 KB | None | 0 0
  1. /** Change Header Logo || Example for Spesific Category */
  2. function jnews_generate_header_logo( $echo = true ) {
  3.     if ( get_theme_mod( 'jnews_header_logo_type', 'image' ) === 'image' ) {
  4.         $logo        = get_theme_mod( 'jnews_header_logo', get_parent_theme_file_uri( 'assets/img/logo.png' ) );
  5.         $logo_retina = get_theme_mod( 'jnews_header_logo_retina', get_parent_theme_file_uri( 'assets/img/logo@2x.png' ) );
  6.         $alt         = get_theme_mod( 'jnews_header_logo_alt', get_bloginfo( 'name' ) );
  7.  
  8.         /* Dark logo */
  9.         $logo_dark        = get_theme_mod( 'jnews_header_logo_darkmode', get_parent_theme_file_uri( 'assets/img/logo_darkmode.png' ) );
  10.         $logo_retina_dark = get_theme_mod( 'jnews_header_logo_retina_darkmode', get_parent_theme_file_uri( 'assets/img/logo_darkmode@2x.png' ) );
  11.  
  12.         /* START Custom Change */
  13.         $term          = get_queried_object(); /* Get Current Category Data */
  14.         $list_category = array( '90radio', 'another-example-category-slug', 'lifestyle' ); /* List Slug of Category */
  15.         if ( is_category() && in_array( $term->slug, $list_category ) ) { /* If is Category Page and Current Category Slug in List Category */
  16.             /* Link Logo URL */
  17.             $logo             = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  18.             $logo_retina      = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  19.             $alt              = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  20.             $logo_dark        = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  21.             $logo_retina_dark = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  22.         }
  23.         /* END Custom Change */
  24.  
  25.         return JNews\Image\Image::generate_image_retina( $logo, $logo_retina, $alt, $echo, $logo_dark, $logo_retina_dark );
  26.     } else {
  27.         $logo_text = get_theme_mod( 'jnews_header_logo_text', 'Logo' );
  28.  
  29.         return jnews_generate_logo_text( $logo_text, $echo );
  30.     }
  31. }
  32.  
  33. /** Change Mobile Logo || Example for Spesific Category */
  34. function jnews_generate_mobile_logo( $echo = true ) {
  35.     if ( get_theme_mod( 'jnews_mobile_logo_type', 'image' ) === 'image' ) {
  36.         $logo        = get_theme_mod( 'jnews_mobile_logo', get_parent_theme_file_uri( 'assets/img/logo_mobile.png' ) );
  37.         $logo_retina = get_theme_mod( 'jnews_mobile_logo_retina', get_parent_theme_file_uri( 'assets/img/logo_mobile@2x.png' ) );
  38.         $alt         = get_theme_mod( 'jnews_mobile_logo_alt', get_bloginfo( 'name' ) );
  39.  
  40.         /*Dark logo*/
  41.         $logo_dark        = get_theme_mod( 'jnews_mobile_logo_darkmode', get_parent_theme_file_uri( 'assets/img/logo_darkmode.png' ) );
  42.         $logo_retina_dark = get_theme_mod( 'jnews_mobile_logo_retina_darkmode', get_parent_theme_file_uri( 'assets/img/logo_darkmode@2x.png' ) );
  43.  
  44.         /* START Custom Change */
  45.         $term          = get_queried_object(); /* Get Current Category Data */
  46.         $list_category = array( '90radio', 'another-example-category-slug', 'lifestyle' ); /* List Slug of Category */
  47.         if ( is_category() && in_array( $term->slug, $list_category ) ) { /* If is Category Page and Current Category Slug in List Category */
  48.             /* Link Logo URL */
  49.             $logo             = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  50.             $logo_retina      = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  51.             $alt              = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  52.             $logo_dark        = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  53.             $logo_retina_dark = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  54.         }
  55.         /* END Custom Change */
  56.  
  57.         return JNews\Image\Image::generate_image_retina( $logo, $logo_retina, $alt, $echo, $logo_dark, $logo_retina_dark );
  58.     } else {
  59.         $logo_text = get_theme_mod( 'jnews_mobile_logo_text', 'Logo' );
  60.  
  61.         return jnews_generate_logo_text( $logo_text, $echo );
  62.     }
  63. }
  64.  
  65. /** Change Sticky Logo || Example for Spesific Category */
  66. function jnews_generate_sticky_logo( $echo = true ) {
  67.     if ( get_theme_mod( 'jnews_sticky_logo_type', 'image' ) === 'image' ) {
  68.         $logo        = get_theme_mod( 'jnews_sticky_menu_logo', get_parent_theme_file_uri( 'assets/img/sticky_logo.png' ) );
  69.         $logo_retina = get_theme_mod( 'jnews_sticky_menu_logo_retina', get_parent_theme_file_uri( 'assets/img/sticky_logo@2x.png' ) );
  70.         $alt         = get_theme_mod( 'jnews_sticky_menu_alt', get_bloginfo( 'name' ) );
  71.  
  72.         /*Dark logo*/
  73.         $logo_dark        = get_theme_mod( 'jnews_sticky_menu_logo_darkmode', get_parent_theme_file_uri( 'assets/img/logo_darkmode.png' ) );
  74.         $logo_retina_dark = get_theme_mod( 'jnews_sticky_menu_logo_retina_darkmode', get_parent_theme_file_uri( 'assets/img/logo_darkmode@2x.png' ) );
  75.  
  76.         /* START Custom Change */
  77.         $term          = get_queried_object(); /* Get Current Category Data */
  78.         $list_category = array( '90radio', 'another-example-category-slug', 'lifestyle' ); /* List Slug of Category */
  79.         if ( is_category() && in_array( $term->slug, $list_category ) ) { /* If is Category Page and Current Category Slug in List Category */
  80.             /* Link Logo URL */
  81.             $logo             = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  82.             $logo_retina      = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  83.             $alt              = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  84.             $logo_dark        = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  85.             $logo_retina_dark = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  86.         }
  87.         /* END Custom Change */
  88.  
  89.         return JNews\Image\Image::generate_image_retina( $logo, $logo_retina, $alt, $echo, $logo_dark, $logo_retina_dark );
  90.     } else {
  91.         $logo_text = get_theme_mod( 'jnews_sticky_logo_text', 'Logo' );
  92.  
  93.         return jnews_generate_logo_text( $logo_text, $echo );
  94.     }
  95. }
Add Comment
Please, Sign In to add comment