Skip to content

Commit

Permalink
added Customizer control to change Read More text
Browse files Browse the repository at this point in the history
  • Loading branch information
Netzberufler committed Jun 9, 2018
1 parent 74132d4 commit c765feb
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 47 deletions.
8 changes: 4 additions & 4 deletions assets/css/customizer.css
Expand Up @@ -14,11 +14,11 @@
margin-bottom: 16px;
}

#customize-control-tortuga_theme_options-blog_title,
#customize-control-tortuga_theme_options-blog_description,
#customize-control-tortuga_theme_options-blog_magazine_widgets_title,
#customize-control-tortuga_theme_options-post_layout,
#customize-control-tortuga_theme_options-excerpt_length,
#customize-control-tortuga_theme_options-postmeta_headline,
#customize-control-tortuga_theme_options-read_more_text,
#customize-control-tortuga_theme_options-blog_magazine_widgets_title,
#customize-control-tortuga_theme_options-single_post_headline,
#customize-control-tortuga_theme_options-featured_images,
#customize-control-tortuga_theme_options-slider_category,
Expand All @@ -36,7 +36,7 @@
}

#customize-control-tortuga_theme_options-blog_description textarea {
height: 5em;
height: 4em;
}

#customize-control-tortuga_theme_options-upgrade div {
Expand Down
7 changes: 7 additions & 0 deletions assets/js/customizer.js
Expand Up @@ -69,6 +69,13 @@
} );
} );

// Read More textfield.
wp.customize( 'tortuga_theme_options[read_more_text]', function( value ) {
value.bind( function( to ) {
$( 'a.more-link' ).text( to );
} );
} );

