Изменения виджета WordPress не применяются

Я создал свой собственный плагин WordPress с виджетами, и моя проблема в том, что когда я делаю изменения в моем widgetname_widget.php, половина изменений не применяется.

Мой код:

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() и у конструктора нет проблем, я перезагружаю свою страницу (содержащую виджет) и изменения отменяются.
Но когда я изменяю свои функции, которые я создал (random_pos_handheld() а также disposition_blocs_home_handheld()), ничего … Я попытался перезагрузить страницу, деактивировал и повторно активировал плагин, переустановил последнее обновление WordPress … ничего. Я думаю, что я должен заставить перезагрузить widget_init но я ничего не нашел в интернете.

0

Решение

Хорошо, большая ошибка новичка …
Решение состоит в том, чтобы … вызывать функции с $this->function() !

0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector