Making WordPress.org

Ticket #4857: 4857.diff

File 4857.diff, 2.1 KB (added by dingo_d, 5 years ago)
  • wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    diff --git wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php
    index e5796871c..e6f8a8808 100644
    function wporg_themes_get_current_url( $path_only = false ) { 
    12971297
    12981298        return $link;
    12991299}
     1300
     1301/**
     1302 * Add suspend bulk action
     1303 */
     1304add_action( 'current_screen', 'wporg_themes_bulk_hooks' );
     1305
     1306/**
     1307 * Hooks to current_screen hook, so that we have the WP_Screen defined
     1308 */
     1309function wporg_themes_bulk_hooks() {
     1310        add_filter( 'bulk_actions-edit-post', 'wporg_themes_add_bulk_suspend_option' );
     1311        add_filter( 'handle_bulk_actions-edit-post', 'wporg_themes_suspend_bulk_action_handler', 10, 3 );
     1312        add_action( 'admin_notices', 'wporg_themes_suspend_bulk_action_admin_notice' );
     1313}
     1314
     1315/**
     1316 * Add a new bulk action
     1317 *
     1318 * Add the suspend themes action
     1319 *
     1320 * @param  array $bulk_actions Array of bulk actions.
     1321 * @return array               Updated array of bulk actions.
     1322 */
     1323function wporg_themes_add_bulk_suspend_option( $bulk_actions ) {
     1324        $bulk_actions['suspend_themes'] = __( 'Suspend themes', 'wporg-themes' );
     1325
     1326        return $bulk_actions;
     1327}
     1328
     1329function wporg_themes_suspend_bulk_action_handler( $redirect_to, $doaction, $post_ids ) {
     1330        if ( $doaction !== 'suspend_themes' ) {
     1331                return $redirect_to;
     1332        }
     1333
     1334        foreach ( $post_ids as $post_id ) {
     1335                wp_update_post(
     1336                        array(
     1337                                'ID'          => $post_id,
     1338                                'post_status' => 'suspended',
     1339                        )
     1340                );
     1341        }
     1342
     1343        $redirect_to = add_query_arg( 'bulk_suspend_themes', count( $post_ids ), $redirect_to );
     1344
     1345        return $redirect_to;
     1346}
     1347
     1348function wporg_themes_suspend_bulk_action_admin_notice() {
     1349        if ( ! empty( $_REQUEST['bulk_suspend_themes'] ) ) {
     1350                $suspended_themes_count = intval( $_REQUEST['bulk_suspend_themes'] );
     1351
     1352                printf( '<div id="message" class="updated fade">' .
     1353                        _n( '%s theme is suspended.',
     1354                                '%s theme are suspended.',
     1355                                $suspended_themes_count,
     1356                                'wporg-themes'
     1357                        ) . '</div>', $suspended_themes_count );
     1358        }
     1359}