PluginProbe ʕ •ᴥ•ʔ
Wp Social Login and Register Social Counter / 3.2.1
Wp Social Login and Register Social Counter v3.2.1
3.2.1 trunk 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.10 1.3.11 1.3.2 1.3.3 1.3.4 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.4 1.4.5 1.4.6 1.4.8 1.4.9 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.8 2.2.9 3.0.0 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0
wp-social / inc / counter-widget.php
wp-social / inc Last commit date
elementor 3 years ago admin-create-shortcode.php 7 years ago admin-create-user.php 1 week ago admin-custom-function.php 1 week ago admin-rest-api.php 1 week ago admin-settings.php 2 years ago admin-social-button.php 1 week ago admin-social-enque-script.php 5 years ago counter-widget.php 1 week ago counter.php 1 week ago custom-function.php 5 years ago login-widget.php 3 years ago login.php 5 years ago share-widget.php 1 week ago share.php 1 week ago
counter-widget.php
182 lines
1 <?php
2
3 namespace WP_Social\Inc;
4
5 use WP_Social\App\Providers;
6
7 defined('ABSPATH') || exit;
8
9
10 /**
11 * Class Name : Counter_Widget;
12 * Class Details : Create Widget for XS Social Login Plugin
13 *
14 * @params : void
15 * @return : void
16 *
17 * @since : 1.0
18 */
19 class Counter_Widget extends \WP_Widget {
20
21 public $styleArr = [];
22 public $providers = [];
23 private $hover_effect = [];
24
25 public function __construct() {
26
27 $widget_ops = array(
28 'classname' => 'xs_counter-widget',
29 'description' => __('Wp Social Login System for Facebook, Twitter, Linkedin, Dribble, Pinterest, Post, Comments counter.', 'wp-social')
30 );
31
32 parent::__construct('Counter_Widget', __('WSLU Social Counter', 'wp-social'), $widget_ops, []);
33
34 $this->styleArr = \WP_Social\Inc\Admin_Settings::counter_styles();
35 }
36
37 public static function register() {
38
39 register_widget('WP_Social\Inc\Counter_Widget');
40 }
41
42
43 /**
44 *
45 * @param $args
46 * @param $instance
47 */
48 public function widget($args, $instance) {
49
50 extract($args);
51
52 $title = isset($instance['title']) ? $instance['title'] : '';
53 $layout = isset($instance['layout']) ? $instance['layout'] : '';
54 $hover = isset($instance['hover_effect']) ? $instance['hover_effect'] : '';
55 $providers = isset($instance['providers']) ? $instance['providers'] : '';
56 $cusClass = isset($instance['customclass']) ? $instance['customclass'] : '';
57 $box_only = isset($instance['box_only']) ? $instance['box_only'] : false;
58
59
60 $counter = New \WP_Social\Inc\Counter(false);
61
62 $config = [];
63 $config['class'] = $cusClass;
64 $config['style'] = $layout;
65 $config['hover'] = $hover;
66 $providers = (is_array($providers) && !empty($providers) && !empty($providers[0])) ? $providers : 'all';
67
68 echo wp_kses(($before_widget . $before_title . $title . $after_title), \WP_Social\Helper\Helper::get_kses_array());
69
70 echo wp_kses(($counter->get_counter_data($providers, $config)), \WP_Social\Helper\Helper::get_kses_array());
71
72 echo wp_kses(($after_widget), \WP_Social\Helper\Helper::get_kses_array());
73 }
74
75
76 /**
77 *
78 * @param $instance
79 */
80 public function form($instance) {
81
82 $defaults = array('title' => __('Follow us', 'wp-social'), 'layout' => 'block', 'columns' => 'xs-3-column', 'box_only' => false, 'providers' => '', 'customclass' => '');
83 $instance = wp_parse_args((array)$instance, $defaults);
84 $select_provider = is_array($instance['providers']) && !empty($instance['providers']) && !empty($instance['providers'][0]) ? $instance['providers'] : [];
85
86 $core_providers = Providers::get_core_providers_count();
87
88 ?>
89 <p>
90 <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('Counter Title :', 'wp-social') ?> </label>
91 <input id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>"
92 value="<?php echo esc_attr($instance['title']); ?>" class="widefat" type="text"/>
93 </p>
94
95 <p>
96 <label for="<?php echo esc_attr($this->get_field_id('providers')); ?>"><?php esc_html_e('Providers :', 'wp-social') ?></label>
97 <select class="widefat"
98 id="<?php echo esc_attr($this->get_field_id('providers')); ?>"
99 name="<?php echo esc_attr($this->get_field_name('providers')); ?>[]" multiple>
100 <option value="" <?php echo empty($select_provider) ? 'selected' : '' ?>>All</option>
101 <?php
102 foreach($core_providers as $k => $v):
103 ?>
104 <option value="<?php echo esc_attr($k); ?>" <?php echo esc_attr((in_array($k, $select_provider)) ? 'selected' : ''); ?>>
105 <?php echo esc_html($v['label']) ?>
106 </option> <?php
107 endforeach; ?>
108 </select>
109 </p>
110
111 <p>
112 <label for="<?php echo esc_attr($this->get_field_id('layout')); ?>"><?php esc_html_e('Style :', 'wp-social') ?></label>
113 <select class="widefat" id="<?php echo esc_attr($this->get_field_id('layout')); ?>"
114 name="<?php echo esc_attr($this->get_field_name('layout')); ?>">
115 <?php
116 foreach($this->styleArr as $k => $v):
117 ?>
118 <option value="<?php echo esc_attr((!did_action('wslu_social_pro/plugin_loaded')) && ($v['package'] == 'pro') ? 'wslu-pro-only' : $k); ?>" <?php echo esc_attr(($instance['layout'] == $k) ? 'selected' : ''); ?>>
119 <?php
120 echo esc_html($v['name']);
121 if((!did_action('wslu_social_pro/plugin_loaded')) && ($v['package'] == 'pro')) {
122 esc_html_e('(Pro Only)', 'wp-social');
123 }
124 ?>
125 </option>
126 <?php endforeach; ?>
127 </select>
128 </p>
129
130 <?php
131
132 if(did_action('wslu_social_pro/plugin_loaded')):
133
134 if( method_exists( \WP_Social_Pro\Inc\Admin_Settings::class, 'counter_hover_effects' ) ){
135
136 $this->hover_effect = \WP_Social_Pro\Inc\Admin_Settings::counter_hover_effects();
137
138 }else{
139
140 $this->hover_effect = \WP_Social_Pro\Inc\Admin_Settings::$counter_hover_effects;
141
142 }
143 ?>
144 <p>
145 <label for="<?php echo esc_attr($this->get_field_id('hover_effect')); ?>"><?php esc_html_e('Hover effect :', 'wp-social') ?></label>
146 <select class="widefat" id="<?php echo esc_attr($this->get_field_id('hover_effect')); ?>"
147 name="<?php echo esc_attr($this->get_field_name('hover_effect')); ?>">
148 <?php
149 foreach($this->hover_effect as $k => $v):
150 ?>
151 <option value="<?php echo esc_attr($k); ?>" <?php echo esc_attr((isset($instance['hover_effect']) && $instance['hover_effect'] == $k) ? 'selected' : ''); ?>> <?php esc_html_e($v['name'], 'wp-social'); ?> </option>
152 <?php endforeach; ?>
153 </select>
154 </p>
155
156 <?php
157
158 endif; ?>
159
160 <p>
161 <label for="<?php echo esc_attr($this->get_field_id('customclass')); ?>"><?php esc_html_e('Custom Class :', 'wp-social') ?> </label>
162 <input id="<?php echo esc_attr($this->get_field_id('customclass')); ?>"
163 name="<?php echo esc_attr($this->get_field_name('customclass')); ?>"
164 value="<?php echo esc_attr($instance['customclass']); ?>" class="widefat" type="text"/>
165 </p>
166 <?php
167 }
168
169 public function update($new_instance, $old_instance) {
170
171 $instance = $old_instance;
172 $instance['providers'] = $new_instance['providers'] ;
173 $instance['layout'] = $new_instance['layout'] ;
174 $instance['hover_effect'] = isset($new_instance['hover_effect']) ? $new_instance['hover_effect'] : '' ;
175 $instance['title'] = $new_instance['title'] ;
176 $instance['box_only'] = isset($new_instance['box_only']) ? $new_instance['box_only'] : false ;
177 $instance['customclass'] = $new_instance['customclass'] ;
178
179 return $instance;
180 }
181 }
182