tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'header-menu' => esc_html__( 'Header Menu', 'easydita_knowledge_portal' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
) );
/*
* Enable support for Post Formats.
* See https://developer.wordpress.org/themes/functionality/post-formats/
*/
add_theme_support( 'post-formats', array(
'aside',
'image',
'video',
'quote',
'link',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'easydita_knowledge_portal_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
}
endif; // easydita_knowledge_portal_setup
add_action( 'after_setup_theme', 'easydita_knowledge_portal_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function easydita_knowledge_portal_content_width() {
$GLOBALS['content_width'] = apply_filters( 'easydita_knowledge_portal_content_width', 640 );
}
add_action( 'after_setup_theme', 'easydita_knowledge_portal_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function easydita_knowledge_portal_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'easydita_knowledge_portal' ),
'id' => 'sidebar-1',
'description' => '',
'before_widget' => '
',
'before_title' => '
',
'after_title' => '
',
) );
}
add_action( 'widgets_init', 'easydita_knowledge_portal_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function easydita_knowledge_portal_scripts() {
wp_enqueue_style( 'easydita-knowledge-portal-style', get_stylesheet_uri() );
wp_enqueue_script( 'easydita-knowledge-portal-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true );
wp_enqueue_script( 'easydita-knowledge-portal-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'easydita_knowledge_portal_scripts' );
/**
* Allow changing of default version number on style.css to circumvent caching
* This should always be commented out in production
*/
function easydita_knowledge_portal_change_style_version_num($styles) {
$styles -> default_version = "123";
}
//add_action("wp_default_styles", "easydita_knowledge_portal_change_style_version_num");
/**
* Is Versioning Enabled?
**/
if (!function_exists('easydita_knowledge_portal_is_versioning_enabled')) {
function easydita_knowledge_portal_is_versioning_enabled() {
return get_theme_mod('versioning_enabled','no') == 'yes';
}
}
/***
* Hierarchy Functions
***/
// Walk the hierarchy and return an array of IDs
if (!function_exists('easydita_knowledge_portal_get_hierarchy')) {
function easydita_knowledge_portal_get_hierarchy() {
global $post;
$hierarchy = array();
if($post->ID) {
$hierarchy[] = $post->ID;
$parent_id = $post->post_parent;
while ($parent_id) {
$hierarchy[] = $parent_id;
$page = get_page($parent_id);
$parent_id = $page->post_parent;
}
return array_reverse($hierarchy);
}
return array(0);
}
}
if (!function_exists('easydita_knowledge_portal_get_hierarchy_of')) {
function easydita_knowledge_portal_get_hierarchy_of($post) {
$hierarchy = array();
if($post->ID) {
$hierarchy[] = $post->ID;
$parent_id = $post->post_parent;
while ($parent_id) {
$hierarchy[] = $parent_id;
$page = get_page($parent_id);
$parent_id = $page->post_parent;
}
return array_reverse($hierarchy);
}
return array(0);
}
}
if (!function_exists('easydita_knowledge_portal_get_root_map_id')) {
function easydita_knowledge_portal_get_root_map_id() {
/** get the title for the root map this is a member of **/
$hierarchy = easydita_knowledge_portal_get_hierarchy();
if (easydita_knowledge_portal_is_versioning_enabled()) {
return $hierarchy[1];
} else {
return $hierarchy[0];
}
}
}
/**
* Get version id
**/
if (!function_exists('easydita_knowledge_portal_get_version_id')) {
function easydita_knowledge_portal_get_version_id() {
if (!easydita_knowledge_portal_is_versioning_enabled()) {
return 0;
} else if (isset($_GET['version'])) {
$versionId = $_GET['version'];
} else if (is_front_page()) {
$versionId = get_pages("parent=0&post_type=page&sort_column=menu_order")[0]->ID;
} else {
$hierarchy = easydita_knowledge_portal_get_hierarchy();
$versionId = $hierarchy[0];
}
return $versionId;
}
}
if (!function_exists('easydita_knowledge_portal_get_version_id_of')) {
function easydita_knowledge_portal_get_version_id_of($post) {
if (!easydita_knowledge_portal_is_versioning_enabled()) {
return 0;
} else {
$hierarchy = easydita_knowledge_portal_get_hierarchy_of($post);
$versionId = $hierarchy[0];
return $versionId;
}
}
}
/***
* Get all subsections (for Tutorials)
***/
if (!function_exists('easydita_knowledge_portal_get_subsections')) {
function easydita_knowledge_portal_get_subsections() {
global $post;
$content = $post->post_content;
preg_match_all('#
]*class="[^"]*topic-title [^"]*"[^>]*>((.*?
)|(.))*?#', $content, $matches);
return $matches[0];
}
}
/**
* get the short description
**/
if (!function_exists('easydita_knowledge_portal_get_the_shortdesc')) {
function easydita_knowledge_portal_get_the_shortdesc() {
global $post;
if ($post->post_content != '') {
preg_match('#