| 1 |
<?php |
| 2 |
/** |
| 3 |
* Functions |
| 4 |
* |
| 5 |
* @package GamiPress\QSM\Functions |
| 6 |
* @since 1.0.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
// Exit if accessed directly |
| 10 |
if( !defined( 'ABSPATH' ) ) exit; |
| 11 |
|
| 12 |
/** |
| 13 |
* Get the quiz post ID |
| 14 |
* |
| 15 |
* @since 1.0.0 |
| 16 |
* |
| 17 |
* @param int $quiz_id |
| 18 |
* |
| 19 |
* @return int |
| 20 |
*/ |
| 21 |
function gamipress_qsm_get_quiz_post_id( $quiz_id ) { |
| 22 |
|
| 23 |
// False if no quiz ID provided |
| 24 |
if( !isset( $quiz_id ) ) { |
| 25 |
return false; |
| 26 |
} |
| 27 |
|
| 28 |
$post_id = get_posts( array( |
| 29 |
'posts_per_page' => 1, |
| 30 |
'post_type' => 'qsm_quiz', |
| 31 |
'post_status' => array( 'publish' ), |
| 32 |
'fields' => 'ids', |
| 33 |
'meta_query' => array( |
| 34 |
array( |
| 35 |
'key' => 'quiz_id', |
| 36 |
'value' => $quiz_id, |
| 37 |
'compare' => '=', |
| 38 |
), |
| 39 |
), |
| 40 |
) ); |
| 41 |
|
| 42 |
return $post_id; |
| 43 |
|
| 44 |
} |