esc_html__( 'Primary Menu', 'automotive-services' ),
) );
/*
* 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',
) );
add_theme_support('custom-logo');
/*
* WooCommerce Plugin Support
*/
add_theme_support( 'woocommerce' );
// Gutenberg wide images.
add_theme_support( 'align-wide' );
/*
* This theme styles the visual editor to resemble the theme style,
* specifically font, colors, icons, and column width.
*/
add_editor_style( array( 'assets/css/editor-style.css', automotive_services_google_font_url() ) );
//Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'automotive_services_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
}
endif;
add_action( 'after_setup_theme', 'automotive_services_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function automotive_services_content_width() {
$GLOBALS['content_width'] = apply_filters( 'automotive_services_content_width', 1170 );
}
add_action( 'after_setup_theme', 'automotive_services_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function automotive_services_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar Widget Area', 'automotive-services' ),
'id' => 'automotive-services-sidebar-primary',
'description' => __( 'The Primary Widget Area', 'automotive-services' ),
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer Widget Area', 'automotive-services' ),
'id' => 'automotive-services-footer-widget-area',
'description' => __( 'The Footer Widget Area', 'automotive-services' ),
'before_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'automotive_services_widgets_init' );
/**
* All Styles & Scripts.
*/
require_once get_template_directory() . '/inc/enqueue.php';
/**
* Nav Walker fo Bootstrap Dropdown Menu.
*/
require_once get_template_directory() . '/inc/class-wp-bootstrap-navwalker.php';
/**
* Implement the Custom Header feature.
*/
require_once get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require_once get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require_once get_template_directory() . '/inc/extras.php';
/**
* Customizer additions.
*/
require_once get_template_directory() . '/inc/customizer.php';
require_once get_template_directory() . '/inc/fonts.php';
require_once get_template_directory() . '/wptt-webfont-loader.php';
/**
* Load Theme About Page
*/
require get_parent_theme_file_path( '/inc/aboutthemes/about-theme.php' );
/**
* Load Theme About Page
*/
//require get_parent_theme_file_path( '/inc/aboutthemes/about-theme.php' );
/*
* Enable support for Post Formats.
*
* See: https://codex.wordpress.org/Post_Formats
*/
add_theme_support( 'post-formats', array('image','video','gallery','audio',) );
/* Excerpt Limit Begin */
function automotive_services_string_limit_words($string, $word_limit) {
$words = explode(' ', $string, ($word_limit + 1));
if(count($words) > $word_limit)
array_pop($words);
return implode(' ', $words);
}
function automotive_services_sanitize_select( $input, $setting ) {
$input = sanitize_key( $input );
$choices = $setting->manager->get_control( $setting->id )->choices;
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
}
function automotive_services_sanitize_phone_number( $phone ) {
return preg_replace( '/[^\d+]/', '', $phone );
}
// Sanitize the input
function automotive_services_sanitize_sidebar_position( $input ) {
$valid = array( 'right', 'left' );
if ( in_array( $input, $valid ) ) {
return $input;
} else {
return 'right';
}
}
function automotive_services_custom_controls() {
load_template( trailingslashit( get_template_directory() ) . '/inc/customizer/customizer-custom-controls.php' );
}
add_action( 'customize_register', 'automotive_services_custom_controls' );
add_filter( 'nav_menu_link_attributes', 'automotive_services_dropdown_data_attribute', 20, 3 );
/**
* Use namespaced data attribute for Bootstrap's dropdown toggles.
*
* @param array $atts HTML attributes applied to the item's `` element.
* @param WP_Post $item The current menu item.
* @param stdClass $args An object of wp_nav_menu() arguments.
* @return array
*/
function automotive_services_dropdown_data_attribute( $atts, $item, $args ) {
if ( is_a( $args->walker, 'WP_Bootstrap_Navwalker' ) ) {
if ( array_key_exists( 'data-toggle', $atts ) ) {
unset( $atts['data-toggle'] );
$atts['data-bs-toggle'] = 'dropdown';
}
}
return $atts;
}
function automotive_services_remove_theme_customizer_setting($wp_customize) {
// Remove the setting
$wp_customize->remove_setting('display_header_text');
// Remove the control
$wp_customize->remove_control('display_header_text');
}
add_action('customize_register', 'automotive_services_remove_theme_customizer_setting', 20);
// Use a priority greater than the one used for adding the setting
// Set the number of products per row to 3 on the shop page
add_filter('loop_shop_columns', 'automotive_services_custom_shop_loop_columns');
if (!function_exists('automotive_services_custom_shop_loop_columns')) {
function automotive_services_custom_shop_loop_columns() {
// Retrieve the number of columns from theme customizer setting (default: 3)
$automotive_services_columns = get_theme_mod('automotive_services_custom_shop_per_columns', 3);
return $automotive_services_columns;
}
}
// Set the number of products per page on the shop page
add_filter('loop_shop_per_page', 'automotive_services_custom_shop_per_page', 20);
if (!function_exists('automotive_services_custom_shop_per_page')) {
function automotive_services_custom_shop_per_page($automotive_services_products_per_page) {
// Retrieve the number of products per page from theme customizer setting (default: 9)
$automotive_services_products_per_page = get_theme_mod('automotive_services_custom_shop_product_per_page', 9);
return $automotive_services_products_per_page;
}
}
function automotive_services_fonts_scripts() {
$automotive_services_headings_font = esc_html(get_theme_mod('automotive_services_headings_text'));
$automotive_services_body_font = esc_html(get_theme_mod('automotive_services_body_text'));
if( $automotive_services_headings_font ) {
wp_enqueue_style( 'automotive-services-headings-fonts', '//fonts.googleapis.com/css?family='. $automotive_services_headings_font );
} else {
wp_enqueue_style( 'automotive-services-source-sans', '//fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic');
}
if( $automotive_services_body_font ) {
wp_enqueue_style( 'automotive-services-body-fonts', '//fonts.googleapis.com/css?family='. $automotive_services_body_font );
} else {
wp_enqueue_style( 'automotive-services-source-body', '//fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,400italic,700,600');
}
}
add_action( 'wp_enqueue_scripts', 'automotive_services_fonts_scripts' );
function automotive_services_customize_css() {
?>
implode('|', $font_family), // No need for rawurlencode in this case
'display' => 'swap' // Add display=swap to improve loading performance
);
return esc_url(add_query_arg($query_args, 'https://fonts.googleapis.com/css2')); // Use https://fonts.googleapis.com/css2 for variable fonts
}
/**
* Enqueue theme styles and scripts.
*/
function automotive_services_scripts_styles() {
// Enqueue Google Fonts
wp_enqueue_style('automotive-services-google-fonts', automotive_services_google_font_url(), array(), null);
// Enqueue other styles and scripts as needed
wp_enqueue_style('automotive-services-main-style', get_stylesheet_uri(), array(), '1.0.0');
// Add more enqueuing here if needed
}
add_action('wp_enqueue_scripts', 'automotive_services_scripts_styles');
function automotive_services_activation_notice() {
// Check if the notice has already been dismissed
if (get_option('automotive_services_notice_dismissed')) {
return;
}
?>
' . wp_get_theme()->get('Name') . '');
?>