deregister_hook( 'init', 'WPMUDEV_Dashboard_Notice3', 'init', 10 ); $this->deregister_hook( 'plugins_loaded', 'WPMUDEV_Dashboard_Notice3', 'init', 10 ); } //remove version 2.0 if ( method_exists( 'WPMUDEV_Dashboard_Notice', 'init' ) ) { $this->deregister_hook( 'init', 'WPMUDEV_Dashboard_Notice', 'init', 10 ); $this->deregister_hook( 'plugins_loaded', 'WPMUDEV_Dashboard_Notice', 'init', 10 ); } //remove version 1.0 remove_action( 'admin_notices', 'wdp_un_check', 5 ); remove_action( 'network_admin_notices', 'wdp_un_check', 5 ); } /* Adapted from: https://github.com/herewithme/wp-filters-extras/ - Copyright 2012 Amaury Balmer - amaury@beapi.fr */ function deregister_hook( $hook_name, $class_name, $method_name, $priority ) { global $wp_filter; // Take only filters on right hook name and priority if ( ! isset( $wp_filter[ $hook_name ][ $priority ] ) || ! is_array( $wp_filter[ $hook_name ][ $priority ] ) ) { return false; } // Loop on filters registered foreach ( (array) $wp_filter[ $hook_name ][ $priority ] as $unique_id => $filter_array ) { // Test if filter is an array ! (always for class/method) if ( isset( $filter_array['function'] ) && is_array( $filter_array['function'] ) ) { // Test if object is a class, class and method is equal to param ! if ( is_object( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) == $class_name && $filter_array['function'][1] == $method_name ) { if ( class_exists( 'WP_Hook' ) ) { //introduced in WP 4.7 https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/ unset( $wp_filter[ $hook_name ]->callbacks[ $priority ][ $unique_id ] ); } else { unset( $wp_filter[ $hook_name ][ $priority ][ $unique_id ] ); } return true; } } } return false; } function init() { global $wpmudev_un; if ( class_exists( 'WPMUDEV_Dashboard' ) || ( isset( $wpmudev_un->version ) && version_compare( $wpmudev_un->version, '3.4', '<' ) ) ) { return; } // Schedule update cron on main site only if ( is_main_site() ) { if ( ! wp_next_scheduled( 'wpmudev_scheduled_jobs' ) ) { wp_schedule_event( time(), 'twicedaily', 'wpmudev_scheduled_jobs' ); } add_action( 'wpmudev_scheduled_jobs', array( $this, 'updates_check' ) ); } add_action( 'delete_site_transient_update_plugins', array( &$this, 'updates_check' ) ); //refresh after upgrade/install add_action( 'delete_site_transient_update_themes', array( &$this, 'updates_check' ) ); //refresh after upgrade/install if ( is_admin() && current_user_can( 'install_plugins' ) ) { add_action( 'site_transient_update_plugins', array( &$this, 'filter_plugin_count' ) ); add_action( 'site_transient_update_themes', array( &$this, 'filter_theme_count' ) ); add_filter( 'plugins_api', array( &$this, 'filter_plugin_info' ), 101, 3 ); //run later to work with bad autoupdate plugins add_filter( 'themes_api', array( &$this, 'filter_plugin_info' ), 101, 3 ); //run later to work with bad autoupdate plugins add_action( 'load-plugins.php', array( &$this, 'filter_plugin_rows' ), 21 ); //make sure it runs after WP's add_action( 'load-themes.php', array( &$this, 'filter_plugin_rows' ), 21 ); //make sure it runs after WP's add_action( 'core_upgrade_preamble', array( &$this, 'disable_checkboxes' ) ); add_action( 'activated_plugin', array( &$this, 'set_activate_flag' ) ); add_action( 'wp_ajax_wdpun-changelog', array( &$this, 'popup_changelog_ajax' ) ); add_action( 'wp_ajax_wdpun-dismiss', array( &$this, 'dismiss_ajax' ) ); //if dashboard is installed but not activated if ( file_exists( WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php' ) ) { if ( ! get_site_option( 'wdp_un_autoactivated' ) ) { //include plugin API if necessary if ( ! function_exists( 'activate_plugin' ) ) { require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); } $result = activate_plugin( '/wpmudev-updates/update-notifications.php', network_admin_url( 'admin.php?page=wpmudev' ), is_multisite() ); if ( ! is_wp_error( $result ) ) { //if autoactivate successful don't show notices update_site_option( 'wdp_un_autoactivated', 1 ); return; } } add_action( 'admin_print_styles', array( &$this, 'notice_styles' ) ); add_action( 'admin_print_footer_scripts', array( &$this, 'notice_scripts' ) ); add_action( 'all_admin_notices', array( &$this, 'activate_notice' ), 5 ); } else { //dashboard not installed at all if ( get_site_option( 'wdp_un_autoactivated' ) ) { update_site_option( 'wdp_un_autoactivated', 0 );//reset flag when dashboard is deleted } add_action( 'admin_print_styles', array( &$this, 'notice_styles' ) ); add_action( 'admin_print_footer_scripts', array( &$this, 'notice_scripts' ) ); add_action( 'all_admin_notices', array( &$this, 'install_notice' ), 5 ); } } } function is_allowed_screen() { global $wpmudev_notices; $screen = get_current_screen(); if ($screen && is_object($screen)) $this->screen_id = $screen->id; //Show special message right after plugin activation if ( in_array( $this->screen_id, array( 'plugins', 'plugins-network' ) ) && ( isset( $_GET['activate'] ) || isset( $_GET['activate-multi'] ) ) ) { $activated = get_site_option( 'wdp_un_activated_flag' ); if ( $activated === false ) { $activated = 1; } //on first encounter of new installed notice show if ( $activated ) { if ( $activated >= 2 ) { update_site_option( 'wdp_un_activated_flag', 0 ); } else { update_site_option( 'wdp_un_activated_flag', 2 ); } return true; } } //check dismiss flag $dismissed = get_site_option( 'wdp_un_dismissed' ); if ( $dismissed && $dismissed > strtotime( '-1 week' ) ) { return false; } //always show on certain core pages if updates are available $updates = get_site_option( 'wdp_un_updates_available' ); if ( is_array( $updates ) && count( $updates ) ) { $this->update_count = count( $updates ); if ( in_array( $this->screen_id, array( 'update-core', 'update-core-network' ) ) ) { return true; } } //check our registered plugins for hooks if ( isset( $wpmudev_notices ) && is_array( $wpmudev_notices ) ) { foreach ( $wpmudev_notices as $product ) { if ( isset( $product['screens'] ) && is_array( $product['screens'] ) && in_array( $this->screen_id, $product['screens'] ) ) { $this->product_name = $product['name']; //if this plugin needs updating flag it if ( isset( $product['id'] ) && isset( $updates[ $product['id'] ] ) ) { $this->product_update = true; } return true; } } } return false; } function auto_install_url() { $function = is_multisite() ? 'network_admin_url' : 'admin_url'; return wp_nonce_url( $function( "update.php?action=install-plugin&plugin=install_wpmudev_dash" ), "install-plugin_install_wpmudev_dash" ); } function activate_url() { $function = is_multisite() ? 'network_admin_url' : 'admin_url'; return wp_nonce_url( $function( 'plugins.php?action=activate&plugin=wpmudev-updates%2Fupdate-notifications.php' ), 'activate-plugin_wpmudev-updates/update-notifications.php' ); } function install_notice() { if ( ! $this->is_allowed_screen() ) return; ?> is_allowed_screen() ) return; ?> is_allowed_screen() ) return; ?> is_allowed_screen() ) return; ?> 'Plugin Name', 'id' => 'WDP ID', 'version' => 'Version' ) ); } //simple check for updates function updates_check() { global $wp_version; $local_projects = array(); //----------------------------------------------------------------------------------// //plugins directory //----------------------------------------------------------------------------------// $plugins_root = WP_PLUGIN_DIR; if ( empty( $plugins_root ) ) { $plugins_root = ABSPATH . 'wp-content/plugins'; } $plugins_dir = @opendir( $plugins_root ); $plugin_files = array(); if ( $plugins_dir ) { while ( ( $file = readdir( $plugins_dir ) ) !== false ) { if ( substr( $file, 0, 1 ) == '.' ) { continue; } if ( is_dir( $plugins_root . '/' . $file ) ) { $plugins_subdir = @ opendir( $plugins_root . '/' . $file ); if ( $plugins_subdir ) { while ( ( $subfile = readdir( $plugins_subdir ) ) !== false ) { if ( substr( $subfile, 0, 1 ) == '.' ) { continue; } if ( substr( $subfile, - 4 ) == '.php' ) { $plugin_files[] = "$file/$subfile"; } } } } else { if ( substr( $file, - 4 ) == '.php' ) { $plugin_files[] = $file; } } } } @closedir( $plugins_dir ); @closedir( $plugins_subdir ); if ( $plugins_dir && ! empty( $plugin_files ) ) { foreach ( $plugin_files as $plugin_file ) { if ( is_readable( "$plugins_root/$plugin_file" ) ) { unset( $data ); $data = $this->get_id_plugin( "$plugins_root/$plugin_file" ); if ( isset( $data['id'] ) && ! empty( $data['id'] ) ) { $local_projects[ $data['id'] ]['type'] = 'plugin'; $local_projects[ $data['id'] ]['version'] = $data['version']; $local_projects[ $data['id'] ]['filename'] = $plugin_file; } } } } //----------------------------------------------------------------------------------// // mu-plugins directory //----------------------------------------------------------------------------------// $mu_plugins_root = WPMU_PLUGIN_DIR; if ( empty( $mu_plugins_root ) ) { $mu_plugins_root = ABSPATH . 'wp-content/mu-plugins'; } if ( is_dir( $mu_plugins_root ) && $mu_plugins_dir = @opendir( $mu_plugins_root ) ) { while ( ( $file = readdir( $mu_plugins_dir ) ) !== false ) { if ( substr( $file, - 4 ) == '.php' ) { if ( is_readable( "$mu_plugins_root/$file" ) ) { unset( $data ); $data = $this->get_id_plugin( "$mu_plugins_root/$file" ); if ( isset( $data['id'] ) && ! empty( $data['id'] ) ) { $local_projects[ $data['id'] ]['type'] = 'mu-plugin'; $local_projects[ $data['id'] ]['version'] = $data['version']; $local_projects[ $data['id'] ]['filename'] = $file; } } } } @closedir( $mu_plugins_dir ); } //----------------------------------------------------------------------------------// // wp-content directory //----------------------------------------------------------------------------------// $content_plugins_root = WP_CONTENT_DIR; if ( empty( $content_plugins_root ) ) { $content_plugins_root = ABSPATH . 'wp-content'; } $content_plugins_dir = @opendir( $content_plugins_root ); $content_plugin_files = array(); if ( $content_plugins_dir ) { while ( ( $file = readdir( $content_plugins_dir ) ) !== false ) { if ( substr( $file, 0, 1 ) == '.' ) { continue; } if ( ! is_dir( $content_plugins_root . '/' . $file ) ) { if ( substr( $file, - 4 ) == '.php' ) { $content_plugin_files[] = $file; } } } } @closedir( $content_plugins_dir ); if ( $content_plugins_dir && ! empty( $content_plugin_files ) ) { foreach ( $content_plugin_files as $content_plugin_file ) { if ( is_readable( "$content_plugins_root/$content_plugin_file" ) ) { unset( $data ); $data = $this->get_id_plugin( "$content_plugins_root/$content_plugin_file" ); if ( isset( $data['id'] ) && ! empty( $data['id'] ) ) { $local_projects[ $data['id'] ]['type'] = 'drop-in'; $local_projects[ $data['id'] ]['version'] = $data['version']; $local_projects[ $data['id'] ]['filename'] = $content_plugin_file; } } } } //----------------------------------------------------------------------------------// //themes directory //----------------------------------------------------------------------------------// $themes_root = WP_CONTENT_DIR . '/themes'; if ( empty( $themes_root ) ) { $themes_root = ABSPATH . 'wp-content/themes'; } $themes_dir = @opendir( $themes_root ); $themes_files = array(); $local_themes = array(); if ( $themes_dir ) { while ( ( $file = readdir( $themes_dir ) ) !== false ) { if ( substr( $file, 0, 1 ) == '.' ) { continue; } if ( is_dir( $themes_root . '/' . $file ) ) { $themes_subdir = @ opendir( $themes_root . '/' . $file ); if ( $themes_subdir ) { while ( ( $subfile = readdir( $themes_subdir ) ) !== false ) { if ( substr( $subfile, 0, 1 ) == '.' ) { continue; } if ( substr( $subfile, - 4 ) == '.css' ) { $themes_files[] = "$file/$subfile"; } } } } else { if ( substr( $file, - 4 ) == '.css' ) { $themes_files[] = $file; } } } } @closedir( $themes_dir ); @closedir( $themes_subdir ); if ( $themes_dir && ! empty( $themes_files ) ) { foreach ( $themes_files as $themes_file ) { //skip child themes if ( strpos( $themes_file, '-child' ) !== false ) { continue; } if ( is_readable( "$themes_root/$themes_file" ) ) { unset( $data ); $data = $this->get_id_plugin( "$themes_root/$themes_file" ); if ( isset( $data['id'] ) && ! empty( $data['id'] ) ) { $local_projects[ $data['id'] ]['type'] = 'theme'; $local_projects[ $data['id'] ]['filename'] = substr( $themes_file, 0, strpos( $themes_file, '/' ) ); //keep record of all themes for 133 themepack if ( $data['id'] == $this->theme_pack ) { $local_themes[ $themes_file ]['id'] = $data['id']; $local_themes[ $themes_file ]['filename'] = substr( $themes_file, 0, strpos( $themes_file, '/' ) ); $local_themes[ $themes_file ]['version'] = $data['version']; //increment 133 theme pack version to lowest in all of them if ( isset( $local_projects[ $data['id'] ]['version'] ) && version_compare( $data['version'], $local_projects[ $data['id'] ]['version'], '<' ) ) { $local_projects[ $data['id'] ]['version'] = $data['version']; } else if ( ! isset( $local_projects[ $data['id'] ]['version'] ) ) { $local_projects[ $data['id'] ]['version'] = $data['version']; } } else { $local_projects[ $data['id'] ]['version'] = $data['version']; } } } } } update_site_option( 'wdp_un_local_themes', $local_themes ); update_site_option( 'wdp_un_local_projects', $local_projects ); //now check the API $projects = array(); $theme = wp_get_theme(); $ms_allowed = $theme->get_allowed(); foreach ( $local_projects as $pid => $item ) { if ( ! empty( $blog_projects[ $pid ] ) ) { //not yet implemented // This project is activated on a blog! $active = true; } else { if ( is_multisite() ) { if ( 'theme' == $item['type'] ) { // If the theme is available on main site it's "active". $slug = $item['filename']; $active = ! empty( $ms_allowed[ $slug ] ); } else { $active = is_plugin_active_for_network( $item['filename'] ); } } else { if ( 'theme' == $item['type'] ) { $slug = $item['filename']; $active = ( $theme->stylesheet == $slug || $theme->template == $slug ); } else { $active = is_plugin_active( $item['filename'] ); } } } $extra = ''; /** * Collect extra data from individual plugins. * * @since 4.0.0 * @api wpmudev_api_project_extra_data-$pid * * @param string $extra Default extra data is an empty string. */ $extra = apply_filters( "wpmudev_api_project_extra_data-$pid", $extra ); $extra = apply_filters( 'wpmudev_api_project_extra_data', $extra, $pid ); $projects[ $pid ] = array( 'version' => $item['version'], 'active' => $active ? true : false, 'extra' => $extra, ); } //get WP/BP version string to help with support $wp_ver = is_multisite() ? "WordPress Multisite $wp_version" : "WordPress $wp_version"; if ( defined( 'BP_VERSION' ) ) { $wp_ver .= ', BuddyPress ' . BP_VERSION; } //add blog count if multisite $blog_count = is_multisite() ? get_blog_count() : 1; $url = $this->server_url . 'updates'; $options = array( 'timeout' => 15, 'sslverify' => false, // Many hosts have no updated CA bundle. 'user-agent' => 'Dashboard Notification/' . $this->version ); $options['body'] = array( 'blog_count' => $blog_count, 'wp_version' => $wp_ver, 'projects' => json_encode( $projects ), 'domain' => network_site_url(), 'admin_url' => network_admin_url(), 'home_url' => network_home_url(), ); $response = wp_remote_post( $url, $options ); if ( wp_remote_retrieve_response_code( $response ) == 200 ) { $data = $response['body']; if ( $data != 'error' ) { $data = json_decode( $data, true ); if ( is_array( $data ) ) { //we've made it here with no errors, now check for available updates $remote_projects = isset( $data['projects'] ) ? $data['projects'] : array(); $updates = array(); //check for updates if ( is_array( $remote_projects ) ) { foreach ( $remote_projects as $id => $remote_project ) { if ( isset( $local_projects[ $id ] ) && is_array( $local_projects[ $id ] ) ) { //match $local_version = $local_projects[ $id ]['version']; $remote_version = $remote_project['version']; if ( version_compare( $remote_version, $local_version, '>' ) ) { //add to array $updates[ $id ] = $local_projects[ $id ]; $updates[ $id ]['url'] = $remote_project['url']; $updates[ $id ]['name'] = $remote_project['name']; $updates[ $id ]['version'] = $local_version; $updates[ $id ]['new_version'] = $remote_version; $updates[ $id ]['autoupdate'] = $remote_project['autoupdate']; } } } //record results update_site_option( 'wdp_un_updates_available', $updates ); } else { return false; } } } } } function filter_plugin_info( $res, $action, $args ) { global $wp_version; $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version ); if ( ( $action == 'plugin_information' || $action == 'theme_information' ) && strpos( $args->slug, 'wpmudev_install' ) !== false ) { $string = explode( '-', $args->slug ); $id = intval( $string[1] ); $updates = get_site_option( 'wdp_un_updates_available' ); //if in details iframe on update core page short-curcuit it if ( did_action( 'install_plugins_pre_plugin-information' ) && is_array( $updates ) && isset( $updates[ $id ] ) ) { $this->popup_changelog( $id ); } $res = new stdClass; $res->name = $updates[ $id ]['name']; $res->slug = sanitize_title( $updates[ $id ]['name'] ); $res->version = $updates[ $id ]['version']; $res->rating = 100; $res->homepage = $updates[ $id ]['url']; $res->download_link = ''; $res->tested = $cur_wp_version; return $res; } if ( $action == 'plugin_information' && strpos( $args->slug, 'install_wpmudev_dash' ) !== false ) { $res = new stdClass; $res->name = 'WPMU DEV Dashboard'; $res->slug = 'wpmu-dev-dashboard'; $res->version = ''; $res->rating = 100; $res->homepage = 'https://premium.wpmudev.org/project/wpmu-dev-dashboard/'; $res->download_link = $this->server_url . "download-dashboard"; $res->tested = $cur_wp_version; return $res; } return $res; } function filter_plugin_rows() { if ( ! current_user_can( 'update_plugins' ) ) { return; } //don't show on per site plugins list, just like core if ( is_multisite() && ! is_network_admin() ) { return; } $updates = get_site_option( 'wdp_un_updates_available' ); if ( is_array( $updates ) && count( $updates ) ) { foreach ( $updates as $id => $plugin ) { if ( $plugin['autoupdate'] != '2' ) { if ( $plugin['type'] == 'theme' ) { remove_all_actions( 'after_theme_row_' . $plugin['filename'] ); add_action( 'after_theme_row_' . $plugin['filename'], array( &$this, 'plugin_row' ), 99, 2 ); } else { remove_all_actions( 'after_plugin_row_' . $plugin['filename'] ); add_action( 'after_plugin_row_' . $plugin['filename'], array( &$this, 'plugin_row' ), 99, 2 ); } } } } $local_themes = get_site_option( 'wdp_un_local_themes' ); if ( is_array( $local_themes ) && count( $local_themes ) ) { foreach ( $local_themes as $id => $plugin ) { remove_all_actions( 'after_theme_row_' . $plugin['filename'] ); //only add the notice if specific version is wrong if ( isset( $updates[ $this->theme_pack ] ) && version_compare( $plugin['version'], $updates[ $this->theme_pack ]['new_version'], '<' ) ) { add_action( 'after_theme_row_' . $plugin['filename'], array( &$this, 'themepack_row' ), 9, 2 ); } } } } function filter_plugin_count( $value ) { global $wp_version; $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version ); //remove any conflicting slug local WPMU DEV plugins from WP update notifications $local_projects = get_site_option( 'wdp_un_local_projects' ); if ( is_array( $local_projects ) && count( $local_projects ) ) { foreach ( $local_projects as $id => $plugin ) { if ( isset( $value->response[ $plugin['filename'] ] ) ) { unset( $value->response[ $plugin['filename'] ] ); } } } $updates = get_site_option( 'wdp_un_updates_available' ); if ( is_array( $updates ) && count( $updates ) ) { foreach ( $updates as $id => $plugin ) { if ( $plugin['type'] != 'theme' && $plugin['autoupdate'] != '2' ) { //build plugin class $object = new stdClass; $object->url = $plugin['url']; $object->slug = "wpmudev_install-$id"; $object->new_version = $plugin['new_version']; $object->package = ''; $object->tested = $cur_wp_version; //add to class $value->response[ $plugin['filename'] ] = $object; } } } return $value; } function filter_theme_count( $value ) { $updates = get_site_option( 'wdp_un_updates_available' ); if ( is_array( $updates ) && count( $updates ) ) { foreach ( $updates as $id => $theme ) { if ( $theme['type'] == 'theme' && $theme['autoupdate'] != '2' ) { $theme_slug = $theme['filename']; //build theme listing $value->response[ $theme_slug ]['theme'] = $theme['filename']; $value->response[ $theme_slug ]['url'] = admin_url( 'admin-ajax.php?action=wdpun-changelog&pid=' . $id ); $value->response[ $theme_slug ]['new_version'] = $theme['new_version']; $value->response[ $theme_slug ]['package'] = ''; } } } //filter 133 theme pack themes from the list unless update is available $local_themes = get_site_option( 'wdp_un_local_themes' ); if ( is_array( $local_themes ) && count( $local_themes ) ) { foreach ( $local_themes as $id => $theme ) { $theme_slug = $theme['filename']; //add to count only if new version exists, otherwise remove if ( isset( $updates[ $theme['id'] ] ) && isset( $updates[ $theme['id'] ]['new_version'] ) && version_compare( $theme['version'], $updates[ $theme['id'] ]['new_version'], '<' ) ) { $value->response[ $theme_slug ]['new_version'] = $updates[ $theme['id'] ]['new_version']; $value->response[ $theme_slug ]['package'] = ''; } else if ( isset( $value ) && isset( $value->response ) && isset( $theme_slug ) && isset( $value->response[ $theme_slug ] ) ) { unset( $value->response[ $theme_slug ] ); } } } return $value; } function plugin_row( $file, $plugin_data ) { //get new version and update url $updates = get_site_option( 'wdp_un_updates_available' ); if ( is_array( $updates ) && count( $updates ) ) { foreach ( $updates as $id => $plugin ) { if ( $plugin['filename'] == $file ) { $project_id = $id; $version = $plugin['new_version']; $plugin_url = $plugin['url']; $autoupdate = $plugin['autoupdate']; $filename = $plugin['filename']; $type = $plugin['type']; break; } } } else { return false; } $plugins_allowedtags = array( 'a' => array( 'href' => array(), 'title' => array() ), 'abbr' => array( 'title' => array() ), 'acronym' => array( 'title' => array() ), 'code' => array(), 'em' => array(), 'strong' => array() ); $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); $info_url = admin_url( 'admin-ajax.php?action=wdpun-changelog&pid=' . $project_id . '&TB_iframe=true&width=640&height=800' ); if ( file_exists( WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php' ) ) { $message = "Activate WPMU DEV Dashboard"; $action_url = $this->activate_url(); } else { //dashboard not installed at all $message = "Install WPMU DEV Dashboard"; $action_url = $this->auto_install_url(); } if ( current_user_can( 'update_plugins' ) ) { echo '

