2017-11-02 19 views
0

Ich habe mein eigenes Wordpress-Plugin mit Widgets, und mein Problem ist, wenn ich Änderungen in meinem Widgetname_widget.php die Hälfte der Änderung nicht angewendet werden.Wordpress Widget Änderungen gelten nicht

Mein Code:

class Blocs_Home_HS_Widget extends WP_Widget { 

public function __construct() { 

    parent::__construct('blocshomehswidget', 'Blocs Home (version mobile)', array('description' => 'Gestion du contenu des blocs de la page d\'accueil version mobile')); 
} 

public function widget($args, $instance) { 

    $strReturn = disposition_blocs_home_handheld(array('sport_title' => $instance['sport_title'], 'sport_content' => $instance['sport_content'], 'sante_title' => $instance['sante_title'], 'sante_content' => $instance['sante_content'], 'be_title' => $instance['be_title'], 'be_content' => $instance['be_content'], 'recup_title' => $instance['recup_title'], 'recup_content' => $instance['recup_content'])); 

    echo $strReturn; 
} 

public function form($instance) { 

    $sport_title = isset($instance['sport_title']) ? $instance['sport_title'] : ''; 
    $sport_content = isset($instance['sport_content']) ? $instance['sport_content'] : ''; 
    $sante_title = isset($instance['sante_title']) ? $instance['sante_title'] : ''; 
    $sante_content = isset($instance['sante_content']) ? $instance['sante_content'] : ''; 
    $be_title = isset($instance['be_title']) ? $instance['be_title'] : ''; 
    $be_content = isset($instance['be_content']) ? $instance['be_content'] : ''; 
    $recup_title = isset($instance['recup_title']) ? $instance['recup_title'] : ''; 
    $recup_content = isset($instance['recup_content']) ? $instance['recup_content'] : ''; 

    ?> 
    <p> 
     <label for="<?php echo $this->get_field_name('sport_title');?>"><?php _e('Titre du bloc sport : ');?></label> 
     <input class="widefat" id="<?php echo $this->get_field_id('sport_title');?>" name="<?php echo $this->get_field_name('sport_title');?>" type="text" value="<?php echo $sport_title;?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_name('sport_content');?>"><?php _e('Contenu du bloc sport (max 56 caratères par ligne, max 280 au total) : ');?></label> 
     <input class="widefat" id="<?php echo $this->get_field_id('sport_content');?>" name="<?php echo $this->get_field_name('sport_content');?>" type="text" value="<?php echo $sport_content;?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_name('sante_title');?>"><?php _e('Titre du bloc santé :');?></label> 
     <input class="widefat" id="<?php echo $this->get_field_id('sante_title');?>" name="<?php echo $this->get_field_name('sante_title');?>" type="text" value="<?php echo $sante_title;?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_name('sante_content');?>"><?php _e('Contenu du bloc santé (max 56 caratères par ligne, max 280 au total) :');?></label> 
     <input class="widefat" id="<?php echo $this->get_field_id('sante_content');?>" name="<?php echo $this->get_field_name('sante_content');?>" type="text" value="<?php echo $sante_content;?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_name('be_title');?>"><?php _e('Titre du bloc bien-être :');?></label> 
     <input class="widefat" id="<?php echo $this->get_field_id('be_title');?>" name="<?php echo $this->get_field_name('be_title');?>" type="text" value="<?php echo $be_title;?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_name('be_content');?>"><?php _e('Contenu du bloc bien-être (max 56 caratères par ligne, max 280 au total) :');?></label> 
     <input class="widefat" id="<?php echo $this->get_field_id('be_content');?>" name="<?php echo $this->get_field_name('be_content');?>" type="text" value="<?php echo $be_content;?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_name('recup_title');?>"><?php _e('Titre du bloc récupération :');?></label> 
     <input class="widefat" id="<?php echo $this->get_field_id('recup_title');?>" name="<?php echo $this->get_field_name('recup_title');?>" type="text" value="<?php echo $recup_title;?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_name('recup_content');?>"><?php _e('Contenu du bloc récupération (max 56 caratères par ligne, max 280 au total) :');?></label> 
     <input class="widefat" id="<?php echo $this->get_field_id('recup_content');?>" name="<?php echo $this->get_field_name('recup_content');?>" type="text" value="<?php echo $recup_content;?>" /> 
    </p> 

    <?php 
} 

public function random_pos_handheld($param) { 

    $toReturn = array(); 
    $tempId = ''; 
    $tempTitle = ''; 
    $tempContent = ''; 
    $logRand = array(); 

    for($i = 0; $i < 4; $i++) { 

     $random = rand(0, 3); 

     if(in_array($random, $logRand)) { 

      $i--; 
     } 
     else { 

      array_push($logRand, $random); 

      switch($random) { 

       case 0: 
        $tempId = 'sport'; 
        $tempTitle = $param['sport_title']; 
        $tempContent = $param['sport_content']; 
        break; 

       case 1: 
        $tempId = 'sante'; 
        $tempTitle = $param['sante_title']; 
        $tempContent = $param['sante_content']; 
        break; 

       case 2: 
        $tempId = 'be'; 
        $tempTitle = $param['be_title']; 
        $tempContent = $param['be_content']; 
        break; 

       case 3: 
        $tempId = 'recup'; 
        $tempTitle = $param['recup_title']; 
        $tempContent = $param['recup_content']; 
        break; 

       default: 

      } 

      $toReturn[$i] = array(
           'id' => $tempId, 
           'bloc' => $i, 
           'title' => $tempTitle, 
           'content' => $tempContent 
           ); 
     } 
    } 

    return $toReturn; 
} 

public function disposition_blocs_home_handheld($param) { 

    $result = random_pos_handheld($param); 

    $strReturn = ''; 

    foreach($result as $elt) { 

     $strReturn .= '<div class="pos_absolute bloc_' . $elt['id'] . '_hs bloc_' . $elt['bloc'] . '"> 
         <img src="wp-content/themes/pulsdesign/images/bloc_' . $elt['id'] . '_hs.jpg" class="pos_absolute float_right img_bloc_home" /> 
         <img src="wp-content/themes/pulsdesign/images/segment_bloc_hs_home.png" class="pos_absolute segment_bloc_hs_home" /> 
         <p class="pos_absolute bloc_p_title_hs fsize4p4 p_blanc">' . $elt['title'] . '</p> 
         <p class="pos_absolute bloc_p_content fsize39 p_blanc">' . $elt['content'] . '</p> 
         <img src="wp-content/themes/pulsdesign/images/bouton_fade.png" class="button_bloc_solutions_hs pos_absolute" /> 
         <p class="pos_absolute text_bloc_solutions_hs p_blanc fsize30"><b>Nos solutions</b></p> 
         <a href="/testimonies_' . $elt['id'] . '"> 
          <img src="wp-content/themes/pulsdesign/images/bouton_fade.png" class="button_bloc_temoignage_hs pos_absolute" /> 
          <p class="pos_absolute text_bloc_temoignage_hs p_blanc fsize30"><b>Témoignages<br />clients</b></p> 
         </a> 
         <img src="wp-content/themes/pulsdesign/images/bouton_fade.png" class="button_bloc_sp_articles_hs pos_absolute" /> 
         <p class="pos_absolute text_bloc_articles_hs p_blanc fsize30"><b>Articles</b></p> 
        </div>'; 
    } 

    return $strReturn; 
} 

}

Wenn ich die Funktionen ändern widget(), form() und der Konstruktor es kein Problem ist, ich neu laden meine Seite (die das Widget) und die Änderungen apllied. Aber wenn ich meine Funktionen ändere, die ich erstellt habe (random_pos_handheld() und disposition_blocs_home_handheld()), nichts ... Ich habe versucht, die Seite neu zu laden, deaktivierte und reaktivierte das Plugin, installieren Sie das letzte WordPress-Update ... nichts. Ich denke, ich muss das Nachladen von widget_init erzwingen, aber ich habe nichts im Internet gefunden.

Antwort

0

Okay, großer Anfängerfehler ... Die Lösung ist ... die Funktionen mit einer $this->function() aufzurufen!