| @@ 697-715 (lines=19) @@ | ||
| 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' ) ) |
|
| 699 | return get_current_user_id(); |
|
| 700 | ||
| 701 | $author = (string) $author; |
|
| 702 | if ( ctype_digit( $author ) ) { |
|
| 703 | $_user = get_user_by( 'id', $author ); |
|
| 704 | if ( ! $_user || is_wp_error( $_user ) ) |
|
| 705 | return new WP_Error( 'invalid_author', 'Invalid author provided' ); |
|
| 706 | ||
| 707 | return $_user->ID; |
|
| 708 | } |
|
| 709 | ||
| 710 | $_user = get_user_by( 'login', $author ); |
|
| 711 | if ( ! $_user || is_wp_error( $_user ) ) |
|
| 712 | return new WP_Error( 'invalid_author', 'Invalid author provided' ); |
|
| 713 | ||
| 714 | return $_user->ID; |
|
| 715 | } |
|
| 716 | } |
|
| 717 | ||
| @@ 708-726 (lines=19) @@ | ||
| 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' ) ) |
|
| 710 | return get_current_user_id(); |
|
| 711 | ||
| 712 | $author = (string) $author; |
|
| 713 | if ( ctype_digit( $author ) ) { |
|
| 714 | $_user = get_user_by( 'id', $author ); |
|
| 715 | if ( ! $_user || is_wp_error( $_user ) ) |
|
| 716 | return new WP_Error( 'invalid_author', 'Invalid author provided' ); |
|
| 717 | ||
| 718 | return $_user->ID; |
|
| 719 | } |
|
| 720 | ||
| 721 | $_user = get_user_by( 'login', $author ); |
|
| 722 | if ( ! $_user || is_wp_error( $_user ) ) |
|
| 723 | return new WP_Error( 'invalid_author', 'Invalid author provided' ); |
|
| 724 | ||
| 725 | return $_user->ID; |
|
| 726 | } |
|
| 727 | } |
|
| 728 | ||