PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / 3.2.2
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits v3.2.2
3.2.2 3.2.3 3.2.1 3.2.0 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.9 trunk 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.3 1.1.4 1.1.5 All 174 releases
master-addons / lib / Featured.php

Featured.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits 3.2.2, at lib/Featured.php

125 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MasterAddons\Lib;
4
5 // No, Direct access Sir !!!
6 if (!defined('ABSPATH')) {
7 exit;
8 }
9
10 /**
11 * Featured global class
12 *
13 * Jewel Theme <support@jeweltheme.com>
14 */
15 class Featured
16 {
17 /**
18 * Instance
19 *
20 * @var Featured
21 */
22 private static $instance = null;
23
24 /**
25 * Get Instance
26 *
27 * @return Featured
28 */
29 public static function get_instance()
30 {
31 if (is_null(self::$instance)) {
32 self::$instance = new self();
33 }
34 return self::$instance;
35 }
36
37 /**
38 * Constructor
39 */
40 public function __construct()
41 {
42 if (is_admin()) {
43 add_filter('install_plugins_table_api_args_featured', array($this, 'jltma_featured_plugins_tab'));
44 }
45 }
46
47 /**
48 * Helper function for adding plugins to fav list.
49 *
50 * @param [type] $args .
51 */
52 public function jltma_featured_plugins_tab($args)
53 {
54 add_filter('plugins_api_result', array($this, 'jltma_plugins_api_result'), 10, 3);
55
56 return $args;
57 }
58
59 /**
60 * Add our plugins to recommended list.
61 *
62 * @param [type] $res .
63 * @param [type] $action .
64 * @param [type] $args .
65 */
66 public function jltma_plugins_api_result($res, $action, $args)
67 {
68 remove_filter('plugins_api_result', array($this, 'jltma_plugins_api_result'), 10, 1);
69
70 // Plugin list which you want to show as feature in dashboard.
71 $res = $this->jltma_add_plugin_favs('adminify', $res);
72 $res = $this->jltma_add_plugin_favs('ultimate-blocks-for-gutenberg', $res);
73 $res = $this->jltma_add_plugin_favs('darken', $res);
74 $res = $this->jltma_add_plugin_favs('copy-to-clipboard', $res);
75 $res = $this->jltma_add_plugin_favs('image-hover-effects-elementor-addon', $res);
76
77 return $res;
78 }
79
80 /**
81 * Add single plugin to list of favs.
82 *
83 * @param [type] $plugin_slug .
84 * @param [type] $res .
85 */
86 public function jltma_add_plugin_favs($plugin_slug, $res)
87 {
88 if (!empty($res->plugins) && is_array($res->plugins)) {
89 foreach ($res->plugins as $plugin) {
90 if (is_object($plugin) && !empty($plugin->slug) && $plugin_slug === $plugin->slug) {
91 return $res;
92 }
93 } // foreach
94 }
95
96 $plugin_info = new \stdClass();
97 if (get_transient('jltma-plugin-info-' . $plugin_slug == $plugin_info)) {
98 array_unshift($res->plugins, $plugin_info);
99 } else {
100 $plugin_info = plugins_api(
101 'plugin_information',
102 array(
103 'slug' => $plugin_slug,
104 'is_ssl' => is_ssl(),
105 'fields' => array(
106 'banners' => true,
107 'reviews' => true,
108 'downloaded' => true,
109 'active_installs' => true,
110 'icons' => true,
111 'short_description' => true,
112 ),
113 )
114 );
115
116 if (!is_wp_error($plugin_info)) {
117 $res->plugins[] = $plugin_info;
118 set_transient('jltma-plugin-info-' . $plugin_slug, $plugin_info, DAY_IN_SECONDS * 7);
119 }
120 }
121
122 return $res;
123 }
124 }
125