Skip to content

Instantly share code, notes, and snippets.

View codearachnid's full-sized avatar
🎯
Focusing

Timothy Wood codearachnid

🎯
Focusing
View GitHub Profile
$0=10
$1=255
$2=0
$3=3
$4=0
$5=0
$6=0
$10=115
$11=0.020
$12=0.002
SELECT t1.entity_id, t2.post_id, t2.post_title, t1.value, t3.address, t3.street, t3.city, t3.state, t3.zip, t4.phone, t4.mobile, t4.fax, t4.email, t4.website
FROM wp_sabai_entity_field_content_body as t1
LEFT JOIN wp_sabai_content_post as t2
ON t1.entity_id = t2.post_id
LEFT JOIN wp_sabai_entity_field_directory_location as t3
ON t1.entity_id = t3.entity_id
LEFT JOIN wp_sabai_entity_field_directory_contact as t4
ON t1.entity_id = t4.entity_id
WHERE t2.post_entity_bundle_name = 'campfinder_listing'
AND t2.post_status = 'published'
@codearachnid
codearachnid / ajax-actions.php
Created November 8, 2018 18:06
Fix date format for export convertplus
<?php
// convertplus/admin/ajax-actions.php
// line 3133
/*** RFM DATE ADJUST ***/
foreach($contacts as $key => $contact){
$contact['date'] = date("Y-m-d", strtotime($contact['date']));
$contacts[$key] = $contact;
}
@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, 2023 10:46
Add the optgroup ability to Gravity Forms default select field.
/**
* 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
*/
add_filter( 'gform_field_content', 'filter_gf_select_optgroup', 10, 2 );
function filter_gf_select_optgroup( $input, $field ) {
@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 ){