Make WordPress Core

Ticket #24722: 24722-full.diff

File 24722-full.diff, 1.8 KB (added by nerrad, 12 years ago)

make sure get_post_statuses() includes registered post stati

  • wp-includes/post.php

     
    804804 * @return array List of post statuses.
    805805 */
    806806function get_post_statuses() {
    807         $status = array(
    808                 'draft'                 => __('Draft'),
    809                 'pending'               => __('Pending Review'),
    810                 'private'               => __('Private'),
    811                 'publish'               => __('Published')
    812         );
     807        global $wp_post_statuses;
     808        $stati = wp_set_array_key_value_from_objects( $wp_post_statuses, 'name', 'label' );
    813809
    814         return $status;
     810        return $stati;
    815811}
    816812
    817813/**
     
    831827                'publish'               => __('Published')
    832828        );
    833829
    834         return $status;
     830        return $stati;
    835831}
    836832
    837833/**
  • wp-includes/functions.php

     
    26292629        return $list;
    26302630}
    26312631
     2632
     2633
    26322634/**
     2635 * This just takes an incoming array of objects and returns an array of keys/values from the objects for what you want returned.
     2636 * @param  array $objects     array of objects
     2637 * @param  string $keyindex   What object property you want to be the key
     2638 * @param  string $valueindex What object propery you want to be the value
     2639 * @return array             An array set up with the key/value pairs as indicated in the params
     2640 */
     2641function wp_set_array_key_value_from_objects( $objects, $keyindex, $valueindex ) {
     2642        $formedarray = array();
     2643        if ( !is_array( $objects ) )
     2644                return;
     2645
     2646        foreach ( $objects as $obj ) {
     2647                if ( !isset( $obj->$keyindex ) )
     2648                        continue;
     2649                if ( !isset( $obj->$valueindex ) )
     2650                        continue;
     2651
     2652                $formedarray[$obj->$keyindex] = $obj->$valueindex;
     2653        }
     2654
     2655        return $formedarray;
     2656}
     2657
     2658/**
    26332659 * Filters a list of objects, based on a set of key => value arguments.
    26342660 *
    26352661 * @since 3.1.0