public static function course_unit_page_title($atts) { extract(shortcode_atts(array('unit_id' => in_the_loop() ? get_the_ID() : '', 'title_tag' => '', 'show_unit_title' => 'no'), $atts, 'course_unit_page_title')); $unit_id = (int) $unit_id; $title_tag = sanitize_text_field($title_tag); $show_unit_title = sanitize_text_field($show_unit_title); global $wp; $paged = isset($wp->query_vars['paged']) ? absint($wp->query_vars['paged']) : 1; $page_name = Unit::page_name($unit_id, (int) $paged); $unit_name = get_post_field('post_title', $unit_id); $show_title_array = get_post_meta($unit_id, 'show_page_title', true); $show_title = false; if (isset($show_title_array[$paged - 1]) && 'yes' == $show_title_array[$paged - 1]) { $show_title = true; } if (!empty($page_name) && $show_title) { if ('yes' === strtolower($show_unit_title)) { $page_name = $unit_name . ': ' . $page_name; } $content = !empty($title_tag) ? '<' . $title_tag . ' class="unit-archive-single-title course-unit-page-title course-unit-page-title-' . $unit_id . '">' : ''; $content .= $page_name; $content .= !empty($title_tag) ? '</' . $title_tag . '>' : ''; return $content; } else { return ''; } }