Support » Plugin: Kirki Customizer Framework » Typography %s sample not working

  • Resolved WebTrooper

    (@webtrooper)


    The output sample at https://aristath.github.io/kirki/docs/controls/typography.html returns %s instead of the values. What am I doing wrong?

    My setting code:

    Kirki::add_field( 'theme_config_id', array(
    	'type'        => 'typography',
    	'settings'    => 'my_setting',
    	'label'       => esc_attr__( 'Control Label', 'textdomain' ),
    	'section'     => 'fonts',
    	'default'     => array(
    		'font-family'    => 'Roboto',
    		'variant'        => 'regular',
    		'font-size'      => '14px',
    		'line-height'    => '1.5',
    		'letter-spacing' => '0',
    		'subsets'        => array( 'latin-ext' ),
    		'color'          => '#333333',
    		'text-transform' => 'none',
    		'text-align'     => 'left'
    	),
    	'priority'    => $priority++,
    	'output'      => array(
    		array(
    			'element' => 'body',
    		),
    	),
    ) );

    and the code in my theme

    <?php
    $value = get_theme_mod( 'my_setting', array() );
    
    if ( isset( $value['font-family'] ) ) {
    	echo '<p>' . sprintf( esc_attr_e( 'Font Family: %s', 'textdomain' ), $value['font-family'] ) . '</p>';
    }
    if ( isset( $value['variant'] ) ) {
    	echo '<p>' . sprintf( esc_attr_e( 'Variant: %s', 'textdomain' ), $value['variant'] ) . '</p>';
    }
    if ( isset( $value['subsets'] ) ) {
    	if ( is_array( $value['subsets'] ) ) {
    		echo '<p>' . sprintf( esc_attr_e( 'Subsets: %s', 'textdomain' ), implode( ', ', $value['subsets'] ) ) . '</p>';
    	} else {
    		echo '<p>' . sprintf( esc_attr_e( 'Subset: %s', 'textdomain' ), $value['subsets'] ) . '</p>';
    	}
    }
    if ( isset( $value['font-size'] ) ) {
    	echo '<p>' . sprintf( esc_attr_e( 'Font Size: %s', 'textdomain' ), $value['font-size'] ) . '</p>';
    }
    if ( isset( $value['line-height'] ) ) {
    	echo '<p>' . sprintf( esc_attr_e( 'Line Height: %s', 'textdomain' ), $value['line-height'] ) . '</p>';
    }
    if ( isset( $value['letter-spacing'] ) ) {
    	echo '<p>' . sprintf( esc_attr_e( 'Letter Spacing: %s', 'textdomain' ), $value['letter-spacing'] ) . '</p>';
    }
    if ( isset( $value['color'] ) ) {
    	echo '<p>' . sprintf( esc_attr_e( 'Color: %s', 'textdomain' ), $value['color'] ) . '</p>';
    }

    WP 4.9.1 / PHP7 / Apache

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter WebTrooper

    (@webtrooper)

    I wish these forums allowed us a few minutes to edit our posts… hint, hint automattic! 🙂

    The output I get is as follows:

    Font Family: %s
    Variant: %s
    Subsets: %s
    Font Size: %s
    Line Height: %s
    Letter Spacing: %s
    Color: %s

    I don’t think it’s my code because I changed from the sample only what’s needed, and var_dump gives me the expected results

    array(12) {
    [“font-family”]=>
    string(11) “Roboto Slab”
    [“variant”]=>
    string(3) “700”
    [“font-size”]=>
    string(4) “16px”
    [“line-height”]=>
    string(3) “1.3”
    [“letter-spacing”]=>
    string(3) “1px”
    [“subsets”]=>
    array(4) {
    [0]=>
    string(12) “cyrillic-ext”
    [1]=>
    string(5) “greek”
    [2]=>
    string(9) “latin-ext”
    [3]=>
    string(10) “vietnamese”
    }
    [“color”]=>
    string(7) “#333333”
    [“text-transform”]=>
    string(4) “none”
    [“text-align”]=>
    string(4) “left”
    [“font-backup”]=>
    string(0) “”
    [“font-weight”]=>
    int(700)
    [“font-style”]=>
    string(6) “normal”
    }

    Plugin Author Ari Stathopoulos

    (@aristath)

    That was actually just a typo in my docs page… fixed now.
    The problem was the use of esc_attr_e() instead of esc_attr__().
    Fixed in the docs page. The values are saved fine, it was just the example had a dumb mistake in it 🙂

    Thread Starter WebTrooper

    (@webtrooper)

    Thanks Aristeides, you rock! 😀

    Plugin Author Ari Stathopoulos

    (@aristath)

    Glad I could help, merry Christmas!

    Thread Starter WebTrooper

    (@webtrooper)

    Merry Christmas back at ya!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Typography %s sample not working’ is closed to new replies.