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