Skip to content

Instantly share code, notes, and snippets.

@fitzhaile
fitzhaile / tiny-mce.php
Created November 15, 2013 16:39
Config for Tiny MCE in Wordpress.
<?php
/**
* Add custom styles to the styleselect dropdown
*
* @since required+ Foundation 0.5.0
*
* @param array $settings
* @return array
*/
@fitzhaile
fitzhaile / enable_tags.php
Last active December 20, 2015 00:19
WP: Enable Page tags
<?php
// Include the following in functions.php
//-------------------------------------------
// add tag support to pages
function tags_support_all() {
register_taxonomy_for_object_type('post_tag', 'page');
}
// ensure all tags are included in queries
@fitzhaile
fitzhaile / script.rb
Created June 5, 2013 19:29
Base 64 encode Sass script
# Additional SASS Script functions
require 'sass'
require 'base64'
module Sass::Script::Functions
def base64encode(string)
assert_type string, :String
file = "."+string.value
data = File.open(file, "rb") {|io| io.read}
data = [data].flatten.pack("m").gsub("\n","")
@fitzhaile
fitzhaile / svg-png-fallback.js
Created March 26, 2013 22:17
Modernizr PNG SVG Fallback
if(!Modernizr.svg){
$("img.svg").each(function(){
var src = this.src.replace('.svg', '.png');
this.src = src;
});
}
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
@fitzhaile
fitzhaile / file_exists.rb
Last active December 14, 2015 01:29
Ruby: Custom file_exists Sass Function
module Sass::Script::Functions
def file_exists(image_file)
path = Dir.getwd + "/" + image_file.value
Sass::Script::Bool.new(File.exists?(path))
end
end
@fitzhaile
fitzhaile / *.php
Last active December 12, 2015 12:48
WP: Typical Testimonials Markup
<?php $testimonials = new WP_Query('post_type=testimonial'.ks_query('testimonials')); ?>
<div class="testimonials">
<?php while( $testimonials->have_posts() ): $testimonials->the_post(); ?>
<blockquote class="testimonial">
<?php the_content(); ?>
<footer>
<p>
<?php the_title(); ?>
</p>
<?php $attachments = new Attachments( 'attachments' ); ?>
<?php if( $attachments->exist() ) : ?>
<h3>Attachments</h3>
<ul>
<?php while( $attachments->get() ) : ?>
<li>
ID: <?php echo $attachments->id(); ?><br />
Type: <?php echo $attachments->type(); ?><br />
Subtype: <?php echo $attachments->subtype(); ?><br />
URL: <?php echo $attachments->url(); ?><br />
<?php
function my_attachments( $attachments )
{
$args = array(
// title of the meta box (string)
'label' => 'My Attachments',
// all post types to utilize (string|array)
@fitzhaile
fitzhaile / is_blog.php
Created October 16, 2012 16:31 — forked from wesbos/is_blog.php
WordPress is_blog()
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>