'Welcar e-Commerce',
'slug' => 'usc-e-shop',
'required' => false,
),
);
$config = array(
'default_path' => '',
'menu' => 'tgmpa-install-plugins',
'has_notices' => true,
'dismissable' => true,
'dismiss_msg' => '',
'is_automatic' => false,
'message' => '',
'strings' => array(
'page_title' => __( 'Install Recommended Plugins', 'blanc' ),
'menu_title' => __( 'Install Plugins', 'blanc' ),
'installing' => __( 'Installing Plugin: %s', 'blanc' ),
'oops' => __( 'Something went wrong with the plugin API.', 'blanc' ),
'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.', 'blanc' ),
'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.', 'blanc' ),
'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', 'blanc' ),
'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.', 'blanc' ),
'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', 'blanc' ),
'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.', 'blanc' ),
'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'blanc' ),
'activate_link' => _n_noop( 'Begin activating plugin', 'Begin activating plugins', 'blanc' ),
'return' => __( 'Return to Recommended Plugins Installer', 'blanc' ),
'plugin_activated' => __( 'Plugin activated successfully.', 'tgmpa' ),
'complete' => __( 'All plugins installed and activated successfully. %s', 'blanc' ),
'nag_type' => 'updated'
)
);
tgmpa( $plugins, $config );
}
//Translation
load_theme_textdomain( 'blanc', get_template_directory() . '/languages' );
//Editor style
add_editor_style();
//Remove generator
remove_action('wp_head', 'wp_generator');
//Search form
add_theme_support('html5', array('search-form'));
//Navigation menu
register_nav_menu('navigation',__( 'Navigation', 'blanc' ));
//Content width
if ( !isset( $content_width ) ){
$content_width = 720;
}
//Feed
add_theme_support( 'automatic-feed-links' );
//Scripts and Style sheets
function blanc_scripts(){
wp_enqueue_style( 'foundation-style', get_template_directory_uri() .'/css/foundation.min.css');
wp_enqueue_style( 'blanc-style', get_stylesheet_uri() );
wp_enqueue_style( 'font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css');
wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Quicksand');
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'modernizr', get_template_directory_uri() . '/js/vendor/modernizr.js', array(), '', true);
wp_enqueue_script( 'scripts', get_template_directory_uri() . '/js/scripts.js', array(), '1.0', true);
if( is_single() && in_category( 'blog' ) &&comments_open() ){
wp_enqueue_script('comment-reply');
}
if ( is_front_page() || ( is_single() && in_category('item') ) ){
wp_enqueue_style( 'flexslider-css', get_template_directory_uri() . '/css/flexslider.css');
wp_enqueue_script( 'flexslider-js', get_template_directory_uri() . '/js/jquery.flexslider-min.js', array(), '2.2.2', true);
if ( is_front_page() ){
wp_enqueue_script( 'use-flexslider-home', get_template_directory_uri() . '/js/use-flexslider-home.js', array(), '1.0', true);
}
}
if( is_single() ){
wp_enqueue_style( 'swipebox-style', get_template_directory_uri() .'/css/swipebox.min.css', 'all');
wp_enqueue_script( 'swipebox', get_template_directory_uri() . '/js/jquery.swipebox.min.js', array(), '1.2.9', true);
wp_enqueue_script( 'use-swipebox', get_template_directory_uri() . '/js/use-swipebox.js', array(), '1.0', true);
if( in_category( 'item' ) ){
wp_enqueue_script( 'use-flexslider-single', get_template_directory_uri() . '/js/use-flexslider-single.js', array(), '1.0', true);
wp_enqueue_script( 'script-qty', get_template_directory_uri() . '/js/script-qty.js', array(), '1.0', true);
}
}
if( is_page(array('usces-cart','usces-member'))){
wp_enqueue_style( 'validationEngine-css', get_template_directory_uri() .'/css/validationEngine.jquery.css', 'all');
wp_enqueue_script( 'validationEngine', get_template_directory_uri() . '/js/jquery.validationEngine.js', array(), '2.6.2', true);
wp_enqueue_script( 'validationEngine-lang', get_template_directory_uri() . '/js/jquery.validationEngine-en.js', array(), '2.0', true);
wp_enqueue_script( 'use-validationEngine', get_template_directory_uri() . '/js/use-validationEngine.js', array(), '1.0', true);
}
}
add_action( 'wp_enqueue_scripts', 'blanc_scripts');
//Length of excerpt
function blanc_length($length){
if(!wp_is_mobile()){
return 70;
} else {
return 35;
}
}
add_filter( 'excerpt_mblength', 'blanc_length' );
//Excerpt more
function blanc_more($more){
return '…';
}
add_filter( 'excerpt_more', 'blanc_more');
//Featured image
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 150, true );
//Fixing problem of title tag of multiple item category search page & date archives
add_filter( 'wp_title', 'blanc_wp_title', 10, 2 );
function blanc_wp_title($title, $sep){
$sep = ' – ';
if( isset( $_GET['page'] ) && ( $_GET['page'] == 'search_item') ){
$title = __( 'Multiple Category Search', 'blanc' ) . $sep;
} elseif( is_day() ){
$date = __('F jS, Y', 'blanc');
$title = sprintf(__("Posts on %s", "blanc"), get_the_date( $date ) ) . $sep;
} elseif( is_month() ){
$month = __('F Y', 'blanc');
$title = sprintf(__("Posts in %s", "blanc"), get_the_date( $month ) ) . $sep;
} elseif( is_year() ){
$year = __('Y', 'blanc');
$title = sprintf(__("Posts in %s", "blanc"), get_the_date( $year ) ) . $sep;
} elseif ( is_front_page() ){
$title = bloginfo('description') . $sep;
} elseif ( is_search() ){
$s_word = get_search_query();
$title = sprintf(__("Results for '%s'", "blanc"), $s_word ) . $sep;
}
if ( is_paged() ){
$title .= 'page' . get_query_var('paged') . $sep;
}
return $title;
}
//Breadcrumb for blog posts
function blanc_breadcrumb() {
global $post;
$front_page = get_option('page_on_front');
$home = get_option('page_for_posts');
$str ='';
if(!is_admin()){
$str.= '
';
$str.= '' .__( "Home", "blanc" ). ' ';
if(is_search()){
$s_word = get_search_query();
$str.=''.sprintf(__("Results for '%s'", "blanc"), $s_word ).' ';
} elseif(is_tag()){
if( $home && $front_page!=0 ){
$str.='' .get_the_title($home). ' ';
}
$str.='' .__( "Tag:", "blanc" ) . single_tag_title( '' , false ). ' ';
} elseif(is_404()){
$str.='' .__('404 Not found','blanc') . ' ';
} elseif(is_date()){
$date = __('jS', 'blanc');
$month = __('F', 'blanc');
$year = __('Y', 'blanc');
if( $home && $front_page!=0 ){
$str.='' .get_the_title($home). ' ';
}
if(is_day()){
$str.='' . get_the_date( $year ). ' ';
$str.=''. get_the_date( $month ) .' ';
$str.=''. get_the_date( $date ). ' ';
} elseif(is_month()){
$str.=''. get_the_date( $year ) .' ';
$str.=''. get_the_date( $month ). ' ';
} else {
$str.=''. get_the_date( $year ) .' ';
}
} elseif(is_category()) {
if( $home && $front_page!=0 ){
$str.='' .get_the_title($home). ' ';
}
$cat = get_queried_object();
if($cat -> parent != 0){
$ancestors = array_reverse(get_ancestors( $cat -> cat_ID, 'category' ));
foreach($ancestors as $ancestor){
$str.=''. get_cat_name($ancestor) .' ';
}
}
$str.=''. $cat -> name;
if( is_paged()){
$current = (get_query_var('paged')) ? get_query_var('paged') : 1;
$str.= sprintf(__(" - Page %d", "blanc"), $current );
}
$str.=' ';
} elseif(is_author()){
if( $home && $front_page!=0 ){
$str.='' .get_the_title($home). ' ';
}
$str .='' .__( "Author:", "blanc" ) . get_the_author_meta('display_name', get_query_var('author')).' ';
} elseif(is_attachment()){
if( $home && $front_page!=0 ){
$str.='' .get_the_title($home). ' ';
}
if($post -> post_parent != 0 ){
$post_parent = $post -> post_parent;
$str.= ''. get_the_title($post -> post_parent) .' ';
}
$str.= '' . $post -> post_title . ' ';
} elseif(is_single()){
if( $home && $front_page!=0 ){
$str.='' .get_the_title($home). ' ';
}
$categories = get_the_category($post->ID);
$cat = $categories[0];
if($cat -> parent != 0){
$ancestors = array_reverse(get_ancestors( $cat -> cat_ID, 'category' ));
foreach($ancestors as $ancestor){
$str.=''. get_cat_name($ancestor). ' ';
}
}
$str.=''. $cat-> cat_name . ' ';
$str.= ''. $post -> post_title .' ';
} elseif(is_page()){
if($post -> post_parent != 0 ){
$ancestors = array_reverse(get_post_ancestors( $post->ID ));
foreach($ancestors as $ancestor){
$str.=''. get_the_title($ancestor) .' ';
}
}
$str.= ''. $post -> post_title .' ';
} elseif(is_home()){
$str.=''. get_the_title($home);
if( is_paged()){
$current = (get_query_var('paged')) ? get_query_var('paged') : 1;
$str.= sprintf(__(" - Page %d", "blanc"), $current );
}
$str.=' ';
} else {
$str.=''. wp_title('', false, 'right') .' ';
}
$str.=' ';
}
echo $str;
}
//Breadcrumbs for items
function blanc_breadcrumb_item() {
global $post;
$str ='';
if(!is_home()&&!is_admin()){
$str.= '';
$str.= '' .__( "Home", "blanc" ). ' ';
if(is_search()){
$s_word = get_search_query();
$str.='' .sprintf(__("Results for '%s'", "blanc"), $s_word ). ' ';
} elseif(is_tag()){
$str.='' .__( "Tag:", "blanc" ) . single_tag_title( '' , false ). ' ';
} elseif(is_category()) {
$cat = get_queried_object();
$str.=''. $cat -> name;
if( is_paged()){
$current = (get_query_var('paged')) ? get_query_var('paged') : 1;
$str.= sprintf(__(" - Page %d", "blanc"), $current );
}
$str.=' ';
} elseif(is_single()){
$str .= '';
$cats = '';
$categories = get_the_category();
foreach( $categories as $category){
$category_id = $category->term_id;
$category_child = get_term_children($category_id, 'category');
if($category_child != true){
$cats .= '' . get_cat_name($category_id) . ' / ';
}
}
$str.= rtrim( $cats, ' / ' );
$str.= ' ';
$str.= ''. $post -> post_title .' ';
} else{
$str.=''. wp_title('', false) .' ';
}
$str.=' ';
}
echo $str;
}
//Related Items
function blanc_related_item_list(){
global $post;
$categories = get_the_category($post->ID);
if( $categories ){
$category_ids = array();
foreach( $categories as $category){
$category_id = $category->term_id;
$category_child = get_term_children($category_id, 'category');
if($category_child != true){
$category_ids[] = $category->term_id ;
}
}
$args=array(
'category__in' => $category_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=> 4,
'ignore_sticky_posts'=> 1,
'orderby' => 'rand',
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo '';
wp_reset_query();
}
}
}
//Specific templates for item archives & item search page
add_filter( 'category_template', 'blanc_category_item_template' );
function blanc_category_item_template($category_item_template) {
$category_id = get_query_var('cat');
$parent_ids = get_ancestors($category_id, 'category');
$parent_slugs = array();
foreach ($parent_ids as $parent_id){
$parent = get_category($parent_id);
$parent_slugs[] = $parent->slug;
}
if (in_array('item', $parent_slugs) || is_category('item')){
$category_item_template = dirname( __FILE__ ) . '/archive-item.php';
}
return $category_item_template;
}
add_filter( 'tag_template', 'blanc_tag_item_template' );
function blanc_tag_item_template($tag_item_template) {
if ( in_category( 'item' )) {
$tag_item_template = dirname( __FILE__ ) . '/archive-item.php';
}
return $tag_item_template;
}
add_filter( 'search_template', 'blanc_search_item_template' );
function blanc_search_item_template($search_item_template) {
if ( is_search() && !isset($_GET['searchitem'])){
$search_item_template = dirname( __FILE__ ) . '/search-item.php';
}
return $search_item_template;
}
add_action('template_redirect', 'search_no_keywords');
function search_no_keywords() {
if (isset($_GET['s']) && empty($_GET['s'])) {
header("Location:" . $_SERVER['HTTP_REFERER']);
exit;
}
}
//Widgets
register_sidebar( array(
'id' => 'column1',
'name' => __( 'Footer column 1', 'blanc' ),
'description' => __( 'Place widgets for 1st column.', 'blanc' ),
'before_widget' => '',
'before_title' => ''
)
);
register_sidebar( array(
'id' => 'column2',
'name' => __( 'Footer column 2', 'blanc' ),
'description' => __( 'Place widgets for 2nd column.', 'blanc' ),
'before_widget' => '',
'before_title' => ''
)
);
register_sidebar( array(
'id' => 'column3',
'name' => __( 'Footer column 3', 'blanc' ),
'description' => __( 'Place widgets for 3rd column.', 'blanc' ),
'before_widget' => '',
'before_title' => ''
)
);
register_sidebar( array(
'id' => 'column4',
'name' => __( 'Footer column 4', 'blanc' ),
'description' => __( 'Place widgets for 4th column.', 'blanc' ),
'before_widget' => '',
'before_title' => ''
)
);
register_sidebar( array(
'id' => 'column-blog',
'name' => __( 'Blog sidebar', 'blanc' ),
'description' => __( 'Place widgets for blog page.', 'blanc' ),
'before_widget' => '',
'before_title' => ''
)
);
register_sidebar( array(
'id' => 'column-page',
'name' => __( 'Page sidebar', 'blanc' ),
'description' => __( 'Place widgets for pages.', 'blanc' ),
'before_widget' => '',
'before_title' => ''
)
);
register_sidebar( array(
'id' => 'column-member',
'name' => __( 'Member page sidebar', 'blanc' ),
'description' => __( 'Place widgets for member page.', 'blanc' ),
'before_widget' => '',
'before_title' => ''
)
);
//Remove auto OGP by Welcart plugin
remove_action( 'wp_head', 'usces_action_ogp_meta');
//Show Inquiry Button in case of out of stock
add_filter('usces_filters_single_sku_zaiko_message', 'blanc_single_sku_zaiko_message', 10);
function blanc_single_sku_zaiko_message($inquery_button){
$inquery_button = usces_get_itemZaiko( 'name' ).' '.__( "Inquiry Form", "blanc" ) .' ';
return $inquery_button;
}
add_filter('usces_filters_multi_sku_zaiko_message', 'blanc_multi_sku_zaiko_message', 10);
function blanc_multi_sku_zaiko_message($inquery_button){
$inquery_button = usces_get_itemZaiko( 'name' ).' '.__( "Inquiry Form", "blanc" ) . ' ';
return $inquery_button;
}
//Change querys for item archives
if(term_exists('item', 'category')){
add_action('pre_get_posts', 'blanc_query');
function blanc_query($query){
$item_cat = get_category_by_slug('item');
$item_cat_id = $item_cat->cat_ID;
if ( is_admin() || ! $query->is_main_query() ){
return;
}
if ( $query->is_home() || $query->is_author() || $query->is_date() ){
$query->set('category__not_in', $item_cat_id);
}
if ( $query->is_category('item') ){
$query->set('posts_per_page', '12');
}
if ( $query->is_search && isset($_GET['searchitem']) ) {
$query->set('category__not_in', $item_cat_id);
}
if ( $query->is_search && !isset($_GET['searchitem']) ){
$query->set('posts_per_page','12');
$query->set('category_name','item');
}
}
}
//Remove numbering cell & stock status cell on cart page
add_filter('usces_filter_cart_row', 'blanc_filter_cart_row', 10, 3);
function blanc_filter_cart_row($row, $cart, $materials){
extract($materials);
$args = compact('cart', 'i', 'cart_row', 'post_id', 'sku' );
$row = '';
if ( empty($options) ) {
$optstr = '';
$options = array();
}
$row .= '
';
$cart_thumbnail = '' . wp_get_attachment_image( $pictid, array(60, 60), true ) . ' ';
$row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i,$cart_row);
$row .= ' ' . esc_html($cartItemName) . ' ';
if( is_array($options) && count($options) > 0 ){
$optstr = '';
foreach($options as $key => $value){
if( !empty($key) ) {
$key = urldecode($key);
if(is_array($value)) {
$c = '';
$optstr .= esc_html($key) . ' : ';
foreach($value as $v) {
$optstr .= $c.nl2br(esc_html(urldecode($v)));
$c = ', ';
}
$optstr .= " \n";
} else {
$optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . " \n";
}
}
}
$row .= apply_filters( 'usces_filter_option_cart', $optstr, $options);
}
$row .= apply_filters( 'usces_filter_option_info_cart', '', $cart_row, $args );
$row .= '
';
if( usces_is_gptekiyo($post_id, $sku_code, $quantity) ) {
$usces_gp = 1;
$Business_pack_mark = ' ';
$row .= apply_filters('usces_filter_itemGpExp_cart_mark', $Business_pack_mark);
}
$row .= usces_crform($skuPrice, true, false, 'return') . '
';
$row_quant = ' ';
$row .= apply_filters( 'usces_filter_cart_rows_quant', $row_quant, $args );
$row .= '
' . usces_crform(($skuPrice * $cart_row['quantity']), true, false, 'return') . '
';
foreach($options as $key => $value){
if(is_array($value)) {
foreach($value as $v) {
$row .= ' ';
}
} else {
$row .= ' ';
}
}
$row .= '
';
return $row;
}
//Remove unused cell in the Table on confirmation page
add_filter('usces_filter_confirm_row', 'blanc_filter_confirm_row', 10, 3);
function blanc_filter_confirm_row($row, $cart, $materials){
extract($materials);
$row = '';
if (empty($options)) {
$optstr = '';
$options = array();
}
$row .= '
';
$cart_thumbnail = wp_get_attachment_image( $pictid, array(60, 60), true );
$row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row);
$row .= ' ' . $cartItemName . ' ';
if( is_array($options) && count($options) > 0 ){
$optstr = '';
foreach($options as $key => $value){
if( !empty($key) ) {
$key = urldecode($key);
if(is_array($value)) {
$c = '';
$optstr .= esc_html($key) . ' : ';
foreach($value as $v) {
$optstr .= $c.nl2br(esc_html(urldecode($v)));
$c = ', ';
}
$optstr .= " \n";
} else {
$optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . " \n";
}
}
}
$row .= apply_filters( 'usces_filter_option_confirm', $optstr, $options);
}
$row .= '
' . usces_crform($skuPrice, true, false, 'return') . '
' . $cart_row['quantity'] . '
' . usces_crform(($skuPrice * $cart_row['quantity']), true, false, 'return') . '
';
return $row;
}
function get_attachment_id($url){
// Split the $url into two parts with the wp-content directory as the separator.
$parse_url = explode( parse_url( WP_CONTENT_URL, PHP_URL_PATH ), $url );
// Get the host of the current site and the host of the $url, ignoring www.
$this_host = str_ireplace( 'www.', '', parse_url( home_url(), PHP_URL_HOST ) );
$file_host = str_ireplace( 'www.', '', parse_url( $url, PHP_URL_HOST ) );
// Return nothing if there aren't any $url parts or if the current host and $url host do not match.
if ( ! isset( $parse_url[1] ) || empty( $parse_url[1] ) || ( $this_host != $file_host ) ) {
return;
}
// Now we're going to quickly search the DB for any attachment GUID with a partial path match.
// Example: /uploads/2013/05/test-image.jpg
global $wpdb;
$attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->prefix}posts WHERE guid RLIKE %s;", $parse_url[1] ) );
// Returns null if no attachment is found.
return $attachment[0];
}