Skip to content

Commit

Permalink
改用wp_add_inline_style挂载行内和自定义样式
Browse files Browse the repository at this point in the history
  • Loading branch information
Lvshujun0918 committed Mar 11, 2024
1 parent 39d5e90 commit 81511a1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
4 changes: 0 additions & 4 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@
<link rel="apple-touch-icon" href="<?php echo pk_get_option('favicon') ?>"/>
<?php if(pk_is_checked('seo_open',true)) get_template_part('inc/seo') ?>
<?php wp_head(); ?>
<?php get_template_part('templates/css', 'grey') ?>
<?php get_template_part('templates/css', 'custom') ?>
<?php echo pk_head_style_var() ?>
<?php if (!empty(pk_get_option('tj_code_header', ''))): ?>
<?php echo pk_get_option('tj_code_header', ''); ?>
<?php endif; ?>
<?php if (!empty(pk_get_option('css_code_header', ''))): ?>
<?php echo "<style>" . pk_get_option('css_code_header', '') . "</style>"; ?>
<?php endif; ?>
</head>
<body class="puock-<?php echo pk_theme_light() ? 'light' : 'dark';
echo current_theme_supports('custom-background') ? ' custom-background' : ''; ?>">
Expand Down
16 changes: 15 additions & 1 deletion inc/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ function pk_init_register_assets()
wp_enqueue_style('puock-strawberry-icon-admin', pk_get_static_url() . '/assets/libs/strawberry-icon.css', [], PUOCK_CUR_VER_STR);
wp_enqueue_script('puock-admin', pk_get_static_url() . '/assets/dist/js/admin.min.js', [], PUOCK_CUR_VER_STR, true);
} else {
// wp_deregister_script('jquery');
wp_register_script('jquery', pk_get_static_url() . '/assets/libs/jquery.min.js', [], PUOCK_CUR_VER_STR);
wp_enqueue_script('jquery');
wp_enqueue_style('puock-libs', pk_get_static_url() . '/assets/dist/style/libs.min.css', [], PUOCK_CUR_VER_STR);
Expand All @@ -193,6 +192,21 @@ function pk_init_register_assets()
wp_enqueue_script('puock-gt4', pk_get_static_url() . '/assets/libs/gt4.js', [], PUOCK_CUR_VER_STR, true);
}
wp_enqueue_script('puock', pk_get_static_url() . '/assets/dist/js/puock.min.js', array('puock-libs'), PUOCK_CUR_VER_STR, true);

//加载全站黑白样式
if(pk_is_checked('grey')){
wp_add_inline_style( 'puock', 'html {
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-o-filter: grayscale(100%);
}');
}

//加载自定义样式
if (!empty(pk_get_option('css_code_header', ''))){
wp_add_inline_style( 'puock', pk_get_option('css_code_header', ''));
}
}
}

Expand Down
12 changes: 0 additions & 12 deletions templates/css-grey.php

This file was deleted.

0 comments on commit 81511a1

Please sign in to comment.