validations.php (1663B)
1 <?php 2 namespace Elementor; 3 4 if ( ! defined( 'ABSPATH' ) ) { 5 exit; // Exit if accessed directly. 6 } 7 8 /** 9 * Elementor settings validations. 10 * 11 * Elementor settings validations handler class is responsible for validating settings 12 * fields. 13 * 14 * @since 1.0.0 15 */ 16 class Settings_Validations { 17 18 /** 19 * Validate HTML field. 20 * 21 * Sanitize content for allowed HTML tags and remove backslashes before quotes. 22 * 23 * @since 1.0.0 24 * @access public 25 * @static 26 * 27 * @param string $input Input field. 28 * 29 * @return string Input field. 30 */ 31 public static function html( $input ) { 32 return stripslashes( wp_filter_post_kses( addslashes( $input ) ) ); 33 } 34 35 /** 36 * Validate checkbox list. 37 * 38 * Make sure that an empty checkbox list field will return an array. 39 * 40 * @since 1.0.0 41 * @access public 42 * @static 43 * 44 * @param mixed $input Input field. 45 * 46 * @return mixed Input field. 47 */ 48 public static function checkbox_list( $input ) { 49 if ( empty( $input ) ) { 50 $input = []; 51 } 52 53 return $input; 54 } 55 56 /** 57 * Current Time 58 * 59 * Used to return current time 60 * 61 * @since 2.5.0 62 * @access public 63 * @static 64 * 65 * @param mixed $input Input field. 66 * 67 * @return int 68 */ 69 public static function current_time( $input ) { 70 return time(); 71 } 72 73 /** 74 * Clear cache. 75 * 76 * Delete post meta containing the post CSS file data. And delete the actual 77 * CSS files from the upload directory. 78 * 79 * @since 1.4.8 80 * @access public 81 * @static 82 * 83 * @param mixed $input Input field. 84 * 85 * @return mixed Input field. 86 */ 87 public static function clear_cache( $input ) { 88 Plugin::$instance->files_manager->clear_cache(); 89 90 return $input; 91 } 92 }