Current File : /home/kelaby89/teamhachem.com/wp-content/themes/artkombat/inc/hooks.php |
<?php if ( ! defined( 'ABSPATH' ) ) { die( 'Direct access forbidden.' ); }
/**
* Filters and Actions
*/
/**
* Enqueue Google fonts style to admin screen for custom header display.
*
* @internal
*/
function artkombat_action_theme_admin_fonts() {
wp_enqueue_style( 'fw-theme-lato', artkombat_font_url(), array(), '1.0' );
}
add_action( 'admin_print_scripts-appearance_page_custom-header', 'artkombat_action_theme_admin_fonts' );
/**
* Theme setup.
*
* Set up theme defaults and registers support for various WordPress features.
* @internal
*/
if ( ! function_exists( 'artkombat_theme_setup' ) ) {
function artkombat_theme_setup() {
/*
* Make Theme available for translation.
*/
load_theme_textdomain( 'artkombat', get_template_directory() . '/languages' );
// This theme styles the visual editor to resemble the theme style.
add_editor_style( array( 'css/editor-style.css', artkombat_font_url() ) );
// Add RSS feed links to <head> for posts and comments.
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
// Enable support for Post Thumbnails, and declare two sizes.
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 770, 535, true );
add_image_size( 'artkombat-service-full', 600, 450, true );
add_image_size( 'artkombat-service', 492, 492, true );
add_image_size( 'artkombat-blog', 370, 258, true );
add_image_size( 'artkombat-blog-full', 770, 535, true );
add_image_size( 'artkombat-tiny-square', 70, 70, true );
add_image_size( 'artkombat-tiny', 110, 80, true );
add_image_size( 'artkombat-gallery', 755, 755 );
add_image_size( 'artkombat-team', 585, 520 );
/*
* 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 http://codex.wordpress.org/Post_Formats
*/
add_theme_support( 'post-formats', array(
'video',
'audio',
'quote',
'link',
'gallery',
) );
// This theme uses its own gallery styles.
add_filter( 'use_default_gallery_style', '__return_false' );
}
}
add_action( 'init', 'artkombat_theme_setup' );
function artkombat_add_woocommerce_support() {
add_theme_support( 'woocommerce' );
if ( function_exists( 'fw_get_db_settings_option' ) ) $wc_zoom = fw_get_db_settings_option( 'wc_zoom' );
if ( !empty($wc_zoom) AND $wc_zoom == 'enabled') add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
}
add_action( 'after_setup_theme', 'artkombat_add_woocommerce_support' );
/**
* Adjust content_width value for image attachment template.
*
* @internal
*/
function artkombat_action_theme_content_width() {
if ( is_attachment() && wp_attachment_is_image() ) {
$GLOBALS['content_width'] = 770;
}
}
add_action( 'template_redirect', 'artkombat_action_theme_content_width' );
/**
* Extend the default WordPress body classes.
*
* @param array $classes A list of existing body class values.
*
* @return array The filtered body class list.
* @internal
*/
function artkombat_filter_theme_body_classes( $classes ) {
global $wp_query;
if ( is_multi_author() ) {
$classes[] = 'group-blog';
}
if ( get_header_image() ) {
$classes[] = 'header-image';
} else {
$classes[] = 'masthead-fixed';
}
if ( is_archive() || is_search() || is_home() ) {
$classes[] = 'list-view';
}
if ( function_exists( 'fw_ext_sidebars_get_current_position' ) ) {
$current_position = fw_ext_sidebars_get_current_position();
if ( in_array( $current_position, array( 'full', 'left' ) )
|| empty( $current_position )
|| is_page_template( 'page-templates/full-width.php' )
|| is_page_template( 'page-templates/contributors.php' )
|| is_attachment()
) {
$classes[] = 'full-width';
}
} else {
$classes[] = 'full-width';
}
if ( is_active_sidebar( 'sidebar-1' ) ) {
$classes[] = 'footer-widgets';
}
if ( is_singular() && ! is_front_page() ) {
$classes[] = 'singular';
}
if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) {
$classes[] = 'slider';
} elseif ( is_front_page() ) {
$classes[] = 'grid';
}
$artkombat_pace = 'disabled';
if ( function_exists( 'fw' ) ) {
$artkombat_pace = fw_get_db_settings_option( 'page-loader' );
if ( !empty($artkombat_pace) AND !empty($artkombat_pace['loader'])) $artkombat_pace = $artkombat_pace['loader'];
$body_color = fw_get_db_post_option( $wp_query->get_queried_object_id(), 'body-color' );
if ( !empty($body_color) AND $body_color != 'default' ) $classes[] = "body-".esc_attr($body_color);
$body_border = fw_get_db_post_option( $wp_query->get_queried_object_id(), 'margin-layout' );
if ( !empty($body_border) AND $body_border == 'body-border' ) $classes[] = "ltx-body-border";
}
$classes[] = 'paceloader-'.esc_attr($artkombat_pace);
return $classes;
}
add_filter( 'body_class', 'artkombat_filter_theme_body_classes' );
/**
* Extend the default WordPress post classes.
*
* Adds a post class to denote:
* Non-password protected page with a post thumbnail.
*
* @param array $classes A list of existing post class values.
*
* @return array The filtered post class list.
* @internal
*/
function artkombat_filter_theme_post_classes( $classes ) {
if ( ! post_password_required() && ! is_attachment() && has_post_thumbnail() ) {
$classes[] = 'has-post-thumbnail';
}
return $classes;
}
add_filter( 'post_class', 'artkombat_filter_theme_post_classes' );
/**
* Create a nicely formatted and more specific title element text for output
* in head of document, based on current view.
*
* @param string $title Default title text for current view.
* @param string $sep Optional separator.
*
* @return string The filtered title.
* @internal
*/
function artkombat_filter_theme_wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() ) {
return $title;
}
// Add the site name.
$title .= get_bloginfo( 'name', 'display' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) ) {
$title = "$title $sep $site_description";
}
// Add a page number if necessary.
if ( $paged >= 2 || $page >= 2 ) {
$title = "$title $sep " . sprintf( esc_html__( 'Page %s', 'artkombat' ), max( $paged, $page ) );
}
return $title;
}
add_filter( 'wp_title', 'artkombat_filter_theme_wp_title', 10, 2 );
/**
* Flush out the transients used in artkombat_categorized_blog.
*
* @internal
*/
function artkombat_action_theme_category_transient_flusher() {
delete_transient( 'artkombat_category_count' );
}
add_action( 'edit_category', 'artkombat_action_theme_category_transient_flusher' );
add_action( 'save_post', 'artkombat_action_theme_category_transient_flusher' );
/**
* @param FW_Ext_Backups_Demo[] $demos
* @return FW_Ext_Backups_Demo[]
*/
function artkombat_filter_theme_fw_ext_backups_demos( $demos ) {
$demos_array = array(
'artkombat-demo' => array(
'title' => esc_html__( 'Artkombat Demo Content', 'artkombat' ),
'screenshot' => 'http://updates.like-themes.com/artkombat/screenshot.png',
'preview_link' => 'http://artkombat.like-themes.com/',
),
);
$download_url = 'http://updates.like-themes.com/artkombat/?kov='.esc_attr(wp_get_theme(get_template())->version);
foreach ( $demos_array as $id => $data ) {
$demo = new FW_Ext_Backups_Demo($id, 'piecemeal', array(
'url' => $download_url,
'file_id' => $id,
));
$demo->set_title( $data['title'] );
$demo->set_screenshot( $data['screenshot'] );
$demo->set_preview_link( $data['preview_link'] );
$demos[ $demo->get_id() ] = $demo;
unset( $demo );
}
return $demos;
}
add_filter( 'fw:ext:backups-demo:demos', 'artkombat_filter_theme_fw_ext_backups_demos' );