Skip to content

Instantly share code, notes, and snippets.

@brentonstrine
brentonstrine / css-compress.php
Last active January 23, 2026 20:30 — forked from manastungare/css-compress.php
Fix space removal so that it doesn't break space-separated values where the developer used more than one space to separate values.
<?php
/**
* On-the-fly CSS Compression
* Copyright (c) 2009 and onwards, Manas Tungare.
* Creative Commons Attribution, Share-Alike.
*
* In order to minimize the number and size of HTTP requests for CSS content,
* this script combines multiple CSS files into a single file and compresses
* it on-the-fly.
*
<?php
/**
*
* cURL and XML parsing.
*
*/
$url = "http://www.w3schools.com/xml/simple.xml";
$ch = curl_init();
@BFTrick
BFTrick / install-wp.sh
Last active March 18, 2026 07:20
Download & Install WordPress via Curl
curl -O https://wordpress.org/latest.zip
unzip latest.zip
mv wordpress site
rm latest.zip
@hereswhatidid
hereswhatidid / query-user-firstname.php
Last active August 29, 2015 13:56
WP_User_Query meta parameters for first name
<?php
$args = array(
'role' => 'Administrator',
'meta_query' => array(
array(
'key' => 'first_name',
'value' => '',
'compare' => '!='
),
),
@NateWr
NateWr / socicons.css
Created February 17, 2014 17:41
Social media navigation menus in WordPress with Socicons
/**
* Turn links in a WordPress menu into icons linked to social profiles
*
* This file implements the social menu icons technique by Justin Tadlock for
* the Socicon font, which supports a very large number of social network sites.
*
* Learn how to set up a social menu from Justin here:
*
* http://justintadlock.com/archives/2013/08/07/social-media-nav-menus
*
@hereswhatidid
hereswhatidid / get-wordpress.bat
Created February 15, 2014 05:30
Windows batch file for getting the latest WordPress core files
wget64 http://wordpress.org/latest.tar.gz
7z e latest.tar.gz & 7z x latest.tar
robocopy wordpress ./ /MOVE /E
del latest.tar
del latest.tar.gz
ren wp-config-sample.php wp-config.php
@hereswhatidid
hereswhatidid / clean-walker.php
Last active February 5, 2021 16:14
WordPress nav walker that strips the WP generated styles and IDs from the generated output.
<?php
class Clean_Walker_Nav extends Walker_Nav_Menu {
/**
* Filter used to remove built in WordPress-generated classes
* @param mixed $var The array item to verify
* @return boolean Whether or not the item matches the filter
*/
function filter_builtin_classes( $var ) {
return ( FALSE === strpos( $var, 'item' ) ) ? $var : '';
}
// add new field under gallery post format forms ui
add_action( 'vp_pfui_after_gallery_meta', 'mytheme_add_gallery_type_field' );
// handle the saving of our new field
add_action( 'admin_init' , 'mytheme_admin_init' );
function mytheme_admin_init() {
$post_formats = get_theme_support('post-formats');
if (!empty($post_formats[0]) && is_array($post_formats[0])) {
if (in_array('gallery', $post_formats[0])) {
@retgef
retgef / psuedo-static-js.php
Last active April 7, 2017 22:00
Add a pseudo static JS file to WordPress
<?php
#Add a query var to sniff requests
add_filter( 'query_vars', 'my_query_var_callback', 10, 1 );
function my_query_var_callback( $vars ){
$vars[] = 'dynamic_js';
return $vars;
}
#Dynamic JavaScript
add_rewrite_rule( '^assets/js/dynamic\.js$', 'index.php?dynamic_js=1', 'top' ); //Note the hidden query variable
@mgmartel
mgmartel / TimberRedux.php
Last active December 30, 2015 17:49
Use Redux Framework with Timber (and, optionally, WPML).
<?php
/**
* Use Redux Framework with Timber
*
* Use this class like you would Redux Framework. All options are automatically
* made available in your Timber template context (by default as 'options').
*
* Extra optional arguments in the $args array:
* - 'timber_context' (string) Name of the variable in template context.