--- /dev/null
+<?php\r
+/*\r
+Plugin Name: danixland CountDown\r
+Plugin URI: http://danixland.net/?p=3330 \r
+Description: A simple plugin that shows a widget with a countdown\r
+Version: 0.4\r
+Author: Danilo 'danix' Macri\r
+Author URI: http://danixland.net\r
+Text Domain: dnxcd\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r
+*/\r
+\r
+\r
+/**\r
+ * Add plugin i18n domain: dnxcd\r
+ * @since 0.1\r
+ */\r
+load_plugin_textdomain('dnxcd', plugins_url() . '/danixland-countdown/i18n/', 'danixland-countdown/i18n/');\r
+\r
+/**\r
+ * Function that installs our widget options\r
+ * @since 0.1\r
+ */\r
+function dnxcd_options_set() {\r
+ add_option( 'dnxcd_future_date', '06-05-2020', '', 'yes' );\r
+ add_option( 'dnxcd_widget_link', '', '', 'yes' );\r
+ add_option( 'dnxcd_use_style', 1, '', 'yes' );\r
+}\r
+\r
+/**\r
+ * Function that deletes our widget options\r
+ * @since 0.3\r
+ */\r
+function dnxcd_options_unset() {\r
+ delete_option( 'dnxcd_future_date' );\r
+ delete_option( 'dnxcd_widget_link' );\r
+ delete_option( 'dnxcd_use_style' );\r
+}\r
+\r
+/**\r
+ * Use widget's stylesheet if user wants it\r
+ * @since 0.3\r
+ */\r
+function dnxcd_style_handle() {\r
+ wp_register_style('dnxcd_basic', plugins_url() . '/danixland-countdown/inc/style/basic.css');\r
+ if( false == get_option('dnxcd_use_style') )\r
+ return;\r
+ wp_enqueue_style('dnxcd_basic');\r
+}\r
+add_action( 'wp_enqueue_scripts', 'dnxcd_style_handle' );\r
+\r
+/**\r
+ * Add function on plugin activation that'll set our plugin options\r
+ * @since 0.1\r
+ */\r
+register_activation_hook( __FILE__, 'dnxcd_options_set' );\r
+\r
+/**\r
+ * Add function on plugin deactivation that'll unset our plugin options\r
+ * @since 0.3\r
+ */\r
+register_deactivation_hook( __FILE__, 'dnxcd_options_unset' );\r
+\r
+/**\r
+ * Add function to widgets_init that'll load our widget.\r
+ * @since 0.1\r
+ */\r
+add_action( 'widgets_init', 'danixland_countdown' );\r
+\r
+/**\r
+ * Register our widget.\r
+ * 'dnx_CountDown' is the widget class used below.\r
+ *\r
+ * @since 0.1\r
+ */\r
+function danixland_countdown() {\r
+ register_widget( 'dnx_CountDown' );\r
+}\r
+\r
+/**\r
+ * dnx_CountDown class.\r
+ * This class handles everything that needs to be handled with the widget:\r
+ * the settings, form, display, and update. Nice!\r
+ *\r
+ * @since 0.1\r
+ */\r
+class dnx_CountDown extends WP_Widget {\r
+\r
+\r
+ /**\r
+ * Widget setup.\r
+ */\r
+ public function __construct() {\r
+ $control_ops = array('width' => 400, 'height' => 350);\r
+ parent::__construct(\r
+ 'dnx-countdown', // id_base\r
+ __('danixland CountDown', 'dnxcd' ), // Name\r
+ array( 'description' => __('Use this widget to add a simple Count Down to your Sidebar', 'dnxcd') ),\r
+ $control_ops\r
+ );\r
+ }\r
+\r
+ /**\r
+ * How to display the widget on the public side of the site.\r
+ */\r
+ public function widget( $args, $instance ) {\r
+ extract( $args );\r
+\r
+ /* Our variables from the widget settings. */\r
+ $title = apply_filters('widget_title', $instance['title'] );\r
+\r
+ /* Before widget (defined by themes). */\r
+ echo $before_widget;\r
+\r
+ /* Display the widget title if one was input (before and after defined by themes). */\r
+ if ( $title ) {\r
+ echo $before_title . $title . $after_title;\r
+ }\r
+\r
+ if ( '' != get_option('dnxcd_future_date') ) {\r
+ echo '<div class="dnx-countdown">';\r
+ $date = gmdate('U', strtotime( get_option('dnxcd_future_date') ));\r
+ $diff = $date - gmdate('U');\r
+ if ( '' != get_option('dnxcd_widget_link') ) {\r
+ echo '<a href="' . get_option('dnxcd_widget_link') . '">';\r
+ echo '-' . floor($diff / (24 * 60 * 60));\r
+ echo '</a>';\r
+ } else {\r
+ echo '-' . floor($diff / (24 * 60 * 60));\r
+ }\r
+ echo '</div> <!-- #dnx-countdown -->';\r
+ echo '<div class="dnx-days">' . __('days to go', 'dnxcd') . '</div>'; \r
+ } else {\r
+ echo "<div class='dnx-warning'><a href='" . get_admin_url('', 'widgets.php', '') . "' title='" . __('configure widget', 'dnxcd') . "'>" . __('the date is missing<br />configure widget', 'dnxcd') . "</a></div>";\r
+ }\r
+\r
+ /* After widget (defined by themes). */\r
+ echo $after_widget;\r
+ }\r
+\r
+ //Update the widget \r
+ \r
+ public function update( $new_instance, $old_instance ) {\r
+ $instance = $old_instance;\r
+\r
+ //Strip tags from title and name to remove HTML \r
+ $instance['title'] = sanitize_text_field( $new_instance['title'] );\r
+ $instance['date'] = strip_tags( $new_instance['date'] );\r
+ $instance['link'] = esc_url( $new_instance['link'], array('http', 'https') );\r
+ $instance['style'] = (bool) $new_instance['style'];\r
+\r
+ update_option( 'dnxcd_future_date', $instance['date'] );\r
+ update_option( 'dnxcd_widget_link', $instance['link'] );\r
+ update_option( 'dnxcd_use_style', $instance['style'] );\r
+ \r
+ return $instance;\r
+ }\r
+\r
+ /**\r
+ * Displays just a quick notice with a link to the Settings page\r
+ */\r
+ public function form( $instance ) {\r
+ $defaults = array( \r
+ 'title' => __( 'Count Down', 'dnxcd' ),\r
+ 'date' => get_option( 'dnxcd_future_date' ),\r
+ 'link' => get_option( 'dnxcd_widget_link' ),\r
+ 'style' => get_option( 'dnxcd_use_style' )\r
+ );\r
+ $instance = wp_parse_args( (array) $instance, $defaults );\r
+ extract( $instance, EXTR_SKIP );\r
+ ?>\r
+\r
+ <p>\r
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'dnxcd'); ?></label>\r
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $title; ?>" style="width:100%;" />\r
+ </p>\r
+ <p>\r
+ <label for="<?php echo $this->get_field_id( 'date' ); ?>"><?php _e('Future Date (dd-mm-yyyy):', 'dnxcd'); ?></label>\r
+ <input type="date" class="widefat" id="<?php echo $this->get_field_id( 'date' ); ?>" name="<?php echo $this->get_field_name( 'date' ); ?>" value="<?php echo $date ?>" style="width:100%;" />\r
+ <label for="<?php echo $this->get_field_id( 'link' ); ?>"><?php _e('Link (only http/https allowed):', 'dnxcd'); ?></label>\r
+ <input class="widefat" id="<?php echo $this->get_field_id( 'link' ); ?>" name="<?php echo $this->get_field_name( 'link' ); ?>" value="<?php echo $link; ?>" style="width:100%;" />\r
+ </p>\r
+ <p>\r
+ <input class="checkbox" type="checkbox" <?php checked( $style, true ); ?> id="<?php echo $this->get_field_id( 'style' ); ?>" name="<?php echo $this->get_field_name( 'style' ); ?>" />\r
+ <label for="<?php echo $this->get_field_id( 'style' ); ?>"><?php _e('Enable Widget Stylesheet?', 'dnxcd'); ?></label>\r
+ </p>\r
+ <?php\r
+ }\r
+}\r
+\r
+?>\r
--- /dev/null
+# Copyright (C) 2016 danixland CountDown
+# This file is distributed under the same license as the danixland CountDown package.
+msgid ""
+msgstr ""
+"Project-Id-Version: danixland CountDown 0.4\n"
+"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/danixland-"
+"countdown\n"
+"POT-Creation-Date: 2016-01-22 11:15:01+00:00\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+
+#. #-#-#-#-# plugin.pot (danixland CountDown 0.4) #-#-#-#-#
+#. Plugin Name of the plugin/theme
+#: danixland-countdown.php:100
+msgid "danixland CountDown"
+msgstr ""
+
+#: danixland-countdown.php:101
+msgid "Use this widget to add a simple Count Down to your Sidebar"
+msgstr ""
+
+#: danixland-countdown.php:135
+msgid "days to go"
+msgstr ""
+
+#: danixland-countdown.php:137
+msgid "configure widget"
+msgstr ""
+
+#: danixland-countdown.php:137
+msgid "the date is missing<br />configure widget"
+msgstr ""
+
+#: danixland-countdown.php:167
+msgid "Count Down"
+msgstr ""
+
+#: danixland-countdown.php:177
+msgid "Title:"
+msgstr ""
+
+#: danixland-countdown.php:181
+msgid "Future Date (dd-mm-yyyy):"
+msgstr ""
+
+#: danixland-countdown.php:183
+msgid "Link (only http/https allowed):"
+msgstr ""
+
+#: danixland-countdown.php:188
+msgid "Enable Widget Stylesheet?"
+msgstr ""
+
+#. Plugin URI of the plugin/theme
+msgid "http://danixland.net/?p=3330"
+msgstr ""
+
+#. Description of the plugin/theme
+msgid "A simple plugin that shows a widget with a countdown"
+msgstr ""
+
+#. Author of the plugin/theme
+msgid "Danilo 'danix' Macri"
+msgstr ""
+
+#. Author URI of the plugin/theme
+msgid "http://danixland.net"
+msgstr ""
--- /dev/null
+@font-face {
+
+ font-family: digit;
+
+ src: local(digit), url('digital.ttf') format('opentype');
+}
+
+.dnx-countdown {
+ font: 400 6em 'digit', sans-serif;
+}
+.dnx-countdown a {
+ text-decoration: none;
+}
+.dnx-days {
+ font-size: 3em;
+ font-weight: 400;
+}
+.dnx-warning a {
+ text-decoration: none;
+ display: block;
+ margin: 4px auto 0;
+ text-align: center;
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 14px;
+ font-weight: 600;
+ color: #ffffff;
+ padding: 5px 7px;
+ background: -moz-linear-gradient(
+ top,
+ #ff5454 0%,
+ #960000);
+ background: -webkit-gradient(
+ linear, left top, left bottom,
+ from(#ff5454),
+ to(#960000));
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+ border: 1px solid #470000;
+ -moz-box-shadow:
+ 0px 2px 6px rgba(000,000,000,0.5),
+ inset 0px 1px 1px rgba(255,255,255,0.5);
+ -webkit-box-shadow:
+ 0px 2px 6px rgba(000,000,000,0.5),
+ inset 0px 1px 1px rgba(255,255,255,0.5);
+ box-shadow:
+ 0px 2px 6px rgba(000,000,000,0.5),
+ inset 0px 1px 1px rgba(255,255,255,0.5);
+ text-shadow:
+ 0px -1px 0px rgba(000,000,000,0.7),
+ 0px 1px 0px rgba(255,255,255,0.3);
+}
+.dnx-warning a:hover,
+.dnx-warning a:active {
+ text-decoration: none;
+ background: -moz-linear-gradient(
+ bottom,
+ #ff5454 0%,
+ #960000);
+ background: -webkit-gradient(
+ linear, left bottom, left top,
+ from(#ff5454),
+ to(#960000));
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+}
\ No newline at end of file
--- /dev/null
+=== danixland-countdown ===
+Contributors: danixland
+Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PEBBHUDM8YAF8
+Tags: widget, sidebar, countdown,
+Requires at least: 3.4
+Tested up to: 4.4
+Stable tag: 0.4
+
+This plugin adds a simple widget and shows a countdown to a future date.
+
+== Description ==
+
+danixland-countdown is a simple plugin that adds a widget you can load on your sidebar which will show a simple countdown to a future date that you can set.
+this plugin makes use of a simple css stylesheet that you can enable or disable at will. You can also link the countdown to whatever url you want.
+
+== Installation ==
+
+Installing danixland-countdown is straightforward and requires just a few seconds:
+
+If you use the **"Add New Plugin"** pane from your dashboard just install it and activate it, then proceed to the last step and configure it.
+Otherwise follow these steps:
+
+1. Download the latest version of the plugin.
+1. If using the "Install Plugins->Upload" section on the WordPress admin area just upload the zip file, otherwise unpack the zip file and upload the **"danixland-countdown"** directory inside the "wp-content/plugins" directory of your WordPress installation using your favourite ftp client.
+1. Activate the plugin through the 'Plugins' menu in WordPress.
+1. Configure the widget from the Appearance->Widgets page in your Admin area and add it to your sidebar.
+
+
+== Frequently Asked Questions ==
+
+= What can I do to customize even more the appearance of the widget? =
+
+You can disable the css stylesheet provided with the plugin, but it will also disable the use of the custom digital font shipped with it.
+If you want to override the css without disabling it you can edit the style of the div with id **#dnx-countdown**, it contains all the output by this plugin.
+
+= I like the font shipped with this plugin, can I use it somewhere else? =
+
+The font is free for home use, it was created for the shareware program Calculator-7 by http://www.styleseven.com/.
+It can be used in other projects as long as they are free, just by giving credit to the author at the website http://www.styleseven.com/
+
+== Screenshots ==
+
+1. The widget as seen in the "Available Widgets" panel in your Widgets Admin page.
+2. The widget settings, available once you put it in your sidebar.
+3. The jQuery datepicker dialog visible once you click on the date input.
+4. The widget as seen on a page using the twentythirteen theme.
+
+
+== Changelog ==
+
+= 0.4 =
+ * Updated Plugin to the new Plugins API. Minimum WordPress requirement is now 3.4
+ * Dropped use of external jQuery lib in favor of html5 date picker.
+
+= 0.3 =
+ * Added various functions that take care of uninstalling all the data when the plugin is disabled.
+
+= 0.1 =
+ * This is the first release.
+
+
+== Upgrade Notice ==
+
+= 0.4 =
+* It's highly recommended to upgrade since previous versions of the plugin made use of the old Plugins API and are deprecated with versions of WordPress starting from 3.4
+
+
+== ToDo list ==
+
+List is actually empty, but I'm open to suggestions.
+
+== Translations ==
+
+None as of now. This plugin ships with a .pot file that will allow you to create a translation in your language.
+If you want it to be added to this plugin contact me and I'll add it and put a link to your WordPress profile here in this section.