classes/PodsAPI.php
public function duplicate_pod( $params, $strict = false ) {

		if ( ! is_object( $params ) && ! is_array( $params ) ) {
			if ( is_numeric( $params ) ) {
				$params = array( 'id' => $params );
			} else {
				$params = array( 'name' => $params );
			}

			$params = (object) pods_sanitize( $params );
		} else {
			$params = (object) pods_sanitize( $params );
		}

		$params->table_info = false;

		$pod = $this->load_pod( $params, $strict );

		if ( empty( $pod ) ) {
			if ( false !== $strict ) {
				return pods_error( __( 'Pod not found', 'pods' ), $this );
			}

			return false;
		} elseif ( in_array( $pod['type'], array( 'media', 'user', 'comment' ) ) ) {
			if ( false !== $strict ) {
				return pods_error( __( 'Pod not allowed to be duplicated', 'pods' ), $this );
			}

			return false;
		} elseif ( in_array( $pod['type'], array( 'post_type', 'taxonomy' ) ) && 0 < strlen( $pod['object'] ) ) {
			$pod['object'] = '';
		}

		unset( $pod['id'] );

		if ( isset( $params->new_name ) ) {
			$pod['name'] = $params->new_name;
		}

		$try = 1;

		$check_name = $pod['name'];
		$new_label  = $pod['label'];

		while ( $this->load_pod( array( 'name' => $check_name, 'table_info' => false ), false ) ) {
			$try ++;

			$check_name = $pod['name'] . $try;
			$new_label  = $pod['label'] . $try;
		}

		$pod['name']  = $check_name;
		$pod['label'] = $new_label;

		foreach ( $pod['fields'] as $field => $field_data ) {
			unset( $pod['fields'][ $field ]['id'] );
		}

		return $this->save_pod( $pod );
	}
public function duplicate_pod( $params, $strict = false ) {

		if ( ! is_object( $params ) && ! is_array( $params ) ) {
			if ( is_numeric( $params ) ) {
				$params = array( 'id' => $params );
			} else {
				$params = array( 'name' => $params );
			}

			$params = (object) pods_sanitize( $params );
		} else {
			$params = (object) pods_sanitize( $params );
		}

		$params->table_info = false;

		$pod = $this->load_pod( $params, $strict );

		if ( empty( $pod ) ) {
			if ( false !== $strict ) {
				return pods_error( __( 'Pod not found', 'pods' ), $this );
			}

			return false;
		} elseif ( in_array( $pod['type'], array( 'media', 'user', 'comment' ) ) ) {
			if ( false !== $strict ) {
				return pods_error( __( 'Pod not allowed to be duplicated', 'pods' ), $this );
			}

			return false;
		} elseif ( in_array( $pod['type'], array( 'post_type', 'taxonomy' ) ) && 0 < strlen( $pod['object'] ) ) {
			$pod['object'] = '';
		}

		unset( $pod['id'] );

		if ( isset( $params->new_name ) ) {
			$pod['name'] = $params->new_name;
		}

		$try = 1;

		$check_name = $pod['name'];
		$new_label  = $pod['label'];

		while ( $this->load_pod( array( 'name' => $check_name, 'table_info' => false ), false ) ) {
			$try ++;

			$check_name = $pod['name'] . $try;
			$new_label  = $pod['label'] . $try;
		}

		$pod['name']  = $check_name;
		$pod['label'] = $new_label;

		foreach ( $pod['fields'] as $field => $field_data ) {
			unset( $pod['fields'][ $field ]['id'] );
		}

		return $this->save_pod( $pod );
	}
public function duplicate_pod ( $ params , $ strict = false ) { if ( ! is_object ( $ params ) && ! is_array ( $ params ) ) { if ( is_numeric ( $ params ) ) { $ params = array ( 'id' => $ params ) ; } else { $ params = array ( 'name' => $ params ) ; } $ params = ( object ) pods_sanitize ( $ params ) ; } else { $ params = ( object ) pods_sanitize ( $ params ) ; } $ params -> table_info = false ; $ pod = $ this -> load_pod ( $ params , $ strict ) ; if ( empty ( $ pod ) ) { if ( false !== $ strict ) { return pods_error ( __ ( 'Pod not found' , 'pods' ) , $ this ) ; } return false ; } elseif ( in_array ( $ pod [ 'type' ] , array ( 'media' , 'user' , 'comment' ) ) ) { if ( false !== $ strict ) { return pods_error ( __ ( 'Pod not allowed to be duplicated' , 'pods' ) , $ this ) ; } return false ; } elseif ( in_array ( $ pod [ 'type' ] , array ( 'post_type' , 'taxonomy' ) ) && 0 < strlen ( $ pod [ 'object' ] ) ) { $ pod [ 'object' ] = '' ; } unset ( $ pod [ 'id' ] ) ; if ( isset ( $ params -> new_name ) ) { $ pod [ 'name' ] = $ params -> new_name ; } $ try = 1 ; $ check_name = $ pod [ 'name' ] ; $ new_label = $ pod [ 'label' ] ; while ( $ this -> load_pod ( array ( 'name' => $ check_name , 'table_info' => false ) , false ) ) { $ try ++ ; $ check_name = $ pod [ 'name' ] . $ try ; $ new_label = $ pod [ 'label' ] . $ try ; } $ pod [ 'name' ] = $ check_name ; $ pod [ 'label' ] = $ new_label ; foreach ( $ pod [ 'fields' ] as $ field => $ field_data ) { unset ( $ pod [ 'fields' ] [ $ field ] [ 'id' ] ) ; } return $ this -> save_pod ( $ pod ) ; }
Duplicate a Pod

$params['id'] int The Pod ID
$params['name'] string The Pod name
$params['new_name'] string The new Pod name

@param array $params An associative array of parameters
@param bool  $strict (optional) Makes sure a pod exists, if it doesn't throws an error

@return int New Pod ID
@since 2.3.0
Duplicate a Pod