'ヘッダー ウィジェット',
'id' => 'header-widget-area',
'before_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => 'トップバナー ウィジェット',
'id' => 'topbnr-widget-area',
'before_widget' => '',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => 'トップイメージ ウィジェット',
'id' => 'topimg-widget-area',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
}
add_action('widgets_init', 'cbsonline_widgets_init');
// tweak bogo plugin
// - disable flags
add_filter( 'bogo_use_flags','bogo_use_flags_false');
function bogo_use_flags_false() {
return false;
}
// - remove ' (United States)' strings from en_US language
add_filter( 'bogo_language_switcher','replace_bogo_text');
function replace_bogo_text($output) {
return str_replace(' (United States)', '', $output);
}
// add short code
// - topbox : http://www.webopixel.net/wordpress/53.html
function cbsonline_shortcode_TopBox( $atts, $content = null ) {
$content = do_shortcode(shortcode_unautop($content));
extract(shortcode_atts(['class' => 'default'], $atts));
return ''.$content.'
';
}
add_shortcode('topbox', 'cbsonline_shortcode_TopBox');
// allow illustrator file upload
function cbsonline_allow_upload_ai($mimes) {
$mimes['ai'] = 'image/x-illustrator';
return $mimes;
}
add_filter('upload_mimes', 'cbsonline_allow_upload_ai');
// force override Archive widget arguments
add_filter( 'widget_archives_args', 'cbsonline_widget_archives_args' );
function cbsonline_widget_archives_args( $args ) {
// yearly
$args['type'] = 'yearly';
// maximum number of items : 10 years
$args['limit'] = 10;
return $args;
}
// support category based archives
add_filter('getarchives_join', 'cbsonline_category_getarchives_join', 10, 2);
function cbsonline_category_getarchives_join($join, $r) {
global $wpdb;
if (is_category()) {
$cat = intval(get_query_var('cat'));
if ($cat > 0) {
return
" LEFT JOIN $wpdb->term_relationships as r ON $wpdb->posts.ID = r.object_ID
LEFT JOIN $wpdb->term_taxonomy as t ON r.term_taxonomy_id = t.term_taxonomy_id
LEFT JOIN $wpdb->terms as terms ON t.term_id = terms.term_id";
}
}
}
add_filter('getarchives_where', 'cbsonline_category_getarchives_where', 10, 2);
function cbsonline_category_getarchives_where($where, $r) {
if (is_category()) {
$cat = intval(get_query_var('cat'));
if ($cat > 0) {
return $where." AND t.taxonomy = 'category' AND terms.term_id = $cat";
}
}
}
add_filter('year_link', 'cbsonline_category_year_link', 10, 2);
function cbsonline_category_year_link($url, $year){
global $wp_rewrite;
if (is_category()) {
$cat = intval(get_query_var('cat'));
if ($cat > 0) {
$url .= '?cat='.get_query_var('cat');
}
}
return $url;
}