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 / gist:2991270
Last active August 3, 2017 13:35
Wordpress: Move Site SQL Command
UPDATE wp_options SET option_value = replace(option_value, 'http://oldsite.com', 'http://newsite.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://oldsite.com', 'http://newsite.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://oldsite.com', 'http://newsite.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://oldsite.com', 'http://newsite.com');
@rupert-ong
rupert-ong / gist:2995877
Created June 26, 2012 13:49
Wordpress: Remove Image Attributes
// Remove Image Attributes
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
function remove_thumbnail_dimensions( $html ) {
$html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
return $html;
}
@rupert-ong
rupert-ong / gist:3004405
Created June 27, 2012 14:28
Wordpress: Previous Next Post Link
<?php
previous_post_link('%link', '&laquo; Previous Post');
if (get_adjacent_post(false, '', false) && get_adjacent_post(false, '', true)) {
echo ' | ';
}
next_post_link('%link', 'Next Post &raquo;');
@rupert-ong
rupert-ong / CSS3 Shadow
Created July 6, 2012 14:53
CSS3: Angled Drop Shadows
div {
background: rgba(255,255,255,1);
margin: 0 auto;
width: 200px;
padding: 100px;
text-align: center;
position: relative;
}
.shadow::before, .shadow::after {
@rupert-ong
rupert-ong / snippet.js
Created July 9, 2012 14:44 — forked from necolas/snippet.js
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
@rupert-ong
rupert-ong / gist:3209846
Created July 30, 2012 20:21
CSS: Micro Clearfix
/**
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* contenteditable attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that are clearfixed.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
*/
.cf:before,
@rupert-ong
rupert-ong / 0_selector_hacks.scss
Created September 5, 2012 18:17 — forked from chriseppstein/0_selector_hacks.scss
This gist demonstrates some uses of the new sass feature: Passing content blocks to mixins.
@mixin ie6 { * html & { @content } }
#logo {
background-image: url("/images/logo.png");
@include ie6 { background-image: url("/images/logo.gif"); }
}
@rupert-ong
rupert-ong / ajaxify-html5.js
Created September 25, 2012 14:03 — forked from balupton/README.md
Ajaxify a Website with the HTML5 History API using History.js, jQuery and ScrollTo
// https://gist.github.com/854622
(function(window,undefined){
// Prepare our Variables
var
History = window.History,
$ = window.jQuery,
document = window.document;
// Check to see if History.js is enabled for our Browser
@rupert-ong
rupert-ong / header.php
Created November 19, 2012 14:47
Wordpress: Title Section
<?php if (function_exists('is_tag') && is_tag()) {
single_tag_title('Tag Archive for &quot;');
echo '&quot; - ';
} elseif (is_archive()) {
wp_title('');
echo ' Archive - ';
} elseif (is_search()) {
echo 'Search for &quot;'.wp_specialchars($s).'&quot; - ';
} elseif (!(is_404()) && (is_single()) || (is_page())) {
wp_title('');
@rupert-ong
rupert-ong / header.php
Created November 19, 2012 14:57
Wordpress: Page Indexing
<?php if ( (is_home() && (!$paged || $paged ==1)) || is_page() || is_single() || is_category()) :?>
<meta name="googlebot" content="index,archive,follow,noodp" />
<meta name="robots" content="all,index,follow" />
<meta name="msnbot" content="all,index,follow" />
<?php else : ?>
<meta name="googlebot" content="noindex,noarchive,follow,noodp" />
<meta name="robots" content="noindex,follow" />
<meta name="msnbot" content="noindex,follow" />
<?php endif; ?>