<?php
/**
 * @package bz-multisatilet
 */
require_once get_template_directory() . "/dir/lib/bz_multi_satilet_customizer.php";

function bz_multi_satilet_style_js() {
    wp_enqueue_style('bootstrap', get_template_directory_uri() . '/dir/bootstrap/css/bootstrap.css');
    wp_enqueue_style('font-awesome', get_template_directory_uri() . '/css/font-awesome.css');
    wp_enqueue_style('bz-multisatilet-basic-style', get_stylesheet_uri());
    wp_enqueue_script('bootstrap', get_template_directory_uri() . '/dir/bootstrap/js/bootstrap.js', array('jquery'));
    wp_enqueue_script('bz-multisatilet-toggle', get_template_directory_uri() . '/dir/js/bz_multi_satilet_toggle.js', array('jquery'));
}

add_action('wp_enqueue_scripts', 'bz_multi_satilet_style_js');

if (!function_exists('bz_multi_satilet_setup')) :

    function bz_multi_satilet_setup() {
        add_theme_support('automatic-feed-links');
        add_theme_support('woocommerce');
        add_theme_support('post-thumbnails');
        add_theme_support('custom-header');
        add_theme_support('title-tag');
        add_theme_support("wp-block-styles");
        add_theme_support("responsive-embeds");
        add_theme_support("align-wide");
        add_theme_support('custom-logo', array(
            'height' => 480,
            'width'  => 720,
        ));
        register_nav_menus(array(
            'primary' => esc_html__('Primary Menu', 'bz-multisatilet'),
            'footer'  => esc_html__('Footer Menu', 'bz-multisatilet'),
        ));
        add_theme_support('custom-background', array(
            'default-color' => 'ffffff'
        ));

        /**
         * Add post-formats support.
         */
        add_theme_support(
                'post-formats',
                array(
                    'link',
                    'aside',
                    'gallery',
                    'image',
                    'quote',
                    'status',
                    'video',
                    'audio',
                    'chat',
                )
        );

        /*
         * Switch default core markup for search form, comment form, and comments
         * to output valid HTML5.
         */
        add_theme_support(
                'html5',
                array(
                    'comment-form',
                    'comment-list',
                    'gallery',
                    'caption',
                    'style',
                    'script',
                    'navigation-widgets',
                )
        );

        // Add theme support for selective refresh for widgets.
        add_theme_support('customize-selective-refresh-widgets');

        // Add support for Block Styles.
        add_theme_support('wp-block-styles');

        // Add support for full and wide align images.
        add_theme_support('align-wide');

        // Add support for responsive embedded content.
        add_theme_support('responsive-embeds');

        // Add support for custom line height controls.
        add_theme_support('custom-line-height');

        // Add support for experimental link color control.
        add_theme_support('experimental-link-color');

        // Add support for experimental cover block spacing.
        add_theme_support('custom-spacing');

        // Add support for custom units.
        // This was removed in WordPress 5.6 but is still required to properly support WP 5.5.
        add_theme_support('custom-units');

        add_theme_support('jetpack-content-options', array(
            'blog-display'       => 'content', // the default setting of the theme: 'content', 'excerpt' or array( 'content', 'excerpt' ) for themes mixing both display.
            'author-bio'         => true, // display or not the author bio: true or false.
            'author-bio-default' => false, // the default setting of the author bio, if it's being displayed or not: true or false (only required if false).
            'masonry'            => '.site-main', // a CSS selector matching the elements that triggers a masonry refresh if the theme is using a masonry layout.
            'post-details'       => array(
                'stylesheet' => 'themeslug-style', // name of the theme's stylesheet.
                'date'       => '.posted-on', // a CSS selector matching the elements that display the post date.
                'categories' => '.cat-links', // a CSS selector matching the elements that display the post categories.
                'tags'       => '.tags-links', // a CSS selector matching the elements that display the post tags.
                'author'     => '.byline', // a CSS selector matching the elements that display the post author.
                'comment'    => '.comments-link', // a CSS selector matching the elements that display the comment link.
            ),
            'featured-images'    => array(
                'archive'         => true, // enable or not the featured image check for archive pages: true or false.
                'archive-default' => false, // the default setting of the featured image on archive pages, if it's being displayed or not: true or false (only required if false).
                'post'            => true, // enable or not the featured image check for single posts: true or false.
                'post-default'    => false, // the default setting of the featured image on single posts, if it's being displayed or not: true or false (only required if false).
                'page'            => true, // enable or not the featured image check for single pages: true or false.
                'page-default'    => false, // the default setting of the featured image on single pages, if it's being displayed or not: true or false (only required if false).
            ),
        ));
    }

endif; // bz_multi_satilet_setup
add_action('after_setup_theme', 'bz_multi_satilet_setup');

