??????????????
??????????????
??????????????
??????????????
Warning : Undefined variable $auth in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
Warning : Trying to access array offset on value of type null in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
??????????????
??????????????
??????????????
??????????????
File Manager
✏️ Edit File: /home/mklsvubc/monicslandscape.co.uk/wp-content/plugins/surerank/inc/functions/sanitize.php
⬅ Kembali
<?php
/**
* Sanitize
*
* @package surerank
* @since 0.0.1
*/
namespace SureRank\Inc\Functions;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Sanitize
*
* @since 1.0.0
*/
class Sanitize {
/**
* Sanitize text
* if the value after sanitize_text is empty, return the default value
*
* @param string $value Value to sanitize.
* @param string $default Default value.
*
* @since 1.0.0
* @return string
*/
public static function text( $value, $default = '' ) {
return sanitize_text_field( $value ) ? $value : $default;
}
/**
* Sanitize multi-dimension array.
*
* @param callable $function Function reference.
* @param array<string, mixed>|array<int, string> $data_array Array what we need to sanitize.
* @since 0.0.1
* @return array<string, mixed>|array<int, string>
*/
public static function array_deep( callable $function, array $data_array ) {
if ( ! is_callable( $function ) ) {
return [];
}
if ( empty( $data_array ) ) {
return [];
}
$response = [];
foreach ( $data_array as $key => $data ) {
if ( is_array( $data ) ) {
$response[ $key ] = self::array_deep( $function, $data );
} else {
$response[ $key ] = $function( $data );
}
}
return $response;
}
/**
* Sanitize request payloads while preserving raw custom JSON-LD values.
*
* @param array<string, mixed>|array<int, string> $data_array Array to sanitize.
* @return array<string, mixed>|array<int, string>
*/
public static function sanitize_request_data( array $data_array ) {
if ( empty( $data_array ) ) {
return [];
}
/**
* Request keys that should keep raw string values for downstream validation.
*
* @param array<int, string> $raw_value_keys Raw-preserved request keys.
*/
$raw_value_keys = array_map( 'strval', apply_filters( 'surerank_preserve_raw_request_value_keys', [] ) );
$response = [];
foreach ( $data_array as $key => $data ) {
if ( is_array( $data ) ) {
$response[ $key ] = self::sanitize_request_data( $data );
continue;
}
if ( in_array( (string) $key, $raw_value_keys, true ) ) {
$response[ $key ] = self::sanitize_raw_json_ld( $data );
continue;
}
$response[ $key ] = self::sanitize_with_placeholders( $data );
}
return $response;
}
/**
* Custom sanitization function to allow specific placeholders like %term_title%
*
* Sanitize data recursively, while preserving any placeholder patterns in the format %placeholder%.
* The default sanitize_text_field function would remove certain characters, such as the '%' symbol,
* potentially breaking placeholders like %term_title%. By using the custom sanitize_with_placeholders
* function, we ensure that placeholders are retained exactly as they are (e.g., %term_title% remains intact),
* while still sanitizing other parts of the text to prevent any malicious input.
*
* @param string|bool $text The input text to sanitize.
* @return string|bool The sanitized text with placeholders retained.
*/
public static function sanitize_with_placeholders( $text ) {
if ( is_bool( $text ) ) {
return $text;
}
if ( empty( $text ) ) {
return '';
}
if ( ! is_string( $text ) ) {
return $text;
}
if ( filter_var( $text, FILTER_VALIDATE_URL ) ) {
return esc_url_raw( $text );
}
return sanitize_text_field( $text );
}
/**
* Preserve raw JSON-LD strings so validation can operate on exact input.
*
* @param mixed $text Raw JSON-LD payload.
* @return mixed
*/
public static function sanitize_raw_json_ld( $text ) {
if ( is_bool( $text ) || is_array( $text ) ) {
return $text;
}
if ( null === $text ) {
return '';
}
if ( ! is_string( $text ) ) {
return $text;
}
return trim( $text );
}
/**
* Sanitize shortcode
*
* @since 1.2.0
* @param string $text The text to sanitize.
* @return string The sanitized text.
*/
public static function sanitize_shortcode( $text ) {
if ( empty( $text ) ) {
return '';
}
if ( ! is_string( $text ) ) {
return $text;
}
/**
* Filter to control whether to execute or strip shortcodes in meta descriptions.
*
* By default, shortcodes are stripped to avoid side effects from complex blocks
* (e.g., Event Tickets, WooCommerce blocks) that may output unwanted content.
*
* Set to true to execute shortcodes with do_shortcode() instead.
*
* @since 1.6.3
* @param bool $execute_shortcodes Whether to execute shortcodes. Default false.
*/
return apply_filters( 'surerank_do_shortcodes_in_description', false ) ? do_shortcode( $text ) : strip_shortcodes( $text );
}
/**
* Sanitize Email address
*
* @since 1.6.0
* @param string $email The email address to sanitize.
* @param string $default Default value if email is invalid.
* @return string The sanitized email address.
*/
public static function email( $email, $default = '' ) {
$sanitized_email = sanitize_email( $email );
return is_email( $sanitized_email ) ? $sanitized_email : $default;
}
}
Nama
Tipe
Ukuran
Diubah
Aksi
🐘 api-utils.php
php
6.6 KB
2026-06-04 12:50
🐘 cache.php
php
18.6 KB
2026-05-20 12:46
🐘 compat.php
php
7.5 KB
2026-04-27 18:58
🐘 cron.php
php
3.3 KB
2025-08-18 15:48
🐘 defaults.php
php
14.2 KB
2026-06-17 16:29
🐘 get.php
php
6.8 KB
2026-06-17 16:29
🐘 helper.php
php
22.1 KB
2026-06-04 12:50
🐘 modified-date-lock.php
php
2.5 KB
2026-06-04 12:50
🐘 requests.php
php
1.9 KB
2025-06-27 15:25
🐘 rest-observation.php
php
2.8 KB
2026-04-27 18:58
🐘 sanitize.php
php
5 KB
2026-06-17 16:29
🐘 send-json.php
php
1.3 KB
2025-07-21 08:58
🐘 settings.php
php
24.2 KB
2026-06-17 16:29
🐘 update.php
php
4.2 KB
2026-06-17 16:29
🐘 utils.php
php
2.5 KB
2026-05-20 12:46
🐘 validate.php
php
2.3 KB
2025-07-21 08:58
🐘 variables.php
php
3.7 KB
2026-06-17 16:29