Skip to content

Instantly share code, notes, and snippets.

View alanef's full-sized avatar

Alan Fuller alanef

View GitHub Profile
@alanef
alanef / dropdown.html
Created May 9, 2022 16:08
example dropdown
<select onchange="window.location=this.value">
<option disabled selected>Choose location</option>
<option value="https://example.com/location-page-one">Location One</option>
<option value="https://example.com//location-page-two">Location Two</option>
</select>
#!/bin/bash -xv
# parse the current directory name
currentdirectory=${PWD##*/}
# get env variables
export $(grep -v '^#' .env | xargs)
ssh ${LIVE_USER}@${LIVE_DOMAIN} "cd /home/${LIVE_DIR};wp db export --add-drop-table db.sql"
export default function Edit(props) {
const {attributes, setAttributes} = props
const UnitSelector = () => {
const updateUnits = (val) => {
setAttributes({units: val});
}
return (
<TextControl
label={__('Enter Units', 'blocks-for-weatherlink')}
help={__('Knots, MPH, KPH', 'blocks-for-weatherlink')}
@alanef
alanef / get-data.php
Created March 10, 2022 17:48
Example get data as a plugin
<?php
/*
Plugin Name: Get Data
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: A brief description of the Plugin.
Version: 1.0
Author: alan
Author URI: http://URI_Of_The_Plugin_Author
License: A "Slug" license name e.g. GPL2
version: '3.3'
services:
db:
image: mariadb:latest
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: mypass
FROM php:8.1-apache
ENV PORT 80
ENTRYPOINT []
CMD sed -i "s/80/$PORT/g" /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf && docker-php-entrypoint apache2-foreground
RUN a2enmod rewrite
RUN apt-get update \
&& apt-get install -y libzip-dev \
&& apt-get install -y libxml2-dev \
<?php
add_filter( 'woocommerce_return_to_shop_redirect', function ( $shop_url ) {
if ( is_cart() && wc()->cart->cart_contents_count == 0 ) {
$deleted_items = wc()->cart->get_removed_cart_contents();
$deleted_items = array_reverse( $deleted_items );
foreach ( $deleted_items as $deleted_item ) {
$deleted_id = (int) $deleted_item['product_id'];
$vendor_id = wcfm_get_vendor_id_by_post( $deleted_id );
if ( $vendor_id ) {
return wcfmmp_get_store_url( $vendor_id );
@alanef
alanef / scratch_26.json
Created January 28, 2022 12:21
test data
{
"track_general_name": "Thread",
"session_general_name": "Session",
"login_page": "http:\/\/55",
"logout_page": "http:\/\/2",
"stream": [
{
"header": "Thread 1",
"0": {
"name": "Opening Remarks",
@alanef
alanef / index.php
Created December 31, 2021 15:46
Working cal color
<?php
/**
* Plugin Name: Trent Valley Woodturners Code Snippets
* Description: Custome functions specific for the TVW website
* Author: Ben Wild
* Version: 1.1
*/
// just a check to make sure no hacker tries this file
if ( ! defined( 'ABSPATH' ) ) {
die();
<?php
//* Do NOT include the opening php tag shown
add_filter(
'wfea_cal_event_extra_options',
function ( $options ) {
$title = get_the_title();
if (preg_match('/securing/i',$title) ) {
$options['backgroundColor'] = 'red';
$options['borderColor'] = 'black';
$options['textColor'] = 'white';