true, 'target' => true, 'rel' => true, 'download' => true, ) ); } foreach ( $data as $key => $value ) { if ( is_array( $value ) ) { $data[ $key ] = addifect_recursive_sanitize_array( $value ); continue; } if ( ! is_string( $value ) ) { continue; } /** * We use specific sanitization logic based on the key type. * 'html' use wp_kses to preserve safe HTML/DSL structure. * 'css' and 'd' are stripped of tags to prevent script injection. */ switch ( $key ) { case 'html': $data[ $key ] = wp_kses( $value, $allowed_tags ); break; case 'css': $data[ $key ] = wp_strip_all_tags( $value ); break; case 'fontURL': $data[ $key ] = esc_url_raw( $value ); break; default: $data[ $key ] = sanitize_text_field( $value ); break; } } return $data; } /** * Custom sanitizer for Addifect Template IDs. * Allows alphanumeric, dashes, underscores, AND the @ symbol for system routes. * * @param string $param The parameter to sanitize. * @return string */ function addifect_sanitize_template_id( $param ) { // Strip everything EXCEPT a-z, A-Z, 0-9, -, _, and @. return preg_replace( '/[^a-zA-Z0-9_\-@]/', '', $param ); }