Skip to content

Instantly share code, notes, and snippets.

View kopepasah's full-sized avatar
🤖
Solving problems with bots.

Justin Kopepasah kopepasah

🤖
Solving problems with bots.
View GitHub Profile
@kopepasah
kopepasah / ddd.md
Created April 14, 2021 16:11 — forked from zsup/ddd.md
Documentation-Driven Development (DDD)

Documentation-Driven Development

The philosophy behind Documentation-Driven Development is a simple: from the perspective of a user, if a feature is not documented, then it doesn't exist, and if a feature is documented incorrectly, then it's broken.

  • Document the feature first. Figure out how you're going to describe the feature to users; if it's not documented, it doesn't exist. Documentation is the best way to define a feature in a user's eyes.
  • Whenever possible, documentation should be reviewed by users (community or Spark Elite) before any development begins.
  • Once documentation has been written, development should commence, and test-driven development is preferred.
  • Unit tests should be written that test the features as described by the documentation. If the functionality ever comes out of alignment with the documentation, tests should fail.
  • When a feature is being modified, it should be modified documentation-first.
  • When documentation is modified, so should be the tests.
@kopepasah
kopepasah / wp-filter-upload-mimes.php
Last active January 28, 2021 19:08
Filters the WordPress mime type uploads to allow for JSON files.
<?php
/**
* Allow JSON file uploads to WordPress media library.
*
* @package WordPress
*
* @author Justin Kopepasah <[email protected]>
*/
/**
@kopepasah
kopepasah / wp-always-on-panels.js
Last active April 30, 2019 09:26
Ensure some panels are "Always On".
// Subscribe to changes in the wp.data redux store.
wp.data.subscribe( () => {
// An array of "Always On" panel (metabox) ids to disallow disabling.
const alwaysOn = [];
// Current panels preferences
const panels = wp.data.select( 'core/edit-post' ).getPreference( 'panels' );
// Loop over the panels object.
@kopepasah
kopepasah / wpsnapshots.sh
Created August 2, 2018 15:33
Shortcut for using WP Snapshots in wp-local-docker: https://github.com/10up/wp-local-docker#wp-snapshots
#!/usr/bin/env bash
# Shortcut for WP Snapshots usage in wp-local-docker
#
# @link: https://github.com/10up/wp-local-docker#wp-snapshots
function snap() {
if [ -f "$PWD/bin/wpsnapshots.sh" ]; then
sh ./bin/wpsnapshots.sh "$@"
fi
}

Reset Audio & Video, w/o restarting your Mac

A couple handy commands to help you restart your audio and video during a call, without restarting your computer.

@kopepasah
kopepasah / terminus-update-wp-core.sh
Created November 16, 2017 07:44
Updates WordPress Core on the Pantheon hosting platform using Terminus.
#!/bin/bash
echo "Preparing update..."
terminus login [email protected] -q
terminus connection:set site.dev sftp -q
echo "Validating update..."
if [[ $(terminus wp site.dev -- core check-update) == *"WordPress is at the latest version"* ]] 2>/dev/null; then
terminus wp site.dev -- core version --extra 2>/dev/null
echo "No WordPress Core update to apply."
@kopepasah
kopepasah / colors-with-quoted-keys.scss
Last active October 19, 2017 17:10
Example code for the case to always use quotes in Sass maps.
$colors: (
"blue": "#2b55f3",
"green": "#39dd4a",
"yellow": "#f0f30f",
"red": "#ff2e35",
"orange": "#f8ad55",
);
@each $name, $color in $colors {
.#{$name} {
@mixin breakpoint( $start, $stop: null ) {
$breakpoints: (
'small': 480px,
'medium': 720px,
'large': 960px,
'huge': 1200px,
'container': $container,
);
$start: validate-point( $start, $breakpoints );
@kopepasah
kopepasah / redirect-lost-posts.php
Created January 13, 2017 06:11
Simple redirect function to correctly redirect lost posts.
<?php
/**
* Redirect Lost Posts
*
* @author Justin Kopepasah <[email protected]>
* @license MIT
*/
add_action( 'template_redirect', function() {
// Only redirect if nothing is found.
if ( is_404() ) {
@kopepasah
kopepasah / wp-menu-separator.php
Created November 16, 2016 07:06
Simple filter for adding a menu separator at a specific location on the WordPress admin menu.
<?php
/**
* Adds a separator to the administration menus in a specific location.
*
* @param array $menu Associative array of administration menu items.
*
* @return array $menu Modified associative array of administration menu items.
*/
add_filter( 'add_menu_classes', function( $menu ) {
$menu['44'] = array(