Permalink
Browse files

simplify the sidebar

  • Loading branch information...
bueltge committed Jan 4, 2018
1 parent c07f285 commit 281bdf2de1814dc94207145f5e8a0f6ca42579f0
Showing with 51 additions and 63 deletions.
  1. +30 −11 inc/Setup.php
  2. +8 −44 sidebar.php
  3. +13 −8 widgets/{init.php → Widgets_Init.php}
View
@@ -24,17 +24,6 @@
use Wp_Basis\Gutenberg\Gutenberg;
use Wp_Basis\I18n\I18n;
/**
* Set the content width in pixels based on the theme's design and stylesheet.
* Also the width of oEmbed objects to scale specific size
*
* @since 2012-05-08 0.0.1
*/
if ( ! isset( $content_width ) ) {
/** @noinspection PhpUnusedLocalVariableInspection */
$content_width = 640;
} /* pixels */
/**
* Sets up theme defaults and registers support for various WordPress features.
*
@@ -49,6 +38,14 @@
add_action( 'init', __NAMESPACE__ . '\\setup' );
function setup() {
/**
* Set the content width in pixels based on the theme's design and stylesheet.
* Also the width of oEmbed objects to scale specific size
*
* @since 2012-05-08 0.0.1
*/
$GLOBALS['content_width'] = 640; /* pixels */
/**
* Set the prefix for each usage.
* Use the core class for all primary settings about the theme functions.
@@ -98,8 +95,30 @@ function setup() {
* Add default posts and comments RSS feed links to head
*/
add_theme_support( 'automatic-feed-links' );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
) );
}
/**
* Makes widget-ready.
*/
require_once __DIR__ . '/../widgets/Widgets_Init.php';
/**
* Enqueue Scripts and Style.
*
* @ToDo we should switch this in separately class.
*/
add_action( 'wp_enqueue_scripts', '\Wp_Basis\Setup\scripts' );
function scripts() {
View
@@ -1,15 +1,15 @@
<?php
/**
* @package WordPress
* @package WordPress
* @subpackage WP-Basis Theme
* @template sidebar template
* @since 0.0.1
* @template sidebar template
* @since 0.0.1
*/
if ( get_theme_support( 'show_sidebar-1' ) && 'on' != get_theme_mod( 'show_sidebar-1' ) )
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
return;
?>
}
<?php
/*
* An <aside> is used to enclose content that is additional to the main content
* but not essential. If it were removed, the meaning of the main content should not be lost,
@@ -20,43 +20,7 @@
* information for the main content that remains meaningful even when separated from it
*/
?>
<aside id="sidebar" role="complementary">
<?php
/**
* A <header> element is not required
* here as the heading only contains a single <h1> element
*/
?>
<h1><?php _e('Sidebar', 'wp_basis'); ?></h1>
<nav>
<h2><?php _e('Navigation', 'wp_basis'); ?></h2>
<ul>
<?php
/* Widgetized sidebar, if you have the plugin installed. */
if ( ! dynamic_sidebar() ) : ?>
<li id="posts" class="widget">
<h3 class="widget-title"><?php _e('Last Posts', 'wp_basis') ?></h3>
<ul>
<?php wp_get_archives('type=postbypost&limit=10'); ?>
</ul>
</li>
<li id="meta" class="widget">
<h3 class="widget-title"><?php _e( 'Meta', 'wp_basis' ); ?></h1>
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<?php wp_meta(); ?>
</ul>
</li>
<?php
endif; // End Widgets
?>
</ul>
</nav>
<aside id="sidebar" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</aside>
@@ -1,6 +1,6 @@
<?php
/**
* Init wor Widgetized area
* Init wor Widgetized area.
*
* @package WP Basis
* @since 06/05/2012 0.0.1
@@ -14,25 +14,30 @@
*
* @since 06/05/2012 0.0.1
* @version 06/05/2012
* @author Frank Bültge <frank@bueltge.de>
* @author Frank Bültge <frank@bueltge.de>
*/
namespace Wp_Basis\Widgets;
namespace Wp_Basis\Widgets_Init;
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* Register widgetized area and update sidebar with default widgets
*
* @since 06/05/2012 0.0.1
* @version 06/05/2012
* @author Frank Bültge <frank@bueltge.de>
* @author Frank Bültge <frank@bueltge.de>
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
add_action( 'widgets_init', '\Wp_Basis\Widgets\widgets_init' );
add_action( 'widgets_init', __NAMESPACE__ . '\\widgets_init' );
function widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'wp_basis' ),
'id' => 'sidebar-1',
'description' => __( 'The primary Sidebar', 'wp_basis' ),
'name' => esc_attr__( 'Sidebar', 'wp_basis' ),
'description' => esc_attr__( 'The primary Sidebar', 'wp_basis' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );

0 comments on commit 281bdf2

Please sign in to comment.