1
+ <?php
2
+ /*
3
+ Plugin Name: Task timer
4
+ Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
5
+ Description: Test task
6
+ Version: 0.2
7
+ Author: Okhmat Aleksey
8
+ Author URI: http://URI_Of_The_Plugin_Author
9
+ License: none
10
+
11
+ */
12
+
13
+ define ( 'WP_Timer_PLUGIN ' , __FILE__ );
14
+ define ( 'WP_Timer_PLUGIN_DIR ' , untrailingslashit ( dirname ( WP_Timer_PLUGIN ) ) );
15
+ define ( 'WP_Timer_THEME_TEMPLATE_DIR ' , (get_stylesheet_directory () . '/ ' . 'countdown/layout.php ' ) );
16
+
17
+ class Countdown_Timer extends WP_Widget {
18
+
19
+ public function Countdown_Timer ()
20
+ {
21
+ $ widget_ops = array ('classname ' => 'Countdown_Timer ' , 'description ' => 'Timer for the test task ' );
22
+ $ this ->WP_Widget ('Countdown_Timer ' , 'Timer ' , $ widget_ops );
23
+ }
24
+
25
+ public function form ($ instance ) {
26
+ if ( $ instance ) {
27
+ $ title = esc_attr ($ instance ['title ' ]);
28
+ $ descr =$ instance ['descr ' ];
29
+ $ date = esc_attr ($ instance ['date ' ]);
30
+ $ hour = esc_attr ($ instance ['hour ' ]);
31
+ $ minute = esc_attr ($ instance ['minute ' ]);
32
+ } else {
33
+ $ title = '' ;
34
+ $ date = '' ;
35
+ $ hour = '' ;
36
+ $ descr ='' ;
37
+ $ minute = '' ;
38
+ }
39
+ require_once WP_Timer_PLUGIN_DIR . '/admin/templates/admin-template.php ' ;
40
+ }
41
+
42
+ public function update ($ new_instance , $ old_instance ) {
43
+ $ instance = $ old_instance ;
44
+ $ rand = (int )$ new_instance ['the_random_number ' ];
45
+ $ instance ['descr ' ] =$ new_instance [ 'wp_editor_ ' . $ rand ];
46
+ $ instance ['title ' ] = strip_tags ($ new_instance ['title ' ]);
47
+ $ instance ['date ' ] = strip_tags ($ new_instance ['date ' ]);
48
+ $ instance ['hour ' ] = strip_tags ($ new_instance ['hour ' ]);
49
+ $ instance ['minute ' ] = strip_tags ($ new_instance ['minute ' ]);
50
+ return $ instance ;
51
+ }
52
+
53
+ public function widget ($ args , $ instance ) {
54
+
55
+ $ temp_date = explode ("/ " , $ instance ['date ' ]);
56
+ $ instance ['date ' ] = $ temp_date [2 ] . "/ " . $ temp_date [0 ] . "/ " . $ temp_date [1 ];
57
+ extract ($ args );
58
+ $ title = apply_filters ('widget_title ' , $ instance ['title ' ]);
59
+ echo $ args ['before_widget ' ];
60
+ if (file_exists ( WP_Timer_THEME_TEMPLATE_DIR)) {
61
+ include WP_Timer_THEME_TEMPLATE_DIR;
62
+ } else {
63
+ if (!empty ($ title )){
64
+ ?>
65
+ <div class="tp-title">
66
+ <?php
67
+ echo $ before_title . $ title . $ after_title ;
68
+ }
69
+ ?>
70
+ </div>
71
+ <p class="clockTitle">Description:</p>
72
+ <p><?php echo $ instance ['descr ' ]; ?> </p>
73
+ <?php
74
+ echo do_shortcode ('[tp_shortcode date=" ' . $ instance ['date ' ] . '" time=" ' . $ instance ['hour ' ] . ': ' . $ instance ['minute ' ] . '"] ' );
75
+ }
76
+ echo $ after_widget ;
77
+ }
78
+ }
79
+
80
+ require_once WP_Timer_PLUGIN_DIR . '/includes/shortcodes.php ' ;
81
+ require_once WP_Timer_PLUGIN_DIR . '/includes/functions.php ' ;
82
+ ?>
83
+
0 commit comments