Skip to content

Instantly share code, notes, and snippets.

View ebinnion's full-sized avatar

Eric Binnion ebinnion

View GitHub Profile
@ebinnion
ebinnion / gist:5045409
Created February 27, 2013 05:36
Youtube Popup on Subscriber page
<!-- This link will take someone to your youtube channel then present them with a subscribe popup-->
<a href="http://www.youtube.com/subscription_center?add_user=artofblog">Text</a>
@ebinnion
ebinnion / gist:5045658
Created February 27, 2013 06:24
Random String Javascript
var numRand = String((new Date()).getTime()).replace(/\D/gi,'')
@ebinnion
ebinnion / gist:5095189
Last active June 14, 2017 15:44
Facebook centered pop up share
<script type="text/javascript">
function fbs_click(width, height) {
var leftPosition, topPosition;
//Allow for borders.
leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
//Allow for title and status bars.
topPosition = (window.screen.height / 2) - ((height / 2) + 50);
var windowFeatures = "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no";
u=location.href;
t=document.title;
@ebinnion
ebinnion / gist:5593813
Last active December 17, 2015 10:19
Followerwonk Social Authority API Code Example
<?php
// Not currently working.
// Example Output
/*
https://api.followerwonk.com/social-authority?screen_name=randfish;AccessID=member-NTFhMjQxOTQtYTcwNi01YzI4LTk0OTYtZDZlY mRlYzJiMjVk;Timestamp=1368728186;Signature=S97mqDTS0qngjKR41hPhdO4BHpE%3D
"401 Unauthorized"
*/
@ebinnion
ebinnion / config.php
Created May 31, 2013 14:01
Dynamically set CodeIgniter Base URL
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = "$root";
@ebinnion
ebinnion / interaction.js
Last active May 28, 2021 12:47
Will generate xpaths when elements clicked
/*!
* jQuery Cookie Plugin v1.3.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as anonymous module.
@ebinnion
ebinnion / indexOfType.js
Created July 11, 2013 15:19
Snippet will return a 1-based-index of an element in relation to like tags at same level.
// Return 1-based-index of an element in relation to like tags
function indexOfType(element) {
var prev = element.prevAll(element[0].tagName);
if ( empty(prev) ){
return 1; // For 1 indexing
}
else return 1 + prev.length;
}

Ok, I got there at the end. I couldn't use WP_Query class as I really needed to have my own pretty big and complex SQL. Here is what I ended up having:

In functions.php I have my custom SQL and logic for counting the values needed for the WP pagination logic:

function vacancies_current( ){
    global $wpdb, $paged, $max_num_pages, $current_date;

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $post_per_page = intval(get_query_var('posts_per_page'));

$offset = ($paged - 1)*$post_per_page;

@ebinnion
ebinnion / edd-custom-license.php
Last active December 21, 2015 18:39
This is a fully functioning WordPress plugin for Easy Digital Downloads that we use to allow users to choose between year or lifetime licenses. This assumes you are selling a singular product.
<?php
/*
* Plugin Name: EDD License Filter
* Description: Allows us to change license lengths based on pricing options.
* Author: Eric Binnion
* Version: 0.1
*/
// This snippet adapted from https://easydigitaldownloads.com/docs/changing-license-expiration-length/
@ebinnion
ebinnion / index.html
Created September 3, 2013 15:40
Foundation Starter
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Foundation 4</title>
<!-- If you are using CSS version, only link these 2 files, you may add app.css to use for your overrides if you like. -->