'; 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 ); echo '

'; } } function themepack_row( $file, $plugin_data ) { //get new version and update url $updates = get_site_option( 'wdp_un_updates_available' ); if ( isset( $updates[ $this->theme_pack ] ) ) { $plugin = $updates[ $this->theme_pack ]; $project_id = $this->theme_pack; $version = $plugin['new_version']; $plugin_url = $plugin['url']; } else { return false; } $plugins_allowedtags = array( 'a' => array( 'href' => array(), 'title' => array() ), 'abbr' => array( 'title' => array() ), 'acronym' => array( 'title' => array() ), 'code' => array(), 'em' => array(), 'strong' => array() ); $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); $info_url = admin_url( 'admin_ajax.php?action=wdpun-changelog&pid=' . $project_id . '&TB_iframe=true&width=640&height=800' ); if ( file_exists( WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php' ) ) { $message = "Activate WPMU DEV Dashboard"; $action_url = $this->activate_url(); } else { //dashboard not installed at all $message = "Install WPMU DEV Dashboard"; $action_url = $this->auto_install_url(); } if ( current_user_can( 'update_themes' ) ) { echo '

'; 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 ); echo '

'; } } function disable_checkboxes() { $updates = get_site_option( 'wdp_un_updates_available' ); if ( ! is_array( $updates ) || ( is_array( $updates ) && ! count( $updates ) ) ) { return; } $jquery = "\n"; echo $jquery; } function set_activate_flag( $plugin ) { $data = $this->get_id_plugin( WP_PLUGIN_DIR . '/' . $plugin ); if ( isset( $data['id'] ) && ! empty( $data['id'] ) ) { update_site_option( 'wdp_un_activated_flag', 1 ); } } function popup_changelog( $project_id ) { /** * Dashboard popup template: Project changelog * * Displays the changelog of a specific project. * * Following variables are passed into the template: * $pid (project ID) * * @since 4.0.5 * @package WPMUDEV_Dashboard */ $url = $this->server_url . 'changelog/' . $project_id; $options = array( 'timeout' => 15, 'sslverify' => false, // Many hosts have no updated CA bundle. 'user-agent' => 'Dashboard Notification/' . $this->version ); $response = wp_remote_get( $url, $options ); if ( wp_remote_retrieve_response_code( $response ) == 200 ) { $changelog = json_decode( wp_remote_retrieve_body( $response ), true ); } $updates = get_site_option( 'wdp_un_updates_available' ); $item = $updates[ $project_id ]; if ( ! $changelog || ! is_array( $changelog ) || ! $item ) { wp_die( __( 'We did not find any data for this plugin or theme...', 'wpmudev' ) ); } $dlg_id = 'dlg-' . md5( time() . '-' . $project_id ); ?>

', '', __( 'Current', 'wpmudev' ) ); } elseif ( 1 === $version_check ) { $badge = sprintf( '
%s %s
', '', __( 'New', 'wpmudev' ) ); } } $version = $log['version']; if ( empty( $log['time'] ) ) { $rel_date = ''; } else { $rel_date = date_i18n( get_option( 'date_format' ), $log['time'] ); } printf( '
  • %2$s %3$s %4$s

    ', esc_attr( $row_class ), sprintf( esc_html__( 'Version %s', 'wpmudev' ), esc_html( $version ) ), wp_kses_post( $badge ), esc_html( $rel_date ) ); $notes = explode( "\n", $log['log'] ); $detail_level = 0; $detail_class = 'intro'; echo '
  • '; } ?>
    popup_changelog( $project_id ); } function dismiss_ajax() { update_site_option( 'wdp_un_dismissed', time() ); wp_send_json_success(); } } $GLOBALS['WPMUDEV_Dashboard_Notice4'] = new WPMUDEV_Dashboard_Notice4(); } //disable older versions if ( ! class_exists( 'WPMUDEV_Dashboard_Notice' ) ) { class WPMUDEV_Dashboard_Notice { } } if ( ! class_exists( 'WPMUDEV_Dashboard_Notice3' ) ) { class WPMUDEV_Dashboard_Notice3 { } }