PluginProbe
Welcart e-Commerce / 1.3.16
Welcart e-Commerce v1.3.16
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / widgets / usces_bestseller.php

usces_bestseller.php in Welcart e-Commerce 1.3.16, at widgets/usces_bestseller.php

154 lines 9.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Welcart_bestseller Class
5 */
6 class Welcart_bestseller extends WP_Widget {
7 /** constructor */
8 function Welcart_bestseller() {
9 parent::WP_Widget(false, $name = 'Welcart '.__('best seller', 'usces'));
10 }
11
12 /** @see WP_Widget::widget */
13 function widget($args, $instance) {
14 global $usces;
15 extract( $args );
16 if( !isset($instance['title']) )
17 $instance['title'] = '';
18 if( !isset($instance['rows_num']) )
19 $instance['rows_num'] = '';
20 if( !isset($instance['icon']) )
21 $instance['icon'] = '';
22 if( !isset($instance['list']) )
23 $instance['list'] = '';
24 if( !isset($instance['code1']) )
25 $instance['code1'] = '';
26 if( !isset($instance['code2']) )
27 $instance['code2'] = '';
28 if( !isset($instance['code3']) )
29 $instance['code3'] = '';
30 if( !isset($instance['code4']) )
31 $instance['code4'] = '';
32 if( !isset($instance['code5']) )
33 $instance['code5'] = '';
34 if( !isset($instance['code6']) )
35 $instance['code6'] = '';
36 if( !isset($instance['code7']) )
37 $instance['code7'] = '';
38 if( !isset($instance['code8']) )
39 $instance['code8'] = '';
40 if( !isset($instance['code9']) )
41 $instance['code9'] = '';
42 if( !isset($instance['code10']) )
43 $instance['code10'] = '';
44
45 $title = WCUtils::is_blank($instance['title']) ? 'Welcart '.__('best seller', 'usces') : $instance['title'];
46 $rows_num = WCUtils::is_blank($instance['rows_num']) ? 10 : $instance['rows_num'];
47 $icon = WCUtils::is_blank($instance['icon']) ? 1 : (int)$instance['icon'];
48 //if($icon == 1) $before_title = '<div class="widget_title"><img src="' . USCES_PLUGIN_URL . '/images/best-seller.png" alt="' . $title . '" width="24" height="24" />';
49 $img_path = file_exists(get_stylesheet_directory().'/images/bestseller.png') ? get_stylesheet_directory_uri().'/images/bestseller.png' : USCES_FRONT_PLUGIN_URL . '/images/bestseller.png';
50 if($icon == 1) $before_title .= '<img src="' . $img_path . '" alt="' . $title . '" />';
51 $list = WCUtils::is_blank($instance['list']) ? 1 : (int)$instance['list'];
52 ?>
53 <?php echo $before_widget; ?>
54 <?php echo $before_title
55 . esc_html($title)
56 . $after_title; ?>
57
58 <ul class="ucart_widget_body">
59 <?php if($list === 1): ?>
60 <?php usces_list_bestseller($rows_num); ?>
61 <?php else: ?>
62 <?php
63 for($i=0; $i<$rows_num; $i++) {
64 $cname = 'code' . ($i+1);
65 $code = esc_html(trim($instance[$cname]));
66 if(WCUtils::is_blank($code)) continue;
67 $id = $usces->get_postIDbyCode($code);
68 if(WCUtils::is_blank($id)) continue;
69 $post = get_post($id);
70 $disp_text = apply_filters('usces_widget_bestseller_manual_text', esc_html($post->post_title), $id);
71 $list = '<li><a href="' . get_permalink($id) . '">' . $disp_text . '</a></li>' . "\n";
72 $htm .= apply_filters('usces_filter_bestseller', $list, $post->ID, $i);
73 }
74 echo $htm;
75 ?>
76 <?php endif; ?>
77 </ul>
78 <?php echo $after_widget; ?>
79 <?php
80 }
81
82 /** @see WP_Widget::update */
83 function update($new_instance, $old_instance) {
84 return $new_instance;
85 }
86
87 /** @see WP_Widget::form */
88 function form($instance) {
89 if( !isset($instance['title']) )
90 $instance['title'] = '';
91 if( !isset($instance['rows_num']) )
92 $instance['rows_num'] = '';
93 if( !isset($instance['icon']) )
94 $instance['icon'] = '';
95 if( !isset($instance['list']) )
96 $instance['list'] = '';
97 if( !isset($instance['code1']) )
98 $instance['code1'] = '';
99 if( !isset($instance['code2']) )
100 $instance['code2'] = '';
101 if( !isset($instance['code3']) )
102 $instance['code3'] = '';
103 if( !isset($instance['code4']) )
104 $instance['code4'] = '';
105 if( !isset($instance['code5']) )
106 $instance['code5'] = '';
107 if( !isset($instance['code6']) )
108 $instance['code6'] = '';
109 if( !isset($instance['code7']) )
110 $instance['code7'] = '';
111 if( !isset($instance['code8']) )
112 $instance['code8'] = '';
113 if( !isset($instance['code9']) )
114 $instance['code9'] = '';
115 if( !isset($instance['code10']) )
116 $instance['code10'] = '';
117
118 $title = WCUtils::is_blank($instance['title']) ? 'Welcart '.__('best seller', 'usces') : esc_attr($instance['title']);
119 $rows_num = WCUtils::is_blank($instance['rows_num']) ? 10 : esc_attr($instance['rows_num']);
120 $icon = WCUtils::is_blank($instance['icon']) ? 1 : (int)$instance['icon'];
121 $list = WCUtils::is_blank($instance['list']) ? 1 : (int)$instance['list'];
122 $code1 = esc_attr($instance['code1']);
123 $code2 = esc_attr($instance['code2']);
124 $code3 = esc_attr($instance['code3']);
125 $code4 = esc_attr($instance['code4']);
126 $code5 = esc_attr($instance['code5']);
127 $code6 = esc_attr($instance['code6']);
128 $code7 = esc_attr($instance['code7']);
129 $code8 = esc_attr($instance['code8']);
130 $code9 = esc_attr($instance['code9']);
131 $code10 = esc_attr($instance['code10']);
132 ?>
133 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
134 <p><label for="<?php echo $this->get_field_id('icon'); ?>"><?php _e('display of icon', 'usces'); ?>: <select class="widefat" id="<?php echo $this->get_field_id('icon'); ?>" name="<?php echo $this->get_field_name('icon'); ?>"><option value="1"<?php if($icon == 1){echo ' selected="selected"';} ?>><?php _e('Indication', 'usces'); ?></option><option value="2"<?php if($icon == 2){echo ' selected="selected"';} ?>><?php _e('Non-indication', 'usces'); ?></option></select></label></p>
135 <p><label for="<?php echo $this->get_field_id('rows_num'); ?>"><?php _e('number of indication', 'usces'); ?>: <input class="widefat" id="<?php echo $this->get_field_id('rows_num'); ?>" name="<?php echo $this->get_field_name('rows_num'); ?>" type="text" value="<?php echo $rows_num; ?>" /></label></p>
136 <p><label for="<?php echo $this->get_field_id('list'); ?>"><?php _e('automatic count', 'usces'); ?>: <select class="widefat" id="<?php echo $this->get_field_id('list'); ?>" name="<?php echo $this->get_field_name('list'); ?>"><option value="1"<?php if($list == 1){echo ' selected="selected"';} ?>><?php _e('automatic list', 'usces'); ?></option><option value="2"<?php if($list == 2){echo ' selected="selected"';} ?>><?php _e('handwriting list', 'usces'); ?></option></select></label></p>
137 <fieldset><legend><?php _e('handwriting list', 'usces'); ?></legend>
138 <p><?php _e('Please input an article cord.', 'usces'); ?></p>
139 <p><label for="<?php echo $this->get_field_id('code1'); ?>"><?php _e('item code', 'usces'); ?>1 : <input class="widefat" id="<?php echo $this->get_field_id('code1'); ?>" name="<?php echo $this->get_field_name('code1'); ?>" type="text" value="<?php echo $code1; ?>" /></label></p>
140 <p><label for="<?php echo $this->get_field_id('code2'); ?>"><?php _e('item code', 'usces'); ?>2 : <input class="widefat" id="<?php echo $this->get_field_id('code2'); ?>" name="<?php echo $this->get_field_name('code2'); ?>" type="text" value="<?php echo $code2; ?>" /></label></p>
141 <p><label for="<?php echo $this->get_field_id('code3'); ?>"><?php _e('item code', 'usces'); ?>3 : <input class="widefat" id="<?php echo $this->get_field_id('code3'); ?>" name="<?php echo $this->get_field_name('code3'); ?>" type="text" value="<?php echo $code3; ?>" /></label></p>
142 <p><label for="<?php echo $this->get_field_id('code4'); ?>"><?php _e('item code', 'usces'); ?>4 : <input class="widefat" id="<?php echo $this->get_field_id('code4'); ?>" name="<?php echo $this->get_field_name('code4'); ?>" type="text" value="<?php echo $code4; ?>" /></label></p>
143 <p><label for="<?php echo $this->get_field_id('code5'); ?>"><?php _e('item code', 'usces'); ?>5 : <input class="widefat" id="<?php echo $this->get_field_id('code5'); ?>" name="<?php echo $this->get_field_name('code5'); ?>" type="text" value="<?php echo $code5; ?>" /></label></p>
144 <p><label for="<?php echo $this->get_field_id('code6'); ?>"><?php _e('item code', 'usces'); ?>6 : <input class="widefat" id="<?php echo $this->get_field_id('code6'); ?>" name="<?php echo $this->get_field_name('code6'); ?>" type="text" value="<?php echo $code6; ?>" /></label></p>
145 <p><label for="<?php echo $this->get_field_id('code7'); ?>"><?php _e('item code', 'usces'); ?>7 : <input class="widefat" id="<?php echo $this->get_field_id('code7'); ?>" name="<?php echo $this->get_field_name('code7'); ?>" type="text" value="<?php echo $code7; ?>" /></label></p>
146 <p><label for="<?php echo $this->get_field_id('code8'); ?>"><?php _e('item code', 'usces'); ?>8 : <input class="widefat" id="<?php echo $this->get_field_id('code8'); ?>" name="<?php echo $this->get_field_name('code8'); ?>" type="text" value="<?php echo $code8; ?>" /></label></p>
147 <p><label for="<?php echo $this->get_field_id('code9'); ?>"><?php _e('item code', 'usces'); ?>9 : <input class="widefat" id="<?php echo $this->get_field_id('code9'); ?>" name="<?php echo $this->get_field_name('code9'); ?>" type="text" value="<?php echo $code9; ?>" /></label></p>
148 <p><label for="<?php echo $this->get_field_id('code10'); ?>"><?php _e('item code', 'usces'); ?>10 : <input class="widefat" id="<?php echo $this->get_field_id('code10'); ?>" name="<?php echo $this->get_field_name('code10'); ?>" type="text" value="<?php echo $code10; ?>" /></label></p>
149 </fieldset>
150 <?php
151 }
152
153 }
154 ?>