Make WordPress Core

Ticket #26526: 26526.4.diff

File 26526.4.diff, 5.5 KB (added by ocean90, 11 years ago)

Use get_term_by( 'slug', ...

  • src/wp-content/themes/twentyfourteen/inc/customizer.php

     
    3333        // Add the featured content section in case it's not already there.
    3434        $wp_customize->add_section( 'featured_content', array(
    3535                'title'       => __( 'Featured Content', 'twentyfourteen' ),
    36                 'description' => sprintf( __( 'Use a <a href="%1$s">tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ), admin_url( '/edit.php?tag=featured' ), admin_url( '/edit.php?show_sticky=1' ) ),
     36                'description' => sprintf( __( 'Use a <a href="%1$s">tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ),
     37                        esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ),
     38                        admin_url( 'edit.php?show_sticky=1' )
     39                ),
    3740                'priority'    => 130,
    3841        ) );
    3942
     
    98101                'title'   => __( 'Twenty Fourteen', 'twentyfourteen' ),
    99102                'content' =>
    100103                        '<ul>' .
    101                                 '<li>' . sprintf( __( 'The home page features your choice of up to 6 posts prominently displayed in a grid or slider, controlled by the <a href="%1$s">featured</a> tag; you can change the tag and layout in <a href="%2$s">Appearance &rarr; Customize</a>. If no posts match the tag, <a href="%3$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ), admin_url( '/edit.php?tag=featured' ), admin_url( 'customize.php' ), admin_url( '/edit.php?show_sticky=1' ) ) . '</li>' .
     104                                '<li>' . sprintf( __( 'The home page features your choice of up to 6 posts prominently displayed in a grid or slider, controlled a <a href="%1$s">tag</a>; you can change the tag and layout in <a href="%2$s">Appearance &rarr; Customize</a>. If no posts match the tag, <a href="%3$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ), esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ), admin_url( 'customize.php' ), admin_url( 'edit.php?show_sticky=1' ) ) . '</li>' .
    102105                                '<li>' . sprintf( __( 'Enhance your site design by using <a href="%s">Featured Images</a> for posts you&rsquo;d like to stand out (also known as post thumbnails). This allows you to associate an image with your post without inserting it. Twenty Fourteen uses featured images for posts and pages&mdash;above the title&mdash;and in the Featured Content area on the home page.', 'twentyfourteen' ), 'http://codex.wordpress.org/Post_Thumbnails#Setting_a_Post_Thumbnail' ) . '</li>' .
    103106                                '<li>' . sprintf( __( 'For an in-depth tutorial, and more tips and tricks, visit the <a href="%s">Twenty Fourteen documentation</a>.', 'twentyfourteen' ), 'http://codex.wordpress.org/Twenty_Fourteen' ) . '</li>' .
    104107                        '</ul>',
  • src/wp-content/themes/twentyfourteen/inc/featured-content.php

     
    159159                $settings = self::get_setting();
    160160
    161161                // Return sticky post ids if no tag name is set.
    162                 $term = get_term_by( 'name', $settings['tag-name'], 'post_tag' );
     162                $term = get_term_by( 'slug', $settings['tag-name'], 'post_tag' );
    163163                if ( $term ) {
    164164                        $tag = $term->term_id;
    165165                } else {
     
    406406        public static function customize_register( $wp_customize ) {
    407407                $wp_customize->add_section( 'featured_content', array(
    408408                        'title'          => __( 'Featured Content', 'twentyfourteen' ),
    409                         'description'    => sprintf( __( 'Use the <a href="%1$s">"featured" tag</a> to feature your posts. You can change this to a tag of your choice; if no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ), admin_url( '/edit.php?tag=featured' ), admin_url( '/edit.php?show_sticky=1' ) ),
     409                        'description'    => sprintf( __( 'Use a <a href="%1$s">tag</a> to feature your posts. You can change this to a tag of your choice; if no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ),
     410                                esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ),
     411                                admin_url( 'edit.php?show_sticky=1' )
     412                        ),
    410413                        'priority'       => 130,
    411414                        'theme_supports' => 'featured-content',
    412415                ) );
    413416
    414417                // Add Featured Content settings.
    415418                $wp_customize->add_setting( 'featured-content[tag-name]', array(
    416                         'default'              => 'featured',
     419                        'default'              => _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ),
    417420                        'type'                 => 'option',
    418421                        'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ),
    419422                ) );
     
    474477                        'hide-tag' => 1,
    475478                        'quantity' => 6,
    476479                        'tag-id'   => 0,
    477                         'tag-name' => 'featured',
     480                        'tag-name' => _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ),
    478481                );
    479482
    480483                $options = wp_parse_args( $saved, $defaults );
     
    508511                if ( empty( $input['tag-name'] ) ) {
    509512                        $output['tag-id'] = 0;
    510513                } else {
    511                         $term = get_term_by( 'name', $input['tag-name'], 'post_tag' );
     514                        $term = get_term_by( 'slug', $input['tag-name'], 'post_tag' );
    512515
    513516                        if ( $term ) {
    514517                                $output['tag-id'] = $term->term_id;