Shortens a URL, to be used as link text.
*
* @since 1.2.0
* @since 4.4.0 Moved to wp-includes/formatting.php from wp-admin/includes/misc.php and added $length param.
*
* @param string $url URL to shorten.
* @param int $length Optional. Maximum length of the shortened URL. Default 35 characters.
* @return string Shortened URL.
*/
function url_shorten( $url, $length = 35 ) {
$stripped = str_replace( array( 'https://', 'http://', 'www.' ), '', $url );
$short_url = untrailingslashit( $stripped );
if ( strlen( $short_url ) > $length ) {
$short_url = substr( $short_url, 0, $length - 3 ) . '…';
}
return $short_url;
}
/**
* Sanitizes a hex color.
*
* Returns either '', a 3 or 6 digit hex color (with #), or nothing.
* For sanitizing values without a #, see sanitize_hex_color_no_hash().
*
* @since 3.4.0
*
* @param string $color
* @return string|void
*/
function sanitize_hex_color( $color ) {
if ( '' === $color ) {
return '';
}
// 3 or 6 hex digits, or the empty string.
if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
return $color;
}
}
/**
* Sanitizes a hex color without a hash. Use sanitize_hex_color() when possible.
*
* Saving hex colors without a hash puts the burden of adding the hash on the
* UI, which makes it difficult to use or upgrade to other color types such as
* rgba, hsl, rgb, and HTML color names.
*
* Returns either '', a 3 or 6 digit hex color (without a #), or null.
*
* @since 3.4.0
*
* @param string $color The color value to sanitize. Can be with or without a #.
* @return string|null The sanitized hex color without the hash prefix,
* empty string if input is empty, or null if invalid.
*/
function sanitize_hex_color_no_hash( $color ) {
$color = ltrim( $color, '#' );
if ( '' === $color ) {
return '';
}
return sanitize_hex_color( '#' . $color ) ? $color : null;
}
/**
* Ensures that any hex color is properly hashed.
* Otherwise, returns value untouched.
*
* This method should only be necessary if using sanitize_hex_color_no_hash().
*
* @since 3.4.0
*
* @param string $color The color value to add the hash prefix to. Can be with or without a #.
* @return string The color with the hash prefix if it's a valid hex color,
* otherwise the original value.
*/
function maybe_hash_hex_color( $color ) {
$unhashed = sanitize_hex_color_no_hash( $color );
if ( $unhashed ) {
return '#' . $unhashed;
}
return $color;
}
Fatal error: Uncaught Error: Call to undefined function esc_sql() in /home/decotrad/public_html/wp-includes/option.php:628
Stack trace:
#0 /home/decotrad/public_html/wp-includes/functions.php(1787): wp_load_alloptions()
#1 /home/decotrad/public_html/wp-includes/load.php(943): is_blog_installed()
#2 /home/decotrad/public_html/wp-settings.php(178): wp_not_installed()
#3 /home/decotrad/public_html/wp-config.php(115): require_once('/home/decotrad/...')
#4 /home/decotrad/public_html/wp-load.php(50): require_once('/home/decotrad/...')
#5 /home/decotrad/public_html/wp-blog-header.php(13): require_once('/home/decotrad/...')
#6 /home/decotrad/public_html/index.php(17): require('/home/decotrad/...')
#7 {main}
thrown in /home/decotrad/public_html/wp-includes/option.php on line 628
Fatal error: Uncaught Error: Call to undefined function esc_sql() in /home/decotrad/public_html/wp-includes/option.php:628
Stack trace:
#0 /home/decotrad/public_html/wp-includes/option.php(164): wp_load_alloptions()
#1 /home/decotrad/public_html/wp-includes/l10n.php(63): get_option('WPLANG')
#2 /home/decotrad/public_html/wp-includes/l10n.php(166): get_locale()
#3 /home/decotrad/public_html/wp-includes/l10n.php(954): determine_locale()
#4 /home/decotrad/public_html/wp-includes/class-wp-fatal-error-handler.php(49): load_default_textdomain()
#5 [internal function]: WP_Fatal_Error_Handler->handle()
#6 {main}
thrown in /home/decotrad/public_html/wp-includes/option.php on line 628