Skip to content

Instantly share code, notes, and snippets.

View dotherightthing's full-sized avatar

Dan Smith dotherightthing

  • Do The Right Thing
  • Wellington, New Zealand
View GitHub Profile
@dotherightthing
dotherightthing / plugins-vs-functions-php.md
Created August 15, 2019 09:20
[Plugins vs functions.php] Why plugins are preferable. #wordpress

Plugins vs functions.php

Created 2017.04.13

Write once

Rather than copying and pasting code between projects, plugins can be created for easy reuse. A bug found in Website B can be fixed and easily shipped to Website A.

In a multisite install, that plugin can be made available to all subsites. This approach can also be used to install and update proprietary plugins, which have not been published to the plugin directory.

@dotherightthing
dotherightthing / bower-install-from-github-bitbucket-etc.md
Last active August 15, 2019 09:26
[Bower install from Github, Bitbucket etc] The correct syntax to use. #git

Bower install from Github, Bitbucket etc

Created: 2017.04.13

Github

A Github download URL.

When clicking Clone or download, Github provides this URL:

@dotherightthing
dotherightthing / output-keys-from-a-hash-array.md
Created August 15, 2019 09:29
[Output keys from a hash array] #wordpress

Output keys from a hash array

Created: 2017.04.12

Get the first key, the last key, the first value or the last value of a (hash) array

WET WordPress approach

WordPress uses a hash array to populate select menus in the customizer:

@dotherightthing
dotherightthing / godaddy-seo.md
Last active August 15, 2019 09:35
[Godaddy SEO] How to improve the SEO of Godaddy Website Builder sites. #seo

Godaddy SEO

Created: 2017.04.10

Sitemaps

I just checked w/ our Website Builder team regarding your specific question, and here's what they said: "Website Builder automatically creates a site map for all published websites but does not automatically submit it to search engines. For customers who update their website using the SEO wizard (on the Business Plus plan) we also do automatically submit the site map to the search engines on their behalf."

The sitemap is available at http://www.domain.com/sitemap.xml.

@dotherightthing
dotherightthing / md5.md
Created August 15, 2019 09:45
[MD5] #security

MD5

Created: 2017.04.12

MD5 is a secure hash algorithm. It takes a string as input, and produces a 128-bit number, the hash.

MD5 and SHA1 are designed for a number of properties, one of the strongest being collision resistance. This means that it should take an enormous computational effort -- around 264264 MD5 calls or 280280 SHA1 calls -- in order to find two files that have the same hash output.

This is an important property for a number of applications, most obviously digital signatures.

@dotherightthing
dotherightthing / nonce.md
Created August 15, 2019 09:47
[Nonce] A nonce is a "number used once" to help protect URLs and forms from certain types of misuse. #security #wordpress

Nonce

Created: 2017.04.12

The one or single occasion; the present reason or purpose (now only in for the nonce).

That will do for the nonce, but we'll need a better answer for the long term.

@dotherightthing
dotherightthing / storing-geolocation-exif-with-the-attachment-post.md
Created August 15, 2019 09:49
[Storing Geolocation EXIF with the attachment post] #wordpress

Storing Geolocation EXIF with the attachment post

Created: 2017.04.09

This code causes the Geolocation EXIF to the attachment metadata stored in the database.

It is run when an image is uploaded into WordPress.

I found that by adding a call to 6q3rVgtQsiH0820S_2_read_image_metadata into my dtrt_gallery_thumbnail_link function (hooked into 6q3rVgtQsiH0820S_2_get_attachment_link) resulted in the attachment metadata being added for existing images.

@dotherightthing
dotherightthing / the-right-way-to-customize-a-wordpress-plugin.md
Created August 15, 2019 09:50
[Customizing WordPress Plugins] #wordpress

Customizing WordPress Plugins

Created: 2017.04.11

@dotherightthing
dotherightthing / variable-scoping-in-es6.md
Created August 15, 2019 09:51
[Variable scoping in ES6] The difference between var, let and const. #javascript

Variable scoping in ES6

Created: 2017.04.08

var

var variables are globally scoped (within the window), or function {} scoped:

Global scope