Skip to content

Instantly share code, notes, and snippets.

View georgestephanis's full-sized avatar

George Stephanis georgestephanis

View GitHub Profile
@georgestephanis
georgestephanis / wp7-compat.js
Created May 3, 2012 22:10
Add support for menus to WP7 and better support to Android
jQuery(document).ready(function($){
if( $('#wpadminbar li.menupop').size() ){
$('#wpadminbar li.menupop').click(function(e){
if( ! $(this).hasClass('hover') ){
$('#wpadminbar li.menupop.hover').removeClass('hover');
$(this).addClass('hover');
e.preventDefault();
return;
@georgestephanis
georgestephanis / wp7-compat.js
Created May 3, 2012 22:10
Add support for menus to WP7 and better support to Android
if( 'undefined' != typeof( jQuery ) ){
jQuery(document).ready(function($){
var wpAdminBarChildren = $('#wpadminbar li.menupop');
if( wpAdminBarChildren.length ){
var wpAdminBarMobileHide = function(e){
if( ! $(e.target).closest('#wpadminbar').length ){
wpAdminBarChildren.removeClass('hover');
@georgestephanis
georgestephanis / gist:2784183
Created May 24, 2012 20:53
Tweet Markup for Brian
<div class="tweet" data-id="205505607548149760" data-author="knapier">
<img class="featured-pic" src="http://placekitten.com/300/300?rand=205505607548149760">
<img class="profile-pic" src="http://a0.twimg.com/profile_images/1924723185/why_normal.jpg" />
<h3 class="author-name">knapier</h3>
<p class="num-days">0 Days</p>
<p class="author-handle">knapier</p>
<hr class="dot-bar" />
<p class="content">RT @<a class=" " href="http://twitter.com/geeksugar">geeksugar</a>: Int'l Orange & general Golden Gate Bridge enthusiasts—that darlin' GGB case from <em>@<a class=" " href="http://twitter.com/speckproducts">speckproducts</a></em> is at the <a href="http://search.twitter.com/search?q=%23GGB75" title="#GGB75" class=" ">#GGB75</a> party <a href="http://t.co/Jv1zqfha">http://t.co/Jv1zqfha</a></p>
<p class="do-stuff">
<a href="https://twitter.com/intent/tweet?in_reply_to=205505607548149760">Reply</a>
$wp_rich_edit = true;
if ( wp_is_mobile() ) {
if( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) ){
$wp_rich_edit = ( intval( $match[1] ) >= 534 );
}
}
for( var i = 0; i < 10; i++ ){
alert( 'i=' + i );
}
var i = 0;
while( i < 10 ){
alert( 'i=' + i );
i++
}
@georgestephanis
georgestephanis / ___index.php
Created June 7, 2012 21:23
Magento Website Switcher
/* Determine the store we're after. */
if( isset( $_REQUEST['___website'] ) ) {
$___website = preg_replace( '/[^a-zA-Z0-9\s]/', '', $_REQUEST['___website'] );
$_SERVER['MAGE_RUN_CODE'] = $___website;
$_SERVER['MAGE_RUN_TYPE'] = 'website';
/* If the cookie isn't yet set, or the request variable is changing it ... */
if( ! isset( $_COOKIE['___website'] ) || ( $_COOKIE['___website'] !== $___website ) ){
@georgestephanis
georgestephanis / fetch-images.js
Created June 14, 2012 02:05
Possibility for fetching images for Press This?
img = document.getElementsByTagName('img');
send = [];
raw = new Image();
for( i in img ){
raw.src = img[i].src;
if( raw.width >= 50 || raw.height >= 50 ){
send.push( raw.src );
}
}
@georgestephanis
georgestephanis / random.sql
Created June 17, 2012 12:43
MySQL Optimization -- which is faster, or does it matter?
--- Option 1
SELECT p.ID
FROM wp_posts p
INNER JOIN wp_postmeta pm ON p.ID = pm.post_id
WHERE pm.key = 'key'
--- Option 2
SELECT p.ID
@georgestephanis
georgestephanis / ecchi.sql
Created June 18, 2012 03:55
sql for ecchi
UPDATE `wp_term_taxonomy`
SET `parent` = '1013'
WHERE `parent` = '0'
AND `term_id` != '1013'
@georgestephanis
georgestephanis / press-this.js
Created June 20, 2012 14:13
Press This Bookmarklet JS
var d=document,
w=window,
e=w.getSelection,
k=d.getSelection,
x=d.selection,
s=(e?e():(k)?k():(x?x.createRange().text:0)),
f='http://wordpress.site/wp-admin/press-this.php',
l=d.location,
e=encodeURIComponent,
u=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=4';