| @@ 691-708 (lines=18) @@ | ||
| 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' ) ) |
|
| 693 | return get_current_user_id(); |
|
| 694 | ||
| 695 | if ( ctype_digit( $author ) ) { |
|
| 696 | $_user = get_user_by( 'id', $author ); |
|
| 697 | if ( ! $_user || is_wp_error( $_user ) ) |
|
| 698 | return new WP_Error( 'invalid_author', 'Invalid author provided' ); |
|
| 699 | ||
| 700 | return $_user->ID; |
|
| 701 | } |
|
| 702 | ||
| 703 | $_user = get_user_by( 'login', $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 | ||
| @@ 702-719 (lines=18) @@ | ||
| 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' ) ) |
|
| 704 | return get_current_user_id(); |
|
| 705 | ||
| 706 | if ( ctype_digit( $author ) ) { |
|
| 707 | $_user = get_user_by( 'id', $author ); |
|
| 708 | if ( ! $_user || is_wp_error( $_user ) ) |
|
| 709 | return new WP_Error( 'invalid_author', 'Invalid author provided' ); |
|
| 710 | ||
| 711 | return $_user->ID; |
|
| 712 | } |
|
| 713 | ||
| 714 | $_user = get_user_by( 'login', $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 | ||