Make WordPress Core

Ticket #23257: 23257.3.diff

File 23257.3.diff, 2.6 KB (added by iamfriendly, 8 years ago)

Refreshed the patch and added docs

  • wp-includes/post-formats.php

    diff --git wp-includes/post-formats.php wp-includes/post-formats.php
    index 7800ba0..94c5581 100644
    function set_post_format( $post, $format ) { 
    7979}
    8080
    8181/**
    82  * Returns an array of post format slugs to their translated and pretty display versions
     82 * Returns an array of post format slugs to their translated and pretty display versions.
    8383 *
    8484 * @since 3.1.0
     85 * @since 4.4.0 Added the `$plural` parameter.
    8586 *
     87 * @param $plural bool Set to true to return the plural versions of the strings.
    8688 * @return array The array of translated post format names.
    8789 */
    88 function get_post_format_strings() {
    89         $strings = array(
     90function get_post_format_strings( $plural = false ) {
     91        $singular_strings = array(
    9092                'standard' => _x( 'Standard', 'Post format' ), // Special case. any value that evals to false will be considered standard
    9193                'aside'    => _x( 'Aside',    'Post format' ),
    9294                'chat'     => _x( 'Chat',     'Post format' ),
    function get_post_format_strings() { 
    98100                'video'    => _x( 'Video',    'Post format' ),
    99101                'audio'    => _x( 'Audio',    'Post format' ),
    100102        );
    101         return $strings;
     103
     104        $plural_strings = array(
     105                'standard' => _x( 'Standard posts', 'Post format (plural)' ),
     106                'aside'    => _x( 'Asides',         'Post format (plural)' ),
     107                'chat'     => _x( 'Chats',          'Post format (plural)' ),
     108                'gallery'  => _x( 'Galleries',      'Post format (plural)' ),
     109                'link'     => _x( 'Links',          'Post format (plural)' ),
     110                'image'    => _x( 'Images',         'Post format (plural)' ),
     111                'quote'    => _x( 'Quotes',         'Post format (plural)' ),
     112                'status'   => _x( 'Statuses',       'Post format (plural)' ),
     113                'video'    => _x( 'Videos',         'Post format (plural)' ),
     114                'audio'    => _x( 'Audio',          'Post format (plural)' ),
     115        );
     116
     117        if ( $plural ) {
     118                return $plural_strings;
     119        } else {
     120                return $singular_strings;
     121        }
    102122}
    103123
    104124/**
    function get_post_format_slugs() { 
    117137 * Returns a pretty, translated version of a post format slug
    118138 *
    119139 * @since 3.1.0
     140 * @since 4.4.0 Added the `$plural` parameter.
    120141 *
    121  * @param string $slug A post format slug.
     142 * @param string  $slug A post format slug.
     143 * @param bool    $plural The singular or plural version of the strings.
    122144 * @return string The translated post format name.
    123145 */
    124 function get_post_format_string( $slug ) {
    125         $strings = get_post_format_strings();
     146function get_post_format_string( $slug, $plural = false ) {
     147        $strings = get_post_format_strings( $plural );
    126148        if ( !$slug )
    127149                return $strings['standard'];
    128150        else