Skip to content

Instantly share code, notes, and snippets.

View seafarer's full-sized avatar
☎️
DM me, maybe

Colin OBrien seafarer

☎️
DM me, maybe
View GitHub Profile
@seafarer
seafarer / current-template.php
Created April 23, 2014 21:56
What template is in use on wp page?
<?php
add_filter( 'template_include', 'var_template_include', 1000 );
function var_template_include( $t ){
$GLOBALS['current_theme_template'] = basename($t);
return $t;
}
function get_current_template( $echo = false ) {
if( !isset( $GLOBALS['current_theme_template'] ) )
@seafarer
seafarer / icon-font.scss
Created March 18, 2014 20:33
Font face icons in scss
// Start with a mixin
@mixin iconfont {
font-family: "foundation-icons"; // whatever your icon fonts name is
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
display: inline-block;
<form id="contact" name="contact" method="post">
<fieldset>
<label for="name" id="name">Name<span class="required">*</span></label>
<input type="text" name="name" id="name" size="30" value="" required/>
<label for="email" id="email">Email<span class="required">*</span></label>
<input type="text" name="email" id="email" size="30" value="" required/>
<label for="phone" id="phone">Phone</label>
<input type="text" name="phone" id="phone" size="30" value="" />
@seafarer
seafarer / update-hooks.php
Created February 14, 2014 19:49
drupal update hooks
function MODULE_update_7200() {
if( module_exists('MODULE')) {
module_disable(array('MODULE'));
drupal_uninstall_modules(array('MODULE'));
}
}
@seafarer
seafarer / admin-filter
Created February 3, 2014 22:43
Sexy Wordpress admin filter for custom post types with custom taxonomies. Plug and play - no config necessary. Via [stackexchange] (http://wordpress.stackexchange.com/questions/578/adding-a-taxonomy-filter-to-admin-list-for-a-custom-post-type)
function todo_restrict_manage_posts() {
global $typenow;
$args=array( 'public' => true, '_builtin' => false );
$post_types = get_post_types($args);
if ( in_array($typenow, $post_types) ) {
$filters = get_object_taxonomies($typenow);
foreach ($filters as $tax_slug) {
$tax_obj = get_taxonomy($tax_slug);
wp_dropdown_categories(array(
'show_option_all' => __('Show All '.$tax_obj->label ),
@seafarer
seafarer / wp-category-sort
Created January 2, 2014 21:37
category sort on category archive template
<?php
global $wp_query;
query_posts(
array_merge(
$wp_query->query,
array(
'order' => 'ASC',
'orderby'=>'title',
'posts_per_page' => 20,
)
# Requre a specific version in this file:
# gem 'zurb-foundation', '=4.3.1'
require 'zurb-foundation'
# Require any additional compass plugins here.
# IE 9 and below only support up to 4095 CSS selectors
# This class will split all selectors after that point
class CssSplitter
def self.split(infile, outdir = File.dirname(infile), max_selectors = 4095)
@seafarer
seafarer / magnific wordpress
Created October 15, 2013 03:15
Integrate magnific popup into wordpress via http://pastebin.com/s3rT3FBr
jQuery(document).ready(function($) {
$('a[href*=".jpg"], a[href*=".jpeg"], a[href*=".png"], a[href*=".gif"]').each(function(){
//single image popup
if ($(this).parents('.gallery').length == 0) {
$(this).magnificPopup({type:'image'});
}
});
//gallery popup
$('.gallery').each(function() {
$(this).magnificPopup({
@seafarer
seafarer / wordpress-gitignore
Last active December 20, 2015 05:58
wordpress gitignore
wp-config.php
wp-content/uploads/
wp-content/blogs.dir/
wp-content/upgrade/
wp-content/backup-db/
wp-content/advanced-cache.php
wp-content/wp-cache-config.php
sitemap.xml
*.log
wp-content/cache/
@seafarer
seafarer / wp-post-images
Created July 24, 2013 03:22
Access wordpress post images uploaded and inserted through gallery function
<?php
$args = array(
'numberposts' => -1, // Using -1 loads all posts
'orderby' => 'menu_order', // This ensures images are in the order set in the page media manager
'order'=> 'ASC',
'post_mime_type' => 'image', // Make sure it doesn't pull other resources, like videos
'post_parent' => $post->ID, // Important part - ensures the associated images are loaded
'post_status' => null,
'post_type' => 'attachment'