Skip to content

Commit

Permalink
feat: add child theme support (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
seatonjiang committed Jun 25, 2021
1 parent b18299b commit 6883a9e
Show file tree
Hide file tree
Showing 11 changed files with 2,509 additions and 2,518 deletions.
2,497 changes: 0 additions & 2,497 deletions assets/css/kratos.css

This file was deleted.

1 change: 0 additions & 1 deletion assets/css/kratos.min.css

This file was deleted.

Empty file removed custom/custom.css
Empty file.
2 changes: 0 additions & 2 deletions custom/custom.js

This file was deleted.

2 changes: 0 additions & 2 deletions custom/custom.php

This file was deleted.

3 changes: 0 additions & 3 deletions custom/readme.md

This file was deleted.

9 changes: 3 additions & 6 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* 模板函数
* @author Seaton Jiang <[email protected]>
* @license MIT License
* @version 2020.06.05
* @version 2020.06.25
*/

define('THEME_VERSION', wp_get_theme()->get('Version'));
define('THEME_VERSION', '3.3.2');

// 主题配置
require get_template_directory() . '/inc/options-framework/autoload.php';
Expand Down Expand Up @@ -39,7 +39,4 @@
require get_template_directory() . '/inc/theme-volcengine.php';

// SMTP 配置
require get_template_directory() . '/inc/theme-smtp.php';

// 自定义函数
require get_template_directory() . '/custom/custom.php';
require get_template_directory() . '/inc/theme-smtp.php';
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function enqueue_admin_styles( $hook ) {
if ( $this->options_screen != $hook )
return;

wp_enqueue_style( 'optionsframework', get_stylesheet_directory_uri() . '/inc/options-framework/css/optionsframework.css', array(), Options_Framework::VERSION );
wp_enqueue_style( 'optionsframework', 'https://cdn.jsdelivr.net/gh/vtrois/kratos@' . THEME_VERSION . '/inc/options-framework/css/optionsframework.css', array(), Options_Framework::VERSION );
wp_enqueue_style( 'wp-color-picker' );
}

Expand All @@ -133,7 +133,7 @@ function enqueue_admin_scripts( $hook ) {
// Enqueue custom option panel JS
wp_enqueue_script(
'options-custom',
get_stylesheet_directory_uri() . '/inc/options-framework/js/options-custom.js',
'https://cdn.jsdelivr.net/gh/vtrois/kratos@' . THEME_VERSION . '/inc/options-framework/js/options-custom.js',
array( 'jquery','wp-color-picker' ),
Options_Framework::VERSION
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function optionsframework_media_scripts( $hook ) {
if ( function_exists( 'wp_enqueue_media' ) )
wp_enqueue_media();

wp_register_script( 'of-media-uploader', get_stylesheet_directory_uri() . '/inc/options-framework/js/media-uploader.js', array( 'jquery' ), Options_Framework::VERSION );
wp_register_script( 'of-media-uploader', 'https://cdn.jsdelivr.net/gh/vtrois/kratos@' . THEME_VERSION . '/inc/options-framework/js/media-uploader.js', array( 'jquery' ), Options_Framework::VERSION );
wp_enqueue_script( 'of-media-uploader' );
wp_localize_script( 'of-media-uploader', 'optionsframework_l10n', array(
'upload' => __( '上传', 'kratos' ),
Expand Down
10 changes: 6 additions & 4 deletions inc/theme-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 核心函数
* @author Seaton Jiang <[email protected]>
* @license MIT License
* @version 2021.06.05
* @version 2021.06.25
*/

if (kratos_option('g_cdn', false)) {
Expand Down Expand Up @@ -45,7 +45,11 @@ function theme_autoload()
if (kratos_option('g_fontawesome', false)) {
wp_enqueue_style('fontawesome', ASSET_PATH . '/assets/css/fontawesome.min.css', array(), '5.15.2');
}
wp_enqueue_style('kratos', ASSET_PATH . '/assets/css/kratos.min.css', array(), THEME_VERSION);
if (kratos_option('g_cdn', false) && !is_child_theme()) {
wp_enqueue_style('kratos', 'https://cdn.jsdelivr.net/gh/vtrois/kratos@' . THEME_VERSION . '/style.css' , array(), THEME_VERSION);
} else {
wp_enqueue_style('kratos', get_stylesheet_uri(), array(), THEME_VERSION);
}
if (kratos_option('g_adminbar', true)) {
$admin_bar_css = "
@media screen and (min-width: 782px) {
Expand All @@ -67,7 +71,6 @@ function theme_autoload()
wp_add_inline_style('kratos', $admin_bar_css);
}
}
wp_enqueue_style('custom', get_template_directory_uri() . '/custom/custom.css', array(), THEME_VERSION);
// js
wp_deregister_script('jquery');
wp_enqueue_script('jquery', ASSET_PATH . '/assets/js/jquery.min.js', array(), '3.4.1', false);
Expand All @@ -76,7 +79,6 @@ function theme_autoload()
wp_enqueue_script('sticky', ASSET_PATH . '/assets/js/theia-sticky-sidebar.min.js', array(), '1.5.0', true);
wp_enqueue_script('dplayer', ASSET_PATH . '/assets/js/DPlayer.min.js', array(), THEME_VERSION, true);
wp_enqueue_script('kratos', ASSET_PATH . '/assets/js/kratos.min.js', array(), THEME_VERSION, true);
wp_enqueue_script('custom', get_template_directory_uri() . '/custom/custom.js', array(), THEME_VERSION, true);

$data = array(
'site' => home_url(),
Expand Down
Loading

0 comments on commit 6883a9e

Please sign in to comment.