Skip to content

Instantly share code, notes, and snippets.

View reformatco's full-sized avatar

Reformat reformatco

View GitHub Profile
@reformatco
reformatco / wp-fn-twitter
Last active September 11, 2022 10:18
Twitter Feed Function for Wordpress
function getTweets($user, $num = 3) {
//first, get the user's timeline
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/$user.json?count=$num");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
curl_close($ch);
if ($json === false) { return false; } //abort on error
@reformatco
reformatco / wp-fn-topslug
Last active September 11, 2022 10:18
Top-Level Slug Function for Wordpress
function top_slug($post){
if(count($post->ancestors)>0){
/* if in a sub section */
$parent_permalink = get_permalink($post->ancestors[count($post->ancestors)-1]);
echo basename($parent_permalink);
}else{
$permalink = get_permalink($post->ID);
if($permalink===get_bloginfo('url')."/"){
/* if on home page */
@reformatco
reformatco / less-css3-buttons
Last active September 11, 2022 10:18
CSS3 Bevelled Button LESS Mixin
/* I am using classes from http://snipplr.com/view/47181/less-classes/ for border radius */
.css3button(
@bg : #666,
@border : 1px,
@border-rad : 0.3em
){
display:inline-block;
outline:none;
line-height:2em;
@reformatco
reformatco / gist:3852078
Created October 8, 2012 11:42
Freeagent Invoice LESS Styles
/* All templates seem to have 1cm padding, must be required */
#invoice {
padding:0 1cm 1cm 1cm;
font-size:9pt;
line-height:12pt;
}
#invoice-header {
.logo {
@reformatco
reformatco / gist:3865249
Created October 10, 2012 12:19
Fix Scissors Cropping in Wordpress
// scissors.php in Scissors Continued
// Source: http://wordpress.org/support/topic/plugin-scissors-continued-custom-image-sizes-arent-handled
function scissors_admin_head()
{
if(strstr($_SERVER['REQUEST_URI'], 'media'))
{
global $scissors_dirname, $_wp_additional_image_sizes;
wp_enqueue_script('scissors_crop', '/' . PLUGINDIR . '/'.$scissors_dirname.'/js/jquery.Jcrop.js', array('jquery') );
@reformatco
reformatco / 1_Instructions.md
Created November 29, 2012 00:19 — forked from Daniel15/1_Twitter autoresponder bot.md
Twitter autoresponder bot

Twitter autoresponder bot

By Daniel15 (dan.cx) This is a very simple Twitter autoresponder bot. It requires PECL OAuth extension to be installed (run "pecl install oauth", or if on Windows, grab php-oauth.dll. If using cPanel you can install it via WHM). The authentication is designed for command-line usage, it won't work too well via a web browser. You'll have to sign up for an application on Twitter's site to get the consumer key and secret.

Could be modified to be more advanced (match regular expressions to answer questions, etc.)

@reformatco
reformatco / gist:5813218
Created June 19, 2013 10:08
Menu Fix for Custom Post Type
// Menu Fix for CPT
function remove_parent($var)
{
// check for current page values, return false if they exist.
if ($var == 'current_page_item' || $var == 'current_page_parent' || $var == 'current_page_ancestor' || $var == 'current-menu-item') { return false; }
return true;
}
function add_class_to_cpt_menu($classes)
@reformatco
reformatco / gist:6607771
Last active December 23, 2015 08:29
LESS Base Styles for Gravity Form CSS
.gform_wrapper {
}
.gform_body {
}
.gform_fields {
list-style-type:none;
@reformatco
reformatco / gridsome.config.js
Created March 29, 2019 11:48
Adding postcss plugins to Gridsome
module.exports = {
siteName: 'Example',
chainWebpack: config => {
config.module
.rule('postcss')
.oneOf('normal')
.use('postcss-loader')
.tap(options => {
options.plugins.unshift(...[
require('rucksack-css'),
@reformatco
reformatco / remove-tec-filters.php
Created September 29, 2023 13:45
Allow past events custom query with The Events Calendar
// You can save original $wp_filter
remove_action('parse_query', 'Tribe__Events__Query::parse_query', 50);
remove_action('parse_query', 'Tribe__Events__Query::filter_and_order_by_date', 1000);
// Run your query
$query = new WP Query()
// Reinstate the parse_query filters here in case you need it later on