Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
node_modules/
.idea/
7 changes: 6 additions & 1 deletion assets/css/customizer.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

#customize-control-maxwell_theme_options-blog_description,
#customize-control-maxwell_theme_options-post_layout,
#customize-control-maxwell_theme_options-excerpt_length,
#customize-control-maxwell_theme_options-read_more_text,
#customize-control-maxwell_theme_options-blog_excerpt_settings_title,
#customize-control-maxwell_theme_options-blog_magazine_widgets_title,
#customize-control-maxwell_theme_options-single_post_headline,
#customize-control-maxwell_theme_options-featured_images,
Expand All @@ -31,8 +31,13 @@
margin-top: 16px;
}

#customize-control-maxwell_theme_options-excerpt_length {
margin-top: 0;
}

#customize-control-maxwell_theme_options-retina_logo_title,
#customize-control-maxwell_theme_options-postmeta_headline,
#customize-control-maxwell_theme_options-blog_excerpt_settings_title,
#customize-control-maxwell_theme_options-blog_magazine_widgets_title,
#customize-control-maxwell_theme_options-single_post_headline,
#customize-control-maxwell_theme_options-featured_images,
Expand Down
12 changes: 11 additions & 1 deletion assets/js/customizer-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// Based on https://make.xwp.co/2016/07/24/dependently-contextual-customizer-controls/
wp.customize( 'custom_logo', function( setting ) {
setting.bind( function( value ) {
setting.bind( function( value ) {
if ( '' !== value ) {
// Set retina logo option to false when a new logo image is uploaded.
wp.customize.instance( 'maxwell_theme_options[retina_logo]' ).set( false );
Expand All @@ -33,4 +33,14 @@
wp.customize.control( 'maxwell_theme_options[retina_logo]', setupControl );
} );

// Excerpt Settings
wp.customize( 'maxwell_theme_options[excerpt_use_more_tag]', function( value ) {
const excerptUseMoreTagCallback = function( newVal ) {
const excerptLengthControls = $('#customize-control-maxwell_theme_options-excerpt_length');
true === newVal ? excerptLengthControls.hide() : excerptLengthControls.show();
}
excerptUseMoreTagCallback(value.get());
value.bind( excerptUseMoreTagCallback );
});

})( this.wp, jQuery );
1 change: 1 addition & 0 deletions inc/customizer/default-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function maxwell_default_options() {
'post_layout' => 'one-column',
'read_more_text' => esc_html__( 'Continue reading', 'maxwell' ),
'blog_magazine_widgets' => true,
'excerpt_use_more_tag' => false,
'excerpt_length' => 20,
'meta_date' => true,
'meta_author' => true,
Expand Down
28 changes: 27 additions & 1 deletion inc/customizer/sections/customizer-blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function maxwell_customize_register_blog_settings( $wp_customize ) {

// Add Blog Layout setting and control.
$wp_customize->add_setting( 'maxwell_theme_options[post_layout]', array(
'default' => 'three-columns',
'default' => 'one-column',
'type' => 'option',
'transport' => 'refresh',
'sanitize_callback' => 'maxwell_sanitize_select',
Expand All @@ -86,6 +86,32 @@ function maxwell_customize_register_blog_settings( $wp_customize ) {
),
) );

// Add Excerpt Settings Headline.
$wp_customize->add_control( new Maxwell_Customize_Header_Control(
$wp_customize, 'maxwell_theme_options[blog_excerpt_settings_title]', array(
'label' => esc_html__( 'Excerpt Settings', 'maxwell' ),
'section' => 'maxwell_section_blog',
'settings' => array(),
'priority' => 32,
)
) );

// Add Setting and Control for support for More Block.
$wp_customize->add_setting( 'maxwell_theme_options[excerpt_use_more_tag]', array(
'default' => false,
'type' => 'option',
'transport' => 'refresh',
'sanitize_callback' => 'maxwell_sanitize_checkbox',
) );

$wp_customize->add_control( 'maxwell_theme_options[excerpt_use_more_tag]', array(
'label' => esc_html__( 'Excerpt based on More Block', 'maxwell' ),
'section' => 'maxwell_section_blog',
'settings' => 'maxwell_theme_options[excerpt_use_more_tag]',
'type' => 'checkbox',
'priority' => 35,
) );

// Add Excerpt Length setting and control.
$wp_customize->add_setting( 'maxwell_theme_options[excerpt_length]', array(
'default' => 20,
Expand Down
2 changes: 1 addition & 1 deletion inc/extras.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function maxwell_excerpt_length( $length ) {
* @return string
*/
function maxwell_excerpt_more( $more_text ) {
return '';
return ' ...';
}
add_filter( 'excerpt_more', 'maxwell_excerpt_more' );

Expand Down
10 changes: 8 additions & 2 deletions template-parts/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@
</header><!-- .entry-header -->

<div class="entry-content entry-excerpt clearfix">
<?php the_excerpt(); ?>
<?php maxwell_more_link(); ?>
<?php
if ( maxwell_get_option( 'excerpt_use_more_tag' ) ) {
the_content(maxwell_get_option( 'read_more_text' ));
} else {
the_excerpt();
maxwell_more_link();
}
?>
</div><!-- .entry-content -->

</article>
Expand Down