Skip to content

Instantly share code, notes, and snippets.

@jcobb
jcobb / readme
Created May 21, 2012 04:08 — forked from ScottPhillips/readme
Boilerplate Wordpress Widget
How to Use
Step 1.
Copy the custom_widget.php file and place it in your WordPress theme folder. Assuming WordPress is installed in the root of your server the file will be place in /wp-content/themes/yourtheme/
Step 2.
Open up functions.php and include the following piece of code somewhere in the file. include TEMPLATEPATH . '/custom_widget.php';
Step 3.
Edit the custom_widget.php file to suit your needs.
@jcobb
jcobb / gist:2760538
Created May 21, 2012 04:18 — forked from ScottPhillips/gist:2382192
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@jcobb
jcobb / .gitignore
Created May 21, 2012 04:21 — forked from redoPop/.gitignore
Template .gitignore file for WordPress projects
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@jcobb
jcobb / gist:2766570
Created May 22, 2012 04:30 — forked from davidalexander/gist:1086455
Magento Snippets

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

@jcobb
jcobb / gist:2921358
Created June 13, 2012 02:06
print_r Beautifier
<?php
function my_print_r($thing,$description=false){
echo '<pre style="background:#fff; padding:10px; color:#111; font-family:monospace; font-size:12px; border:1px solid #555">';
if($description) echo '<strong>'.$description.'</strong><br><br>';
print_r($thing);
echo '</pre>';
}
//Usage
@jcobb
jcobb / gist:2963530
Created June 21, 2012 02:52
WordPress $post logging function
<?php
function log_post($post){
$p_title = $post->post_title;
$p_type = $post->post_type;
$p_cat = get_the_category( $post->ID );
$summary = '<strong>Post Title: </strong>' . $p_title;
$summary .= ' | <strong>Post Type:</strong> ' . $p_type;
@jcobb
jcobb / dabblet.css
Created June 21, 2012 11:20
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
#wp-log-output{
padding:10px;
background:#fff;
border:1px solid #eee;
font-family:Helvetica;
color:#555;
@jcobb
jcobb / gist:2993853
Created June 26, 2012 06:42
Combine multiple WordPress queries
<?php
// An example of creating two separate WP queries, combining the results,
// sorting by date and formatting the results for us in a loop like a regular query.
// order the posts by date in descending order (should go in functions.php to keep things tidy)
function order_by_date( $a, $b )
{
return strcmp( $b->post_date, $a->post_date );
}
@jcobb
jcobb / gist:3081631
Created July 10, 2012 06:45
Custom Magento Category Navigation
<div class="category-navigation">
<?php
// get the root category id
$root_cat_id = Mage::app()->getStore()->getRootCategoryId();
// get the current category object and ID
$current_cat_obj = Mage::registry('current_category');
$current_cat_id = $current_cat_obj->getId();
# Update LS colors
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi