diff --git a/functions.php b/functions.php
index 04d429a..9284a15 100644
--- a/functions.php
+++ b/functions.php
@@ -645,19 +645,19 @@ function wpjam_custom_upload_dir( $uploads ) {
* 删除自带小工具
*/
function unregister_default_widgets() {
- unregister_widget("WP_Widget_Pages");
+ //unregister_widget("WP_Widget_Pages");
unregister_widget("WP_Widget_Calendar");
- unregister_widget("WP_Widget_Archives");
+ //unregister_widget("WP_Widget_Archives");
unregister_widget("WP_Widget_Links");
unregister_widget("WP_Widget_Meta");
- unregister_widget("WP_Widget_Search");
+ //unregister_widget("WP_Widget_Search");
unregister_widget("WP_Widget_Text");
- unregister_widget("WP_Widget_Categories");
- unregister_widget("WP_Widget_Recent_Posts");
+ //unregister_widget("WP_Widget_Categories");
+ //unregister_widget("WP_Widget_Recent_Posts");
unregister_widget("WP_Widget_Recent_Comments");
unregister_widget("WP_Widget_RSS");
unregister_widget("WP_Widget_Tag_Cloud");
- unregister_widget("WP_Nav_Menu_Widget");
+ //unregister_widget("WP_Nav_Menu_Widget");
}
add_action("widgets_init", "unregister_default_widgets", 11);
@@ -1642,4 +1642,17 @@ function sakura_comment_notify($comment_id){
}
add_action('comment_post', 'sakura_comment_notify');
+//侧栏小工具
+if (akina_option('sakura_widget')) {
+ if (function_exists('register_sidebar')) {
+ register_sidebar(array(
+ 'name' => '侧栏',
+ 'id' => 'sakura_widget',
+ 'before_widget' => '
',
+ 'after_widget' => '
',
+ 'before_title' => '
',
+ 'after_title' => '
'
+ ));
+ }
+}
//code end
diff --git a/js/sakura-app.js b/js/sakura-app.js
index fb0754c..51bf1e8 100644
--- a/js/sakura-app.js
+++ b/js/sakura-app.js
@@ -976,6 +976,17 @@ function mail_me() {
window.open(mail);
}
+function activate_widget(){
+ if (document.body.clientWidth > 860) {
+ $('.show_hide').on('click', function() {
+ $("#secondary").toggleClass("active")
+ });
+ }else{
+ $("#secondary").remove();
+ }
+}
+activate_widget();
+
mashiro_global.ini.normalize();
loadCSS(mashiro_option.jsdelivr_css_src);
loadCSS(mashiro_option.entry_content_theme_src);
diff --git a/options.php b/options.php
index 4cacb2b..8618063 100644
--- a/options.php
+++ b/options.php
@@ -954,6 +954,13 @@ function optionsframework_options() {
'id' => 'nprogress_on',
'std' => '0',
'type' => 'checkbox');
+
+ $options[] = array(
+ 'name' => __('Enable sidebar widget', 'sakura'),/*支持侧栏小部件*/
+ 'desc' => __('Default off, check on', 'sakura'),/*默认不开启,勾选开启*/
+ 'id' => 'sakura_widget',
+ 'std' => '0',
+ 'type' => 'checkbox');
$options[] = array(
'name' => __('Enable Announcement', 'sakura'),
diff --git a/sidebar.php b/sidebar.php
index 05e2185..103ff51 100644
--- a/sidebar.php
+++ b/sidebar.php
@@ -7,7 +7,8 @@
* @package Akina
*/
-if ( ! is_active_sidebar( 'sidebar-1' ) ) {
+//disable get_sidebar()
+if ( is_active_sidebar( 'sakura_widget' ) ) {
return;
}
?>
diff --git a/style.css b/style.css
index b10bb5e..30c1e58 100644
--- a/style.css
+++ b/style.css
@@ -8500,3 +8500,51 @@ h1[id*=toc-head]::before,h2[id*=toc-head]::before,h3[id*=toc-head]::before,h4[id
visibility:hidden
}
+.widget-area {
+ position: fixed;
+ top: 88%;
+ bottom: 10%;
+ left: -400px;
+ z-index: 3;
+ width: 400px;
+ webkit-transition: .3s;
+ transition: all .3s;
+ background-color: rgba(255,255,255,0.8);
+ box-shadow: 0 1px 20px -8px rgba(0,0,0,.5);
+}
+.widget-area.active{
+ top: 100px;
+ bottom: 80px;
+ left: -1px !important;
+}
+
+.widget-area .sakura_widget{
+ padding: 16px;
+ height: calc(100% - 30px);
+ overflow-y: auto;
+}
+
+.widget-area .heading{
+ color: #555;
+ font-size: 20px;
+ font-weight: 900;
+ text-align: center;
+ height: 30px;
+ background-color: #f5f5f5;
+ border-color: #ddd;
+}
+
+.widget-area .show_hide{
+ position: absolute;
+ right: -42px;
+ height: 30px;
+ background: #f5f5f5;
+ border-color: #ddd;
+ outline:none;
+ box-shadow: none;
+ border-left-width: 0;
+}
+
+.widget-area .show_hide .fa{
+ font-size: 20px;
+}