Skip to content

Instantly share code, notes, and snippets.

View tomjn's full-sized avatar
🎯
Focusing

Tom J Nowell tomjn

🎯
Focusing
View GitHub Profile
Make Docs
http://make.wordpress.org/docs/
Progress Spreadsheet
https://docs.google.com/spreadsheet/ccc?key=0AnxB9WffF3jOdDR5ZGgtakxzNHFOTVczSy1fd3ZfSVE#gid=0
IRC Freenode
/j #wordpress-sfd
<?php
$io = new \Composer\IO\BufferIO();
try {
$composer = \Composer\Factory::create($io, null, false);
} catch (\InvalidArgumentException $e) {
if ($required) {
$io->write($e->getMessage());
exit(1);
{
"name": "tomjn/ptahsiteexample",
"description": "Just another WordPress site",
"license": "GPL-2.0+",
"repositories": [
{
"type": "composer",
"url": "http://wpackagist.org"
},
{
@tomjn
tomjn / gist:6645042
Created September 20, 2013 22:58
in a wordpress environment this will generate a composer.json string, WIP
<?php
function get_composer_json() {
$plugins = get_plugins();
$data = array();
$data['rarst/wordpress'] = '>='.get_bloginfo( 'version' );
$data['php'] = '>=5.2.4';
foreach ( $plugins as $plugin ) {
$key = 'wpackagist/'.sanitize_title( $plugin['Name'] );
$data[ $key ] = $plugin['Version'];
@tomjn
tomjn / gist:6435497
Created September 4, 2013 10:55
Grab the assets from https://github.com/EleazarCrusader/nexus-theme, add to your sublime theme, and ammend the paths accordingly to add tab colour coding
{
// - Tab close state
"class": "tab_control",
"settings": ["show_tab_close_buttons"],
"content_margin": [20, 0, 20, 7]
},
{
// - Hover tab state
"class": "tab_control",
"attributes": ["hover"],
@tomjn
tomjn / gist:6426284
Created September 3, 2013 16:35
my sublime user settings
{
"caret_style": "phase",
"color_scheme": "Packages/Theme - Void/Color Scheme - Void/Void.tmTheme",
"draw_white_space": "all",
"fade_fold_buttons": true,
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",
"*.exe",
@tomjn
tomjn / gist:6142772
Created August 2, 2013 19:37
A standard WP_Query loop to display pages
<?php
$query = new WP_Query( array(
'post_type' => 'page'
));
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
the_title();
}
@tomjn
tomjn / gist:6142710
Created August 2, 2013 19:29
A classic standard main post loop
<?php
if ( have_posts() ) {
while( have_posts() ) {
the_post();
the_title();
}
}
@tomjn
tomjn / gist:6140909
Last active February 21, 2020 06:35
If you're thinking of using WP_Query, try using this iterator instead, cleaner boilerplate, auto-cleans up after itself
<?php
$pages = new query_loop( array(
'post_type' => 'page'
));
foreach( $pages as $id => $post ) {
the_title();
// etc...
}
@tomjn
tomjn / gist:6140601
Last active December 20, 2015 13:39
If you're lucky enough to be using any version of PHP 5 with WordPress ( 100% chance! ) You can do this:
<?php
$posts = new posts_loop();
foreach( $posts as $id => $post ) {
the_title();
// etc...
}
// put this below in your functions.php: