Skip to content

Instantly share code, notes, and snippets.

View i30's full-sized avatar
🏠
Working from home

Vu i30

🏠
Working from home
View GitHub Profile
@i30
i30 / delete-attachment-on-deleting-product.php
Last active November 16, 2025 03:56
WordPress - Delete attached images when deleting a product
<?php
/**
* Check if attachement being used elsewhere
*/
function wpclevel_is_attachment_used_elsewhere($attachment_id, $exclude_post_id)
{
global $wpdb;
// Search in postmeta table
$found = $wpdb->get_var($wpdb->prepare(
@i30
i30 / .js
Last active November 2, 2025 15:36
format-card-expiration-date-on-input
// Is user deleting?
document.addEventListener("keydown", e => {
document.body.classList.toggle("deleting", e.key === "Delete" || e.key === "Backspace")
})
// Automaticlly add forward slash
expDateInput.addEventListener("input", e => {
if (document.body.classList.contains("deleting")) {
return
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Simple Backbone WordPress Example</title>
<link rel="stylesheet" href="base.css">
</head>
<body>
<ul id="post-list"></ul>
@i30
i30 / Linux Static IP
Created April 17, 2017 04:50 — forked from fernandoaleman/Linux Static IP
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@i30
i30 / wordpress.vcl
Created March 4, 2017 02:17 — forked from matthewjackowski/wordpress.vcl
Varnish 4 VCL configuration for WordPress. Also allows purging
# A heavily customized VCL to support WordPress
# Some items of note:
# Supports https
# Supports admin cookies for wp-admin
# Caches everything
# Support for custom error html page
vcl 4.0;
import directors;
import std;
@i30
i30 / wordpress-handy-functions.md
Last active January 11, 2017 02:48
A list of handy WordPress functions.