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