diff options
| author | danix <danix@danix.xyz> | 2018-07-04 17:57:25 +0200 |
|---|---|---|
| committer | danix <danix@danix.xyz> | 2018-07-04 17:57:25 +0200 |
| commit | 8da42654c57573e7d241efadb0292b2ff6326537 (patch) | |
| tree | e14ac6fd2289e3abe2c4441d08211931c116bf35 | |
| download | danixland-countdown-8da42654c57573e7d241efadb0292b2ff6326537.tar.gz danixland-countdown-8da42654c57573e7d241efadb0292b2ff6326537.zip | |
| -rw-r--r-- | danixland-countdown.php | 194 | ||||
| -rw-r--r-- | i18n/danixland-countdown.pot | 72 | ||||
| -rw-r--r-- | inc/style/basic.css | 67 | ||||
| -rw-r--r-- | inc/style/digital.ttf | bin | 0 -> 34404 bytes | |||
| -rw-r--r-- | readme.txt | 75 |
5 files changed, 408 insertions, 0 deletions
diff --git a/danixland-countdown.php b/danixland-countdown.php new file mode 100644 index 0000000..c10f7a2 --- /dev/null +++ b/danixland-countdown.php @@ -0,0 +1,194 @@ +<?php
+/*
+Plugin Name: danixland CountDown
+Plugin URI: http://danixland.net/?p=3330
+Description: A simple plugin that shows a widget with a countdown
+Version: 0.4
+Author: Danilo 'danix' Macri
+Author URI: http://danixland.net
+Text Domain: dnxcd
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+*/
+
+
+/**
+ * Add plugin i18n domain: dnxcd
+ * @since 0.1
+ */
+load_plugin_textdomain('dnxcd', plugins_url() . '/danixland-countdown/i18n/', 'danixland-countdown/i18n/');
+
+/**
+ * Function that installs our widget options
+ * @since 0.1
+ */
+function dnxcd_options_set() {
+ add_option( 'dnxcd_future_date', '06-05-2020', '', 'yes' );
+ add_option( 'dnxcd_widget_link', '', '', 'yes' );
+ add_option( 'dnxcd_use_style', 1, '', 'yes' );
+}
+
+/**
+ * Function that deletes our widget options
+ * @since 0.3
+ */
+function dnxcd_options_unset() {
+ delete_option( 'dnxcd_future_date' );
+ delete_option( 'dnxcd_widget_link' );
+ delete_option( 'dnxcd_use_style' );
+}
+
+/**
+ * Use widget's stylesheet if user wants it
+ * @since 0.3
+ */
+function dnxcd_style_handle() {
+ wp_register_style('dnxcd_basic', plugins_url() . '/danixland-countdown/inc/style/basic.css');
+ if( false == get_option('dnxcd_use_style') )
+ return;
+ wp_enqueue_style('dnxcd_basic');
+}
+add_action( 'wp_enqueue_scripts', 'dnxcd_style_handle' );
+
+/**
+ * Add function on plugin activation that'll set our plugin options
+ * @since 0.1
+ */
+register_activation_hook( __FILE__, 'dnxcd_options_set' );
+
+/**
+ * Add function on plugin deactivation that'll unset our plugin options
+ * @since 0.3
+ */
+register_deactivation_hook( __FILE__, 'dnxcd_options_unset' );
+
+/**
+ * Add function to widgets_init that'll load our widget.
+ * @since 0.1
+ */
+add_action( 'widgets_init', 'danixland_countdown' );
+
+/**
+ * Register our widget.
+ * 'dnx_CountDown' is the widget class used below.
+ *
+ * @since 0.1
+ */
+function danixland_countdown() {
+ register_widget( 'dnx_CountDown' );
+}
+
+/**
+ * dnx_CountDown class.
+ * This class handles everything that needs to be handled with the widget:
+ * the settings, form, display, and update. Nice!
+ *
+ * @since 0.1
+ */
+class dnx_CountDown extends WP_Widget {
+
+
+ /**
+ * Widget setup.
+ */
+ public function __construct() {
+ $control_ops = array('width' => 400, 'height' => 350);
+ parent::__construct(
+ 'dnx-countdown', // id_base
+ __('danixland CountDown', 'dnxcd' ), // Name
+ array( 'description' => __('Use this widget to add a simple Count Down to your Sidebar', 'dnxcd') ),
+ $control_ops
+ );
+ }
+
+ /**
+ * How to display the widget on the public side of the site.
+ */
+ public function widget( $args, $instance ) {
+ extract( $args );
+
+ /* Our variables from the widget settings. */
+ $title = apply_filters('widget_title', $instance['title'] );
+
+ /* Before widget (defined by themes). */
+ echo $before_widget;
+
+ /* Display the widget title if one was input (before and after defined by themes). */
+ if ( $title ) {
+ echo $before_title . $title . $after_title;
+ }
+
+ if ( '' != get_option('dnxcd_future_date') ) {
+ echo '<div class="dnx-countdown">';
+ $date = gmdate('U', strtotime( get_option('dnxcd_future_date') ));
+ $diff = $date - gmdate('U');
+ if ( '' != get_option('dnxcd_widget_link') ) {
+ echo '<a href="' . get_option('dnxcd_widget_link') . '">';
+ echo '-' . floor($diff / (24 * 60 * 60));
+ echo '</a>';
+ } else {
+ echo '-' . floor($diff / (24 * 60 * 60));
+ }
+ echo '</div> <!-- #dnx-countdown -->';
+ echo '<div class="dnx-days">' . __('days to go', 'dnxcd') . '</div>';
+ } else {
+ 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>";
+ }
+
+ /* After widget (defined by themes). */
+ echo $after_widget;
+ }
+
+ //Update the widget
+
+ public function update( $new_instance, $old_instance ) {
+ $instance = $old_instance;
+
+ //Strip tags from title and name to remove HTML
+ $instance['title'] = sanitize_text_field( $new_instance['title'] );
+ $instance['date'] = strip_tags( $new_instance['date'] );
+ $instance['link'] = esc_url( $new_instance['link'], array('http', 'https') );
+ $instance['style'] = (bool) $new_instance['style'];
+
+ update_option( 'dnxcd_future_date', $instance['date'] );
+ update_option( 'dnxcd_widget_link', $instance['link'] );
+ update_option( 'dnxcd_use_style', $instance['style'] );
+
+ return $instance;
+ }
+
+ /**
+ * Displays just a quick notice with a link to the Settings page
+ */
+ public function form( $instance ) {
+ $defaults = array(
+ 'title' => __( 'Count Down', 'dnxcd' ),
+ 'date' => get_option( 'dnxcd_future_date' ),
+ 'link' => get_option( 'dnxcd_widget_link' ),
+ 'style' => get_option( 'dnxcd_use_style' )
+ );
+ $instance = wp_parse_args( (array) $instance, $defaults );
+ extract( $instance, EXTR_SKIP );
+ ?>
+
+ <p>
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'dnxcd'); ?></label>
+ <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%;" />
+ </p>
+ <p>
+ <label for="<?php echo $this->get_field_id( 'date' ); ?>"><?php _e('Future Date (dd-mm-yyyy):', 'dnxcd'); ?></label>
+ <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%;" />
+ <label for="<?php echo $this->get_field_id( 'link' ); ?>"><?php _e('Link (only http/https allowed):', 'dnxcd'); ?></label>
+ <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%;" />
+ </p>
+ <p>
+ <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' ); ?>" />
+ <label for="<?php echo $this->get_field_id( 'style' ); ?>"><?php _e('Enable Widget Stylesheet?', 'dnxcd'); ?></label>
+ </p>
+ <?php
+ }
+}
+
+?>
diff --git a/i18n/danixland-countdown.pot b/i18n/danixland-countdown.pot new file mode 100644 index 0000000..ded775b --- /dev/null +++ b/i18n/danixland-countdown.pot @@ -0,0 +1,72 @@ +# 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 "" diff --git a/inc/style/basic.css b/inc/style/basic.css new file mode 100644 index 0000000..f551ee9 --- /dev/null +++ b/inc/style/basic.css @@ -0,0 +1,67 @@ +@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 diff --git a/inc/style/digital.ttf b/inc/style/digital.ttf Binary files differnew file mode 100644 index 0000000..a481b97 --- /dev/null +++ b/inc/style/digital.ttf diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..9534421 --- /dev/null +++ b/readme.txt @@ -0,0 +1,75 @@ +=== 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. |
