Skip to content

Instantly share code, notes, and snippets.

@sambody
sambody / fullwidthelement.js
Created September 30, 2015 23:22 — forked from billerickson/global.js
Full with element in middle of page
// Make an element in the page go full width
// Author: Bill Erickson
// URL: http://www.billerickson.net/code/full-width-element-middle-page/
function explodeWidth() {
var browserWidth = $(document).width();
var wrapWidth = $('.site-inner .wrap').width();
var margin = ( ( browserWidth - wrapWidth ) / 2 );
$('.explode-width').css( 'margin-left', - margin ).css( 'margin-right', - margin );
}
@sambody
sambody / equal-height-columns.js
Created June 25, 2014 11:48
Equal height columns
// Set equal height columns, for background color
$.fn.setAllToMaxHeight = function(){
return this.height( Math.max.apply(this, $.map( this , function(e){ return $(e).height() }) ) );
}
$('.main-col, .sub-col').setAllToMaxHeight()
@sambody
sambody / _config.scss
Last active January 3, 2016 02:09 — forked from elisechant/_config.scss
Compass, Susy configuration, with separate stylesheet for IE8 (automatically)
$is-ie8: false !default;
// Compass cross-browser support configuration
$legacy-support-for-ie6: false;
$legacy-support-for-ie7: false;
$legacy-support-for-ie8: true;
// Susy settings
// ------------------------------------------------
@sambody
sambody / form label classes.js
Created November 29, 2013 10:38
Set classes to form labels depending on (child) input type. (Taken from StarGazer wordpress theme by Justin Tadlock.)
/*
* Adds classes to the `<label>` element based on the type of form element the label belongs
* to. This allows theme devs to style specifically for certain labels (think, icons).
*/
jQuery( '#container input, #container textarea, #container select' ).each(
function() {
var sg_input_type = 'input';
var sg_input_id = jQuery( this ).attr( 'id' );
define('WP_DEBUG', true);
/**
* When debug mode is enabled, you can enable logging to store errors in wp-content/debug.log
* This is useful for finding errors that might not get displayed on screen
*
* The next conditional section will make sure errors are not shown to users when logging is enabled
* This helps with quick troubleshooting on live sites
*/
define('WP_DEBUG_LOG', true);
@sambody
sambody / config for multi environments
Created September 12, 2013 21:39
Multi environment (servers) wordpress config file.
<?php
if( stristr( $_SERVER['SERVER_NAME'], "dev" ) ) {
// Dev Environment
define( 'DB_NAME', 'project_dev' );
define( 'DB_USER', 'project_dev_user' );
define( 'DB_PASSWORD', 'password' );
define( 'DB_HOST', 'localhost' );
@sambody
sambody / hide plugin
Created September 12, 2013 20:56
Remove plugin completely from admin (hide it), to prevent deactivation.
// hide plugins in admin
add_filter( 'all_plugins', 'hide_plugins');
function hide_plugins($plugins)
{
// Hide hello dolly plugin
if(is_plugin_active('hello.php')) {
unset( $plugins['hello.php'] );
}
// Hide disqus plugin
@sambody
sambody / disable theme switching
Created August 8, 2013 21:06
Disable theme switching for all (or all except admin) by hiding theme menu item under Appearance
// disable theme switching by hiding theme item - for all except admin (id 1)
add_action( ‘admin_init’, ‘slt_lock_theme’ );
function slt_lock_theme() {
global $submenu, $userdata;
get_currentuserinfo();
if ( $userdata-&gt;ID != 1 ) {
unset( $submenu['themes.php'][5] );
unset( $submenu['themes.php'][15] );
}
}
@sambody
sambody / no plugin deactivation
Created August 8, 2013 21:01
Prevent one or more plugins to be deactivated by admin link. For clients sites. (or hide it completely with other snippet)
add_filter( 'plugin_action_links', 'disable_plugin_deactivation', 10, 4 );
function disable_plugin_deactivation( $actions, $plugin_file, $plugin_data, $context ) {
// Remove edit link for all
if ( array_key_exists( 'edit', $actions ) )
unset( $actions['edit'] );
// Remove deactivate link for crucial plugins
if ( array_key_exists( 'deactivate', $actions ) && in_array( $plugin_file, array(
'akismet/akismet.php',
'better-author-bio/better-author-bio.php'
)))
@sambody
sambody / tooltip with arrow down
Created June 29, 2013 21:50
CSS: arrow down on tooltip with border
/*
check in IE, might need ":" instead of "::"
HTML: <p class="tooltip">Some text</p>
*/
/* tooltip element with border */
.tooltip {
position:relative;
padding:15px;
margin:1em 0 3em;