'wp_list_plugins', 'title' => 'List plugins', 'group' => 'plugins_themes', 'description' => 'List installed plugins with their version, active state and available updates.', 'read_only' => true, 'callback' => array( __CLASS__, 'list_plugins' ), ) ); MCP100P_Tools::add( array( 'name' => 'wp_list_themes', 'title' => 'List themes', 'group' => 'plugins_themes', 'description' => 'List installed themes and show which one is active.', 'read_only' => true, 'callback' => array( __CLASS__, 'list_themes' ), ) ); } private static function load_plugin_api() { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } public static function list_plugins() { if ( ! MCP100P_Server::owner_can( 'activate_plugins' ) ) { return MCP100P_Util::error( 'You are not allowed to view plugins.' ); } self::load_plugin_api(); $updates = get_site_transient( 'update_plugins' ); $items = array(); foreach ( get_plugins() as $file => $data ) { $items[] = array( 'plugin' => $file, 'name' => $data['Name'], 'version' => $data['Version'], 'active' => is_plugin_active( $file ), 'author' => wp_strip_all_tags( $data['Author'] ), 'description' => wp_trim_words( wp_strip_all_tags( $data['Description'] ), 25 ), 'update_available' => isset( $updates->response[ $file ]->new_version ) ? $updates->response[ $file ]->new_version : null, ); } return array( 'items' => $items ); } public static function list_themes() { if ( ! MCP100P_Server::owner_can( 'switch_themes' ) ) { return MCP100P_Util::error( 'You are not allowed to view themes.' ); } $updates = get_site_transient( 'update_themes' ); $active = get_stylesheet(); $items = array(); foreach ( wp_get_themes() as $stylesheet => $theme ) { $items[] = array( 'stylesheet' => $stylesheet, 'name' => $theme->get( 'Name' ), 'version' => $theme->get( 'Version' ), 'active' => $active === $stylesheet, 'parent' => $theme->get_template() !== $stylesheet ? $theme->get_template() : null, 'block_theme' => method_exists( $theme, 'is_block_theme' ) ? $theme->is_block_theme() : false, 'update_available' => isset( $updates->response[ $stylesheet ]['new_version'] ) ? $updates->response[ $stylesheet ]['new_version'] : null, ); } return array( 'items' => $items ); } }