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
1 parent
edaa99c
commit 4024e24
Showing
4 changed files
with
99 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
/**/ |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
/**/ |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* @package Page Sidebar for TwentySeventeen | ||
* @author Joachim Jensen <jv@intox.dk> | ||
* @license GPLv3 | ||
* @copyright 2017 by Joachim Jensen | ||
*/ | ||
|
||
get_header(); ?> | ||
|
||
<div class="wrap"> | ||
<div id="primary" class="content-area"> | ||
<main id="main" class="site-main" role="main"> | ||
|
||
<?php | ||
while ( have_posts() ) : the_post(); | ||
|
||
get_template_part( 'template-parts/page/content', 'page' ); | ||
|
||
if ( comments_open() || get_comments_number() ) : | ||
comments_template(); | ||
endif; | ||
|
||
endwhile; | ||
?> | ||
|
||
</main><!-- #main --> | ||
</div><!-- #primary --> | ||
<?php get_sidebar(); ?> | ||
</div><!-- .wrap --> | ||
|
||
<?php get_footer(); | ||
|
||
// |
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* @package Page Sidebar for TwentySeventeen | ||
* @author Joachim Jensen <jv@intox.dk> | ||
* @license GPLv3 | ||
* @copyright 2017 by Joachim Jensen | ||
*/ | ||
/* | ||
* Plugin Name: Page Sidebar for TwentySeventeen | ||
* Plugin URI: https://mythemeshop.com/plugins/wp-quiz/ | ||
* Description: Adds the main sidebar to pages. Install Content Aware Sidebars for customization. | ||
* Version: 1.0 | ||
* Author: Joachim Jensen | ||
* Author URI: https://dev.institute | ||
* | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
/** | ||
* Check if sidebar should be added | ||
* | ||
* @since 1.0 | ||
* @return boolean | ||
*/ | ||
function psts_in_context() { | ||
return is_page() && !is_front_page(); | ||
} | ||
|
||
/** | ||
* Add relevant classes to body | ||
* | ||
* @since 1.0 | ||
* @param array $classes | ||
* @return array | ||
*/ | ||
function psts_body_classes( $classes ){ | ||
if ( psts_in_context() && is_active_sidebar( 'sidebar-1' ) ) { | ||
$classes[] = 'has-sidebar'; | ||
} | ||
return $classes; | ||
} | ||
|
||
/** | ||
* Include page template | ||
* | ||
* @since 1.0 | ||
* @param string $original_template | ||
* @return string | ||
*/ | ||
function psts_template( $original_template ) { | ||
if ( psts_in_context() ) { | ||
$original_template = plugin_dir_path( __FILE__ ) . 'templates/page.php'; | ||
} | ||
return $original_template; | ||
} | ||
|
||
add_filter( 'body_class', 'psts_body_classes' ); | ||
add_filter( 'template_include', 'psts_template' ); |