Skip to content

Instantly share code, notes, and snippets.

View hadamlenz's full-sized avatar

H. Adam Lenz hadamlenz

  • UNC Chapel Hill
  • Durham, NC.
View GitHub Profile
<?php
/**
* Given an array of members looks for $width_param and tries to figure out the columns widths for all members
* will return equal parts if all members do not have $width_param set
* will fill in the blank if one is set and another is not
* returns false if $members is not an array or is empty
*
* @param [array] $members
* @param [string] $breakpoint
* @param [string] $width_param
@hadamlenz
hadamlenz / class-SearchIQ.php
Last active September 28, 2018 19:57
proposed class for adding different taxonomies into the search tag interface on search iq
<?php
/**
* If this file is called directly, abort.
*/
if ( !defined( 'ABSPATH' ) ) {
die( 'Direct access is forbidden.' );
}
class SearchIQ{
@hadamlenz
hadamlenz / bu-navigation-external-links-get-pages.php
Created March 27, 2018 17:14
Uses BU Navigation(https://github.com/bu-ist/bu-navigation) if $args['add_bu_links'] = true when using get_pages or wp_list_pages, included the bu_links added in the "edit order' menu item.
@hadamlenz
hadamlenz / dont_send_tickets_for_specific_events.php
Last active November 27, 2017 21:51
Events Tickets Plus - Don't send tickets for specific events
<?php
function filter_send_tickets($send){
$dont_send_tickets = ["70"]; //the event IDs that you don't want to send tickets for
global $post;
$order = wc_get_order( $post->ID );
$items = $order->get_items();
$wootix = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();
$events = [];
foreach( $items as $item ){
$event = $wootix->get_event_for_ticket( $item->get_product_id() );
@hadamlenz
hadamlenz / add_products_to_tickets.php
Created October 20, 2017 19:40
Add a name your price product to an Event Ticket Plus Ticket group
<?php
//add this to wootickets/tickets.php
//add after the big foreach ( $tickets as $ticket )
//requires ACF to set a custom field that pulls the product you want to add with a post object field
//requires WooComerce Name Your Price plugin
if( 0 < count( get_field( 'add_products_to_tickets' ) ) ):
foreach( get_field( 'add_products_to_tickets' ) as $extra_product ):
$product = wc_get_product( $extra_product );
if( class_exists('WC_Name_Your_Price')){
/*
*create a new ease Easing ease
*instasiate the new ease ease = new Ease(start, end, steps, type)
*get the value from in draw from ease.step();
*
*ease types are in the switch case starting on line 29
*/
class Easing {
<?php
$search = new WP_Query( array(
's' => $qv,
'posts_per_page' => 30,
'paged' => $paged,
'post_status' => array( 'publish', 'future' )
));
$search->query_vars['searchblogs'] = '1,8,9,16,18';
relevanssi_do_query($search);
@hadamlenz
hadamlenz / WP_Inline_Diffing.php
Created December 8, 2016 14:18
Class to display inline diff using wordpress's native text diff engine
<?php
class wp_native_inline_diffing{
public function diffcheck($oldValue, $newValue){
if ( ! class_exists( 'WP_Text_Diff_Renderer_inline', false ) )
require( ABSPATH . WPINC . '/wp-diff.php' );
$renderer = new WP_Text_Diff_Renderer_inline();
$old_lines = explode( "\n", $oldValue );
$new_lines = explode( "\n", $newValue );
$text_diff = new Text_Diff( 'auto', array( $old_lines, $new_lines ) );
<?php
$moreargs = ['one','two']
add_filter('filtername',function($args) use($moreargs){
//do stuff with more args
})
<?php
/*
*a wordpress funtion for dumping in a <pre> and dying
*
*param any $thing the thing you want to var_dump
*param bool $die = should we wp_die or just echo
*/
function wp_predump($thing,$die=true){
$output = '<pre>';
ob_start();