Skip to content

Instantly share code, notes, and snippets.

View szepeviktor's full-sized avatar
🍓
Guess I'm the lone ranger keeping it all running.

Viktor Szépe szepeviktor

🍓
Guess I'm the lone ranger keeping it all running.
View GitHub Profile
@szepeviktor
szepeviktor / wordfence-plugin-check.sh
Created September 6, 2025 16:20
Wordfence plugin vulnerability check in small shell script
#!/bin/bash
wget -O wordfence-vulnerabilities.json "https://www.wordfence.com/api/intelligence/v2/vulnerabilities/production"
wp plugin list --skip-update-check --status=active --fields=name,version \
| tail -n +2 \
| while read -r PLUGIN VERSION; do
UPDATE="$(jq -r --arg slug "${PLUGIN}" \
'[.. | objects | select(."type"=="plugin" and ."slug"==$slug) | ."patched_versions"[]?] | if length>0 then map(split(".") | map(tonumber)) | max | join(".") else empty end' \
wordfence-vulnerabilities.json
@szepeviktor
szepeviktor / twilio-sms.sh
Created September 3, 2025 01:31
Twilio SMS to email
#!/bin/bash
#
# Send SMS with Twilio API.
#
# DEPENDS :apt-get install curl mpack
TWILIO_FROM="YOUR-PHONE-NUMBER"
TWILIO_TO="$1"
TWILIO_API_KEY="YOUR-API-KEY"
TWILIO_API_SECRET="$2"
@szepeviktor
szepeviktor / wc-gtin-search.php
Last active August 22, 2025 08:49
WC Admin Search by Global Unique ID
<?php
/**
* Plugin Name: WC Admin Search by Global Unique ID
* Description: Make the admin Products search match the _global_unique_id (GTIN/EAN/UPC/ISBN).
* Version: 1.0.0
* WC requires at least: 9.2
* Requires PHP: 7.4
* Author: Viktor Szépe
* Author URI: https://www.szepe.net/
*/
@szepeviktor
szepeviktor / php-switch.sh
Created July 29, 2025 07:52
Switch PHP version for a user in Debian
#!/bin/bash
mkdir -p /usr/local/bin/php8.3
ln -s /usr/bin/php8.3 /usr/local/bin/php8.3/php
# Add this to your script: export PATH="/usr/local/bin/php8.3:$PATH"
@szepeviktor
szepeviktor / Environments.md
Last active July 4, 2025 08:40
Futtató környezetek szerepe egy szoftver életében

Környezetek

  • local - Fícsör kifejlesztése a saját gépen, amíg nem látszik a hiba
  • CI - Véleményt mondanak: minőségbiztosító eszközök, tesztek ✔ ❌, kollégák
  • staging - Bemutatjuk a hozzá nem értő ügyfélnek, illetve kipróbáljuk egy prod-hoz közeli környezetben
  • production - Oda adjuk a felhasználóknak
@szepeviktor
szepeviktor / wp-cli-array.sh
Created June 13, 2025 16:36
WP-CLI edit array option
wp option get auto_update_plugins --format=json \
| jq -c 'to_entries | map(select(.value != "wordpress-seo/wp-seo.php")) | from_entries' \
| wp option update auto_update_plugins --format=json
@szepeviktor
szepeviktor / HelloPack.sh
Created May 20, 2025 06:29
HelloPack plugin list and plugin update
# List plugin IDs
wp eval 'var_export(array_column(hellopack_client()->api()->plugins(),"name","id"));'
# Update the plugin
wp plugin install "$(wp eval 'echo hellopack_client()->api()->download(260729283,[]);')" --force
@szepeviktor
szepeviktor / glyph-width.php
Last active May 12, 2025 10:34
Estimate glyph widths for sans serif 16px font
<?php
function get_text_width(string $text): int
{
$glyph_widths = [
'A' => 10.67,
'B' => 10.67,
'C' => 11.55,
'D' => 11.55,
'E' => 10.67,
@szepeviktor
szepeviktor / zip-uploads.php
Last active May 8, 2025 06:04
Archive WordPress uploads in a ZIP file on the server
<?php
function addDirToZip(string $dir, ZipArchive $zipFile, string $basePath = '')
{
$files = scandir($dir);
// Remove '.' and '..'
unset($files[0], $files[1]);
foreach ($files as $file) {
$filePath = $dir . $file;
@szepeviktor
szepeviktor / comment-tor-spam.php
Last active March 29, 2025 18:37
Mark WordPress comments from Tor exit nodes as spam
<?php
/*
* Plugin Name: Mark comments from Tor exit nodes as spam
* Plugin URI: https://github.com/szepeviktor/wordpress-website-lifecycle
*/
/** @return string|null */
function getTorExitNodes()
{