| @@ 889-910 (lines=22) @@ | ||
| 886 | return $this->get_post_by( 'ID', $post->ID, $args['context'] ); |
|
| 887 | } |
|
| 888 | ||
| 889 | private function parse_and_set_featured_image( $post_id, $delete_featured_image, $featured_image ) { |
|
| 890 | if ( $delete_featured_image ) { |
|
| 891 | delete_post_thumbnail( $post_id ); |
|
| 892 | return; |
|
| 893 | } |
|
| 894 | ||
| 895 | $featured_image = (string) $featured_image; |
|
| 896 | ||
| 897 | // if we got a post ID, we can just set it as the thumbnail |
|
| 898 | if ( ctype_digit( $featured_image ) && 'attachment' == get_post_type( $featured_image ) ) { |
|
| 899 | set_post_thumbnail( $post_id, $featured_image ); |
|
| 900 | return $featured_image; |
|
| 901 | } |
|
| 902 | ||
| 903 | $featured_image_id = $this->handle_media_sideload( $featured_image, $post_id, 'image' ); |
|
| 904 | ||
| 905 | if ( empty( $featured_image_id ) || ! is_int( $featured_image_id ) ) |
|
| 906 | return false; |
|
| 907 | ||
| 908 | set_post_thumbnail( $post_id, $featured_image_id ); |
|
| 909 | return $featured_image_id; |
|
| 910 | } |
|
| 911 | ||
| 912 | private function parse_and_set_author( $author = null, $post_type = 'post' ) { |
|
| 913 | if ( empty( $author ) || ! post_type_supports( $post_type, 'author' ) ) |
|
| @@ 957-978 (lines=22) @@ | ||
| 954 | return $this->get_post_by( 'ID', $post->ID, $args['context'] ); |
|
| 955 | } |
|
| 956 | ||
| 957 | protected function parse_and_set_featured_image( $post_id, $delete_featured_image, $featured_image ) { |
|
| 958 | if ( $delete_featured_image ) { |
|
| 959 | delete_post_thumbnail( $post_id ); |
|
| 960 | return; |
|
| 961 | } |
|
| 962 | ||
| 963 | $featured_image = (string) $featured_image; |
|
| 964 | ||
| 965 | // if we got a post ID, we can just set it as the thumbnail |
|
| 966 | if ( ctype_digit( $featured_image ) && 'attachment' == get_post_type( $featured_image ) ) { |
|
| 967 | set_post_thumbnail( $post_id, $featured_image ); |
|
| 968 | return $featured_image; |
|
| 969 | } |
|
| 970 | ||
| 971 | $featured_image_id = $this->handle_media_sideload( $featured_image, $post_id, 'image' ); |
|
| 972 | ||
| 973 | if ( empty( $featured_image_id ) || ! is_int( $featured_image_id ) ) |
|
| 974 | return false; |
|
| 975 | ||
| 976 | set_post_thumbnail( $post_id, $featured_image_id ); |
|
| 977 | return $featured_image_id; |
|
| 978 | } |
|
| 979 | ||
| 980 | protected function parse_and_set_author( $author = null, $post_type = 'post' ) { |
|
| 981 | if ( empty( $author ) || ! post_type_supports( $post_type, 'author' ) ) |
|