PluginProbe ʕ •ᴥ•ʔ
Wp Social Login and Register Social Counter / 1.8.2
Wp Social Login and Register Social Counter v1.8.2
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 / lib / pro-awareness / pro-awareness.php
wp-social / lib / pro-awareness Last commit date
assets 5 years ago pro-awareness.php 4 years ago
pro-awareness.php
443 lines
1 <?php
2
3 namespace Wpmet\Libs;
4
5 defined('ABSPATH') || exit;
6
7 if(!class_exists('\Wpmet\Libs\Pro_Awareness')) :
8
9 class Pro_Awareness
10 {
11
12 private static $instance;
13
14 private $text_domain;
15 private $plugin_file;
16 private $parent_menu_slug;
17 private $menu_slug = '_get_help';
18 private $default_grid_link = 'https://help.wpmet.com/';
19 private $default_grid_title = 'Support Center';
20 private $default_grid_thumbnail = '';
21 private $default_grid_desc = '';
22 private $pro_link_conf = [];
23
24 private $grids = [];
25 private $action_links = [];
26 private $row_meta_links = [];
27 private $parent_menu_text = 'Get Help';
28
29
30 protected $script_version = '1.0.3';
31
32 /**
33 * Get version of this script
34 *
35 * @return string Version name
36 */
37 public function get_version() {
38 return $this->script_version;
39 }
40
41 /**
42 * Get current directory path
43 *
44 * @return string
45 */
46 public function get_script_location() {
47 return __FILE__;
48 }
49
50
51 public static function instance($text_domain) {
52
53 self::$instance = new self();
54
55 return self::$instance->set_text_domain($text_domain);
56 }
57
58 protected function set_text_domain($val) {
59
60 $this->text_domain = $val;
61
62 return $this;
63 }
64
65 private function default_grid() {
66
67 return [
68 'url' => $this->default_grid_link,
69 'title' => $this->default_grid_title,
70 'thumbnail' => $this->default_grid_thumbnail,
71 'description' => $this->default_grid_desc,
72 ];
73 }
74
75 public function set_parent_menu_text($text) {
76
77 $this->parent_menu_text = $text;
78
79 return $this;
80 }
81
82 public function set_default_grid_link($url) {
83
84 $this->default_grid_link = $url;
85
86 return $this;
87 }
88
89 public function set_default_grid_title($title) {
90
91 $this->default_grid_title = $title;
92
93 return $this;
94 }
95
96 public function set_default_grid_desc($title) {
97
98 $this->default_grid_desc = $title;
99
100 return $this;
101 }
102
103 public function set_default_grid_thumbnail($thumbnail) {
104
105 $this->default_grid_thumbnail = $thumbnail;
106
107 return $this;
108 }
109
110 public function set_parent_menu_slug($slug) {
111
112 $this->parent_menu_slug = $slug;
113
114 return $this;
115 }
116
117
118 public function set_menu_slug($slug) {
119
120 $this->menu_slug = $slug;
121
122 return $this;
123 }
124
125 public function set_plugin_file($plugin_file) {
126
127 $this->plugin_file = $plugin_file;
128
129 return $this;
130 }
131
132 public function set_pro_link($url, $conf = []) {
133
134 if($url == '') {
135 return $this;
136 }
137
138 $this->pro_link_conf[] = [
139 'url' => $url,
140 'anchor' => empty($conf['anchor']) ? '<span style="color: #FCB214;" class="pro_aware pro">Upgrade To Premium</span>' : $conf['anchor'],
141 'permission' => empty($conf['permission']) ? 'manage_options' : $conf['permission'],
142 ];
143
144 return $this;
145 }
146
147 /**
148 * Set page grid
149 */
150 public function set_page_grid($conf = []) {
151
152 if(!empty($conf['url'])) {
153
154 $this->grids[] = [
155 'url' => $conf['url'],
156 'title' => empty($conf['title']) ? esc_html__('Default Title', 'wp-social') : $conf['title'],
157 'thumbnail' => empty($conf['thumbnail']) ? '' : esc_url($conf['thumbnail']),
158 'description' => empty($conf['description']) ? '' : $conf['description'],
159 ];
160 }
161
162 return $this;
163 }
164
165 /**
166 * @deprecated This method will be removed
167 */
168 public function set_grid($conf = []) {
169 $this->set_page_grid($conf);
170
171 return $this;
172 }
173
174 protected function prepare_pro_links() {
175
176 if(!empty($this->pro_link_conf)) {
177
178 foreach($this->pro_link_conf as $conf) {
179
180 add_submenu_page($this->parent_menu_slug, $conf['anchor'], $conf['anchor'], $conf['permission'], $conf['url'], '');
181 }
182 }
183 }
184
185 protected function prepare_grid_links() {
186
187 if(!empty($this->grids)) {
188
189 add_submenu_page($this->parent_menu_slug, $this->parent_menu_text, $this->parent_menu_text, 'manage_options', $this->text_domain . $this->menu_slug, [$this, 'generate_grids']);
190 }
191 }
192
193
194 public function generate_grids() {
195
196 /**
197 * Adding default grid at first position
198 */
199 array_unshift($this->grids, $this->default_grid());
200
201 ?>
202
203
204 <div class="pro_aware grid_container wpmet_pro_a-grid-container">
205
206 <?php do_action($this->text_domain.'/pro_awareness/before_grid_contents'); ?>
207
208 <div class="wpmet_pro_a-row">
209 <?php
210 foreach($this->grids as $grid) {
211 ?>
212 <div class="grid wpmet_pro_a-grid">
213 <div class="wpmet_pro_a-grid-inner">
214 <a target="_blank" href="<?php echo esc_url($grid['url']); ?>"
215 class="wpmet_pro_a_wrapper" title="<?php echo esc_attr($grid['title']); ?>"
216 title="<?php echo esc_attr($grid['title']); ?>">
217 <div class="wpmet_pro_a_thumb">
218 <img src="<?php echo esc_attr($grid['thumbnail']); ?>" alt="Thumbnail">
219 </div>
220 <!-- // thumbnail -->
221
222 <h4 class="wpmet_pro_a_grid_title"><?php echo esc_attr($grid['title']); ?></h4>
223 <?php if(!empty($grid['description'])) { ?>
224 <p class="wpmet_pro_a_description"><?php echo esc_html($grid['description']); ?></p>
225 <!-- // description -->
226 <?php } ?>
227 <!-- // title -->
228 </a>
229 </div>
230 </div>
231 <?php
232 } ?>
233 </div>
234
235 <?php do_action($this->text_domain.'/pro_awareness/after_grid_contents'); ?>
236
237 </div>
238
239 <?php
240 }
241
242 public static function enqueue_scripts() {
243 echo "
244 <script>
245
246 </script>
247
248 <style>
249 .wpmet_pro_a-grid-container {
250 max-width: 1140px;
251 width: 100%;
252 padding-right: 15px;
253 padding-left: 15px;
254 box-sizing: border-box;
255 margin-top: 50px;
256 }
257
258 .wpmet_pro_a-grid-inner {
259 margin-bottom: 20px;
260 background-color: #fff;
261 border-radius: 4px;
262 box-shadow: 0px 2px 5px 10px rgba(0,0,0,.01);
263 transition: all .4s ease;
264 }
265 .wpmet_pro_a-grid-inner .wpmet_pro_a_wrapper {
266 padding: 35px 50px;
267 display: block;
268 }
269
270 .wpmet_pro_a-grid-inner:hover {
271 transform: translateY(-3px);
272 box-shadow: 0px 10px 15px 15px rgba(0,0,0,.05);
273 }
274
275 .wpmet_pro_a-row {
276 display: -webkit-box;
277 display: -ms-flexbox;
278 display: flex;
279 -ms-flex-wrap: wrap;
280 flex-wrap: wrap;
281 margin-right: -15px;
282 margin-left: -15px;
283 box-sizing: border-box;
284 }
285
286 .wpmet_pro_a-grid {
287 padding-right: 15px;
288 padding-left: 15px;
289 position: relative;
290 width: 100%;
291 min-height: 1px;
292 box-sizing: border-box;
293 }
294
295 .wpmet_pro_a_thumb {
296 min-height: 76px;
297 margin-bottom: 10px;
298 display: block;
299 border-radius: inherit;
300 }
301
302 .wpmet_pro_a_grid_title {
303 font-size:1.6rem;
304 margin:0;
305 color: #222;
306 display: inline-block;
307 line-height: normal;
308 text-decoration: none;
309 }
310
311 .wpmet_pro_a_description {
312 margin-bottom: 0;
313 }
314 .wp-submenu > li > a{
315 position: relative;
316 }
317
318 @media (min-width: 991px) {
319 .wpmet_pro_a-grid {
320 -webkit-box-flex: 0;
321 -ms-flex: 0 0 33.333333%;
322 flex: 0 0 33.333333%;
323 max-width: 33.333333%;
324 }
325 }
326
327 @media (max-width: 991px) and (min-width: 768px) {
328 .wpmet_pro_a-grid {
329 -webkit-box-flex: 0;
330 -ms-flex: 0 0 50%;
331 flex: 0 0 50%;
332 max-width: 50%;
333 }
334 }
335
336 @media (max-width: 767px) {
337 .wpmet_pro_a-grid {
338 -webkit-box-flex: 0;
339 -ms-flex: 0 0 100%;
340 flex: 0 0 100%;
341 max-width: 100%;
342 }
343 .wpmet_pro_a_grid_title {
344 font-size: 1.2rem;
345 }
346 }
347 </style>
348 ";
349 }
350
351 public function insert_plugin_links($links) {
352
353 foreach($this->action_links as $action_link) {
354
355 if(!empty($action_link['link']) && !empty($action_link['text'])) {
356
357 $attributes = '';
358
359 if(!empty($action_link['attr'])) {
360
361 foreach($action_link['attr'] as $key => $val) {
362
363 $attributes .= $key.'="'.esc_attr($val).'" ';
364 }
365 }
366
367 $links[] = sprintf('<a href="%s" ' . $attributes . ' > %s </a>', $action_link['link'], esc_html($action_link['text']));
368 }
369 }
370
371
372 return $links;
373 }
374
375 public function insert_plugin_row_meta($links, $file) {
376 if($file == $this->plugin_file) {
377
378 foreach($this->row_meta_links as $meta) {
379
380 if(!empty($meta['link']) && !empty($meta['text'])) {
381
382 $attributes = '';
383
384 if(!empty($meta['attr'])) {
385
386 foreach($meta['attr'] as $key => $val) {
387
388 $attributes .= $key.'="'.esc_attr($val).'" ';
389 }
390 }
391
392 $links[] = sprintf('<a href="%s" %s > %s </a>', $meta['link'], $attributes, esc_html($meta['text']));
393 }
394 }
395
396 }
397
398 return $links;
399 }
400
401 public function set_plugin_action_link($text, $link, $attr = []) {
402
403 $this->action_links[] = [
404 'text' => $text,
405 'link' => $link,
406 'attr' => $attr,
407 ];
408
409 return $this;
410 }
411
412 public function set_plugin_row_meta($text, $link, $attr = []) {
413
414 $this->row_meta_links[] = [
415 'text' => $text,
416 'link' => $link,
417 'attr' => $attr,
418 ];
419
420 return $this;
421 }
422
423 public function generate_menus() {
424 add_filter('plugin_action_links_' . $this->plugin_file, [$this, 'insert_plugin_links']);
425 add_filter('plugin_row_meta', [$this, 'insert_plugin_row_meta'], 10, 2);
426
427 if(!empty($this->parent_menu_slug)) {
428 $this->prepare_grid_links();
429 $this->prepare_pro_links();
430 }
431 }
432
433 public static function init() {
434 add_action('admin_head', [__CLASS__, 'enqueue_scripts']);
435 }
436
437 public function call() {
438 add_action('admin_menu', [$this, 'generate_menus'], 99999);
439 }
440 }
441
442 endif;
443