Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Shelob9 / twitter-button
Created December 31, 2012 02:26
Add twitter share button to wordpress theme. Change data-show-count="false" to data-show-count="true" to show follower count https://dev.twitter.com/docs/follow-button
<?php $username = get_the_author_meta('twitter'); ?>
<a class="twitter-follow-button" data-show-count="false" href="http://twitter.com/<?php echo $username; ?>">Follow @<?php echo $username; ?></a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
@Shelob9
Shelob9 / foundation.min.js
Last active December 11, 2015 07:58
This is a minified version of all of the javascript for ZURB's Foundation except for jquery itself and app.js. I included all files I found in https://github.com/zurb/foundation/tree/master/vendor/assets/javascripts/foundation except for app.js, index.js and jquery.js
/* Modernizr 2.6.2 (Custom Build) | MIT & BSD
* Build: http://modernizr.com/download/#-inlinesvg-svg-svgclippaths-touch-shiv-mq-cssclasses-teststyles-prefixes-ie8compat-load
*/
;window.Modernizr=function(a,b,c){function y(a){j.cssText=a}function z(a,b){return y(m.join(a+";")+(b||""))}function A(a,b){return typeof a===b}function B(a,b){return!!~(""+a).indexOf(b)}function C(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:A(f,"function")?f.bind(d||b):f}return!1}var d="2.6.2",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k,l={}.toString,m=" -webkit- -moz- -o- -ms- ".split(" "),n={svg:"http://www.w3.org/2000/svg"},o={},p={},q={},r=[],s=r.slice,t,u=function(a,c,d,e){var f,i,j,k,l=b.createElement("div"),m=b.body,n=m||b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),l.appendChild(j);return f=["&#173;",'<style id="s',h,'">',a,"</style>"].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style
@Shelob9
Shelob9 / foundation-wp-comment-submit.js
Last active November 21, 2017 02:18
This is a hack for adding a class (in this case a standard button) to style the comment submit button in wordpress when using foundation. Found this method at: http://wordpress.stackexchange.com/a/60197/25300
jQuery(document).ready(function($) { //noconflict wrapper
$('input#submit').addClass('button');
});//end noconflict
@Shelob9
Shelob9 / WordPress-Social
Last active December 11, 2015 16:59
Reddit/ Twitter/ Facebook/ Google Plus sharing for WordPress without using plugins. I have included an example layout using Foundation Framework by ZURB. There is both a button to tweet the post, and a button to follow the post author, which is useful for multi-author blogs. You will need to get the Facebook Javascript SDK from Facebook Javascri…
<div class="row">
<!-- BE SURE TO ADD USER NAME In "Date-via" property-->
<div class="small-6 large-4 columns" id="tweet-it">
<a href="https://twitter.com/share" class="twitter-share-button" data-via="USERNAME" data-text="<?php the_title(); ?>" data-url="<?php the_permalink(); ?>">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];
if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
<div class="small-6 large-4 columns">
<div class="g-plusone" data-size="medium" data-annotation="none">
@Shelob9
Shelob9 / wp-arbitrary-order
Created March 3, 2013 21:30
Show wordpress posts in arbitrary order. Best for category page. Problem solves, as always, on WordPress Answers http://wordpress.stackexchange.com/questions/89148/how-to-order-posts-in-an-arbitrary-order
<?php
$custom_query = new WP_Query(array(
'post__in' => array(4, 9, 12 /* whatever your post ID's are here */),
'orderby' => 'post__in',
));
while ($custom_query->have_posts()) {
$custom_query->the_post();
get_template_part( 'content', get_post_format() );
}
@Shelob9
Shelob9 / zip-no-DS_Store
Last active December 16, 2015 07:48
Zip a file in Mac OSX without including the DS_Store file.
zip -r archive.zip directory -x "*/\.DS_Store"
@Shelob9
Shelob9 / f4-init.js
Created April 17, 2013 06:34
Initialize Foundation 4 javascript with support for tooltips and orbit, with the ability to do a double or single orbit slider. It is wrapped in a no conflict wrapper for use with WordPress. Double orbit script found at: http://stackoverflow.com/questions/15534385/slide-two-divs-at-the-same-time/15545241#15545241
jQuery(document).ready(function($) {
//http://stackoverflow.com/questions/15534385/slide-two-divs-at-the-same-time/15545241#15545241
$(document)
.foundation('tooltips')
.foundation('orbit', {
timer_speed: 0
});
$(document).ready(function () {
var fromSlide1 = false;
var fromSlide2 = false;
@Shelob9
Shelob9 / put-in-functions.php
Last active December 17, 2015 04:38
Set fullscreen background in WordPress with an approprietly sized image. Work in progress from: http://stackoverflow.com/a/16454226/1469799
/**
* Set the fullscreen background image using a smaller image for small (ie mobile screens)
* http://pippinsplugins.com/retrieve-attachment-id-from-image-url/
*/
//get id of attachment by full url
// http://pippinsplugins.com/retrieve-attachment-id-from-image-url/
function _sf_get_image_id($image_url) {
global $wpdb;
$prefix = $wpdb->prefix;
@Shelob9
Shelob9 / adsenser.php
Last active December 17, 2015 07:09
Function to add adsense ads to WordPress theme with tracking codes per author and a default tracking code for non-post pages. Work in progress, but should function fine. Will be finished and made into a plugin when I have time. Adapted from what I did for http://NatureScholar.com Needs: a better way to set the Client ID, make into a plugin, more…
<?php
//based on http://wp.tutsplus.com/tutorials/business/how-to-share-adsense-revenue-with-your-authors/
//Set Adsense client ID.
$ad_client_id = ' ';
// Create Custom Settings Menu
add_action('admin_menu', 'adsenser_menu');
function adsenser_menu() {
//Create Sub-Level Menu Page under Settings
add_submenu_page( 'options-general.php', 'Adsenser Settings', 'Adsenser', 'manage_options', 'adsenser_settings_page', 'adsenser_settings_page');
@Shelob9
Shelob9 / dabblet.css
Created May 16, 2013 22:13 — forked from kizu/dabblet.css
Arc movement
/* Arc movement */
.wrapper {
width: 500px;
margin: 300px 0 0;
transition: all 1s;
transform-origin: 50% 50%;
}
.inner {
display: inline-block;