958, 'margin-left'=>0, 'margin-right'=>0 );
add_action( 'template_redirect', 'business_content_width' );
/* ============= Functions ============= */
function business_loadsettings($section) {
global $lz_default;
$result=get_option( 'business-settings' );
if (! isset($result[$section]) ) {
include_once ( get_template_directory().'/inc/default.php' );
$result[$section]=$lz_default[$section];
update_option( 'business-settings', $result );
}
return $result[$section];
}
function business_custom_theme_setup() {
global $settings;
$lang_dir = get_template_directory() . '/languages';
load_theme_textdomain('lizard', $lang_dir);
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'woocommerce' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'custom-background', array(
'default-color' => 'd7d7d7',
'default-image' => get_template_directory_uri() . '/images/background.png',
'wp-head-callback'=>'business_custom_background_cb')
);
set_post_thumbnail_size( $settings['layout']['fimage_width'], $settings['layout']['fimage_height'], true );
add_image_size( 'slide', 1000, 430, true );
add_image_size( 'showroom', 207, 297, true );
add_image_size( 'related', 160, 160, true );
add_image_size( 'slide-preview', 122, 75, true );
}
function business_custom_header_setup() {
$args = array(
'default-text-color' => '444',
'default-image' => '',
'height' => 250,
'width' => 1000,
'max-width' => 2000,
'flex-height' => true,
'flex-width' => true
);
add_theme_support( 'custom-header', $args );
}
function business_register_theme_menus() {
register_nav_menus(
array(
'header-menu1' => __( 'Main Menu', 'lizard' ),
'header-menu2' => __( 'Extra Menu', 'lizard' )
)
);
}
function business_widgets_init() {
register_sidebar(array(
'name' => __( 'Right sidebar', 'lizard' ),
'id' => 'right_sidebar',
'description' => __( 'Right sidebar', 'lizard' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
'
));
register_sidebar(array(
'name' => __( 'Left sidebar', 'lizard' ),
'id' => 'left_sidebar',
'description' => __( 'Left sidebar', 'lizard' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
'
));
register_sidebar(array(
'name' => __( 'Tabs', 'lizard' ),
'id' => 'tabs_sidebar',
'description' => __( 'Sadebar for Tabs widget', 'lizard' ),
'before_widget' => '',
'before_title' => '',
'after_title' => ''
));
register_sidebar(array(
'name' => __( 'Footer left', 'lizard' ),
'id' => 'footer_left',
'description' => __( 'Left footer widgets', 'lizard' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
'
));
register_sidebar(array(
'name' => __( 'Footer middle', 'lizard' ),
'id' => 'footer_middle',
'description' => __( 'Middle footer widgets', 'lizard' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
'
));
register_sidebar(array(
'name' => __( 'Footer right', 'lizard' ),
'id' => 'footer_right',
'description' => __( 'Right footer widgets', 'lizard' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
'
));
}
function business_content_width() {
global $post, $content_width, $container, $settings;
if (((is_single()||is_page())&&(get_post_meta($post->ID, 'pagetemplate', true) == 'left' || get_post_meta($post->ID, 'pagetemplate', true) == 'both' || ($settings['elements']['leftsidebar']['show'] && get_post_meta($post->ID, 'pagetemplate', true) != 'right' && get_post_meta($post->ID, 'pagetemplate', true) != 'full') )) || (!(is_single()||is_page())&&$settings['elements']['leftsidebar']['show'])) {
$container['width']-=$settings['theme']['sidebar-width'];
$container['margin-left']=$settings['theme']['sidebar-width'];
}
if (((is_single()||is_page())&&(get_post_meta($post->ID, 'pagetemplate', true) == 'right' || get_post_meta($post->ID, 'pagetemplate', true) == 'both' || ($settings['elements']['rightsidebar']['show'] && get_post_meta($post->ID, 'pagetemplate', true) != 'left' && get_post_meta($post->ID, 'pagetemplate', true) != 'full') )) || (!(is_single()||is_page())&&$settings['elements']['rightsidebar']['show'])) {
$container['width']-=$settings['theme']['sidebar-width'];
$container['margin-right']=$settings['theme']['sidebar-width'];
}
$content_width = $container['width']-137;
}
function business_custom_header_code() {
global $settings, $post, $container; ?>
'h1, h2, h3, h4, h5, h6',
'body'=>'body, input, textarea, select, code',
'menu'=>'.menu, .readmore, #submit, .post-password-required form input[type=\"submit\"], .button'
);
foreach ($settings['fonts'] as $key=>$value) { ?>
$value) {
wp_enqueue_style( 'gglFont-'.$key, '//fonts.googleapis.com/css?family='.$value.'&subset=latin,cyrillic' );
}
}
function business_theme_secondary_menu() { ?>
comment_type ) :
case 'pingback' :
case 'trackback' :
?>
id="comment-">
', '' ); ?>
id="li-comment-">
',
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )
);
$author = sprintf( '%3$s',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'lizard' ), get_the_author() ) ),
get_the_author()
);
ob_start();
comments_popup_link();
$comments = ob_get_contents();
ob_end_clean();
printf(
$settings['layout']['postmeta'],
$date,
$categories_list,
$author,
$comments
);
}
function business_custom_excerpt($args=''){
global $post, $settings;
$p=$post;
parse_str($args, $i);
$echo = isset($i['echo'])?true:false;
if ( isset($i['maxchar']) ) {
$maxchar=(int)trim($i['maxchar']);
$content = $p->post_content;
$content = apply_filters('the_content', $content);
} else {
if ( $p->post_excerpt ) {
$content = $p->post_excerpt;
$maxchar=false;
} else {
$content = $p->post_content;
$content = apply_filters('the_content', $content);
$maxchar=$settings['layout']['cutcontent']?$settings['layout']['contentlength']:0;
$maxchar=(strpos($content, ''))?strpos(preg_replace('/<.*?>/', '', preg_replace('//','@readmore_tag',$content)), '@readmore_tag'):$maxchar;
}
}
if (!$maxchar||strlen(preg_replace('/<.*?>/', '', $content)) <= $maxchar) {
if ($echo) print $content;
else return $content;
} else {
preg_match_all('/(<.+?>)?([^<>]*)/s', $content, $lines, PREG_SET_ORDER);
$total_length=0;
$open_tags = array();
$truncate = '';
foreach( $lines as $line_matchings ) {
if (!empty($line_matchings[1])) {
if (preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) {;}
else if (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
$pos = array_search($tag_matchings[1], $open_tags);
if ($pos !== false) {
unset($open_tags[$pos]);
}
} else if (preg_match('/^<\s*([^\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) {
array_unshift($open_tags, strtolower($tag_matchings[1]));
}
$truncate .= $line_matchings[1];
}
$content_length = strlen(preg_replace('/&[0-9a-z]{2,8};|[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
if ( $total_length+$content_length > $maxchar ) {
$left = $maxchar - $total_length;
$entities_length = 0;
if ( preg_match_all('/&[0-9a-z]{2,8};|[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, PREG_OFFSET_CAPTURE) ) {
foreach ($entities[0] as $entity) {
if ($entity[1]+1-$entities_length <= $left) {
$left--;
$entities_length += strlen($entity[0]);
} else {
break;
}
}
}
$truncate .= preg_replace('/(.*)\.[^\.]*$/s', "$1",mb_substr($line_matchings[2], 0, $left+$entities_length, 'utf-8'))."...";
break;
} else {
$truncate .= $line_matchings[2];
$total_length += $content_length;
}
if( $total_length>= $maxchar ) {
break;
}
}
foreach ($open_tags as $tag) {
$truncate .= '' . $tag . '>';
}
$truncate=preg_replace('/])*>( )?<\/p>/', '', $truncate);
if ($echo) return print $truncate;
else return $truncate;
}
return;
}
function business_wp_title( $title, $sep ) {
global $settings;
if (is_home()) {
$title = get_bloginfo('name');
} else
$title = sprintf( $settings['general']['site_title'], $title, get_bloginfo('name') );
return $title;
}