PluginProbe
Welcart e-Commerce / 1.4.10
Welcart e-Commerce v1.4.10
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.4.10, at widgets/usces_bestseller.php

155 lines 9.4 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 $htm = '';
64 for($i=0; $i<$rows_num; $i++) {
65 $cname = 'code' . ($i+1);
66 $code = esc_html(trim($instance[$cname]));
67 if(WCUtils::is_blank($code)) continue;
68 $id = $usces->get_postIDbyCode($code);
69 if(WCUtils::is_blank($id)) continue;
70 $post = get_post($id);
71 $disp_text = apply_filters('usces_widget_bestseller_manual_text', esc_html($post->post_title), $id);
72 $list = '<li><a href="' . get_permalink($id) . '">' . $disp_text . '</a></li>' . "\n";
73 $htm .= apply_filters('usces_filter_bestseller', $list, $post->ID, $i);
74 }
75 echo $htm;
76 ?>
77 <?php endif; ?>
78 </ul>
79 <?php echo $after_widget; ?>
80 <?php
81 }
82
83 /** @see WP_Widget::update */
84 function update($new_instance, $old_instance) {
85 return $new_instance;
86 }
87
88 /** @see WP_Widget::form */
89 function form($instance) {
90 if( !isset($instance['title']) )
91 $instance['title'] = '';
92 if( !isset($instance['rows_num']) )
93 $instance['rows_num'] = '';
94 if( !isset($instance['icon']) )
95 $instance['icon'] = '';
96 if( !isset($instance['list']) )
97 $instance['list'] = '';
98 if( !isset($instance['code1']) )
99 $instance['code1'] = '';
100 if( !isset($instance['code2']) )
101 $instance['code2'] = '';
102 if( !isset($instance['code3']) )
103 $instance['code3'] = '';
104 if( !isset($instance['code4']) )
105 $instance['code4'] = '';
106 if( !isset($instance['code5']) )
107 $instance['code5'] = '';
108 if( !isset($instance['code6']) )
109 $instance['code6'] = '';
110 if( !isset($instance['code7']) )
111 $instance['code7'] = '';
112 if( !isset($instance['code8']) )
113 $instance['code8'] = '';
114 if( !isset($instance['code9']) )
115 $instance['code9'] = '';
116 if( !isset($instance['code10']) )
117 $instance['code10'] = '';
118
119 $title = WCUtils::is_blank($instance['title']) ? 'Welcart '.__('best seller', 'usces') : esc_attr($instance['title']);
120 $rows_num = WCUtils::is_blank($instance['rows_num']) ? 10 : esc_attr($instance['rows_num']);
121 $icon = WCUtils::is_blank($instance['icon']) ? 1 : (int)$instance['icon'];
122 $list = WCUtils::is_blank($instance['list']) ? 1 : (int)$instance['list'];
123 $code1 = esc_attr($instance['code1']);
124 $code2 = esc_attr($instance['code2']);
125 $code3 = esc_attr($instance['code3']);
126 $code4 = esc_attr($instance['code4']);
127 $code5 = esc_attr($instance['code5']);
128 $code6 = esc_attr($instance['code6']);
129 $code7 = esc_attr($instance['code7']);
130 $code8 = esc_attr($instance['code8']);
131 $code9 = esc_attr($instance['code9']);
132 $code10 = esc_attr($instance['code10']);
133 ?>
134 <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>
135 <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>
136 <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>
137 <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>
138 <fieldset><legend><?php _e('handwriting list', 'usces'); ?></legend>
139 <p><?php _e('Please input an article cord.', 'usces'); ?></p>
140 <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>
141 <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>
142 <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>
143 <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>
144 <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>
145 <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>
146 <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>
147 <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>
148 <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>
149 <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>
150 </fieldset>
151 <?php
152 }
153
154 }
155 ?>