This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function clean_dir() { | |
files_to_remove=`ls | grep -v 'composer\.json'` | |
if [[ "$files_to_remove" ]]; then | |
rm -r $files_to_remove > /dev/null 2>&1 | |
fi | |
} | |
LOCK_FILE='/tmp/updating_wordpress' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Safe read to check any amount of properties are safe to traverse | |
* From: http://thecodeabode.blogspot.com.au/2013/04/javascript-safely-reading-nested.html | |
* | |
* Usage... for a nested structure | |
* var test = { | |
* nested: { | |
* value: 'Read Correctly' | |
* } | |
* }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function performance( $visible = false ) { | |
$stat = sprintf( '%d queries in %.3f seconds, using %.2fMB memory', | |
get_num_queries(), | |
timer_stop( 0, 3 ), | |
memory_get_peak_usage() / 1024 / 1024 | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// | |
// Assumption: we have two post types, "books" and "videos" and a shared hierarchical taxonomy called "library-section" | |
// | |
/* | |
* Pulls all non-empty terms for a given post type. | |
* | |
* @param $taxonomy The name of the taxonomy, e.g. "library-section" | |
* @param $post_type The name of the post type, e.g. "book" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -s http://codex.wordpress.org/Function_Reference | grep -C 0 "title=\"Function Reference" | sed 's/.*:.*Function Reference\/.*">//' | sed 's/<.*>//' | sed 's/(.*)//' > wp-functions.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var typeOf = function( type ) { | |
return function( value ) { | |
if ( typeof value !== type ) { | |
throw new TypeError( 'Expected a ' + type + '!' ); | |
} else { | |
return value; | |
} | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Disable certain tools in jetpack that can cause issues | |
*/ | |
add_filter( 'jetpack-tools-to-include', function( $tools ) { | |
$disabled_array = [ | |
'theme-tools/random-redirect.php', | |
'holiday-snow.php', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant ssh | |
cd /srv/www/ | |
mkdir site-name && cd site-name && mkdir htdocs && cd htdocs | |
wp core download | |
wp core config --dbname=site-name --dbuser=root --dbpass=root | |
wp db create | |
wp core install --url=site-name.dev --title=Site --admin_user=admin --admin_pass=password --admin_email=admin@example.dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Plugin Name: Oh noes, not another SEO plugin! | |
* License: GPLv3 http://www.gnu.org/copyleft/gpl.html | |
*/ | |
add_filter( 'wp_title', function( $title ) { | |
if ( is_singular() ) $title .= ' — ' . get_bloginfo( 'name' ); | |
if ( is_archive() ) $title = sprintf( ' Archives: %s — %s', $title, get_bloginfo( 'name' ) ); | |
if ( is_home() ) $title = sprintf( '%s — %s', get_bloginfo( 'name' ), get_bloginfo( 'description' ) ); | |
if ( is_search() ) $title = sprintf( 'Searching for: %s — %s', get_search_query( true ), get_bloginfo( 'description' ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This program is free software: you can redistribute it and/or modify | |
it under the terms of the GNU General Public License as published by | |
the Free Software Foundation, either version 2 of the License, or | |
(at your option) any later version. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of | |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
GNU General Public License for more details. |
OlderNewer