elementor
4 years ago
admin-create-shortcode.php
7 years ago
admin-create-user.php
4 years ago
admin-custom-function.php
4 years ago
admin-rest-api.php
4 years ago
admin-settings.php
4 years ago
admin-social-button.php
4 years ago
admin-social-enque-script.php
5 years ago
counter-widget.php
4 years ago
counter.php
4 years ago
custom-function.php
4 years ago
login-widget.php
4 years ago
login.php
5 years ago
share-widget.php
4 years ago
share.php
4 years ago
counter-widget.php
179 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 | * @author UnKnown |
| 46 | * @modifiedBy Md. Atiqur Rahman <atiqur.su@gmail.com> |
| 47 | * |
| 48 | * @param $args |
| 49 | * @param $instance |
| 50 | */ |
| 51 | public function widget($args, $instance) { |
| 52 | |
| 53 | extract($args); |
| 54 | |
| 55 | $title = isset($instance['title']) ? $instance['title'] : ''; |
| 56 | $layout = isset($instance['layout']) ? $instance['layout'] : ''; |
| 57 | $hover = isset($instance['hover_effect']) ? $instance['hover_effect'] : ''; |
| 58 | $providers = isset($instance['providers']) ? $instance['providers'] : ''; |
| 59 | $cusClass = isset($instance['customclass']) ? $instance['customclass'] : ''; |
| 60 | $box_only = isset($instance['box_only']) ? $instance['box_only'] : false; |
| 61 | |
| 62 | |
| 63 | $counter = New \WP_Social\Inc\Counter(false); |
| 64 | |
| 65 | $config = []; |
| 66 | $config['class'] = $cusClass; |
| 67 | $config['style'] = $layout; |
| 68 | $config['hover'] = $hover; |
| 69 | $providers = (is_array($providers) && !empty($providers) && !empty($providers[0])) ? $providers : 'all'; |
| 70 | |
| 71 | echo $before_widget . $before_title . $title . $after_title; |
| 72 | |
| 73 | echo $counter->get_counter_data($providers, $config); |
| 74 | |
| 75 | echo $after_widget; |
| 76 | } |
| 77 | |
| 78 | |
| 79 | /** |
| 80 | * |
| 81 | * @author UnKnown |
| 82 | * @modifiedBy Md. Atiqur Rahman <atiqur.su@gmail.com> |
| 83 | * |
| 84 | * @param $instance |
| 85 | */ |
| 86 | public function form($instance) { |
| 87 | |
| 88 | $defaults = array('title' => __('Follow us', 'wp-social'), 'layout' => 'block', 'columns' => 'xs-3-column', 'box_only' => false, 'providers' => '', 'customclass' => ''); |
| 89 | $instance = wp_parse_args((array)$instance, $defaults); |
| 90 | $select_provider = is_array($instance['providers']) && !empty($instance['providers']) && !empty($instance['providers'][0]) ? $instance['providers'] : []; |
| 91 | |
| 92 | $core_providers = Providers::get_core_providers_count(); |
| 93 | |
| 94 | ?> |
| 95 | <p> |
| 96 | <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Counter Title :', 'wp-social') ?> </label> |
| 97 | <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" |
| 98 | value="<?php echo $instance['title']; ?>" class="widefat" type="text"/> |
| 99 | </p> |
| 100 | |
| 101 | <p> |
| 102 | <label for="<?php echo $this->get_field_id('providers'); ?>"><?php _e('Providers :', 'wp-social') ?></label> |
| 103 | <select class="widefat" |
| 104 | id="<?php echo $this->get_field_id('providers'); ?>" |
| 105 | name="<?php echo $this->get_field_name('providers'); ?>[]" multiple> |
| 106 | <option value="" <?php echo empty($select_provider) ? 'selected' : '' ?>>All</option> |
| 107 | <?php |
| 108 | foreach($core_providers as $k => $v): |
| 109 | ?> |
| 110 | <option value="<?php echo $k; ?>" <?php echo (in_array($k, $select_provider)) ? 'selected' : ''; ?>> |
| 111 | <?php echo $v['label'] ?> |
| 112 | </option> <?php |
| 113 | endforeach; ?> |
| 114 | </select> |
| 115 | </p> |
| 116 | |
| 117 | <p> |
| 118 | <label for="<?php echo $this->get_field_id('layout'); ?>"><?php _e('Style :', 'wp-social') ?></label> |
| 119 | <select class="widefat" id="<?php echo $this->get_field_id('layout'); ?>" |
| 120 | name="<?php echo $this->get_field_name('layout'); ?>"> |
| 121 | <?php |
| 122 | foreach($this->styleArr as $k => $v): |
| 123 | ?> |
| 124 | <option value="<?php echo (!did_action('wslu_social_pro/plugin_loaded')) && ($v['package'] == 'pro') ? 'wslu-pro-only' : $k; ?>" <?php echo ($instance['layout'] == $k) ? 'selected' : ''; ?>> |
| 125 | <?php |
| 126 | echo esc_html($v['name']); |
| 127 | esc_html_e((!did_action('wslu_social_pro/plugin_loaded')) && ($v['package'] == 'pro') ? '(Pro Only)' : '', 'wp-social'); |
| 128 | ?> |
| 129 | </option> |
| 130 | <?php endforeach; ?> |
| 131 | </select> |
| 132 | </p> |
| 133 | |
| 134 | <?php |
| 135 | |
| 136 | if(did_action('wslu_social_pro/plugin_loaded')): |
| 137 | |
| 138 | $this->hover_effect = \WP_Social_Pro\Inc\Admin_Settings::$counter_hover_effects; |
| 139 | ?> |
| 140 | <p> |
| 141 | <label for="<?php echo $this->get_field_id('hover_effect'); ?>"><?php _e('Hover effect :', 'wp-social') ?></label> |
| 142 | <select class="widefat" id="<?php echo $this->get_field_id('hover_effect'); ?>" |
| 143 | name="<?php echo $this->get_field_name('hover_effect'); ?>"> |
| 144 | <?php |
| 145 | foreach($this->hover_effect as $k => $v): |
| 146 | ?> |
| 147 | <option value="<?php echo $k; ?>" <?php echo (isset($instance['hover_effect']) && $instance['hover_effect'] == $k) ? 'selected' : ''; ?>> <?php _e($v['name'], 'wp-social'); ?> </option> |
| 148 | <?php endforeach; ?> |
| 149 | </select> |
| 150 | </p> |
| 151 | |
| 152 | <?php |
| 153 | |
| 154 | endif; ?> |
| 155 | |
| 156 | <p> |
| 157 | <label for="<?php echo $this->get_field_id('customclass'); ?>"><?php _e('Custom Class :', 'wp-social') ?> </label> |
| 158 | <input id="<?php echo $this->get_field_id('customclass'); ?>" |
| 159 | name="<?php echo $this->get_field_name('customclass'); ?>" |
| 160 | value="<?php echo $instance['customclass']; ?>" class="widefat" type="text"/> |
| 161 | </p> |
| 162 | <?php |
| 163 | } |
| 164 | |
| 165 | |
| 166 | public function update($new_instance, $old_instance) { |
| 167 | |
| 168 | $instance = $old_instance; |
| 169 | $instance['providers'] = $new_instance['providers'] ; |
| 170 | $instance['layout'] = $new_instance['layout'] ; |
| 171 | $instance['hover_effect'] = isset($new_instance['hover_effect']) ? $new_instance['hover_effect'] : '' ; |
| 172 | $instance['title'] = $new_instance['title'] ; |
| 173 | $instance['box_only'] = isset($new_instance['box_only']) ? $new_instance['box_only'] : false ; |
| 174 | $instance['customclass'] = $new_instance['customclass'] ; |
| 175 | |
| 176 | return $instance; |
| 177 | } |
| 178 | } |
| 179 |