2017-03-18 08:20:33 +03:00
< ? php
/*
Plugin Name : Discordian Date Function
2026-02-02 01:21:07 +03:00
Plugin URI : https :// is3 . ussr . win / discordian - date - function
2020-06-18 12:01:08 +03:00
Description : Convert dates in Wordpress to customizable Discordian dates and time ( decimal ) . Also , this plugin provides shortcode and widget used to display the current erisian date with notification of 70 holidays . Based on the Discordian Date plugin by Dan Johnson .
2026-02-02 01:21:07 +03:00
Version : 3.5
2017-03-18 08:20:33 +03:00
Author : ivan zlax
2026-02-02 01:21:07 +03:00
Author URI : https :// is3 . ussr . win / about
2017-03-18 08:20:33 +03:00
*/
function get_ddate ( $content , $format = " " , $originalRequest = null ) {
/*
Based on : http :// www . dexterityunlimited . com / wordpress - plugins / discordian - date / by Dan Johnson
*/
2020-04-04 12:02:47 +03:00
$season_list = array ( " Chaos " , " Discord " , " Confusion " , " Bureaucracy " , " Aftermath " );
2017-03-18 08:20:33 +03:00
$day_list = array ( " Sweetmorn " , " Boomtime " , " Pungenday " , " Prickle-Prickle " , " Setting Orange " );
switch ( $originalRequest ) {
case " get_the_date " :
2020-04-04 11:52:59 +03:00
case " get_the_time " :
2017-03-18 08:20:33 +03:00
$post = get_post ( $format );
2022-07-17 19:33:08 +03:00
if ( get_option ( 'dtime_convert' ))
2020-04-04 11:52:59 +03:00
$standard_date = utcm5_convert ( mysql2date ( 'U' , $post -> post_date_gmt ));
else
$standard_date = getdate ( mysql2date ( 'U' , $post -> post_date ));
2017-03-18 08:20:33 +03:00
break ;
case " get_comment_date " :
2020-04-04 11:52:59 +03:00
case " get_comment_time " :
2017-03-18 08:20:33 +03:00
$comment = get_comment ( $format );
2022-07-17 19:33:08 +03:00
if ( get_option ( 'dtime_convert' ))
2020-04-04 11:52:59 +03:00
$standard_date = utcm5_convert ( mysql2date ( 'U' , $comment -> comment_date_gmt ));
else
$standard_date = getdate ( mysql2date ( 'U' , $comment -> comment_date ));
2017-03-18 08:20:33 +03:00
break ;
case " now " :
2022-07-17 19:33:08 +03:00
if ( get_option ( 'dtime_convert' ))
2020-04-04 11:52:59 +03:00
$standard_date = utcm5_convert ( getdate ()[ 0 ]);
else
$standard_date = getdate ();
2017-03-18 08:20:33 +03:00
}
2020-04-04 11:52:59 +03:00
if ( $originalRequest == " get_comment_time " ) return dtime_convert ( $standard_date );
if ( $originalRequest == " get_the_time " ) return dtime_convert ( $standard_date );
2017-03-18 08:20:33 +03:00
$dyear = $standard_date [ " year " ] + 1166 ;
2026-02-02 01:21:07 +03:00
$eyear = $dyear - 3000 ;
2020-03-01 12:46:42 +03:00
$gyear = $standard_date [ " year " ];
2017-03-18 08:20:33 +03:00
$yday = $standard_date [ " yday " ];
2020-03-01 12:46:42 +03:00
// Check Tib's day according to Gregorian calendar
if ( $gyear % 4 == 0 && $gyear % 100 != 0 || $gyear % 400 == 0 ) {
if ( $standard_date [ " yday " ] == 59 ) $sttib = " St. Tib's " ;
if ( $standard_date [ " yday " ] > 59 ) $yday = $standard_date [ " yday " ] - 1 ;
}
2017-03-18 08:20:33 +03:00
$mon = $standard_date [ " mon " ];
$mday = $standard_date [ " mday " ];
$dseason = ( int )( $yday / 73 );
$name_season = $season_list [ $dseason ];
$dday = ( $yday - ( 73 * $dseason )) + 1 ;
2017-03-19 14:18:04 +03:00
$clear_dday = $dday ;
2017-03-18 08:20:33 +03:00
$suff = $dday % 10 ;
switch ( $suff ) {
case 1 :
$dday .= " st " ;
break ;
case 2 :
$dday .= " nd " ;
break ;
case 3 :
$dday .= " rd " ;
break ;
default :
$dday .= " th " ;
}
$dweekday = $day_list [( $yday % 5 )];
2017-03-19 14:18:04 +03:00
if ( $originalRequest == " now " ) {
2026-02-02 01:21:07 +03:00
if ( get_option ( 'ee_widget' )) {
$ddate = $dweekday . " , the " . $dday . " day of " . $name_season . " , in the year " . $eyear . " of the erisian era " ;
if ( isset ( $sttib )) $ddate = $sttib . " day, in the year " . $eyear . " of the erisian era " ;
} else {
$ddate = $dweekday . " , the " . $dday . " day of " . $name_season . " , in the yold " . $dyear ;
if ( isset ( $sttib )) $ddate = $sttib . " day, in the yold " . $dyear ;
}
2017-03-19 14:18:04 +03:00
} else {
$patterns = array ();
$patterns [ 0 ] = '%DY' ;
$patterns [ 1 ] = '%DS' ;
$patterns [ 2 ] = '%DD' ;
$patterns [ 3 ] = '%DC' ;
$patterns [ 4 ] = '%DW' ;
$patterns [ 5 ] = '%GY' ;
$patterns [ 6 ] = '%GM' ;
$patterns [ 7 ] = '%GN' ;
$patterns [ 8 ] = '%GD' ;
$patterns [ 9 ] = '%GW' ;
2020-04-04 11:52:59 +03:00
$patterns [ 10 ] = '%DT' ;
$patterns [ 11 ] = '%CT' ;
$patterns [ 12 ] = '%UT' ;
2026-02-02 01:21:07 +03:00
$patterns [ 13 ] = '%EY' ;
$patterns [ 14 ] = '%ES' ;
2017-03-19 14:18:04 +03:00
$replacements = array ();
$replacements [ 0 ] = $dyear ;
$replacements [ 1 ] = $name_season ;
$replacements [ 2 ] = $dday ;
$replacements [ 3 ] = $clear_dday ;
2020-03-01 12:46:42 +03:00
if ( isset ( $sttib )) {
$replacements [ 2 ] = $sttib ;
$replacements [ 3 ] = " tib " ;
}
2017-03-19 14:18:04 +03:00
$replacements [ 4 ] = $dweekday ;
$replacements [ 5 ] = $standard_date [ " year " ];
$replacements [ 6 ] = $standard_date [ " month " ];
$replacements [ 7 ] = $standard_date [ " mon " ];
$replacements [ 8 ] = $standard_date [ " mday " ];
$replacements [ 9 ] = $standard_date [ " weekday " ];
2020-04-04 11:52:59 +03:00
$replacements [ 10 ] = dtime_convert ( $standard_date );
$replacements [ 11 ] = $standard_date [ " hours " ] . " : " . str_pad ( $standard_date [ " minutes " ], 2 , '0' , STR_PAD_LEFT );
$replacements [ 12 ] = $standard_date [ 0 ];
2026-02-02 01:21:07 +03:00
$replacements [ 13 ] = $eyear ;
$replacements [ 14 ] = $dseason + 1 ;
2017-03-19 14:18:04 +03:00
$ddate = str_replace ( $patterns , $replacements , get_option ( 'ddatefunc_string' ));
}
2017-03-18 08:20:33 +03:00
return $ddate ;
}
2020-04-04 11:52:59 +03:00
function dtime_convert ( $standard_date ) {
$standard_msday = $standard_date [ " hours " ] * 3600000 + $standard_date [ " minutes " ] * 60000 + $standard_date [ " seconds " ] * 1000 ;
$discordian_sday = round ( $standard_msday / 864 );
$discordian_minutes = $discordian_sday % 10000 ;
$dtime = floor ( $discordian_sday / 10000 ) . " : " . str_pad ( floor ( $discordian_minutes / 100 ), 2 , '0' , STR_PAD_LEFT );
return $dtime ;
}
function utcm5_convert ( $standard_date ) {
// Easter Island Winter Time Zone offset (-5*60*60)
$utcm5_date = array ();
$utcm5_date [ 0 ] = $standard_date ;
$unixtime_utcm5 = $standard_date - 18000 ;
$utcm5_date [ " seconds " ] = gmdate ( " s " , $unixtime_utcm5 );
$utcm5_date [ " minutes " ] = gmdate ( " i " , $unixtime_utcm5 );
$utcm5_date [ " hours " ] = gmdate ( " G " , $unixtime_utcm5 );
$utcm5_date [ " mday " ] = gmdate ( " j " , $unixtime_utcm5 );
$utcm5_date [ " wday " ] = gmdate ( " w " , $unixtime_utcm5 );
$utcm5_date [ " mon " ] = gmdate ( " n " , $unixtime_utcm5 );
$utcm5_date [ " year " ] = gmdate ( " Y " , $unixtime_utcm5 );
$utcm5_date [ " yday " ] = gmdate ( " z " , $unixtime_utcm5 );
$utcm5_date [ " weekday " ] = gmdate ( " l " , $unixtime_utcm5 );
$utcm5_date [ " month " ] = gmdate ( " F " , $unixtime_utcm5 );
return $utcm5_date ;
}
2017-03-18 08:20:33 +03:00
class Discordian_Date_Widget extends WP_Widget {
2026-02-02 01:21:07 +03:00
function __construct () {
$widget_ops = array ( 'classname' => 'discordian_date_func' , 'name' => 'Discordian Date Widget' , 'description' => 'Display the current date according to the Discordian Calendar.' );
2017-03-18 08:20:33 +03:00
$control_ops = array ( 'width' => 200 , 'height' => 120 );
2026-02-02 01:21:07 +03:00
parent :: __construct ( 'Discordian_Date_Widget' , 'Discordian Date Widget' , $widget_ops );
2017-03-18 08:20:33 +03:00
}
function widget ( $args , $instance ) {
$now = getdate ();
$yday = $now [ " yday " ];
$mon = $now [ " mon " ];
$mday = $now [ " mday " ];
$dseason = ( int )( $yday / 73 );
2020-03-13 09:10:29 +01:00
if ( $now [ " year " ] % 4 == 0 && $now [ " year " ] % 100 != 0 || $now [ " year " ] % 400 == 0 )
if ( $now [ " yday " ] > 59 ) $yday = $now [ " yday " ] - 1 ;
2017-03-18 08:20:33 +03:00
$dday = ( $yday - ( 73 * $dseason )) + 1 ;
$a_holiday = array ( " Mungday " , " Mojoday " , " Syaday " , " Zaraday " , " Maladay " );
$s_holiday = array ( " Chaoflux " , " Discoflux " , " Confuflux " , " Bureflux " , " Afflux " );
2020-06-18 12:01:08 +03:00
$m_holiday = array ( " Chaomas " , " Discomas " , " Confumas " , " Buremas " , " Afmas " );
$t_holiday = array ( " Chaosloth " , " Discosloth " , " Confusloth " , " Buresloth " , " Afsloth " );
$e_holiday = array ( " Mungeye " , " Mojeye " , " Syadeye " , " Zareye " , " Maleye " );
$holiday = " " ;
2017-03-18 08:20:33 +03:00
if ( $dday == 5 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Apostle Day, " . $a_holiday [ $dseason ] . " . " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dday == 23 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Synaptyclypse Day, " . $m_holiday [ $dseason ] . " . " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dday == 27 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Sloth Day, " . $t_holiday [ $dseason ] . " . " ;
2020-03-01 12:46:42 +03:00
} elseif ( $dday == 50 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Flux Day, " . $s_holiday [ $dseason ] . " . " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dday == 73 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Eye Day, " . $e_holiday [ $dseason ] . " . " ;
2020-03-01 12:46:42 +03:00
} elseif ( $mon == 2 && $mday == 29 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate St. Tib's Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 0 && $dday == 8 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Death of Emperor Norton. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 0 && $dday == 10 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Backwards/Binary Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 0 && $dday == 11 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate RAW Day. " ;
2020-03-13 09:10:29 +01:00
} elseif ( $dseason == 0 && $dday == 14 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Golden Apple Presentation Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 0 && $dday == 17 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Joshmas. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 0 && $dday == 18 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Pat Pineapple Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 0 && $dday == 21 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Hug Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 0 && $dday == 26 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate yaD sdrawkcaB, Traditional. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 0 && $dday == 37 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate Aaron Burr's Birthday. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 0 && $dday == 51 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Pet Loving Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 0 && $dday == 69 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate Chicken Head Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 0 && $dday == 72 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Daytime. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 1 && $dday == 4 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate Grover Cleveland's Birthday. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 1 && $dday == 11 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Discordians for Jesus/Love Your Neighbor Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 1 && $dday == 18 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate Fool's Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 1 && $dday == 19 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate St. John the Blasphemist's Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 1 && $dday == 34 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Omarmas. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 1 && $dday == 43 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Universal Ordination Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 1 && $dday == 68 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Mal-2mas. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 1 && $dday == 70 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate Day of the Elppin/Defenestration of Prague Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 1 && $dday == 72 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Towel Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 2 && $dday == 26 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate Imaginary Friend. " ;
2020-03-01 12:46:42 +03:00
} elseif ( $dseason == 2 && $dday == 28 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate St. George's Day. " ;
2020-03-01 12:46:42 +03:00
} elseif ( $dseason == 2 && $dday == 30 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Zoog Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 2 && $dday == 37 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate Mid-Year's Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 2 && $dday == 40 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate X-Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 2 && $dday == 55 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Mal-2 Day. " ;
2020-03-01 12:46:42 +03:00
} elseif ( $dseason == 2 && $dday == 57 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate John Dillinger Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 3 && $dday == 3 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Multiversal Underwear Day. " ;
2024-06-12 13:02:39 +03:00
} elseif ( $dseason == 3 && $dday == 10 ) {
$holiday = " Celebrate St. Cecil Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 3 && $dday == 18 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate Spanking Fest. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 3 && $dday == 33 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate Pussyfoot Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 3 && $dday == 37 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate Mass of Planet Eris/Mass of Eristotle. " ;
2020-03-01 12:46:42 +03:00
} elseif ( $dseason == 3 && $dday == 39 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate St. Mammes's Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 3 && $dday == 41 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Emperor Norton Proclamation Day. " ;
2024-06-12 13:02:39 +03:00
} elseif ( $dseason == 3 && $dday == 55 ) {
$holiday = " Celebrate Feast of St. John Blasphemist. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 3 && $dday == 57 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Shamlicht Kids Club Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 3 && $dday == 59 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate Gonculator Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 3 && $dday == 60 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Mad Hatter Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 3 && $dday == 66 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Habeas Corpus Remembrance Day. " ;
2024-06-12 13:02:39 +03:00
} elseif ( $dseason == 4 && $dday == 17 ) {
$holiday = " Celebrate Pope Night. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 4 && $dday == 28 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Ek-sen-triks CluborGuild Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 4 && $dday == 37 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate 537 Day. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 4 && $dday == 40 ) {
2024-06-12 13:02:39 +03:00
$holiday = " Celebrate Omar's Day. " ;
2020-03-13 09:10:29 +01:00
} elseif ( $dseason == 4 && $dday == 43 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Day D. " ;
2017-03-18 08:20:33 +03:00
} elseif ( $dseason == 4 && $dday == 46 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Hug Day II. " ;
2024-06-12 13:02:39 +03:00
} elseif ( $dseason == 4 && $dday == 56 ) {
$holiday = " Celebrate Agnostica. " ;
2020-03-01 12:46:42 +03:00
} elseif ( $dseason == 4 && $dday == 65 ) {
2020-06-18 12:01:08 +03:00
$holiday = " Celebrate Circlemas. " ;
2017-03-18 08:20:33 +03:00
}
extract ( $args );
$title = $instance [ 'title' ];
2026-02-02 01:21:07 +03:00
$body = apply_filters ( 'widget_text' , isset ( $instance [ 'body' ]));
2017-03-18 08:20:33 +03:00
ob_start ();
2024-06-12 13:57:10 +03:00
echo " <div class= \" discordian_date_func \" style= \" width:100%;text-align:center;font-size:18px;line-height:36px;padding-top:40px;padding-bottom:40px; \" > " ;
2024-06-12 15:29:31 +03:00
if ( get_option ( 'dtime_widget' )) {
if ( get_option ( 'dtime_convert' ))
echo " <script type= \" text/javascript \" >var eastertime = true;</script> " ;
if ( get_option ( 'dtime_widgetsec' ))
echo " <script type= \" text/javascript \" >var widgetsec = true;</script> " ;
echo " <h1 style= \" font-size: 255% \" id= \" dtime \" ></h1> " ;
}
2024-06-12 13:57:10 +03:00
echo " Today is " ;
2026-02-02 01:21:07 +03:00
echo get_ddate ( isset ( $content ), isset ( $format ), " now " ) . " . " ;
2020-06-18 12:01:08 +03:00
if ( $holiday ) echo " <br><b> " . $holiday . " </b> " ;
2017-03-18 08:20:33 +03:00
echo " </div> " ;
$body2 = ob_get_contents ();
ob_end_clean ();
if ( ! empty ( $title2 ) ||! empty ( $body2 )) echo $before_widget ;
if ( ! empty ( $title2 )) echo $before_title , $title2 , $after_title ;
if ( ! empty ( $body2 )) echo $body2 ;
if ( ! empty ( $title2 ) ||! empty ( $body2 )) echo $after_widget ;
}
function update ( $new_instance , $old_instance ) {
return $new_instance ;
}
function form ( $instance ) {
2026-02-02 01:21:07 +03:00
$title = isset ( $instance [ 'title' ]);
2017-03-18 08:20:33 +03:00
$title_id = $this -> get_field_id ( 'title' );
$title_name = $this -> get_field_name ( 'title' );
?>
< p >
< label for = " <?php echo $title_id ; ?> " >< strong > Title :</ strong ></ label >
< input class = " widefat " id = " <?php echo $title_id ; ?> " name = " <?php echo $title_name ; ?> "
type = " text " value = " <?php echo esc_attr( $title ); ?> " />
</ p >
2017-03-19 14:18:04 +03:00
< ? php
2017-03-18 08:20:33 +03:00
}
}
2019-08-04 22:00:05 +00:00
function get_the_ddate_post ( $content , $format = null ) {
2017-03-18 08:20:33 +03:00
return get_ddate ( $content , $format , " get_the_date " ); }
2020-04-04 11:52:59 +03:00
function get_the_dtime_post ( $content , $format = null ) {
return get_ddate ( $content , $format , " get_the_time " ); }
2019-08-04 22:00:05 +00:00
function get_the_ddate_comment ( $content , $format = null ) {
2017-03-18 08:20:33 +03:00
return get_ddate ( $content , $format , " get_comment_date " ); }
2020-04-04 11:52:59 +03:00
function get_the_dtime_comment ( $content , $format = null ) {
return get_ddate ( $content , $format , " get_comment_time " ); }
2017-03-18 08:20:33 +03:00
function register_ddatefunc_widget () {
register_widget ( 'Discordian_Date_Widget' );
}
2017-03-19 14:18:04 +03:00
function today_ddate () {
2017-03-18 08:20:33 +03:00
echo return_today_hebDate ();
}
function return_today_ddate () {
return get_ddate ( $content , $format , " now " );
}
2017-03-19 14:18:04 +03:00
$settings_name = " Discordian Date Function Settings " ;
function ddatefunc_add_admin () {
global $settings_name ;
add_options_page ( __ ( 'Settings' ) . ': ' . $settings_name , $settings_name , 'edit_themes' , basename ( __FILE__ ), 'ddatefunc_admin' );
}
function ddatefunc_admin () {
global $settings_name ;
?>
< div class = " wrap " >
< ? php
screen_icon ();
echo '<h2>' . $settings_name . '</h2>' ;
if ( isset ( $_POST [ 'save' ])) {
update_option ( 'ddatefunc_string' , stripslashes ( $_POST [ 'textfield' ]));
2020-04-04 11:52:59 +03:00
if ( isset ( $_POST [ 'ddatefunc_change_checkbox' ]))
2017-03-19 14:18:04 +03:00
update_option ( 'ddatefunc_change' , " 1 " );
else
update_option ( 'ddatefunc_change' , " 0 " );
2020-04-04 11:52:59 +03:00
if ( isset ( $_POST [ 'dtimefunc_change_checkbox' ]))
update_option ( 'dtimefunc_change' , " 1 " );
else
update_option ( 'dtimefunc_change' , " 0 " );
if ( isset ( $_POST [ 'dtime_convert_checkbox' ]))
update_option ( 'dtime_convert' , " 1 " );
else
update_option ( 'dtime_convert' , " 0 " );
2022-07-17 19:33:08 +03:00
if ( isset ( $_POST [ 'dtime_widget_checkbox' ]))
update_option ( 'dtime_widget' , " 1 " );
else
update_option ( 'dtime_widget' , " 0 " );
2024-06-12 15:29:31 +03:00
if ( isset ( $_POST [ 'dtime_widgetsec_checkbox' ]))
update_option ( 'dtime_widgetsec' , " 1 " );
else
update_option ( 'dtime_widgetsec' , " 0 " );
2026-02-02 01:21:07 +03:00
if ( isset ( $_POST [ 'ee_widget_checkbox' ]))
update_option ( 'ee_widget' , " 1 " );
else
update_option ( 'ee_widget' , " 0 " );
2017-03-19 14:18:04 +03:00
echo '<div id="setting-error-settings_updated" class="updated settings-error"><p><b>' . __ ( 'Settings saved.' ) . '</b></p></div>' ;
}
?>
< form method = " post " >
< table class = " form-table " >
< tr valign = " top " >
< th scope = " row " > Date string :</ th >
< td >
< input name = " textfield " class = " regular-text " type = " text " value = " <?php echo get_option('ddatefunc_string'); ?> " >
</ td >
</ tr >
< tr valign = " top " >
< th scope = " row " > Legend :</ th >
< td >
2026-02-02 01:21:07 +03:00
< b >% EY </ b > - Erisian era year ( example : 180 ) < br >
2017-03-19 14:18:04 +03:00
< b >% DY </ b > - Discordian yold ( example : 3180 ) < br >
2026-02-02 01:21:07 +03:00
< b >% DS </ b > - Discordian season name ( example : Chaos ) < br >
< b >% ES </ b > - Erisian season number ( example : 1 ) < br >
2017-03-19 14:18:04 +03:00
< b >% DD </ b > - Discordian season day ( example : 5 th ) < br >
< b >% DC </ b > - Clear erisian day number ( example : 5 ) < br >
< b >% DW </ b > - Discordian week day ( example : Setting Orange ) < br >
< b >% GY </ b > - Gregorian year ( example : 2014 ) < br >
< b >% GM </ b > - Gregorian month ( example : January ) < br >
< b >% GN </ b > - Gregorian month number ( example : 1 ) < br >
< b >% GD </ b > - Gregorian month day ( example : 5 ) < br >
< b >% GW </ b > - Gregorian weekday ( example : Friday ) < br >
2026-02-02 01:21:07 +03:00
< b >% DT </ b > - Erisian ( decimal ) time ( example : 5 : 67 ) < br >
< b >% CT </ b > - Christian time ( example : 18 : 37 ) < br >
< b >% UT </ b > - Unix time ( example : 1388947033 ) < br >
2017-03-19 14:18:04 +03:00
< br >
Examples < br >
< br >
2026-02-02 01:21:07 +03:00
< b >% EY .% ES .% DC % DT ee ( unittime : % UT ) </ b > < i > ( returns : 180.1 . 5 5 : 67 ee ( unixtime : 1388947033 )) </ i ></ br >
2017-03-19 14:18:04 +03:00
< br >
2026-02-02 01:21:07 +03:00
< b >% DW , the % DD day of % DS , in the yold % DY </ b > < i > ( returns : Setting Orange , the 5 th day of Chaos , in the yold 3180 ) </ i >< br >
< br >
< b >% DC % DS , % DY ( % GN .% GN .% GY ) </ b > < i > ( returns : 5 Chaos , 3180 ( 5.1 . 2014 )) </ i ></ br >
2017-03-19 14:18:04 +03:00
</ td >
</ tr >
< tr valign = " top " >
2020-04-04 11:52:59 +03:00
< th scope = " row " > Convert all post and comment dates :</ th >
2017-03-19 14:18:04 +03:00
< td >
< fieldset >
< legend class = " screen-reader-text " >
< span > Convert to Discordian dates </ span >
</ legend >
< label for = " users_can_register " >
2020-04-04 11:52:59 +03:00
< input name = " ddatefunc_change_checkbox " id = " users_can_register " type = " checkbox " value = " 1 " < ? php if ( get_option ( 'ddatefunc_change' ) == 1 ) { echo 'checked="checked"' ; } ?> >
</ label >
</ fieldset >
</ td >
</ tr >
< tr valign = " top " >
< th scope = " row " > Convert Christian time to Discordian ( decimal ) time :</ th >
< td >
< fieldset >
< legend class = " screen-reader-text " >
< span > Convert to Erisian time </ span >
</ legend >
< label for = " users_can_register " >
< input name = " dtimefunc_change_checkbox " id = " users_can_register " type = " checkbox " value = " 1 " < ? php if ( get_option ( 'dtimefunc_change' ) == 1 ) { echo 'checked="checked"' ; } ?> >
</ label >
</ fieldset >
</ td >
</ tr >
< tr valign = " top " >
2024-06-12 13:57:10 +03:00
< th scope = " row " > Use Erisian start of the day - < a href = " https://discordia.fandom.com/wiki/Erisian_Time " > starts 5 Christian hours later than the day in London </ a >:</ th >
2020-04-04 11:52:59 +03:00
< td >
< fieldset >
< legend class = " screen-reader-text " >
< span > Erisian start of the day </ span >
</ legend >
< label for = " users_can_register " >
< input name = " dtime_convert_checkbox " id = " users_can_register " type = " checkbox " value = " 1 " < ? php if ( get_option ( 'dtime_convert' ) == 1 ) { echo 'checked="checked"' ; } ?> >
2017-03-19 14:18:04 +03:00
</ label >
</ fieldset >
</ td >
</ tr >
2022-07-17 19:33:08 +03:00
< tr valign = " top " >
< th scope = " row " > Show Erisian time clock in the widget :</ th >
< td >
< fieldset >
< legend class = " screen-reader-text " >
< span > Erisian time in the widget </ span >
</ legend >
< label for = " users_can_register " >
< input name = " dtime_widget_checkbox " id = " users_can_register " type = " checkbox " value = " 1 " < ? php if ( get_option ( 'dtime_widget' ) == 1 ) { echo 'checked="checked"' ; } ?> >
</ label >
</ fieldset >
</ td >
</ tr >
2024-06-12 15:29:31 +03:00
< tr valign = " top " >
< th scope = " row " > Display seconds in erisian time clock in the widget :</ th >
< td >
< fieldset >
< legend class = " screen-reader-text " >
< span > Seconds in the widget </ span >
</ legend >
< label for = " users_can_register " >
< input name = " dtime_widgetsec_checkbox " id = " users_can_register " type = " checkbox " value = " 1 " < ? php if ( get_option ( 'dtime_widgetsec' ) == 1 ) { echo 'checked="checked"' ; } ?> >
</ label >
</ fieldset >
</ td >
</ tr >
2026-02-02 01:21:07 +03:00
< tr valign = " top " >
< th scope = " row " > Use the erisian era in the widget :</ th >
< td >
< fieldset >
< legend class = " screen-reader-text " >
< span > Erisian era </ span >
</ legend >
< label for = " users_can_register " >
< input name = " ee_widget_checkbox " id = " users_can_register " type = " checkbox " value = " 1 " < ? php if ( get_option ( 'ee_widget' ) == 1 ) { echo 'checked="checked"' ; } ?> >
</ label >
</ fieldset >
</ td >
</ tr >
2017-03-19 14:18:04 +03:00
</ table >
< div class = " submit " >
< input name = " save " type = " submit " class = " button-primary " value = " <?php echo __('Save Cganges'); ?> " />
</ div >
</ form >
</ div >
< ? php
}
2022-07-17 19:33:08 +03:00
function ddatefunc_settings ( $actions , $plugin_file ) {
if ( false === strpos ( $plugin_file , basename ( __FILE__ )))
2017-03-19 14:18:04 +03:00
return $actions ;
$settings_link = '<a href="options-general.php?page=ddatefunc.php' . '">Settings</a>' ;
2022-07-17 19:33:08 +03:00
array_unshift ( $actions , $settings_link );
2017-03-19 14:18:04 +03:00
return $actions ;
}
function ddatefunc_deinstall () {
delete_option ( 'ddatefunc_string' );
delete_option ( 'ddatefunc_change' );
2020-04-04 11:52:59 +03:00
delete_option ( 'dtimefunc_change' );
delete_option ( 'dtime_convert' );
2022-07-17 19:33:08 +03:00
delete_option ( 'dtime_widget' );
2024-06-12 15:29:31 +03:00
delete_option ( 'dtime_widgetsec' );
2026-02-02 01:21:07 +03:00
delete_option ( 'ee_widget' );
2017-03-19 14:18:04 +03:00
}
2022-07-17 19:33:08 +03:00
function ddatefunc_init () {
wp_enqueue_script ( 'dtime' , plugins_url ( '/dtime.js' , __FILE__ ));
}
add_shortcode ( 'today_ddate' , 'return_today_ddate' );
add_action ( 'widgets_init' , 'register_ddatefunc_widget' );
add_option ( 'ddatefunc_string' , '%DD day of %DS, in the yold %DY' );
add_option ( 'ddatefunc_change' , '1' );
add_option ( 'dtimefunc_change' , '1' );
add_option ( 'dtime_convert' , '1' );
add_option ( 'dtime_widget' , '1' );
2024-06-12 15:29:31 +03:00
add_option ( 'dtime_widgetsec' , '1' );
2026-02-02 01:21:07 +03:00
add_option ( 'ee_widget' , '1' );
2022-07-17 19:33:08 +03:00
add_filter ( 'plugin_action_links' , 'ddatefunc_settings' , 10 , 2 );
add_action ( 'admin_menu' , 'ddatefunc_add_admin' );
2017-03-19 14:18:04 +03:00
2022-07-17 19:33:08 +03:00
if ( get_option ( 'ddatefunc_change' )) {
add_filter ( 'get_the_date' , 'get_the_ddate_post' );
add_filter ( 'get_comment_date' , 'get_the_ddate_comment' );
2017-03-19 14:18:04 +03:00
}
2022-07-17 19:33:08 +03:00
if ( get_option ( 'dtimefunc_change' )) {
add_filter ( 'get_the_time' , 'get_the_dtime_post' );
add_filter ( 'get_comment_time' , 'get_the_dtime_comment' );
2020-04-04 11:52:59 +03:00
}
2022-07-17 19:33:08 +03:00
if ( get_option ( 'dtime_widget' ))
add_action ( 'wp_enqueue_scripts' , 'ddatefunc_init' );
2017-03-19 14:18:04 +03:00
if ( function_exists ( 'register_uninstall_hook' ))
2020-03-01 12:46:42 +03:00
register_uninstall_hook ( __FILE__ , 'ddatefunc_deinstall' );