<?php
if ( ! function_exists( 'leonspharmacy_setup' ) ) :

function leonspharmacy_setup() {

    /*
     * Make theme available for translation.
     * Translations can be filed in the /languages/ directory.
     */
    /* Pinegrow generated Load Text Domain Begin */
    load_theme_textdomain( 'leonpharmacy', get_template_directory() . '/languages' );
    /* Pinegrow generated Load Text Domain End */

    // Add default posts and comments RSS feed links to head.
    add_theme_support( 'automatic-feed-links' );

    /*
     * Let WordPress manage the document title.
     */
    add_theme_support( 'title-tag' );
    
    /*
     * Enable support for Post Thumbnails on posts and pages.
     */
    add_theme_support( 'post-thumbnails' );
    //Support custom logo
    add_theme_support( 'custom-logo' );

    // Add menus.
    register_nav_menus( array(
        'primary' => __( 'Primary Menu', 'leonspharmacy' ),
        'social'  => __( 'Social Links Menu', 'leonspharmacy' ),
    ) );

/*
     * Register custom menu locations
     */
    /* Pinegrow generated Register Menus Begin */

    register_nav_menu(  'primary', __( 'Main menu', 'leonpharmacy' )  );

    register_nav_menu(  'leon_pharmacy', __( 'Main Footer Menu', 'leonpharmacy' )  );

    /* Pinegrow generated Register Menus End */
    
/*
    * Set image sizes
     */
    /* Pinegrow generated Image sizes Begin */

    /* Pinegrow generated Image sizes End */
    
    /*
     * 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'
    ) );

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

    /*
     * Enable support for Page excerpts.
     */
     add_post_type_support( 'page', 'excerpt' );
}
endif; // leonspharmacy_setup

add_action( 'after_setup_theme', 'leonspharmacy_setup' );


if ( ! function_exists( 'leonspharmacy_init' ) ) :

function leonspharmacy_init() {

    
    // Use categories and tags with attachments
    register_taxonomy_for_object_type( 'category', 'attachment' );
    register_taxonomy_for_object_type( 'post_tag', 'attachment' );

    /*
     * Register custom post types. You can also move this code to a plugin.
     */
    /* Pinegrow generated Custom Post Types Begin */

    register_post_type('contact_message', array(
        'labels' => 
            array(
                'name' => __( 'Messages', 'leonpharmacy' ),
                'singular_name' => __( 'Message', 'leonpharmacy' )
            ),
        'public' => false,
        'supports' => array( 'title', 'editor', 'author' ),
        'show_in_rest' => false,
        'show_ui' => true,
        'show_in_menu' => true
    ));

    /* Pinegrow generated Custom Post Types End */
    
    /*
     * Register custom taxonomies. You can also move this code to a plugin.
     */
    /* Pinegrow generated Taxonomies Begin */

    /* Pinegrow generated Taxonomies End */

}
endif; // leonspharmacy_setup

add_action( 'init', 'leonspharmacy_init' );


if ( ! function_exists( 'leonspharmacy_custom_image_sizes_names' ) ) :

function leonspharmacy_custom_image_sizes_names( $sizes ) {

    /*
     * Add names of custom image sizes.
     */
    /* Pinegrow generated Image Sizes Names Begin*/
    /* This code will be replaced by returning names of custom image sizes. */
    /* Pinegrow generated Image Sizes Names End */
    return $sizes;
}
add_action( 'image_size_names_choose', 'leonspharmacy_custom_image_sizes_names' );
endif;// leonspharmacy_custom_image_sizes_names



if ( ! function_exists( 'leonspharmacy_widgets_init' ) ) :

function leonspharmacy_widgets_init() {

    /*
     * Register widget areas.
     */
    /* Pinegrow generated Register Sidebars Begin */

    register_sidebar( array(
        'name' => __( 'Archive', 'leonpharmacy' ),
        'id' => 'archive',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h3 class="widgettitle">',
        'after_title' => '</h3>'
    ) );

    /* Pinegrow generated Register Sidebars End */
}
add_action( 'widgets_init', 'leonspharmacy_widgets_init' );
endif;// leonspharmacy_widgets_init



