2017-11-02 13 views
0

ウィジェットを使用して独自のWordpressプラグインを作成しましたが、私の問題はwidgetname_widget.phpに変更を加えたときの半分の変更が適用されないことです。Wordpressのウィジェットの変更は適用されません

マイコード:

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; 
} 

}

私は機能widget()を修正し、form()およびコンストラクタ何ら問題はありません、私は(ウィジェットを含む)私のページをリロードし、変更がaplliedし。 私が作成した機能(random_pos_handheld()disposition_blocs_home_handheld())を変更すると、何も...ページをリロードしようとしましたが、プラグインが非アクティブ化され再アクティブ化されました。私はwidget_initのリロードを強制しなければならないと思うが、私はインターネット上で何も見つけられなかった。

答えて

0

さて、大きな初心者のエラー... 解決策は... $this->function()で関数を呼び出すことです!

関連する問題