validations.php 1.4 KB

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