Make WordPress Core


Ignore:
Timestamp:
11/04/2015 09:48:43 PM (11 years ago)
Author:
SergeyBiryukov
Message:

Themes: Add a Favorites tab to the Add Themes screen.

You can now browse and install your wordpress.org theme favorites from the theme installer, just like with plugins.

Props swissspidy.
Fixes #34206.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r35518 r35527  
    28222822        ) );
    28232823
     2824        if ( 'favorites' === $args['browse'] && ! isset( $args['user'] ) ) {
     2825                $user = get_user_option( 'wporg_favorites' );
     2826                if ( $user ) {
     2827                        $args['user'] = $user;
     2828                }
     2829        }
     2830
    28242831        $old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search';
    28252832
    … …  
    32913298        wp_send_json_success( wp_generate_password( 24 ) );
    32923299}
     3300
     3301/**
     3302 * Ajax handler for saving the user's WordPress.org username.
     3303 *
     3304 * @since 4.4.0
     3305 */
     3306function wp_ajax_save_wporg_username() {
     3307        if ( ! current_user_can( 'install_themes' ) && ! current_user_can( 'install_plugins' ) ) {
     3308                wp_send_json_error();
     3309        }
     3310
     3311        $username = isset( $_REQUEST['username'] ) ? wp_unslash( $_REQUEST['username'] ) : false;
     3312
     3313        if ( ! $username ) {
     3314                wp_send_json_error();
     3315        }
     3316
     3317        wp_send_json_success( update_user_meta( get_current_user_id(), 'wporg_favorites', $username ) );
     3318}
Note: See TracChangeset for help on using the changeset viewer.