LLMS_Post_Model::clone_post()

Clones the Post if the post is cloneable


Description Description


Return Return

(mixed) WP_Error or WP Post ID of the clone (new) post


Top ↑

Source Source

File: includes/abstracts/abstract.llms.post.model.php

	public function clone_post() {

		// if post type doesnt support cloning don't proceed
		if ( ! $this->is_cloneable() ) {
			return;
		}

		$this->allowed_post_tags_set();

		$generator = new LLMS_Generator( $this->toArray() );
		$generator->set_generator( 'LifterLMS/Single' . ucwords( $this->model_post_type ) . 'Cloner' );
		if ( ! $generator->is_error() ) {
			$generator->generate();
		}

		$this->allowed_post_tags_unset();

		$generated = $generator->get_generated_posts();
		if ( isset( $generated[ $this->db_post_type ] ) ) {
			return $generated[ $this->db_post_type ][0];
		}

		return new WP_Error( 'generator-error', __( 'An unknown error occurred during post cloning. Please try again.', 'lifterlms' ) );

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.





Permalink: