support tag cloud to static page.
This commit is contained in:
parent
a40136398c
commit
248cc6bdd9
148
functions.php
148
functions.php
@ -10,13 +10,14 @@ add_filter('auto_update_plugin', '__return_true');
|
|||||||
|
|
||||||
// remove parent theme defined filters and actions
|
// remove parent theme defined filters and actions
|
||||||
add_action('after_setup_theme', 'cbsonline_disable_parent_defines');
|
add_action('after_setup_theme', 'cbsonline_disable_parent_defines');
|
||||||
function cbsonline_disable_parent_defines() {
|
function cbsonline_disable_parent_defines()
|
||||||
|
{
|
||||||
// remove 'ico - image/x-icon' mime support
|
// remove 'ico - image/x-icon' mime support
|
||||||
remove_filter('upload_mimes', 'biz_vektor_mine_types');
|
remove_filter('upload_mimes', 'biz_vektor_mine_types');
|
||||||
// remove web fonts
|
// remove web fonts
|
||||||
remove_action('wp_enqueue_scripts','biz_vektor_addWebFonts');
|
remove_action('wp_enqueue_scripts', 'biz_vektor_addWebFonts');
|
||||||
// remove buggy biz_vector script
|
// remove buggy biz_vector script
|
||||||
remove_action('wp_head','biz_vektor_addJScripts');
|
remove_action('wp_head', 'biz_vektor_addJScripts');
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable emoji
|
// disable emoji
|
||||||
@ -31,101 +32,108 @@ remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
|
|||||||
|
|
||||||
// remove unnecessary head tags
|
// remove unnecessary head tags
|
||||||
// - rest
|
// - rest
|
||||||
remove_action('wp_head','rest_output_link_wp_head');
|
remove_action('wp_head', 'rest_output_link_wp_head');
|
||||||
// - embed
|
// - embed
|
||||||
remove_action('wp_head','wp_oembed_add_discovery_links');
|
remove_action('wp_head', 'wp_oembed_add_discovery_links');
|
||||||
remove_action('wp_head','wp_oembed_add_host_js');
|
remove_action('wp_head', 'wp_oembed_add_host_js');
|
||||||
// - feed
|
// - feed
|
||||||
remove_action('wp_head','feed_links', 2);
|
remove_action('wp_head', 'feed_links', 2);
|
||||||
remove_action('wp_head','feed_links_extra', 3);
|
remove_action('wp_head', 'feed_links_extra', 3);
|
||||||
// - rsd
|
// - rsd
|
||||||
remove_action('wp_head','rsd_link');
|
remove_action('wp_head', 'rsd_link');
|
||||||
// - windows live writer
|
// - windows live writer
|
||||||
remove_action('wp_head','wlwmanifest_link');
|
remove_action('wp_head', 'wlwmanifest_link');
|
||||||
// - generator
|
// - generator
|
||||||
remove_action('wp_head','wp_generator');
|
remove_action('wp_head', 'wp_generator');
|
||||||
// - shortlink
|
// - shortlink
|
||||||
remove_action('wp_head','wp_shortlink_wp_head');
|
remove_action('wp_head', 'wp_shortlink_wp_head');
|
||||||
// - rel link
|
// - rel link
|
||||||
remove_action('wp_head','index_rel_link');
|
remove_action('wp_head', 'index_rel_link');
|
||||||
remove_action('wp_head','parent_post_rel_link', 10);
|
remove_action('wp_head', 'parent_post_rel_link', 10);
|
||||||
remove_action('wp_head','start_post_rel_link', 10);
|
remove_action('wp_head', 'start_post_rel_link', 10);
|
||||||
remove_action('wp_head','adjacent_posts_rel_link_wp_head');
|
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
|
||||||
|
|
||||||
// disable automatically appending srcset attribute in img tag
|
// disable automatically appending srcset attribute in img tag
|
||||||
add_filter('wp_calculate_image_srcset_meta', '__return_null');
|
add_filter('wp_calculate_image_srcset_meta', '__return_null');
|
||||||
|
|
||||||
// disable DNS prefetch
|
// disable DNS prefetch
|
||||||
add_filter('wp_resource_hints', 'cbsonline_remove_dns_prefetch', 10, 2);
|
add_filter('wp_resource_hints', 'cbsonline_remove_dns_prefetch', 10, 2);
|
||||||
function cbsonline_remove_dns_prefetch( $hints, $relation_type ) {
|
function cbsonline_remove_dns_prefetch($hints, $relation_type)
|
||||||
if ( 'dns-prefetch' === $relation_type ) {
|
{
|
||||||
return array_diff( wp_dependencies_unique_hosts(), $hints );
|
if ('dns-prefetch' === $relation_type) {
|
||||||
|
return array_diff(wp_dependencies_unique_hosts(), $hints);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $hints;
|
return $hints;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add styles
|
// add styles
|
||||||
add_action('wp_enqueue_scripts', 'cbsonline_add_styles');
|
add_action('wp_enqueue_scripts', 'cbsonline_add_styles');
|
||||||
function cbsonline_add_styles() {
|
function cbsonline_add_styles()
|
||||||
|
{
|
||||||
wp_enqueue_style('parent-style', get_template_directory_uri().'/style.css');
|
wp_enqueue_style('parent-style', get_template_directory_uri().'/style.css');
|
||||||
wp_enqueue_style('dashicons');
|
wp_enqueue_style('dashicons');
|
||||||
}
|
}
|
||||||
|
|
||||||
// add scripts
|
// add scripts
|
||||||
add_action('wp_head', 'cbsonline_add_scripts');
|
add_action('wp_head', 'cbsonline_add_scripts');
|
||||||
function cbsonline_add_scripts() {
|
function cbsonline_add_scripts()
|
||||||
|
{
|
||||||
wp_register_script('biz-vektor-fix-min-js', get_stylesheet_directory_uri().'/js/biz-vektor-fix-min.js', ['jquery'], '20201029');
|
wp_register_script('biz-vektor-fix-min-js', get_stylesheet_directory_uri().'/js/biz-vektor-fix-min.js', ['jquery'], '20201029');
|
||||||
wp_enqueue_script('biz-vektor-fix-min-js');
|
wp_enqueue_script('biz-vektor-fix-min-js');
|
||||||
}
|
}
|
||||||
|
|
||||||
// add widgets
|
// add widgets
|
||||||
function cbsonline_widgets_init() {
|
function cbsonline_widgets_init()
|
||||||
register_sidebar( array(
|
{
|
||||||
'name' => 'ヘッダー ウィジェット',
|
register_sidebar([
|
||||||
'id' => 'header-widget-area',
|
'name' => 'ヘッダー ウィジェット',
|
||||||
'before_widget' => '<div class="header-widget-area">',
|
'id' => 'header-widget-area',
|
||||||
'after_widget' => '</div>',
|
'before_widget' => '<div class="header-widget-area">',
|
||||||
'before_title' => '<h2 class="rounded">',
|
'after_widget' => '</div>',
|
||||||
'after_title' => '</h2>',
|
'before_title' => '<h2 class="rounded">',
|
||||||
) );
|
'after_title' => '</h2>',
|
||||||
|
]);
|
||||||
|
|
||||||
register_sidebar( array(
|
register_sidebar([
|
||||||
'name' => 'トップバナー ウィジェット',
|
'name' => 'トップバナー ウィジェット',
|
||||||
'id' => 'topbnr-widget-area',
|
'id' => 'topbnr-widget-area',
|
||||||
'before_widget' => '<div class="topbnr-widget-area clearfix"><div class="topbnr-widget-area-inner clearfix">',
|
'before_widget' => '<div class="topbnr-widget-area clearfix"><div class="topbnr-widget-area-inner clearfix">',
|
||||||
'after_widget' => '</div></div>',
|
'after_widget' => '</div></div>',
|
||||||
'before_title' => '<h2 class="rounded">',
|
'before_title' => '<h2 class="rounded">',
|
||||||
'after_title' => '</h2>',
|
'after_title' => '</h2>',
|
||||||
) );
|
]);
|
||||||
|
|
||||||
register_sidebar( array(
|
|
||||||
'name' => 'トップイメージ ウィジェット',
|
|
||||||
'id' => 'topimg-widget-area',
|
|
||||||
'before_widget' => '<div class="topimg-widget-area clearfix">',
|
|
||||||
'after_widget' => '</div>',
|
|
||||||
'before_title' => '<h2 class="rounded">',
|
|
||||||
'after_title' => '</h2>',
|
|
||||||
) );
|
|
||||||
|
|
||||||
|
register_sidebar([
|
||||||
|
'name' => 'トップイメージ ウィジェット',
|
||||||
|
'id' => 'topimg-widget-area',
|
||||||
|
'before_widget' => '<div class="topimg-widget-area clearfix">',
|
||||||
|
'after_widget' => '</div>',
|
||||||
|
'before_title' => '<h2 class="rounded">',
|
||||||
|
'after_title' => '</h2>',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
add_action('widgets_init', 'cbsonline_widgets_init');
|
add_action('widgets_init', 'cbsonline_widgets_init');
|
||||||
|
|
||||||
// tweak bogo plugin
|
// tweak bogo plugin
|
||||||
// - disable flags
|
// - disable flags
|
||||||
add_filter( 'bogo_use_flags','bogo_use_flags_false');
|
add_filter('bogo_use_flags', 'bogo_use_flags_false');
|
||||||
function bogo_use_flags_false() {
|
function bogo_use_flags_false()
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// - remove ' (United States)' strings from en_US language
|
// - remove ' (United States)' strings from en_US language
|
||||||
add_filter( 'bogo_language_switcher','replace_bogo_text');
|
add_filter('bogo_language_switcher', 'replace_bogo_text');
|
||||||
function replace_bogo_text($output) {
|
function replace_bogo_text($output)
|
||||||
return str_replace(' (United States)', '', $output);
|
{
|
||||||
|
return str_replace(' (United States)', '', $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add short code
|
// add short code
|
||||||
// - topbox : http://www.webopixel.net/wordpress/53.html
|
// - topbox : http://www.webopixel.net/wordpress/53.html
|
||||||
function cbsonline_shortcode_TopBox( $atts, $content = null ) {
|
function cbsonline_shortcode_TopBox($atts, $content = null)
|
||||||
$content = do_shortcode(shortcode_unautop($content));
|
{
|
||||||
|
$content = do_shortcode(shortcode_unautop($content));
|
||||||
extract(shortcode_atts(['class' => 'default'], $atts));
|
extract(shortcode_atts(['class' => 'default'], $atts));
|
||||||
|
|
||||||
return '<div class="topbox">'.$content.'</div>';
|
return '<div class="topbox">'.$content.'</div>';
|
||||||
@ -133,15 +141,18 @@ function cbsonline_shortcode_TopBox( $atts, $content = null ) {
|
|||||||
add_shortcode('topbox', 'cbsonline_shortcode_TopBox');
|
add_shortcode('topbox', 'cbsonline_shortcode_TopBox');
|
||||||
|
|
||||||
// allow illustrator file upload
|
// allow illustrator file upload
|
||||||
function cbsonline_allow_upload_ai($mimes) {
|
function cbsonline_allow_upload_ai($mimes)
|
||||||
|
{
|
||||||
$mimes['ai'] = 'image/x-illustrator';
|
$mimes['ai'] = 'image/x-illustrator';
|
||||||
|
|
||||||
return $mimes;
|
return $mimes;
|
||||||
}
|
}
|
||||||
add_filter('upload_mimes', 'cbsonline_allow_upload_ai');
|
add_filter('upload_mimes', 'cbsonline_allow_upload_ai');
|
||||||
|
|
||||||
// force override Archive widget arguments
|
// force override Archive widget arguments
|
||||||
add_filter( 'widget_archives_args', 'cbsonline_widget_archives_args' );
|
add_filter('widget_archives_args', 'cbsonline_widget_archives_args');
|
||||||
function cbsonline_widget_archives_args( $args ) {
|
function cbsonline_widget_archives_args($args)
|
||||||
|
{
|
||||||
// yearly
|
// yearly
|
||||||
$args['type'] = 'yearly';
|
$args['type'] = 'yearly';
|
||||||
// maximum number of items : 10 years
|
// maximum number of items : 10 years
|
||||||
@ -152,7 +163,8 @@ function cbsonline_widget_archives_args( $args ) {
|
|||||||
|
|
||||||
// support category based archives
|
// support category based archives
|
||||||
add_filter('getarchives_join', 'cbsonline_category_getarchives_join', 10, 2);
|
add_filter('getarchives_join', 'cbsonline_category_getarchives_join', 10, 2);
|
||||||
function cbsonline_category_getarchives_join($join, $r) {
|
function cbsonline_category_getarchives_join($join, $r)
|
||||||
|
{
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
if (is_category()) {
|
if (is_category()) {
|
||||||
$cat = intval(get_query_var('cat'));
|
$cat = intval(get_query_var('cat'));
|
||||||
@ -165,7 +177,8 @@ function cbsonline_category_getarchives_join($join, $r) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_filter('getarchives_where', 'cbsonline_category_getarchives_where', 10, 2);
|
add_filter('getarchives_where', 'cbsonline_category_getarchives_where', 10, 2);
|
||||||
function cbsonline_category_getarchives_where($where, $r) {
|
function cbsonline_category_getarchives_where($where, $r)
|
||||||
|
{
|
||||||
if (is_category()) {
|
if (is_category()) {
|
||||||
$cat = intval(get_query_var('cat'));
|
$cat = intval(get_query_var('cat'));
|
||||||
if ($cat > 0) {
|
if ($cat > 0) {
|
||||||
@ -174,7 +187,8 @@ function cbsonline_category_getarchives_where($where, $r) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_filter('year_link', 'cbsonline_category_year_link', 10, 2);
|
add_filter('year_link', 'cbsonline_category_year_link', 10, 2);
|
||||||
function cbsonline_category_year_link($url, $year){
|
function cbsonline_category_year_link($url, $year)
|
||||||
|
{
|
||||||
global $wp_rewrite;
|
global $wp_rewrite;
|
||||||
if (is_category()) {
|
if (is_category()) {
|
||||||
$cat = intval(get_query_var('cat'));
|
$cat = intval(get_query_var('cat'));
|
||||||
@ -182,6 +196,20 @@ function cbsonline_category_year_link($url, $year){
|
|||||||
$url .= '?cat='.get_query_var('cat');
|
$url .= '?cat='.get_query_var('cat');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// support tag cloud for static pages
|
||||||
|
add_action('init', 'cbsonline_add_tag_to_page');
|
||||||
|
function cbsonline_add_tag_to_page()
|
||||||
|
{
|
||||||
|
register_taxonomy_for_object_type('post_tag', 'page');
|
||||||
|
}
|
||||||
|
add_action('pre_get_posts', 'cbsonline_add_page_to_tag_archive');
|
||||||
|
function cbsonline_add_page_to_tag_archive($obj)
|
||||||
|
{
|
||||||
|
if (is_tag()) {
|
||||||
|
$obj->query_vars['post_type'] = ['post', 'page'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user