Remove redundant post ID validation.

Props SergeyBiryukov
fixes #24199


git-svn-id: http://core.svn.wordpress.org/trunk@24249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2013-05-14 13:57:59 +00:00
parent 004e66320a
commit f14b0c3e13
2 changed files with 22 additions and 20 deletions

View File

@ -1850,8 +1850,7 @@ function wp_enqueue_media( $args = array() ) {
* @return array Found attachments
*/
function get_attached_media( $type, $post_id = 0 ) {
$post = empty( $post_id ) ? get_post() : get_post( $post_id );
if ( empty( $post ) )
if ( ! $post = get_post( $post_id ) )
return;
$args = array(
@ -2340,8 +2339,10 @@ function get_content_galleries( &$content, $html = true, $remove = false, $limit
* from the expanded shortcode
*/
function get_post_galleries( $post_id = 0, $html = true ) {
$post = empty( $post_id ) ? clone get_post() : get_post( $post_id );
if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' ) )
if ( ! $post = get_post( $post_id ) )
return array();
if ( ! has_shortcode( $post->post_content, 'gallery' ) )
return array();
return get_content_galleries( $post->post_content, $html );
@ -2357,8 +2358,10 @@ function get_post_galleries( $post_id = 0, $html = true ) {
* from an expanded shortcode
*/
function get_post_galleries_images( $post_id = 0 ) {
$post = empty( $post_id ) ? clone get_post() : get_post( $post_id );
if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' ) )
if ( ! $post = get_post( $post_id ) )
return array();
if ( ! has_shortcode( $post->post_content, 'gallery' ) )
return array();
$data = get_content_galleries( $post->post_content, false );
@ -2375,8 +2378,10 @@ function get_post_galleries_images( $post_id = 0 ) {
* @return array Gallery data and srcs parsed from the expanded shortcode
*/
function get_post_gallery( $post_id = 0, $html = true ) {
$post = empty( $post_id ) ? clone get_post() : get_post( $post_id );
if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' ) )
if ( ! $post = get_post( $post_id ) )
return array();
if ( ! has_shortcode( $post->post_content, 'gallery' ) )
return array();
$data = get_content_galleries( $post->post_content, $html, false, 1 );

View File

@ -316,12 +316,11 @@ function post_format_content_class( $format ) {
* @uses get_post_format_meta()
*
* @param string $content The post content.
* @param int $id (optional) The post ID.
* @param int $post_id (optional) The post ID.
* @return string Formatted output based on associated post format.
*/
function post_formats_compat( $content, $id = 0 ) {
$post = empty( $id ) ? get_post() : get_post( $id );
if ( empty( $post ) )
function post_formats_compat( $content, $post_id = 0 ) {
if ( ! $post = get_post( $post_id ) )
return $content;
$format = get_post_format( $post );
@ -639,12 +638,11 @@ function get_content_chat( &$content, $remove = false ) {
*
* @since 3.6.0
*
* @param int $id (optional) The post ID.
* @param int $post_id (optional) The post ID.
* @return array The chat content.
*/
function get_the_post_format_chat( $id = 0 ) {
$post = empty( $id ) ? clone get_post() : get_post( $id );
if ( empty( $post ) )
function get_the_post_format_chat( $post_id = 0 ) {
if ( ! $post = get_post( $post_id ) )
return array();
$data = get_content_chat( get_paged_content( $post->post_content ) );
@ -814,12 +812,11 @@ function get_content_url( &$content, $remove = false ) {
*
* @since 3.6.0
*
* @param int $id (optional) The post ID.
* @param int $post_id (optional) The post ID.
* @return string A URL, if found.
*/
function get_the_post_format_url( $id = 0 ) {
$post = empty( $id ) ? get_post() : get_post( $id );
if ( empty( $post ) )
function get_the_post_format_url( $post_id = 0 ) {
if ( ! $post = get_post( $post_id ) )
return '';
$format = get_post_format( $post->ID );