recommended_plugins = get_transient( 'wpaas_recommended_plugins' ); if ( WP_DEBUG || false === $this->recommended_plugins ) { $response = wp_remote_get( add_query_arg( 'ver', time(), esc_url_raw( self::URL ) ) ); if ( 200 !== wp_remote_retrieve_response_code( $response ) || is_wp_error( $response ) ) { return $response; } $plugins = (object) json_decode( wp_remote_retrieve_body( $response ), true ); if ( empty( $plugins ) ) { return; } $this->recommended_plugins = $plugins; set_transient( 'wpaas_recommended_plugins', $plugins, DAY_IN_SECONDS ); } add_filter( 'install_plugins_tabs', [ $this, 'install_plugins_tabs' ], -PHP_INT_MAX ); add_action( 'install_plugins_' . self::SLUG, [ $this, 'recommended_plugin_list' ] ); add_filter( 'admin_body_class', [ $this, 'recommended_plugin_list_class' ] ); } /** * Setup our install plugins tabs * * @param array $tabs List of available tabs. * * @return array Filtered list of plugin install tabs. */ public function install_plugins_tabs( $tabs ) { $unset_tabs = [ 'beta', 'featured', 'recommended', ]; foreach ( $unset_tabs as $tab ) { if ( ! isset( $tabs[ $tab ] ) ) { continue; } unset( $tabs[ $tab ] ); } $tabs = [ self::SLUG => __( 'GoDaddy Recommended', 'gd-system-plugin' ) ] + $tabs; return $tabs; } /** * Render the recommended plugin table * * @return null */ public function recommended_plugin_list() { $list_table = new Recommended_Plugins_List_Table( $this->recommended_plugins ); ?>
display(); ?>