Skip to content

Instantly share code, notes, and snippets.

View Vheissu's full-sized avatar
💭
SURFING THE INTERNET

Dwayne Charrington Vheissu

💭
SURFING THE INTERNET
View GitHub Profile
@Vheissu
Vheissu / sidebar_helper.php
Created September 25, 2012 22:23
Dynamic Sidebar Functionality
// This version does a simple file include
// Like you would in your template view file
// Using the standard CI Views functionality
function get_sidebar($slug = '')
{
// No slug? Just get sidebar.php then
if ($slug == '')
{
include_once APPPATH.'views/sidebar.php';
}
@Vheissu
Vheissu / 960gs.less
Created October 9, 2012 23:10 — forked from Aeon/960gs.less
LessCSS and 960gs don't play well together normally. Here's the definitions for 960gs to let LessCSS work with it. Looks like we can pull all grid data out of the HTML.
/**
* A LessCSS version of the 960 Grid System
*
* All widths are using percentages making the grid
* responsive to most resolutions.
*
* http://lesscss.org/
* http://960.gs/
*/
@Vheissu
Vheissu / wordpress-auto-p.php
Created October 15, 2012 23:22
Wordpress Auto P Forked
function wpautop_forked($pee, $br = 1) {</code>
if ( trim($pee) === '' )
return '';
$pee = $pee . "\n"; // just to make things a little easier, pad the end
$pee = preg_replace('|
\s*
|', "\n\n", $pee);
// Space things out a little
$allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li
@Vheissu
Vheissu / functions.php
Created October 22, 2012 01:59
A simple Wordpress function for checking whether or not a page is using any custom page template
// A simple function for checking if a page is using a custom template
function using_page_template()
{
$templates = get_page_templates();
$result = FALSE;
foreach ($templates AS $template_name => $template_filename)
{
if ( is_page_template($template_filename) )
{
@Vheissu
Vheissu / functions.php
Created October 22, 2012 02:36
Bundling the Advanced Custom Fields plugin into a theme using the TGM Plugin Class
add_action( 'tgmpa_register', 'register_required_plugins' );
// This function is called from the above hook
function register_required_plugins()
{
// The plugins array allows us to define multiple plugins we want to include.
// The commented out example shows how we can include and activation a bundled
// plugin zip file in our theme.
$plugins = array(
/* array(
@Vheissu
Vheissu / gist:4063547
Created November 13, 2012 02:15
Wordpress has a nasty and annoyingly known bug that prevents paginated custom post type pages from abiding by a set posts_per_page value, this sets it straight. Replace the post type value of "project" with your own custom post type name, you can add OR c
/**
* Wordpress has a known bug with the posts_per_page value and overriding it using
* query_posts. The result is that although the number of allowed posts_per_page
* is abided by on the first page, subsequent pages give a 404 error and act as if
* there are no more custom post type posts to show and thus gives a 404 error.
*
* This fix is a nicer alternative to setting the blog pages show at most value in the
* WP Admin reading options screen to a low value like 1.
*
*/
@Vheissu
Vheissu / functions.php
Last active December 13, 2015 21:08
Will allow you to display descriptions in the Wordpress Theme Customisation API settings sections.
add_action('customize_controls_print_footer_scripts', function() {
?>
<script type="text/javascript">
(function($, window) {
$(document).ready(function() {
var $customisationOptions = $("#customize-theme-controls");
@Vheissu
Vheissu / functions.php
Created February 20, 2013 06:04
Creates a 404 page so you can have a custom editable 404 page in Wordpress
// Ensures this function is only called after the theme is setup
// You could bind to the "init" event if "after_setup_theme" doesn't work well for you.
add_action('after_setup_theme', 'create_404_page');
// Insert a privately published page we can query for our 404 page
function create_404_page() {
// Check if the 404 page exists
$page_exists = get_page_by_title( '404' );
@Vheissu
Vheissu / 404.php
Last active December 13, 2015 23:39
Custom 404 page template for displaying a custom editable Wordpress 404 page.
<?php get_header(); ?>
<?php
$the_page = null;
$errorpageid = get_option( '404pageid', 0 );
if ($errorpageid !== 0) {
// Typecast to an integer
$errorpageid = (int) $errorpageid;
@Vheissu
Vheissu / .htaccess
Created February 20, 2013 23:33
W3 Total Cache .htaccess rules for caching
# BEGIN W3TC Browser Cache
<IfModule mod_mime.c>
AddType text/css .css
AddType text/x-component .htc
AddType application/x-javascript .js
AddType application/javascript .js2
AddType text/javascript .js3
AddType text/x-js .js4
AddType text/html .html .htm
AddType text/richtext .rtf .rtx