[Plugin: Saint du jour] Saint of .. tomorrow?
-
Hi –
Thank you for this wonderful plug-in. One problem, it appears it is pulling the saint of the “French” day and not the local time zone day. That means that us in the west coast of the US see tomorrow’s saint of the day after 10am. Any way to adjust for the time difference?
We enjoy the simplicity of the design and output. English labels on the plugin would be nice, but google translator cleared this up.
Thanks again.
-
I use this plugin on the school website I developed. I fixed the PHP so that it would take timezone into account.
If you would like the file that I have edited let me know and I will generate one that uses west coast time.
I just need to know which one of these cities I should grab the timezone from. Here is the list.
https://www.php.net/manual/en/timezones.america.php
Thanks,
Hi mrk –
Thank you – that would be fantastic! We would be in the America/Los_Angeles time zone. Would you post to the forum or do you need an email to send it to?
If you run into problems let me know. You need to replace the saint-du-jour/saintdujour.php file with this content. Just copying and pasting the whole thing should work as I already put America/Los_Angeles where it needs to go.
I actually just installed this on the website I am working on yesterday. I saw it switched with France time and you were the only one that I saw that had the same issue and it had not been resolved. I stayed up till midnight to make sure it worked properly. Sorry I am not PHP savy enough to create an option on the plugin admin page to change the timezones. I had to hard code it in.
I would also suggest making a back up of your content just in case something goes wrong.
<?php
/*
Plugin Name: Saint du jour
Plugin URI: https://sitesweb.sursum-corda.fr/telechargements.html
Description: This widget displays the saint of the day, according to the timetable of the ordinary and/or the extraordinary form of Roman Catholic rite. Affiche le saint du jour, en accord avec la liturgie catholique romaine dans sa forme ordinaire et/ou extraordinaire.
Version: 1.1
Author: Nicolas Fischmeister
Author URI: https://sitesweb.sursum-corda.fr/
*/load_plugin_textdomain(‘saintdujour’, ‘wp-content/plugins/’ . dirname(plugin_basename(__FILE__)) . ‘/language’);
function reglages_widget_saintdujour()
{
$options = get_option(‘widget_saintdujour’);
if (!is_array($options))
{
$options = array(
‘titre’ => ‘Saint du jour’,
‘aff_forme_1’ => ‘1’,
‘aff_lang_1’ => ‘0’,
‘aff_label_1’ => ‘1’,
‘aff_label_ordi’ => ‘Forme ordinaire :’,
‘aff_sep_1’ => ‘1’,
‘aff_lien_1’ => ‘1’,
‘aff_forme_2’ => ‘1’,
‘aff_lang_2’ => ‘0’,
‘aff_label_2’ => ‘1’,
‘aff_label_extra’ => ‘Forme extraordinaire :’,
‘aff_sep_2’ => ‘1’,
‘aff_lien_2’ => ‘1’
);
}
if ($_POST[‘saintdujour-modifier’])
{
$options[‘titre’] = strip_tags(stripslashes($_POST[‘titre’]));
$options[‘aff_forme_1’] = $_POST[‘aff_forme_1’];
$options[‘aff_lang_1’] = $_POST[‘aff_lang_1’];
$options[‘aff_label_1’] = $_POST[‘aff_label_1’];
$options[‘aff_label_ordi’] = strip_tags(stripslashes($_POST[‘aff_label_ordi’]));
$options[‘aff_sep_1’] = $_POST[‘aff_sep_1’];
$options[‘aff_lien_1’] = $_POST[‘aff_lien_1’];
$options[‘aff_forme_2’] = $_POST[‘aff_forme_2’];
$options[‘aff_lang_2’] = $_POST[‘aff_lang_2’];
$options[‘aff_label_2’] = $_POST[‘aff_label_2’];
$options[‘aff_label_extra’] = strip_tags(stripslashes($_POST[‘aff_label_extra’]));
$options[‘aff_sep_2’] = $_POST[‘aff_sep_2’];
$options[‘aff_lien_2’] = $_POST[‘aff_lien_2’];
update_option(‘widget_saintdujour’, $options);
}
$titre = htmlspecialchars($options[‘titre’], ENT_QUOTES);
$aff_forme_1 = $options[‘aff_forme_1’];
$aff_lang_1 = $options[‘aff_lang_1’];
$aff_label_1 = $options[‘aff_label_1’];
$aff_label_ordi = htmlspecialchars($options[‘aff_label_ordi’], ENT_QUOTES);
$aff_sep_1 = $options[‘aff_sep_1’];
$aff_lien_1 = $options[‘aff_lien_1’];
$aff_forme_2 = $options[‘aff_forme_2’];
$aff_lang_2 = $options[‘aff_lang_2’];
$aff_label_2 = $options[‘aff_label_2’];
$aff_label_extra = htmlspecialchars($options[‘aff_label_extra’], ENT_QUOTES);
$aff_sep_2 = $options[‘aff_sep_2’];
$aff_lien_2 = $options[‘aff_lien_2’];
echo ‘
<h3>’ . __(‘TITRE DU WIDGET’) . ‘</h3>
<div style=”background-color:#FAFAFA; padding:5px; font-size:9px; text-align:right;”>
<input style=”width: 200px; height:15px; font-size:9px; padding:0;” id=”titre” name=”titre” type=”text” value=”‘ . $titre . ‘” />
</div>
<hr />
<h3>’ . __(‘FORME ORDINAIRE’) . ‘</h3>
<div style=”background-color:#FAFAFA; padding:5px; font-size:9px; text-align:right;”>
<label for=”aff_forme_1″>’ . __(‘Afficher forme ordinaire’) . ‘</label>
<input name=”aff_forme_1″ id=”aff_forme_1″ value=”1″‘; if ($aff_forme_1 == 1) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
<label for=”aff_forme_1″>’ . __(‘Non’) . ‘</label>
<input name=”aff_forme_1″ id=”aff_forme_1″ value=”0″‘; if ($aff_forme_1 == 0) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
<label for=”aff_lang_1″>’ . __(‘Langue’) . ‘?
<select style=”width: 160px; height:15px; font-size:9px; padding:0;” id=”aff_lang_1″ name=”aff_lang_1″>
<option value=”0″ selected=”selected”>Fran?ais / French</option>
<option value=”1″>Anglais / English</option>
<option value=”2″>Allemand / German</option>
<option value=”3″>Espagnol / Spanish</option>
<option value=”4″>Portugais / Portuguese</option>
<option value=”5″>Néerlandais / Dutch</option>
<option value=”6″>Italien / Italian</option>
<option value=”7″>Arabe maronite / Arab maronite</option>
</select>
</label>
</div>
<div style=”background-color:#EFEFEF; padding:5px; font-size:9px; text-align:right;”>
<label for=”aff_label_1″>’ . __(‘Afficher le label’) . ‘</label>
<input name=”aff_label_1″ id=”aff_label_1″ value=”1″‘; if ($aff_label_1 == 1) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
<label for=”aff_label_1″>’ . __(‘Non’) . ‘</label>
<input name=”aff_label_1″ id=”aff_label_1″ value=”0″‘; if ($aff_label_1 == 0) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
<label for=”aff_label_ordi”>’ . __(‘Label’) . ‘?<input style=”width: 160px; height:15px; font-size:9px; padding:0;” id=”aff_label_ordi” name=”aff_label_ordi” type=”text” value=”‘ . $aff_label_ordi . ‘” /></label>
<label for=”aff_sep_1″>’ . __(‘Saut de ligne après label’) . ‘</label>
<input name=”aff_sep_1″ id=”aff_sep_1″ value=”1″‘; if ($aff_sep_1 == 1) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
<label for=”aff_sep_1″>’ . __(‘Non’) . ‘</label>
<input name=”aff_sep_1″ id=”aff_sep_1″ value=”0″‘; if ($aff_sep_1 == 0) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
</div>
<div style=”background-color:#FAFAFA; padding:5px; font-size:9px; text-align:right;”>
<label for=”aff_lien_1″>’ . __(‘Afficher le lien’) . ‘</label>
<input name=”aff_lien_1″ id=”aff_lien_1″ value=”1″‘; if ($aff_lien_1 == 1) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
<label for=”aff_lien_1″>’ . __(‘Non’) . ‘</label>
<input name=”aff_lien_1″ id=”aff_lien_1″ value=”0″‘; if ($aff_lien_1 == 0) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
</div>
<hr />
<h3>’ . __(‘FORME ORDINAIRE’) . ‘</h3>
<div style=”background-color:#FAFAFA; padding:5px; font-size:9px; text-align:right;”>
<label for=”aff_forme_2″>’ . __(‘Afficher forme ordinaire’) . ‘</label>
<input name=”aff_forme_2″ id=”aff_forme_2″ value=”1″‘; if ($aff_forme_2 == 1) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
<label for=”aff_forme_2″>’ . __(‘Non’) . ‘</label>
<input name=”aff_forme_2″ id=”aff_forme_2″ value=”0″‘; if ($aff_forme_2 == 0) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
<label for=”aff_lang_2″>’ . __(‘Langue’) . ‘?
<select style=”width: 160px; height:15px; font-size:9px; padding:0;” id=”aff_lang_2″ name=”aff_lang_2″>
<option value=”0″ selected=”selected”>Fran?ais / French</option>
<option value=”1″>Anglais / English</option>
<option value=”2″>Allemand / German</option>
<option value=”3″>Espagnol / Spanish</option>
<option value=”4″>Portugais / Portuguese</option>
<option value=”5″>Néerlandais / Dutch</option>
<option value=”6″>Italien / Italian</option>
<option value=”7″>Arabe maronite / Arab maronite</option>
</select>
</label>
</div>
<div style=”background-color:#EFEFEF; padding:5px; font-size:9px; text-align:right;”>
<label for=”aff_label_2″>’ . __(‘Afficher le label’) . ‘</label>
<input name=”aff_label_2″ id=”aff_label_2″ value=”1″‘; if ($aff_label_2 == 1) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
<label for=”aff_label_2″>’ . __(‘Non’) . ‘</label>
<input name=”aff_label_2″ id=”aff_label_2″ value=”0″‘; if ($aff_label_2 == 0) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
<label for=”aff_label_extra”>’ . __(‘Label’) . ‘?<input style=”width: 160px; height:15px; font-size:9px; padding:0;” id=”aff_label_extra” name=”aff_label_extra” type=”text” value=”‘ . $aff_label_extra . ‘” /></label>
<label for=”aff_sep_2″>’ . __(‘Saut de ligne après label’) . ‘</label>
<input name=”aff_sep_2″ id=”aff_sep_2″ value=”1″‘; if ($aff_sep_2 == 1) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
<label for=”aff_sep_2″>’ . __(‘Non’) . ‘</label>
<input name=”aff_sep_2″ id=”aff_sep_2″ value=”0″‘; if ($aff_sep_2 == 0) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
</div>
<div style=”background-color:#FAFAFA; padding:5px; font-size:9px; text-align:right;”>
<label for=”aff_lien_2″>’ . __(‘Afficher le lien’) . ‘</label>
<input name=”aff_lien_2″ id=”aff_lien_2″ value=”1″‘; if ($aff_lien_2 == 1) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
<label for=”aff_lien_2″>’ . __(‘Non’) . ‘</label>
<input name=”aff_lien_2″ id=”aff_lien_2″ value=”0″‘; if ($aff_lien_2 == 0) echo ‘ checked=”checked”‘; echo ‘ type=”radio”>
</div><input type=”hidden” id=”saintdujour-modifier” name=”saintdujour-modifier” value=”1″ />
<div style=”font-size:8px; color:#999999; padding:10px;”>
‘ . __(‘Saut de ligne si décoché = ?Saut de ligne si coché = Classe du label : .saintdujour_formeClasse du saint : .saintdujour_saint‘) . ‘
</div>
‘;
}
function widget_saintdujour($args)
{
extract($args);
$options = get_option(‘widget_saintdujour’);
$titre = $options[‘titre’];
$aff_forme_1 = $options[‘aff_forme_1’];
$aff_lang_1 = $options[‘aff_lang_1’];
$aff_label_1 = $options[‘aff_label_1’];
$aff_sep_1 = $options[‘aff_sep_1’];
$aff_label_ordi = $options[‘aff_label_ordi’];
$aff_lien_1 = $options[‘aff_lien_1’];
$aff_forme_2 = $options[‘aff_forme_2’];
$aff_lang_2 = $options[‘aff_lang_2’];
$aff_label_2 = $options[‘aff_label_2’];
$aff_sep_2 = $options[‘aff_sep_2’];
$aff_label_extra = $options[‘aff_label_extra’];
$aff_lien_2 = $options[‘aff_lien_2’];
switch ($aff_lang_1)
{
case 0 : $aff_lang_1 = “FR”; break;
case 1 : $aff_lang_1 = “AM”; break;
case 2 : $aff_lang_1 = “DE”; break;
case 3 : $aff_lang_1 = “SP”; break;
case 4 : $aff_lang_1 = “PT”; break;
case 5 : $aff_lang_1 = “NL”; break;
case 6 : $aff_lang_1 = “IT”; break;
case 7 : $aff_lang_1 = “MAA”; break;
}
switch ($aff_lang_2)
{
case 0 : $aff_lang_2 = “TRF”; break;
case 1 : $aff_lang_2 = “TRA”; break;
}
// ——————————————————————————————–
// — Définition du Saint du jour – Forme ordinaire ——————————————
// ——————————————————————————————–
date_default_timezone_set(‘America/Los_Angeles’);
$local_timestamp = date(“Ymd”);
$url = “https://feed.evangelizo.org/reader.php?date=$local_timestamp&type=saint&lang=$aff_lang_1”;
$h = fopen($url,”r”);
if ($h) :
while (!feof($h)) { $a .= fgets($h); }
$a = utf8_encode($a);
$a = str_replace (“(? “, “(?”, $a);
$a = str_replace (“,??“, ”???“, $a);
$a = str_replace (“(+ “, “(?”, $a);
endif;
// On affiche la fête s’il n’y a pas de saint du jour
if (!$a) {
$aa=fopen(“https://feed.evangelizo.org/reader.php?date=$local_timestamp&type=liturgic_t&lang=$aff_lang_1”, “r”);
if ($aa) $a=fgets($aa);
}
// On retire les liens du code si on n’en a pas besoin
if ($aff_lien_1 == “0”) {
$a = ereg_replace(“<a[^>]*>”, “”, $a);
$a = ereg_replace(“</a[^>]*>”, “”, $a);
}
// ——————————————————————————————–
// — Définition du Saint du jour – Forme extraordinaire ————————————-
// ——————————————————————————————–
$url = “https://feed.evangelizo.org/reader.php?date=$local_timestamp&type=saint&lang=$aff_lang_2”;
$h = fopen($url,”r”);
if ($h) :
while (!feof($h)) { $b .= fgets($h); }
$b = utf8_encode($b);
$b = str_replace (“(? “, “(?”, $b);
$b = str_replace (“,??“, ”???“, $b);
$b = str_replace (“(+ “, “(?”, $b);
endif;
// On affiche la fête s’il n’y a ps de saint du jour
if (!$b) {
$bb=fopen(“https://feed.evangelizo.org/reader.php?date=$local_timestamp&type=liturgic_t&lang=$aff_lang_2”, “r”);
if ($bb) $b=fgets($bb);
}
// On retire les liens du code si on n’en a pas besoin
if ($aff_lien_2 == “0”) {
$b = ereg_replace(“<a[^>]*>”, “”, $b);
$b = ereg_replace(“</a[^>]*>”, “”, $b);
}
echo $before_widget;
echo $before_title . $titre . $after_title;
if ($aff_forme_1 == “1”)
{
if ($aff_label_1 == “1”)
{
echo “<span class=’saintdujour_forme’>” . $aff_label_ordi . “</span>”;
if ($aff_sep_1 == “1”) echo “”; else echo ”?“;
}
echo “<span class=’saintdujour_saint’>”.$a.”</span>”;
}
if ($aff_forme_1 == “1” && $aff_forme_2 == “1”)
{
echo “”;
}
if ($aff_forme_2 == “1”)
{
if ($aff_label_2 == “1”)
{
echo “<span class=’saintdujour_forme’>” . $aff_label_extra . “</span>”;
if ($aff_sep_2 == “1”) echo “”; else echo ”?“;
}
echo “<span class=’saintdujour_saint’>”.$b.”</span>”;
}
// merci de laisser ce lien invisible en guise de contribution au développement du wiget.
echo “<div style=’display:none;’>Sursum Corda</div>”;
echo $after_widget;
}
function affichage_widget_saintdujour($args)
{
if ( !function_exists(‘register_sidebar_widget’) || !function_exists(‘register_widget_control’) ) return;
register_sidebar_widget(‘Saint du jour’, ‘widget_saintdujour’);
register_widget_control(‘Saint du jour’, ‘reglages_widget_saintdujour’);
}
add_action(‘plugins_loaded’, ‘affichage_widget_saintdujour’);
?>Thanks again mrk! I’ll give it a try tonight and let you know. I am also using it on a school website. I’ve received great feedback because of it. Another great plug-in that we has brought us positive reviews is PrayBox – https://www.ads-software.com/extend/plugins/praybox/.
Awesome thanks for the info. I will bring it up at the next meeting. It looks like a pretty nice plugin. I also use the Verse of the Day (https://kirilisa.com/projects/bible-verse-display/) plugin on the site I am working on.
Something weird that I noticed is that your Saint switched at 10 AM… I live in Chicago and my time didn’y change till 6 PM so something seems a little off. If the code doesn’t work it could very well be the time on your server is off. You can check that by running a PHP script using a plugin called Exec-PHP, but we can work that out if you have an issue.
Also just so you know the only place that I have tested the Saints du jour plugin was in the widgets area, but I would imagine that it should work thoughout the rest of the website as I changed all of the URLs in the file to change the date within the link to the correct timezone.
The only other reason why I can see that you would run into issues would be posting the code on this blog my remove some of the special characters. If that is the case we can figure out another way to pass the code along.
- The topic ‘[Plugin: Saint du jour] Saint of .. tomorrow?’ is closed to new replies.