/home/lnzliplg/www/wp-content/themes/law-firm-attorney/functions.php
<?php

add_action( 'after_setup_theme', 'law_firm_attorney_after_setup_theme' );
function law_firm_attorney_after_setup_theme() {
    add_theme_support( 'title-tag' );
    add_theme_support( 'automatic-feed-links' );
    add_theme_support( "responsive-embeds" );
    add_theme_support( 'wp-block-styles' );
    add_theme_support( 'align-wide' );
    add_theme_support( 'post-thumbnails' );
    add_image_size( 'law-firm-attorney-featured-image', 2000, 1200, true );
    add_image_size( 'law-firm-attorney-thumbnail-avatar', 100, 100, true );

    // Set the default content width.
    $GLOBALS['content_width'] = 525;

    // Add theme support for Custom Logo.
    add_theme_support( 'custom-logo', array(
        'width'       => 250,
        'height'      => 250,
        'flex-width'  => true,
        'flex-height' => true,
    ) );



    add_theme_support( 'custom-background', array(
        'default-color' => 'ffffff'
    ) );

    add_theme_support( 'html5', array('comment-form','comment-list','gallery','caption',) );

}

// Add function after setup:
function law_firm_attorney_conditional_editor_styles() {
    
    add_editor_style( array( 'assets/css/editor-style.css') );
}
add_action( 'after_setup_theme', 'law_firm_attorney_conditional_editor_styles', 11 );

/**
 * Register widget area.
 */
function law_firm_attorney_widgets_init() {
    register_sidebar( array(
        'name'          => __( 'Blog Sidebar', 'law-firm-attorney' ),
        'id'            => 'sidebar-1',
        'description'   => __( 'Add widgets here to appear in your sidebar on blog posts and archive pages.', 'law-firm-attorney' ),
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget'  => '</section>',
        'before_title'  => '<h3 class="widget-title">',
        'after_title'   => '</h3>',
    ) );

    register_sidebar( array(
        'name'          => __( 'Page Sidebar', 'law-firm-attorney' ),
        'id'            => 'sidebar-2',
        'description'   => __( 'Add widgets here to appear in your sidebar on pages.', 'law-firm-attorney' ),
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget'  => '</section>',
        'before_title'  => '<h3 class="widget-title">',
        'after_title'   => '</h3>',
    ) );

    register_sidebar( array(
        'name'          => __( 'Sidebar 3', 'law-firm-attorney' ),
        'id'            => 'sidebar-3',
        'description'   => __( 'Add widgets here to appear in your sidebar on blog posts and archive pages.', 'law-firm-attorney' ),
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget'  => '</section>',
        'before_title'  => '<h3 class="widget-title">',
        'after_title'   => '</h3>',
    ) );

    register_sidebar( array(
        'name'          => __( 'Footer 1', 'law-firm-attorney' ),
        'id'            => 'footer-1',
        'description'   => __( 'Add widgets here to appear in your footer.', 'law-firm-attorney' ),
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget'  => '</section>',
        'before_title'  => '<h3 class="widget-title">',
        'after_title'   => '</h3>',
    ) );

    register_sidebar( array(
        'name'          => __( 'Footer 2', 'law-firm-attorney' ),
        'id'            => 'footer-2',
        'description'   => __( 'Add widgets here to appear in your footer.', 'law-firm-attorney' ),
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget'  => '</section>',
        'before_title'  => '<h3 class="widget-title">',
        'after_title'   => '</h3>',
    ) );

    register_sidebar( array(
        'name'          => __( 'Footer 3', 'law-firm-attorney' ),
        'id'            => 'footer-3',
        'description'   => __( 'Add widgets here to appear in your footer.', 'law-firm-attorney' ),
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget'  => '</section>',
        'before_title'  => '<h3 class="widget-title">',
        'after_title'   => '</h3>',
    ) );

    register_sidebar( array(
        'name'          => __( 'Footer 4', 'law-firm-attorney' ),
        'id'            => 'footer-4',
        'description'   => __( 'Add widgets here to appear in your footer.', 'law-firm-attorney' ),
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget'  => '</section>',
        'before_title'  => '<h3 class="widget-title">',
        'after_title'   => '</h3>',
    ) );
}
add_action( 'widgets_init', 'law_firm_attorney_widgets_init' );

