Skip to content

Instantly share code, notes, and snippets.

View rupert-ong's full-sized avatar

Rupert Ong rupert-ong

  • Toronto, Ontario
View GitHub Profile
@rupert-ong
rupert-ong / style.scss
Created November 19, 2012 15:01
Wordpress: Stylesheet Markup
/*
Theme Name:
Theme URI:
Author:
Author URI:
Description:
Version: 1.0
License: GNU General Public License
License URI: licensep
Tags:
@rupert-ong
rupert-ong / header.php
Created November 19, 2012 15:39
Wordpress: Navigation Menu Embed
<?php
if(function_exists('wp_nav_menu')):
wp_nav_menu(
array(
'menu' =>'primary_nav',
'container'=>'',
'depth' => 2,
'menu_id' => '' )
);
else:
@rupert-ong
rupert-ong / Wordpress - Sass Move style.css to parent directory (config.rb)
Created April 25, 2013 12:52
Wordpress: Sass - Move style.css to parent directory (config.rb)
# Move style.css to parent (root) directory of theme
require 'fileutils'
on_stylesheet_saved do |file|
if File.exists?(file) && File.basename(file) == "style.css"
puts "Moving: #{file}"
FileUtils.mv(file, File.dirname(file) + "/../" + File.basename(file))
end
end
@rupert-ong
rupert-ong / Sass: Ultimate Media Query Mixin (Alwaystwisted.com)
Created April 25, 2013 13:51
Sass: Ultimate Media Query Mixin (Alwaystwisted.com)
@mixin mq($point, $IE9: false, $query1: min, $query2: width) {
@if $IE9 == true{
.lt-ie9 & {
@content;
}
@media screen and (#{$query1}-#{$query2}: $point / $base-font-size +em) {
@content;
}
}
@rupert-ong
rupert-ong / functions.php
Last active December 17, 2015 18:59
Wordpress: Remove Unwanted BR and P Tags around Shortcodes
// Place in functions.php
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 12);
// Place in your shortcode (in functions.php)
$content = wpautop(trim($content))
@rupert-ong
rupert-ong / functions.php
Last active December 20, 2015 23:09
Wordpress: Remove auto paragraphs from shortcode content
/**
* Don't auto-p wrap shortcodes that stand alone
*
* Ensures that shortcodes are not wrapped in <<p>>...<</p>>.
*
* @since 2.9.0
*
* @param string $pee The content.
* @return string The filtered content.
*/
@rupert-ong
rupert-ong / single.php
Created August 14, 2013 17:50
Wordpress: Post Time Snippet
<time datetime="<?php the_time('Y-m-d'); echo('T'); the_time('h:i:s'); ?>"><?php the_time('F j, Y') ?></time>
@rupert-ong
rupert-ong / functions.php
Created September 24, 2013 14:23
Wordpress: Limit Search Results to Specific Post Type
<?php
function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type',array('post','page'));
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');
?>
@rupert-ong
rupert-ong / gist:6685564
Created September 24, 2013 14:24
Wordpress: Get Featured Image Source
<?php
$imgsrc = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");
echo $imgsrc[0];
?>
@rupert-ong
rupert-ong / Main.java
Last active September 16, 2018 01:54
Java: Logging Hierarchy #java #logging #hierarchy
package com.ps;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Main {
// Parent and child logger
static Logger pkgLogger = Logger.getLogger("com.ps");
static Logger logger = Logger.getLogger("com.ps.Main");