Skip to content

Instantly share code, notes, and snippets.

@pascalknecht
pascalknecht / .htaccess
Created August 19, 2019 14:53
htaccess rules
# Redirect URL with query string to another URL
RewriteEngine On
RewriteCond %{REQUEST_URI} /
RewriteCond %{QUERY_STRING} ^lang=en
RewriteRule ^(.*)$ https://example.ch/ [QSD,R=301,L]
@pascalknecht
pascalknecht / reset.sh
Created December 10, 2019 10:31
Reset WPML in Multisite
cd wp-content/plugins/sitepress-multilingual-cms
wp shell
include 'sitepress.php'
icl_reset_wpml(blogid)
@pascalknecht
pascalknecht / OnBlurComponent.jsx
Created May 18, 2021 06:14 — forked from pstoica/OnBlurComponent.jsx
onBlur for entire react element
function OnBlurComponent({ onBlur }) {
const handleBlur = (e) => {
const currentTarget = e.currentTarget;
// Check the newly focused element in the next tick of the event loop
setTimeout(() => {
// Check if the new activeElement is a child of the original container
if (!currentTarget.contains(document.activeElement)) {
// You can invoke a callback or add custom logic here
onBlur();