Skip to content

Instantly share code, notes, and snippets.

View vyskoczilova's full-sized avatar

Karolína Vyskočilová vyskoczilova

View GitHub Profile
@vyskoczilova
vyskoczilova / README.md
Last active July 7, 2026 09:54
Claude Code hooks: keep the Mac awake exactly while Claude Code is working (refcounted across concurrent sessions)

Claude Code caffeinate hooks

Keep your Mac awake for exactly as long as Claude Code is actively working — no more, no less — even across several concurrent sessions.

Why

Claude Code can run for a while unattended (long tool calls, big builds), and by default your Mac will happily go to sleep mid-task if you walk away. These two hooks start a shared caffeinate -is (prevent idle + system sleep) on the

@vyskoczilova
vyskoczilova / empty_spaces.php
Last active June 18, 2025 07:28
WP block editor tweaks
<?php
/**
* Skip rendering of empty paragraph, heading, group, and columns blocks.
*
* - Paragraphs/headings: skipped if they contain only whitespace or &nbsp;
* - Group/columns: skipped if all inner blocks are empty or filtered out
*
* @param string $block_content The rendered HTML content.
* @param array $block The parsed block array.
@vyskoczilova
vyskoczilova / functions.php
Created January 16, 2025 16:38
Phone Validator and Formatter
<?php
$phone = "555555555"; // The phone number.
$country = "us_US"; // The country selected in the address related to the phone number.
$group = "billing"; // The group of the phone number (billing, shipping).
$wc_validate_phone = true; // If WooCommerce phone validation should be used in addition.
$format = "standardize_e164"; // Standardize setting: standardize_international, no_standardize, standardize_national, standardize_e164).
$validator = \phone_validator_and_formatter()->validator();// Get validator.
$phone_is_valid = $validator->is_valid($phone, $country, $group, $wc_validate_phone);
@vyskoczilova
vyskoczilova / disable_decoding_async.php
Last active June 1, 2025 00:57
Decoding async issue
<?php
add_filter('wp_img_tag_add_decoding_attr', '__return_false');
@vyskoczilova
vyskoczilova / add_page_template_support_missing_in_WP_5_8.php
Last active August 19, 2021 09:22
Add page template support broken in WP 5.8
<?php // don't copy this line
/**
* Add page template support
* @return void
* @author Karolína Vyskočilová (https://kybernaut.cz)
* @see https://wordpress.org/support/topic/page-templates-missing-from-page-attributes-after-5-8/
* @updated 2021-08-19
*/
function add_page_template_support_missing_in_WP_5_8()
@vyskoczilova
vyskoczilova / woocommerce_ulice_s_cislem_popisnym.php
Created July 30, 2021 13:08
WooCommerce: Ulice (první řádek) obsahuje alespoň jednu číslici (číslo popisné)
<?php // nekopírujte tento řádek
/**
* @snippet WooCommerce: Ulice (první řádek) obsahuje alespoň jednu číslici (číslo popisné)
* @author Karolína Vyskočilová (https://kybernaut.cz)
* @testedwith WordPress 5.8 & WooCommmerce 5.5
*/
function my_theme_validate_street( $fields, $errors ){
if ( ! preg_match('/[0-9]+/', $fields['billing_address_1']) && !empty( $fields['billing_address_1'] ) ) {
$errors->add( 'validation', __( '<strong>Adresa ulice</strong> musí obsahovat číslo popisné.', 'my-theme' ) );
@vyskoczilova
vyskoczilova / enhanced_has_block_functional.php
Last active May 13, 2021 15:18
Enhanced has_block() function.
<?php
// Do not copy the line above if you don't need it.
/**
* Has block function which searches as well in reusable blocks.
*
* Extends functionality of core's has_block (https://developer.wordpress.org/reference/functions/has_block/)
*
* @author Karolína Vyskočilová <karolina@kybernaut.cz>
* @since 2021-04-12
@vyskoczilova
vyskoczilova / parse_utm_codes_by_JS.js
Created November 13, 2020 11:56
Parse UTM codes to Contact Form 7 by javascript
/**
* Solving a trouble with WP Engine which is caching website without URL parameters and re-attaches them back once the request is compiled.
* If you need to add UTM values to any form (not only CF7) you can use this JS snippet on the form page.
*
* Author: Karolína Vyskočilová (karolina@kybernaut.cz)
* Author website: https://kybernaut.cz
* Date created: 2020-11-13
*
* Read more about WP Engine's cache: https://wpengine.com/support/utm-gclid-variables-caching/
*/
@vyskoczilova
vyskoczilova / theme-guard.php
Created October 9, 2020 16:26
Check if theme exists and is active or die
<?php
/**
* Plugin Name: Theme Guard
* Plugin URI: https://kybernaut.cz/?p=3204
* Description: Check if theme exists and is active or die.
* Version: 0.0.1
* Author: Karolína Vyskočilová
* Author URI: https://kybernaut.cz
* License: MIT
@vyskoczilova
vyskoczilova / pre-push
Last active March 16, 2020 15:48
Pre-push confirmation
#!/bin/sh
# An additional confirmation if you really want to push to remote (prevents accidental pushes).
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# Information about the commits which are being pushed is supplied as lines to