protected function cloneMetadata() {
		$metadata_post_id = ( new \Pressbooks\Metadata )->getMetaPostId();

		if ( ! $metadata_post_id ) {
			return false;
		}

		$book_information = schema_to_book_information( $this->sourceBookMetadata );

		// Cover image
		if ( ! \Pressbooks\Image\is_default_cover( $book_information['pb_cover_image'] ) ) {
			$new_cover_id = $this->downloads->fetchAndSaveUniqueImage( $book_information['pb_cover_image'] );
			if ( $new_cover_id > 0 ) {
				$this->clonedItems['media'][] = $new_cover_id; // Counter
				$book_information['pb_cover_image'] = wp_get_attachment_url( $new_cover_id );
			} else {
				$book_information['pb_cover_image'] = default_cover_url();
			}
		} else {
			$book_information['pb_cover_image'] = default_cover_url();
		}

		// Everything else
		$book_information['pb_is_based_on'] = $this->sourceBookUrl;
		$metadata_array_values = [ 'pb_keywords_tags', 'pb_bisac_subject', 'pb_additional_subjects' ];
		foreach ( $book_information as $key => $value ) {
			if ( $this->contributors->isValid( $key ) ) {
				$values = oxford_comma_explode( $value );
				foreach ( $values as $v ) {
					$this->contributors->insert( $v, $metadata_post_id, $key );
				}
			} elseif ( in_array( $key, $metadata_array_values, true ) ) {
				$values = explode( ', ', $value );
				foreach ( $values as $v ) {
					add_post_meta( $metadata_post_id, $key, $v );
				}
			} elseif ( $key === 'pb_title' ) {
				update_post_meta( $metadata_post_id, $key, $this->targetBookTitle );
			} else {
				update_post_meta( $metadata_post_id, $key, $value );
				if ( $key === 'pb_book_license' ) {
					wp_set_object_terms( $metadata_post_id, $value, \Pressbooks\Licensing::TAXONOMY ); // Link
				}
			}
		}

		// Remove the current user from the author field in Book Info
		$user_data = get_userdata( get_current_user_id() );
		$this->contributors->unlink( $user_data->user_nicename, $metadata_post_id );

		return $metadata_post_id;
	}
protected function cloneMetadata() {
		$metadata_post_id = ( new \Pressbooks\Metadata )->getMetaPostId();

		if ( ! $metadata_post_id ) {
			return false;
		}

		$book_information = schema_to_book_information( $this->sourceBookMetadata );

		// Cover image
		if ( ! \Pressbooks\Image\is_default_cover( $book_information['pb_cover_image'] ) ) {
			$new_cover_id = $this->downloads->fetchAndSaveUniqueImage( $book_information['pb_cover_image'] );
			if ( $new_cover_id > 0 ) {
				$this->clonedItems['media'][] = $new_cover_id; // Counter
				$book_information['pb_cover_image'] = wp_get_attachment_url( $new_cover_id );
			} else {
				$book_information['pb_cover_image'] = default_cover_url();
			}
		} else {
			$book_information['pb_cover_image'] = default_cover_url();
		}

		// Everything else
		$book_information['pb_is_based_on'] = $this->sourceBookUrl;
		$metadata_array_values = [ 'pb_keywords_tags', 'pb_bisac_subject', 'pb_additional_subjects' ];
		foreach ( $book_information as $key => $value ) {
			if ( $this->contributors->isValid( $key ) ) {
				$values = oxford_comma_explode( $value );
				foreach ( $values as $v ) {
					$this->contributors->insert( $v, $metadata_post_id, $key );
				}
			} elseif ( in_array( $key, $metadata_array_values, true ) ) {
				$values = explode( ', ', $value );
				foreach ( $values as $v ) {
					add_post_meta( $metadata_post_id, $key, $v );
				}
			} elseif ( $key === 'pb_title' ) {
				update_post_meta( $metadata_post_id, $key, $this->targetBookTitle );
			} else {
				update_post_meta( $metadata_post_id, $key, $value );
				if ( $key === 'pb_book_license' ) {
					wp_set_object_terms( $metadata_post_id, $value, \Pressbooks\Licensing::TAXONOMY ); // Link
				}
			}
		}

		// Remove the current user from the author field in Book Info
		$user_data = get_userdata( get_current_user_id() );
		$this->contributors->unlink( $user_data->user_nicename, $metadata_post_id );

		return $metadata_post_id;
	}
protected function cloneMetadata ( ) { $ metadata_post_id = ( new \ Pressbooks \ Metadata ) -> getMetaPostId ( ) ; if ( ! $ metadata_post_id ) { return false ; } $ book_information = schema_to_book_information ( $ this -> sourceBookMetadata ) ; // Cover image if ( ! \ Pressbooks \ Image \ is_default_cover ( $ book_information [ 'pb_cover_image' ] ) ) { $ new_cover_id = $ this -> downloads -> fetchAndSaveUniqueImage ( $ book_information [ 'pb_cover_image' ] ) ; if ( $ new_cover_id > 0 ) { $ this -> clonedItems [ 'media' ] [ ] = $ new_cover_id ; // Counter $ book_information [ 'pb_cover_image' ] = wp_get_attachment_url ( $ new_cover_id ) ; } else { $ book_information [ 'pb_cover_image' ] = default_cover_url ( ) ; } } else { $ book_information [ 'pb_cover_image' ] = default_cover_url ( ) ; } // Everything else $ book_information [ 'pb_is_based_on' ] = $ this -> sourceBookUrl ; $ metadata_array_values = [ 'pb_keywords_tags' , 'pb_bisac_subject' , 'pb_additional_subjects' ] ; foreach ( $ book_information as $ key => $ value ) { if ( $ this -> contributors -> isValid ( $ key ) ) { $ values = oxford_comma_explode ( $ value ) ; foreach ( $ values as $ v ) { $ this -> contributors -> insert ( $ v , $ metadata_post_id , $ key ) ; } } elseif ( in_array ( $ key , $ metadata_array_values , true ) ) { $ values = explode ( ', ' , $ value ) ; foreach ( $ values as $ v ) { add_post_meta ( $ metadata_post_id , $ key , $ v ) ; } } elseif ( $ key === 'pb_title' ) { update_post_meta ( $ metadata_post_id , $ key , $ this -> targetBookTitle ) ; } else { update_post_meta ( $ metadata_post_id , $ key , $ value ) ; if ( $ key === 'pb_book_license' ) { wp_set_object_terms ( $ metadata_post_id , $ value , \ Pressbooks \ Licensing :: TAXONOMY ) ; // Link } } } // Remove the current user from the author field in Book Info $ user_data = get_userdata ( get_current_user_id ( ) ) ; $ this -> contributors -> unlink ( $ user_data -> user_nicename , $ metadata_post_id ) ; return $ metadata_post_id ; }
Clone book information to the target book.

@since 4.1.0

@return bool | int False if the creation failed; the ID of the new book's book information post if it succeeded.
Clone book information to the target book .