450,
'height' => 200,
'flex-width' => true,
'flex-height' => true,
);
add_theme_support( 'custom-logo', $custom_logo_defaults );
// Add theme support for Custom Header.
$custom_header_defaults = array('default-text-color' => 'ffffff');
add_theme_support( 'custom-header', $custom_header_defaults );
// Add theme support for Editor Style.
add_editor_style();
// Add theme support for Custom Background.
$custom_background_defaults = array(
'default-color' => '',
);
add_theme_support( 'custom-background', $custom_background_defaults );
// Set the default content width.
$GLOBALS['content_width'] = 960;
// This theme uses wp_nav_menu() in two locations
register_nav_menus( array(
'top' => __( 'Top Menu', 'amazin' ),
'main' => __( 'Main Menu', 'amazin' ),
) );
// 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',
) );
// WooCommerce
add_theme_support( 'woocommerce' );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
// Theme Activation Notice
global $pagenow;
if ( is_admin() && ('themes.php' == $pagenow) && isset( $_GET['activated'] ) ) {
add_action( 'admin_notices', 'amazin_activation_notice' );
}
// Disable block editor in widgets WP 5.8+
remove_theme_support( 'widgets-block-editor' );
add_theme_support('align-wide');
add_theme_support('responsive-embeds');
add_theme_support('wp-block-styles');
}
add_action( 'after_setup_theme', 'amazin_setup' );
// Notice after Theme Activation
function amazin_activation_notice() {
echo '
';
}
/**
* Add a pingback url auto-discovery header for singularly identifiable articles.
*/
function amazin_pingback_header() {
if ( is_singular() && pings_open() ) {
printf( '' . "\n", esc_url(get_bloginfo( 'pingback_url' )) );
}
}
add_action( 'wp_head', 'amazin_pingback_header' );
/*
** Enqueue scripts and styles
*/
function amazin_scripts() {
// Theme Stylesheet
wp_enqueue_style( 'amazin-style', get_stylesheet_uri() );
// FontAwesome Icons
wp_enqueue_style( 'fontawesome', get_theme_file_uri( '/assets/css/font-awesome.css' ) );
// Google Fonts
wp_enqueue_style( 'g-fonts', get_theme_file_uri( '/assets/css/g-fonts.css' ) );
// Slick Slider
wp_enqueue_style( 'slick', get_theme_file_uri( '/assets/css/slick.css' ) );
// Scrollbar
wp_enqueue_style( 'scrollbar', get_theme_file_uri( '/assets/css/perfect-scrollbar.css' ) );
// WooCommerce
wp_enqueue_style( 'amazin-woocommerce', get_theme_file_uri( '/assets/css/woocommerce.css' ) );
// Theme Responsive CSS
wp_enqueue_style( 'amazin-responsive', get_theme_file_uri( '/assets/css/responsive.css' ) );
// Enqueue Custom Scripts
wp_enqueue_script( 'amazin-plugins', get_theme_file_uri( '/assets/js/custom-plugins.js' ), array( 'jquery' ), false, true );
wp_enqueue_script( 'amazin-custom-scripts', get_theme_file_uri( '/assets/js/custom-scripts.js' ), array( 'jquery' ), false, true );
// Comment reply link
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'amazin_scripts' );
/*
** Register widget areas.
*/
function amazin_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar Right', 'amazin' ),
'id' => 'sidebar-right',
'description' => __( 'Add widgets here to appear in your sidebar.', 'amazin' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Sidebar Left', 'amazin' ),
'id' => 'sidebar-left',
'description' => __( 'Add widgets here to appear in your sidebar.', 'amazin' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Slide Out Sidebar', 'amazin' ),
'id' => 'sidebar-alt',
'description' => __( 'Add widgets here to appear in your alternative/fixed sidebar.', 'amazin' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer Widgets', 'amazin' ),
'id' => 'footer-widgets',
'description' => __( 'Add widgets here to appear in your footer.', 'amazin' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
}
add_action( 'widgets_init', 'amazin_widgets_init' );
/*
** Custom Image Sizes
*/
add_image_size( 'amazin-slider-full-thumbnail', 1080, 540, true );
add_image_size( 'amazin-full-thumbnail', 1140, 0, true );
add_image_size( 'amazin-grid-thumbnail', 500, 330, true );
add_image_size( 'amazin-single-navigation', 75, 75, true );
/*
** Top Menu Fallback
*/
function top_menu_fallback() {
if ( current_user_can( 'edit_theme_options' ) ) {
echo '';
}
}
/*
** Main Menu Fallback
*/
function amazin_main_menu_fallback() {
if ( current_user_can( 'edit_theme_options' ) ) {
echo '';
}
}
/*
** Custom Excerpt Length
*/
function amazin_excerpt_length( $link ) {
if ( is_admin() ) {
return $link;
}
$link = sprintf( '%2$s
',
esc_url( get_permalink( get_the_ID() ) ),
/* translators: %s: Name of current post */
sprintf( __( 'Continue reading "%s"', 'amazin' ), get_the_title( get_the_ID() ) )
);
return 2000;
}
add_filter( 'excerpt_length', 'amazin_excerpt_length', 999 );
function amazin_new_excerpt( $link ) {
if ( is_admin() ) {
return $link;
}
$link = sprintf( '%2$s
',
esc_url( get_permalink( get_the_ID() ) ),
/* translators: %s: Name of current post */
sprintf( __( 'Continue reading "%s"', 'amazin' ), get_the_title( get_the_ID() ) )
);
return '...';
}
add_filter( 'excerpt_more', 'amazin_new_excerpt' );
if ( ! function_exists( 'amazin_excerpt' ) ) {
function amazin_excerpt( $limit = 50 ) {
echo ''. esc_html(wp_trim_words(get_the_excerpt(), $limit)) .'
';
}
}
/*
** Custom Functions
*/
// Page Layouts
function amazin_page_layout() {
if ( is_active_sidebar( 'sidebar-left' ) && is_active_sidebar( 'sidebar-right' ) ) {
return 'col1-lrsidebar';
} else if ( is_active_sidebar( 'sidebar-left' ) ) {
return 'col1-lsidebar';
} else if ( is_active_sidebar( 'sidebar-right' ) ) {
return 'col1-rsidebar';
}
}
// HEX to RGBA Converter
function amazin_hex2rgba( $color, $opacity = 1 ) {
// remove '#' from string
$color = substr( $color, 1 );
// get values from string
$hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
// convert HEX to RGB
$rgb = array_map( 'hexdec', $hex );
// convert HEX to RGBA
$output = 'rgba('. implode( ",", $rgb ) .', '. $opacity .')';
return $output;
}
// Social Media
if ( ! function_exists( 'amazin_social_media' ) ) {
function amazin_social_media( $social_class='' ) {
?>
term_id;
// Random
if ( $orderby === 'random' ) {
$args = array(
'post_type' => 'post',
'post__not_in' => array( $post->ID ),
'orderby' => 'rand',
'posts_per_page' => 3,
'ignore_sticky_posts' => 1,
'meta_query' => array(
array(
'key' => '_thumbnail_id',
'compare' => 'EXISTS'
),
)
);
// Similar
} else {
$args = array(
'post_type' => 'post',
'category__in' => array( $first_category ),
'post__not_in' => array( $post->ID ),
'orderby' => 'rand',
'posts_per_page' => 3,
'ignore_sticky_posts' => 1,
'meta_query' => array(
array(
'key' => '_thumbnail_id',
'compare' => 'EXISTS'
),
)
);
}
$similar_posts = new WP_Query( $args );
if ( $similar_posts->have_posts() ) {
?>
have_posts() ) {
$similar_posts->the_post();
if ( has_post_thumbnail() ) {
?>