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 '
'; echo '

'. esc_html__( 'Thank you for choosing Amazin! Now, we higly recommend you to visit our welcome page.', 'amazin' ) .'

'; echo '

'. esc_html__( 'Get Started with Amazin', 'amazin' ) .'

'; 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( '', 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( '', 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() ) { ?>
  • >

  • >

    $depth, 'max_depth' => $args['max_depth']) ) ); ?>
    comment_approved == '0' ) : ?>

    '; echo '
    '; } add_action( 'woocommerce_before_main_content', 'amazin_woocommerce_output_content_wrapper', 5 ); // wrap woocommerce content - end function amazin_woocommerce_output_content_wrapper_end() { echo '
    '; echo ''; } add_action( 'woocommerce_after_main_content', 'amazin_woocommerce_output_content_wrapper_end', 50 ); // Remove Default Sidebar remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 ); // Change product grid columns if ( ! function_exists('amazin_woocommerce_grid_columns') ) { function amazin_woocommerce_grid_columns() { return 3; } } add_filter('loop_shop_columns', 'amazin_woocommerce_grid_columns'); // Change related products grid columns add_filter( 'woocommerce_output_related_products_args', 'amazin_related_products_args' ); function amazin_related_products_args( $args ) { $args['posts_per_page'] = 3; $args['columns'] = 3; return $args; } // Remove Breadcrumbs if ( ! function_exists('amazin_remove_wc_breadcrumbs') ) { function amazin_remove_wc_breadcrumbs() { remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 ); } } add_action( 'init', 'amazin_remove_wc_breadcrumbs' ); // Shop Per Page function amazin_set_shop_post_per_page() { return 9; } add_filter( 'loop_shop_per_page', 'amazin_set_shop_post_per_page', 20 ); // Pagination remove_action( 'woocommerce_pagination', 'woocommerce_pagination', 10 ); function woocommerce_pagination() { get_template_part( 'templates/grid/blog', 'pagination' ); } add_action( 'woocommerce_pagination', 'woocommerce_pagination', 10 ); /* ** Incs: Theme Customizer */ // Customizer require get_parent_theme_file_path( '/inc/customizer/customizer.php' ); require get_parent_theme_file_path( '/inc/customizer/customizer-defaults.php' ); require get_parent_theme_file_path( '/inc/customizer/dynamic-css.php' ); // About Amazin require get_parent_theme_file_path( '/inc/about/about-amazin.php' ); // Extend Recent Posts Widget to show post thumbnails Class Amazin_Recent_Posts_Widget extends WP_Widget_Recent_Posts { function widget($args, $instance) { extract( $args ); $title = apply_filters('widget_title', empty($instance['title']) ? ('Recent Posts') : $instance['title'], $instance, $this->id_base); if( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) $number = 10; $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); if( $r->have_posts() ) : echo ent2ncr($before_widget); if( $title ) echo ent2ncr($before_title) . ent2ncr($title) . ent2ncr($after_title); ?> remove_control('display_header_text'); } add_action( 'customize_register', 'de_register', 11 ); /** * Shim for wp_body_open, ensuring backwards compatibility with versions of WordPress older than 5.2. */ if ( ! function_exists( 'wp_body_open' ) ) { function wp_body_open() { do_action( 'wp_body_open' ); } } /** * TGMPA */ require_once get_template_directory() . '/inc/tgmpa/class-tgm-plugin-activation.php'; function amazin_register_required_plugins() { $plugins = array( array( 'name' => 'Woocommerce', 'slug' => 'woocommerce', 'required' => false, ), array( 'name' => 'Contact Form 7', 'slug' => 'contact-form-7', 'required' => false, ), array( 'name' => 'MailChimp for WordPress', 'slug' => 'mailchimp-for-wp', 'required' => false, ), ); $config = array( 'id' => 'amazin', 'default_path' => '', 'menu' => 'tgmpa-install-plugins', 'has_notices' => true, 'dismissable' => true, 'dismiss_msg' => '', 'is_automatic' => false, 'message' => '', ); tgmpa( $plugins, $config ); } add_action( 'tgmpa_register', 'amazin_register_required_plugins' );