Skip to content

Instantly share code, notes, and snippets.

View stracker-phil's full-sized avatar

Philipp Stracker stracker-phil

View GitHub Profile
@stracker-phil
stracker-phil / translate_with_openai.py
Last active May 31, 2024 14:37
Python script to translate a GlotPress JSON export to another language
#!/usr/bin/env python3
import json
import os
from openai import OpenAI
# URL: https://gist.github.com/stracker-phil/d1d874a299883ff540966a402793f616
#
# Usage:
# 1. Download the current translations as JSON format from the internal GlotPress site.
@stracker-phil
stracker-phil / Hook-Obsidian - New-Item.scpt
Last active March 7, 2024 12:11
Hookmark script: Obsidian | New Item
use framework "Foundation"
use scripting additions
property NSString : a reference to current application's NSString
property NSMutableCharacterSet : a reference to current application's NSMutableCharacterSet
set fileType to ".md"
set prefUrl to ""
try
@stracker-phil
stracker-phil / divi-areas-in-search-results.php
Created May 4, 2023 11:18
Include Divi Areas in WordPress search results
<?php
/**
* How to use this snippet:
*
* 1. Click the "Download ZIP" button (top-right area)
* 2. Open wp-admin > Plugins > Add New
* 3. Click "Upload Plugin" and select the zip file
* 4. After uploading the zip file, activate the plugin
*
* ----------
@stracker-phil
stracker-phil / edd-generate-discount.php
Last active October 21, 2022 11:12
Function to generate a random discount code for Easy Digital Downloads
<?php
/**
* Generate a random discount code that matches the given criteria.
*
* Samples:
* - generate_discount( 10, 'percent', '+7days', 'HI-^^^^' );
* - generate_discount( 5, 'flat', '', '********' );
*
* @param int $amount The discount code value.
* @param string $type The type, either [flat|percent].
@stracker-phil
stracker-phil / trigger-after-delay-1.html
Created September 30, 2022 08:36 — forked from divimode-philipp/trigger-after-delay-1.html
Sample trigger for Popups for Divi / Divi Areas Pro that opens the #contact Popup after 5 seconds
<script>
setTimeout(function () {
DiviArea.show('contact');
}, 5000);
</script>
@stracker-phil
stracker-phil / trigger-after-delay-2.html
Created September 30, 2022 08:36 — forked from divimode-philipp/trigger-after-delay-2.html
Generic trigger snippet for Popups for Divi / Divi Areas Pro to trigger the given Popup after a delay.
<script>
(function () {
// TODO: Adjust the following two lines:
var popup = 'contact'; // Your Popup ID.
var delay = 5; // Delay [in seconds].
setTimeout(function () {
DiviArea.show(popup);
}, delay * 1000);
@stracker-phil
stracker-phil / trigger-on-scroll-1.html
Created September 30, 2022 08:36 — forked from divimode-philipp/trigger-on-scroll-1.html
JS snippet for Popups for Divi / Divi Areas Pro to trigger a Popup after the user scrolled down to a certain point
<script>
(function ($) {
// TODO: Adjust the following to lines to your needs:
var popup = 'contact'; // Your Popup ID.
var distance = 500; // Scroll distance [pixel].
$(window).on('scroll.popup_' + popup, function () {
// Check if the user scrolled far enough.
@stracker-phil
stracker-phil / divi-areas-in-search-results.php
Created September 30, 2022 08:35 — forked from divimode-philipp/divi-areas-in-search-results.php
Include Divi Areas in WordPress search results
<?php
/**
* How to use this snippet:
*
* 1. Click the "Download ZIP" button (top-right area)
* 2. Open wp-admin > Plugins > Add New
* 3. Click "Upload Plugin" and select the zip file
* 4. After uploading the zip file, activate the plugin
*
* ----------
@stracker-phil
stracker-phil / dynamic-popups-1.js
Created September 30, 2022 08:33 — forked from divimode-philipp/dynamic-popups-1.js
Two ways how to display dynamic contents inside a Divi Area. In this sample we only change the URL of an iframe inside the Area, but it's possible to literally change anything inside the Area (e.g. fill out form fields, insert a user-name into a <span>, show/hide a button, etc.)
/**
* Option 1:
* Open an existing Popup and change the URL of an iframe inside the Popup.
*
* Preparation:
* Create a Divi Area (or an On-Page Popup) which contains an iframe.
*
* @param {string} areaId - The ID of an existing Popup or Divi Area.
* @param {string} iframeUrl - The new URL of the iframe inside the Popup.
*/
@stracker-phil
stracker-phil / asset-cache.php
Created September 30, 2022 08:33 — forked from divimode-philipp/asset-cache.php
Proof of concept - Cache External WP Assets
<?php
/**
* Proof of concept for https://github.com/divimode/gdpr-cache-script-styles
*/
/**
* Filter all scripts and style URLs.
* When an external URL is detected, download the file
* and replace it in the page source.