Advertisement
MrPauloeN

Grafika zależna od pory dnia

Mar 16th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. function my_logo_switcher($html)
  2. {
  3.     $timezone = "Europe/Warsaw";
  4.     date_default_timezone_set($timezone);
  5.  
  6.     $godzina = date('H');
  7.     $godzina_od = 22;
  8.     $godzina_do = 6;
  9.     $identyfikator_obrazka_w_galerii_wp = 45;
  10.  
  11.     if($godzina >= $godzina_od || $godzina <= $godzina_do)
  12.     {
  13.         $html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
  14.             esc_url( home_url( '/' ) ),
  15.             wp_get_attachment_image( $identyfikator_obrazka_w_galerii_wp, 'full', false, array(
  16.                 'class'    => 'custom-logo',
  17.                 'itemprop' => 'logo',
  18.             ) )
  19.         );
  20.     }
  21.  
  22.     return $html;
  23. }
  24.  
  25. add_filter('get_custom_logo', 'my_logo_switcher');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement