1295
1295
function wp_dashboard_secondary_control() {}
1298
* Display plugins text for the WordPress news widget.
1303
* @param string $rss The RSS feed URL.
1304
* @param array $args Array of arguments for this RSS feed.
1306
function wp_dashboard_plugins_output( $rss, $args = array() ) {
1307
_deprecated_function( __FUNCTION__, '4.8.0' );
1309
// Plugin feeds plus link to install them
1310
$popular = fetch_feed( $args['url']['popular'] );
1312
if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
1313
$plugin_slugs = array_keys( get_plugins() );
1314
set_transient( 'plugin_slugs', $plugin_slugs, DAY_IN_SECONDS );
1319
foreach ( array( $popular ) as $feed ) {
1320
if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() )
1323
$items = $feed->get_items(0, 5);
1325
// Pick a random, non-installed plugin
1327
// Abort this foreach loop iteration if there's no plugins left of this type
1328
if ( 0 == count($items) )
1331
$item_key = array_rand($items);
1332
$item = $items[$item_key];
1334
list($link, $frag) = explode( '#', $item->get_link() );
1336
$link = esc_url($link);
1337
if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) )
1338
$slug = $matches[1];
1340
unset( $items[$item_key] );
1344
// Is this random plugin's slug already installed? If so, try again.
1345
reset( $plugin_slugs );
1346
foreach ( $plugin_slugs as $plugin_slug ) {
1347
if ( $slug == substr( $plugin_slug, 0, strlen( $slug ) ) ) {
1348
unset( $items[$item_key] );
1353
// If we get to this point, then the random plugin isn't installed and we can stop the while().
1357
// Eliminate some common badly formed plugin descriptions
1358
while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
1359
unset($items[$item_key]);
1361
if ( !isset($items[$item_key]) )
1364
$raw_title = $item->get_title();
1366
$ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&TB_iframe=true&width=600&height=800';
1367
echo '<li class="dashboard-news-plugin"><span>' . __( 'Popular Plugin' ) . ':</span> ' . esc_html( $raw_title ) .
1368
' <a href="' . $ilink . '" class="thickbox open-plugin-details-modal" aria-label="' .
1369
/* translators: %s: plugin name */
1370
esc_attr( sprintf( __( 'Install %s' ), $raw_title ) ) . '">(' . __( 'Install' ) . ')</a></li>';
1372
$feed->__destruct();
1298
1380
* This was once used to move child posts to a new parent.