PluginProbe
QuadMenu – Mega Menu / 2.0.3
QuadMenu – Mega Menu v2.0.3
3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 87 releases
quadmenu / includes / suggestions.php

suggestions.php in QuadMenu – Mega Menu 2.0.3, at includes/suggestions.php

133 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 require_once( ABSPATH . 'wp-admin/includes/class-wp-plugin-install-list-table.php' );
4
5 class QuadMenu_Suggestions_List_Table extends WP_Plugin_Install_List_Table {
6
7 public $promote = array(
8 'wp-whatsapp-chat',
9 'insta-gallery',
10 'woocommerce-checkout-manager',
11 'woocommerce-direct-checkout',
12 'wp-menu-icons',
13 'quadmenu',
14 );
15
16 private function remove_plugins($plugins) {
17
18 $promote = array();
19
20 foreach ($this->promote as $order => $slug) {
21
22 if ($id = @max(array_keys(array_column($plugins, 'slug'), $slug))) {
23
24 $promote[] = $plugins[$id];
25 }
26 }
27
28 return $promote;
29 }
30
31 public function self_admin_url($url, $path) {
32
33 if (strpos($url, 'tab=plugin-information') !== false) {
34 $url = network_admin_url($path);
35 }
36
37 return $url;
38 }
39
40 public function network_admin_url($url, $path) {
41
42 if (strpos($url, 'plugins.php') !== false) {
43 $url = self_admin_url($path);
44 }
45
46 return $url;
47 }
48
49 public function display_rows() {
50 add_filter('self_admin_url', array($this, 'self_admin_url'), 10, 2);
51 add_filter('network_admin_url', array($this, 'network_admin_url'), 10, 2);
52 parent::display_rows();
53 }
54
55 public function is_connected() {
56
57 global $wp_version;
58
59 $http_args = array(
60 'timeout' => 15,
61 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url('/'),
62 );
63
64 return is_wp_error(wp_remote_get('http://api.wordpress.org/plugins/info/1.2/', $http_args));
65 }
66
67 public function get_plugins() {
68
69 $plugins = get_transient('ql_suggestions_plugins');
70
71 if ($plugins === false) {
72
73 $args = array(
74 'per_page' => 36,
75 'author' => 'quadlayers',
76 'locale' => get_user_locale(),
77 );
78
79 $api = plugins_api('query_plugins', $args);
80
81 if (!is_wp_error($api)) {
82
83 $plugins = $this->remove_plugins($api->plugins);
84
85 set_transient('ql_suggestions_plugins', $plugins, 24 * HOUR_IN_SECONDS);
86 }
87 }
88
89 return $plugins;
90 }
91
92 public function prepare_items() {
93
94 include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
95
96 global $tabs, $tab;
97
98 wp_enqueue_style('thickbox');
99 wp_enqueue_script('plugin-install');
100 wp_enqueue_script('thickbox');
101 wp_enqueue_script('updates');
102
103 wp_reset_vars(array('tab'));
104
105 $tabs = array();
106
107 if ('search' === $tab) {
108 $tabs['search'] = __('Search Results');
109 }
110 if ($tab === 'beta' || false !== strpos(get_bloginfo('version'), '-')) {
111 $tabs['beta'] = _x('Beta Testing', 'Plugin Installer');
112 }
113 $tabs['featured'] = _x('Featured', 'Plugin Installer');
114 $tabs['popular'] = _x('Popular', 'Plugin Installer');
115 $tabs['recommended'] = _x('Recommended', 'Plugin Installer');
116 $tabs['favorites'] = _x('Favorites', 'Plugin Installer');
117
118 $nonmenu_tabs = array('plugin-information'); // Valid actions to perform which do not have a Menu item.
119
120 $tabs = apply_filters('install_plugins_tabs', $tabs);
121
122 $nonmenu_tabs = apply_filters('install_plugins_nonmenu_tabs', $nonmenu_tabs);
123
124 // If a non-valid menu tab has been selected, And it's not a non-menu action.
125 if (empty($tab) || (!isset($tabs[$tab]) && !in_array($tab, (array) $nonmenu_tabs) )) {
126 $tab = key($tabs);
127 }
128
129 $this->items = $this->get_plugins();
130 }
131
132 }
133