Question

I'm building a Wordpress theme and I use the Kirki Customizer framework to add controls and settings to the customiser. I added a description to some controls, using the following code:

'description' => esc_html__( 'Description here', 'kirki' ),

Now I want to add a link in the description to an external website. I already tried inserting HTML, but that doesn't work; it just did just output the flat HTML code. It probably has sth to do with the esc_html__() thing, but I already searched on the internet and couldn't find a solution for this. Please enlighten me if you have a solution! Thanks a lot ;)

Was it helpful?

Solution

esc_html__ is a translation API, specifically it's equivalent to this:

$var = esc_html( __( ... )  );

Note that __( is not a language construct, it's a WordPress function.

Your problem is that esc_html escapes your HTML so that its safe to render as text. Swap it for wp_kses_post, and remove the __ function, you don't want html inside translation strings


A sidenote: Frameworks are useful, but they have disadvantages, in order to get help you now need to have the luck of coming across somebody else already familiar with the kirki customizer framework, which I've never heard of. General customizer knowledge is of little to no help, severely limiting your ability to research solutions and get the help of others.

In this case, your question was answerable without knowing anything about the customizer

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top