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