Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/05/2012, 12:22
Eric_Draven
 
Fecha de Ingreso: mayo-2011
Mensajes: 18
Antigüedad: 13 años
Puntos: 0
Full Bg + Rotacion img según hora

Tengo un plugin para wodpress en el cual me pone una imagen de fondo completa, el problema es que necesito también que cambie según la hora. He buscado por la web un código para que cambie. Pero al combinarlo, funciona, pero en el panel de admin de wordpress deja de funcionar, y sale la imagen solo, no sale el form de login.

El código es este:

Código:
    <?php

    function fsb_display_image() {
        global $fsb_options;
       
        if($fsb_options) {
            $image = '<img src="' . $fsb_options['image'] . '" id="fsb_image"/>';
        }
        // output the image
        echo $image;
    }
    add_action('wp_footer', 'fsb_display_image');
Este codigo es el que hace que cambie cada según la hora:

Código:
  <?php

    date_default_timezone_set("GMT"); // set to your time zone

    $thetime = date("H"); // H means it just grabs the hour in 24 hour format

    // this section grabs the correct stylesheet by time, don't alter if you can help it

    if($thetime > 00 AND $thetime < 06) { echo "http://www.turisrialp.cat/img/ima01.jpg";} // between midnight and 6am
    elseif($thetime > 05 AND $thetime < 12) { echo "http://www.turisrialp.cat/img/ima01.jpg";} // between 6am and 12pm
    elseif($thetime > 11 AND $thetime < 19) { echo "http://www.turisrialp.cat/img/ima02.jpg";} // between 12pm and 7pm
    elseif($thetime > 18 AND $thetime < 23) { echo "http://www.turisrialp.cat/img/ima02.jpg";} // between 7pm and 11pm
    elseif($thetime = 23) { echo "http://www.turisrialp.cat/img/ima03.jpg";} // 11pm
    elseif($thetime = 00) { echo "http://www.turisrialp.cat/img/ima03.jpg";} // midnight
    ?>"
Y yo lo resolví así:

Código:
<img src="<?php

date_default_timezone_set("GMT"); // set to your time zone

$thetime = date("H"); // H means it just grabs the hour in 24 hour format

// this section grabs the correct stylesheet by time, don't alter if you can help it

if($thetime > 00 AND $thetime < 06) { echo "http://www.turisrialp.cat/img/ima01.jpg";} // between midnight and 6am
elseif($thetime > 05 AND $thetime < 12) { echo "http://www.turisrialp.cat/img/ima01.jpg";} // between 6am and 12pm
elseif($thetime > 11 AND $thetime < 19) { echo "http://www.turisrialp.cat/img/ima02.jpg";} // between 12pm and 7pm
elseif($thetime > 18 AND $thetime < 23) { echo "http://www.turisrialp.cat/img/ima02.jpg";} // between 7pm and 11pm
elseif($thetime = 23) { echo "http://www.turisrialp.cat/img/ima03.jpg";} // 11pm
elseif($thetime = 00) { echo "http://www.turisrialp.cat/img/ima03.jpg";} // midnight
?>" id="fsb_image"
/>
Como he comentado, funciona, pero en la pagína wp-admin solo muestra la imagen.

Lo he probado también con funciones, pero no hay manera.

ALgun consejo?

Gracias