Skip to content

Instantly share code, notes, and snippets.

View ontiuk's full-sized avatar

Stephen Betley ontiuk

View GitHub Profile
@ontiuk
ontiuk / wordpress_get_terms_args.txt
Last active December 28, 2016 13:09
WordPress: Filter get_terms via get_terms_args
add_filter( 'get_terms_args', 'filter_term_args', 10, 2 );
/** 
* Filter get_terms args 
* - within term edit page 
*/
function filter_term_args( $args, $taxonomies ) {   
global $wpdb, $pagenow;    
@ontiuk
ontiuk / wordpress-taxonomy-get-terms
Created December 28, 2016 12:58
WordPress: Taxononomy term filtering with get_terms
add_filter( 'get_terms', 'filter_get_terms', 10, 2 );
/** 
* Enable drilldown in term meta column 
* - Requires the meta column value to be wrapped in a link with '&meta_field_name=meta_field_value' 
* - urlencode meta field value & sanitize input 
*/
function filter_get_terms( $terms, $taxonomy ) {   
global $wpdb, $pagenow;
@ontiuk
ontiuk / wordpress_terms_clauses_sorting.txt
Created December 28, 2016 12:08
WordPress: Taxonomy Meta Sorting With Terms_Clauses Filter
add_filter( 'terms_clauses', 'filter_terms_clauses', 10, 3 );
/** 
* Filter WP_Term_Query meta query 
* @param   object  $query  WP_Term_Query 
* @return  object 
*/
function filter_terms_clauses( $pieces, $taxonomies, $args ) {
global $pagenow, $wpdb;    
@ontiuk
ontiuk / char_type_js.txt
Last active August 20, 2016 13:37
Get case / type of a string's character by position in Javascript
<script>
function charType(chr, pos) {
pos = (pos === undefined) ? 0 : parseInt(pos);
var ret = "O";
var code = chr.charCodeAt(pos);
if (code >= "A".charCodeAt(0) && code <= "Z".charCodeAt(0)) {
return "U";
@ontiuk
ontiuk / mysql_command_line_dump.tst
Last active August 20, 2016 13:38
MySQL Command Line Dump: mysqldump
/* Command Line: Dump Table Contents. One insert per line */
mysqldump --complete-insert --lock-all-tables --no-create-db
--no-create-info --skip-extended-insert --password=XXX -u XXX
--dump-date dump_table_name > dump_table_data.sql
/* Command Line: Dump Table Contents. One insert per line. Root SSH no pwd */
mysqldump --complete-insert --lock-all-tables --no-create-db
--no-create-info --skip-extended-insert --dump-date dump_table_name > dump_table_data.sql
/* Command Line: Dump Table Contents & Structure. One insert per line. Root SSH no pwd */
@ontiuk
ontiuk / woocommerce_wcvendors_product_post_type_labels.txt
Last active August 20, 2016 13:46
Woocommerce & WCVendors Integration: Product post-type labels
<?php
/**
* Product Post Type Labels. Wrap around admin labels for product post type.
* Integrated with check for vendor, so applies to vendor only in WP Admin UI
*/
final class Theme_Product_Labels {
/**
@ontiuk
ontiuk / woocommerce_wcvendors_woobookings_bookings_post_list.txt
Last active August 20, 2016 13:47
Woocommerce and VCVendors integration: Bookings Post List
/**
* Sets filtering of bookings per vendor.
*/
// Bookings Post Listing. Restrict to current user as author
function riv_vendor_bookings_where( $where, $q ) {
global $current_user, $wpdb;
// test the page