Skip to content

Instantly share code, notes, and snippets.

@guillermorangel
guillermorangel / csstoggle
Created July 9, 2013 22:01
Toggle CSS format between single and multiline
import sublime, sublime_plugin, re
DEBUG_ENABLED = False
PRINT_CONTEXT = False
# Toggle between single-line or multi-line formatted css statement
#
# Save as: ~/Library/Application Support/Sublime Text 2/Packages/User/CSSToggle.py
#
# Add the following line to Preferences > Key Bindings - User
@guillermorangel
guillermorangel / Simple.tmTheme
Created July 10, 2013 00:56
Custom Sublime Theme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Simple</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@guillermorangel
guillermorangel / chidtheme.css
Last active December 19, 2015 18:49
Child theme code for style.css
/*
Theme Name: Twenty Twelve Child
Theme URI: http://example.com/
Description: Child theme for the Twenty Twelve theme
Author: Your name here
Author URI: http://example.com/about/
Template: twentytwelve
Version: 0.1.0
*/
<?php function mobile_device($classes) {
global $variable;
$is_ipad = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad');
$is_iphone = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPhone');
$is_ipod = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPod');
$is_android = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'Android');
if ( $is_android ) {
$mobile_device = 'android';
} elseif ( $is_iphone || $is_ipad || $is_ipod ) {
@guillermorangel
guillermorangel / sticky-scroll
Created July 31, 2013 20:42
sticky content after scroll
$(function(){ // document ready
if (!!$('.sticky').offset()) { // make sure ".sticky" element exists
var stickyTop = $('.sticky').offset().top; // returns number
$(window).scroll(function(){ // scroll event
var windowTop = $(window).scrollTop(); // returns number
<?php
// http://codex.wordpress.org/Class_Reference/WP_Query
$query = new WP_Query( 'p=7' );
$query = new WP_Query( 'name=about-my-life' );
$query = new WP_Query( 'page_id=7' );
$query = new WP_Query( 'pagename=contact' );
<?php
add_action( 'init', 'my_custom_menus' );
function my_custom_menus() {
register_nav_menus(
array(
'primary-menu' => __( 'Primary Menu' ),
'secondary-menu' => __( 'Secondary Menu' ),
'footer-left' => __( 'Footer Left' ),
'footer-right' => __( 'Footer Right' ),
'sitemap' => __( 'Sitemap' )
<?php
// Action Hook
add_action('action_name', 'your_function_name');
function your_function_name() {
// Your code
}
// Filter Hook
@guillermorangel
guillermorangel / custom_post_types.php
Created August 28, 2013 18:16
Custom Post Types
<?php
// http://wp.smashingmagazine.com/2012/11/08/complete-guide-custom-post-types/
// http://codex.wordpress.org/Function_Reference/register_post_type
function custom_post_type_employees() {
$labels = array(
'name' => _x( 'Employees', 'post type general name' ),
'singular_name' => _x( 'Employee', 'post type singular name' ),
'menu_name' => _x( 'Employees', 'wordpress menu name, default value of name' ),
'add_new' => _x( 'Add New', 'employee' ),
'add_new_item' => __( 'Add New Employee' ),
<?php
add_action('init', 'woo_add_portfolio');
if ( !function_exists('woo_add_portfolio') ) {
function woo_add_portfolio()
{
$labels = array(
'name' => _x('Portfolio', 'post type general name', 'woothemes'),
'singular_name' => _x('Portfolio Item', 'post type singular name', 'woothemes'),
'add_new' => _x('Add New', 'slide', 'woothemes'),
'add_new_item' => __('Add New Portfolio Item', 'woothemes'),