| Server IP : 103.48.194.25 / Your IP : 216.73.217.33 Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33 System : Linux VMHostDefault 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64 User : sieuthimay ( 1016) PHP Version : 8.2.20 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/sieuthimayasia.com/public_html/wp-content/themes/mtw-maycn/ |
Upload File : |
<?php
/**
* MTWTeam functions and definitions.
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package MTWTeam
*/
/**
* WordPress and PHP version compat.
*/
require get_theme_file_path( '/inc/version-compat.php' );
if ( ! function_exists( 'mtwfn_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function mtwfn_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on MTWTeam, use a find and replace
* to change 'maycn' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'maycn', get_theme_file_path( '/languages' ) );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for custom logo.
*
* @since MTWTeam 1.0.0
*/
add_theme_support( 'custom-logo', array(
'width' => 264,
'height' => 64,
'flex-height' => true,
) );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 90, 90 );
set_post_thumbnail_size( 100, 100 );
add_image_size( 'partner', 175, 95, true );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'maycn' ),
'mobile' => esc_html__( 'Mobile', 'maycn' ),
) );
/*
* 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',
) );
// Indicate widget sidebars can use selective refresh in the Customizer.
add_theme_support( 'customize-selective-refresh-widgets' );
// Add support Woocommerce.
add_theme_support( 'woocommerce' );
}
endif;
add_action( 'after_setup_theme', 'mtwfn_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function mtwfn_content_width() {
$GLOBALS['content_width'] = apply_filters( 'mtwfn_content_width', 640 );
}
add_action( 'after_setup_theme', 'mtwfn_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function mtwfn_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Home Products', 'maycn' ),
'id' => 'home-product',
'description' => esc_html__( 'Sản phẩm trang chủ.', 'maycn' ),
'before_widget' => '<div id="%1$s" class="section %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="section-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Menu Ngang', 'maycn' ),
'id' => 'header-menu',
'description' => esc_html__( 'Menu ngang header.', 'maycn' ),
'before_widget' => '',
'after_widget' => '',
//'before_title' => '<h3 class="section-title">',
//'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'maycn' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Thêm tiện ích ở đây.', 'maycn' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Topbar Left', 'maycn' ),
'id' => 'left-topbar',
'description' => esc_html__( 'Thêm tiện ích ở đây.', 'maycn' ),
'before_widget' => '<div id="%1$s" class="section %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="section-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Topbar Right', 'maycn' ),
'id' => 'right-topbar',
'description' => esc_html__( 'Thêm tiện ích ở đây.', 'maycn' ),
'before_widget' => '<div id="%1$s" class="section %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="section-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Header Right', 'maycn' ),
'id' => 'header-right',
'description' => esc_html__( 'Thêm hotline tại đây.', 'maycn' ),
'before_widget' => '<div id="%1$s" class="section %2$s">',
'after_widget' => '</div>',
//'before_title' => '<h3 class="section-title">',
//'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Header Cart', 'maycn' ),
'id' => 'header-cart',
'description' => esc_html__( 'Thêm tiện ích ở đây.', 'maycn' ),
'before_widget' => '<div id="%1$s" class="section %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="section-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Slider Section', 'maycn' ),
'id' => 'slider-section',
'description' => esc_html__( 'Thêm tiện ích ở đây.', 'maycn' ),
'before_widget' => '<div id="%1$s" class="section %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="section-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Trang chủ', 'maycn' ),
'id' => 'home-section',
'description' => esc_html__( 'Thêm tiện ích ở đây.', 'maycn' ),
'before_widget' => '<div id="%1$s" class="section %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="section-title clearfix">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Dưới mỗi bài viết', 'maycn' ),
'id' => 'under-single-post',
'description' => esc_html__( 'Thêm tiện ích ở đây.', 'maycn' ),
'before_widget' => '<div id="%1$s" class="section %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="section-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Dưới mỗi bài sản phẩm', 'maycn' ),
'id' => 'under-single-product',
'description' => esc_html__( 'Thêm tiện ích ở đây.', 'maycn' ),
'before_widget' => '<div id="%1$s" class="section %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="section-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Khu vực dưới nội dung', 'maycn' ),
'id' => 'bottom-content',
'description' => esc_html__( 'Thêm tiện ích ở đây.', 'maycn' ),
'before_widget' => '<div id="%1$s" class="section %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="section-title">',
'after_title' => '</h3>',
) );
register_sidebars( 4, array(
'name' => esc_html__( 'Chân trang %d', 'maycn' ),
'id' => 'footer',
'description' => esc_html__( 'Thêm tiện ích ở đây.', 'maycn' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'mtwfn_widgets_init' );
/**
* Register Fonts
*/
function mtwfn_google_fonts_url() {
$font_url = '';
/*
Translators: If there are characters in your language that are not supported
by chosen font(s), translate this to 'off'. Do not translate into your own language.
*/
if ( 'off' !== _x( 'on', 'Google font: on or off', 'maycn' ) ) {
$font_url = add_query_arg( 'family', urlencode( 'Roboto Condensed:300,400,400i,700&subset=vietnamese' ), '//fonts.googleapis.com/css' );
}
return $font_url;
}
/**
* Handles JavaScript detection.
*
* Adds a `js` class to the root `<html>` element when JavaScript is detected.
*
* @since MTWTeam 1.0.0
*/
function mtwfn_javascript_detection() {
echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n";
}
add_action( 'wp_head', 'mtwfn_javascript_detection', 0 );
/**
* Enqueue scripts and styles.
*/
function mtwfn_scripts() {
wp_enqueue_style( 'maycn-google-fonts', mtwfn_google_fonts_url(), array(), false );
wp_enqueue_style( 'bootstrap', get_theme_file_uri( '/assets/css/bootstrap.min.css' ), array(), '3.3.7' );
wp_enqueue_style( 'font-awesome', get_theme_file_uri( '/assets/css/font-awesome.min.css' ), array(), time() ); //'4.7.0'
wp_enqueue_style( 'slick', get_theme_file_uri( '/assets/css/slick.min.css' ), array(), '1.6.0' );
wp_enqueue_style( 'maycn-main', get_theme_file_uri( '/assets/css/main.min.css' ), array(), time() );
wp_enqueue_style( 'maycn-style', get_stylesheet_uri(), array(), time() );
wp_enqueue_script( 'slick', get_theme_file_uri( '/assets/js/slick.min.js' ), array( 'jquery' ), '1.6.0', true );
wp_enqueue_script( 'maycn-main', get_theme_file_uri( '/assets/js/main.min.js' ), array( 'jquery' ), time(), true );
}
add_action( 'wp_enqueue_scripts', 'mtwfn_scripts' );
/**
* Get default option for our theme.
*
* @param string $name Option key name to get.
* @return mixin
*/
function mtwfn_defaults( $name ) {
static $defaults;
if ( ! $defaults ) {
$defaults = apply_filters( 'mtwfn_defaults', array(
'facebook_app_id' => '100013587579810',
'fb_sdk_js' => true,
'fb_language' => 'vi_VN',
'totop' => true,
'mobile_menu_phone' => '0916223776|+84.932 347 817',
'mobile_menu_email' => 'info@mythuatweb.com',
'mobile_menu_facebook' => 'https://facebook.com/tritigi',
) );
}
return isset( $defaults[ $name ] ) ? $defaults[ $name ] : null;
}
/**
* MTWTeam Option for our theme.
*
* Retrieve theme modification value for the current theme.
*
* @since MTWTeam 1.0.0
*
* @param string $name The option name used to retrieve value.
* @param mixed|null $default The option default used to retrieve default value.
* @param boolean $echo Echo or return the value.
* @return string
*/
function mtwfn_option( $name, $default = null, $echo = true ) {
$name = sanitize_key( $name );
if ( is_null( $default ) ) {
$default = mtwfn_defaults( $name );
}
$option = get_theme_mod( $name, $default );
/**
* Apply filter maycn option.
*
* @param string $option Option value.
*
* @var mixed
*/
$option = apply_filters( 'mtwfn_option_' . $name, $option );
if ( ! $echo ) {
return $option;
} else {
print $option; // WPCS: XSS OK.
}
}
/**
* Custom template tags for this theme.
*/
require get_theme_file_path( '/inc/template-tags.php' );
/**
* Custom functions that act independently of the theme templates.
*/
require get_theme_file_path( '/inc/extras.php' );
/**
* Load Woocommerce Functions.
*/
require get_theme_file_path( '/inc/woocommerce.php' );
/**
* Register post types.
*/
require get_theme_file_path( '/inc/post-type.php' );
/**
* Register post types.
*/
require get_theme_file_path( '/inc/shortcode.php' );
/**
* Customizer additions.
*/
require get_theme_file_path( '/inc/customizer.php' );
/**
* Load Jetpack compatibility file.
*/
require get_theme_file_path( '/inc/jetpack.php' );
/**
* Load menu support.
*/
require get_theme_file_path( '/inc/menu.php' );
/**
* Load Sidebar feature class.
*/
require get_theme_file_path( '/inc/sidebar.php' );
/**
* Include the TGM_Plugin_Activation class.
*/
require get_theme_file_path( '/inc/class-tgm-plugin-activation.php' );
/**
* Register required plugins.
*/
require get_theme_file_path( '/inc/tgm-register.php' );
/**
* Load Abstract MTW Widget.
*/
require get_theme_file_path( '/inc/abstract/abstract-mtw-widget.php' );
/**
* Load MTW Widget Functions.
*/
require get_theme_file_path( '/inc/class-mtw-autoloader.php' );
/**
* Load MTW Widget Functions.
*/
require get_theme_file_path( '/inc/mtw-widget-functions.php' );
add_filter('add_to_cart_redirect', 'custom_add_to_cart_redirect');
function custom_add_to_cart_redirect() {
/**
* Replace with the url of your choosing
* e.g. return 'http://www.yourshop.com/'
*/
return get_permalink( get_option('woocommerce_checkout_page_id') );
}
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_archive_custom_cart_button_text' );
function woo_archive_custom_cart_button_text() {
return __( 'Mua ngay', 'woocommerce' );
}