Skip to content

Instantly share code, notes, and snippets.

View kasparsd's full-sized avatar

Kaspars Dambis kasparsd

View GitHub Profile
@kasparsd
kasparsd / systeme-api.php
Created January 22, 2026 10:48
PHP client for Systeme.io API
<?php
class Systeme_API {
const API_URL = 'https://api.systeme.io/api';
public function __construct( private string $api_key ) {}
private function url_to( string $endpoint, ?array $params = [] ): string {
$url = sprintf( '%s/%s', self::API_URL, ltrim( $endpoint, '/' ) );
@kasparsd
kasparsd / autoload-transients.php
Last active October 14, 2025 11:06
Autoload all WordPress transients including those with expiration (add this as a mu-plugin)
<?php
/**
* Plugin Name: Transient Autoload
* Description: Autoload transients with expiration since they're not preloaded by WP core.
* Version: 1.0.0
*/
namespace Transient_Autoload;
function get_transient_option(): array {
@kasparsd
kasparsd / wp-inherit-style-classes.php
Created August 9, 2025 20:59
Add dynamic classes like has-background to static blocks like paragraphs and headings
<?php
add_filter( 'render_block', function( $block_content, $block ) {
if ( empty( $block['blockName'] ) ) {
return $block_content;
}
$supports = [];
@kasparsd
kasparsd / custom-post-taxonomy-permalinks.php
Created June 13, 2012 15:47
Create permalink structure URLs for custom post types that include all parent terms from a custom taxonomy
<?php
/*
Term Archive Pages:
- http://example.com/recipes/dinner/
- http://example.com/recipes/breakfast,brunch/
Single Recipe Pages:
- http://example.com/recipes/dinner/soup-title/
@kasparsd
kasparsd / disable-title-rewrite-wordpress-seo.php
Last active July 1, 2025 20:50
Disable page title rewrite feature in WordPress SEO plugin
<?php
// Remove the wp_title filter
add_action( 'init', 'remove_wpseo_title_rewrite' );
function maybe_remove_wpseo_title_rewrite() {
global $wpseo_front;
remove_filter( 'wp_title', array( $wpseo_front, 'title' ), 15 );
}
@kasparsd
kasparsd / readme.md
Last active June 13, 2025 14:26
WordPress handbooks as a single markdown file for LLMs (source https://developer.wordpress.org)
@kasparsd
kasparsd / lazy-load-videos.js
Created June 3, 2025 07:57
Lazy Load Videos
(function () {
function initLazyVideos() {
var videos = document.querySelectorAll("video[data-src]");
if ("IntersectionObserver" in window) {
var observer = new IntersectionObserver(
function (entries, observer) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
var video = entry.target;
@kasparsd
kasparsd / wordpress-plugin-svn-to-git.md
Last active June 2, 2025 17:14
Using Git with Subversion Mirroring for WordPress Plugin Development
@kasparsd
kasparsd / nginx.conf
Created February 21, 2017 13:40
Nginx HTTP basic auth with cookie pass
map $cookie_skip_http_auth $auth_type {
default "Restricted Area";
"123" "off";
}
server {
location /setauthcookie {
add_header Set-Cookie "skip_http_auth=123";
return 301 http://example.com;
}
<?php
add_action(
'login_head',
function () {
$site_icon_url = get_site_icon_url();
if ( ! empty( $site_icon_url ) ) {
printf(
'<style type="text/css">