Skip to content

Instantly share code, notes, and snippets.

@wvega
wvega / add-order-note-date-to-order-notes-column-in-csv-exports.php
Created May 2, 2020 01:15
Add order note date to order_notes column in CSV exports generated with WooCommerce Customers Orders Coupons Export
<?php // only copy this line if needed
/**
* Adds the order note date to the notes in the order notes column of CSV exports.
*/
/**
* Adds the order note date to the notes in the order notes column of CSV exports.
*
@wvega
wvega / wptranslationday.md
Created May 2, 2019 13:30
Descripción para el evento de traducción de WordPress

¡Reunámonos para traducir WordPress!

Haz parte de un evento global de 24 horas que incluirá un evento transmitido en línea y multiples meetups en diferentes ubicaciones en todas partes del mundo.

No es necesario tener experiencia haciendo traducciones para WordPress. La traducción se hacer generalmente a partir del texto que está disponible en Inglés (E.E.U.U).

En este evento:

  • Te ayudaremos a empezar a traducir plugins, temas y otros proyectos de WordPress.
  • Compartiremos trucos y consejos para realizar mejores traducciones.
@wvega
wvega / attendees.js
Last active February 10, 2019 16:35
Extract Meetup member information from event's Attendees page
Array.prototype.slice.apply(document.getElementsByClassName('member-item')).map((attendee) => {
return attendee.querySelector('a').href.replace('https://www.meetup.com/WordPressMedellin/members/', '').replace('/', '') + "," + attendee.querySelector('h4').innerText
}).join("\n")
@wvega
wvega / wvega-850-eventbrite-api-workarounds.php
Created December 19, 2016 16:11
Workarounds to make Eventbrite API WordPress plugin work on 32bit systems
<?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
@wvega
wvega / fix-hidden-files-memory-stick.sh
Created October 3, 2016 21:18
Oneliner used to remove the hidden flag from files and directories in the current directory
ls -lO | grep hidden | tr -s " " | cut -d " " -f 10- | awk '{ system(sprintf("chflags nohidden \"%s\"", $0)) }'
@wvega
wvega / wp-debug-util.php
Last active April 7, 2018 11:23
Utility functions for debugging WordPress websites
<?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] ) ) {
@wvega
wvega / jquery.timepicker-1.3.2-custom.min.js
Created May 11, 2016 04:18
A modified version of jQuery Timepicker 1.3.2 (See issue #50)
/**
* 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
@wvega
wvega / custom-meta-query.php
Created March 17, 2016 01:10
Code used to create SQL clauses for meta queries using custom tables (Draft)
<?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'] );
@wvega
wvega / snippet-from-class-freemius.php
Created December 7, 2015 22:38
Alternative implementation for _find_caller_plugin_file() (2nd Attempt).
<?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 ) {
<?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/' ) ) {