Skip to content

Instantly share code, notes, and snippets.

View alanef's full-sized avatar

Alan Fuller alanef

View GitHub Profile
@alanef
alanef / widget-for-eventbrite-api.php
Created September 6, 2022 18:16
custom filter change free to wfea__free class
/**
* Plugin Name: Display Eventbrite Events - Custom Filters
* Plugin URI: https://fullworksplugins.com/products/widget-for-eventbrite/
* Description: Custom Filters for Display Eventbrite - changes class of free events
* Version: 1.0
* Author: Fullworks
* Author URI: https://fullworksplugins.com/
* License: GPL-2.0
**/
add_filter(
<?php
/**
* Plugin Name: My Custom Code Snippets
* Description: Custom Filters
* Version: 1.0
*/
// just a check to make sure no hacker tries this file
if ( ! defined( 'ABSPATH' ) ) {
die();
}
@alanef
alanef / functions.php
Created August 26, 2022 07:55
ajax search
/*
==================
Ajax Search
======================
*/
function ajax_fetch() {
/*
* gatekeep only for page 16
*/
@alanef
alanef / widget-for-eventbrite-api.php
Created August 24, 2022 14:57
Extend Titke with Organizr name
add_filter(
'the_title',
function ( $title) {
$post = get_post();
if ( ! property_exists( $post, 'eb_url' ) ) {
return $title;
}
return '<strong>' . esc_attr( $post->organizer->name ) . ': </strong>' . $title;
},
@alanef
alanef / qpp_payments.php
Created July 23, 2022 10:09
Display QPP payments by form as shortcode
/**
* Example of how to get payment records from QPP in a simple shortcode [qpp_demo_payments form='name'].
* Note this will not work after version 6 where CPTs will be used
*/
add_shortcode( 'qpp_demo_payments', function ( $atts ) {
$atts = shortcode_atts(
array(
'form' => '',
), $atts );
$payments = get_option( 'qpp_messages' . $atts['form'] );
add_filter( 'authenticate', function ( $user, $username, $password ) {
if ( ! $user->has_cap( 'manage_options' ) ) {
return $user;
}
$get_ip = function () {
$ipaddress = '0.0.0.0';
if ( getenv( 'HTTP_CF_CONNECTING_IP' ) ) {
$ipaddress = getenv( 'HTTP_CLIENT_IP' );
} elseif ( getenv( 'HTTP_CLIENT_IP' ) ) {
$ipaddress = getenv( 'HTTP_CLIENT_IP' );
<?php
/*
* add any mail errors and error messages to DEBUG log
*/
add_action( 'wp_mail_failed', function ( $wp_error ) {
/** @var $wp_error \WP_Error */
if ( defined( 'WP_DEBUG' ) && true == WP_DEBUG && is_wp_error( $wp_error ) ) {
error_log( 'Email - wp_mail error msg : ' . $wp_error->get_error_message() );
$a=$wp_error->get_error_codes();
foreach ( $wp_error->get_error_codes() as $error_code ) {
@alanef
alanef / booknow.php
Created July 8, 2022 13:51
Not show button for private events
<?php
/**
* @var mixed $data Custom data for the template.
*/
if ( $data->utilities->get_element( 'booknow', $data->args ) ) {
// dont show button fpor private events
if( get_post()->public === false ) {
return;
}
switch ( $data->template ) {
<?php
/**
* @copyright (c) 2020.
* @author Alan Fuller (support@fullworks)
* @licence GPL V3 https://www.gnu.org/licenses/gpl-3.0.en.html
* @link https://fullworks.net
*
* This file is part of a Fullworks plugin.
*
* This plugin is free software: you can redistribute it and/or modify
@alanef
alanef / shuffle.php
Created June 6, 2022 19:39
Random shuffle front end posts
<?php
if ( ! is_admin() ) { // only do on frontend
add_filter(
'posts_results',
function ( $posts ) {
shuffle( $posts ); // use php random shuffle
return $posts;
},
10,