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_page.php +88 -50 1.3.22.12.4 View file →
@@ -1,50 +1,88 @@
1 -<?php
2 -
3 -/**
4 - * Welcart_page Class
5 - */
6 -class Welcart_page extends WP_Widget {
7 - /** constructor */
8 - function Welcart_page() {
9 - parent::WP_Widget(false, $name = 'Welcart '.__('Page', 'usces'));
10 - }
11 -
12 - /** @see WP_Widget::widget */
13 - function widget($args, $instance) {
14 - extract( $args );
15 - $title = ( !isset($instance['title']) || WCUtils::is_blank($instance['title'])) ? 'Welcart '.__('Page', 'usces') : $instance['title'];
16 - $icon = ( !isset($instance['icon']) || WCUtils::is_blank($instance['icon'])) ? 1 : (int)$instance['icon'];
17 - $img_path = file_exists(get_stylesheet_directory().'/images/page.png') ? get_stylesheet_directory_uri().'/images/page.png' : USCES_FRONT_PLUGIN_URL . '/images/page.png';
18 - if($icon == 1) $before_title .= '<img src="' . $img_path . '" alt="' . $title . '" />';
19 - ?>
20 - <?php echo $before_widget; ?>
21 - <?php echo $before_title
22 - . esc_html($title)
23 - . $after_title; ?>
24 -
25 - <ul class="ucart_widget_body">
26 - <?php wp_list_pages(apply_filters('usces_filter_wc_widget_page_arg', ('title_li=&include=' . $instance['page']), $instance['page'])) ; ?>
27 - </ul>
28 -
29 - <?php echo $after_widget; ?>
30 - <?php
31 - }
32 -
33 - /** @see WP_Widget::update */
34 - function update($new_instance, $old_instance) {
35 - return $new_instance;
36 - }
37 -
38 - /** @see WP_Widget::form */
39 - function form($instance) {
40 - $title = ( !isset($instance['title']) || WCUtils::is_blank($instance['title'])) ? 'Welcart '.__('Page', 'usces') : esc_attr($instance['title']);
41 - $icon = ( !isset($instance['icon']) || WCUtils::is_blank($instance['icon'])) ? 1 : (int)$instance['icon'];
42 - ?>
43 - <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>
44 - <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>
45 - <p><label for="<?php echo $this->get_field_id('page'); ?>"><?php _e('Page ID(comma separate)', 'usces'); ?>: <input class="widefat" id="<?php echo $this->get_field_id('page'); ?>" name="<?php echo $this->get_field_name('page'); ?>" type="text" value="<?php echo $instance['page']; ?>" /></label></p>
46 - <?php
47 - }
48 -
49 -}
50 -?>
1 +<?php
2 +/**
3 + * Welcart Page Widget
4 + *
5 + * @package Welcart
6 + */
7 +
8 +/**
9 + * Welcart_page Class
10 + */
11 +class Welcart_page extends WP_Widget {
12 +
13 + /**
14 + * Constructor.
15 + */
16 + public function __construct() {
17 + $widget_ops = array(
18 + 'classname' => 'widget_welcart_page',
19 + 'description' => __( 'Display page content.', 'usces' ),
20 + );
21 + parent::__construct( 'welcart_page', 'Welcart ' . __( 'Page', 'usces' ), $widget_ops );
22 + }
23 +
24 + /**
25 + * Echoes the widget content.
26 + *
27 + * @see WP_Widget::widget
28 + * @param array $args Display arguments including 'before_title', 'after_title',
29 + * 'before_widget', and 'after_widget'.
30 + * @param array $instance The settings for the particular instance of the widget.
31 + */
32 + public function widget( $args, $instance ) {
33 + extract( $args );
34 + $title = $instance['title'];
35 + $icon = ( ! isset( $instance['icon'] ) || WCUtils::is_blank( $instance['icon'] ) ) ? 1 : (int) $instance['icon'];
36 + $page = ( ! isset( $instance['page'] ) || WCUtils::is_blank( $instance['page'] ) ) ? '' : $instance['page'];
37 + $img_path = file_exists( get_stylesheet_directory() . '/images/page.png' ) ? get_stylesheet_directory_uri() . '/images/page.png' : USCES_FRONT_PLUGIN_URL . '/images/page.png';
38 + if ( 1 === $icon ) {
39 + $before_title .= '<img src="' . $img_path . '" alt="' . $title . '" />';
40 + }
41 +
42 + wel_esc_script_e( $before_widget );
43 + if ( ! empty( $title ) ) {
44 + wel_esc_script_e( $before_title . esc_html( $title ) . $after_title );
45 + }
46 + ?>
47 +
48 + <ul class="ucart_widget_body">
49 + <?php wp_list_pages( apply_filters( 'usces_filter_wc_widget_page_arg', ( 'title_li=&include=' . $page ), $page ) ); ?>
50 + </ul>
51 +
52 + <?php
53 + wel_esc_script_e( $after_widget );
54 + }
55 +
56 + /**
57 + * Updates a particular instance of a widget.
58 + *
59 + * @see WP_Widget::update
60 + * @param array $new_instance New settings for this instance as input by the user via
61 + * WP_Widget::form().
62 + * @param array $old_instance Old settings for this instance.
63 + * @return array Settings to save or bool false to cancel saving.
64 + */
65 + public function update( $new_instance, $old_instance ) {
66 + return $new_instance;
67 + }
68 +
69 + /**
70 + * Outputs the settings update form.
71 + *
72 + * @see WP_Widget::form
73 + * @param array $instance Current settings.
74 + */
75 + public function form( $instance ) {
76 + $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
77 + $icon = ( ! isset( $instance['icon'] ) || WCUtils::is_blank( $instance['icon'] ) ) ? 1 : (int) $instance['icon'];
78 + $page = ( ! isset( $instance['page'] ) || WCUtils::is_blank( $instance['page'] ) ) ? '' : $instance['page'];
79 + ?>
80 + <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>
81 + <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' ) ); ?>">
82 + <option value="1"<?php selected( $icon, 1 ); ?>><?php esc_html_e( 'Indication', 'usces' ); ?></option>
83 + <option value="2"<?php selected( $icon, 2 ); ?>><?php esc_html_e( 'Non-indication', 'usces' ); ?></option></select></label>
84 + </p>
85 + <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'page' ) ); ?>"><?php esc_html_e( 'Page ID(comma separate)', 'usces' ); ?>: <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'page' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'page' ) ); ?>" type="text" value="<?php wel_esc_script_e( $page ); ?>" /></label></p>
86 + <?php
87 + }
88 +}