Created
March 30, 2017 21:47
-
-
Save emiluzelac/32d53ab85c05cda846ad61590588a7bb to your computer and use it in GitHub Desktop.
Escape translated strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Escape translated strings with: | |
*/ | |
__( ‘Hello world’, ‘text-domain’ ); _e( ‘Hello world’, ‘text-domain’ );. | |
/** | |
* If there is no HTML use: | |
*/ | |
esc_html__( ‘Hello world’, ‘text-domain’ ); esc_html_e( ‘Hello world’, ‘text-domain’ ); | |
/** | |
* When there's some HTML use: | |
*/ | |
wp_kses( __( ‘Hello world’, ‘text-domain’ ), $allowed_html_array ); |
@joyously - Here's an option if you're not wanting any tags from the title to appear:
<?php
edit_post_link(
sprintf(
// Translators: %s is the post title shown to screen readers.
esc_html__( 'Edit%s' ),
' <span class="screen-reader-text">' . wp_strip_all_tags( get_the_title() ) . '</span>'
)
);
Thanks, I think @justintadlock has the best version since the HTML is of no use to screen readers.
But I've been thinking lately that the screen reader user might be better off with "Edit current post", rather than "Edit Hello World!".
i am currently working with codeigniter can i use html_escape?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@joyously, I am currently doing this: