WordPress.org

Make WordPress Core

Changeset 16705


Ignore:
Timestamp:
12/03/2010 10:13:17 AM (8 years ago)
Author:
nacin
Message:

Post format indexes. First pass. see #15378.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/themes.php

    r16553 r16705  
    1313$wp_list_table->check_permissions();
    1414
    15 if ( current_user_can('switch_themes') && isset($_GET['action']) ) {
     15if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
    1616    if ( 'activate' == $_GET['action'] ) {
    1717        check_admin_referer('switch-theme_' . $_GET['template']);
     
    1919        wp_redirect( admin_url('themes.php?activated=true') );
    2020        exit;
    21     } else if ( 'delete' == $_GET['action'] ) {
     21    } elseif ( 'delete' == $_GET['action'] ) {
    2222        check_admin_referer('delete-theme_' . $_GET['template']);
    2323        if ( !current_user_can('delete_themes') )
     
    3535
    3636if ( current_user_can( 'switch_themes' ) ) :
     37
     38// Flush rewrite rules on activation once new theme is in place.
     39if ( isset( $_GET['activated'] ) && $_GET['activated'] == 'true' )
     40    flush_rewrite_rules();
    3741
    3842$help = '<p>' . __('Aside from the default theme included with your WordPress installation, themes are designed and developed by third parties.') . '</p>';
  • trunk/wp-includes/post.php

    r16698 r16705  
    50685068}
    50695069
     5070function get_post_format_slugs() {
     5071    $slugs = array(
     5072        'default' => _x( 'default', 'Post format slug' ),
     5073        'aside'   => _x( 'aside',   'Post format slug' ),
     5074        'chat'    => _x( 'chat',    'Post format slug' ),
     5075        'gallery' => _x( 'gallery', 'Post format slug' ),
     5076        'link'    => _x( 'link',    'Post format slug' ),
     5077        'image'   => _x( 'image',   'Post format slug' ),
     5078        'quote'   => _x( 'quote',   'Post format slug' ),
     5079        'status'  => _x( 'status',  'Post format slug' ),
     5080        'video'   => _x( 'video',   'Post format slug' ),
     5081        'audio'   => _x( 'audio',   'Post format slug' ),
     5082    );
     5083    $slugs = array_map( 'sanitize_title_with_dashes', $slugs );
     5084    return $slugs;
     5085}
     5086
    50705087/**
    50715088 * Returns a pretty, translated version of a post format slug
     
    51065123}
    51075124
     5125/**
     5126 * Returns a link to a post format index.
     5127 *
     5128 * @since 3.1.0
     5129 *
     5130 * @param $format string Post format
     5131 * @return string Link
     5132 */
     5133function get_post_format_link( $format ) {
     5134    $term = get_term_by('slug', 'post-format-' . $format, 'post_format' );
     5135    if ( ! $term || is_wp_error( $term ) )
     5136        return false;
     5137    return get_term_link( $term );
     5138}
     5139
     5140/**
     5141 * Filters the request to allow for the format prefix.
     5142 *
     5143 * @access private
     5144 * @since 3.1.0
     5145 */
     5146function _post_format_request( $qvs ) {
     5147    if ( ! isset( $qvs['post_format'] ) )
     5148        return $qvs;
     5149    $slugs = array_flip( get_post_format_slugs() );
     5150    if ( isset( $slugs[ $qvs['post_format'] ] ) )
     5151        $qvs['post_format'] = 'post-format-' . $slugs[ $qvs['post_format'] ];
     5152    return $qvs;
     5153}
     5154add_filter( 'request', '_post_format_request' );
     5155
     5156/**
     5157 * Filters the post format term link to remove the format prefix.
     5158 *
     5159 * @access private
     5160 * @since 3.1.0
     5161 */
     5162function _post_format_link( $link, $term, $taxonomy ) {
     5163    global $wp_rewrite;
     5164    if ( 'post_format' != $taxonomy )
     5165        return $link;
     5166    $slugs = get_post_format_slugs();
     5167    if ( $wp_rewrite->get_extra_permastruct( $taxonomy ) ) {
     5168        return str_replace( "/{$term->slug}", '/' . $slugs[ str_replace( 'post-format-', '', $term->slug ) ], $link );
     5169    } else {
     5170        $link = remove_query_arg( 'format', $link );
     5171        return add_query_arg( 'format', str_replace( 'post-format-', $term->slug ), $link );
     5172    }
     5173}
     5174add_filter( 'term_link', '_post_format_link', 10, 3 );
     5175
    51085176?>
  • trunk/wp-includes/taxonomy.php

    r16691 r16705  
    2020        'update_count_callback' => '_update_post_term_count',
    2121        'query_var' => 'category_name',
    22         'rewrite' => array(
     22        'rewrite' => did_action( 'init' ) ? array(
    2323                    'hierarchical' => true,
    2424                    'slug' => get_option('category_base') ? get_option('category_base') : 'category',
    25                     'with_front' => false),
     25                    'with_front' => false) : false,
    2626        'public' => true,
    2727        'show_ui' => true,
     
    3333        'update_count_callback' => '_update_post_term_count',
    3434        'query_var' => 'tag',
    35         'rewrite' => array(
    36                     'slug' => get_option('tag_base') ? get_option('tag_base') : 'tag' ,
    37                     'with_front' => false),
     35        'rewrite' => did_action( 'init' ) ? array(
     36                    'slug' => get_option('tag_base') ? get_option('tag_base') : 'tag',
     37                    'with_front' => false) : false,
    3838        'public' => true,
    3939        'show_ui' => true,
     
    5353        '_builtin' => true,
    5454        'show_in_nav_menus' => false,
    55     ) ) ;
     55    ) );
    5656
    5757    register_taxonomy( 'link_category', 'link', array(
     
    7676        'show_ui' => false,
    7777        '_builtin' => true,
    78     ) ) ;
     78    ) );
     79
     80    $rewrite = false;
     81    if ( did_action( 'init' ) && current_theme_supports( 'post-formats' ) ) {
     82        $rewrite = apply_filters( 'post_format_rewrite_base', 'type' );
     83        $rewrite = $rewrite ? array( 'slug' => $rewrite ) : false;
     84    }
    7985
    8086    register_taxonomy( 'post_format', 'post', array(
    81         'public' => false,
     87        'public' => true,
    8288        'hierarchical' => false,
    8389        'labels' => array(
     
    8591            'singular_name' => '',
    8692        ),
    87         'query_var' => false,
    88         'rewrite' => false,
     93        'query_var' => 'post_format',
     94        'rewrite' => $rewrite,
    8995        'show_ui' => false,
    9096        '_builtin' => true,
    9197        'show_in_nav_menus' => false,
    92     ) ) ;
     98    ) );
    9399}
    94100add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
     
    311317    }
    312318
    313     if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') && !empty($wp_rewrite) ) {
     319    if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') ) {
    314320        $args['rewrite'] = wp_parse_args($args['rewrite'], array(
    315321            'slug' => sanitize_title_with_dashes($taxonomy),
Note: See TracChangeset for help on using the changeset viewer.