Skip to content

Instantly share code, notes, and snippets.

@rmpel
rmpel / class-uploads.php
Last active September 18, 2025 23:32
The definitive way to add more filetypes to WordPress Media.
<?php
/**
* Filters that assist in uploading additional filetypes.
*
* @package Your_Package
* @subpackage Your_Package/Includes
*/
namespace Your_Package\Includes;
@stokesman
stokesman / vite.config.js
Created October 24, 2023 18:56
Rudimentary Vite config that builds with WordPress dependency extraction
import { createHash } from 'crypto'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import {
defaultRequestToExternal,
defaultRequestToHandle
} from '@wordpress/dependency-extraction-webpack-plugin/lib/util.js'
import json2php from 'json2php'
import packageMeta from './package.json';
@Gictorbit
Gictorbit / allpersiangirlnames.md
Created May 25, 2023 17:58
all persian girl names

آ

آبانا آباندخت آبگین آبگینه آبنوس آبین آبینه آپام آپاما

@Gictorbit
Gictorbit / allperianboynames.md
Created May 25, 2023 16:44
all persian boy names

آ

آبان آبتين آپتين آتا آتبين آتريداد آتمين آتور آتيلا

@thewebartisan7
thewebartisan7 / valid-attributes.js
Last active May 20, 2025 01:40
All valid HTML attributes by element
/**
* List of valid HTML attributes that will be passed to first node of component or
* to the node with an attribute 'attributes'.
* Generated from https://www.w3.org/TR/html4/index/attributes.html
*
* @see https://jsfiddle.net/1r8czt2h/
*/
module.exports = {
elementAttributes: {
@ichim-david
ichim-david / gulp-cjs-to-esm.md
Created July 27, 2022 18:18 — forked from noraj/gulp-cjs-to-esm.md
Moving gulpfile from CommonJS (CJS) to ECMAScript Modules (ESM)

Moving gulpfile from CommonJS (CJS) to ECMAScript Modules (ESM)

Context

del v7.0.0 moved to pure ESM (no dual support), which forced me to move my gulpfile to ESM to be able to continue to use del.

The author sindresorhus maintains a lot of npm packages and does not want to provides an upgrade guide for each package so he provided a generic guide. But this guide is a bit vague because it's generic and not helping for gulp, hence this guide.

Guide

@ve3
ve3 / strftime-to-intldateformatter-converter.php
Last active October 23, 2025 15:29
Convert strftime format to IntlDateFormatter pattern.
<?php
/**
* PHP `strftime()` format to `IntlDateFormatter()` pattern converter.
*
* PHP `strftime()` is deprecated since v 8.1. They recommended to use `IntlDateFormatter()` instead.
* However `IntlDateFormatter()` pattern does not fully supported all format that `strftime()` does.
*
* Run this file to get the result of most close pattern to `strftime()` based on Thai locale.
*
* @license MIT
@sindresorhus
sindresorhus / esm-package.md
Last active December 5, 2025 20:00
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@yanknudtskov
yanknudtskov / functions.php
Created January 28, 2021 10:00
HTML cutter when you want to preserver formatting and avoid strip_tags and still be able to grab a substr (which can cut off HTML-tags)
<?php
function yanco_html_cut($text, $max_length)
{
$tags = array();
$result = "";
$is_open = false;
$grab_open = false;
$is_close = false;
@Gictorbit
Gictorbit / iran-nationalcode-location.json
Created May 6, 2020 00:27
json کد شهرستان و استان برای کد ملی فایل
{
"000": {
"province": "-",
"city": "-"
},
"001": {
"province": "تهران",
"city": "تهران مرکزی"
},
"002": {