Skip to content

Instantly share code, notes, and snippets.

View robwent's full-sized avatar
💭
Doing 'stuff'

Robert Went robwent

💭
Doing 'stuff'
View GitHub Profile
@mattboon
mattboon / gist:1275191
Created October 10, 2011 12:32
WordPress - Query Custom Post Type and taxonomy term by ID
<?php
// gets the ID from a custom field to show posts on a specific page
$buildType = get_post_meta($post->ID, 'build_type_id', true);
// run query
query_posts(array(
'post_type' => 'portfolio',
'showposts' => -1,
'tax_query' => array(
array(
@mattboon
mattboon / gist:4202188
Created December 4, 2012 09:34
WordPress - Split content above and below <!--more--> tag
<?php
$morestring = '<!--more-->';
$explode_content = explode( $morestring, $post->post_content );
$content_before = apply_filters( 'the_content', $explode_content[0] );
$content_after = apply_filters( 'the_content', $explode_content[1] );
?>
@jonahvsweb
jonahvsweb / web.config
Created April 29, 2013 03:38
How to Setup WordPress Permalinks on Windows IIS ======================================= Place this file into the base directory of your WordPress installation to allow permalinks (or "pretty URLs") on Windows IIS.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
@bmarston
bmarston / InitialDbMigrationCommand.php
Created May 8, 2013 16:23
Let's say you're starting a new Yii project and you've already created the database schema for it using something like phpMyAdmin or MySQL Workbench. Now you want to create an initial database migration so you can put the schema under version control, but you don't want to manually write the Yii code to create the tables, indexes, and foreign ke…
<?php
class InitialDbMigrationCommand extends CConsoleCommand
{
public function run($args) {
$schema = $args[0];
$tables = Yii::app()->db->schema->getTables($schema);
$addForeignKeys = '';
$dropForeignKeys = '';
@paulirish
paulirish / gist:5558557
Last active April 18, 2024 14:32
a brief history of detecting local storage

A timeline of the last four years of detecting good old window.localStorage.


Jan Lenhart, bless his heart contributed the first patch for support:

October 2009: 5059daa

@AmyStephen
AmyStephen / ProcessInput.php
Created July 11, 2013 00:23
System Plugin - onBeforeCompileHead - you can walk through any assets for the head. Where the head is rendered https://github.com/joomla/joomla-cms/blob/9c576378b4809a245f6fcf18bdbbd00baa4f7ac2/libraries/joomla/document/html/renderer/head.php
<?php
public function onBeforeCompileHead()
{
$head = JFactory::getDocument()->getHeadData();
$styleSheets = $head['styleSheets'];
$newStyleSheets = array();
foreach ($styleSheets as $key => $value)
{
@cyakimov
cyakimov / gist:6456518
Created September 5, 2013 21:34
Allow apache user to exec a git pull command.

Change your PHP to run git via sudo

<?php `sudo git pull [email protected]:my-user/myrepo.git`; ?>

Then change your suoders to allow git to be run by the apache user:

nano /etc/sudoers

Add this to the EOF:

@DevinWalker
DevinWalker / woocommerce-optimize-scripts.php
Last active November 14, 2024 09:20
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@moneal
moneal / gist:9859180
Created March 29, 2014 18:03
Disable WordPress script concatenation.
/**
* Disable script concatenation.
* If WordPress's dashboard isn't loading styles from load-styles.php
* add this to wp-config.php to disable concatenation and load styles that
* don't have errors
*/
define( 'CONCATENATE_SCRIPTS', false );
@DevinWalker
DevinWalker / remove-rev-slider-metabox.php
Created May 14, 2014 20:32
This code removed the Revolution Slider metabox on pages, posts and CTPs
/**
* Remove Rev Slider Metabox
*/
if ( is_admin() ) {
function remove_revolution_slider_meta_boxes() {
remove_meta_box( 'mymetabox_revslider_0', 'page', 'normal' );
remove_meta_box( 'mymetabox_revslider_0', 'post', 'normal' );
remove_meta_box( 'mymetabox_revslider_0', 'YOUR_CUSTOM_POST_TYPE', 'normal' );
}