Make WordPress Core

Changeset 24249


Ignore:
Timestamp:
05/14/2013 01:57:59 PM (13 years ago)
Author:
ryan
Message:

Remove redundant post ID validation.

Props SergeyBiryukov
fixes #24199

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r24241 r24249  
    18511851 */
    18521852function get_attached_media( $type, $post_id = 0 ) {
    1853     $post = empty( $post_id ) ? get_post() : get_post( $post_id );
    1854     if ( empty( $post ) )
     1853    if ( ! $post = get_post( $post_id ) )
    18551854        return;
    18561855
     
    23412340 */
    23422341function get_post_galleries( $post_id = 0, $html = true ) {
    2343     $post = empty( $post_id ) ? clone get_post() : get_post( $post_id );
    2344     if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' )  )
     2342    if ( ! $post = get_post( $post_id ) )
     2343        return array();
     2344
     2345    if ( ! has_shortcode( $post->post_content, 'gallery' )  )
    23452346        return array();
    23462347
     
    23582359 */
    23592360function get_post_galleries_images( $post_id = 0 ) {
    2360     $post = empty( $post_id ) ? clone get_post() : get_post( $post_id );
    2361     if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' )  )
     2361    if ( ! $post = get_post( $post_id ) )
     2362        return array();
     2363
     2364    if ( ! has_shortcode( $post->post_content, 'gallery' )  )
    23622365        return array();
    23632366
     
    23762379 */
    23772380function get_post_gallery( $post_id = 0, $html = true ) {
    2378     $post = empty( $post_id ) ? clone get_post() : get_post( $post_id );
    2379     if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' ) )
     2381    if ( ! $post = get_post( $post_id ) )
     2382        return array();
     2383
     2384    if ( ! has_shortcode( $post->post_content, 'gallery' ) )
    23802385        return array();
    23812386
  • trunk/wp-includes/post-formats.php

    r24242 r24249  
    317317 *
    318318 * @param string $content The post content.
    319  * @param int $id (optional) The post ID.
     319 * @param int $post_id (optional) The post ID.
    320320 * @return string Formatted output based on associated post format.
    321321 */
    322 function post_formats_compat( $content, $id = 0 ) {
    323     $post = empty( $id ) ? get_post() : get_post( $id );
    324     if ( empty( $post ) )
     322function post_formats_compat( $content, $post_id = 0 ) {
     323    if ( ! $post = get_post( $post_id ) )
    325324        return $content;
    326325
     
    640639 * @since 3.6.0
    641640 *
    642  * @param int $id (optional) The post ID.
     641 * @param int $post_id (optional) The post ID.
    643642 * @return array The chat content.
    644643 */
    645 function get_the_post_format_chat( $id = 0 ) {
    646     $post = empty( $id ) ? clone get_post() : get_post( $id );
    647     if ( empty( $post ) )
     644function get_the_post_format_chat( $post_id = 0 ) {
     645    if ( ! $post = get_post( $post_id ) )
    648646        return array();
    649647
     
    815813 * @since 3.6.0
    816814 *
    817  * @param int $id (optional) The post ID.
     815 * @param int $post_id (optional) The post ID.
    818816 * @return string A URL, if found.
    819817 */
    820 function get_the_post_format_url( $id = 0 ) {
    821     $post = empty( $id ) ? get_post() : get_post( $id );
    822     if ( empty( $post ) )
     818function get_the_post_format_url( $post_id = 0 ) {
     819    if ( ! $post = get_post( $post_id ) )
    823820        return '';
    824821
Note: See TracChangeset for help on using the changeset viewer.