// enqueue styles for child theme
function law_firm_attorney_enqueue_styles() {

    wp_enqueue_style( 'law-firm-attorney-fonts', lawyer_hub_fonts_url(), array(), null );

    // Bootstrap
    wp_enqueue_style( 'bootstrap-css', get_theme_file_uri( '/assets/css/bootstrap.css' ) );

    // Theme block stylesheet.
    wp_enqueue_style( 'law-firm-attorney-block-style', get_theme_file_uri( '/assets/css/blocks.css' ), array( 'law-firm-attorney-child-style' ), '1.0' );

    // enqueue parent styles
    wp_enqueue_style('lawyer-hub-style', get_template_directory_uri() .'/style.css');

    // enqueue child styles
    wp_enqueue_style('law-firm-attorney-child-style', get_stylesheet_directory_uri() .'/style.css', array('lawyer-hub-style'));

    require get_theme_file_path( '/tp-theme-color.php' );
    wp_add_inline_style( 'law-firm-attorney-child-style',$lawyer_hub_tp_theme_css );

    wp_enqueue_script( 'comment-reply', '/wp-includes/js/comment-reply.min.js', array(), false, true );

    $lawyer_hub_body_font_family = get_theme_mod('lawyer_hub_body_font_family', '');

    $lawyer_hub_heading_font_family = get_theme_mod('lawyer_hub_heading_font_family', '');

    $lawyer_hub_tp_theme_css = '
        body{
            font-family: '.esc_html($lawyer_hub_body_font_family).' !important;
        }
        h1{
            font-family: '.esc_html($lawyer_hub_heading_font_family).' !important;
        }
        h2{
            font-family: '.esc_html($lawyer_hub_heading_font_family).' !important;
        }
        h3{
            font-family: '.esc_html($lawyer_hub_heading_font_family).' !important;
        }
        h4{
            font-family: '.esc_html($lawyer_hub_heading_font_family).' !important;
        }
        h5{
            font-family: '.esc_html($lawyer_hub_heading_font_family).' !important;
        }
        h6{
            font-family: '.esc_html($lawyer_hub_heading_font_family).' !important;
        }
        #theme-sidebar .wp-block-search .wp-block-search__label{
            font-family: '.esc_html($lawyer_hub_heading_font_family).' !important;
        }
    ';
    wp_add_inline_style('lawyer-hub-style', $lawyer_hub_tp_theme_css);

}
add_action('wp_enqueue_scripts', 'law_firm_attorney_enqueue_styles');

function law_firm_attorney_admin_scripts() {
    // Backend CSS
    wp_enqueue_style( 'law-firm-attorney-backend-css', get_theme_file_uri( '/assets/css/customizer.css' ) );
}
add_action( 'admin_enqueue_scripts', 'law_firm_attorney_admin_scripts' );

function law_firm_attorney_sanitize_select( $input, $setting ){
    //input must be a slug: lowercase alphanumeric characters, dashes and underscores are allowed only
    $input = sanitize_key($input);

    //get the list of possible select options
    $choices = $setting->manager->get_control( $setting->id )->choices;

    //return input if valid or return default option
    return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
}

function law_firm_attorney_theme_setup() {

    require get_theme_file_path( '/customizer/customize-control-toggle.php' );

    require get_stylesheet_directory() . '/customizer/customizer.php';

    if ( ! defined( 'LAWYER_HUB_PRO_THEME_URL' ) ) {
        define( 'LAWYER_HUB_PRO_THEME_URL', 'https://www.themespride.com/products/attorney-wordpress-theme' );
    }
    if ( ! defined( 'LAWYER_HUB_PRO_THEME_NAME' ) ) {
        define( 'LAWYER_HUB_PRO_THEME_NAME', esc_html__( 'Law Firm Attorney Pro', 'law-firm-attorney' ));
    }
    if ( ! defined( 'LAWYER_HUB_FREE_THEME_URL' ) ) {
    	define( 'LAWYER_HUB_FREE_THEME_URL', 'https://www.themespride.com/products/free-law-firm-wordpress-theme' );
    }
    if ( ! defined( 'LAWYER_HUB_DEMO_THEME_URL' ) ) {
    	define( 'LAWYER_HUB_DEMO_THEME_URL', 'https://page.themespride.com/law-firm-attorney-pro/' );
    }
    if ( ! defined( 'LAWYER_HUB_DOCS_THEME_URL' ) ) {
        define( 'LAWYER_HUB_DOCS_THEME_URL', 'https://page.themespride.com/demo/docs/law-firm-attorney-lite/' );
    }
    if ( ! defined( 'LAWYER_HUB_DOCS_URL' ) ) {
        define( 'LAWYER_HUB_DOCS_URL', 'https://page.themespride.com/demo/docs/law-firm-attorney-lite/' );
    }
    if ( ! defined( 'LAWYER_HUB_RATE_THEME_URL' ) ) {
        define( 'LAWYER_HUB_RATE_THEME_URL', 'https://wordpress.org/support/theme/law-firm-attorney/reviews/#new-post' );
    }
    if ( ! defined( 'LAWYER_HUB_SUPPORT_THEME_URL' ) ) {
        define( 'LAWYER_HUB_SUPPORT_THEME_URL', 'https://wordpress.org/support/theme/law-firm-attorney' );
    }
    if ( ! defined( 'LAWYER_HUB_CHANGELOG_THEME_URL' ) ) {
        define( 'LAWYER_HUB_CHANGELOG_THEME_URL', get_stylesheet_directory() . '/readme.txt' );
    }

    define('LAW_FIRM_ATTORNEY',__('https://www.themespride.com/products/free-law-firm-wordpress-theme','law-firm-attorney') );
    if ( ! function_exists( 'law_firm_attorney_credit' ) ) {
        function law_firm_attorney_credit(){
            echo "<a href=".esc_url(LAW_FIRM_ATTORNEY)." target='_blank'>".esc_html__(get_theme_mod('lawyer_hub_footer_text',__('Law Firm Attorney WordPress Theme','law-firm-attorney')))."</a>";
        }
    }

}
add_action( 'after_setup_theme', 'law_firm_attorney_theme_setup' );