function bz_multi_satilet_widgets_init() {

    register_sidebar(array(
        'name'          => esc_html__('Sidebar', 'bz-multisatilet'),
        'description'   => esc_html__('Appears on sidebar', 'bz-multisatilet'),
        'id'            => 'sidebar-1',
        'before_widget' => '',
        'before_title'  => '<h3 class="widget-title">',
        'after_title'   => '</h3><aside id="" class="widget">',
        'after_widget'  => '</aside>',
    ));
    register_sidebar(array(
        'name'          => esc_html__('Footer 1', 'bz-multisatilet'),
        'description'   => esc_html__('Appears on sidebar', 'bz-multisatilet'),
        'id'            => 'footer-1',
        'before_widget' => '',
        'before_title'  => '<h1 class="widget-title">',
        'after_title'   => '</h1><aside id="" class="widget">',
        'after_widget'  => '</aside>',
    ));
    register_sidebar(array(
        'name'          => esc_html__('Footer 2', 'bz-multisatilet'),
        'description'   => esc_html__('Appears on sidebar', 'bz-multisatilet'),
        'id'            => 'footer-2',
        'before_widget' => '',
        'before_title'  => '<h1 class="widget-title">',
        'after_title'   => '</h1><aside id="" class="widget">',
        'after_widget'  => '</aside>',
    ));
    register_sidebar(array(
        'name'          => esc_html__('Footer 3', 'bz-multisatilet'),
        'description'   => esc_html__('Appears on sidebar', 'bz-multisatilet'),
        'id'            => 'footer-3',
        'before_widget' => '',
        'before_title'  => '<h1 class="widget-title">',
        'after_title'   => '</h1><aside id="" class="widget">',
        'after_widget'  => '</aside>',
    ));
    register_sidebar(array(
        'name'          => esc_html__('Footer 4', 'bz-multisatilet'),
        'description'   => esc_html__('Appears on sidebar', 'bz-multisatilet'),
        'id'            => 'footer-4',
        'before_widget' => '',
        'before_title'  => '<h1 class="widget-title">',
        'after_title'   => '</h1><aside id="" class="widget">',
        'after_widget'  => '</aside>',
    ));
}

add_action('widgets_init', 'bz_multi_satilet_widgets_init');
if (!isset($content_width))
    $content_width = 900;

add_action('admin_menu', 'bz_multi_satilet_pros');

function bz_multi_satilet_pros() {
    add_theme_page(esc_html__('bz-multisatilet Details', 'bz-multisatilet'), esc_html__('bz-multisatilet Details', 'bz-multisatilet'), 'edit_theme_options', 'bz_multi_satilet_pro', 'bz_multi_satilet_pro_details');
}

function bz_multi_satilet_pro_details() {
    ?>
    <div class="wrap col-md-8">
    <?php $proimage = "" . get_template_directory_uri() . "/images/themesbunch.jpg"; ?>
        <div><a target="_blank" href="<?php echo esc_url(bz_multi_satilet_PROURL); ?>"><img src="<?php echo esc_url($proimage); ?>"></a></div><br>
        <div><a class="button button-primary button-large" href="<?php echo esc_url(bz_multi_satilet_PROURL); ?>" target="_blank"><?php esc_html_e('Upgrade To Pro', 'bz-multisatilet'); ?></a></div><br>
        <div><a class="button button-primary button-large" href="<?php echo esc_url(bz_multi_satilet_DEMOURL); ?>" target="_blank"><?php esc_html_e('Live Demo', 'bz-multisatilet'); ?></a></div><br>
        <div><a class="button button-primary button-large" href="<?php echo esc_url(bz_multi_satilet_DOCURL); ?>" target="_blank"><?php esc_html_e('Documentation', 'bz-multisatilet'); ?></a></div>
    </div> 
<?php } ?>
<?php
add_image_size('home-banner-size', 1600, 550, true);
add_image_size('home-box-size', 400, 250, true);
add_image_size('inner-page-banner', 1600, 450, true);

function bz_multi_satilet_get_excerpt($postid, $post_count_size) {
    $excerpt = get_post_field('post_content', $postid);
    ;
    $excerpt = preg_replace(" ([.*?])", '', $excerpt);
    $excerpt = strip_shortcodes($excerpt);
    $excerpt = strip_tags($excerpt);
    $excerpt = substr($excerpt, 0, $post_count_size);
    $excerpt = substr($excerpt, 0, strripos($excerpt, " "));
    return $excerpt;
}

/**
 * Registers an editor stylesheet in a sub-directory.
 */
function bz_multisatilet_add_editor_styles_sub_dir() {
    add_editor_style( trailingslashit( get_template_directory_uri() ) . '/css/editor-style.css' );
}
add_action( 'after_setup_theme', 'bz_multisatilet_add_editor_styles_sub_dir' );

function bz_multisatilet_register_block_extras() {
    if ( function_exists( 'register_block_style' ) ) {
        register_block_style( 'core/button', array(
            'name'  => 'bz-multisatilet-cta',
            'label' => esc_html__( 'Business CTA', 'bz-multisatilet' ),
        ) );
    }
    if ( function_exists( 'register_block_pattern' ) ) {
        register_block_pattern( 'bz-multisatilet/cta', array(
            'title'   => esc_html__( 'Call to action', 'bz-multisatilet' ),
            'content' => '<!-- wp:buttons --><div class="wp-block-buttons"><!-- wp:button --><div class="wp-block-button"><a class="wp-block-button__link">Get Started</a></div><!-- /wp:button --></div><!-- /wp:buttons -->',
        ) );
    }
}
add_action( 'init', 'bz_multisatilet_register_block_extras' );
?>