PluginProbe
Uji Countdown / 1.2
Uji Countdown v1.2
3.0 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 36 releases
uji-countdown / uji-countdown-widget.php

uji-countdown-widget.php in Uji Countdown 1.2, at uji-countdown-widget.php

126 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php class UJI_countdown extends WP_Widget {
2
3 function UJI_countdown(){
4 $widget_ops = array('description' => 'Uji Countdown widget');
5 $control_ops = array('width' => 300, 'height' => 400);
6 parent::WP_Widget('UJI_countdown_widget', $name='..:: Uji Countdown ::..', $widget_ops, $control_ops);
7 }
8
9 function widget($args, $instance) {
10 extract($args);
11 $UJI_title = $instance['UJI_title'];
12 $UJI_style = $instance['UJI_style'];
13 $UJI_date = $instance['UJI_date'];
14 $UJI_exp = $instance['UJI_exp'];
15 $UJI_link = $instance['UJI_link'];
16
17 $shtval = '';
18 $shtval .= (!empty($UJI_style)) ? ' id="'.$UJI_style.'"' : $shtval;
19 $shtval .= (!empty($UJI_date)) ? ' expire="'.$UJI_date.'"' : $shtval;
20 $shtval .= (!empty($UJI_exp)) ? ' hide = "true"' : $shtval;
21 $shtval .= (empty($UJI_exp) && !empty($UJI_link)) ? ' url = "'.$UJI_link.'"' : $shtval;
22 $shortcode = (!empty($shtval)) ? '[ujicountdown'.$shtval.']' : '';
23
24 if(!empty($shortcode)) echo '<h3 class="widget-title">'.$UJI_title.'</h3>'.do_shortcode($shortcode);
25
26 } // widget
27
28 function update($new_instance, $old_instance){
29 $instance = $old_instance;
30 $instance['UJI_title'] = stripslashes($new_instance['UJI_title']);
31 $instance['UJI_style'] = stripslashes($new_instance['UJI_style']);
32 $instance['UJI_date'] = stripslashes($new_instance['UJI_date']);
33 $instance['UJI_exp'] = stripslashes($new_instance['UJI_exp']);
34 $instance['UJI_link'] = stripslashes($new_instance['UJI_link']);
35 return $instance;
36 } // save
37
38 function form($instance){
39 $instance = wp_parse_args( (array) $instance, array('UJI_title'=>'', 'UJI_style'=>'', 'UJI_date'=>'', 'UJI_exp'=>'', 'UJI_link'=>'') );
40 $UJI_title = htmlspecialchars($instance['UJI_title']);
41 $UJI_style = htmlspecialchars($instance['UJI_style']);
42 $UJI_date = htmlspecialchars($instance['UJI_date']);
43 $UJI_exp = htmlspecialchars($instance['UJI_exp']);
44 $UJI_link = (isset($UJI_link)) ? htmlspecialchars($instance['UJI_link']) : '';
45
46
47 global $wp_version;
48 if ( $wp_version >= 3.5 ) {
49 wp_enqueue_script ( 'ujic_jquery_date_js' , UJI_PLUGIN_URL . '/inc/js/jquery-ui.min.js' , array ( 'jquery' ) , '1.10.3' , true );
50 wp_enqueue_script ( 'ujic_date_js' , UJI_PLUGIN_URL . '/inc/js/jquery-ui-timepicker.js' , array ( 'ujic_jquery_date_js' ) , '1.3' , true );
51 }else{
52 wp_enqueue_script ( 'ujic_jquery_date_js' , UJI_PLUGIN_URL . '/inc/js/jquery-ui-old.min.js' , array ( 'jquery' ) , '1.8' , true );
53 wp_enqueue_script ( 'ujic_date_js' , UJI_PLUGIN_URL . '/inc/js/jquery-ui-timepicker-old.js' , array ( 'ujic_jquery_date_js' ) , '1.0.1' , true );
54 }
55 wp_enqueue_script ( 'ujic_widget_js' , UJI_PLUGIN_URL . '/inc/js/widget-js.js' , array ( 'jquery' ) , '1.0');
56 wp_register_style('ujic-jqueryui-css', "http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/base/jquery-ui.css");
57 wp_enqueue_style( 'ujic-jqueryui-css');
58
59
60 echo '<p style="font-size:11px">Just one counter on page is allowed. <br>Check <a href="http://wpmanage.com/uji-countdown" target="_blank">Premium version</a> for multiple countdown timers on the same page. <p>';
61
62 echo '<p><label>' . 'Title:' . '</label>
63 <input type="text" value="'. $UJI_title .'" width="200px" id="'.$this->get_field_id('UJI_title').'" class="widefat" name="' . $this->get_field_name('UJI_title') . '" />
64 </p>';
65
66 echo '<p><label>' . 'Select your style:' . '</label>
67 <select class="widefat" id="'.$this->get_field_id('UJI_style').'" name="'.$this->get_field_name('UJI_style').'">
68 <option value=""> Select a Style </option>'
69 .ujic_forms($UJI_style).
70 '</select></p>';
71
72 echo '<p><label>' . 'Countdown Expire In:' . '</label>
73 <input type="text" value="'. $UJI_date .'" width="200px" id="'.$this->get_field_id('UJI_date').'" class="UJI_date widefat" name="' . $this->get_field_name('UJI_date') . '" />
74 </p>';
75
76 echo '<p><h3>After expiry:</h3>
77 <label>' . 'Hide countdown:' . '</label>
78 <input type="checkbox" ', ($UJI_exp==1) ? ' checked="checked"' : '' ,' value="1" id="'.$this->get_field_id('UJI_exp').'" class="ujic_exp" name="' . $this->get_field_name('UJI_exp') . '" />
79 </p>';
80
81 echo '<p><label>' . 'Or go to link:' . '</label>
82 <input type="text" value="'. $UJI_link .'" width="200px" id="'.$this->get_field_id('UJI_link').'" class="ujic_link widefat" name="' . $this->get_field_name('UJI_link') . '" />
83 </p>';
84 ?>
85 <script language="javascript">
86 jQuery(function() {
87
88 jQuery('.UJI_date').each(function() {
89 jQuery(this).datetimepicker({
90 timeFormat: 'hh:mm',
91 dateFormat: 'yy/mm/dd'
92 });
93 });
94
95 jQuery('.ujic_link').each(function() {
96 jQuery(this).keyup(function () {
97 var value = jQuery(this).val();
98 var cname = jQuery(this).parent().parent().find('.ujic_exp').attr("name");
99 jQuery(this).parent().parent().find('.ujic_exp').css('border', 'red');
100 //alert("ccc");
101
102 if(value){
103 jQuery('input[name="'+cname+'"]').attr('checked', false);
104 }else{
105
106 jQuery('input[name="'+cname+'"]').attr('checked', true);
107 }
108
109 });
110 });
111
112 });
113
114 </script>
115 <?php
116 } // form
117
118 } // class
119
120 function UJI_countdownWidget() {
121 register_widget('UJI_countdown');
122 }
123
124 add_action('widgets_init', 'UJI_countdownWidget');
125 ?>
126