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