Skip to content

Instantly share code, notes, and snippets.

View earth3300's full-sized avatar

Earth3300 earth3300

View GitHub Profile
@earth3300
earth3300 / plugin.php
Last active September 11, 2018 17:59
/**
* Four Ways to Hook into WordPress when using a Class
*
* Do NOT place the action hook in the `_construct`.
*
* @link https://carlalexander.ca/designing-class-wordpress-hooks/
*/
/**
* Call init from outside the class.
@earth3300
earth3300 / plugin.php
Last active September 11, 2018 21:44
Using a shortcode with a class. Passing attributes.
/**
* The shortcode calls a function, which then has attributes passed to it.
* That function then instantiates a class, which processes the data and
* then returns it.
*
* @see https://carlalexander.ca/designing-class-generate-wordpress-html-content/
*/
function myplugin_display_comment_shortcode($attributes)
{
if (!is_array($attributes) || !isset($attributes['id'])) {
@earth3300
earth3300 / index.php
Last active September 21, 2018 20:45
A single file that lists the media files in a given directory. Can also be used as a WordPress plugin.
<?php
/**
* EC01 Media Index.
*
* Allows media (images, video and audio) to be viewed in a directory through a
* single index file.
*
* @package EC01 Media Index
* @since 1.0.0
<?php
defined('NDA') || exit('No direct access.');
/**
* Lists the jpg files in the media directory in which it is placed.
*
* Rename to index.php for it to work automatically, when viewing the directory.
*
*
@earth3300
earth3300 / .htaccess
Created September 12, 2018 15:48
Use of RequireAll to deny all access to the directory (and all subdirectories) in which this .htaccess directive is placed.
# SECURITY BEGIN
<RequireAll>
Require all denied
</RequireAll>
# SECURITY END
@earth3300
earth3300 / plugin.php
Last active September 12, 2018 20:40
File header for a WordPress plugin conforming to the PHPDoc DocBlock Standard. Use this.
<?php
/**
* Plugin Name
*
* @package PluginPackage
* @author Your Name
* @copyright Copyright (c) 2018 Your Name or Company Name
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3.0+
*
* @wordpress-plugin
@earth3300
earth3300 / style.css
Last active September 21, 2018 20:47
Style for index.php (media list).
/*
Theme Name: EC01 Commons Style
Theme URI: http://ec01.earth3300.info/
Author: Clarence Bos
Author URI: http://ec01.earth3300.info/
Description: Part of a sustainable community design.
Version: 1.0.0
License: GPL-3.0+
License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
Text Domain: ec01-commons
@earth3300
earth3300 / data.php
Last active September 19, 2018 20:17
Data file for Tiers (Tier Two to Tier 4).
<?php
defined( 'SITE' ) || exit;
/**
* Get Tier Two Data (Three Characters).
*
* Who, What, When, Where, How and Why, shortened to:
* who, wha, whn, whe, how and why.
*
@earth3300
earth3300 / article.html
Last active October 27, 2018 14:01
The front page for an integrated multi-person system.
<article>
<h1 id="earth-colony-01" class="hide">Earth Colony 01</h1>
<nav class="horizontal icons">
<a href="#what" class="what" title="What"><span class="icon icon16x8"></a>
<a href="#how" class="how" title="How"><span class="icon icon8x16"></a>
<a href="#where" class="where" title="Where"><span class="icon icon16x16"></a>
<a href="#who" class="who" title="Who"><span class="icon icon8x8"></a>
<a href="#when" class="when" title="When"><span class="icon icon8x24"></a>
<a href="#why" class="why" title="Why"><span class="icon icon16x14"></a>
@earth3300
earth3300 / colors-w3c.min.json
Created October 8, 2018 15:30
W3C Color Data in json format (minified), checked for conformance.
[{"colorId":0,"hexString":"#000000","rgb":{"r":0,"g":0,"b":0},"hsl":{"h":0,"s":0,"l":0},"name":"Black"},{"colorId":1,"hexString":"#800000","rgb":{"r":128,"g":0,"b":0},"hsl":{"h":0,"s":100,"l":25},"name":"Maroon"},{"colorId":2,"hexString":"#008000","rgb":{"r":0,"g":128,"b":0},"hsl":{"h":120,"s":100,"l":25},"name":"Green"},{"colorId":3,"hexString":"#808000","rgb":{"r":128,"g":128,"b":0},"hsl":{"h":60,"s":100,"l":25},"name":"Olive"},{"colorId":4,"hexString":"#000080","rgb":{"r":0,"g":0,"b":128},"hsl":{"h":240,"s":100,"l":25},"name":"Navy"},{"colorId":5,"hexString":"#800080","rgb":{"r":128,"g":0,"b":128},"hsl":{"h":300,"s":100,"l":25},"name":"Purple"},{"colorId":6,"hexString":"#008080","rgb":{"r":0,"g":128,"b":128},"hsl":{"h":180,"s":100,"l":25},"name":"Teal"},{"colorId":7,"hexString":"#c0c0c0","rgb":{"r":192,"g":192,"b":192},"hsl":{"h":0,"s":0,"l":75},"name":"Silver"},{"colorId":8,"hexString":"#808080","rgb":{"r":128,"g":128,"b":128},"hsl":{"h":0,"s":0,"l":50},"name":"Grey"},{"colorId":9,"hexString":"#ff0000","r