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()
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 ); } } }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.16.0 | Introduced. |