86 lines
1.7 KiB
PHP
86 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* PHPUnit bootstrap.
|
|
*
|
|
* @package LogoSoup\Tests
|
|
*/
|
|
|
|
if ( ! function_exists( 'sanitize_key' ) ) {
|
|
/**
|
|
* Sanitize key.
|
|
*
|
|
* @param string $key Raw key.
|
|
* @return string
|
|
*/
|
|
function sanitize_key( $key ) {
|
|
$key = strtolower( (string) $key );
|
|
|
|
return preg_replace( '/[^a-z0-9_\-]/', '', $key );
|
|
}
|
|
}
|
|
|
|
if ( ! function_exists( 'sanitize_text_field' ) ) {
|
|
/**
|
|
* Sanitize text.
|
|
*
|
|
* @param string $value Raw value.
|
|
* @return string
|
|
*/
|
|
function sanitize_text_field( $value ) {
|
|
return trim( wp_strip_all_tags( (string) $value ) );
|
|
}
|
|
}
|
|
|
|
if ( ! function_exists( 'absint' ) ) {
|
|
/**
|
|
* Convert to absolute integer.
|
|
*
|
|
* @param mixed $maybeint Value.
|
|
* @return int
|
|
*/
|
|
function absint( $maybeint ) {
|
|
return abs( (int) $maybeint );
|
|
}
|
|
}
|
|
|
|
if ( ! function_exists( 'esc_url_raw' ) ) {
|
|
/**
|
|
* Sanitize raw URL.
|
|
*
|
|
* @param string $url URL.
|
|
* @return string
|
|
*/
|
|
function esc_url_raw( $url ) {
|
|
return filter_var( (string) $url, FILTER_SANITIZE_URL );
|
|
}
|
|
}
|
|
|
|
if ( ! function_exists( 'wp_parse_args' ) ) {
|
|
/**
|
|
* Parse args against defaults.
|
|
*
|
|
* @param array $args Args.
|
|
* @param array $defaults Defaults.
|
|
* @return array
|
|
*/
|
|
function wp_parse_args( $args, $defaults = array() ) {
|
|
return array_merge( $defaults, $args );
|
|
}
|
|
}
|
|
|
|
if ( ! function_exists( 'wp_strip_all_tags' ) ) {
|
|
/**
|
|
* Strip all tags.
|
|
*
|
|
* @param string $value Raw text.
|
|
* @return string
|
|
*/
|
|
function wp_strip_all_tags( $value ) {
|
|
return trim( preg_replace( '/<[^>]*>/', '', (string) $value ) );
|
|
}
|
|
}
|
|
|
|
require_once dirname( __DIR__, 2 ) . '/tests/php/wp-stubs.php';
|
|
require_once dirname( __DIR__, 2 ) . '/src/class-settings.php';
|
|
require_once dirname( __DIR__, 2 ) . '/src/Support/class-logo-sanitizer.php';
|