-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
95 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,34 @@ | ||
<?php | ||
|
||
|
||
register_sidebar(array( | ||
'name' => __( '正文内容侧边栏' ), | ||
'id' => 'sidebar_single', | ||
'description' => __( '文章正文内容侧边栏' ), | ||
'before_widget' => '<div class="widget %2$s">', | ||
'after_widget' => '</div>', | ||
'before_title' => '<h3 class="widget-title">', | ||
'after_title' => '</h3>' | ||
) ); | ||
|
||
register_sidebar(array( | ||
'name' => __( '首页侧边栏' ), | ||
'id' => 'sidebar_home', | ||
'description' => __( '首页侧边栏' ), | ||
'before_widget' => '<div class="widget %2$s">', | ||
'after_widget' => '</div>', | ||
'before_title' => '<h3 class="widget-title">', | ||
'after_title' => '</h3>' | ||
) ); | ||
|
||
register_sidebar(array( | ||
'name' => __( '搜索页侧边栏' ), | ||
'id' => 'sidebar_search', | ||
'description' => __( '搜索页侧边栏' ), | ||
'before_widget' => '<div class="widget %2$s">', | ||
'after_widget' => '</div>', | ||
'before_title' => '<h3 class="widget-title">', | ||
'after_title' => '</h3>' | ||
) ); | ||
|
||
register_sidebar(array( | ||
'name' => __( '分类/标签页侧边栏' ), | ||
'id' => 'sidebar_cat', | ||
'description' => __( '分类/标签页侧边栏' ), | ||
'before_widget' => '<div class="widget %2$s">', | ||
'after_widget' => '</div>', | ||
'before_title' => '<h3 class="widget-title">', | ||
'after_title' => '</h3>' | ||
) ); | ||
|
||
register_sidebar(array( | ||
'name' => __( '单页面侧边栏' ), | ||
'id' => 'sidebar_page', | ||
'description' => __( '单页面侧边栏' ), | ||
'before_widget' => '<div class="widget %2$s">', | ||
'after_widget' => '</div>', | ||
'before_title' => '<h3 class="widget-title">', | ||
'after_title' => '</h3>' | ||
) ); | ||
|
||
register_sidebar(array( | ||
'name' => __( '其他页面侧边栏' ), | ||
'id' => 'sidebar_other', | ||
'description' => __( '包括作者/404等其他页面' ), | ||
'before_widget' => '<div class="widget %2$s">', | ||
'after_widget' => '</div>', | ||
'before_title' => '<h3 class="widget-title">', | ||
'after_title' => '</h3>' | ||
) ); | ||
|
||
register_sidebar(array( | ||
'name' => __( '通用侧边栏' ), | ||
'id' => 'sidebar_not', | ||
'description' => __( '若指定页面未配置任何栏目,则显示此栏目下的数据' ), | ||
'before_widget' => '<div class="widget %2$s">', | ||
'after_widget' => '</div>', | ||
'before_title' => '<h3 class="widget-title">', | ||
'after_title' => '</h3>' | ||
) ); | ||
add_action('widgets_init', 'pk_widgets_init'); | ||
function pk_widgets_init() | ||
{ | ||
pk_common_sidebar_register('sidebar_single', '正文内容 - 侧边栏', '文章正文内容侧边栏'); | ||
pk_common_sidebar_register('sidebar_home', '首页 - 侧边栏', '首页侧边栏'); | ||
pk_common_sidebar_register('sidebar_search', '搜索页 - 侧边栏', '搜索页侧边栏'); | ||
pk_common_sidebar_register('sidebar_cat', '分类/标签页 - 侧边栏', '分类/标签页侧边栏'); | ||
pk_common_sidebar_register('sidebar_page', '单页面 - 侧边栏', '单页面侧边栏'); | ||
pk_common_sidebar_register('sidebar_other', '其他页面 - 侧边栏', '包括作者/404等其他页面'); | ||
pk_common_sidebar_register('sidebar_not', '通用 - 侧边栏', '若指定页面未配置任何栏目,则显示此栏目下的数据'); | ||
pk_common_sidebar_register('post_content_author_top', '正文 - 作者上方栏目', '显示在正文作者栏上方的栏目'); | ||
pk_common_sidebar_register('post_content_author_bottom', '正文 - 作者下方栏目', '显示在正文作者栏下方的栏目'); | ||
pk_common_sidebar_register('index_bottom', '首页 - 底部栏目', '显示在首页内容最底部(友情链接上方的通栏项)'); | ||
pk_common_sidebar_register('index_cms_layout_top', 'CMS布局 - 分类栏上方栏目', 'CMS布局下显示在分类栏之上的栏目'); | ||
pk_common_sidebar_register('index_cms_layout_bottom', 'CMS布局 - 分类栏下方栏目', 'CMS布局下显示在分类栏之下的栏目'); | ||
pk_common_sidebar_register('post_content_comment_top', '正文 - 评论上方栏目', '显示在正文评论上方的栏目'); | ||
pk_common_sidebar_register('post_content_comment_bottom', '正文 - 评论下方栏目', '显示在正文评论下方的栏目'); | ||
pk_common_sidebar_register('page_content_comment_top', '页面 - 评论上方栏目', '显示在页面评论上方的栏目'); | ||
pk_common_sidebar_register('page_content_comment_bottom', '页面 - 评论下方栏目', '显示在页面评论下方的栏目'); | ||
} | ||
|
||
function pk_common_sidebar_register($id, $name, $description = '') | ||
{ | ||
register_sidebar(array( | ||
'name' => __($name, PUOCK), | ||
'id' => $id, | ||
'description' => __($description, PUOCK), | ||
'before_widget' => '<div class="widget %2$s">', | ||
'after_widget' => '</div>', | ||
'before_title' => '<h3 class="widget-title">', | ||
'after_title' => '</h3>' | ||
)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,21 @@ | ||
<?php if(pk_hide_sidebar()==false): ?> | ||
<div id="sidebar" class="<?php pk_open_box_animated('animated fadeInRight') ?> col-lg-4 d-none d-lg-block"> | ||
<div class="sidebar-main"> | ||
<?php | ||
|
||
function sidebar_check_has($name){ | ||
if(!dynamic_sidebar($name)){ | ||
dynamic_sidebar('sidebar_not'); | ||
} | ||
} | ||
if(is_home()): | ||
sidebar_check_has('sidebar_home'); | ||
elseif(is_single()): | ||
sidebar_check_has('sidebar_single'); | ||
elseif(is_search()): | ||
sidebar_check_has('sidebar_search'); | ||
elseif(is_category() || is_tag()): | ||
sidebar_check_has('sidebar_cat'); | ||
elseif(is_page()): | ||
sidebar_check_has('sidebar_page'); | ||
else: | ||
sidebar_check_has('sidebar_other'); | ||
endif; | ||
|
||
?> | ||
<?php if (!pk_hide_sidebar()): ?> | ||
<div id="sidebar" class="<?php pk_open_box_animated('animated fadeInRight') ?> col-lg-4 d-none d-lg-block"> | ||
<div class="sidebar-main"> | ||
<?php | ||
if (is_home()): | ||
pk_sidebar_check_has('sidebar_home'); | ||
elseif (is_single()): | ||
pk_sidebar_check_has('sidebar_single'); | ||
elseif (is_search()): | ||
pk_sidebar_check_has('sidebar_search'); | ||
elseif (is_category() || is_tag()): | ||
pk_sidebar_check_has('sidebar_cat'); | ||
elseif (is_page()): | ||
pk_sidebar_check_has('sidebar_page'); | ||
else: | ||
pk_sidebar_check_has('sidebar_other'); | ||
endif; | ||
?> | ||
</div> | ||
</div> | ||
</div> | ||
<?php endif; ?> | ||
<?php endif; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters