Skip to content

Instantly share code, notes, and snippets.

View codearachnid's full-sized avatar
:octocat:
curiouser and curiouser

Timothy Wood codearachnid

:octocat:
curiouser and curiouser
View GitHub Profile
@codearachnid
codearachnid / Main.php
Last active November 21, 2015 11:29
Modern Tribe's The Event Calendar plugin edit event screen improvement.
<?php
/**
* Modern Tribe's The Event Calendar plugin would be much faster in the editing interface
* if it removed the upfront loading of organizers and venues from the select dropdown and
* relied on AJAX loading after initial page load. Additional improvement would be to drop
* the `get_the_title` method when displaying the venue and organizer titles in the list.
* This was tested on a production site with ~4500+ events. Average of 10 attempts time to
* load edit screen prior to modification 47.2 seconds with memory load 290.63mb and
* 18,968 queries. In contrast after modification 16.88 seconds with memory load 217.89mb
* and 155 queries.
<?php
// look at line 69 and change
$field = 'eventStart.meta_value';
// to
$field = 'tribe_event_start_date.meta_value';
/**********/
@codearachnid
codearachnid / filter_gf_select_optgroup.php
Last active November 10, 2025 09:01
Add the optgroup ability to Gravity Forms default select field.
<?php
/**
* Filter Gravity Forms select field display to wrap optgroups where defined
* USE:
* set the value of the select option to `optgroup` within the form editor. The
* filter will then automagically wrap the options following until the start of
* the next option group
*/
@codearachnid
codearachnid / app.js
Created July 1, 2015 20:29
Angular JS demo app
angular.module('SampleApp', ['ngRoute'])
.filter('filterByProperty', function(){
return function( items, propMatch ){
var filtered = [];
for (var i = 0; i < items.length; i++) {
var item = items[i];
for(var property in propMatch){
if (propMatch[property] == item[property]) {
@codearachnid
codearachnid / angular-filterByProperty.js
Created July 1, 2015 19:24
Needed a simple way to filter an array of object by a property
.filter('filterByProperty', function(){
return function( items, propMatch ){
var filtered = [];
for (var i = 0; i < items.length; i++) {
var item = items[i];
for(var property in propMatch){
if (propMatch[property] == item[property]) {
filtered.push(item);
}
}
@codearachnid
codearachnid / series-engine-embed-extend.php
Created May 27, 2015 10:02
A simple modification to implement filters for embed display within archive and ajax shortcodes for Series Engine.
<?php
/**
* implement a filter hook by replacing the original echo in
* serieslistings.php lines 621, 727
* ajaxlink.php lines 632, 746
*/
echo stripslashes($enmse_singlemessage->embed_code);
// with the new filter
@codearachnid
codearachnid / ping.php
Created January 28, 2015 18:04
Simple PHP ping request
<?php
function ping($host){
if(exec('echo EXEC') == 'EXEC'){
exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res, $rval);
} elseif( function_exists('fsocketopen') ){
$port = 80;
$timeout= 6;
$fsock = fsockopen($host, $port, $errno, $errstr, $timeout);
if ( ! $fsock ){
@codearachnid
codearachnid / gform_field_value.php
Created January 26, 2015 00:04
Populate a gravity forms field for a currently logged in user
<?php
add_filter( 'gform_field_value_user_name', 'my_custom_gform_field_user_name' );
function my_custom_gform_field_user_name( $value ){
$current_user = wp_get_current_user();
if ( 0 != $current_user->ID ) {
$value = $current_user->display_name;
}
return $value;
@codearachnid
codearachnid / remove_query_strings.php
Created January 12, 2015 03:02
WordPress automatically adds query strings to enqueued static resources like stylesheets and scripts. This shall remove them on production sites.
<?php
/**
* WordPress automatically adds query strings to enqueued static resources like stylesheets and scripts.
* This is meant for caching reasons (e.g. if a script version changes,
* it should prevent the client to use a cached copy of the old one).
* However, this feature can be omitted to improve site performance.
*/
function remove_query_strings_questionmark( $src ){
@codearachnid
codearachnid / floatingsearch.html
Last active August 29, 2015 14:11
Floating Search
<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<div id="floatingSearchWrap">
<span class="lookup">
<input type="text" name="s" placeholder="Search..." />
<button class="clear">
<img src="search-delete.svg" alt="Click to clear search">