Cocoonをダークテーマに

CSSのメディアクエリで対応できるみたいなので、CSSに下記を追加。
力技です。

@media (prefers-color-scheme: dark) {
    body.public-page {
        background-color: #222!important;
    }
    .header-container, .main, .sidebar, .footer {
        background-color: #333!important;
    }
    .a-wrap {
        color: white!important;
        background-color: #555!important;
    }
    a {
        color: white!important;
    }
    p a {
        color: #d93!important;
    }
    body {
        color: white!important;
    }
    .menu-content {
        background-color: #333!important;
    }
    .sidebar-menu-content {
        color: white;
    }
    .key-btn {
        background-color: rgba(57, 63, 76);
        border-color: rgba(57, 63, 76);
        color: white!important;
    }
    .breadcrumb {
        color: white!important;
    }
    table tr:nth-of-type(2n+1), .page-numbers.dots, .a-wrap:hover, .pagination a:hover, .pagination-next-link:hover, .widget_recent_entries ul li a:hover, .widget_categories ul li a:hover, .widget_archive ul li a:hover, .widget_pages ul li a:hover, .widget_meta ul li a:hover, .widget_rss ul li a:hover, .widget_nav_menu ul li a:hover, .pager-links a:hover span, .tag-link:hover, .tagcloud a:hover {
        background-color: #777!important;
    }
    .widget_recent_entries ul li a:hover, .widget_categories ul li a:hover, .widget_archive ul li a:hover, .widget_pages ul li a:hover, .widget_meta ul li a:hover, .widget_rss ul li a:hover, .widget_nav_menu ul li a:hover, .tagcloud a:hover, .pagination a:hover, .pager-links a:hover span, .pagination-next-link:hover, .comment-btn:hover, .comment-reply-link:hover, .navi-footer-in a:hover, .navi-footer-in a:hover {
        background-color: #555!important;
    }
    .cat-link:hover {
        transition: all 0.3s ease-in-out;
        background-color: #555!important;
        color: white!important;
        opacity: 1!important;
    }
}

ついでに、ボックスシャドウとボーダーラディウスを消しました。

.main, .sidebar, .carousel-in, .sbp-main-before, .sbp-footer-before, .pbp-main-before, .pbp-footer-before {
    box-shadow: none!important;
    border-radius: 0!important;
}

.a-wrap {
    padding: 20px!important;
    border-radius: 0!important;
}

h1, h2, h3, h4, h5, h6 {
    border-radius: 0!important;
    padding-left: 1em!important;
}

デフォルトで生成されるパーマリンクをランダムな短い文字列にしたくて、ググってみるとfunctions.phpに追加で行けそうな感じでしたが、うまくいきませんでした。

function auto_post_slug($slug, $post_ID, $post_status, $post_type){
  if ( preg_match( '/[0-9a-zA-Z_\-]{8}/', $slug) == false) {
    $slug = makeRandStr(8);
  }
  return $slug;
}
add_filter('wp_unique_post_slug', 'auto_post_slug', 10, 4);

function makeRandStr($length = 8){
    static $chars = '0123456789abcdefghijklmnopqrstuvwxyz_-';
    $str = '';
    for ($i = 0; $i < $length; ++$i) {
        $str .= $chars[mt_rand(0, 37)];
    }
    return $str;
}

仕方ないので、力技で解決。wp-addmin/post.phpの一番最後に下記を追加。うーん、、、

function makeRandStr2($length = 8)
{
    $chars = '0123456789abcdefghijklmnopqrstuvwxyz_-';
    $str = '';
    for ($i = 0; $i < $length; ++$i) {
        $str .= $chars[mt_rand(0, 37)];
    }
    return $str;
}
$orisulg= makeRandStr2();
echo "<script type='text/javascript'>
window.onload=function() {
var regex = /[0-9a-zA-Z_\-]{8}/;
var result = regex.test((document.getElementById('inspector-text-control-0')).value);
if(!result){
(document.getElementById('inspector-text-control-0')).value='".$orisulg."';
}
};
</script>";

コメント

タイトルとURLをコピーしました