403Webshell
Server IP : 104.21.93.192  /  Your IP : 216.73.216.73
Web Server : LiteSpeed
System : Linux premium900.web-hosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
User : redwjova ( 1790)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : OFF |  Pkexec : OFF
Directory :  /home/redwjova/public_html/wp-content/themes/kadence/inc/customizer/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/redwjova/public_html/wp-content/themes/kadence/inc/customizer/class-customizer-sanitize.php
<?php
/**
 * Class for the Customizer
 *
 * @package Kadence
 */

namespace Kadence;

use WP_Customize_Control;
use function sanitize_text_field;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class for Customizer Sanitize
 *
 * @category class
 */
class Customizer_Sanitize {

	/**
	 * Sanitize string, remove spaces and special characters.
	 *
	 * @param string $value the string to be sanitized.
	 *
	 * @return string
	 */
	public static function kadence_sanitize_key_string( $value ) {
		// To allow for strings with capitals, dashes, underscores, remove other special characters and spaces.
		return preg_replace( '/[^A-Za-z0-9_\-]/', '', $value );
	}
	/**
	 * Sanitize customizer setting. If a string use sanitize_key, for an array, loop through each item.
	 * For the key use sanitize_key and the value strip out most special characters.
	 * 
	 * @param mixed $start_value the value before sanitized.
	 *
	 * @return mixed
	 */
	public static function kadence_sanitize_option( $start_value ) {
		if ( empty( $start_value ) ) {
			return '';
		}
		if ( ! is_array( $start_value ) ) {
			return self::kadence_sanitize_key_string( $start_value );
		}
		$new_value = array();
		foreach ( $start_value as $key => $value ) {
			// Sanitize key, remove spaces and special characters.
			$key = self::kadence_sanitize_key_string( $key );
			if ( is_array( $value ) ) {
				$new_value[ $key ] = self::kadence_sanitize_option( $value );
			} else {
				switch ( $key ) {
					case 'family':
					case 'label':
						// Font family names can have special characters and can be custom so treat like an text field, label is a text field.
						$new_value[ $key ] = sanitize_text_field( $value );
						break;
					case 'color':
					case 'hover':
					case 'active':
					case 'link':
					case 'background':
					case 'backgroundHover':
					case 'border':
					case 'borderHover':
						// To allow hex, rgba(), and var() values or custom values like transparent run through custom preg_replace to remove most special characters and spaces.
						if ( strpos( $value, '#' ) === 0 ) {
							$new_value[ $key ] = sanitize_hex_color( $value );
						} else {
							$new_value[ $key ] = preg_replace( '/[^A-Za-z0-9_)(\-,.]/', '', $value );
						}
						break;
					case 'gradient':
						// gradient has some extra symbols that need to be allowed.
						$new_value[ $key ] = sanitize_text_field( $value );
						break;
					case 'enabled':
					case 'locked':
						// return a boolean.
						$new_value[ $key ] = ( ( isset( $value ) && true == $value ) ? true : false );
						break;
					case 'url':
						// URL is used for custom social images and background images so save as a url.
						$new_value[ $key ] = esc_url_raw( $value );
						break;
					default:
						// To allow for strings with capitals, negative numbers and decimals. Remove other special characters and spaces.
						$new_value[ $key ] = preg_replace( '/[^A-Za-z0-9_\-.]/', '', $value );
						break;
				}
			}
		}
		return $new_value;
	}
	/**
	 * Sanitize customizer toggle setting.
	 *
	 * @param mixed $value the value before sanitized.
	 *
	 * @return bool
	 */
	public static function kadence_sanitize_toggle( $value ) {
		return ( ( isset( $value ) && true == $value ) ? true : false );
	}
	/**
	 * Sanitize customizer google subset setting.
	 *
	 * @param mixed $start_value the value before sanitized.
	 *
	 * @return mixed
	 */
	public static function kadence_sanitize_google_subsets( $start_value ) {
		if ( empty( $start_value ) ) {
			return '';
		}
		if ( ! is_array( $start_value ) ) {
			return '';
		}
		$new_value = array();
		foreach ( $start_value as $key => $value ) {
			// Sanitize key, remove spaces and special characters.
			$key               = self::kadence_sanitize_key_string( $key );
			$new_value[ $key ] = ( ( isset( $value ) && true == $value ) ? true : false );
		}
		return $new_value;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit