Skip to content

Instantly share code, notes, and snippets.

View alanef's full-sized avatar

Alan Fuller alanef

View GitHub Profile
<?php
/*
Plugin Name: Test Ajax
Plugin URI: https://fullworks.net
Description: A demo of ajax calls to the Widget for Eventbrite plugin shortcode
Version: 1.0
Author: Alan Fuller
Author URI: https://fullworks.net
License: GPL3
jQuery(document).ready(function ($) {
// as nothing will be on the page we initialise with a call
ajax_call();
// on click of the search button we make the call with the filter value
$('#ajaxwfeasearch').click(function () {
ajax_call();
});
add_filter(
'wfea_availability_display', // filter hook name
function ( $msg, $total_sold, $event_capacity ) { // annonyous function that takes 3 parameters - paramters are defined by the hook
if ( $total_sold >= $event_capacity ) {
$msg = __( 'Sold Out', 'widget-for-eventbrite-api' );
} else if ( ( $event_capacity - $total_sold ) > 10 ) { // set this number to what you like if you don't want a count
$msg = 'Places Available';
} else {
$msg = sprintf( '%1$s Places Left', ( $event_capacity - $total_sold ) );
}
#!/bin/bash -xv
echo "Deploy to WordPress SVN"
pattern="*.zip"
files=( $pattern )
[ "${files[0]}" == "*.zip" ] && { echo "Error: No zip file found"; exit 1; }
echo "Plugin zip file found ${files[0]}"
search="-free"
rootdir=${files[0]%$search*}
echo $rootdir
dir='workdir'
<?php
/*
* Plugin Name: Clean media files in trash
*
* Plugin URI: https://fullworks.net/products/the-webinar-toolkit/
* Description: add define('EMPTY_MEDIA_TRASH_DAYS', 7); to wp-config.php
* Version: 1.0
* Author: Fullworks
* Author URI: https://fullworks.net/
* Licence: GPL 2 or later
const find = require('local-devices');
const fetch = require('node-fetch');
let heatpumpIPs = [];
const getHeatpumps = () => find().then( async devices => {
for ( let i = 0; i < devices.length; i++) {
try {
let response = await fetch('http://' + devices[i].ip + '/common/basic_info')
let isHeatpump = await response.ok
@alanef
alanef / audio html
Created November 26, 2020 18:39
HTML 5 Audio
<audio id="myRing">
<source src="/path/to/ringring.mp3">
</audio>
<a onclick="document.getElementById('myRing').play()"><img src="https://myphone.png"></a>
@alanef
alanef / ex.php
Last active November 22, 2020 16:13
Example
/* before doing this check if $_GET['event_id'] is set e.g.
if ( ! isset($_GET['event_id']) {
// return or do error stuff
}
*/
$event_id=sanitize_text_field($_GET['event_id']);
$event_id=wp_unslash($event_Id);
$date = get_post_meta($event_id, '_mdjm_event_date', true );
@alanef
alanef / Plugin
Last active December 23, 2020 11:00
<?php
/*
Plugin Name: Custom code
Plugin URI: https://fullworks.net/
Description: Custom code
Version: 1.0
Author: Alan
Author URI: https://fullworks.net/
License: GPL2
*/
<?php
/*
Plugin Name: Test Shortcode
Plugin URI: https://fullworks.net
Description: Test Shortcode Gutenberg content
Version: 1.0
Author: alan
Author URI: https://fullworks.net
License: GPL2