Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wp 5251 post layout #420

Open
wants to merge 4 commits into
base: WP-5251-post-layout
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions core/includes/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,36 @@ function responsive_theme_options() {
* Responsive_wrapper_class
*/
function responsive_wrapper_classes() {
global $post;
$custom = ( get_post_custom( $post->ID ) ? get_post_custom( $post->ID ) : false );
$layout = ( isset( $custom['_responsive_layout'][0] ) ? $custom['_responsive_layout'][0] : 'default' );
$valid_layouts = responsive_get_valid_layouts();
?>
<div id="wrapper" class="site-content clearfix">
<div class="content-outer container">
<div class="row">
<div class="content-outer container">
<?php
if ( is_single() ) {
$row_class = ( 'sidebar-content-page' === $layout )
? esc_attr( implode( ' ', responsive_get_content_classes() ) )
: '';
} else {
$row_class = '';
}
?>
<div class="row <?php echo esc_html( $row_class ); ?>">

<?php responsive_in_wrapper(); // wrapper hook. ?>

<main id="primary" class="content-area <?php echo esc_attr( implode( ' ', responsive_get_content_classes() ) ); ?>" role="main">
<?php
if ( is_single() && 'full-width-page' === $layout ) {
?>
<main id="primary" class="content-area col-layout-full-width" role="main" style="width:100%;">
<?php
} else {
?>
<main id = 'primary' class = "content-area <?php echo esc_attr( implode( ' ', responsive_get_content_classes() ) ); ?>" role = 'main' >
<?php
}
?>
<?php
if ( is_home() || is_archive() ) {
echo '<div class="content-area-wrapper">';
Expand Down Expand Up @@ -537,4 +560,4 @@ function responsive_custom_footer() {
*/
function responsive_single_blog_related_posts_entry() {
do_action( 'responsive_single_blog_related_posts_entry' );
}
}
21 changes: 16 additions & 5 deletions core/includes/post-custom-meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ function responsive_get_valid_layouts() {
'content-sidebar-page' => __( 'Content/Sidebar', 'responsive' ),
'sidebar-content-page' => __( 'Sidebar/Content', 'responsive' ),
'full-width-page' => __( 'Full Width Page (no sidebar)', 'responsive' ),
'blog-2-col' => __( 'Blog 2 Column', 'responsive' ),
'blog-3-col' => __( 'Blog 3 Column', 'responsive' ),
'blog-4-col' => __( 'Blog 4 Column', 'responsive' ),
);

return apply_filters( 'responsive_valid_layouts', $layouts );
Expand Down Expand Up @@ -197,12 +194,27 @@ function responsive_layout_meta_box() {
<select name="_responsive_layout">
<?php foreach ( $valid_layouts as $slug => $name ) { ?>
<?php $selected = selected( $layout, $slug, false ); ?>
<option value="<?php echo esc_html( $slug ); ?>" <?php echo esc_html( $selected ); ?>><?php echo esc_html( $name ); ?></option>
<<option value="<?php echo esc_html( $slug ); ?>" <?php echo wp_kses_post( $selected ); ?>><?php echo esc_html( $name ); ?></option>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double <<

<?php } ?>
</select>
</p>
<?php
}
/**
* Saves the layout meta data for a post.
*
* This function checks if the '_responsive_layout' value is set in the POST request.
* If it is set, it sanitizes the input and updates the post meta for the given post ID.
*
* @param int $post_id The ID of the post being saved.
*/
function save_responsive_layout_meta( $post_id ) {
if ( isset( $_POST['_responsive_layout'] ) ) {
update_post_meta( $post_id, '_responsive_layout', sanitize_text_field( $_POST['_responsive_layout'] ) );
}
}
add_action( 'save_post', 'save_responsive_layout_meta' );


/**
* Validate, sanitize, and save post metadata.
Expand All @@ -225,7 +237,6 @@ function responsive_save_layout_post_metadata() {
}
$valid_layouts = responsive_get_valid_layouts();
$layout = ( isset( $_POST['_responsive_layout'] ) && array_key_exists( (string) wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_responsive_layout'] ) ) ), $valid_layouts ) ? wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_responsive_layout'] ) ) ) : 'default' );

update_post_meta( $post->ID, '_responsive_layout', $layout );
}

Expand Down
3 changes: 3 additions & 0 deletions core/sass/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,7 @@ body {
.page.sidebar-position-no:not(.woocommerce) .alignwide{
margin-left: auto;
margin-right: auto;
}
#wrapper .content-outer >.row.grid-right.col-620.fit{
flex-direction: row-reverse;
}
47 changes: 31 additions & 16 deletions sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,37 +45,35 @@
} elseif ( class_exists( 'LifterLMS' ) ) {


if ( in_array('post-type-archive-course', get_body_class()) || in_array('post-type-archive-llms_membership', get_body_class()) ) {
if ( in_array( 'post-type-archive-course', get_body_class() ) || in_array( 'post-type-archive-llms_membership', get_body_class() ) ) {

return;
} else {
return;
} else {

if ( ( is_page() && 'no' === get_theme_mod( 'responsive_page_sidebar_position', 'right' ) ) ||
( is_page() && 'no' === get_post_meta( get_the_ID(), 'responsive_page_meta_sidebar_position', true ) ) ||
( is_single() && 'no' === get_theme_mod( 'responsive_single_blog_sidebar_position', 'right' ) ) ||
( ( is_home() || is_search() || is_archive() ) && 'no' === get_theme_mod( 'responsive_blog_sidebar_position', 'right' ) )
) {
return;
}
if ( ( is_page() && 'no' === get_theme_mod( 'responsive_page_sidebar_position', 'right' ) ) ||
( is_page() && 'no' === get_post_meta( get_the_ID(), 'responsive_page_meta_sidebar_position', true ) ) ||
( is_single() && 'no' === get_theme_mod( 'responsive_single_blog_sidebar_position', 'right' ) ) ||
( ( is_home() || is_search() || is_archive() ) && 'no' === get_theme_mod( 'responsive_blog_sidebar_position', 'right' ) )
) {
return;
}

?>
?>
<aside id="secondary" class="main-sidebar widget-area <?php echo esc_attr( implode( ' ', responsive_get_sidebar_classes() ) ); ?>" role="complementary" <?php responsive_schema_markup( 'sidebar' ); ?>>

<?php

Responsive\responsive_widgets(); // above widgets hook.
if ( ! dynamic_sidebar( 'main-sidebar' ) ) :
endif; // End of main-sidebar.
Responsive\responsive_widgets_end(); // after widgets hook.
Responsive\responsive_widgets_end(); // after widgets hook.
?>

</aside><!-- end of #secondary -->
<?php
Responsive\responsive_widgets_after(); // after widgets container hook.

}


}
} else {

if ( ( is_page() && 'no' === get_theme_mod( 'responsive_page_sidebar_position', 'right' ) ) ||
Expand All @@ -87,7 +85,24 @@
}

?>
<aside id="secondary" class="main-sidebar widget-area <?php echo esc_attr( implode( ' ', responsive_get_sidebar_classes() ) ); ?>" role="complementary" <?php responsive_schema_markup( 'sidebar' ); ?>>
<?php
global $post;
$custom = ( get_post_custom( $post->ID ) ? get_post_custom( $post->ID ) : false );
$layout = ( isset( $custom['_responsive_layout'][0] ) ? $custom['_responsive_layout'][0] : 'default' );
$valid_layouts = responsive_get_valid_layouts();

if ( is_single() && 'full-width-page' === $layout ) {
?>
<aside id="secondary" class="main-sidebar widget-area col-layout-fw-sidebar" role="complementary" style="display:none;" <?php responsive_schema_markup( 'sidebar' ); ?>>

<?php
} else {
?>
<aside id="secondary" class="main-sidebar widget-area <?php echo esc_attr( implode( ' ', responsive_get_sidebar_classes() ) ); ?>" role="complementary" <?php responsive_schema_markup( 'sidebar' ); ?>>

<?php
}
?>

<?php

Expand Down