public function add_settings_metabox($post)
    {
        $checked = AceCourseExercise::is_exercise($post->ID) ? 'checked="checked" ' : '';
        if ($post->post_type == 'page') {
            $label = __('Only show the user\'s own comments on this page', ACE_COURSE_TEXT_DOMAIN);
        } else {
            // 'post'
            $label = __('Treat comments as answers to an <strong>Ace Course exercise</strong>; only show the user\'s own comments', ACE_COURSE_TEXT_DOMAIN);
        }
        $exercise_id = AceCourseExercise::TAG_EXERCISE;
        $nonce_id = AceCourseCore::TAG_NONCE;
        $nonce = AceCourseCore::get_nonce();
        echo <<<EOT2
<div>
    <label for="{$exercise_id}"><input type="checkbox" id="{$exercise_id}" name="{$exercise_id}" value="1" {$checked} />{$label}</label>
    <input type="hidden" name="{$nonce_id}" value="{$nonce}" />
</div>
EOT2;
    }
Пример #2
0
 public function count_filtered_comments($count)
 {
     global $post;
     if ($count > 0 && AceCourseExercise::is_exercise($post->ID)) {
         $comments = get_comments(array('post_id' => $post->ID));
         $filteredCommets = $this->filter_comments($comments);
         $count = count($filteredCommets);
     }
     return $count;
 }