PluginProbe ʕ •ᴥ•ʔ
Wp Social Login and Register Social Counter / trunk
Wp Social Login and Register Social Counter vtrunk
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 / lib / onboard / classes / utils.php
wp-social / lib / onboard / classes Last commit date
ajax.php 7 months ago plugin-data-sender.php 9 months ago plugin-installer.php 7 months ago plugin-skin.php 7 months ago plugin-status.php 4 years ago utils.php 3 years ago
utils.php
211 lines
1 <?php
2
3 namespace WP_Social\Lib\Onboard\Classes;
4
5 use WP_Social\Plugin;
6
7 defined( 'ABSPATH' ) || exit;
8
9 class Utils{
10
11 public static $instance = null;
12 private static $key = 'wp_social_options';
13
14 public static function get_dir(){
15 return Plugin::instance()->lib_dir() . 'onboard/';
16 }
17
18 public static function get_url(){
19 return Plugin::instance()->lib_dir() . 'onboard/';
20 }
21
22 public function get_option($key, $default = ''){
23 $data_all = get_option(self::$key);
24 return (isset($data_all[$key]) && $data_all[$key] != '') ? $data_all[$key] : $default;
25 }
26
27 public function save_option($key, $value = ''){
28 $data_all = get_option(self::$key);
29 $data_all[$key] = $value;
30 update_option(self::$key, $data_all);
31 }
32
33 public function get_settings($key, $default = ''){
34 $data_all = $this->get_option('settings', []);
35 return (isset($data_all[$key]) && $data_all[$key] != '') ? $data_all[$key] : $default;
36 }
37
38 public function save_settings($new_data = ''){
39 $data_old = $this->get_option('settings', []);
40 $data = array_merge($data_old, $new_data);
41 $this->save_option('settings', $data);
42 }
43
44 /*
45 -> this method used to check weather the widget active/deactive
46 -> this method takes two paramitter 1. widget name 2. Active/deactive hook
47 */
48 public function is_widget_active_class( $widget_name, $pro_active ){
49 if($pro_active){
50 return 'label-'.esc_attr($widget_name).' attr-panel-heading';
51 }else{
52 return 'label-'.esc_attr($widget_name).' attr-panel-heading pro-disabled';
53 }
54 }
55
56 public function input($input_options){
57 $defaults = [
58 'type' => null,
59 'name' => '',
60 'value' => '',
61 'class' => '',
62 'label' => '',
63 'info' => '',
64 'disabled' => '',
65 'options' => [],
66 ];
67 $input_options = array_merge($defaults, $input_options);
68
69 if(file_exists(self::get_dir() . 'controls/settings/' . $input_options['type'] . '.php')){
70 extract($input_options);
71 include self::get_dir() . 'controls/settings/' . $input_options['type'] . '.php';
72 }
73 }
74
75 public static function strify($str){
76 return strtolower(preg_replace("/[^A-Za-z0-9]/", "__", $str));
77 }
78
79 public static function instance() {
80 if ( is_null( self::$instance ) ) {
81
82 // Fire the class instance
83 self::$instance = new self();
84 }
85
86 return self::$instance;
87 }
88
89
90 public static function kses( $raw ) {
91
92 $allowed_tags = array(
93 'a' => array(
94 'class' => array(),
95 'href' => array(),
96 'rel' => array(),
97 'title' => array(),
98 'target' => array(),
99 ),
100 'abbr' => array(
101 'title' => array(),
102 ),
103 'b' => array(),
104 'blockquote' => array(
105 'cite' => array(),
106 ),
107 'cite' => array(
108 'title' => array(),
109 ),
110 'code' => array(),
111 'pre' => array(),
112 'del' => array(
113 'datetime' => array(),
114 'title' => array(),
115 ),
116 'dd' => array(),
117 'div' => array(
118 'class' => array(),
119 'title' => array(),
120 'style' => array(),
121 ),
122 'dl' => array(),
123 'dt' => array(),
124 'em' => array(),
125 'strong' => array(),
126 'h1' => array(
127 'class' => array(),
128 ),
129 'h2' => array(
130 'class' => array(),
131 ),
132 'h3' => array(
133 'class' => array(),
134 ),
135 'h4' => array(
136 'class' => array(),
137 ),
138 'h5' => array(
139 'class' => array(),
140 ),
141 'h6' => array(
142 'class' => array(),
143 ),
144 'i' => array(
145 'class' => array(),
146 ),
147 'img' => array(
148 'alt' => array(),
149 'class' => array(),
150 'height' => array(),
151 'src' => array(),
152 'width' => array(),
153 ),
154 'li' => array(
155 'class' => array(),
156 ),
157 'ol' => array(
158 'class' => array(),
159 ),
160 'p' => array(
161 'class' => array(),
162 ),
163 'q' => array(
164 'cite' => array(),
165 'title' => array(),
166 ),
167 'span' => array(
168 'class' => array(),
169 'title' => array(),
170 'style' => array(),
171 ),
172 'iframe' => array(
173 'width' => array(),
174 'height' => array(),
175 'scrolling' => array(),
176 'frameborder' => array(),
177 'allow' => array(),
178 'src' => array(),
179 ),
180 'strike' => array(),
181 'br' => array(),
182 'strong' => array(),
183 'data-wow-duration' => array(),
184 'data-wow-delay' => array(),
185 'data-wallpaper-options' => array(),
186 'data-stellar-background-ratio' => array(),
187 'ul' => array(
188 'class' => array(),
189 ),
190 'svg' => array(
191 'class' => true,
192 'aria-hidden' => true,
193 'aria-labelledby' => true,
194 'role' => true,
195 'xmlns' => true,
196 'width' => true,
197 'height' => true,
198 'viewbox' => true, // <= Must be lower case!
199 ),
200 'g' => array( 'fill' => true ),
201 'title' => array( 'title' => true ),
202 'path' => array( 'd' => true, 'fill' => true, ),
203 );
204
205 if ( function_exists( 'wp_kses' ) ) { // WP is here
206 return wp_kses( $raw, $allowed_tags );
207 } else {
208 return $raw;
209 }
210 }
211 }