full-width, boxed
* APTNEWS_HEADER -> fixed, standard, (auto-show)
* APTNEWS_MENU -> off-canvas, (dropdown), (push)
* APTNEWS_BLOG_LAYOUT -> full-width, leftbar, rightbar
* APTNEWS_BLOG_COLUMNS -> 1, 2, 3, 4, 5, 6
* APTNEWS_SHOP_LAYOUT -> full-width, leftbar, rightbar
* APTNEWS_SHOP_MAINPAGE -> default, page-builder
* APTNEWS_ADMIN_BAR -> hidden, bottom, top
*/
if ( ! function_exists( 'aptnews_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 aptnews_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on seed, use a find and replace
* to change 'apt-news' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'apt-news', get_template_directory() . '/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
tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
add_theme_support( 'custom-logo', array(
'width' => 200,
'height' => 100,
'flex-width' => 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( 370, 277, TRUE );
/* add_image_size( 'featured', 840, 400, true ); */
// This theme uses wp_nav_menu() in one location.
/*register_nav_menus( array(
'primary' => esc_html__( 'Main Menu', 'apt-news' ),
'mobile' => esc_html__( 'Mobile Menu', 'apt-news' ),
) );*/
/*
* 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',
) );
/*
* Enable support for Post Formats.
* See https://developer.wordpress.org/themes/functionality/post-formats/
*/
/*
add_theme_support( 'post-formats', array(
'aside',
'image',
'video',
'quote',
'link',
) );
*/
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'aptnews_custom_background_args', array(
'default-color' => 'fff',
//'default-image' => get_template_directory_uri() . '/img/background.jpg',
) ) );
}
endif; // aptnews_setup
add_action( 'after_setup_theme', 'aptnews_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 aptnews_content_width() {
$GLOBALS['content_width'] = apply_filters( 'aptnews_content_width', 840 );
}
add_action( 'after_setup_theme', 'aptnews_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function aptnews_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Headbar', 'apt-news' ),
'id' => 'headbar',
'description' => '',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Right Sidebar', 'apt-news' ),
'id' => 'rightbar',
'description' => '',
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Left Sidebar', 'apt-news' ),
'id' => 'leftbar',
'description' => '',
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Shop Sidebar', 'apt-news' ),
'id' => 'shopbar',
'description' => '',
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footbar', 'apt-news' ),
'id' => 'footbar',
'description' => '',
'before_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'aptnews_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function aptnews_scripts() {
/* CSS */
wp_enqueue_style( 'aptnews-bootstrap3', get_stylesheet_directory_uri() . '/vendor/bootstrap3/css/bootstrap.min.css' );
wp_enqueue_style( 'aptnews-font-awesome', get_stylesheet_directory_uri() . '/vendor/font-awesome/css/font-awesome.min.css' );
wp_enqueue_style( 'aptnews-start', get_stylesheet_directory_uri() . '/vendor/seedthemes/seed.css' );
wp_enqueue_style( 'aptnews-style', get_stylesheet_uri() );
wp_enqueue_style( 'aptnews-head', get_stylesheet_directory_uri() . '/css/head.css' );
wp_enqueue_style( 'aptnews-body', get_stylesheet_directory_uri() . '/css/body.css' );
wp_enqueue_style( 'aptnews-side', get_stylesheet_directory_uri() . '/css/side.css' );
wp_enqueue_style( 'aptnews-etc', get_stylesheet_directory_uri() . '/css/etc.css' );
wp_enqueue_style( 'aptnews-foot', get_stylesheet_directory_uri() . '/css/foot.css' );
/* JS */
/* <-- Move jQuery to footer for good Page Speed */
// wp_deregister_script( 'jquery' );
// wp_register_script( 'jquery', includes_url( '/js/jquery/jquery.js' ), false, NULL, true );
/* --> */
wp_enqueue_script( 'jquery' );
// wp_enqueue_script( 'aptnews-bootstrap3', get_stylesheet_directory_uri() . '/vendor/bootstrap3/js/bootstrap.min.js', array( 'jquery' ), array(), true );
wp_enqueue_script( 'aptnews-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
//apt wp_enqueue_script( 'aptnews-slidebars-script', get_template_directory_uri() . '/vendor/slidebars/slidebars.min.js', array(), '0.10.3', true );
wp_enqueue_script( 'aptnews-main', get_template_directory_uri() . '/js/main.js', array(), '2016-1', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'aptnews_scripts' );
/**
* Registers an editor stylesheet for the theme.
*/
function aptnews_add_editor_styles() {
add_editor_style( get_stylesheet_directory_uri() . '/css/wp-editor-style.css' );
}
add_action( 'admin_init', 'aptnews_add_editor_styles' );
/*======= Some great snippet =======*/
/**
* WooCommerce
*/
add_theme_support( 'woocommerce' );
// remove_action( 'admin_notices', 'woothemes_updater_notice' );
/* Display 12 products per page */
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 12;' ), 20 );
/* Change Thumbnails Columns in Single Product Page */
add_filter ( 'woocommerce_product_thumbnails_columns', 'aptnews_thumb_cols' );
function aptnews_thumb_cols() {
return 5;
}
/* Custome Thai Province order */
/*
add_filter( 'woocommerce_states', 'aptnews_woocommerce_states' );
function aptnews_woocommerce_states( $states ) {
$states['TH'] = array(
'TH-81' => 'กระบี่',
'TH-10' => 'กรุงเทพมหานคร',
'TH-71' => 'กาญจนบุรี',
'TH-46' => 'กาฬสินธุ์',
'TH-62' => 'กำแพงเพชร',
'TH-40' => 'ขอนแก่น',
'TH-22' => 'จันทบุรี',
'TH-24' => 'ฉะเชิงเทรา',
'TH-20' => 'ชลบุรี',
'TH-18' => 'ชัยนาท',
'TH-36' => 'ชัยภูมิ',
'TH-86' => 'ชุมพร',
'TH-57' => 'เชียงราย',
'TH-50' => 'เชียงใหม่',
'TH-92' => 'ตรัง',
'TH-23' => 'ตราด',
'TH-63' => 'ตาก',
'TH-26' => 'นครนายก',
'TH-73' => 'นครปฐม',
'TH-48' => 'นครพนม',
'TH-30' => 'นครราชสีมา',
'TH-80' => 'นครศรีธรรมราช',
'TH-60' => 'นครสวรรค์',
'TH-12' => 'นนทบุรี',
'TH-96' => 'นราธิวาส',
'TH-55' => 'น่าน',
'TH-38' => 'บึงกาฬ',
'TH-31' => 'บุรีรัมย์',
'TH-13' => 'ปทุมธานี',
'TH-77' => 'ประจวบคีรีขันธ์',
'TH-25' => 'ปราจีนบุรี',
'TH-94' => 'ปัตตานี',
'TH-14' => 'พระนครศรีอยุธยา',
'TH-56' => 'พะเยา',
'TH-82' => 'พังงา',
'TH-93' => 'พัทลุง',
'TH-66' => 'พิจิตร',
'TH-65' => 'พิษณุโลก',
'TH-76' => 'เพชรบุรี',
'TH-67' => 'เพชรบูรณ์',
'TH-54' => 'แพร่',
'TH-83' => 'ภูเก็ต',
'TH-44' => 'มหาสารคาม',
'TH-49' => 'มุกดาหาร',
'TH-58' => 'แม่ฮ่องสอน',
'TH-35' => 'ยโสธร',
'TH-95' => 'ยะลา',
'TH-45' => 'ร้อยเอ็ด',
'TH-85' => 'ระนอง',
'TH-21' => 'ระยอง',
'TH-70' => 'ราชบุรี',
'TH-16' => 'ลพบุรี',
'TH-52' => 'ลำปาง',
'TH-51' => 'ลำพูน',
'TH-42' => 'เลย',
'TH-33' => 'ศรีสะเกษ',
'TH-47' => 'สกลนคร',
'TH-90' => 'สงขลา',
'TH-91' => 'สตูล',
'TH-11' => 'สมุทรปราการ',
'TH-75' => 'สมุทรสงคราม',
'TH-74' => 'สมุทรสาคร',
'TH-27' => 'สระแก้ว',
'TH-19' => 'สระบุรี',
'TH-17' => 'สิงห์บุรี',
'TH-64' => 'สุโขทัย',
'TH-72' => 'สุพรรณบุรี',
'TH-84' => 'สุราษฎร์ธานี',
'TH-32' => 'สุรินทร์',
'TH-43' => 'หนองคาย',
'TH-39' => 'หนองบัวลำภู',
'TH-15' => 'อ่างทอง',
'TH-37' => 'อำนาจเจริญ',
'TH-41' => 'อุดรธานี',
'TH-53' => 'อุตรดิตถ์',
'TH-61' => 'อุทัยธานี',
'TH-34' => 'อุบลราชธานี'
);
return $states;
}
*/
/**
* Admin CSS
*/
function aptnews_admin_style() {
wp_enqueue_style('aptnews-admin-style', get_template_directory_uri() . '/css/wp-admin.css');
}
add_action('admin_enqueue_scripts', 'aptnews_admin_style');
/**
* Hide admin bar
*/
/*add_filter('show_admin_bar', '__return_false');*/
/**
* Force WordPress Gallery to Use Media File Link instead of Attachment Link.
*/
/*
add_shortcode( 'gallery', 'my_gallery_shortcode' );
function my_gallery_shortcode( $atts )
{
$atts['link'] = 'file';
return gallery_shortcode( $atts );
}
*/
/**
* Remove "Category: ", "Tag: ", "Taxonomy: " from archive title
*/
/*
add_filter( 'get_the_archive_title', function ($title) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '' . get_the_author() . '' ;
} elseif ( is_tax() ) {
$title = single_term_title( '', false ) ;
}
return $title;
});
*/
add_filter( 'get_the_archive_title', function ($title) {
if ( is_category() ) {
$title = single_cat_title( '', false );
}
return $title;
});
/*apt append*/
/* Remove [...] at the end of excerpt */
add_filter('excerpt_more','__return_false');
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
/**
* TGM activation
*/
require get_template_directory() . '/inc/tgm/class-tgm-plugin-activation.php';
require get_template_directory() . '/inc/tgm/tgm_registration.php';
/**
* widget framework
*/
function apt_so_widgets () {
/**
* fallbacak if users haven't yet install so-widgets-bundle
*/
// check if plugin is activated
if ( !class_exists('SiteOrigin_Widgets_Bundle') ) {
require get_template_directory() . '/inc/so_framework/so_framework.php';
}
require get_template_directory() . '/inc/apt_widgets/apt_widgets.php';
}
add_action('after_setup_theme', 'apt_so_widgets', 1);