diff --git a/php/class-assets.php b/php/class-assets.php index a83b70b5..ccd01800 100644 --- a/php/class-assets.php +++ b/php/class-assets.php @@ -117,6 +117,7 @@ class Assets extends Settings_Component { */ public function __construct( Plugin $plugin ) { parent::__construct( $plugin ); + $this->should_sanitize_slugs = true; $this->media = $plugin->get_component( 'media' ); $this->delivery = $plugin->get_component( 'delivery' ); diff --git a/php/traits/trait-params.php b/php/traits/trait-params.php index a653885f..05fb2ab7 100644 --- a/php/traits/trait-params.php +++ b/php/traits/trait-params.php @@ -30,6 +30,13 @@ trait Params_Trait { */ public $separator = '.'; + /** + * Whether to sanitize slugs. + * + * @var boolean + */ + protected $should_sanitize_slugs = false; + /** * Sets the params recursively. * @@ -77,7 +84,6 @@ protected function set_param_array( $parts, $param, $value ) { * @return $this */ public function set_param( $param, $value = null ) { - $sanitized_param = $this->sanitize_slug( $param ); $parts = explode( $this->separator, $sanitized_param ); $param = array_shift( $parts ); @@ -140,6 +146,9 @@ public function remove_param( $param ) { * @return string */ protected function sanitize_slug( $slug ) { + if ( ! $this->should_sanitize_slugs || ! str_contains( $slug, $this->separator ) ) { + return $slug; + } $sanitized = array_map( 'sanitize_file_name', explode( $this->separator, $slug ) );