Skip to content

Instantly share code, notes, and snippets.

View kjohnson's full-sized avatar

Kyle B. Johnson kjohnson

View GitHub Profile
@kjohnson
kjohnson / CustomTab.php
Last active December 12, 2023 18:34
GiveWP Donor Dashboard Custom Tab
<?php
namespace App;
class CustomTab extends \Give\DonorDashboards\Tabs\Contracts\Tab
{
public static function id() {
return 'custom-tab';
}
@kjohnson
kjohnson / query.php
Last active October 20, 2023 03:38
Query WooCommerce Subscriptions with Next Payment and Last Payment
<?php
global $wpdb;
return "
SELECT
ShopOrder.ID as order_id,
ShopOrder.post_parent as parent_id,
ShopOrder.post_date,
ShopOrder.post_status,
@kjohnson
kjohnson / example.js
Created May 31, 2023 12:45
REGEX for WordPress i18n functions in JavaScript
/* Generated using ChatGPT
const jsCode = `
function exampleFunction() {
// Some code here
}
const translatedText = __("Hello, world!");
const translatedText2 = _x("Hello", "Greeting");
const translatedText3 = _n("One item", "%d items", 5);
@kjohnson
kjohnson / regex.txt
Created March 15, 2023 14:47
Spatie Ray remove debuggin REGEX
// `\b`: Word Boundary
\b(ray\(.*\));
@kjohnson
kjohnson / 60aa88243a93dda825b2fbb78e8ffca4191b8c76.patch
Created May 15, 2021 18:24
ninja-forms-60aa88243a93dda825b2fbb78e8ffca4191b8c76
commit 60aa88243a93dda825b2fbb78e8ffca4191b8c76
Author: Jörn Lund <[email protected]>
Date: Wed Nov 13 17:10:34 2013 +0100
Make CSV format filterable
Added filters `ninja_forms_csv_bom`, `ninja_forms_csv_delimiter`, `ninja_forms_csv_enclosure` and `ninja_forms_csv_terminator`.
diff --git a/includes/admin/export-subs.php b/includes/admin/export-subs.php
index fec5ec95..ee5a3723 100644
'give_fields_before_donation_levels',
'give_fields_after_donation_amount',
'give_fields_after_donation_levels',
'give_fields_payment_mode_top',
'give_fields_payment_mode_before_gateways',
'give_fields_payment_mode_after_gateways',
'give_fields_payment_mode_after_gateways_wrap',
'give_fields_payment_mode_bottom',
'give_fields_donation_form',
'give_fields_purchase_form_top',
@kjohnson
kjohnson / wordpress.test.conf
Created February 23, 2021 15:27
WordPress on Apache over HTTPS with pretty permalinks
# /etc/apache2/sites-available/wordpress.test.conf
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
function wordpress() {
cd ~/WordPress
}
function wpdebug() {
pwd=$PWD
cd ~/WordPress
wp config set WP_DEBUG $1 --raw
cd "$pwd"
}
@kjohnson
kjohnson / .bash_aliases
Last active October 28, 2020 20:00 — forked from joshlevinson/.bash_profile
WP CLI + Xdebug
function wpx {
export XDEBUG_CONFIG="idekey=WPCLIDEBUG remote_connect_back=1"
wp "$@"
unset XDEBUG_CONFIG
};
@kjohnson
kjohnson / gist:ddd59433f2bdaa8be62e9a9c77f2cccd
Last active September 16, 2020 17:41
Sprintf vs Interpolation
<?php
// Formatted string.
echo sprintf( 'This is a known %s being translated.', __( 'Translated String' ) );
// Interpolation
extract([
'string' => __( 'Translated String' )
]);
echo "This is a user provided ${string}";