/**
 * Callback after creating the meta box
 * @param (object) the post object
 * @return (void)
 */
function han_dwa_qa_asked_questions_meta_box_callback($post)
{
    global $hanDwaQaAskedQuestionsActionId;
    global $hanDwaQaAskedQuestionsNonceId;
    // Set a nonce
    wp_nonce_field($hanDwaQaAskedQuestionsActionId, $hanDwaQaAskedQuestionsNonceId);
    // Prepare the content
    $questions = han_dwa_qa_get_questions_for_qa($post->ID);
    // Output
    include_once 'qa_asked_questions_html.php';
}
/**
 * Add content to the created admin columns for Q&A
 * @param (string) the column title
 * @param (int) the post ID
 * @return (void / output buffer)
 */
function han_dwa_qa_admin_columns_content($column, $postId)
{
    if ($column === 'question-counter') {
        echo count(han_dwa_qa_get_questions_for_qa($postId));
    }
}
示例#3
0
/**
 * Check if an email address hasn't already submitted a question to a specific Q&A
 * @param (int) the Q&A ID
 * @param (string) the email address
 * @return (bool) true when not submitted
 */
function han_dwa_qa_is_email_unique_for_qa($qaId, $email)
{
    $isValid = true;
    foreach (han_dwa_qa_get_questions_for_qa($qaId) as $question) {
        if ($question->getEmail() === $email) {
            $isValid = false;
            break;
        }
    }
    return $isValid;
}
<?php

$questions = han_dwa_qa_get_questions_for_qa(get_the_ID());
?>
<hr/>
<div class="han_dwa_qa_asked_questions">
    <h3><?php 
_e('Posted items', 'han-dwa-qa');
?>
</h3>

    <?php 
if (count($questions)) {
    ?>
        <div class="han_dwa_qa_asked_questions_list">
            <?php 
    foreach ($questions as $question) {
        ?>
                <?php 
        require 'asked_question.php';
        ?>
            <?php 
    }
    ?>
        </div>
    <?php 
} else {
    ?>
        <p><em><?php 
    _e('No items have been posted', 'han-dwa-qa');
    ?>