<?php
/**
* Theme sprecific functions and definitions
*/
/* Theme setup section
------------------------------------------------------------------- */
// Set the content width based on the theme's design and stylesheet.
if ( ! isset( $content_width ) ) $content_width = 1170; /* pixels */
// Add theme specific actions and filters
// Attention! Function were add theme specific actions and filters handlers must have priority 1
if ( !function_exists( 'citygov_theme_setup' ) ) {
add_action( 'citygov_action_before_init_theme', 'citygov_theme_setup', 1 );
function citygov_theme_setup() {
// Add default posts and comments RSS feed links to head
add_theme_support( 'automatic-feed-links' );
// Enable support for Post Thumbnails
add_theme_support( 'post-thumbnails' );
// Custom header setup
add_theme_support( 'custom-header', array('header-text'=>false));
// Custom backgrounds setup
add_theme_support( 'custom-background');
// Supported posts formats
add_theme_support( 'post-formats', array('gallery', 'video', 'audio', 'link', 'quote', 'image', 'status', 'aside', 'chat') );
// Autogenerate title tag
add_theme_support('title-tag');
// Add user menu
add_theme_support('nav-menus');
// WooCommerce Support
add_theme_support( 'woocommerce' );
// Add wide and full blocks support
add_theme_support( 'align-wide' );
// Register theme menus
add_filter( 'citygov_filter_add_theme_menus', 'citygov_add_theme_menus' );
// Register theme sidebars
add_filter( 'citygov_filter_add_theme_sidebars', 'citygov_add_theme_sidebars' );
// Set options for importer
add_filter( 'citygov_filter_importer_options', 'citygov_set_importer_options' );
// Add theme specified classes into the body
add_filter( 'body_class', 'citygov_body_classes' );
// Set list of the theme required plugins
citygov_storage_set('required_plugins', array(
'booked',
'buddypress', // Attention! This slug used to install both BuddyPress and bbPress
'essgrids',
'instagram_widget',
'revslider',
'tribe_events',
'trx_donations',
'trx_utils',
'visual_composer',
'wordpress-social-login',
'html5_jquery_audio_player',
'wp_gdpr_compliance',
'contact_form_7'
)
);
}
}
//
//function citygov_disable_admin_bar() {
// if ( ! current_user_can('edit_posts') ) {
// add_filter('show_admin_bar', '__return_false');
// }
//}
//add_action( 'after_setup_theme', 'citygov_disable_admin_bar' );
function citygov_disable_admin_bar() {
if ( function_exists( 'trx_utils_disable_admin_bar' ) ) {
trx_utils_disable_admin_bar();
}
}
add_action( 'after_setup_theme', 'citygov_disable_admin_bar' );
// Add/Remove theme nav menus
if ( !function_exists( 'citygov_add_theme_menus' ) ) {
//Handler of add_filter( 'citygov_filter_add_theme_menus', 'citygov_add_theme_menus' );
function citygov_add_theme_menus($menus) {
return $menus;
}
}
// Add theme specific widgetized areas
if ( !function_exists( 'citygov_add_theme_sidebars' ) ) {
function citygov_add_theme_sidebars($sidebars=array()) {
if (is_array($sidebars)) {
$theme_sidebars = array(
'sidebar_main' => esc_html__( 'Main Sidebar', 'citygov' ),
'sidebar_footer' => esc_html__( 'Footer Sidebar', 'citygov' )
);
if (function_exists('citygov_exists_woocommerce') && citygov_exists_woocommerce()) {
$theme_sidebars['sidebar_cart'] = esc_html__( 'WooCommerce Cart Sidebar', 'citygov' );
}
$sidebars = array_merge($theme_sidebars, $sidebars);
}
return $sidebars;
}
}
// Add theme specified classes into the body
if ( !function_exists('citygov_body_classes') ) {
function citygov_body_classes( $classes ) {
$classes[] = 'citygov_body';
$classes[] = 'body_style_' . trim(citygov_get_custom_option('body_style'));
$classes[] = 'body_' . (citygov_get_custom_option('body_filled')=='yes' ? 'filled' : 'transparent');
$classes[] = 'theme_skin_' . trim(citygov_get_custom_option('theme_skin'));
$classes[] = 'article_style_' . trim(citygov_get_custom_option('article_style'));
$blog_style = citygov_get_custom_option(is_singular() && !citygov_storage_get('blog_streampage') ? 'single_style' : 'blog_style');
$classes[] = 'layout_' . trim($blog_style);
$classes[] = 'template_' . trim(citygov_get_template_name($blog_style));
$body_scheme = citygov_get_custom_option('body_scheme');
if (empty($body_scheme) || citygov_is_inherit_option($body_scheme)) $body_scheme = 'original';
$classes[] = 'scheme_' . $body_scheme;
$top_panel_position = citygov_get_custom_option('top_panel_position');
if (!citygov_param_is_off($top_panel_position)) {
$classes[] = 'top_panel_show';
$classes[] = 'top_panel_' . trim($top_panel_position);
} else
$classes[] = 'top_panel_hide';
$classes[] = citygov_get_sidebar_class();
if (citygov_get_custom_option('show_video_bg')=='yes' && (citygov_get_custom_option('video_bg_youtube_code')!='' || citygov_get_custom_option('video_bg_url')!=''))
$classes[] = 'video_bg_show';
if (citygov_get_theme_option('page_preloader')!='')
$classes[] = 'preloader';
return $classes;
}
}
//------------------------------------------------------------------------
// One-click import support
//------------------------------------------------------------------------
// Set theme specific importer options
if ( ! function_exists( 'citygov_importer_set_options' ) ) {
add_filter( 'trx_utils_filter_importer_options', 'citygov_importer_set_options', 9 );
function citygov_importer_set_options( $options=array() ) {
if ( is_array( $options ) ) {
// Save or not installer's messages to the log-file
$options['debug'] = false;
// Prepare demo data
if ( is_dir( CITYGOV_THEME_PATH . 'demo/' ) ) {
$options['demo_url'] = CITYGOV_THEME_PATH . 'demo/';
} else {
$options['demo_url'] = esc_url( citygov_get_protocol().'://demofiles.ancorathemes.com/citygov/' ); // Demo-site domain
}
// Required plugins
$options['required_plugins'] = array(
'booked',
'bbpress', // Attention! This slug used to install both BuddyPress and bbPress
'essential-grid',
'instagram_widget',
'revslider',
'the-events-calendar',
'trx_donations',
'trx_utils',
'js_composer',
'wordpress-social-login',
'html5_jquery_audio_player',
'wp_gdpr_compliance',
'contact-form-7'
);
$options['theme_slug'] = 'citygov';
// Set number of thumbnails to regenerate when its imported (if demo data was zipped without cropped images)
// Set 0 to prevent regenerate thumbnails (if demo data archive is already contain cropped images)
$options['regenerate_thumbnails'] = 3;
// Default demo
$options['files']['default']['title'] = esc_html__( 'Education Demo', 'citygov' );
$options['files']['default']['domain_dev'] = esc_url(citygov_get_protocol().'://citygov.dv.ancorathemes.com'); // Developers domain
$options['files']['default']['domain_demo']= esc_url(citygov_get_protocol().'://citygov.ancorathemes.com'); // Demo-site domain
}
return $options;
}
}
// Add theme required plugins
if ( !function_exists( 'citygov_add_trx_utils' ) ) {
add_filter( 'trx_utils_active', 'citygov_add_trx_utils' );
function citygov_add_trx_utils($enable=true) {
return true;
}
}
/* Include framework core files
------------------------------------------------------------------- */
// If now is WP Heartbeat call - skip loading theme core files (to reduce server and DB uploads)
// Remove comments below only if your theme not work with own post types and/or taxonomies
//if (!isset($_POST['action']) || $_POST['action']!="heartbeat") {
require_once get_template_directory().'/fw/loader.php';
//}
?>