diff --git a/ddatefunc.php b/ddatefunc.php index 00db1ed..18d1675 100644 --- a/ddatefunc.php +++ b/ddatefunc.php @@ -2,8 +2,8 @@ /* Plugin Name: Discordian Date Function Plugin URI: https://is3.soundragon.su/discordian-date-function -Description: Convert dates in Wordpress to Discordian dates. Also, this plugin provides shortcode and widget used to display the current erisian date with notification of 70 holydays. Based on the Discordian Date plugin by Dan Johnson. -Version: 0.5 +Description: Convert dates in Wordpress to customizable Discordian dates. Also, this plugin provides shortcode and widget used to display the current erisian date with notification of 70 holydays. Based on the Discordian Date plugin by Dan Johnson. +Version: 0.55 Author: ivan zlax Author URI: https://is3.soundragon.su/about */ @@ -37,6 +37,7 @@ function get_ddate($content, $format = "", $originalRequest = null) { $dseason=(int)($yday/73); $name_season=$season_list[$dseason]; $dday=($yday-(73*$dseason))+1; + $clear_dday=$dday; $suff=$dday%10; switch ($suff) { @@ -54,8 +55,34 @@ function get_ddate($content, $format = "", $originalRequest = null) { } $dweekday=$day_list[($yday%5)]; - $ddate=$dweekday.", the ".$dday." day of ".$name_season.", in the yold ".$dyear; + if ($originalRequest == "now") { + $ddate=$dweekday.", the ".$dday." day of ".$name_season.", in the yold ".$dyear; + } 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'; + $replacements = array(); + $replacements[0] = $dyear; + $replacements[1] = $name_season; + $replacements[2] = $dday; + $replacements[3] = $clear_dday; + $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"]; + $ddate = str_replace($patterns, $replacements, get_option('ddatefunc_string')); + } return $ddate; } @@ -77,12 +104,15 @@ class Discordian_Date_Widget extends WP_Widget { $dday=($yday-(73*$dseason))+1; $a_holiday=array("Mungday", "Mojoday", "Syaday", "Zaraday", "Maladay"); $s_holiday=array("Chaoflux", "Discoflux", "Confuflux", "Bureflux", "Afflux"); + $m_holyday=array("Chaomas", "Discomas", "Confumas", "Buremas", "Afmas"); + $t_holyday=array("Chaosloth", "Discosloth", "Confusloth", "Buresloth", "Afsloth"); + $e_holyday=array("Mungeye", "Mojeye", "Syadeye", "Zareye", "Maleye"); $holyday=""; if ($dday==5) { - $holyday = " Celebrate ".$a_holiday[$dseason]."."; + $holyday = " Celebrate Apostle Day, ".$a_holiday[$dseason]."."; } elseif ($dday==50) { - $holyday = " Celebrate ".$s_holiday[$dseason]."."; + $holyday = " Celebrate Flux Day, ".$s_holiday[$dseason]."."; } elseif ($mon==2 && $mday==29) { $holyday = " Celebrate St. Tib's Day."; } elseif ($dseason==2 && $dday==28) { @@ -92,11 +122,11 @@ class Discordian_Date_Widget extends WP_Widget { } elseif ($dseason==4 && $dday==65) { $holyday = " Celebrate Circlemas."; } elseif ($dday==23) { - $holyday = " Celebrate Synaptyclypse Day."; + $holyday = " Celebrate Synaptyclypse Day, ".$m_holiday[$dseason]."."; } elseif ($dday==27) { - $holyday = " Celebrate Sloth Day."; + $holyday = " Celebrate Sloth Day, ".$t_holiday[$dseason]."."; } elseif ($dday==73) { - $holyday = " Celebrate Eye Day."; + $holyday = " Celebrate Eye Day, ".$e_holiday[$dseason]."."; } elseif ($dseason==0 && $dday==8) { $holyday = " Celebrate Death of Emperor Norton."; } elseif ($dseason==0 && $dday==10) { @@ -222,21 +252,21 @@ class Discordian_Date_Widget extends WP_Widget {

- +
+'.$settings_name.''; + if (isset($_POST['save'])) { + update_option('ddatefunc_string', stripslashes($_POST['textfield'])); + if (isset($_POST['checkbox'])) + update_option('ddatefunc_change', "1"); + else + update_option('ddatefunc_change', "0"); + echo '

'.__('Settings saved.').'

'; + } +?> +
+ + + + + + + + + + + + + +
Date string: + +
Legend: +%DY - Discordian yold (example: 3180)
+%DS - Erisian season name (example: Chaos)
+%DD - Discordian season day (example: 5th)
+%DC - Clear erisian day number (example: 5)
+%DW - Discordian week day (example: Setting Orange)
+%GY - Gregorian year (example: 2014)
+%GM - Gregorian month (example: January)
+%GN - Gregorian month number (example: 1)
+%GD - Gregorian month day (example: 5)
+%GW - Gregorian weekday (example: Friday)
+
+Examples
+
+%DW, the %DD day of %DS, in the yold %DY
returns:
Setting Orange, the 5th day of Chaos, in the yold 3180
+
+%DC %DS, %DY (%GN.%GN.%GY)
returns:
5 Chaos, 3180 (5.1.2014)
+
Convert all post and comments dates: +
+ + Convert to Discordian dates + + +
+
+
+ +
+
+
+Settings'; + array_unshift( $actions, $settings_link ); + return $actions; +} + +function ddatefunc_deinstall() { + delete_option('ddatefunc_string'); + delete_option('ddatefunc_change'); +} + +add_shortcode( 'today_ddate', 'return_today_ddate' ); add_action( 'widgets_init', 'register_ddatefunc_widget' ); -add_filter( 'get_the_date','get_the_ddate_post' ); -add_filter( 'get_comment_date','get_the_ddate_comment' ); \ No newline at end of file +add_option( 'ddatefunc_string', '%DD day of %DS, in the yold %DY'); +add_option( 'ddatefunc_change', '1'); + +add_filter( 'plugin_action_links', 'ddatefunc_settings', 10, 2 ); +add_action( 'admin_menu', 'ddatefunc_add_admin' ); + +if ( get_option('ddatefunc_change') == '1' ) { + add_filter( 'get_the_date','get_the_ddate_post' ); + add_filter( 'get_comment_date','get_the_ddate_comment' ); +} + +if (function_exists('register_uninstall_hook')) + register_uninstall_hook(__FILE__, 'ddatefunc_deinstall'); \ No newline at end of file diff --git a/readme.txt b/readme.txt index 5195ebf..59c2dd9 100644 --- a/readme.txt +++ b/readme.txt @@ -13,9 +13,9 @@ Also provides shortcode and widget which displays the current date according to == Description == -This plugin allows WordPress to easily show Erisian dates instead of the standard Gregorian dates. No theme changes are required. +This plugin allows WordPress to easily show customizable Erisian dates instead of the standard Gregorian dates. No theme changes are required. -The Discordian Date plugin provides a widget which will display the current date according to the [Discordian calendar](http://en.wikipedia.org/wiki/Discordian_calendar). This functional based on the Discordian Date plugin by Dan Johnson. +The Discordian Date Function plugin provides a widget which will display the current date according to the [Discordian calendar](http://en.wikipedia.org/wiki/Discordian_calendar). This functional based on the Discordian Date plugin by Dan Johnson. And you can add the shortcode [today_ddate] in posts or pages for show the Discordian date of today. @@ -24,6 +24,7 @@ And you can add the shortcode [today_ddate] in posts or pages for show the Disco 1. Extract the files from archive. 1. Upload the folder ddatefunc and its contents to the /wp-content/plugins/ directory. 1. Activate the plugin through the 'Plugins' menu in WordPress. +1. Press 'Settings' for customize date string. 1. If you want to add widget: position the widget in an available area on your pages using the Widgets section of your WordPress administration control panel. 1. Use the widget options to give the widget any title you'd like. 1. (Optional) if you want to add the erisian date of today than you need to add where you want. @@ -40,10 +41,19 @@ Feel free to ask any questions about this plugin at the [Discordian Date Functio == Changelog == += 0.55 = +*Release Date - 5th day of Discord, 3183* + +* Fixed names of some Whollydays. +* Add settings page. +* Add customizable date string. + = 0.5 = +*Release Date - 2nd day of Discord, 3183* + * First public release. == Upgrade Notice == -= 0.5 = -This version is the first public release. += 0.55 = +This version is actual.