| 1 |
<?php |
| 2 |
/** |
| 3 |
* <meta content="charset=UTF-8"> |
| 4 |
* @package Welcart |
| 5 |
* @subpackage Welcart Default Theme |
| 6 |
*/ |
| 7 |
if(!defined('USCES_VERSION')) return; |
| 8 |
|
| 9 |
/*********************************************************** |
| 10 |
* welcart_setup |
| 11 |
***********************************************************/ |
| 12 |
add_action( 'after_setup_theme', 'welcart_setup' ); |
| 13 |
if ( ! function_exists( 'welcart_setup' ) ): |
| 14 |
function welcart_setup() { |
| 15 |
|
| 16 |
load_theme_textdomain( 'uscestheme', TEMPLATEPATH . '/languages' ); |
| 17 |
|
| 18 |
register_nav_menus( array( |
| 19 |
'header' => __('Header Navigation', 'usces' ), |
| 20 |
'footer' => __('Footer Navigation', 'usces' ), |
| 21 |
) ); |
| 22 |
} |
| 23 |
endif; |
| 24 |
|
| 25 |
/*********************************************************** |
| 26 |
* welcart_page_menu_args |
| 27 |
***********************************************************/ |
| 28 |
function welcart_page_menu_args( $args ) { |
| 29 |
$args['show_home'] = true; |
| 30 |
return $args; |
| 31 |
} |
| 32 |
add_filter( 'wp_page_menu_args', 'welcart_page_menu_args' ); |
| 33 |
|
| 34 |
/*********************************************************** |
| 35 |
* sidebar |
| 36 |
***********************************************************/ |
| 37 |
if ( function_exists('register_sidebar') ) { |
| 38 |
// Area 1, HomeLeft. |
| 39 |
register_sidebar(array( |
| 40 |
'name' => __( 'Home Left', 'uscestheme' ), |
| 41 |
'id' => 'homeleft-widget-area', |
| 42 |
'description' => __( 'home left sidebar widget area', 'uscestheme' ), |
| 43 |
'before_widget' => '<li id="%1$s" class="widget %2$s">', |
| 44 |
'after_widget' => '</li>', |
| 45 |
'before_title' => '<div class="widget_title">', |
| 46 |
'after_title' => '</div>', |
| 47 |
)); |
| 48 |
// Area 2, HomeRight. |
| 49 |
register_sidebar(array( |
| 50 |
'name' => __( 'Home Right', 'uscestheme' ), |
| 51 |
'id' => 'homeright-widget-area', |
| 52 |
'description' => __( 'home right sidebar widget area', 'uscestheme' ), |
| 53 |
'before_widget' => '<li id="%1$s" class="widget %2$s">', |
| 54 |
'after_widget' => '</li>', |
| 55 |
'before_title' => '<div class="widget_title">', |
| 56 |
'after_title' => '</div>', |
| 57 |
)); |
| 58 |
// Area 3, OtherLeft. |
| 59 |
register_sidebar(array( |
| 60 |
'name' => __( 'Other Left', 'uscestheme' ), |
| 61 |
'id' => 'otherleft-widget-area', |
| 62 |
'description' => __( 'other left sidebar widget area', 'uscestheme' ), |
| 63 |
'before_widget' => '<li id="%1$s" class="widget %2$s">', |
| 64 |
'after_widget' => '</li>', |
| 65 |
'before_title' => '<div class="widget_title">', |
| 66 |
'after_title' => '</div>', |
| 67 |
)); |
| 68 |
// Area 4, CartMemberLeft. |
| 69 |
register_sidebar(array( |
| 70 |
'name' => __( 'CartMemberLeft', 'uscestheme' ), |
| 71 |
'id' => 'cartmemberleft-widget-area', |
| 72 |
'description' => __( 'cart or member left sidebar widget area', 'uscestheme' ), |
| 73 |
'before_widget' => '<li id="%1$s" class="widget %2$s">', |
| 74 |
'after_widget' => '</li>', |
| 75 |
'before_title' => '<div class="widget_title">', |
| 76 |
'after_title' => '</div>', |
| 77 |
)); |
| 78 |
} |
| 79 |
|
| 80 |
/*********************************************************** |
| 81 |
* widget |
| 82 |
***********************************************************/ |
| 83 |
add_filter('widget_categories_dropdown_args', 'welcart_categories_args'); |
| 84 |
add_filter('widget_categories_args', 'welcart_categories_args'); |
| 85 |
function welcart_categories_args( $args ){ |
| 86 |
global $usces; |
| 87 |
$ids = $usces->get_item_cat_ids(); |
| 88 |
$ids[] = USCES_ITEM_CAT_PARENT_ID; |
| 89 |
$args['exclude'] = $ids; |
| 90 |
return $args; |
| 91 |
} |
| 92 |
add_filter('getarchives_where', 'welcart_getarchives_where'); |
| 93 |
function welcart_getarchives_where( $r ){ |
| 94 |
$where = "WHERE post_type = 'post' AND post_status = 'publish' AND post_mime_type <> 'item' "; |
| 95 |
return $where; |
| 96 |
} |
| 97 |
add_filter('widget_tag_cloud_args', 'welcart_tag_cloud_args'); |
| 98 |
function welcart_tag_cloud_args( $args ){ |
| 99 |
global $usces; |
| 100 |
if( 'category' == $args['taxonomy']){ |
| 101 |
$ids = $usces->get_item_cat_ids(); |
| 102 |
$ids[] = USCES_ITEM_CAT_PARENT_ID; |
| 103 |
$args['exclude'] = $ids; |
| 104 |
}else if( 'post_tag' == $args['taxonomy']){ |
| 105 |
$ids = $usces->get_item_post_ids(); |
| 106 |
$tobs = wp_get_object_terms($ids, 'post_tag'); |
| 107 |
foreach( $tobs as $ob ){ |
| 108 |
$tids[] = $ob->term_id; |
| 109 |
} |
| 110 |
$args['exclude'] = $tids; |
| 111 |
} |
| 112 |
return $args; |
| 113 |
} |
| 114 |
|
| 115 |
/*********************************************************** |
| 116 |
* excerpt |
| 117 |
***********************************************************/ |
| 118 |
if ( ! function_exists( 'welcart_assistance_excerpt_length' ) ) { |
| 119 |
function welcart_assistance_excerpt_length( $length ) { |
| 120 |
return 10; |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
if ( ! function_exists( 'welcart_assistance_excerpt_mblength' ) ) { |
| 125 |
function welcart_assistance_excerpt_mblength( $length ) { |
| 126 |
return 40; |
| 127 |
} |
| 128 |
} |
| 129 |
|
| 130 |
if ( ! function_exists( 'welcart_excerpt_length' ) ) { |
| 131 |
function welcart_excerpt_length( $length ) { |
| 132 |
return 40; |
| 133 |
} |
| 134 |
} |
| 135 |
add_filter( 'excerpt_length', 'welcart_excerpt_length' ); |
| 136 |
|
| 137 |
if ( ! function_exists( 'welcart_excerpt_mblength' ) ) { |
| 138 |
function welcart_excerpt_mblength( $length ) { |
| 139 |
return 110; |
| 140 |
} |
| 141 |
} |
| 142 |
add_filter( 'excerpt_mblength', 'welcart_excerpt_mblength' ); |
| 143 |
|
| 144 |
if ( ! function_exists( 'welcart_continue_reading_link' ) ) { |
| 145 |
function welcart_continue_reading_link() { |
| 146 |
return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">→</span>', 'uscestheme' ) . '</a>'; |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
if ( ! function_exists( 'welcart_auto_excerpt_more' ) ) { |
| 151 |
function welcart_auto_excerpt_more( $more ) { |
| 152 |
return ' …' . welcart_continue_reading_link(); |
| 153 |
} |
| 154 |
} |
| 155 |
//add_filter( 'excerpt_more', 'welcart_auto_excerpt_more' ); |
| 156 |
|
| 157 |
if ( ! function_exists( 'welcart_custom_excerpt_more' ) ) { |
| 158 |
function welcart_custom_excerpt_more( $output ) { |
| 159 |
if ( has_excerpt() && ! is_attachment() ) { |
| 160 |
$output .= welcart_continue_reading_link(); |
| 161 |
} |
| 162 |
return $output; |
| 163 |
} |
| 164 |
} |
| 165 |
//add_filter( 'get_the_excerpt', 'welcart_custom_excerpt_more' ); |
| 166 |
|
| 167 |
/*********************************************************** |
| 168 |
* SSL |
| 169 |
***********************************************************/ |
| 170 |
if( $usces->options['use_ssl'] ){ |
| 171 |
add_action('init', 'usces_ob_start'); |
| 172 |
function usces_ob_start(){ |
| 173 |
global $usces; |
| 174 |
if( $usces->use_ssl && ($usces->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $usces->is_inquiry_page($_SERVER['REQUEST_URI'])) ) |
| 175 |
ob_start('usces_ob_callback'); |
| 176 |
} |
| 177 |
if ( ! function_exists( 'usces_ob_callback' ) ) { |
| 178 |
function usces_ob_callback($buffer){ |
| 179 |
global $usces; |
| 180 |
$pattern = array( |
| 181 |
'|(<[^<]*)href=\"'.get_option('siteurl').'([^>]*)\.css([^>]*>)|', |
| 182 |
'|(<[^<]*)src=\"'.get_option('siteurl').'([^>]*>)|' |
| 183 |
); |
| 184 |
$replacement = array( |
| 185 |
'${1}href="'.USCES_SSL_URL_ADMIN.'${2}.css${3}', |
| 186 |
'${1}src="'.USCES_SSL_URL_ADMIN.'${2}' |
| 187 |
); |
| 188 |
$buffer = preg_replace($pattern, $replacement, $buffer); |
| 189 |
return $buffer; |
| 190 |
} |
| 191 |
} |
| 192 |
} |
| 193 |
|
| 194 |
?> |
| 195 |
|