PluginProbe
Welcart e-Commerce / 2.12.4
Welcart e-Commerce v2.12.4
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
← All changes | widgets/usces_post.php +96 -57 1.4.122.12.4 View file →
@@ -1,57 +1,96 @@
1 -<?php
2 -
3 -/**
4 - * Welcart_post Class
5 - */
6 -class Welcart_post extends WP_Widget {
7 - /** constructor */
8 - function Welcart_post() {
9 - parent::WP_Widget(false, $name = 'Welcart '.__('Post', 'usces'));
10 - }
11 -
12 - /** @see WP_Widget::widget */
13 - function widget($args, $instance) {
14 - extract( $args );
15 - $wid = str_replace('-', '_', $this->id);
16 - $title = ( !isset($instance['title']) || WCUtils::is_blank($instance['title'])) ? 'Welcart '.__('Post', 'usces') : $instance['title'];
17 - $rows_num = ( !isset($instance['rows_num']) || WCUtils::is_blank($instance['rows_num'])) ? 3 : $instance['rows_num'];
18 - $icon = ( !isset($instance['icon']) || WCUtils::is_blank($instance['icon'])) ? 1 : (int)$instance['icon'];
19 - //if($icon == 1) $before_title = '<div class="widget_title"><img src="' . USCES_PLUGIN_URL . '/images/infomation.png" alt="' . $title . '" width="24" height="24" />';
20 - $img_path = file_exists(get_stylesheet_directory().'/images/post.png') ? get_stylesheet_directory_uri().'/images/post.png' : USCES_FRONT_PLUGIN_URL . '/images/post.png';
21 - if($icon == 1) $before_title .= '<img src="' . $img_path . '" alt="' . $title . '" />';
22 - ?>
23 - <?php echo $before_widget; ?>
24 - <?php echo $before_title
25 - . apply_filters( 'usces_filter_post_widget_title', esc_html($title), $instance)
26 - . $after_title; ?>
27 -
28 - <ul class="ucart_widget_body <?php echo $instance['category']; ?>">
29 - <?php usces_list_post( $instance['category'], $rows_num, $wid ) ; ?>
30 - </ul>
31 -
32 - <?php echo $after_widget; ?>
33 - <?php
34 - }
35 -
36 - /** @see WP_Widget::update */
37 - function update($new_instance, $old_instance) {
38 - return $new_instance;
39 - }
40 -
41 - /** @see WP_Widget::form */
42 - function form($instance) {
43 - $wid = ('welcart_post-__i__' != $this->id) ? str_replace('-', '_', $this->id) : '';
44 - $title = ( !isset($instance['title']) || WCUtils::is_blank($instance['title'])) ? 'Welcart '.__('Post', 'usces') : esc_attr($instance['title']);
45 - $rows_num = ( !isset($instance['rows_num']) || WCUtils::is_blank($instance['rows_num'])) ? 3 : esc_attr($instance['rows_num']);
46 - $icon = ( !isset($instance['icon']) || WCUtils::is_blank($instance['icon'])) ? 1 : (int)$instance['icon'];
47 - ?>
48 - <p>ID : <?php echo $wid; ?></p>
49 - <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>
50 - <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>
51 - <p><label for="<?php echo $this->get_field_id('category'); ?>"><?php _e('category slug', 'usces'); ?> <input class="widefat" id="<?php echo $this->get_field_id('rows_num'); ?>" name="<?php echo $this->get_field_name('category'); ?>" type="text" value="<?php echo $instance['category']; ?>" /></label></p>
52 - <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>
53 - <?php
54 - }
55 -
56 -}
57 -?>
1 +<?php
2 +/**
3 + * Welcart Post Widget
4 + *
5 + * @package Welcart
6 + */
7 +
8 +/**
9 + * Welcart_post Class
10 + *
11 + * @see WP_Widget
12 + */
13 +class Welcart_post extends WP_Widget {
14 +
15 + /**
16 + * Constructor.
17 + */
18 + public function __construct() {
19 + $widget_ops = array(
20 + 'classname' => 'widget_welcart_post',
21 + 'description' => __( 'Display recent posts.', 'usces' ),
22 + );
23 + parent::__construct( 'welcart_post', 'Welcart ' . __( 'Post', '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 + extract( $args );
36 + $wid = str_replace( '-', '_', $this->id );
37 + $title = $instance['title'];
38 + $rows_num = ( ! isset( $instance['rows_num'] ) || WCUtils::is_blank( $instance['rows_num'] ) ) ? 3 : $instance['rows_num'];
39 + $category = ( ! isset( $instance['category'] ) || WCUtils::is_blank( $instance['category'] ) ) ? '' : $instance['category'];
40 + $icon = ( ! isset( $instance['icon'] ) || WCUtils::is_blank( $instance['icon'] ) ) ? 1 : (int) $instance['icon'];
41 + $img_path = file_exists( get_stylesheet_directory() . '/images/post.png' ) ? get_stylesheet_directory_uri() . '/images/post.png' : USCES_FRONT_PLUGIN_URL . '/images/post.png';
42 + if ( 1 === $icon ) {
43 + $before_title .= '<img src="' . $img_path . '" alt="' . $title . '" />';
44 + }
45 +
46 + wel_esc_script_e( $before_widget );
47 + if ( ! empty( $title ) ) {
48 + wel_esc_script_e( $before_title . apply_filters( 'usces_filter_post_widget_title', esc_html( $title ), $instance ) . $after_title );
49 + }
50 + ?>
51 +
52 + <ul class="ucart_widget_body <?php echo esc_attr( $category ); ?>">
53 + <?php usces_list_post( $category, $rows_num, $wid ); ?>
54 + </ul>
55 +
56 + <?php
57 + wel_esc_script_e( $after_widget );
58 + }
59 +
60 + /**
61 + * Updates a particular instance of a widget.
62 + *
63 + * @see WP_Widget::update
64 + * @param array $new_instance New settings for this instance as input by the user via
65 + * WP_Widget::form().
66 + * @param array $old_instance Old settings for this instance.
67 + * @return array Settings to save or bool false to cancel saving.
68 + */
69 + public function update( $new_instance, $old_instance ) {
70 + return $new_instance;
71 + }
72 +
73 + /**
74 + * Outputs the settings update form.
75 + *
76 + * @see WP_Widget::form
77 + * @param array $instance Current settings.
78 + */
79 + public function form( $instance ) {
80 + $wid = ( 'welcart_post-__i__' !== $this->id ) ? str_replace( '-', '_', $this->id ) : '';
81 + $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
82 + $rows_num = ( ! isset( $instance['rows_num'] ) || WCUtils::is_blank( $instance['rows_num'] ) ) ? 3 : esc_attr( $instance['rows_num'] );
83 + $category = ( ! isset( $instance['category'] ) || WCUtils::is_blank( $instance['category'] ) ) ? '' : esc_attr( $instance['category'] );
84 + $icon = ( ! isset( $instance['icon'] ) || WCUtils::is_blank( $instance['icon'] ) ) ? 1 : (int) $instance['icon'];
85 + ?>
86 + <p>ID : <?php wel_esc_script_e( $wid ); ?></p>
87 + <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>
88 + <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' ) ); ?>">
89 + <option value="1"<?php selected( $icon, 1 ); ?>><?php esc_html_e( 'Indication', 'usces' ); ?></option>
90 + <option value="2"<?php selected( $icon, 2 ); ?>><?php esc_html_e( 'Non-indication', 'usces' ); ?></option></select></label>
91 + </p>
92 + <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'category' ) ); ?>"><?php esc_html_e( 'category slug', 'usces' ); ?> <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'category' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'category' ) ); ?>" type="text" value="<?php wel_esc_script_e( $category ); ?>" /></label></p>
93 + <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>
94 + <?php
95 + }
96 +}