public static function render_metrics($content, $context = null) { $metrics = self::get_metrics(array(), null); if (empty($context)) { if ('comment_text' === current_filter()) { $context_type = 'comments'; $context_id = get_comment_ID(); } else { $context_type = get_post_type(); $context_id = get_the_ID(); } $context = apply_filters('evaluate_get_context', array('type' => $context_type, 'id' => $context_id)); } $user_key = Evaluate_Voting::get_user_key(); foreach ($metrics as $key => $metric) { if (in_array($context['type'], $metric['options']['usage']) && in_array($metric['type'], array_keys(self::$metric_types))) { wp_enqueue_script('evaluate-metrics'); wp_enqueue_style('evaluate-metrics'); wp_enqueue_style('evaluate-icons'); ob_start(); ?> <span class="metric metric-<?php echo $metric['metric_id']; ?> metric-<?php echo $metric['type']; ?> " data-id="<?php echo $metric['metric_id']; ?> " data-context="<?php echo $context_id; ?> " data-nonce="<?php echo Evaluate_Voting::get_nonce($metric['metric_id'], $context_id); ?> "> <?php if (!empty($metric['options']['title'])) { ?> <strong class="metric-title"><?php echo $metric['options']['title']; ?> </strong> <?php } $metric_type = self::$metric_types[$metric['type']]; $score = $metric_type->get_score($metric['metric_id'], $context['id']); $user_vote = $metric_type->get_vote($metric, $context['id'], $user_key); $metric_type->render_display($metric, $score, $user_vote); ?> </span> <?php $content .= ob_get_clean(); } } return $content; }