if ( ! function_exists( 'leonspharmacy_customize_register' ) ) :

function leonspharmacy_customize_register( $wp_customize ) {
    // Do stuff with $wp_customize, the WP_Customize_Manager object.

    /* Pinegrow generated Customizer Controls Begin */

    /* Pinegrow generated Customizer Controls End */

}
add_action( 'customize_register', 'leonspharmacy_customize_register' );
endif;// leonspharmacy_customize_register


if ( ! function_exists( 'leonspharmacy_enqueue_scripts' ) ) :
    function leonspharmacy_enqueue_scripts() {

        /* Pinegrow generated Enqueue Scripts Begin */

    wp_deregister_script( 'leonpharmacy-app' );
    wp_enqueue_script( 'leonpharmacy-app', get_template_directory_uri() . '/assets/js/app.js', [], '1.5', true);

    /* Pinegrow generated Enqueue Scripts End */

        /* Pinegrow generated Enqueue Styles Begin */

    wp_deregister_style( 'leonpharmacy-styles' );
    wp_enqueue_style( 'leonpharmacy-styles', get_template_directory_uri() . '/assets/css/styles.css', [], '1.5', 'all');

    wp_deregister_style( 'leonpharmacy-style' );
    wp_enqueue_style( 'leonpharmacy-style', get_bloginfo('stylesheet_url'), [], '1.5', 'all');

    /* Pinegrow generated Enqueue Styles End */

    }
    add_action( 'wp_enqueue_scripts', 'leonspharmacy_enqueue_scripts' );
endif;

function pgwp_sanitize_placeholder($input) { return $input; }
/*
 * Resource files included by Pinegrow.
 */
/* Pinegrow generated Include Resources Begin */
require_once "inc/custom.php";
if( !class_exists( 'PG_Helper_v2' ) ) { require_once "inc/wp_pg_helpers.php"; }
if( !class_exists( 'PG_Blocks_v2' ) ) { require_once "inc/wp_pg_blocks_helpers.php"; }
if( !class_exists( 'PG_Simple_Form_Mailer' ) ) { require_once "inc/wp_simple_form_mailer.php"; }
if( !class_exists( 'PG_Pagination' ) ) { require_once "inc/wp_pg_pagination.php"; }
if( !class_exists( 'PG_Smart_Walker_Nav_Menu' ) ) { require_once "inc/wp_smart_navwalker.php"; }

    /* Pinegrow generated Include Resources End */

/* Creating Editor Blocks with Pinegrow */

if ( ! function_exists('leonspharmacy_blocks_init') ) :
function leonspharmacy_blocks_init() {
    // Register blocks. Don't edit anything between the following comments.
    /* Pinegrow generated Register Pinegrow Blocks Begin */
    require_once 'blocks/contact-block/contact-block_register.php';
    require_once 'blocks/sidebar-heading/sidebar-heading_register.php';

    /* Pinegrow generated Register Pinegrow Blocks End */
}
add_action('init', 'leonspharmacy_blocks_init');
endif;

/* End of creating Editor Blocks with Pinegrow */


/* Register Blocks Categories */

function leonspharmacy_register_blocks_categories( $categories ) {

    // Don't edit anything between the following comments.
    /* Pinegrow generated Register Blocks Category Begin */

$categories = array_merge( $categories, array( array(
        'slug' => 'Leon Pharmacy Blocks',
        'title' => __( 'Leon Pharmacy Blocks', 'leonpharmacy' )
    ) ) );

$categories = array_merge( $categories, array( array(
        'slug' => 'archive',
        'title' => __( 'Archive', 'leonpharmacy' )
    ) ) );

    /* Pinegrow generated Register Blocks Category End */
    
    return $categories;
}
add_action( version_compare('5.8', get_bloginfo('version'), '<=' ) ? 'block_categories_all' : 'block_categories', 'leonspharmacy_register_blocks_categories');

/* End of registering Blocks Categories */

?>