Skip to content

Instantly share code, notes, and snippets.

View oakwoodgates's full-sized avatar
🦉

oakwoodgates

🦉
View GitHub Profile
add_filter( 'the_content', 'prefix_insert_post_ads' );
/**
* Insert code for ads after second paragraph of single post content.
*
* @param string $content Post content
*
* @return string Amended content
*/
function prefix_insert_post_ads( $content ) {
$content_callout = '<h4>Insert code for ads after second paragraph of single post content.</h4>';
<?php
/* ==========
Get Split Nav
include $menu_name for the menu you want and $raw=true if you want to return just the menu objects
========== */
function get_split_nav($menu_name=null, $raw=false){
if($menu_name == null || !is_string($menu_name)){
return false;
}
$output = new stdClass();
<?php
class Aristath_Dynamic_CSS {
public $stylesheet_id;
public function __construct() {
add_action( 'customize_save_after', array( $this, 'make_css' ) );
}
@oakwoodgates
oakwoodgates / Contract Killer 3.md
Last active August 29, 2015 14:26
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Revised date: 7/30/2015
  • Original post

@oakwoodgates
oakwoodgates / gist:7d4768e3280ec412d869
Created October 1, 2015 20:58
ISO country codes array($key=>$value)
'options' => array(
'AF' => __( 'Afghanistan', 'textdomain' ),
'AX' => __( 'Åland Islands', 'textdomain' ),
'AL' => __( 'Albania', 'textdomain' ),
'DZ' => __( 'Algeria', 'textdomain' ),
'AS' => __( 'American Samoa', 'textdomain' ),
'AD' => __( 'Andorra', 'textdomain' ),
'AO' => __( 'Angola', 'textdomain' ),
'AI' => __( 'Anguilla', 'textdomain' ),
'AQ' => __( 'Antarctica', 'textdomain' ),
class PageTemplater {
/**
* A Unique Identifier
*/
protected $plugin_slug;
/**
* A reference to an instance of this class.
*/
<?php
$string = '{"emptyString":"","stringSpace":" ","zeroInteger":0,"zeroString":"0","nullVal":null,"falseVal":false,"emptyArray":[]}';
$array = json_decode( $string, true );
echo $string;
echo'<pre>';print_r( $array );echo'</pre>';
echo '<table>';
echo '
@oakwoodgates
oakwoodgates / gist:375cae1974fc3e0f62cc05bb94a5ed8c
Created August 8, 2019 01:09
Remove /node_modules/* from Windows with Command Prompt
FOR /d /r . %d in (node_modules) DO @IF EXIST "%d" rmdir /Q/S "%d"
@oakwoodgates
oakwoodgates / gist:61896343eee6e0effbdf5737d8a9639d
Created February 19, 2021 19:16
Command line batch file renaming
// All lowercase
Dir | Rename-Item -NewName {$_.FullName.ToLower()}
// Spaces to hyphens
Dir | Rename-Item –NewName { $_.name –replace " ","-" }
SELECT *
FROM `wp_usermeta`
WHERE `meta_key` LIKE '%thing%'
ORDER BY `meta_key` DESC
LIMIT 1500
DELETE FROM `wp_usermeta`
WHERE `meta_key` LIKE '%thing%'
LIMIT 1500