Skip to content

Instantly share code, notes, and snippets.

View kasparsd's full-sized avatar

Kaspars Dambis kasparsd

View GitHub Profile
@kasparsd
kasparsd / wordpress-plugin-svn-to-git.md
Last active April 17, 2024 12:35
Using Git with Subversion Mirroring for WordPress Plugin Development
@kasparsd
kasparsd / fix-ssl-please.php
Created March 8, 2024 14:06
Fix SSL (HTTPs) URLs in WP content
<?php
/*
Plugin Name: Fix SSL Please
Plugin URI: https://github.com/kasparsd/ssl-fix
GitHub URI: https://github.com/kasparsd/ssl-fix
Description: Ensure that everything works over SSL
Version: 0.1.1
Author: Kaspars Dambis
Author URI: http://kaspars.net
*/
@kasparsd
kasparsd / admin-pwa.php
Last active February 20, 2024 12:17
wp-admin-pwa.php
<?php
/**
* Plugin Name: Admin PWA
*/
namespace Preseto\Admin_PWA;
const ACTION_QUERY_VAR = 'admin-pwa';
function manifest_url() {
@kasparsd
kasparsd / zip-chunks.php
Last active January 16, 2024 09:10
Zip chunks with PHP (split ZIP with max size)
<?php // Run as `php zip-chunks.php path/to/directory`.
$chunk_limit = 1024 * 1024 * 1024; // 1 GB
function get_files( $path ) {
$files = glob( rtrim( $path, '\\/' ) . '/*' );
foreach ( $files as $file ) {
if ( is_dir( $file ) ) {
$files = array_merge( $files, get_files( $file ) );
}
@kasparsd
kasparsd / clone-popular.sh
Last active January 3, 2024 16:06
Get the top 1000 most popular plugins on WordPress.org
@kasparsd
kasparsd / disable-title-rewrite-wordpress-seo.php
Last active November 22, 2023 12:13
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 / index.html
Last active June 12, 2023 05:18
Get user timezones using Slack API
<!doctype html>
<html ng-app="timezoneApp">
<head>
<title>Team Timezones</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script>
var period = 172800; // 2 days in seconds
var now = new Date();
var utc = new Date( now.getTime() + now.getTimezoneOffset() * 60000 );
var seconds_today = utc.getSeconds() + ( 60 * ( utc.getMinutes() + ( 60 * utc.getHours() ) ) );
@kasparsd
kasparsd / ms-cron-runner.php
Last active March 16, 2023 19:00
Cron for WordPress Multisite
<?php
// Author: Kaspars Dambis <hi@kaspars.net>
// Usage: php ms-cron-runner.php --domain=example.com [--path=/path/to/wordpress]
// We can't run this reliably from CLI because of how WordPress
// relies on $_SERVER for loading functions.php
if ( php_sapi_name() !== 'cli' )
die;
@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/
<?xml version="1.0" encoding="UTF-8" ?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl"
xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl"
xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"
xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tst="http://www.onvif.org/ver10/storage/wsdl"
xmlns:ter="http://www.onvif.org/ver10/error" xmlns:dn="http://www.onvif.org/ver10/network/wsdl"
xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12"