Skip to content

Instantly share code, notes, and snippets.

View rosswintle's full-sized avatar

Ross Wintle rosswintle

View GitHub Profile
@rosswintle
rosswintle / README.standard.md
Last active August 29, 2015 14:00
Standard README for collaborative web projects

PROJECT NAME

a Project - http://url.co.uk

Last Updated: DD/MM/YYYY

Contents:

  1. Purpose of this file
  2. Authors/contributors
@rosswintle
rosswintle / class_oikos_custom_columns.php
Created January 16, 2015 16:31
WordPress Custom Columns helper
<?php
/*
* WordPress Custom Columns helper
*
* NOTE: The callback function should echo the output. Use global $post to get the post that's
* being displayed in the list.
*
* Example usage:
*
@rosswintle
rosswintle / gist:60152c844a4f8aa1f773
Last active September 8, 2015 15:06
Set default hidden meta boxes and meta box order for users in WordPress
<?php
/*
* This filter specifies default orderings for meta boxes on article screens.
*
* If a user-specific setting exists for the hidden/order list then that is used
*
* The get_<objecttype>_metadata filter is odd. It's always passed "null" as a value. If
* we return a non-null value then that value is used. If we return null, it will fetch the
* real value. Watch out for that!
*/
@rosswintle
rosswintle / gist:6899635
Created October 9, 2013 11:12
Code to do a WordPress query for posts that start with a given letter. Assumes a letter has been passed in the URL as "?s=a" where a is the letter. This code is part of some code that handles ajax requests. You'll need to write mytheme_ajax_list() to run a proper query and/or return results somehow.
// AJAX function for listing directory entries alphabetically
add_action('wp_ajax_directory_alpha', 'mytheme_ajax_directory_alpha');
add_action('wp_ajax_nopriv_directory_alpha', 'mytheme_ajax_directory_alpha');
function mytheme_ajax_directory_alpha() {
function alpha_post_where( $where ) {
$new_where = $where . " AND lower(substring(post_title, 1, 1)) = lower('" . $_REQUEST['s'] . "')";
return $new_where;
}
@rosswintle
rosswintle / _grid.scss
Created December 31, 2015 23:40
Sage _grid.scss for use when using optional full-width templates.
// Grid system - do not apply to full-width-wrapped pages
.wrap.container .main {
@include make-sm-column($main-sm-columns);
.sidebar-primary & {
@include make-sm-column($main-sm-columns - $sidebar-sm-columns);
}
}
.sidebar {
@include make-sm-column($sidebar-sm-columns);
}
@rosswintle
rosswintle / add_category_description_to_content.php
Last active February 25, 2016 17:13
WordPress plugin to add category description to end of the_content
<?php
/*
Plugin Name: Add category description to content
Plugin URI: https://oikos.digital/
Description: Adds the category description to the end of the_content()
Version: 1.0
Author: Ross Wintle/Oikos
Author URI: https://oikos.digital/
*/
@rosswintle
rosswintle / more-post.php
Created July 13, 2016 15:09
Tiny plugin to create a WordPress [more-post] shortcode. This is replaced by a button that loads the content within the shortcode.
<?php
/**
* Plugin Name: More Post - A Dynamic More Post loader
* Version: 0.1-alpha
* Description: A Dynamic More Post loader
* Author: Ross Wintle
* Author URI: http://oikos.digital
* Plugin URI: PLUGIN SITE HERE
* Text Domain: more-post
* Domain Path: /languages
@rosswintle
rosswintle / domain_info.php
Last active September 23, 2016 00:50
Domain Info script - attempts to give you registrar nameservers, basic DNS, actual hostname hosting the domain and MX records
<?php
/*
* This needs comments and command-line arguments and stuff. It's ruff and ready.
*/
global $domain_re;
$domain_re = '([0-9a-zA-Z\-]+\.)+[0-9a-zA-Z\-]+';
function get_nameservers( $whois_out, $domain ) {
@rosswintle
rosswintle / gist:6635876
Created September 20, 2013 10:52
Code to convert Gravity Forms file uploads to media items and attach to a post.
/*
* There are a couple of places where we use GravityForms to do a file upload into a
* meta-data item of type "upload". The upload file type stores an attachment ID,
* whereas the Gravity Forms upload field stores a URL.
*
* This function is used to convert a URL in the meta-data item specified by the
* $field parameter to an attachment ID - creating the attachment as it goes.
*
* This function should be called from a callback hooked to gform_after_submission_[x]
*
@rosswintle
rosswintle / edit-divi-footer.php
Last active October 8, 2017 20:49
Edit Divi Footer plugin