~canonical-sysadmins/wordpress/4.8

« back to all changes in this revision

Viewing changes to wp-admin/includes/deprecated.php

  • Committer: Barry Price
  • Date: 2017-06-09 02:09:58 UTC
  • mfrom: (1.1.26 upstream)
  • Revision ID: barry.price@canonical.com-20170609020958-838whhwt2196f2vk
Merge WP4.8 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1295
1295
function wp_dashboard_secondary_control() {}
1296
1296
 
1297
1297
/**
 
1298
 * Display plugins text for the WordPress news widget.
 
1299
 *
 
1300
 * @since 2.5.0
 
1301
 * @deprecated 4.8.0
 
1302
 *
 
1303
 * @param string $rss  The RSS feed URL.
 
1304
 * @param array  $args Array of arguments for this RSS feed.
 
1305
 */
 
1306
function wp_dashboard_plugins_output( $rss, $args = array() ) {
 
1307
        _deprecated_function( __FUNCTION__, '4.8.0' );
 
1308
 
 
1309
        // Plugin feeds plus link to install them
 
1310
        $popular = fetch_feed( $args['url']['popular'] );
 
1311
 
 
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 );
 
1315
        }
 
1316
 
 
1317
        echo '<ul>';
 
1318
 
 
1319
        foreach ( array( $popular ) as $feed ) {
 
1320
                if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() )
 
1321
                        continue;
 
1322
 
 
1323
                $items = $feed->get_items(0, 5);
 
1324
 
 
1325
                // Pick a random, non-installed plugin
 
1326
                while ( true ) {
 
1327
                        // Abort this foreach loop iteration if there's no plugins left of this type
 
1328
                        if ( 0 == count($items) )
 
1329
                                continue 2;
 
1330
 
 
1331
                        $item_key = array_rand($items);
 
1332
                        $item = $items[$item_key];
 
1333
 
 
1334
                        list($link, $frag) = explode( '#', $item->get_link() );
 
1335
 
 
1336
                        $link = esc_url($link);
 
1337
                        if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) )
 
1338
                                $slug = $matches[1];
 
1339
                        else {
 
1340
                                unset( $items[$item_key] );
 
1341
                                continue;
 
1342
                        }
 
1343
 
 
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] );
 
1349
                                        continue 2;
 
1350
                                }
 
1351
                        }
 
1352
 
 
1353
                        // If we get to this point, then the random plugin isn't installed and we can stop the while().
 
1354
                        break;
 
1355
                }
 
1356
 
 
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]);
 
1360
 
 
1361
                if ( !isset($items[$item_key]) )
 
1362
                        continue;
 
1363
 
 
1364
                $raw_title = $item->get_title();
 
1365
 
 
1366
                $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&amp;TB_iframe=true&amp;width=600&amp;height=800';
 
1367
                echo '<li class="dashboard-news-plugin"><span>' . __( 'Popular Plugin' ) . ':</span> ' . esc_html( $raw_title ) .
 
1368
                        '&nbsp;<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>';
 
1371
 
 
1372
                $feed->__destruct();
 
1373
                unset( $feed );
 
1374
        }
 
1375
 
 
1376
        echo '</ul>';
 
1377
}
 
1378
 
 
1379
/**
1298
1380
 * This was once used to move child posts to a new parent.
1299
1381
 *
1300
1382
 * @since 2.3.0