Skip to content

Instantly share code, notes, and snippets.

@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' => '!='
),
),
@hereswhatidid
hereswhatidid / localize-bootstrap.less
Created February 16, 2014 16:17
Localize Bootstrap to a container element (pre 3.0)
.bootstrap-wrapper {
@import url( '../vendor/bootstrap/bootstrap.less' );
}
@hereswhatidid
hereswhatidid / localize-bootstrap.less
Last active September 19, 2015 05:38
Localize Bootstrap 3+ styles to a container div.
.bootstrap-wrapper {
@import (less) url( '../vendor/bootstrap/bootstrap.css' );
}
@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 : '';
}
@hereswhatidid
hereswhatidid / archive-commit.bat
Last active November 25, 2022 03:55
Create a zip archive of a specific commit. The archive will be named deploy/deploy-COMMITID.zip.
setlocal enabledelayedexpansion
set var=%1
set output=
for /f "delims=" %%a in ('git diff-tree --no-commit-id --name-only -r %1^^') do ( set output=!output! "%%a" )
git archive -o update-%var:~0,7%.zip HEAD %output%
endlocal
@hereswhatidid
hereswhatidid / archive-of-single-commit.git
Created February 7, 2014 21:29
Create an archive of files modified within the given commit.
git archive -o update.zip HEAD $(git diff --name-only COMMITIDHERE^)
@hereswhatidid
hereswhatidid / create-file-archive.sh
Last active July 18, 2019 19:08
Puts the modified files in an archive using git
git archive -o update.zip HEAD $(git diff --name-only 8de5622^)
@hereswhatidid
hereswhatidid / lastfour-and-type.php
Last active January 4, 2016 03:28
Get the last four digits and card type from an Offline Credit Card order in PrestaShop.
<?php
protected function getCardType( $ccNum ) {
if (preg_match("/^5[1-5][0-9]{14}$/", $ccNum))
return "Mastercard";
if (preg_match("/^4[0-9]{12}([0-9]{3})?$/", $ccNum))
return "Visa";
if (preg_match("/^3[47][0-9]{13}$/", $ccNum))
return "American Express";
@hereswhatidid
hereswhatidid / grouped-viewmodel.js
Last active June 24, 2019 06:15
Knockout extender to group the results of an observable array.
var ViewModel = function( data ) {
this.observableArrayObject = ko.observableArray( data.items ).extend( { 'grouped': 4 } );
};