PluginProbe
Welcart e-Commerce / 2.11.31
Welcart e-Commerce v2.11.31
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 2.11.31, at widgets/usces_bestseller.php

242 lines 12.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Welcart Bestseller Widget
4 *
5 * @package Welcart
6 */
7
8 /**
9 * Welcart_bestseller Class
10 *
11 * @see WP_Widget
12 */
13 class Welcart_bestseller extends WP_Widget {
14
15 /**
16 * Constructor.
17 */
18 public function __construct() {
19 $widget_ops = array(
20 'classname' => 'widget_welcart_bestseller',
21 'description' => __( 'Display best-selling items.', 'usces' ),
22 );
23 parent::__construct( 'welcart_bestseller', 'Welcart ' . __( 'best seller', 'usces' ), $widget_ops );
24 }
25
26 /**
27 * Echoes the widget content.
28 *
29 * @see WP_Widget::widget
30 * @param array $args Display arguments including 'before_title', 'after_title',
31 * 'before_widget', and 'after_widget'.
32 * @param array $instance The settings for the particular instance of the widget.
33 */
34 public function widget( $args, $instance ) {
35 global $usces;
36 extract( $args );
37
38 if ( ! isset( $instance['title'] ) ) {
39 $instance['title'] = '';
40 }
41 if ( ! isset( $instance['rows_num'] ) ) {
42 $instance['rows_num'] = '';
43 }
44 if ( ! isset( $instance['days'] ) ) {
45 $instance['days'] = '';
46 }
47 if ( ! isset( $instance['icon'] ) ) {
48 $instance['icon'] = '';
49 }
50 if ( ! isset( $instance['list'] ) ) {
51 $instance['list'] = '';
52 }
53 if ( ! isset( $instance['code1'] ) ) {
54 $instance['code1'] = '';
55 }
56 if ( ! isset( $instance['code2'] ) ) {
57 $instance['code2'] = '';
58 }
59 if ( ! isset( $instance['code3'] ) ) {
60 $instance['code3'] = '';
61 }
62 if ( ! isset( $instance['code4'] ) ) {
63 $instance['code4'] = '';
64 }
65 if ( ! isset( $instance['code5'] ) ) {
66 $instance['code5'] = '';
67 }
68 if ( ! isset( $instance['code6'] ) ) {
69 $instance['code6'] = '';
70 }
71 if ( ! isset( $instance['code7'] ) ) {
72 $instance['code7'] = '';
73 }
74 if ( ! isset( $instance['code8'] ) ) {
75 $instance['code8'] = '';
76 }
77 if ( ! isset( $instance['code9'] ) ) {
78 $instance['code9'] = '';
79 }
80 if ( ! isset( $instance['code10'] ) ) {
81 $instance['code10'] = '';
82 }
83
84 $title = $instance['title'];
85 $rows_num = WCUtils::is_blank( $instance['rows_num'] ) ? 10 : (int) $instance['rows_num'];
86 $days = WCUtils::is_blank( $instance['days'] ) ? 30 : (int) $instance['days'];
87 $icon = WCUtils::is_blank( $instance['icon'] ) ? 1 : (int) $instance['icon'];
88 $img_path = file_exists( get_stylesheet_directory() . '/images/bestseller.png' ) ? get_stylesheet_directory_uri() . '/images/bestseller.png' : USCES_FRONT_PLUGIN_URL . '/images/bestseller.png';
89 if ( 1 === $icon ) {
90 $before_title .= '<img src="' . $img_path . '" alt="' . $title . '" />';
91 }
92 $list = WCUtils::is_blank( $instance['list'] ) ? 1 : (int) $instance['list'];
93 if ( 2 === $list ) {
94 $rows_num = 10;
95 }
96
97 wel_esc_script_e( $before_widget );
98 if ( ! empty( $title ) ) {
99 wel_esc_script_e( $before_title . esc_html( $title ) . $after_title );
100 }
101 ?>
102
103 <ul class="ucart_widget_body">
104 <?php
105 if ( 1 === $list ) {
106 usces_list_bestseller( $rows_num, $days );
107 } else {
108 $htm = '';
109 for ( $i = 0; $i < $rows_num; $i++ ) {
110 $cname = 'code' . ( $i + 1 );
111 $code = esc_html( trim( $instance[ $cname ] ) );
112 if ( WCUtils::is_blank( $code ) ) {
113 continue;
114 }
115 $id = $usces->get_postIDbyCode( $code );
116 if ( WCUtils::is_blank( $id ) ) {
117 continue;
118 }
119 $post = get_post( $id );
120 $disp_text = apply_filters( 'usces_widget_bestseller_manual_text', esc_html( $post->post_title ), $id );
121 $list = '<li><a href="' . get_permalink( $id ) . '">' . $disp_text . '</a></li>';
122 $htm .= apply_filters( 'usces_filter_bestseller', $list, $post->ID, $i );
123 }
124 wel_esc_script_e( $htm );
125 }
126 ?>
127 </ul>
128
129 <?php
130 wel_esc_script_e( $after_widget );
131 }
132
133 /**
134 * Updates a particular instance of a widget.
135 *
136 * @see WP_Widget::update
137 * @param array $new_instance New settings for this instance as input by the user via
138 * WP_Widget::form().
139 * @param array $old_instance Old settings for this instance.
140 * @return array Settings to save or bool false to cancel saving.
141 */
142 public function update( $new_instance, $old_instance ) {
143 return $new_instance;
144 }
145
146 /**
147 * Outputs the settings update form.
148 *
149 * @see WP_Widget::form
150 * @param array $instance Current settings.
151 */
152 public function form( $instance ) {
153 if ( ! isset( $instance['title'] ) ) {
154 $instance['title'] = '';
155 }
156 if ( ! isset( $instance['rows_num'] ) ) {
157 $instance['rows_num'] = '';
158 }
159 if ( ! isset( $instance['days'] ) ) {
160 $instance['days'] = '';
161 }
162 if ( ! isset( $instance['icon'] ) ) {
163 $instance['icon'] = '';
164 }
165 if ( ! isset( $instance['list'] ) ) {
166 $instance['list'] = '';
167 }
168 if ( ! isset( $instance['code1'] ) ) {
169 $instance['code1'] = '';
170 }
171 if ( ! isset( $instance['code2'] ) ) {
172 $instance['code2'] = '';
173 }
174 if ( ! isset( $instance['code3'] ) ) {
175 $instance['code3'] = '';
176 }
177 if ( ! isset( $instance['code4'] ) ) {
178 $instance['code4'] = '';
179 }
180 if ( ! isset( $instance['code5'] ) ) {
181 $instance['code5'] = '';
182 }
183 if ( ! isset( $instance['code6'] ) ) {
184 $instance['code6'] = '';
185 }
186 if ( ! isset( $instance['code7'] ) ) {
187 $instance['code7'] = '';
188 }
189 if ( ! isset( $instance['code8'] ) ) {
190 $instance['code8'] = '';
191 }
192 if ( ! isset( $instance['code9'] ) ) {
193 $instance['code9'] = '';
194 }
195 if ( ! isset( $instance['code10'] ) ) {
196 $instance['code10'] = '';
197 }
198
199 $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
200 $rows_num = WCUtils::is_blank( $instance['rows_num'] ) ? 10 : (int) $instance['rows_num'];
201 $days = WCUtils::is_blank( $instance['days'] ) ? 30 : (int) $instance['days'];
202 $icon = WCUtils::is_blank( $instance['icon'] ) ? 1 : (int) $instance['icon'];
203 $list = WCUtils::is_blank( $instance['list'] ) ? 1 : (int) $instance['list'];
204 $code1 = esc_attr( $instance['code1'] );
205 $code2 = esc_attr( $instance['code2'] );
206 $code3 = esc_attr( $instance['code3'] );
207 $code4 = esc_attr( $instance['code4'] );
208 $code5 = esc_attr( $instance['code5'] );
209 $code6 = esc_attr( $instance['code6'] );
210 $code7 = esc_attr( $instance['code7'] );
211 $code8 = esc_attr( $instance['code8'] );
212 $code9 = esc_attr( $instance['code9'] );
213 $code10 = esc_attr( $instance['code10'] );
214 ?>
215 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'usces' ); ?> <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'title' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php wel_esc_script_e( $title ); ?>" /></label></p>
216 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'icon' ) ); ?>"><?php esc_html_e( 'display of icon', 'usces' ); ?>: <select class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'icon' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'icon' ) ); ?>">
217 <option value="1"<?php selected( $icon, 1 ); ?>><?php esc_html_e( 'Indication', 'usces' ); ?></option>
218 <option value="2"<?php selected( $icon, 2 ); ?>><?php esc_html_e( 'Non-indication', 'usces' ); ?></option></select></label>
219 </p>
220 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'rows_num' ) ); ?>"><?php esc_html_e( 'number of indication', 'usces' ); ?>: <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'rows_num' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'rows_num' ) ); ?>" type="text" value="<?php wel_esc_script_e( $rows_num ); ?>" /></label></p>
221 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'days' ) ); ?>"><?php esc_html_e( 'Aggregation period (days)', 'usces' ); ?>: <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'days' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'days' ) ); ?>" type="text" value="<?php wel_esc_script_e( $days ); ?>" /></label></p>
222 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'list' ) ); ?>"><?php esc_html_e( 'automatic count', 'usces' ); ?>: <select class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'list' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'list' ) ); ?>">
223 <option value="1"<?php selected( $list, 1 ); ?>><?php esc_html_e( 'automatic list', 'usces' ); ?></option>
224 <option value="2"<?php selected( $list, 2 ); ?>><?php esc_html_e( 'handwriting list', 'usces' ); ?></option></select></label>
225 </p>
226 <fieldset><legend><?php esc_html_e( 'handwriting list', 'usces' ); ?></legend>
227 <p><?php esc_html_e( 'Please input an article cord.', 'usces' ); ?></p>
228 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'code1' ) ); ?>"><?php esc_html_e( 'item code', 'usces' ); ?>1 : <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'code1' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'code1' ) ); ?>" type="text" value="<?php wel_esc_script_e( $code1 ); ?>" /></label></p>
229 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'code2' ) ); ?>"><?php esc_html_e( 'item code', 'usces' ); ?>2 : <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'code2' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'code2' ) ); ?>" type="text" value="<?php wel_esc_script_e( $code2 ); ?>" /></label></p>
230 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'code3' ) ); ?>"><?php esc_html_e( 'item code', 'usces' ); ?>3 : <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'code3' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'code3' ) ); ?>" type="text" value="<?php wel_esc_script_e( $code3 ); ?>" /></label></p>
231 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'code4' ) ); ?>"><?php esc_html_e( 'item code', 'usces' ); ?>4 : <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'code4' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'code4' ) ); ?>" type="text" value="<?php wel_esc_script_e( $code4 ); ?>" /></label></p>
232 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'code5' ) ); ?>"><?php esc_html_e( 'item code', 'usces' ); ?>5 : <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'code5' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'code5' ) ); ?>" type="text" value="<?php wel_esc_script_e( $code5 ); ?>" /></label></p>
233 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'code6' ) ); ?>"><?php esc_html_e( 'item code', 'usces' ); ?>6 : <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'code6' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'code6' ) ); ?>" type="text" value="<?php wel_esc_script_e( $code6 ); ?>" /></label></p>
234 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'code7' ) ); ?>"><?php esc_html_e( 'item code', 'usces' ); ?>7 : <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'code7' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'code7' ) ); ?>" type="text" value="<?php wel_esc_script_e( $code7 ); ?>" /></label></p>
235 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'code8' ) ); ?>"><?php esc_html_e( 'item code', 'usces' ); ?>8 : <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'code8' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'code8' ) ); ?>" type="text" value="<?php wel_esc_script_e( $code8 ); ?>" /></label></p>
236 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'code9' ) ); ?>"><?php esc_html_e( 'item code', 'usces' ); ?>9 : <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'code9' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'code9' ) ); ?>" type="text" value="<?php wel_esc_script_e( $code9 ); ?>" /></label></p>
237 <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'code10' ) ); ?>"><?php esc_html_e( 'item code', 'usces' ); ?>10 : <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'code10' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'code10' ) ); ?>" type="text" value="<?php wel_esc_script_e( $code10 ); ?>" /></label></p>
238 </fieldset>
239 <?php
240 }
241 }
242