Edit File: template-functions.php
<?php /** * Functions which enhance the theme by hooking into WordPress * * @package orun */ /** * Adds custom classes to the array of body classes. * * @param array $classes Classes for the body element. * @return array */ function orun_body_classes( $classes ) { // Adds a class of hfeed to non-singular pages. if ( ! is_singular() ) { $classes[] = 'hfeed'; } // Adds a class of no-sidebar when there is no sidebar present. if ( ! is_active_sidebar( 'sidebar-1' ) ) { $classes[] = 'no-sidebar'; } return $classes; } add_filter( 'body_class', 'orun_body_classes' ); /** * Add a pingback url auto-discovery header for single posts, pages, or attachments. */ function orun_pingback_header() { if ( is_singular() && pings_open() ) { printf( '<link rel="pingback" href="%s">', esc_url( get_bloginfo( 'pingback_url' ) ) ); } } add_action( 'wp_head', 'orun_pingback_header' ); /** * After Setup Theme */ function update_post_views_data() { $args = array( 'posts_per_page' => -1, 'post_type' => 'post', 'suppress_filters' => true, ); $posts_array = get_posts($args); foreach ( $posts_array as $post_array ) { if ( empty(get_post_meta( $post_array->ID, 'post_views_count', true )) ) { update_post_meta($post_array->ID, 'post_views_count', '0'); } $metabox_options = get_post_meta( $post_array->ID, 'orun_post_opt', true ); if ( empty($metabox_options['orun-meta-opt-post-layout']) ) { $metabox_options = 'default'; } } } add_action('after_setup_theme', 'update_post_views_data'); /* Login Custom Logo */ function orun_custom_login_logo() { echo '<style type="text/css"> body.login div#login h1 a { background-image: url('.get_template_directory_uri().'/assets/img/logo.png); } .login h1 a { background-size: 270px; width: 270px; height: 60px !important; } </style>'; } add_action('login_head', 'orun_custom_login_logo'); /* Remove Page from Search Results */ function remove_pages_from_search_results() { global $wp_post_types; $wp_post_types['page']->exclude_from_search = true; } add_action('init', 'remove_pages_from_search_results'); /* Remove Customizer Sections */ function remove_customizer_sections( $wp_customize ) { $wp_customize->remove_section( 'colors' ); // Colors $wp_customize->remove_section( 'custom_logo' ); // Colors $wp_customize->remove_section( 'header_image' ); // Header imagen $wp_customize->remove_section( 'background_image' ); // Background image $wp_customize->remove_section( 'themes' ); // Themes $wp_customize->remove_control( 'page_for_posts' ); // Themes } add_action('customize_register', 'remove_customizer_sections'); /* Editor CSS */ function editor_styles() { add_editor_style( 'assets/css/editor.css' ); } add_action('after_setup_theme', 'editor_styles'); /* Remove "Archives:" Tags */ function remove_archive_tags( $title ) { if ( is_category() ) { $title = single_cat_title( '', false ); } elseif ( is_tag() ) { $title = single_tag_title( '', false ); } elseif ( is_author() ) { $title = '<span class="vcard">' . get_the_author() . '</span>'; } elseif ( is_post_type_archive() ) { $title = post_type_archive_title( '', false ); } elseif ( is_tax() ) { $title = single_term_title( '', false ); } return $title; } add_filter( 'get_the_archive_title', 'remove_archive_tags' ); /* Author Social Icons */ function orun_author_social_icons( $author_social ) { $author_social['facebook'] = __('Facebook', 'orun'); $author_social['twitter'] = __('Twitter', 'orun'); $author_social['instagram'] = __('Instagram', 'orun'); $author_social['linkedin'] = __('LinkedIn', 'orun'); $author_social['youtube'] = __('YouTube', 'orun'); $author_social['github'] = __('GitHub', 'orun'); $author_social['medium'] = __('Medium', 'orun'); $author_social['pinterest'] = __('Pinterest', 'orun'); $author_social['tumblr'] = __('Tumblr', 'orun'); $author_social['tiktok'] = __('TikTok', 'orun'); return $author_social; } add_filter('user_contactmethods', 'orun_author_social_icons'); // Remove Widgets function orun_remove_widgets() { unregister_widget('WP_Widget_Calendar'); unregister_widget('WP_Widget_RSS'); } add_action('widgets_init', 'orun_remove_widgets', 1); // Archive Posts Per Page Count function orun_posts_per_page($query) { global $wp_the_query; $options = get_option('orun_opt'); if ( ( ! is_admin() ) && ( $query === $wp_the_query ) && ( $query->is_search() ) ) { $query->set( 'posts_per_page', $options['orun-opt-archive-posts-per-page'] ); } elseif ( ( ! is_admin() ) && ( $query === $wp_the_query ) && ( $query->is_archive() ) ) { $query->set( 'posts_per_page', $options['orun-opt-archive-posts-per-page'] ); } return $query; } add_action( 'pre_get_posts', 'orun_posts_per_page' ); // Theme Opt Custom CSS for Demos function orun_theme_opt_custom_css() { $options = get_option( 'orun_opt' ); $css = $options['orun-opt-custom-css']; echo '<style id="orun-opt-custom-css">'.$css.'</style>'; } add_action( 'wp_head', 'orun_theme_opt_custom_css' ); // Publish Post Views Debug function publish_post_views_debug($post_ID) { global $wpdb; $view = get_post_meta($post_ID, 'post_views_count', true); if ($view == '') { if(!wp_is_post_revision($post_ID)) { update_post_meta($post_ID, 'post_views_count', '1'); } } } add_action('publish_post', 'publish_post_views_debug'); /** * orun Single Post Layout Hooks */ // orun Single Header function orun_single_header() { orun_single_breadcrumb(); post_breadcrumb_schema(); orun_single_category(); orun_single_heading(); orun_single_meta(); } add_action( 'orun/single_header', 'orun_single_header' ); // orun Single Thumbnail function orun_single_thumbnail() { orun_post_thumbnail(); } add_action( 'orun/single_thumbnail', 'orun_single_thumbnail' ); // orun Entry Content function orun_entry_content() { the_content(); orun_post_nav_links(); } add_action( 'orun/entry_content', 'orun_entry_content' ); // orun Entry Footer add_action( 'orun/entry_footer', 'orun_entry_footer' ); // orun Single Related Posts & Comments function orun_after_entry_footer() { orun_author_box(); orun_related_posts(); orun_single_comments(); } add_action( 'orun/after_entry_footer', 'orun_after_entry_footer' ); // Permanently Dark Mode // if permanently dark mode options is enabled add body class function permanently_dark_mode_body_class( $classes ) { $options = get_option( 'orun_opt' ); if ( $options['orun-opt-permanently-dark-mode'] == '1' ) { $classes[] = 'dark-theme'; } return $classes; } add_filter( 'body_class', 'permanently_dark_mode_body_class' ); // On/Off Archive Pages function disable_archive_pages() { $options = get_option( 'orun_opt' ); if ( $options['orun-opt-archive-pages-on-off'] == '1' && is_month() ) { wp_redirect( home_url() ); exit; } } add_action('template_redirect', 'disable_archive_pages');