Skip to content

Instantly share code, notes, and snippets.

@raideus
raideus / git-branch-in-prompt.sh
Last active August 29, 2015 14:03
Add current git branch to command prompt
# Add to bashrc file
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PS1='[\u@\h \w\[\033[32m\]$(parse_git_branch)\[\033[00m\] \t] $' # Edit formatting to your liking
<?php
$args = array();
$args['wp_query'] = array( 'post_type' => array('page', 'field', 'param'),
'orderby' => 'title',
'order' => 'ASC' );
$args['fields'][] = array( 'type' => 'search',
'placeholder' => 'Enter search terms' );
$args['fields'][] = array( 'type' => 'post_type',
'format' => 'checkbox',
'label' => 'Search by post type',
@raideus
raideus / my_homepage_scripts.php
Created April 13, 2012 17:12
Register & Enqueue scripts for a particular page (Wordpress)
<?php
function my_homepage_scripts() {
if ( is_front_page() ) {
// jQuery Cycle plugin
wp_register_script( 'jquery-cycle', get_template_directory_uri() . '/js/libs/jquery.cycle.all.js', array( 'jquery' ), '2012-03-13T10:15', false );
wp_enqueue_script( 'jquery-cycle' );
// Custom settings for jQuery Cycle
wp_register_script( 'jquery-cycle-settings', get_template_directory_uri() . '/js/jquery-cycle-settings.js', array( 'jquery-cycle', 'jquery' ), '2012-04-13T10:15', false );
@raideus
raideus / wp-no-image-links.php
Created April 26, 2012 17:35
Stop WordPress from linking images by default
@raideus
raideus / wp-enqueue-scripts-example1.php
Created April 27, 2012 16:43
Example of using wp_enqueue_scripts() in WordPress
<?php
// Create a function to enqueue our scripts
function add_my_scripts() {
// Enqueue the modernizr script file and specify that it should be placed in the <head>
wp_enqueue_script( 'modernizr', get_template_directory_uri() . '/js/libs/modernizr-2.5.3.min.js', array(), '2.5.2', false );
}
@raideus
raideus / wordpress-fluid-images.css
Created April 29, 2012 17:29
CSS for implementing fluid images on a WordPress site.
img,
.wp-caption {
max-width: 100%;
}
@raideus
raideus / wordpress-fluid-images.js
Created April 29, 2012 17:35
jQuery script for implementing fluid images on a WordPress site
jQuery(document).ready(function($) {
// Remove width & height attributes from images (added by default in WordPress)
$('img').removeAttr('width').removeAttr('height');
// Remove style attribute on image captions, which sets a fixed width by default
$('.wp-caption').removeAttr('style');
});
@raideus
raideus / wordpress-add-editor-style.php
Created May 6, 2012 13:56
Apply Your WordPress Theme Styles in the WYSIWYG Editor
<?php
// Add styles to the WYSIWYG editor. Function finds stylesheet from the root of the current theme's folder.
add_editor_style('style.css');
?>
@raideus
raideus / wordpress-editor-styles.css
Created May 6, 2012 14:02
Override WordPress TinyMCE Editor Styles
#tinymce {
background: white;
}
#tinymce a {
color: #ff0000;
}
@raideus
raideus / wp-absolute-sidebar-urls.php
Created May 10, 2012 22:24
WordPress Absolute Sidebar URLs
<?php
/* --------------------------------------------------------------------------------
Add Shortcode Support in Widgets
** Props to http://hackadelic.com/the-right-way-to-shortcodize-wordpress-widgets
-----------------------------------------------------------------------------------*/
if ( !is_admin() ):
add_filter('widget_text', 'do_shortcode', 11);
endif;