// Post Date checkbox.
wp.customize( 'tortuga_theme_options[meta_date]', function( value ) {
value.bind( function( newval ) {
Expand Down
4 changes: 2 additions & 2 deletions inc/customizer/customizer.php
Expand Up @@ -145,7 +145,7 @@ function tortuga_customize_partial_blogdescription() {
* Embed JS file to make Theme Customizer preview reload changes asynchronously.
*/
function tortuga_customize_preview_js() {
wp_enqueue_script( 'tortuga-customizer-preview', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20170806', true );
wp_enqueue_script( 'tortuga-customizer-preview', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20180609', true );
}
add_action( 'customize_preview_init', 'tortuga_customize_preview_js' );

Expand All @@ -154,7 +154,7 @@ function tortuga_customize_preview_js() {
* Embed CSS styles for the theme options in the Customizer
*/
function tortuga_customize_preview_css() {
wp_enqueue_style( 'tortuga-customizer-css', get_template_directory_uri() . '/assets/css/customizer.css', array(), '20170806' );
wp_enqueue_style( 'tortuga-customizer-css', get_template_directory_uri() . '/assets/css/customizer.css', array(), '20180609' );
}
add_action( 'customize_controls_print_styles', 'tortuga_customize_preview_css' );

Expand Down
82 changes: 57 additions & 25 deletions inc/customizer/sections/customizer-blog.php
Expand Up @@ -21,27 +21,6 @@ function tortuga_customize_register_blog_settings( $wp_customize ) {
'panel' => 'tortuga_options_panel',
) );

// Add Blog Layout setting and control.
$wp_customize->add_setting( 'tortuga_theme_options[post_layout]', array(
'default' => 'two-columns',
'type' => 'option',
'transport' => 'refresh',
'sanitize_callback' => 'tortuga_sanitize_select',
)
);
$wp_customize->add_control( 'tortuga_theme_options[post_layout]', array(
'label' => esc_html__( 'Blog Layout', 'tortuga' ),
'section' => 'tortuga_section_blog',
'settings' => 'tortuga_theme_options[post_layout]',
'type' => 'select',
'priority' => 10,
'choices' => array(
'one-column' => esc_html__( 'One Column', 'tortuga' ),
'two-columns' => esc_html__( 'Two Columns', 'tortuga' ),
'three-columns' => esc_html__( 'Three Columns without Sidebar', 'tortuga' ),
),
) );

// Add Blog Title setting and control.
$wp_customize->add_setting( 'tortuga_theme_options[blog_title]', array(
'default' => '',
Expand All @@ -55,7 +34,7 @@ function tortuga_customize_register_blog_settings( $wp_customize ) {
'section' => 'tortuga_section_blog',
'settings' => 'tortuga_theme_options[blog_title]',
'type' => 'text',
'priority' => 20,
'priority' => 10,
) );

$wp_customize->selective_refresh->add_partial( 'tortuga_theme_options[blog_title]', array(
Expand All @@ -77,7 +56,7 @@ function tortuga_customize_register_blog_settings( $wp_customize ) {
'section' => 'tortuga_section_blog',
'settings' => 'tortuga_theme_options[blog_description]',
'type' => 'textarea',
'priority' => 30,
'priority' => 20,
) );

$wp_customize->selective_refresh->add_partial( 'tortuga_theme_options[blog_description]', array(
Expand All @@ -86,13 +65,66 @@ function tortuga_customize_register_blog_settings( $wp_customize ) {
'fallback_refresh' => false,
) );

// Add Blog Layout setting and control.
$wp_customize->add_setting( 'tortuga_theme_options[post_layout]', array(
'default' => 'two-columns',
'type' => 'option',
'transport' => 'refresh',
'sanitize_callback' => 'tortuga_sanitize_select',
) );

$wp_customize->add_control( 'tortuga_theme_options[post_layout]', array(
'label' => esc_html__( 'Blog Layout', 'tortuga' ),
'section' => 'tortuga_section_blog',
'settings' => 'tortuga_theme_options[post_layout]',
'type' => 'select',
'priority' => 30,
'choices' => array(
'one-column' => esc_html__( 'One Column', 'tortuga' ),
'two-columns' => esc_html__( 'Two Columns', 'tortuga' ),
'three-columns' => esc_html__( 'Three Columns without Sidebar', 'tortuga' ),
),
) );

// Add Setting and Control for Excerpt Length.
$wp_customize->add_setting( 'tortuga_theme_options[excerpt_length]', array(
'default' => 20,
'type' => 'option',
'transport' => 'postMessage',
'sanitize_callback' => 'absint',
) );

$wp_customize->add_control( 'tortuga_theme_options[excerpt_length]', array(
'label' => esc_html__( 'Excerpt Length', 'tortuga' ),
'section' => 'tortuga_section_blog',
'settings' => 'tortuga_theme_options[excerpt_length]',
'type' => 'text',
'priority' => 40,
) );

// Add Setting and Control for Read More Text.
$wp_customize->add_setting( 'tortuga_theme_options[read_more_text]', array(
'default' => esc_html__( 'Continue reading', 'tortuga' ),
'type' => 'option',
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_text_field',
) );

$wp_customize->add_control( 'tortuga_theme_options[read_more_text]', array(
'label' => esc_html__( 'Read More Text', 'tortuga' ),
'section' => 'tortuga_section_blog',
'settings' => 'tortuga_theme_options[read_more_text]',
'type' => 'text',
'priority' => 50,
) );

// Add Magazine Widgets Headline.
$wp_customize->add_control( new Tortuga_Customize_Header_Control(
$wp_customize, 'tortuga_theme_options[blog_magazine_widgets_title]', array(
'label' => esc_html__( 'Magazine Widgets', 'tortuga' ),
'section' => 'tortuga_section_blog',
'settings' => array(),
'priority' => 40,
'priority' => 60,
)
) );

Expand All @@ -109,7 +141,7 @@ function tortuga_customize_register_blog_settings( $wp_customize ) {
'section' => 'tortuga_section_blog',
'settings' => 'tortuga_theme_options[blog_magazine_widgets]',
'type' => 'checkbox',
'priority' => 50,
'priority' => 70,
) );
}
add_action( 'customize_register', 'tortuga_customize_register_blog_settings' );
Expand Down
16 changes: 0 additions & 16 deletions inc/customizer/sections/customizer-post.php
Expand Up @@ -21,22 +21,6 @@ function tortuga_customize_register_post_settings( $wp_customize ) {
'panel' => 'tortuga_options_panel',
) );

// Add Setting and Control for Excerpt Length.
$wp_customize->add_setting( 'tortuga_theme_options[excerpt_length]', array(
'default' => 20,
'type' => 'option',
'transport' => 'postMessage',
'sanitize_callback' => 'absint',
) );

$wp_customize->add_control( 'tortuga_theme_options[excerpt_length]', array(
'label' => esc_html__( 'Excerpt Length', 'tortuga' ),
'section' => 'tortuga_section_post',
'settings' => 'tortuga_theme_options[excerpt_length]',
'type' => 'text',
'priority' => 10,
) );

// Add Post Details Headline.
$wp_customize->add_control( new Tortuga_Customize_Header_Control(
$wp_customize, 'tortuga_theme_options[postmeta_headline]', array(
Expand Down

0 comments on commit c765feb

Please sign in to comment.