esc_html__('Header menu', 'basecraft'), 'footer' => esc_html__('Footer menu', 'basecraft'), ) ); add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script', 'navigation-widgets', ) ); //FOR WOOCOMERCE SUPPORT add_theme_support( 'woocommerce' ); // FOR AVATAR add_theme_support('avatar'); //ADD SUPPORT FOR BLOCK STYLES (GUTERNBURG) add_theme_support( 'wp-block-styles' ); //ADD SUPPORT FOR WIDE AND FULL ALIGNMENT add_theme_support( 'align-wide' ); //ADD SUPPORT FOR RESPONSIVE EMBEDDED CONTENT add_theme_support( 'responsive-embeds' ); } } add_action('after_setup_theme', 'basecraft_setup'); //END THEME SETUP //START ENQUEUE STYLE & SCRIPTS FILES function basecraft_enqueue_style_script() { //STYLE wp_enqueue_style('basecraft-animate-on-scroll-style', get_template_directory_uri() . '/assets/css/basecraft-animate-on-scroll.css', array(), time()); wp_enqueue_style('basecraft-my-custom', get_template_directory_uri() . '/assets/css/basecraft-my-custom.css', array(), time()); //SCRIPT wp_enqueue_script('basecraft-animate-on-scroll-script', get_template_directory_uri() . '/assets/js/basecraft-animate-on-scroll.js', array(), time()); wp_enqueue_script('basecraft-my-script', get_template_directory_uri() . '/assets/js/basecraft-my-script.js', array('jquery'), time()); } add_action('wp_enqueue_scripts', 'basecraft_enqueue_style_script'); //END - ENQUEUE STYLE & SCRIPTS FILES // CREATE CUSTOMIZER IN THEME SETTING add_action('customize_register', 'basecraft_custom_site_identity_logos'); function basecraft_custom_site_identity_logos($wp_customize) { // HEADER LOGO $wp_customize->add_setting('basecraft_site_header_logo', array( 'default' => '', 'sanitize_callback' => 'absint', )); $wp_customize->add_control(new WP_Customize_Media_Control($wp_customize, 'basecraft_site_header_logo', array( 'label' => __('Header Logo', 'basecraft'), 'section' => 'title_tagline', // SITE IDENTITY SECTION 'mime_type' => 'image', ))); // END, HEADER LOGO // FOOTER LOGO $wp_customize->add_setting('basecraft_site_footer_logo', array( 'default' => '', 'sanitize_callback' => 'absint', )); $wp_customize->add_control(new WP_Customize_Media_Control($wp_customize, 'basecraft_site_footer_logo', array( 'label' => __('Footer Logo', 'basecraft'), 'section' => 'title_tagline', 'mime_type' => 'image', ))); // END, FOOTER LOGO // ADD NEW SECTION "COLOR" UNDER CUSTOMIZER $wp_customize->add_section( 'basecraft_color_section', array( 'title' => __( 'Color', 'basecraft' ), 'priority' => 30, ) ); // CREATE COLOR SETTING ARRAY WITH DEFAULTS $basecraft_color_settings = array( 'basecraft_primary_color' => array( 'label' => __( 'Primary Color', 'basecraft' ), 'default' => '#ffffff', ), 'basecraft_secondary_color' => array( 'label' => __( 'Secondary Color', 'basecraft' ), 'default' => '#000000', ), 'basecraft_button_background_color' => array( 'label' => __( 'Button Background Color', 'basecraft' ), 'default' => '#000000', ), 'basecraft_button_hover_background_color' => array( 'label' => __( 'Button Hover Background Color', 'basecraft' ), 'default' => '#ffffff', ), 'basecraft_body_text_color' => array( 'label' => __( 'Body Text Color', 'basecraft' ), 'default' => '#000000', ), ); // ADD SETTING AND CONTROL FOR EACH COLOR foreach ( $basecraft_color_settings as $basecraft_color_setting_id => $basecraft_color_options ) { $wp_customize->add_setting( $basecraft_color_setting_id, array( 'default' => $basecraft_color_options['default'], 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $basecraft_color_setting_id, array( 'label' => $basecraft_color_options['label'], 'section' => 'basecraft_color_section', 'settings' => $basecraft_color_setting_id, ) ) ); } // END, ADD NEW SECTION "COLOR" UNDER CUSTOMIZER // ADD NEW SECTION "FONT" UNDER CUSTOMIZER $wp_customize->add_section( 'basecraft_font_section', array( 'title' => __( 'Font Setting', 'basecraft' ), 'priority' => 35, ) ); // LIST OF FONTS $basecraft_font_choices = array( 'Arial' => 'Arial', 'Verdana' => 'Verdana', 'Helvetica' => 'Helvetica', 'Times New Roman' => 'Times New Roman', 'Georgia' => 'Georgia', 'Courier New' => 'Courier New', 'Trebuchet MS' => 'Trebuchet MS', 'Tahoma' => 'Tahoma', 'Palatino Linotype' => 'Palatino Linotype', 'Garamond' => 'Garamond', 'Impact' => 'Impact', 'Comic Sans MS' => 'Comic Sans MS', 'Lucida Sans Unicode' => 'Lucida Sans Unicode', 'Arial Black' => 'Arial Black', 'Gill Sans' => 'Gill Sans', 'Segoe UI' => 'Segoe UI', 'Open Sans' => 'Open Sans', 'Roboto' => 'Roboto', 'Lato' => 'Lato', 'Montserrat' => 'Montserrat', 'Libre Baskerville' => 'Libre Baskerville', ); // HEADING FONT SETTING $wp_customize->add_setting( 'basecraft_font_for_heading', array( 'default' => 'Arial', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'basecraft_font_for_heading', array( 'label' => __( 'Heading Font:', 'basecraft' ), 'section' => 'basecraft_font_section', 'settings' => 'basecraft_font_for_heading', 'type' => 'select', 'choices' => $basecraft_font_choices, ) ); // BODY FONT SETTING $wp_customize->add_setting( 'basecraft_font_for_body', array( 'default' => 'Arial', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'basecraft_font_for_body', array( 'label' => __( 'Body Font:', 'basecraft' ), 'section' => 'basecraft_font_section', 'settings' => 'basecraft_font_for_body', 'type' => 'select', 'choices' => $basecraft_font_choices, ) ); // END, ADD NEW SECTION "FONT" UNDER CUSTOMIZER // ADD NEW SECTION "SOCIAL MEDIA" UNDER CUSTOMIZER $wp_customize->add_section('basecraft_social_media_section', array( 'title' => __('Social Media (For footer)', 'basecraft'), 'priority' => 160, )); // ADD ARRAY FOR THE SOCIAL MEDIA ICONS $basecraft_social_icon_data = array( 'facebook' => __('Facebook', 'basecraft'), 'instagram' => __('Instagram', 'basecraft'), 'linkedin' => __('LinkedIn', 'basecraft'), 'twitter' => __('X', 'basecraft'), ); // END, ADD ARRAY FOR THE SOCIAL MEDIA ICONS foreach ($basecraft_social_icon_data as $basecraft_social_icon_data_key => $basecraft_social_icon_label) { // SOCIAL ICON LINK SETTING $wp_customize->add_setting("basecraft_{$basecraft_social_icon_data_key}_link", array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control("basecraft_{$basecraft_social_icon_data_key}_link", array( 'label' => sprintf(__('%s Link', 'basecraft'), $basecraft_social_icon_label), 'section' => 'basecraft_social_media_section', 'type' => 'url', )); // END, SOCIAL ICON LINK SETTING // SOCIAL ICON IMAGE SETTING $wp_customize->add_setting("basecraft_{$basecraft_social_icon_data_key}_icon", array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control(new WP_Customize_Image_Control( $wp_customize, "basecraft_{$basecraft_social_icon_data_key}_icon", array( 'label' => sprintf(__('%s Icon', 'basecraft'), $basecraft_social_icon_label), 'section' => 'basecraft_social_media_section', 'settings'=> "basecraft_{$basecraft_social_icon_data_key}_icon", ) )); // END, SOCIAL ICON IMAGE SETTING } // END, ADD NEW SECTION "SOCIAL MEDIA" UNDER CUSTOMIZER // ADD NEW SECTION "FOOTER SECTION" UNDER CUSTOMIZER $wp_customize->add_section('basecraft_footer_section', array( 'title' => __('Footer Section', 'basecraft'), 'priority' => 160, )); // FIELD CREATE FOR FOOTER COPYRIGHT TEXT $wp_customize->add_setting('basecraft_copyright_text', array( 'default' => '© Lorem Ipsum', 'sanitize_callback' => 'wp_kses_post', )); $wp_customize->add_control('basecraft_copyright_text', array( 'label' => __('Copyright Text', 'basecraft'), 'section' => 'basecraft_footer_section', 'settings' => 'basecraft_copyright_text', 'type' => 'textarea', )); // END, ADD NEW SECTION "FOOTER SECTION" UNDER CUSTOMIZER // ADD NEW SECTION "404 PAGE" UNDER CUSTOMIZER $wp_customize->add_section('basecraft_404_section', array( 'title' => __('404 Page', 'basecraft'), 'priority' => 130, )); // 404 PAGE BANNER IMAGE $wp_customize->add_setting('basecraft_banner_image', array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'basecraft_banner_image', array( 'label' => __('Banner Image', 'basecraft'), 'section' => 'basecraft_404_section', 'settings' => 'basecraft_banner_image', ))); // 404 PAGE MAIN TITLE $wp_customize->add_setting('basecraft_main_title', array( 'default' => 'Sorry, Not Found', 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('basecraft_main_title', array( 'label' => __('Main Title', 'basecraft'), 'section' => 'basecraft_404_section', 'type' => 'text', )); // 404 PAGE NOT FOUND TEXT $wp_customize->add_setting('basecraft_notfound_text', array( 'default' => '404', 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('basecraft_notfound_text', array( 'label' => __('Not Found Text', 'basecraft'), 'section' => 'basecraft_404_section', 'type' => 'text', )); // 404 PAGE BUTTON URL $wp_customize->add_setting('basecraft_button_url', array( 'default' => home_url('/'), 'transport' => 'refresh', 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control('basecraft_button_url', array( 'label' => __('Button URL', 'basecraft'), 'section' => 'basecraft_404_section', 'type' => 'url', )); // 404 PAGE BUTTON TEXT $wp_customize->add_setting('basecraft_button_text', array( 'default' => 'Home', 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('basecraft_button_text', array( 'label' => __('Button Text', 'basecraft'), 'section' => 'basecraft_404_section', 'type' => 'text', )); // ADD NEW SECTION "404 PAGE" UNDER CUSTOMIZER } // END, CREATE CUSTOMIZER IN THEME SETTING // START - ENQUEUE BASECRAFT SETTINGS FONTS HEADING AND BODY function basecraft_enqueue_google_fonts() { $basecraft_font_for_heading = get_theme_mod('basecraft_font_for_heading','Arial'); $basecraft_font_for_body = get_theme_mod('basecraft_font_for_body','Arial'); $basecraft_fonts_to_enqueue = array(); if ($basecraft_font_for_heading) { $basecraft_fonts_to_enqueue[] = urlencode($basecraft_font_for_heading); } if ($basecraft_font_for_body) { $basecraft_fonts_to_enqueue[] = urlencode($basecraft_font_for_body); } if (!empty($basecraft_fonts_to_enqueue)) { $basecraft_fonts_url = 'https://fonts.googleapis.com/css2?family=' . implode('&family=', $basecraft_fonts_to_enqueue) . '&display=swap'; wp_enqueue_style( 'basecraft-google-fonts', $basecraft_fonts_url, array(), null ); $basecraft_font_custom_css = " :root { --font-body: '$basecraft_font_for_body', sans-serif; --font-heading: '$basecraft_font_for_heading', sans-serif; } "; wp_add_inline_style('basecraft-google-fonts', $basecraft_font_custom_css); } } add_action('wp_enqueue_scripts', 'basecraft_enqueue_google_fonts'); // END - ENQUEUE BASECRAFT SETTINGS FONTS HEADING AND BODY // START - ENQUEUE BASECRAFT SETTINGS COLOR PICKER add_action('wp_enqueue_scripts', 'basecraft_theme_setting_color_picker', 20); function basecraft_theme_setting_color_picker() { $basecraft_primary_color = get_theme_mod('basecraft_primary_color', '#ffffff'); $basecraft_secondary_color = get_theme_mod('basecraft_secondary_color', '#000000'); $basecraft_body_text_color = get_theme_mod('basecraft_body_text_color', '#000000'); $basecraft_button_background_color = get_theme_mod('basecraft_button_background_color', '#000000'); $basecraft_button_hover_background_color = get_theme_mod('basecraft_button_hover_background_color', '#ffffff'); $basecraft_custom_css = ''; if ( $basecraft_primary_color || $basecraft_secondary_color || $basecraft_body_text_color || $basecraft_button_background_color || $basecraft_button_hover_background_color ) { $basecraft_custom_css .= ':root {'; if ($basecraft_primary_color) { $basecraft_custom_css .= "--primary-color: {$basecraft_primary_color};"; } if ($basecraft_secondary_color) { $basecraft_custom_css .= "--secondary-color: {$basecraft_secondary_color};"; } if ($basecraft_body_text_color) { $basecraft_custom_css .= "--body-text-color: {$basecraft_body_text_color};"; } if ($basecraft_button_background_color) { $basecraft_custom_css .= "--button-bg-color: {$basecraft_button_background_color};"; } if ($basecraft_button_hover_background_color) { $basecraft_custom_css .= "--button-bg-hover-color: {$basecraft_button_hover_background_color};"; } $basecraft_custom_css .= '}'; } if ($basecraft_custom_css) { wp_add_inline_style('basecraft-my-custom', $basecraft_custom_css); } } // END - EBQUEUE BASECRAFT SETTINGS COLOR PICKER // START - THEME ACTIVATION TIME CREATE PAGES(HOME ,ABOUT US, CONTACT US), CATEGORY, POSTS AND SET POST NAME AS PERMALINK add_action('after_switch_theme', 'basecraft_activate'); function basecraft_activate() { $basecraft_theme_activation_file = get_template_directory() . '/basecraft_theme_activation_time.php'; if (file_exists($basecraft_theme_activation_file)) { require $basecraft_theme_activation_file; unlink($basecraft_theme_activation_file); } } // END - THEME ACTIVATION TIME CREATE PAGES(HOME ,ABOUT US, CONTACT US), CATEGORY, POSTS AND SET POST NAME AS PERMALINK // START - IN IMAGE TAG PUT ALT ATTRIBUTE add_action('wp_footer','basecraft_alt_attribute_add_in_image_tag'); function basecraft_alt_attribute_add_in_image_tag() { $basecraft_args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null, ); $basecraft_attachments = get_posts($basecraft_args); if ($basecraft_attachments) { foreach ($basecraft_attachments as $basecraft_post) { setup_postdata($basecraft_post); $basecraft_image_title = get_the_title($basecraft_post->ID); if(empty($basecraft_image_title)) { $basecraft_image_title = $basecraft_post->post_name; $basecraft_post_update = array( 'ID' => $basecraft_post->ID, 'post_title' => $basecraft_image_title ); wp_update_post( $basecraft_post_update ); } $basecraft_image_title = explode(".", $basecraft_image_title); $basecraft_image_title = $basecraft_image_title[0]; $basecraft_image_title = str_replace(array("png","jpg","svg","ico","jpeg"), "", $basecraft_image_title); if(empty (get_post_meta($basecraft_post->ID, '_wp_attachment_image_alt',true))) { update_post_meta($basecraft_post->ID, '_wp_attachment_image_alt', $basecraft_image_title); } } } } // END - IN IMAGE TAG PUT ALT ATTRIBUTE