├── README.md
└── dash-notice
└── wpmudev-dash-notification.php
/README.md:
--------------------------------------------------------------------------------
1 | # BuddyPress Hide Widgets
2 |
3 | **INACTIVE NOTICE: This plugin is unsupported by WPMUDEV, we've published it here for those technical types who might want to fork and maintain it for their needs.**
4 |
5 | ## Translations
6 |
7 | Translation files can be found at https://github.com/wpmudev/translations
8 |
9 | ## BuddyPress Hide Widgets lets you make specific BuddyPress widgets available only on your network's main site.
10 |
11 | ### Extended BuddyPress settings
12 |
13 | Control where BuddyPress widgets can display and limit plugin access to super admins only. Reserve built-in BuddyPress widgets for your main site and establish it as the network hub.
14 |
15 | ### Toggle widget availabilty
16 |
17 | Activate BuddyPress Hide Widgets and a set of simple toggle controls will be added to the BuddyPress 'Settings' tab. Quickly mark specific widgets for exclusive use.
18 |
19 | 
20 |
21 | Limit widget access with a click
22 |
23 | ### Added widget control
24 |
25 | ##### Build the perfect social network with the right tools:
26 |
27 | * Precise control over widget areas
28 | * Establish main site as "community hub"
29 | * Give site administrators the ability to set custom widget areas
30 | * Simple toggle configuration
31 | * Manage BuddyPress widget access
32 |
33 | Hide and set BuddyPress widgets with precision using BuddyPress Hide Widgets.
34 |
35 | ## Usage
36 |
37 | ### To Get Started:
38 |
39 | Start by reading the [Installing Plugins](https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/) section in our comprehensive [WordPress and WordPress Multisite Manual](https://premium.wpmudev.org/wpmu-manual/) if you are new to WordPress. Once installed and network-activated, you'll find the settings for this plugin in your network admin under Settings > BuddyPress > Settings.
40 |
41 | 
42 |
43 | ### To Configure:
44 |
45 | Configuring this plugin couldn't be any easier. Simply check the widgets you want available on the main site only, or available to all sites. Then save your settings. You're done.
46 |
47 | 
48 |
49 | Visit one of the sites in your network and you should see only the widgets you selected to be shown.
50 |
--------------------------------------------------------------------------------
/dash-notice/wpmudev-dash-notification.php:
--------------------------------------------------------------------------------
1 | version) && version_compare($wpmudev_un->version, '3.4', '<') ) )
23 | return;
24 |
25 | // Schedule update jobs
26 | if ( !wp_next_scheduled('wpmudev_scheduled_jobs') ) {
27 | wp_schedule_event(time(), 'twicedaily', 'wpmudev_scheduled_jobs');
28 | }
29 | add_action( 'wpmudev_scheduled_jobs', array( $this, 'updates_check') );
30 | add_action( 'delete_site_transient_update_plugins', array( &$this, 'updates_check' ) ); //refresh after upgrade/install
31 | add_action( 'delete_site_transient_update_themes', array( &$this, 'updates_check' ) ); //refresh after upgrade/install
32 |
33 | if ( is_admin() && current_user_can( 'install_plugins' ) ) {
34 |
35 | add_action( 'site_transient_update_plugins', array( &$this, 'filter_plugin_count' ) );
36 | add_action( 'site_transient_update_themes', array( &$this, 'filter_theme_count' ) );
37 | add_filter( 'plugins_api', array( &$this, 'filter_plugin_info' ), 20, 3 ); //run later to work with bad autoupdate plugins
38 | add_filter( 'themes_api', array( &$this, 'filter_plugin_info' ), 20, 3 ); //run later to work with bad autoupdate plugins
39 | add_action( 'admin_init', array( &$this, 'filter_plugin_rows' ), 15 ); //make sure it runs after WP's
40 | add_action( 'core_upgrade_preamble', array( &$this, 'disable_checkboxes' ) );
41 | add_action( 'activated_plugin', array( &$this, 'set_activate_flag' ) );
42 |
43 | //remove version 1.0
44 | remove_action( 'admin_notices', 'wdp_un_check', 5 );
45 | remove_action( 'network_admin_notices', 'wdp_un_check', 5 );
46 | //remove version 2.0, a bit nasty but only way
47 | remove_all_actions( 'all_admin_notices', 5 );
48 |
49 | //if dashboard is installed but not activated
50 | if ( file_exists(WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php') ) {
51 | if ( !get_site_option('wdp_un_autoactivated') ) {
52 | //include plugin API if necessary
53 | if ( !function_exists('activate_plugin') ) require_once(ABSPATH . 'wp-admin/includes/plugin.php');
54 | $result = activate_plugin( '/wpmudev-updates/update-notifications.php', network_admin_url('admin.php?page=wpmudev'), is_multisite() );
55 | if ( !is_wp_error($result) ) { //if autoactivate successful don't show notices
56 | update_site_option('wdp_un_autoactivated', 1);
57 | return;
58 | }
59 | }
60 |
61 | add_action( 'admin_print_styles', array( &$this, 'notice_styles' ) );
62 | add_action( 'all_admin_notices', array( &$this, 'activate_notice' ), 5 );
63 | } else { //dashboard not installed at all
64 | if ( get_site_option('wdp_un_autoactivated') ) {
65 | update_site_option('wdp_un_autoactivated', 0);//reset flag when dashboard is deleted
66 | }
67 | add_action( 'admin_print_styles', array( &$this, 'notice_styles' ) );
68 | add_action( 'all_admin_notices', array( &$this, 'install_notice' ), 5 );
69 | }
70 | }
71 | }
72 |
73 | function is_allowed_screen() {
74 | global $wpmudev_notices;
75 | $screen = get_current_screen();
76 | $this->screen_id = $screen->id;
77 |
78 | //Show special message right after plugin activation
79 | if ( in_array( $this->screen_id, array('plugins', 'plugins-network') ) && ( isset($_GET['activate']) || isset($_GET['activate-multi']) ) ) {
80 | $activated = get_site_option('wdp_un_activated_flag');
81 | if ($activated === false) $activated = 1; //on first encounter of new installed notice show
82 | if ($activated) {
83 | if ($activated >= 2)
84 | update_site_option('wdp_un_activated_flag', 0);
85 | else
86 | update_site_option('wdp_un_activated_flag', 2);
87 | return true;
88 | }
89 | }
90 |
91 | //always show on certain core pages if updates are available
92 | $updates = get_site_option('wdp_un_updates_available');
93 | if (is_array($updates) && count($updates)) {
94 | $this->update_count = count($updates);
95 | if ( in_array( $this->screen_id, array('plugins', 'update-core', /*'plugin-install', 'theme-install',*/ 'plugins-network', 'themes-network', /*'theme-install-network', 'plugin-install-network',*/ 'update-core-network') ) )
96 | return true;
97 | }
98 |
99 | //check our registered plugins for hooks
100 | if ( isset($wpmudev_notices) && is_array($wpmudev_notices) ) {
101 | foreach ( $wpmudev_notices as $product ) {
102 | if ( isset($product['screens']) && is_array($product['screens']) && in_array( $this->screen_id, $product['screens'] ) ) {
103 | $this->product_name = $product['name'];
104 | //if this plugin needs updating flag it
105 | if ( isset($product['id']) && isset($updates[$product['id']]) )
106 | $this->product_update = true;
107 | return true;
108 | }
109 | }
110 | }
111 |
112 | if ( defined('WPMUDEV_SCREEN_ID') ) var_dump($this->screen_id); //for internal debugging
113 |
114 | return false;
115 | }
116 |
117 | function auto_install_url() {
118 | $function = is_multisite() ? 'network_admin_url' : 'admin_url';
119 | return wp_nonce_url($function("update.php?action=install-plugin&plugin=install_wpmudev_dash"), "install-plugin_install_wpmudev_dash");
120 | }
121 |
122 | function activate_url() {
123 | $function = is_multisite() ? 'network_admin_url' : 'admin_url';
124 | return wp_nonce_url($function('plugins.php?action=activate&plugin=wpmudev-updates%2Fupdate-notifications.php'), 'activate-plugin_wpmudev-updates/update-notifications.php');
125 | }
126 |
127 | function install_notice() {
128 | if ( !$this->is_allowed_screen() ) return;
129 |
130 | echo '
';
131 |
132 | if ($this->product_name) {
133 | if ($this->product_update)
134 | echo 'Important updates are available for ' . esc_html($this->product_name) . '. Install the free WPMU DEV Dashboard plugin now for updates and support!';
135 | else
136 | echo '' . esc_html($this->product_name) . ' is almost ready - install the free WPMU DEV Dashboard plugin for updates and support!';
137 | } else if ($this->update_count) {
138 | echo "Important updates are available for your WPMU DEV plugins/themes. Install the free WPMU DEV Dashboard plugin now for updates and support!";
139 | } else {
140 | echo 'Almost ready - install the free WPMU DEV Dashboard plugin for updates and support!';
141 | }
142 | echo '
Install WPMU DEV Dashboard';
143 | echo '
';
144 | echo '
';
145 | echo '
';
146 | }
147 |
148 | function activate_notice() {
149 | if ( !$this->is_allowed_screen() ) return;
150 |
151 | echo '';
152 | if ($this->product_name) {
153 | if ($this->product_update)
154 | echo 'Important updates are available for ' . esc_html($this->product_name) . '. Activate the WPMU DEV Dashboard to update now!';
155 | else
156 | echo "Just one more step to enable updates and support for " . esc_html($this->product_name) . '!';
157 | } else if ($this->update_count) {
158 | echo "Important updates are available for your WPMU DEV plugins/themes. Activate the WPMU DEV Dashboard to update now!";
159 | } else {
160 | echo "Just one more step - activate the WPMU DEV Dashboard plugin and you're all done!";
161 | }
162 | echo '
Activate WPMU DEV Dashboard ';
163 | }
164 |
165 | function notice_styles() {
166 | if ( !$this->is_allowed_screen() ) return;
167 | ?>
168 |
169 |
183 | 'Plugin Name', 'id' => 'WDP ID', 'version' => 'Version') );
188 | }
189 |
190 | //simple check for updates
191 | function updates_check() {
192 | global $wp_version;
193 | $local_projects = array();
194 |
195 | //----------------------------------------------------------------------------------//
196 | //plugins directory
197 | //----------------------------------------------------------------------------------//
198 | $plugins_root = WP_PLUGIN_DIR;
199 | if( empty($plugins_root) ) {
200 | $plugins_root = ABSPATH . 'wp-content/plugins';
201 | }
202 |
203 | $plugins_dir = @opendir($plugins_root);
204 | $plugin_files = array();
205 | if ( $plugins_dir ) {
206 | while (($file = readdir( $plugins_dir ) ) !== false ) {
207 | if ( substr($file, 0, 1) == '.' )
208 | continue;
209 | if ( is_dir( $plugins_root.'/'.$file ) ) {
210 | $plugins_subdir = @ opendir( $plugins_root.'/'.$file );
211 | if ( $plugins_subdir ) {
212 | while (($subfile = readdir( $plugins_subdir ) ) !== false ) {
213 | if ( substr($subfile, 0, 1) == '.' )
214 | continue;
215 | if ( substr($subfile, -4) == '.php' )
216 | $plugin_files[] = "$file/$subfile";
217 | }
218 | }
219 | } else {
220 | if ( substr($file, -4) == '.php' )
221 | $plugin_files[] = $file;
222 | }
223 | }
224 | }
225 | @closedir( $plugins_dir );
226 | @closedir( $plugins_subdir );
227 |
228 | if ( $plugins_dir && !empty($plugin_files) ) {
229 | foreach ( $plugin_files as $plugin_file ) {
230 | if ( is_readable( "$plugins_root/$plugin_file" ) ) {
231 |
232 | unset($data);
233 | $data = $this->get_id_plugin( "$plugins_root/$plugin_file" );
234 |
235 | if ( isset($data['id']) && !empty($data['id']) ) {
236 | $local_projects[$data['id']]['type'] = 'plugin';
237 | $local_projects[$data['id']]['version'] = $data['version'];
238 | $local_projects[$data['id']]['filename'] = $plugin_file;
239 | }
240 | }
241 | }
242 | }
243 |
244 | //----------------------------------------------------------------------------------//
245 | // mu-plugins directory
246 | //----------------------------------------------------------------------------------//
247 | $mu_plugins_root = WPMU_PLUGIN_DIR;
248 | if( empty($mu_plugins_root) ) {
249 | $mu_plugins_root = ABSPATH . 'wp-content/mu-plugins';
250 | }
251 |
252 | if ( is_dir($mu_plugins_root) && $mu_plugins_dir = @opendir($mu_plugins_root) ) {
253 | while (($file = readdir( $mu_plugins_dir ) ) !== false ) {
254 | if ( substr($file, -4) == '.php' ) {
255 | if ( is_readable( "$mu_plugins_root/$file" ) ) {
256 |
257 | unset($data);
258 | $data = $this->get_id_plugin( "$mu_plugins_root/$file" );
259 |
260 | if ( isset($data['id']) && !empty($data['id']) ) {
261 | $local_projects[$data['id']]['type'] = 'mu-plugin';
262 | $local_projects[$data['id']]['version'] = $data['version'];
263 | $local_projects[$data['id']]['filename'] = $file;
264 | }
265 | }
266 | }
267 | }
268 | @closedir( $mu_plugins_dir );
269 | }
270 |
271 | //----------------------------------------------------------------------------------//
272 | // wp-content directory
273 | //----------------------------------------------------------------------------------//
274 | $content_plugins_root = WP_CONTENT_DIR;
275 | if( empty($content_plugins_root) ) {
276 | $content_plugins_root = ABSPATH . 'wp-content';
277 | }
278 |
279 | $content_plugins_dir = @opendir($content_plugins_root);
280 | $content_plugin_files = array();
281 | if ( $content_plugins_dir ) {
282 | while (($file = readdir( $content_plugins_dir ) ) !== false ) {
283 | if ( substr($file, 0, 1) == '.' )
284 | continue;
285 | if ( !is_dir( $content_plugins_root.'/'.$file ) ) {
286 | if ( substr($file, -4) == '.php' )
287 | $content_plugin_files[] = $file;
288 | }
289 | }
290 | }
291 | @closedir( $content_plugins_dir );
292 |
293 | if ( $content_plugins_dir && !empty($content_plugin_files) ) {
294 | foreach ( $content_plugin_files as $content_plugin_file ) {
295 | if ( is_readable( "$content_plugins_root/$content_plugin_file" ) ) {
296 | unset($data);
297 | $data = $this->get_id_plugin( "$content_plugins_root/$content_plugin_file" );
298 |
299 | if ( isset($data['id']) && !empty($data['id']) ) {
300 | $local_projects[$data['id']]['type'] = 'drop-in';
301 | $local_projects[$data['id']]['version'] = $data['version'];
302 | $local_projects[$data['id']]['filename'] = $content_plugin_file;
303 | }
304 | }
305 | }
306 | }
307 |
308 | //----------------------------------------------------------------------------------//
309 | //themes directory
310 | //----------------------------------------------------------------------------------//
311 | $themes_root = WP_CONTENT_DIR . '/themes';
312 | if ( empty($themes_root) ) {
313 | $themes_root = ABSPATH . 'wp-content/themes';
314 | }
315 |
316 | $themes_dir = @opendir($themes_root);
317 | $themes_files = array();
318 | $local_themes = array();
319 | if ( $themes_dir ) {
320 | while (($file = readdir( $themes_dir ) ) !== false ) {
321 | if ( substr($file, 0, 1) == '.' )
322 | continue;
323 | if ( is_dir( $themes_root.'/'.$file ) ) {
324 | $themes_subdir = @ opendir( $themes_root.'/'.$file );
325 | if ( $themes_subdir ) {
326 | while (($subfile = readdir( $themes_subdir ) ) !== false ) {
327 | if ( substr($subfile, 0, 1) == '.' )
328 | continue;
329 | if ( substr($subfile, -4) == '.css' )
330 | $themes_files[] = "$file/$subfile";
331 | }
332 | }
333 | } else {
334 | if ( substr($file, -4) == '.css' )
335 | $themes_files[] = $file;
336 | }
337 | }
338 | }
339 | @closedir( $themes_dir );
340 | @closedir( $themes_subdir );
341 |
342 | if ( $themes_dir && !empty($themes_files) ) {
343 | foreach ( $themes_files as $themes_file ) {
344 |
345 | //skip child themes
346 | if ( strpos( $themes_file, '-child' ) !== false )
347 | continue;
348 |
349 | if ( is_readable( "$themes_root/$themes_file" ) ) {
350 |
351 | unset($data);
352 | $data = $this->get_id_plugin( "$themes_root/$themes_file" );
353 |
354 | if ( isset($data['id']) && !empty($data['id']) ) {
355 | $local_projects[$data['id']]['type'] = 'theme';
356 | $local_projects[$data['id']]['filename'] = substr( $themes_file, 0, strpos( $themes_file, '/' ) );
357 |
358 | //keep record of all themes for 133 themepack
359 | if ($data['id'] == $this->theme_pack) {
360 | $local_themes[$themes_file]['id'] = $data['id'];
361 | $local_themes[$themes_file]['filename'] = substr( $themes_file, 0, strpos( $themes_file, '/' ) );
362 | $local_themes[$themes_file]['version'] = $data['version'];
363 | //increment 133 theme pack version to lowest in all of them
364 | if ( isset($local_projects[$data['id']]['version']) && version_compare($data['version'], $local_projects[$data['id']]['version'], '<') ) {
365 | $local_projects[$data['id']]['version'] = $data['version'];
366 | } else if ( !isset($local_projects[$data['id']]['version']) ) {
367 | $local_projects[$data['id']]['version'] = $data['version'];
368 | }
369 | } else {
370 | $local_projects[$data['id']]['version'] = $data['version'];
371 | }
372 | }
373 | }
374 | }
375 | }
376 | update_site_option('wdp_un_local_themes', $local_themes);
377 |
378 | update_site_option('wdp_un_local_projects', $local_projects);
379 |
380 | //now check the API
381 | $projects = '';
382 | foreach ($local_projects as $pid => $project)
383 | $projects .= "&p[$pid]=" . $project['version'];
384 |
385 | //get WP/BP version string to help with support
386 | $wp = is_multisite() ? "WordPress Multisite $wp_version" : "WordPress $wp_version";
387 | if ( defined( 'BP_VERSION' ) )
388 | $wp .= ', BuddyPress ' . BP_VERSION;
389 |
390 | //add blog count if multisite
391 | $blog_count = is_multisite() ? get_blog_count() : 1;
392 |
393 | $url = $this->server_url . '?action=check&un-version=3.3.3&wp=' . urlencode($wp) . '&bcount=' . $blog_count . '&domain=' . urlencode(network_site_url()) . $projects;
394 |
395 | $options = array(
396 | 'timeout' => 15,
397 | 'user-agent' => 'Dashboard Notification/' . $this->version
398 | );
399 |
400 | $response = wp_remote_get($url, $options);
401 | if ( wp_remote_retrieve_response_code($response) == 200 ) {
402 | $data = $response['body'];
403 | if ( $data != 'error' ) {
404 | $data = unserialize($data);
405 | if ( is_array($data) ) {
406 |
407 | //we've made it here with no errors, now check for available updates
408 | $remote_projects = isset($data['projects']) ? $data['projects'] : array();
409 | $updates = array();
410 |
411 | //check for updates
412 | if ( is_array($remote_projects) ) {
413 | foreach ( $remote_projects as $id => $remote_project ) {
414 | if ( isset($local_projects[$id]) && is_array($local_projects[$id]) ) {
415 | //match
416 | $local_version = $local_projects[$id]['version'];
417 | $remote_version = $remote_project['version'];
418 |
419 | if ( version_compare($remote_version, $local_version, '>') ) {
420 | //add to array
421 | $updates[$id] = $local_projects[$id];
422 | $updates[$id]['url'] = $remote_project['url'];
423 | $updates[$id]['instructions_url'] = $remote_project['instructions_url'];
424 | $updates[$id]['support_url'] = $remote_project['support_url'];
425 | $updates[$id]['name'] = $remote_project['name'];
426 | $updates[$id]['thumbnail'] = $remote_project['thumbnail'];
427 | $updates[$id]['version'] = $local_version;
428 | $updates[$id]['new_version'] = $remote_version;
429 | $updates[$id]['changelog'] = $remote_project['changelog'];
430 | $updates[$id]['autoupdate'] = $remote_project['autoupdate'];
431 | }
432 | }
433 | }
434 |
435 | //record results
436 | update_site_option('wdp_un_updates_available', $updates);
437 | } else {
438 | return false;
439 | }
440 | }
441 | }
442 | }
443 | }
444 |
445 | function filter_plugin_info($res, $action, $args) {
446 | global $wp_version;
447 | $cur_wp_version = preg_replace('/-.*$/', '', $wp_version);
448 |
449 | //if in details iframe on update core page short-curcuit it
450 | if ( ($action == 'plugin_information' || $action == 'theme_information') && strpos($args->slug, 'wpmudev_install') !== false ) {
451 | $string = explode('-', $args->slug);
452 | $id = intval($string[1]);
453 | $updates = get_site_option('wdp_un_updates_available');
454 | if ( did_action( 'install_plugins_pre_plugin-information' ) && is_array( $updates ) && isset($updates[$id]) ) {
455 | echo '';
456 | exit;
457 | }
458 |
459 | $res = new stdClass;
460 | $res->name = $updates[$id]['name'];
461 | $res->slug = sanitize_title($updates[$id]['name']);
462 | $res->version = $updates[$id]['version'];
463 | $res->rating = 100;
464 | $res->homepage = $updates[$id]['url'];
465 | $res->download_link = '';
466 | $res->tested = $cur_wp_version;
467 |
468 | return $res;
469 | }
470 |
471 | if ( $action == 'plugin_information' && strpos($args->slug, 'install_wpmudev_dash') !== false ) {
472 | $res = new stdClass;
473 | $res->name = 'WPMU DEV Dashboard';
474 | $res->slug = 'wpmu-dev-dashboard';
475 | $res->version = '';
476 | $res->rating = 100;
477 | $res->homepage = 'http://premium.wpmudev.org/project/wpmu-dev-dashboard/';
478 | $res->download_link = $this->server_url . "?action=install_wpmudev_dash";
479 | $res->tested = $cur_wp_version;
480 |
481 | return $res;
482 | }
483 |
484 | return $res;
485 | }
486 |
487 | function filter_plugin_rows() {
488 | if ( !current_user_can( 'update_plugins' ) )
489 | return;
490 |
491 | $updates = get_site_option('wdp_un_updates_available');
492 | if ( is_array($updates) && count($updates) ) {
493 | foreach ( $updates as $id => $plugin ) {
494 | if ( $plugin['autoupdate'] != '2' ) {
495 | if ( $plugin['type'] == 'theme' ) {
496 | remove_all_actions( 'after_theme_row_' . $plugin['filename'] );
497 | add_action('after_theme_row_' . $plugin['filename'], array( &$this, 'plugin_row'), 9, 2 );
498 | } else {
499 | remove_all_actions( 'after_plugin_row_' . $plugin['filename'] );
500 | add_action('after_plugin_row_' . $plugin['filename'], array( &$this, 'plugin_row'), 9, 2 );
501 | }
502 | }
503 | }
504 | }
505 |
506 | $local_themes = get_site_option('wdp_un_local_themes');
507 | if ( is_array($local_themes) && count($local_themes) ) {
508 | foreach ( $local_themes as $id => $plugin ) {
509 | remove_all_actions( 'after_theme_row_' . $plugin['filename'] );
510 | //only add the notice if specific version is wrong
511 | if ( isset($updates[$this->theme_pack]) && version_compare($plugin['version'], $updates[$this->theme_pack]['new_version'], '<') ) {
512 | add_action('after_theme_row_' . $plugin['filename'], array( &$this, 'themepack_row'), 9, 2 );
513 | }
514 | }
515 | }
516 | }
517 |
518 | function filter_plugin_count( $value ) {
519 |
520 | //remove any conflicting slug local WPMU DEV plugins from WP update notifications
521 | $local_projects = get_site_option('wdp_un_local_projects');
522 | if ( is_array($local_projects) && count($local_projects) ) {
523 | foreach ( $local_projects as $id => $plugin ) {
524 | if (isset($value->response[$plugin['filename']]))
525 | unset($value->response[$plugin['filename']]);
526 | }
527 | }
528 |
529 | $updates = get_site_option('wdp_un_updates_available');
530 | if ( is_array($updates) && count($updates) ) {
531 | foreach ( $updates as $id => $plugin ) {
532 | if ( $plugin['type'] != 'theme' && $plugin['autoupdate'] != '2' ) {
533 |
534 | //build plugin class
535 | $object = new stdClass;
536 | $object->url = $plugin['url'];
537 | $object->slug = "wpmudev_install-$id";
538 | $object->upgrade_notice = $plugin['changelog'];
539 | $object->new_version = $plugin['new_version'];
540 | $object->package = '';
541 |
542 | //add to class
543 | $value->response[$plugin['filename']] = $object;
544 | }
545 | }
546 | }
547 |
548 | return $value;
549 | }
550 |
551 | function filter_theme_count( $value ) {
552 |
553 | $updates = get_site_option('wdp_un_updates_available');
554 | if ( is_array($updates) && count($updates) ) {
555 | foreach ( $updates as $id => $theme ) {
556 | if ( $theme['type'] == 'theme' && $theme['autoupdate'] != '2' ) {
557 | //build theme listing
558 | $value->response[$theme['filename']]['url'] = $this->server_url . '?action=details&id=' . $id;
559 | $value->response[$theme['filename']]['new_version'] = $theme['new_version'];
560 | $value->response[$theme['filename']]['package'] = '';
561 | }
562 | }
563 | }
564 |
565 | //filter 133 theme pack themes from the list unless update is available
566 | $local_themes = get_site_option('wdp_un_local_themes');
567 | if ( is_array($local_themes) && count($local_themes) ) {
568 | foreach ( $local_themes as $id => $theme ) {
569 | //add to count only if new version exists, otherwise remove
570 | if (isset($updates[$theme['id']]) && isset($updates[$theme['id']]['new_version']) && version_compare($theme['version'], $updates[$theme['id']]['new_version'], '<')) {
571 | $value->response[$theme['filename']]['new_version'] = $updates[$theme['id']]['new_version'];
572 | $value->response[$theme['filename']]['package'] = '';
573 | } else if (isset($value) && isset($value->response) && isset($theme['filename']) && isset($value->response[$theme['filename']])) {
574 | unset($value->response[$theme['filename']]);
575 | }
576 | }
577 | }
578 |
579 | return $value;
580 | }
581 |
582 | function plugin_row( $file, $plugin_data ) {
583 |
584 | //get new version and update url
585 | $updates = get_site_option('wdp_un_updates_available');
586 | if ( is_array($updates) && count($updates) ) {
587 | foreach ( $updates as $id => $plugin ) {
588 | if ($plugin['filename'] == $file) {
589 | $project_id = $id;
590 | $version = $plugin['new_version'];
591 | $plugin_url = $plugin['url'];
592 | $autoupdate = $plugin['autoupdate'];
593 | $filename = $plugin['filename'];
594 | $type = $plugin['type'];
595 | break;
596 | }
597 | }
598 | } else {
599 | return false;
600 | }
601 |
602 | $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
603 | $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
604 |
605 | $info_url = $this->server_url . '?action=details&id=' . $project_id . '&TB_iframe=true&width=640&height=800';
606 | if ( file_exists(WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php') ) {
607 | $message = "Activate WPMU DEV Dashboard";
608 | $action_url = $this->activate_url();
609 | } else { //dashboard not installed at all
610 | $message = "Install WPMU DEV Dashboard";
611 | $action_url = $this->auto_install_url();
612 | }
613 |
614 | if ( current_user_can('update_plugins') ) {
615 | echo '';
616 | printf( 'There is a new version of %1$s available on WPMU DEV. View version %4$s details or %6$s to update.', $plugin_name, esc_url($info_url), esc_attr($plugin_name), $version, esc_url($action_url), $message );
617 | echo ' |
';
618 | }
619 | }
620 |
621 | function themepack_row( $file, $plugin_data ) {
622 |
623 | //get new version and update url
624 | $updates = get_site_option('wdp_un_updates_available');
625 | if ( isset($updates[$this->theme_pack]) ) {
626 | $plugin = $updates[$this->theme_pack];
627 | $project_id = $this->theme_pack;
628 | $version = $plugin['new_version'];
629 | $plugin_url = $plugin['url'];
630 | } else {
631 | return false;
632 | }
633 |
634 | $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
635 | $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
636 |
637 | $info_url = $this->server_url . '?action=details&id=' . $project_id . '&TB_iframe=true&width=640&height=800';
638 | if ( file_exists(WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php') ) {
639 | $message = "Activate WPMU DEV Dashboard";
640 | $action_url = $this->activate_url();
641 | } else { //dashboard not installed at all
642 | $message = "Install WPMU DEV Dashboard";
643 | $action_url = $this->auto_install_url();
644 | }
645 |
646 | if ( current_user_can('update_themes') ) {
647 | echo '';
648 | printf( 'There is a new version of %1$s available on WPMU DEV. View version %4$s details or %6$s to update.', $plugin_name, esc_url($info_url), esc_attr($plugin_name), $version, esc_url($action_url), $message );
649 | echo ' |
';
650 | }
651 | }
652 |
653 | function disable_checkboxes() {
654 |
655 | $updates = get_site_option('wdp_un_updates_available');
656 | if ( !is_array( $updates ) || ( is_array( $updates ) && !count( $updates ) ) ) {
657 | return;
658 | }
659 |
660 | $jquery = '';
661 | foreach ( (array) $updates as $id => $plugin) {
662 | $jquery .= "\n";
663 | }
664 |
665 | //disable checkboxes for 133 theme pack themes
666 | $local_themes = get_site_option('wdp_un_local_themes');
667 | if ( is_array($local_themes) && count($local_themes) ) {
668 | foreach ( $local_themes as $id => $theme ) {
669 | $jquery .= "\n";
670 | }
671 | }
672 | echo $jquery;
673 | }
674 |
675 | function set_activate_flag($plugin) {
676 | $data = $this->get_id_plugin( WP_PLUGIN_DIR . '/' . $plugin );
677 | if ( isset($data['id']) && !empty($data['id']) ) {
678 | update_site_option('wdp_un_activated_flag', 1);
679 | }
680 | }
681 |
682 | }
683 | $WPMUDEV_Dashboard_Notice3 = new WPMUDEV_Dashboard_Notice3();
684 | }
685 |
686 | //disable older version
687 | if ( !class_exists('WPMUDEV_Dashboard_Notice') ) {
688 | class WPMUDEV_Dashboard_Notice {}
689 | }
--------------------------------------------------------------------------------