LLMS_Question::get_quizzes()
Retrieve quizzes this quiz is assigned to
Return Return
(array) Array of WP_Post IDs (quiz post types).
Source Source
File: includes/models/model.llms.question.php
* @since 3.12.0
*
* @return array Array of WP_Post IDs (quiz post types).
*/
public function get_quizzes() {
$id = absint( $this->get( 'id' ) );
$len = strlen( strval( $id ) );
$str_like = '%' . sprintf( 's:2:"id";s:%1$d:"%2$s";', $len, $id ) . '%';
$int_like = '%' . sprintf( 's:2:"id";i:%1$s;', $id ) . '%';
global $wpdb;
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$query = $wpdb->get_col( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
"SELECT post_id
FROM {$wpdb->postmeta}
WHERE meta_key = '_llms_questions'
AND (
meta_value LIKE '{$str_like}'
OR meta_value LIKE '{$int_like}'
);"
);
// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.12.0 | Introduced. |