Skip to content

Instantly share code, notes, and snippets.

{
"items": [],
"rels": {
"alternate": [
"http://example.com/fr"
],
"author": [
"http://example.com/a",
"http://example.com/b"
],
@gRegorLove
gRegorLove / functions.php
Last active April 2, 2018 02:21
WordPress filter to approve webmentions from previously-approved domains
<?php
if ( !function_exists('indieweb_check_webmention') ) {
/**
* Using the webmention_source_url, approve webmentions that have been received from previously-
* approved domains. For example, once you approve a webmention from http://example.com/post,
* future webmentions from http://example.com will be automatically approved.
* Recommend placing in your theme's functions.php
*

Keybase proof

I hereby claim:

  • I am gregorlove on github.
  • I am gregorlove (https://keybase.io/gregorlove) on keybase.
  • I have a public key whose fingerprint is D7B6 075E 7537 F40A B327 F810 2E57 4552 635B 26CB

To claim this, I am signing this object:

@gRegorLove
gRegorLove / phonon-onhashchanged.js
Last active March 29, 2016 23:22
document.querySelector('#output') is not updating on subsequent page loads
// This function is defined as part of the window.dao object
loadProduct: function(product_id) {
var output = '';
// async db transaction
this.db.readTransaction(
function(tx) {
var sql = 'SELECT * FROM products WHERE id = ? AND deleted IS NULL';
@gRegorLove
gRegorLove / validate_date.php
Last active January 5, 2016 02:21
PHP date validation with DateTime
<?php
/**
* Validates a date string and converts it to a DateTime object
* Returns DateTime object on success, bool false on failure
* @param string $date
* @return DateTime|bool
*/
function validate_date($date)
{
// usage: onblur="absoluteURL(this);" on HTML5 'url' input
function absoluteURL(url) {
var string = url.value;
if ( string != '' && !(string.match(/^https?:/)) ) {
string = 'http://' + string;
}
else if (string == 'http://' || string == 'https://' )
{
string = '';