File: /home/bristolfilton.co.uk/public_html/wp-content/themes/skt-pathway/functions.php
<?php
/**
* SKT Pathway functions and definitions
*
* @package SKT Pathway
*/
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! function_exists( 'skt_pathway_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which runs
* before the init hook. The init hook is too late for some features, such as indicating
* support post thumbnails.
*/
function skt_pathway_setup() {
if ( ! isset( $content_width ) )
$content_width = 640; /* pixels */
load_theme_textdomain( 'skt-pathway', get_template_directory() . '/languages' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'woocommerce' );
add_image_size('homepage-thumb',240,145,true);
add_theme_support( 'title-tag' );
add_theme_support( 'custom-logo', array(
'height' => 35,
'width' => 145,
'flex-height' => true,
) );
add_theme_support( 'custom-header', array( 'header-text' => false ) );
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'skt-pathway' ),
'footer' => __( 'Footer Menu', 'skt-pathway' ),
) );
add_theme_support( 'custom-background', array(
'default-color' => 'eae9e9'
) );
add_editor_style( 'editor-style.css' );
}
endif; // skt_pathway_setup
add_action( 'after_setup_theme', 'skt_pathway_setup' );
function skt_pathway_widgets_init() {
register_sidebar( array(
'name' => __( 'Blog Sidebar', 'skt-pathway' ),
'description' => __( 'Appears on blog page sidebar', 'skt-pathway' ),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Footer Widget 1', 'skt-pathway' ),
'description' => __( 'Appears on Footer', 'skt-pathway' ),
'id' => 'footer-1',
'before_widget' => '<aside class="widget">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Footer Widget 2', 'skt-pathway' ),
'description' => __( 'Appears on Footer', 'skt-pathway' ),
'id' => 'footer-2',
'before_widget' => '<aside class="widget">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Footer Widget 3', 'skt-pathway' ),
'description' => __( 'Appears on Footer', 'skt-pathway' ),
'id' => 'footer-3',
'before_widget' => '<aside class="widget nomarg">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'skt_pathway_widgets_init' );
function skt_pathway_scripts() {
wp_enqueue_style( 'skt_pathway-gfonts', 'https://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic,800,800italic');
wp_enqueue_style( 'skt_pathway-gfonts2', 'https://fonts.googleapis.com/css?family=Oswald:400,700,300');
wp_enqueue_style( 'skt_pathway-basic-style', get_stylesheet_uri() );
wp_enqueue_style( 'skt_pathway-editor-style', get_template_directory_uri()."/editor-style.css" );
wp_enqueue_style( 'skt_pathway-nivoslider-style', get_template_directory_uri()."/css/nivo-slider.css" );
wp_enqueue_style( 'skt_pathway-base-style', get_template_directory_uri()."/css/style_base.css" );
wp_enqueue_script( 'skt_pathway-nivo-script', get_template_directory_uri() . '/js/jquery.nivo.slider.js', array('jquery') );
wp_enqueue_script( 'skt_pathway-custom_js', get_template_directory_uri() . '/js/custom.js' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'skt_pathway_scripts' );
function skt_pathway_enqueue_styles() {
global $wp_styles;
// Load the main stylesheet
wp_enqueue_style( 'skt-pathway', get_stylesheet_uri() );
/**
* Load our IE-only stylesheet for all versions of IE:
* <!--[if lt IE 9]> ... <![endif]-->
*
* NOTE: It is also possible to just check and see if the $is_IE global in WordPress is set to true before
* calling the wp_enqueue_style() function. If you are trying to load a stylesheet for all browsers
* EXCEPT for IE, then you would HAVE to check the $is_IE global since WordPress doesn't have a way to
* properly handle non-IE conditional comments.
*/
wp_enqueue_style( 'skt-pathway-ie', get_stylesheet_directory_uri() . "/css/ie.css", array( 'skt-pathway-style' ) );
$wp_styles->add_data( 'skt-pathway-ie', 'conditional', 'IE' );
}
add_action('wp_enqueue_scripts', 'skt_pathway_enqueue_styles');
// add ie conditional html5 to header
function skt_pathway_add_ie_html5() {
global $is_IE;
if ($is_IE)
echo '<!--[if lt IE 9]>';
echo '<script src="'.get_template_directory_uri().'/js/html5.js"></script>';
echo '<![endif]-->';
}
add_action('wp_head', 'skt_pathway_add_ie_html5');
function media_css_hook(){
$output = '';
$output ='<link rel="stylesheet" href="'.get_template_directory_uri().'/css/computer.css" type="text/css" media="screen and (min-width:1000px)" />
<link rel="stylesheet" href="'.get_template_directory_uri().'/css/navigation.css?ver=3.9.1" type="text/css" media="screen and (max-width: 999px)" />
<link rel="stylesheet" href="'.get_template_directory_uri().'/css/tablet.css" type="text/css" media="screen and (min-width: 768px) and (max-width: 999px)" />
<link rel="stylesheet" href="'.get_template_directory_uri().'/css/mobile_hz.css" type="text/css" media="screen and (min-width: 480px) and (max-width: 767px)" />
<link rel="stylesheet" id="skt_pathway-grid-320-css" href="'.get_template_directory_uri().'/css/mobile.css" type="text/css" media="screen and (max-width: 479px)" />';
echo $output;
}
add_action('wp_head','media_css_hook');
function skt_pathway_custom_head_codes() {
if ( (function_exists( 'of_get_option' )) && (of_get_option('style2', true) != 1) ) {
echo "<style>". esc_html( of_get_option('style2', true) ) ."</style>";
}
}
add_action('wp_head', 'skt_pathway_custom_head_codes');
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template for about theme.
*/
require get_template_directory() . '/inc/about-themes.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
/**
* Load custom functions file.
*/
require get_template_directory() . '/inc/custom-functions.php';
// Add a Custom CSS file to WP Admin Area
function skt_pathway_customizer_styles() {
wp_enqueue_style( 'skt-pathway-customizer', trailingslashit( get_template_directory_uri() ).'css/customizer.css', null );
}
add_action( 'customize_controls_print_styles', 'skt_pathway_customizer_styles', 99 );
function skt_pathway_custom_blogpost_pagination( $wp_query ){
$big = 999999999; // need an unlikely integer
if ( get_query_var('paged') ) { $pageVar = 'paged'; }
elseif ( get_query_var('page') ) { $pageVar = 'page'; }
else { $pageVar = 'paged'; }
$pagin = paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?'.$pageVar.'=%#%',
'current' => max( 1, get_query_var($pageVar) ),
'total' => $wp_query->max_num_pages,
'prev_text' => '« Prev',
'next_text' => 'Next »',
'type' => 'array'
) );
if( is_array($pagin) ) {
$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
echo '<div class="pagination"><div><ul>';
echo '<li><span>'. $paged . ' of ' . $wp_query->max_num_pages .'</span></li>';
foreach ( $pagin as $page ) {
echo "<li>$page</li>";
}
echo '</ul></div></div>';
}
}
// get slug by id
function skt_pathway_get_slug_by_id($id) {
$post_data = get_post($id, ARRAY_A);
$slug = $post_data['post_name'];
return $slug;
}
if ( ! function_exists( 'skt_pathway_the_custom_logo' ) ) :
/**
* Displays the optional custom logo.
*
* Does nothing if the custom logo is not available.
*
*/
function skt_pathway_the_custom_logo() {
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
}
endif;
function remove_header_menu(){
remove_submenu_page( 'themes.php', 'custom-header' );
}
add_action( 'admin_menu', 'remove_header_menu', 999 );
?>