/** * Clean the idea's comment count cache * * @package WP Idea Stream * @subpackage comments/functions * * @since 2.0.0 * * @param int $comment_id the comment ID * @param string $status its status * @uses wp_idea_stream_comments_get_comment() to get the comment object * @uses wp_idea_stream_get_post_type() to get the idea post type identifier * @uses wp_idea_stream_is_comments_disjoined() to check comments about ideas need to be separated from others * @uses wp_cache_delete() to clean the cached count */ function wp_idea_stream_comments_clean_count_cache($comment_id = 0, $status = '') { // Bail if no comment id or the status is delete if (empty($comment_id) || !empty($status) && 'delete' == $status) { return; } $comment = wp_idea_stream_comments_get_comment($comment_id); // Make sure the comment has been made on an idea post type if (empty($comment->comment_post_type) || wp_idea_stream_get_post_type() != $comment->comment_post_type) { return; } // Clean global idea comment count cache if needed. if (wp_idea_stream_is_comments_disjoined()) { wp_cache_delete("idea_comment_count_0", 'wp_idea_stream'); } // Clean user count cache if (!empty($comment->user_id)) { wp_cache_delete("idea_comment_count_{$comment->user_id}", 'wp_idea_stream'); } }
/** * Hooks to disjoin comments about ideas * & to filter the email notifications * * @package WP Idea Stream * @subpackage comments/classes * * @since 2.0.0 * * @uses wp_idea_stream_is_comments_disjoined() to check comments about ideas need to be separated from others */ private function hooks() { if (wp_idea_stream_is_comments_disjoined()) { add_action('pre_get_comments', array($this, 'maybe_idea_comments'), 10, 1); add_action('wp_idea_stream_init', array($this, 'cache_comments_count')); add_filter('wp_count_comments', array($this, 'adjust_comment_count'), 10, 1); add_filter('widget_comments_args', array($this, 'comments_widget_dummy_var'), 10, 1); add_filter('comments_clauses', array($this, 'maybe_alter_comments_query'), 10, 2); } // Make sure the comment notifications respect idea authors capability add_filter('comment_moderation_recipients', array($this, 'moderation_recipients'), 10, 2); add_filter('comment_notification_text', array($this, 'comment_notification'), 10, 2); add_filter('comment_moderation_text', array($this, 'comment_notification'), 10, 2); }
/** * Includes the needed admin files * * @package WP Idea Stream * @subpackage admin/admin * * @since 2.0.0 * * @uses wp_idea_stream_is_comments_disjoined() to check for comments disjoin setting * @uses wp_idea_stream_is_sticky_enabled() to check for sticky setting */ private function includes() { // By default, comments are disjoined from the other post types. if (wp_idea_stream_is_comments_disjoined()) { require $this->includes_dir . 'comments.php'; } // By default, ideas can be sticked to front post type archive page. if (wp_idea_stream_is_sticky_enabled()) { require $this->includes_dir . 'sticky.php'; } // Settings require $this->includes_dir . 'settings.php'; // About & credits screens require $this->includes_dir . 'thanks.php'; }
/** * Disjoin idea comments callback * * @package WP Idea Stream * @subpackage admin/settings * * @since 2.0.0 * * @uses checked() to add a checked attribute if needed * @uses wp_idea_stream_is_comments_disjoined() to get the active option * @return string HTML output */ function wp_idea_stream_disjoin_comments_setting_callback() { ?> <input name="_ideastream_disjoin_comments" id="_ideastream_disjoin_comments" type="checkbox" value="1" <?php checked(wp_idea_stream_is_comments_disjoined()); ?> /> <label for="_ideastream_disjoin_comments"><?php esc_html_e('Separate comments made on ideas from the other post types.', 'wp-idea-stream'); ?> </label> <?php }