Skip to content

Commit

Permalink
simplify the sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
bueltge committed Jan 4, 2018
1 parent c07f285 commit 281bdf2
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 63 deletions.
41 changes: 30 additions & 11 deletions inc/Setup.php
Expand Up @@ -24,17 +24,6 @@
use Wp_Basis\Gutenberg\Gutenberg; use Wp_Basis\Gutenberg\Gutenberg;
use Wp_Basis\I18n\I18n; 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. * Sets up theme defaults and registers support for various WordPress features.
* *
Expand All @@ -49,6 +38,14 @@
add_action( 'init', __NAMESPACE__ . '\\setup' ); add_action( 'init', __NAMESPACE__ . '\\setup' );
function 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. * Set the prefix for each usage.
* Use the core class for all primary settings about the theme functions. * Use the core class for all primary settings about the theme functions.
Expand Down Expand Up @@ -98,8 +95,30 @@ function setup() {
* Add default posts and comments RSS feed links to head * Add default posts and comments RSS feed links to head
*/ */
add_theme_support( 'automatic-feed-links' ); 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' ); add_action( 'wp_enqueue_scripts', '\Wp_Basis\Setup\scripts' );
function scripts() { function scripts() {


Expand Down
52 changes: 8 additions & 44 deletions sidebar.php
@@ -1,15 +1,15 @@
<?php <?php
/** /**
* @package WordPress * @package WordPress
* @subpackage WP-Basis Theme * @subpackage WP-Basis Theme
* @template sidebar template * @template sidebar template
* @since 0.0.1 * @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; return;
?> }


<?php
/* /*
* An <aside> is used to enclose content that is additional to the main content * 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, * but not essential. If it were removed, the meaning of the main content should not be lost,
Expand All @@ -20,43 +20,7 @@
* information for the main content that remains meaningful even when separated from it * information for the main content that remains meaningful even when separated from it
*/ */
?> ?>
<aside id="sidebar" role="complementary"> <aside id="sidebar" class="widget-area" role="complementary">
<?php <?php dynamic_sidebar( 'sidebar-1' ); ?>
/**
* 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> </aside>


21 changes: 13 additions & 8 deletions widgets/init.php → widgets/Widgets_Init.php
@@ -1,6 +1,6 @@
<?php <?php
/** /**
* Init wor Widgetized area * Init wor Widgetized area.
* *
* @package WP Basis * @package WP Basis
* @since 06/05/2012 0.0.1 * @since 06/05/2012 0.0.1
Expand All @@ -14,25 +14,30 @@
* *
* @since 06/05/2012 0.0.1 * @since 06/05/2012 0.0.1
* @version 06/05/2012 * @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 * Register widgetized area and update sidebar with default widgets
* *
* @since 06/05/2012 0.0.1 * @since 06/05/2012 0.0.1
* @version 06/05/2012 * @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() { function widgets_init() {

register_sidebar( array( register_sidebar( array(
'name' => __( 'Sidebar', 'wp_basis' ),
'id' => 'sidebar-1', '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">', 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>", 'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">', 'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>', 'after_title' => '</h1>',
) ); ) );
Expand Down

0 comments on commit 281bdf2

Please sign in to comment.