/** * Display the contents of a specific achievement ID in an output buffer * and return to ensure that post/page contents are displayed first. * * @param array $attr * @param string $content Optional * @return string Contents of output buffer * @since Achievements (3.0) */ public function display_achievement($attr, $content = '') { // Sanity check required info if (!empty($content) || (empty($attr['id']) || !is_numeric($attr['id']))) { return $content; } $this->unset_globals(); // Set passed attribute to $achievement_id for clarity $achievement_id = achievements()->current_achievement_id = absint($attr['id']); // Bail if ID passed is not an achievement if (!dpa_is_achievement($achievement_id)) { return $content; } // If not in theme compat, reset necessary achievement_query attributes for achievements loop to function if (!dpa_is_theme_compat_active()) { achievements()->achievement_query->query_vars['post_type'] = dpa_get_achievement_post_type(); achievements()->achievement_query->in_the_loop = true; achievements()->achievement_query->post = get_post($achievement_id); } $this->start('dpa_single_achievement'); dpa_get_template_part('content-single-achievement'); return $this->end(); }
/** * Are we replacing the_content ? * * @since Achievevements (3.4) * @return bool */ function dpa_do_theme_compat() { $retval = !dpa_is_template_included() && in_the_loop() && dpa_is_theme_compat_active(); return apply_filters('dpa_do_theme_compat', (bool) $retval); }