diff --git a/.gitignore b/.gitignore index 40b878d..78f2710 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules/ \ No newline at end of file +node_modules/ +.idea/ diff --git a/assets/css/customizer.css b/assets/css/customizer.css index 3fee35f..b30718d 100644 --- a/assets/css/customizer.css +++ b/assets/css/customizer.css @@ -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, @@ -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, diff --git a/assets/js/customizer-controls.js b/assets/js/customizer-controls.js index 53f24a1..6c8bf16 100644 --- a/assets/js/customizer-controls.js +++ b/assets/js/customizer-controls.js @@ -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 ); @@ -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 ); diff --git a/inc/customizer/default-options.php b/inc/customizer/default-options.php index 8f0a012..0521f8a 100644 --- a/inc/customizer/default-options.php +++ b/inc/customizer/default-options.php @@ -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, diff --git a/inc/customizer/sections/customizer-blog.php b/inc/customizer/sections/customizer-blog.php index 8650d9d..9d50241 100644 --- a/inc/customizer/sections/customizer-blog.php +++ b/inc/customizer/sections/customizer-blog.php @@ -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', @@ -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, diff --git a/inc/extras.php b/inc/extras.php index a558c5a..6a5954e 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -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' ); diff --git a/template-parts/content.php b/template-parts/content.php index 5cf8e8a..a30e89b 100644 --- a/template-parts/content.php +++ b/template-parts/content.php @@ -22,8 +22,14 @@
- - +