add_section( 'baw_read_more' , array( 'title' => __( 'Read More Button Options', 'baw' ), 'priority' => 94, ) ); $wp_customize->add_setting( 'baw_read_more_activate', array ( 'default' => "Read More", 'sanitize_callback' => 'baw_sanitize_checkbox', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'baw_read_more_activate', array( 'label' => __( 'Activate Read More Button', 'baw' ), 'section' => 'baw_read_more', 'type' => 'checkbox', ) ) ); $wp_customize->add_setting( 'baw_read_more_setting', array ( 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'baw_read_more_setting', array( 'label' => __( 'Read More Button Text', 'baw' ), 'section' => 'baw_read_more', 'type' => 'text' ) ) ); $wp_customize->add_setting( 'baw_read_more_length', array ( 'default' => '30', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'baw_read_more_length', array( 'section' => 'baw_read_more', 'label' => __( 'Read More Button Length', 'baw' ), 'type' => 'number', 'input_attrs' => array( 'min' => 0, 'max' => 1000, 'step' => 1, ), ) ) ); $wp_customize->add_setting( 'baw_read_more_color', array ( 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'baw_read_more_color', array( 'label' => __( 'Read More Button Color', 'baw' ), 'section' => 'baw_read_more', ) ) ); $wp_customize->add_setting( 'baw_read_more_hover_color', array ( 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'baw_read_more_hover_color', array( 'label' => __( 'Read More Button Hover Color', 'baw' ), 'section' => 'baw_read_more', ) ) ); } add_action( 'customize_register', 'baw_customize_register_RM' ); /** * Excerpt */ function baw_excerpt_more( $more ) { if ( get_theme_mod('baw_read_more_activate', true ) ) { return ''; } } add_filter( 'excerpt_more', 'baw_excerpt_more' ); function customize_custom_excerpt_length( $length ) { if (get_theme_mod('baw_read_more_length')) { return get_theme_mod('baw_read_more_length'); } else return 42; } add_filter( 'excerpt_length', 'customize_custom_excerpt_length', 999 ); function baw_return_read_more_text () { if ( get_theme_mod('baw_read_more_setting', "Read More" ) ) { return get_theme_mod('baw_read_more_setting', "Read More" ); } return "Read More"; } /** * Read More Styles */ function bawread_more_method() { $read_more_color_mod = get_theme_mod( 'baw_read_more_color' ); $read_more_hover_color_mod = get_theme_mod( 'baw_read_more_hover_color' ); if($read_more_color_mod) { $read_more_color = ".read-more, .read-slide, .link-more a {color: {$read_more_color_mod};}";} else {$read_more_color ="";} if($read_more_hover_color_mod) { $read_more_hover_color = ".read-more, .read-slide:hover, .link-more a:hover {color: {$read_more_hover_color_mod};}";} else {$read_more_hover_color ="";} wp_add_inline_style( 'black-and-white-style', $read_more_color.$read_more_hover_color); } add_action( 'wp_enqueue_scripts', 'bawread_more_method' );