Make WordPress Core


Ignore:
Timestamp:
03/02/2012 10:09:26 PM (12 years ago)
Author:
nacin
Message:

Output themes and theme-install infinite scrolling args in JS, rather than parsing query strings. props DH-Shredder, helenyhou. Make WP_Theme_Install_List_Table extend WP_Themes_List_Table. Doesn't help much yet, but we should be able to dry things up further. see #19815.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-themes-list-table.php

    r20068 r20094  
    2121    function ajax_user_can() {
    2222        // Do not check edit_theme_options here. AJAX calls for available themes require switch_themes.
    23         return current_user_can('switch_themes');
     23        return current_user_can( 'switch_themes' );
    2424    }
    2525
     
    5353            'total_items' => count( $themes ),
    5454            'per_page' => $per_page,
     55            'infinite_scroll' => true,
    5556        ) );
    5657    }
     
    203204        return true;
    204205    }
     206
     207    /**
     208     * Send required variables to JavaScript land
     209     *
     210     * @since 3.4
     211     * @access private
     212     *
     213     * @uses $this->features Array of all feature search terms.
     214     * @uses get_pagenum()
     215     * @uses _pagination_args['total_pages']
     216     */
     217     function _js_vars( $extra_args = array() ) {
     218        $search_string = isset( $_REQUEST['s'] ) ? esc_attr( stripslashes( $_REQUEST['s'] ) ) : '';
     219
     220        $total_pages = 1;
     221        if ( ! empty( $this->_pagination_args['total_pages'] ) )
     222            $total_pages = $this->_pagination_args['total_pages'];
     223
     224        $args = array(
     225            'search' => $search_string,
     226            'features' => $this->features,
     227            'paged' => $this->get_pagenum(),
     228            'total_pages' => $total_pages,
     229        );
     230
     231        if ( is_array( $extra_args ) )
     232        $args = array_merge( $args, $extra_args );
     233
     234        printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", json_encode( $args ) );
     235        parent::_js_vars();
     236    }
    205237}
Note: See TracChangeset for help on using the changeset viewer.