esc_sql

Definition:
function esc_sql( $sql ) {}

Escapes data for use in a MySQL query
This is just a handy shortcut for $wpdb->escape(), for completeness’ sake

Parameters

  • string $sql: Unescaped SQL data

Return values

returns:The cleaned $sql

Source code

function esc_sql( $sql ) {

	global $wpdb;

	return $wpdb->escape( $sql );

}

1038

esc_js

Definition:
function esc_js( $text ) {}

Escape single quotes, htmlspecialchar " < > &, and fix line endings.
Escapes text strings for echoing in JS. It is intended to be used for inline JS (in a tag attribute, for example onclick="…"). Note that the strings have to be in single quotes. The filter ‘js_escape’ is also applied here.

Parameters

  • string $text: The text to be escaped.

Return values

returns:Escaped text.

Defined filters

  • js_escape
    apply_filters( 'js_escape', $safe_text, $text )

Source code

function esc_js( $text ) {

	$safe_text = wp_check_invalid_utf8( $text );

	$safe_text = _wp_specialchars( $safe_text, ENT_COMPAT );

	$safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) );

	$safe_text = str_replace( "\r", '', $safe_text );

	$safe_text = str_replace( "\n", '\\n', addslashes( $safe_text ) );

	return apply_filters( 'js_escape', $safe_text, $text );

}

1036

esc_html__

Definition:
function esc_html__( $text, $domain = 'default' ) {}

Retrieves the translation of $text and escapes it for safe use in HTML output.
If there is no translation, or the domain isn’t loaded, the original text is returned.

Parameters

  • string $text: Text to translate
  • string $domain: Optional. Domain to retrieve the translated text

Return values

returns:Translated text

Source code

function esc_html__( $text, $domain = 'default' ) {

	return esc_html( translate( $text, $domain ) );

}

1034

esc_html_x

Definition:
function esc_html_x( $single, $context, $domain = 'default' ) {}

Parameters

  • $single
  • $context
  • $domain

Source code

function esc_html_x( $single, $context, $domain = 'default' ) {

	return esc_html( translate_with_gettext_context( $single, $context, $domain ) );

}

1032

esc_html_e

Definition:
function esc_html_e( $text, $domain = 'default' ) {}

Displays translated text that has been escaped for safe use in HTML output.

Parameters

  • string $text: Text to translate
  • string $domain: Optional. Domain to retrieve the translated text

Source code

function esc_html_e( $text, $domain = 'default' ) {

	echo esc_html( translate( $text, $domain ) );

}

1030