Instantly share code, notes, and snippets.

View wvega-850-eventbrite-api-workarounds.php
<?php
// Additions to main functions.php file - eventbrite 32bit php problems - referenced from http://wvega.com/850/getting-eventbrite-api-wordpress-plugin-to-work-on-systems-with-32-bit-builds-of-php/
function wvega_850_filter_event_permalink( $url ) { // eg. http://mysite.com/events/july-test-drive-11829569561
if ( function_exists( 'eventbrite_is_event' ) && eventbrite_is_event() ) {
$url = sprintf( '%1$s/%2$s/%3$s-%4$s/',
esc_url( home_url() ), // protocol://domain
sanitize_title( get_queried_object()->post_name ), // page-with-eventbrite-template
sanitize_title( get_post()->post_title ), // event-title
View fix-hidden-files-memory-stick.sh
ls -lO | grep hidden | tr -s " " | cut -d " " -f 10- | awk '{ system(sprintf("chflags nohidden \"%s\"", $0)) }'
View wp-debug-util.php
<?php
function wp_debug_util_get_hook_handlers( $hook_name ) {
global $wp_filter;
$hook_handlers = array();
foreach ( $wp_filter[ $hook_name ] as $priority => $handlers ) {
foreach ( $handlers as $handler ) {
if ( is_array( $handler['function'] ) && is_callable( $handler['function'] ) && is_object( $handler['function'][0] ) ) {
View jquery.timepicker-1.3.2-custom.min.js
/**
* jQuery Timepicker - v1.3.2 - 2016-05-10
* http://timepicker.co
*
* Enhances standard form input fields helping users to select (or type) times.
*
* Copyright (c) 2016 Willington Vega; Licensed MIT, GPL
*/
"undefined"!=typeof jQuery&&!function(a,b){function c(a,b,c){return new Array(c+1-a.length).join(b)+a}function d(){if(1===arguments.length){var b=arguments[0];return"string"==typeof b&&(b=a.fn.timepicker.parseTime(b)),new Date(0,0,0,b.getHours(),b.getMinutes(),b.getSeconds())}return 3===arguments.length?new Date(0,0,0,arguments[0],arguments[1],arguments[2]):2===arguments.length?new Date(0,0,0,arguments[0],arguments[1],0):new Date(0,0,0)}a.TimePicker=function(){var b=this;b.container=a(".ui-timepicker-container"),b.ui=b.container.find(".ui-timepicker"),0===b.container.length&&(b.container=a("<div></div>").addClass("ui-timepicker-container").addClass("ui-timepicker-hidden ui-helper-hidden").appendTo("body").hide(),b.ui=a("<div></div>").addClass("ui-timepicker").addClass("ui-widget ui-widget-conte
View custom-meta-query.php
<?php
$regions_query = new WP_Meta_Query( $query_object->query['_regions_query'] );
$regions_clauses = $regions_query->get_sql( 'post', $this->db->posts, 'ID', $query_object );
$regions_clauses['join'] = str_replace( $this->db->postmeta, AWPCP_TABLE_AD_REGIONS, $regions_clauses['join'] );
$regions_clauses['join'] = preg_replace( "/mt(\d+)/", 'listing_regions\1', $regions_clauses['join'] );
$regions_clauses['join'] = str_replace( 'post_id', 'ad_id', $regions_clauses['join'] );
$regions_clauses['where'] = str_replace( $this->db->postmeta, AWPCP_TABLE_AD_REGIONS, $regions_clauses['where'] );
View snippet-from-class-freemius.php
<?php
private function _find_caller_plugin_file() {
$bt = debug_backtrace();
$backtrace_entries_count = count( $bt );
$active_plugins = get_option( 'active_plugins' );
$active_plugins_paths = array();
$plugin_file = null;
foreach ( $active_plugins as $i => $relative_path ) {
View snippet-from-class-freemius.php
<?php
private function _find_caller_plugin_file() {
$bt = debug_backtrace();
$abs_path_lenght = strlen( ABSPATH );
$backtrace_entries_count = count( $bt );
$plugin_file = null;
for ( $i = 1; $i < $backtrace_entries_count; $i++ ) {
if ( false !== strpos( substr( fs_normalize_path( $bt[ $i ]['file'] ), $abs_path_lenght ), '/freemius/' ) ) {
View data-to-binary-string.py
import struct
def data_to_binary_string(input_filename):
binary_string = ''
file = open(input_filename, 'rb')
bytes = file.read(1024)
while len(bytes):
binary_string = binary_string + ''.join(['{0:0>8b}'.format(ord(b)) for b in bytes])
View 0001-Use-Pippin-s-WP_Session-in-AWPCP.patch
From 6557efdb0d8c840614706e9f6cb1921128bed363 Mon Sep 17 00:00:00 2001
From: Willington Vega <wvega@wvega.com>
Date: Fri, 12 Jun 2015 19:51:26 -0500
Subject: [PATCH] Use Pippin's WP_Session in AWPCP.
https://pippinsplugins.com/storing-session-data-in-wordpress-without-_session/
---
another-wordpress-classifieds-plugin/awpcp.php | 9 +-
.../includes/sessions/class-session-manager.php | 178 ++++++++++++++++
.../includes/sessions/class-session.php | 119 +++++++++++
View customization-guide.md

AWPCP Customization Guide

Introduction

This document describes the general layout of the Another WordPress Classifieds Plugin directory as well as the contents of most of the files and directories inside. The instructions provided here assume that you are an expert in PHP coding, understand HTML very well, and are comfortable with the WordPress PHP API. If you feel that your skills aren’t up to par in these areas, you should consider hiring help for your project on a forum such as Upwork.

CUSTOMIZATION WARNING: Beyond the help provided here, customizations to the plugin are something that you do on your own and without further support from the AWPCP team. We can’t provide support on any custom changes you make to the plugin—you must be comfortable in debugging techniques and tools to find and fix issues on your own. Any bugs you find in the plugin must be reproducible with the core, unmodified plugin in order to be considered issues we can address.

Before altering plugin files