Add project

This commit is contained in:
feder 2017-03-18 08:20:33 +03:00
commit 76d39c002c
4 changed files with 312 additions and 0 deletions

13
README.md Normal file
View File

@ -0,0 +1,13 @@
Discordian Date Function
under DWTWL 2.5 license: https://soundragon.su/license/license.html
https://wordpress.org/plugins/discordian-date-function/
This plugin allows WordPress to easily show Erisian dates instead of the standard Gregorian dates. No theme changes are required.
This functional based on the Discordian Date plugin by Dan Johnson.
Also provides a widget which displays the current date according to the Discordian calendar, with notification of 70 holydays.
And you can add the shortcode [todаy_ddate] in posts or pages for show the Discordian date of today.

250
ddatefunc.php Normal file
View File

@ -0,0 +1,250 @@
<?php
/*
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
Author: ivan zlax
Author URI: https://is3.soundragon.su/about
*/
function get_ddate($content, $format = "", $originalRequest = null) {
/*
Based on: http://www.dexterityunlimited.com/wordpress-plugins/discordian-date/ by Dan Johnson
*/
$season_list = array("Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath");
$day_list = array("Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange");
switch ($originalRequest) {
case "get_the_date":
$post = get_post( $format );
$standard_date = getdate (mysql2date( 'U', $post->post_date ));
break;
case "get_comment_date":
$comment = get_comment( $format );
$standard_date = getdate (mysql2date( 'U', $comment->comment_date ));
break;
case "now":
$standard_date = getdate();
}
$dyear=$standard_date["year"]+1166;
$yday=$standard_date["yday"];
$mon=$standard_date["mon"];
$mday=$standard_date["mday"];
$dseason=(int)($yday/73);
$name_season=$season_list[$dseason];
$dday=($yday-(73*$dseason))+1;
$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)];
$ddate=$dweekday.", the ".$dday." day of ".$name_season.", in the yold ".$dyear;
return $ddate;
}
class Discordian_Date_Widget extends WP_Widget {
function Discordian_Date_Widget() {
$widget_ops = array('classname' => 'discordian_date_func', 'description' => 'Display the current date according to the Discordian Calendar.');
$control_ops = array('width' => 200, 'height' => 120);
$this->WP_Widget('discordian_date_func', 'Discordian Date Widget', $widget_ops, $control_ops);
}
function widget($args, $instance) {
$now = getdate();
$yday=$now["yday"];
$mon=$now["mon"];
$mday=$now["mday"];
$dseason=(int)($yday/73);
$dday=($yday-(73*$dseason))+1;
$a_holiday=array("Mungday", "Mojoday", "Syaday", "Zaraday", "Maladay");
$s_holiday=array("Chaoflux", "Discoflux", "Confuflux", "Bureflux", "Afflux");
$holyday="";
if ($dday==5) {
$holyday = " Celebrate ".$a_holiday[$dseason].".";
} elseif ($dday==50) {
$holyday = " Celebrate ".$s_holiday[$dseason].".";
} elseif ($mon==2 && $mday==29) {
$holyday = " Celebrate St. Tib's Day.";
} elseif ($dseason==2 && $dday==28) {
$holyday = " Celebrate St. Georges Day.";
} elseif ($dseason==2 && $dday==57) {
$holyday = " Celebrate John Dillinger Day.";
} elseif ($dseason==4 && $dday==65) {
$holyday = " Celebrate Circlemas.";
} elseif ($dday==23) {
$holyday = " Celebrate Synaptyclypse Day.";
} elseif ($dday==27) {
$holyday = " Celebrate Sloth Day.";
} elseif ($dday==73) {
$holyday = " Celebrate Eye Day.";
} elseif ($dseason==0 && $dday==8) {
$holyday = " Celebrate Death of Emperor Norton.";
} elseif ($dseason==0 && $dday==10) {
$holyday = " Celebrate Backwards Day, Reformed / Binary Day.";
} elseif ($dseason==0 && $dday==11) {
$holyday = " Celebrate RAW Day.";
} elseif ($dseason==0 && $dday==17) {
$holyday = " Celebrate Joshmas.";
} elseif ($dseason==0 && $dday==18) {
$holyday = " Celebrate Pat Pineapple Day.";
} elseif ($dseason==0 && $dday==21) {
$holyday = " Celebrate Hug Day.";
} elseif ($dseason==0 && $dday==26) {
$holyday = " Celebrate Backwards Day (Traditional).";
} elseif ($dseason==0 && $dday==37) {
$holyday = " Celebrate Aaron Burrs Birthday.";
} elseif ($dseason==0 && $dday==49) {
$holyday = " Celebrate The Mary Day.";
} elseif ($dseason==0 && $dday==51) {
$holyday = " Celebrate Pet Loving Day.";
} elseif ($dseason==0 && $dday==69) {
$holyday = " Celebrate Head Chicken/Chicken Head Day.";
} elseif ($dseason==0 && $dday==72) {
$holyday = " Celebrate Daytime.";
} elseif ($dseason==1 && $dday==4) {
$holyday = " Celebrate Grover Clevelands Birthday.";
} elseif ($dseason==1 && $dday==11) {
$holyday = " Celebrate Discordians for Jesus/Love Your Neighbor Day.";
} elseif ($dseason==1 && $dday==18) {
$holyday = " Celebrate April Fools Day.";
} elseif ($dseason==1 && $dday==19) {
$holyday = " Celebrate St John the Blasphemists Day.";
} elseif ($dseason==1 && $dday==23) {
$holyday = " Celebrate Jake Day.";
} elseif ($dseason==1 && $dday==34) {
$holyday = " Celebrate Omarmas.";
} elseif ($dseason==1 && $dday==43) {
$holyday = " Celebrate Universal Ordination Day.";
} elseif ($dseason==1 && $dday==68) {
$holyday = " Celebrate Mal-2mas.";
} elseif ($dseason==1 && $dday==70) {
$holyday = " Celebrate Jake Day Jr. (DJ)/Day of the Elppin.";
} elseif ($dseason==1 && $dday==72) {
$holyday = " Celebrate Towel Day.";
} elseif ($dseason==2 && $dday==26) {
$holyday = " Celebrate Imaginary Friend/Captain Tuttle Day.";
} elseif ($dseason==2 && $dday==37) {
$holyday = " Celebrate Mid-Years Day.";
} elseif ($dseason==2 && $dday==40) {
$holyday = " Celebrate X-Day.";
} elseif ($dseason==2 && $dday==55) {
$holyday = " Celebrate Mal-2 Day.";
} elseif ($dseason==3 && $dday==3) {
$holyday = " Celebrate Multiversal Underwear Day.";
} elseif ($dseason==3 && $dday==18) {
$holyday = " Celebrate Festival of Hanky-Panky Spankies.";
} elseif ($dseason==3 && $dday==33) {
$holyday = " Celebrate Cat Dancing & Foot Fetish Day aka Pussyfoot Day.";
} elseif ($dseason==3 && $dday==37) {
$holyday = " Celebrate Mass of Planet Eris/Eristotle.";
} elseif ($dseason==3 && $dday==41) {
$holyday = " Celebrate Emperor Norton Proclamation Day.";
} elseif ($dseason==3 && $dday==57) {
$holyday = " Celebrate Shamlicht Kids Club Day.";
} elseif ($dseason==3 && $dday==59) {
$holyday = " Celebrate Gonkulator Day (Gonculator Day).";
} elseif ($dseason==3 && $dday==60) {
$holyday = " Celebrate Mad Hatter Day.";
} elseif ($dseason==3 && $dday==66) {
$holyday = " Celebrate Habeas Corpus Remembrance Day.";
} elseif ($dseason==4 && $dday==28) {
$holyday = " Celebrate Ek-sen-triks CluborGuild Day.";
} elseif ($dseason==4 && $dday==36) {
$holyday = " Celebrate Spanking Fest.";
} elseif ($dseason==4 && $dday==37) {
$holyday = " Celebrate 537 Day, sometimes Turkey Day.";
} elseif ($dseason==4 && $dday==40) {
$holyday = " Celebrate Omars Day.";
} elseif ($dseason==4 && $dday==46) {
$holyday = " Celebrate Hug Day II.";
} elseif ($dseason==4 && $dday==67) {
$holyday = " Celebrate Santa Claus Day.";
} elseif ($dseason==4 && $dday==72) {
$holyday = " Celebrate New Years Eve Eve.";
}
extract($args);
$title = $instance['title'];
$body = apply_filters('widget_text', $instance['body']);
if (!empty($title)) {
ob_start();
eval(" ?>$title<?php ");
$title2 = ob_get_contents();
ob_end_clean();
}
ob_start();
echo "<div class=\"discordian_date_func\" style=\"width:100%;text-align:center;font-size:18px;line-height:36px;padding-top:40px;padding-bottom:40px;\"> Today is ";
echo get_ddate($content, $format, "now").".";
if ($holyday) echo "<br><b>".$holyday."</b>";
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) {
$title = $instance['title'];
$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>
<?php
}
}
function get_the_ddate_post($content, $format){
return get_ddate($content, $format, "get_the_date"); }
function get_the_ddate_comment($content, $format){
return get_ddate($content, $format, "get_comment_date"); }
function register_ddatefunc_widget() {
register_widget( 'Discordian_Date_Widget' );
}
function today_ddate(){
echo return_today_hebDate();
}
function return_today_ddate() {
return get_ddate($content, $format, "now");
}
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' );

49
readme.txt Normal file
View File

@ -0,0 +1,49 @@
=== Discordian Date Function ===
Contributors: zlaxyi
Donate link: https://is3.soundragon.su/discordian-date-function
Tags: date, discordian, erisian, widget
Requires at least: 2.0
Tested up to: 4.7.3
Stable tag: trunk
License: DWTWL 2.5
License URI: https://soundragon.su/license/license.html
This plugin provides Discordian dates in Wordpress.
Also provides shortcode and widget which displays the current date according to the Discordian calendar, with notification of 70 holydays.
== Description ==
This plugin allows WordPress to easily show 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.
And you can add the shortcode [today_ddate] in posts or pages for show the Discordian date of today.
== Installation ==
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. 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 <?php today_ddate() ?> where you want.
== Frequently Asked Questions ==
= Do you have any questions? =
Feel free to ask any questions about this plugin at the [Discordian Date Function plugin web page](https://is3.soundragon.su/discordian-date-function/).
== Screenshots ==
1. The screenshot shows the Discordian date text shown under post and comment.
== Changelog ==
= 0.5 =
* First public release.
== Upgrade Notice ==
= 0.5 =
This version is the first public release.

BIN
screenshot-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB