| @@ 668-689 (lines=22) @@ | ||
| 665 | return $this->get_post_by( 'ID', $post->ID, $args['context'] ); |
|
| 666 | } |
|
| 667 | ||
| 668 | private function parse_and_set_featured_image( $post_id, $delete_featured_image, $featured_image ) { |
|
| 669 | if ( $delete_featured_image ) { |
|
| 670 | delete_post_thumbnail( $post_id ); |
|
| 671 | return; |
|
| 672 | } |
|
| 673 | ||
| 674 | $featured_image = (string) $featured_image; |
|
| 675 | ||
| 676 | // if we got a post ID, we can just set it as the thumbnail |
|
| 677 | if ( ctype_digit( $featured_image ) && 'attachment' == get_post_type( $featured_image ) ) { |
|
| 678 | set_post_thumbnail( $post_id, $featured_image ); |
|
| 679 | return $featured_image; |
|
| 680 | } |
|
| 681 | ||
| 682 | $featured_image_id = $this->handle_media_sideload( $featured_image, $post_id ); |
|
| 683 | ||
| 684 | if ( empty( $featured_image_id ) || ! is_int( $featured_image_id ) ) |
|
| 685 | return false; |
|
| 686 | ||
| 687 | set_post_thumbnail( $post_id, $featured_image_id ); |
|
| 688 | return $featured_image_id; |
|
| 689 | } |
|
| 690 | ||
| 691 | private function parse_and_set_author( $author = null, $post_type = 'post' ) { |
|
| 692 | if ( empty( $author ) || ! post_type_supports( $post_type, 'author' ) ) |
|
| @@ 679-700 (lines=22) @@ | ||
| 676 | return $this->get_post_by( 'ID', $post->ID, $args['context'] ); |
|
| 677 | } |
|
| 678 | ||
| 679 | protected function parse_and_set_featured_image( $post_id, $delete_featured_image, $featured_image ) { |
|
| 680 | if ( $delete_featured_image ) { |
|
| 681 | delete_post_thumbnail( $post_id ); |
|
| 682 | return; |
|
| 683 | } |
|
| 684 | ||
| 685 | $featured_image = (string) $featured_image; |
|
| 686 | ||
| 687 | // if we got a post ID, we can just set it as the thumbnail |
|
| 688 | if ( ctype_digit( $featured_image ) && 'attachment' == get_post_type( $featured_image ) ) { |
|
| 689 | set_post_thumbnail( $post_id, $featured_image ); |
|
| 690 | return $featured_image; |
|
| 691 | } |
|
| 692 | ||
| 693 | $featured_image_id = $this->handle_media_sideload( $featured_image, $post_id ); |
|
| 694 | ||
| 695 | if ( empty( $featured_image_id ) || ! is_int( $featured_image_id ) ) |
|
| 696 | return false; |
|
| 697 | ||
| 698 | set_post_thumbnail( $post_id, $featured_image_id ); |
|
| 699 | return $featured_image_id; |
|
| 700 | } |
|
| 701 | ||
| 702 | protected function parse_and_set_author( $author = null, $post_type = 'post' ) { |
|
| 703 | if ( empty( $author ) || ! post_type_supports( $post_type, 'author' ) ) |
|