Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

改用wp_add_inline_style挂载行内和自定义样式 #397

Merged
merged 2 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,9 @@
<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
2 changes: 1 addition & 1 deletion inc/fun/opt.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ function pk_head_style_var()
$vars = [
"--puock-block-not-tran:" . pk_get_option('block_not_tran', 100) . "%",
];
return "<style>:root{" . join(";", $vars) . "}</style>";
return ":root{" . join(";", $vars) . "}";
}

// 加载文件媒体文件
Expand Down
24 changes: 23 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,29 @@ 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('style_color_primary'))) {
wp_add_inline_style('puock', 'body{--pk-c-primary:' . pk_get_option('style_color_primary') . '}');
}

//加载头部样式
wp_add_inline_style('puock', pk_head_style_var());

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

Expand Down
5 changes: 0 additions & 5 deletions templates/css-custom.php

This file was deleted.

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

This file was deleted.