/** * Theme template tag to get link * * @param integer $post_id The post ID to check * * @return sting $link The permalink with our "all" included. */ function svo_link($post_id = 0) { // If we have not activated it, return the original canonical. if (false === ($check = RKV_SVO_Helper::check_post_active($post_id))) { return get_permalink($post_id); } // Return the updated link. return RKV_SVO_Helper::all_permalink($post_id); }
/** * Add a "view as single page" link above the content. * * @param mixed $content The original content being passed. * * @return mixed $content The updated content, without breaks. */ public function show_view_link($content) { // Bail if we aren't on a supported type. if (false === ($types = RKV_SVO_Helper::check_post_types())) { return $content; } // Check for the enabled filter. if (false === ($show = RKV_SVO_Helper::check_view_all())) { return $content; } // Check the content for the `nextpage` tag. if (false === ($tag = RKV_SVO_Helper::check_post_content(get_the_ID()))) { return $content; } // Call the $wp_query global. global $wp_query; // If we are already on the "all" page, or if we have not activated it, return the original content. if (isset($wp_query->query['all']) || false === ($check = RKV_SVO_Helper::check_post_active(get_the_ID()))) { return $content; } // Call my global $post object. $link = RKV_SVO_Helper::all_permalink($wp_query->post->ID); // Build the text portion $text = '<p class="svo-view-all-link"><a href="' . esc_url($link) . '">' . esc_html__('View as single page', 'single-view-option') . '</a></p>'; return apply_filters('svo_view_all_link_text', $text) . $content; }