Skip to content

Instantly share code, notes, and snippets.

View colorful-tones's full-sized avatar
💓
Don’t believe the hype!

Damon Cook colorful-tones

💓
Don’t believe the hype!
View GitHub Profile
@colorful-tones
colorful-tones / remove_capital_P_dangit.php
Created March 8, 2012 19:44
remove capital_P_dangit funtion
<?php
// Remove the capital_P_dangit function from Wordpress
// place in your themes' functions.php file, or
// better yet make a plugin and keep functionality
// out of your themes.
remove_filter( 'the_title', 'capital_P_dangit', 11 );
remove_filter( 'the_content', 'capital_P_dangit', 11 );
remove_filter( 'comment_text', 'capital_P_dangit', 31 );
@colorful-tones
colorful-tones / .htaccess
Created April 24, 2013 15:39
enable gzip compression via .htaccess for WordPress sites. Make sure gzip compression is enabled on server first, otherwise it is useless.
# START enable gzip compression
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
@colorful-tones
colorful-tones / Hide WP Admin Menus
Created June 11, 2013 14:36
Hide WordPress admin menu items from everybody but Super Admin. Helpful for hiding 'Posts' and 'Comments' menu items when client isn't using blog. Change unfiltered_html to install_plugins if you want to all Admins access to menu items too, etc.
// hide the Posts and Comments menu items from ALL roles except Super Admin
// https://codex.wordpress.org/Roles_and_Capabilities
function remove_menus () {
global $menu;
if( (current_user_can('unfiltered_html')) ) { $restricted = array(__()); }
else { $restricted = array( __('Posts'),__('Comments')); } // hide these for other roles
end ($menu);
while (prev($menu)) {
$value = explode(' ',$menu[key($menu)][0]);
@colorful-tones
colorful-tones / ClearDNSCache
Created June 11, 2013 14:40
clear dns cache on mac via Terminal or iTerm
sudo killall -HUP mDNSResponder
@colorful-tones
colorful-tones / typekit
Created June 11, 2013 14:42
Enqueue Typekit fonts for WordPress
<?php
// TypeKit
wp_enqueue_script( 'elp-typekit', '//use.typekit.net/YOUR_KIT_NUMBER_ID.js');
function elp_typekit_inline() {
if ( wp_script_is( 'elp-typekit', 'done' ) ) { ?>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<?php }
}
add_action( 'wp_head', 'elp_typekit_inline' );
@colorful-tones
colorful-tones / conditional-sidebar
Created June 11, 2013 14:46
Conditional sidebar logic for WordPress page. http://stackoverflow.com/questions/10486895/wordpress-conditional-sidebar-section-based-off-of-page-id conditional logic for custom sidebar… place it in page.php or even index.php to replace get_sidebar()
<?php
// make sure any child pages inherit sidebar properties
$ancestors = array_reverse(get_ancestors(get_the_ID(), 'page'));
$top_page = $ancestors ? get_page($ancestors[0]) : get_page(get_the_ID());
/*
check to see if a custom sidebar exists for our page based on
the page's slug, like a page named "About Us" would have sidebar-about-us.php
*/
if(locate_template('sidebar-'.$top_page->post_name.'.php'))
@colorful-tones
colorful-tones / update-WP-URLs
Created June 11, 2013 14:49
Update URLs in WordPress database when migrating from dev to production. One way of doing it at least ;)
UPDATE `wp_posts` SET guid = REPLACE(guid, 'http://YOURSITE.sites.mannixmarketing.com', 'http://www.CLIENTSITE.com');
UPDATE `wp_posts` SET post_content = REPLACE(post_content, 'http://YOURSITE.sites.mannixmarketing.com', 'http://www.CLIENTSITE.com');
Modernizr.load([{
// Test
test: Modernizr.cssanimations,
// If yes:
yep: {
'yesResponse': '/css/yes.css'
},
// If no:
nope: {
'noResponse': ['/js/yes.js', '/css/yes.css']
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot
@colorful-tones
colorful-tones / Create-db
Created June 11, 2013 14:53
Create MySQL db
create database 'yourdbname';