Skip to content

Instantly share code, notes, and snippets.

View chriscoyier's full-sized avatar

Chris Coyier chriscoyier

View GitHub Profile
@chriscoyier
chriscoyier / gist:972314
Created May 14, 2011 15:21
is_custom_post_type.php
<?php
// returns boolean
function is_custom_post_type( $type = '' ) {
// access to currently queried post
global $post;
// get the current post type
$post_type = get_post_type( $post );
@chriscoyier
chriscoyier / gist:972699
Created May 14, 2011 22:20
commentcodeplugin.md

IDEA: WordPress Plugin for Improving Leaving Code in Comments

It's always quite a struggle to keep people doing it correctly on CSS-Tricks, so I'd love if there was a plugin to make it more foolproof.

The overall idea: make it so if you use <code> tags, it will come out perfectly.


1) Automatically escape code that isn't escaped

var instanse = false;
var state;
var mes;
var file;
function Chat () {
this.update = updateChat;
this.send = sendChat;
this.getState = getStateOfChat;
}
@chriscoyier
chriscoyier / gist:1027728
Created June 15, 2011 18:21
doctypeandhtml.html
<!doctype html>
<!--[if lt IE 7 ]> <html class="no-js ie6 ie" lang="en"> <![endif]-->
<!--[if IE 7 ]> <html class="no-js ie7 ie" lang="en"> <![endif]-->
<!--[if IE 8 ]> <html class="no-js ie8 ie" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
* {
-webkit-border-radius: 0 !important;
-moz-border-radius: 0 !important;
border-radius: 0 !important;
-webkit-box-shadow: 0 !important;
-moz-box-shadow: 0 !important;
box-shadow: 0 !important;
-webkit-transition: none !important;
# BEGIN W3 Total Cache
<IfModule mod_rewrite.c>
SetEnvIfNoCase Accept-Encoding (gzip) APPEND_EXT=.$1
RewriteEngine On
RewriteCond %{REQUEST_URI} !\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register).php|/video-feed/|/video-feed-iphone/ [OR]
RewriteCond %{REQUEST_URI} wp-comments-popup\.php|wp-links-opml\.php|wp-locations\.php [NC]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =""
RewriteCond %{HTTP_COOKIE} !comment_author|wp-postpass|wordpress_\[a-f0-9\]\+|wordpress_logged_in [NC]
RewriteCond %{HTTP_USER_AGENT} !bot|ia_archive|slurp|crawl|spider [NC]
<ul>
<li>
<a href="#">Do a thing</a>
<summary>
?
<details>
Bunch of HTML in here.
<details>
</summary>
</li>
.fluid-width-video-wrapper {
width: 100%;
position: relative;
padding: SET-BY-JAVASCRIPT% 0 0 0;
}
.fluid-width-video-wrapper iframe,
.fluid-width-video-wrapper object,
.fluid-width-video-wrapper embed {
position: absolute;
@chriscoyier
chriscoyier / functions.php
Created September 16, 2011 20:35
functions.php
<?php
// tumblr-like post titles in feeds
function tumblrFeedTitles($permalink) {
global $wp_query;
if ($url = get_post_meta($wp_query->post->ID, 'TumblrURL', true)) {
return $url;
}
return $permalink;
}
(function() {
var fluidParent = $("#juice > .inside > article"),
newWidth, newHeight;
function resizeVideo() {
newWidth = fluidParent.width();
sublimevideo.resize('the-video', newWidth, newWidth/1.78125);
};