__( 'Primary Menu', 'vegan' ),
'footer' => __( 'Footer Menu', 'vegan' ),
) );
/*
* 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',
) );
// Add support for Block Styles.
add_theme_support( 'wp-block-styles' );
add_theme_support( 'editor-styles' );
// add the visual editor to resemble the theme style
add_editor_style( 'css/editor-style.css' );
// add custom background
add_theme_support( 'custom-background',
array ('default-color' => '#ffffff')
);
// add content width
global $content_width;
if ( ! isset( $content_width ) ) {
$content_width = 900;
}
// add custom header
add_theme_support( 'custom-header', array (
'default-image' => '',
'random-default' => '',
'flex-height' => true,
'flex-width' => true,
'uploads' => true,
'width' => 900,
'height' => 100,
'default-text-color' => '#000000',
'wp-head-callback' => 'vegan_header_style',
) );
// add custom logo
add_theme_support( 'custom-logo', array (
'width' => 75,
'height' => 75,
'flex-height' => true,
'flex-width' => true,
) );
}
endif; // vegan_setup
add_action( 'after_setup_theme', 'vegan_setup' );
if ( ! function_exists( 'vegan_sanitize_checkbox' ) ) :
/**
* Sanitization callback for 'checkbox' type controls. This callback sanitizes `$checked`
* as a boolean value, either TRUE or FALSE.
*
* @param bool $checked Whether the checkbox is checked.
* @return bool Whether the checkbox is checked.
*/
function vegan_sanitize_checkbox( $checked ) {
// Boolean check.
return ( ( isset( $checked ) && true == $checked ) ? true : false );
}
endif; // vegan_sanitize_checkbox
if ( ! function_exists( 'vegan_sanitize_html' ) ) :
function vegan_sanitize_html( $html ) {
return wp_filter_post_kses( $html );
}
endif; // vegan_sanitize_html
if ( ! function_exists( 'vegan_sanitize_url' ) ) :
function vegan_sanitize_url( $url ) {
return esc_url_raw( $url );
}
endif; // vegan_sanitize_url
/**
* Register theme settings in the customizer
*/
function vegan_customize_register( $wp_customize ) {
/**
* Add Slider Section
*/
$wp_customize->add_section(
'vegan_slider_section',
array(
'title' => __( 'Slider', 'vegan' ),
'capability' => 'edit_theme_options',
)
);
// Add display slider option
$wp_customize->add_setting(
'vegan_slider_display',
array(
'default' => 0,
'sanitize_callback' => 'vegan_sanitize_checkbox',
)
);
$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'vegan_slider_display',
array(
'label' => __( 'Display Slider on a Static Front Page', 'vegan' ),
'section' => 'vegan_slider_section',
'settings' => 'vegan_slider_display',
'type' => 'checkbox',
)
)
);
for ($i = 1; $i <= 3; ++$i) {
$slideContentId = 'vegan_slide'.$i.'_content';
$slideImageId = 'vegan_slide'.$i.'_image';
$defaultSliderImagePath = get_template_directory_uri().'/images/slider/'.$i.'.jpg';
// Add Slide Content
$wp_customize->add_setting(
$slideContentId,
array(
'sanitize_callback' => 'vegan_sanitize_html',
)
);
$wp_customize->add_control( new WP_Customize_Control( $wp_customize, $slideContentId,
array(
'label' => sprintf( esc_html__( 'Slide #%s Content', 'vegan' ), $i ),
'section' => 'vegan_slider_section',
'settings' => $slideContentId,
'type' => 'textarea',
)
)
);
// Add Slide Background Image
$wp_customize->add_setting( $slideImageId,
array(
'default' => $defaultSliderImagePath,
'sanitize_callback' => 'vegan_sanitize_url'
)
);
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, $slideImageId,
array(
'label' => sprintf( esc_html__( 'Slide #%s Image', 'vegan' ), $i ),
'section' => 'vegan_slider_section',
'settings' => $slideImageId,
)
)
);
}
/**
* Add Footer Section
*/
$wp_customize->add_section(
'vegan_footer_section',
array(
'title' => __( 'Footer', 'vegan' ),
'capability' => 'edit_theme_options',
)
);
// Add footer copyright text
$wp_customize->add_setting(
'vegan_footer_copyright',
array(
'default' => '',
'sanitize_callback' => 'sanitize_text_field',
)
);
$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'vegan_footer_copyright',
array(
'label' => __( 'Copyright Text', 'vegan' ),
'section' => 'vegan_footer_section',
'settings' => 'vegan_footer_copyright',
'type' => 'text',
)
)
);
/**
* Add Animations Section
*/
$wp_customize->add_section(
'vegan_animations_display',
array(
'title' => __( 'Animations', 'vegan' ),
'capability' => 'edit_theme_options',
)
);
// Add display Animations option
$wp_customize->add_setting(
'vegan_animations_display',
array(
'default' => 1,
'sanitize_callback' => 'vegan_sanitize_checkbox',
)
);
$wp_customize->add_control( new WP_Customize_Control( $wp_customize,
'vegan_animations_display',
array(
'label' => __( 'Enable Animations', 'vegan' ),
'section' => 'vegan_animations_display',
'settings' => 'vegan_animations_display',
'type' => 'checkbox',
)
)
);
}
add_action('customize_register', 'vegan_customize_register');
/**
* the main function to load scripts in the Vegan theme
* if you add a new load of script, style, etc. you can use that function
* instead of adding a new wp_enqueue_scripts action for it.
*/
function vegan_load_scripts() {
// load main stylesheet.
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css', array( ) );
wp_enqueue_style( 'animate-css', get_template_directory_uri() . '/css/animate.css', array( ) );
wp_enqueue_style( 'vegan-style', get_stylesheet_uri(), array() );
wp_enqueue_style( 'vegan-fonts', vegan_fonts_url(), array(), null );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
// Load Utilities JS Script
wp_enqueue_script( 'viewportchecker', get_template_directory_uri() . '/js/viewportchecker.js', array( 'jquery' ) );
wp_enqueue_script( 'vegan-utilities', get_template_directory_uri() . '/js/utilities.js',
array( 'jquery', 'viewportchecker' ) );
// Load Slider JS Script
wp_enqueue_script( 'jquery-easing', get_template_directory_uri() . '/js/jquery.easing.1.3.js', array( 'jquery' ) );
wp_enqueue_script( 'ayaSlider', get_template_directory_uri() . '/js/ayaSlider.js', array( 'jquery', 'jquery-easing' ) );
$data = array(
'loading_effect' => ( get_theme_mod('vegan_animations_display', 1) == 1 ),
);
wp_localize_script('vegan-utilities', 'vegan_options', $data);
}
add_action( 'wp_enqueue_scripts', 'vegan_load_scripts' );
/**
* Load google font url used in the Vegan theme
*/
function vegan_fonts_url() {
$fonts_url = '';
/* Translators: If there are characters in your language that are not
* supported by PT Sans, translate this to 'off'. Do not translate
* into your own language.
*/
$cantarell = _x( 'on', 'PT Sans font: on or off', 'vegan' );
if ( 'off' !== $cantarell ) {
$font_families = array();
$font_families[] = 'PT Sans';
$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,cyrillic-ext,cyrillic,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' );
}
return $fonts_url;
}
/**
* Display website's logo image
*/
function vegan_show_website_logo_image_and_title() {
if ( has_custom_logo() ) {
the_custom_logo();
}
$header_text_color = get_header_textcolor();
if ( 'blank' !== $header_text_color ) {
echo '';
}
}
/**
* Displays the copyright text.
*/
function vegan_show_copyright_text() {
$footerText = get_theme_mod('vegan_footer_copyright', null);
if ( !empty( $footerText ) ) {
echo esc_html( $footerText ) . ' | ';
}
}
/**
* widgets-init action handler. Used to register widgets and register widget areas
*/
function vegan_widgets_init() {
// Register Sidebar Widget.
register_sidebar( array (
'name' => __( 'Sidebar Widget Area', 'vegan'),
'id' => 'sidebar-widget-area',
'description' => __( 'The sidebar widget area', 'vegan'),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
) );
// Register Footer Column #1
register_sidebar( array (
'name' => __( 'Footer Column #1', 'vegan' ),
'id' => 'footer-column-1-widget-area',
'description' => __( 'The Footer Column #1 widget area', 'vegan' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
) );
// Register Footer Column #2
register_sidebar( array (
'name' => __( 'Footer Column #2', 'vegan' ),
'id' => 'footer-column-2-widget-area',
'description' => __( 'The Footer Column #2 widget area', 'vegan' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
) );
// Register Footer Column #3
register_sidebar( array (
'name' => __( 'Footer Column #3', 'vegan' ),
'id' => 'footer-column-3-widget-area',
'description' => __( 'The Footer Column #3 widget area', 'vegan' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'vegan_widgets_init' );
/**
* Displays the slider
* Get the Slider Images from the latest Post Thumbnails
*/
function vegan_display_slider() {
?>