File: /home/slyfwmm/studiomilighetti/wp-content/themes/domik/includes/template-functions.php
<?php
/* banner-php */
/**
* Custom template tags for this theme
*
* Eventually, some of the functionality here could be replaced by core features.
*
*/
function domik_get_option( $setting, $default = null ) {
global $domik_options;
$default_options = array(
// General Settings
'favicon' => array('url'=> get_template_directory_uri().'/assets/images/favicon.png' ),
'logo' => array('url'=> get_template_directory_uri().'/assets/images/logo.png' ),
'logo_size_width' => '37',
'logo_size_height' => '30',
'logo_text' => '',
'slogan' => '',
'disable_ajax_transition' => true,
'show_loader' => true,
'loader_icon' => '<i class="fa fa-refresh fa-spin"></i>',
'show_to_top' => true,
'to_top_icon' => '<i class="fa fa-long-arrow-up"></i>',
'right_parallax_bg' => array('url'=> get_template_directory_uri().'/assets/images/bg/long/7.jpg' ),
'rotate_bg' => array('url'=> get_template_directory_uri().'/assets/images/body-bg.png' ),
'rotate_on' => false,
'fullwidth_layout' => false,
'show_page_title' => true,
// 'gmap_api_key' => '',
// Footer Settings
'footer_info' => '<div class="row">
<div class="col-md-5">
<a class="footer-logo ajax" href="'.home_url('/' ).'"><img width="99" height="30" src="'.get_template_directory_uri().'/assets/images/footer-logo.png" alt="domik"></a>
</div>
<div class="col-md-3">
<div class="footer-adress">
<span>USA 27TH BROOKLYN NY</span>
<a href="#" target="_blank">View on map</a>
</div>
</div>
<div class="col-md-4">
<ul class="footer-contact">
<li>+7(111)123456789</li>
<li><a href="#">yourmail@domain.com</a></li>
</ul>
</div>
</div>',
'footer_copyright' => '<div class="row">
<div class="col-md-5"></div>
<div class="col-md-7">
<p>Copyright by CTHthemes © Domik 2019. All rights reserved.</p>
</div>
</div>',
// Media
'enable_custom_sizes' => false,
'fullscreen_thumb' => array(
'width' => '1366',
'height' => '768',
'hard_crop' => 1
),
'service_thumb' => array(
'width' => '273',
'height' => '165',
'hard_crop' => 1
),
'team_thumb' => array(
'width' => '273',
'height' => '393',
'hard_crop' => 1
),
'folio_size_one' => array(
'width' => '342',
'height' => '207',
'hard_crop' => 1
),
'folio_size_two' => array(
'width' => '684',
'height' => '414',
'hard_crop' => 1
),
'folio_size_three' => array(
'width' => '1026',
'height' => '621',
'hard_crop' => 1
),
'folio_size_one_tall' => array(
'width' => '342',
'height' => '414',
'hard_crop' => 1
),
'blog_image_thumb' => array(
'width' => '497',
'height' => '301',
'hard_crop' => 1
),
// Social Settings
'share_names' => "facebook,twitter,google,tumblr",
// Styling Options
'override-preset' => false,
'skin-color' => '#000',
'body-background-color' => '#f4f4f4',
'main-background-color' => '#fff',
'text-link-color' => '#000',
'text-link-hover-color' => '#000',
'header-background-color' => '#fff',
'menu-text-color' => '#666',
'menu-text-hover-color' => '#666',
'mobile-menu-trigger-color' => '#000',
// Portfolio Settings
'folio_style' => 'style2',
'folio_column' => 'three',
'folio_posts_per_page' => '10',
'folio_archive_orderby' => 'date',
'folio_archive_order' => 'DESC',
'folio_show_info_first' => FALSE,
'folio_pad' => 'none',
'folio_list_link' => esc_url( home_url('/portfolio/' ) ),
'folio_enable_gallery' => false,
'folio_single_use_old' => true,
// Filter
'folio_show_filter' => true,
'folio_filter_orderby' => 'name',
'folio_filter_order' => 'ASC',
'folio_filter_width' => '30%',
'folio_filter_height' => '60px',
// Pagination / Loadmore
'folio_show_loadmore' => true,
'folio_loadmore_items' => 3,
'folio_show_pagination' => false,
// Blog Settings
'blog_home_text' => 'Our Blog',
'blog_home_text_intro' => '<h3><span>All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true</span></h3>',
'blog_layout' => 'right_sidebar',
'blog-sidebar-width' => '3',
'blog_column' => 'one',
'author_checkbox' => true,
'date_checkbox' => true,
'cats_checkbox' => true,
'tag_checkbox' => true,
'comment_checkbox' => true,
'blog_list_link' => esc_url( home_url('/' ) ) .'blog/',
// Blog Single
'blog_single_title' => true,
'blog_featured_single' => true,
'blog_date_single' => true,
'blog_author_meta' => true,
'blog_cats_single' => true,
'blog_comments_single' => true,
'blog_tags_single' => true,
'blog_author_single' => true,
'blog_single_navigation' => true,
'blog_single_nav_same_term' => false,
'blog_list_link' => '',
// 404 Page
'404_intro' => 'Sorry, but the page you are looking for has not been found.',
'back_home_link' => esc_url( home_url('/' ) ),
'404_right_parallax_bg' => array('url'=> get_template_directory_uri().'/assets/images/bg/long/7.jpg' ),
// Custom Code
'custom-css' => '',
);
if( is_customize_preview() ) $domik_options = get_option( 'domik_options', array() );
$value = false;
if ( isset( $domik_options[ $setting ] ) ) {
$value = $domik_options[ $setting ];
}else {
if(isset($default)){
$value = $default;
}else if( isset( $default_options[ $setting ] ) ){
$value = $default_options[ $setting ];
}
}
return $value;
}
/**
* Global variables fix
* https://forums.envato.com/t/redux-framework-global-variable-issue/36739
*/
if ( !function_exists('domik_global_var') ) {
function domik_global_var($opt_1 = '', $opt_2 = '', $opt_check = false){
global $domik_options;
if( is_customize_preview() ) $domik_options = get_option( 'domik_options', array() );
if( $opt_check ) {
if( isset($domik_options[$opt_1]) && isset($domik_options[$opt_1][$opt_2]) ) {
return $domik_options[$opt_1][$opt_2];
}
} else {
if(isset($domik_options[$opt_1])) {
return $domik_options[$opt_1];
}
}
return false;
}
}
if(!function_exists('domik_get_template_part')){
/**
* Load a template part into a template
*
* Makes it easy for a theme to reuse sections of code in a easy to overload way
* for child themes.
*
* Includes the named template part for a theme or if a name is specified then a
* specialised part will be included. If the theme contains no {slug}.php file
* then no template will be included.
*
* The template is included using require, not require_once, so you may include the
* same template part multiple times.
*
* For the $name parameter, if the file is called "{slug}-special.php" then specify
* "special".
* For the var parameter, simple create an array of variables you want to access in the template
* and then access them e.g.
*
* array("var1=>"Something","var2"=>"Another One","var3"=>"heres a third";
*
* becomes
*
* $var1, $var2, $var3 within the template file.
*
*
* @param string $slug The slug name for the generic template.
* @param string $name The name of the specialised template.
* @param array $vars The list of variables to carry over to the template
* @author CTHthemes
* @ref http://www.zmastaa.com/2015/02/06/php-2/wordpress-passing-variables-get_template_part
* @ref http://keithdevon.com/passing-variables-to-get_template_part-in-wordpress/
*/
function domik_get_template_part( $slug, $name = null, $vars = null ) {
$template_name = "{$slug}.php";
$name = (string) $name;
if ( '' !== $name ) {
$template_name = "{$slug}-{$name}.php";
}
$located = locate_template($template_name, false);
if($located !== ''){
/*
* This use of extract() cannot be removed. There are many possible ways that
* templates could depend on variables that it creates existing, and no way to
* detect and deprecate it.
*
* Passing the EXTR_SKIP flag is the safest option, ensuring globals and
* function variables cannot be overwritten.
*/
// phpcs:ignore WordPress.PHP.DontExtract.extract_extract
if(isset($vars)) extract($vars, EXTR_SKIP);
include $located;
}
}
}
/**
* Custom comments list
*
*/
if (!function_exists('domik_comments')) {
function domik_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ('div' == $args['style']) {
$tag = 'div';
$add_below = 'comment';
}
else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php
echo esc_attr($tag); ?> <?php
comment_class(empty($args['has_children']) ? 'media' : 'media parent') ?> id="comment-<?php
comment_ID() ?>">
<?php
if ('div' != $args['style']): ?>
<div id="div-comment-<?php
comment_ID() ?>" class="comment-body">
<?php
endif; ?>
<div class="comment-author">
<?php
if ($args['avatar_size'] != 0) echo get_avatar($comment, $args['avatar_size']); ?>
</div>
<cite class="fn"><a href="#"><?php
echo get_comment_author_link($comment->comment_ID); ?></a></cite>
<div class="comment-meta">
<h6><a href="#"><?php
echo get_comment_date(esc_html__('F j, Y g:i a', 'domik')); ?></a> / <?php
comment_reply_link(array_merge($args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?></h6>
</div>
<?php
comment_text(); ?>
<?php
if ($comment->comment_approved == '0'): ?>
<em class="comment-awaiting-moderation aligncenter"><?php
esc_html_e('Your comment is awaiting moderation.', 'domik'); ?></em>
<br />
<?php
endif; ?>
<?php
if ('div' != $args['style']): ?>
</div>
<?php
endif; ?>
<?php
}
}
function domik_relative_protocol_url(){
return is_ssl() ? 'https' : 'http';
}
/**
* Filter the body_class for global configuration
*
* @since 3.0.5
*/
// Apply filter
add_filter('body_class', 'domik_body_classes');
function domik_body_classes($classes) {
if(post_password_required()) $classes[] = 'is-protected-page';
// Add class of group-blog to blogs with more than 1 published author.
if ( is_multi_author() ) {
$classes[] = 'group-blog';
}
// Add class of hfeed to non-singular pages.
$fullwidth_layout = domik_get_option('fullwidth_layout');
if ( is_singular() ) {
$classes[] = 'domik-singular';
if( false == get_post_meta( get_the_ID(), '_cth_show_header', true ) ) $classes[] = 'domik-no-head-sec';
if( get_post_meta(get_the_ID(),'_cmb_fullwidth_layout',true ) == 'yes'){
$fullwidth_layout = true;
}
}else{
$classes[] = 'hfeed';
if( false == domik_get_option('show_blog_header') ) $classes[] = 'domik-no-head-sec';
}
if($fullwidth_layout){
$classes[] = 'domik_fullwidth';
}
// Add class if we're viewing the Customizer for easier styling of theme options.
if ( is_customize_preview() ) {
$classes[] = 'domik-customizer';
}
// Add class on front page.
if ( is_front_page() && 'posts' !== get_option( 'show_on_front' ) ) {
$classes[] = 'domik-front-page';
}
if( isset($_GET['dark_theme']) && $_GET['dark_theme'] == true ) $classes[] = 'domik-dark';
return $classes;
}
add_filter( 'get_custom_logo', 'domik_new_logo_ajax_class' );
function domik_new_logo_ajax_class($html){
return preg_replace('/class="custom-logo-link"/m', 'class="custom-logo-link ajax"', $html);
}