LLMS_Question_Choice::__construct( int $question_id, array|string $data_or_id = array() )

Constructor


Parameters Parameters

$question_id

(int) (Required) WP Post ID of the choice's parent LLMS_Question

$data_or_id

(array|string) (Optional) array of choice data or the choice ID string

Default value: array()


Top ↑

Source Source

File: includes/models/model.llms.question.choice.php

	public function __construct( $question_id, $data_or_id = array() ) {

		// Ensure the question is valid.
		if ( $this->set_question( $question_id ) ) {

			// If an ID is passed in, load the question data from post meta.
			if ( ! is_array( $data_or_id ) ) {
				$data_or_id = str_replace( $this->prefix, '', $data_or_id );
				$data_or_id = get_post_meta( $this->question_id, $this->prefix . $data_or_id, true );
			}

			// Hydrate with postmeta data or array of data passed in.
			if ( is_array( $data_or_id ) && isset( $data_or_id['id'] ) ) {
				$this->hydrate( $data_or_id );
			}
		}

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.16.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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