Skip to content

Instantly share code, notes, and snippets.

@gildotdev
gildotdev / THEMENAME_menu_link.php
Created April 20, 2011 20:11
This Drupal 7 function will allow you to use anchor names/fragments in your menu links. This functions goes in your template.php file in your theme directory. Remember to change THEMENAME to your theme's name.
@helen
helen / wp-chosen-tax-metabox.php
Last active April 24, 2022 02:25
Use Chosen for a replacement WordPress taxonomy metabox
<?php
/**
* WordPress Chosen Taxonomy Metabox
* Author: Helen Hou-Sandi
*
* Use Chosen for a replacement taxonomy metabox in WordPress
* Useful for taxonomies that aren't changed much on the fly and are
* non-hierarchical in nature, as Chosen is for flat selection only.
* You can always use the taxonomy admin screen to add/edit taxonomy terms.
* Categories need slightly different treatment from the rest in order to
@steven-tey
steven-tey / title-from-url.ts
Last active July 9, 2023 19:48
Get Title from URL
// Note: this gist is a part of this OSS project that I'm currently working on: https://github.com/steven-tey/dub
export default async function getTitleFromUrl (url: string) {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 2000); // timeout if it takes longer than 2 seconds
const title = await fetch(url, { signal: controller.signal })
.then((res) => {
clearTimeout(timeoutId);
return res.text();
})