Skip to content

Instantly share code, notes, and snippets.

View itthinx's full-sized avatar
🏆

itthinx itthinx

🏆
View GitHub Profile
@itthinx
itthinx / foo.php
Created September 14, 2023 12:08
I am a minimalist plugin which logs 'I am Foo!' when the plugins_loaded action fires.
<?php
/**
* Plugin Name: Foo
* Description: I am a minimalist plugin which logs 'I am Foo!' when the plugins_loaded action fires.
*/
if ( !defined( 'ABSPATH' ) ) {
exit;
}
@itthinx
itthinx / functions.php
Last active November 2, 2021 09:07
An example of using the decent_comments_comment_output filter to customize output
<?php
//
// An example filter implementation provided in response to this question on the Decent Comments plugin for WordPress
//
// https://wordpress.org/plugins/decent-comments/
//
// https://www.itthinx.com/plugins/decent-comments/comment-page-3/#comment-1127674
//
function my_decent_comments_comment_output( $output, $comment_ID, $options ) {
$comment = get_comment( $comment_ID );
// An example wp_mail() override that you can place in your site's wp-config.php.
// Read the corresponding post https://www.itthinx.com/2021/09/06/wordpress-mail-debugging/
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
$output = sprintf(
"\n\n" .
@itthinx
itthinx / riche.php
Last active May 25, 2018 17:10
Affiliate Registration issue
<?php
// from https://www.itthinx.com/topic/affiliate-registration-issue-2/
// the snippet for the form action which currently works looks like this:
function referring_affiliate_form_action ( $atts ) {
$output_form_action = '';
if ( !is_admin() ) {
if ( !class_exists( "Affiliates_Service" ) ) {
@itthinx
itthinx / woocommerce-product-search-storefront.php
Created November 15, 2017 10:34
Using WooCommerce Product Search and replacing the default Search Form in Storefront and its child themes
<?php
function storefront_product_search() {
if ( function_exists('storefront_is_woocommerce_activated' ) ) {
if ( storefront_is_woocommerce_activated() ) { ?>
<div class="site-search">
<?php
if ( function_exists( 'woocommerce_product_search' ) ) {
echo woocommerce_product_search();
} else {
the_widget( 'WC_Widget_Product_Search', 'title=' );
/**
* Yves' implementation to add a capability to a group when a purchase has been completed.
*
* http://www.itthinx.com/plugins/groups-paypal/comment-page-1/#comment-647332
*/
add_action('frm_payment_paypal_ipn', 'ls4s_sprint_purchase_completed');
function ls4s_sprint_purchase_completed($args)
{
global $frmdb, $wpdb;
@itthinx
itthinx / uksort.php
Created March 11, 2015 15:03
PHP Bug Warning: uksort(): Array was modified by the user comparison function
<?php
/**
* The following will produce this result:
*
* Warning: uksort(): Array was modified by the user comparison function in /Users/kento/Sites/uksort.php on line 12
* set = array ( 'apple' => 'green', 'color' => 'yellow', 'wine' => 'white', 'yoghurt' => 'frozen', )
*
* See also https://bugs.php.net/bug.php?id=50688
**/
@itthinx
itthinx / craig-auth0.php
Last active August 29, 2015 14:10
Craig's Auth0 integration with Groups
<?php
_log ('firing craig_Login_Hook()');
// require_once(ABSPATH . 'wp-includes/pluggable.php' );
global $currentauth0_user;
$user_id = get_current_user_id();
if ($user_id > 0) {
get_currentauth0userinfo();
/* grab the Auth0 groups for the current user */
@itthinx
itthinx / gist:fd36ab89359332d4a142
Last active August 29, 2015 14:10
Affiliate coupons rendered as text
<style type="text/css">
div.field.affiliate-attribute.coupons {
display:inline;
}
div.field.affiliate-attribute.coupons label {
display:none;
}
div.field.affiliate-attribute.coupons input {
width:60%;
border:none;
@itthinx
itthinx / list-group-users.php
Last active August 29, 2015 14:04
[list_group_users]
<?php
add_shortcode( 'list_group_users', 'list_group_users' );
function list_group_users( $atts, $content = '' ) {
$output = '';
if ( isset( $atts['group'] ) ) {
if ( $group = Groups_Group::read_by_name( trim( $atts['group'] ) ) ) {
$group = new Groups_Group( $group->group_id );
$groups_users = $group->users;
usort( $groups_users, 'sort_list_group_users' );
if ( !empty( $groups_users ) ) {