Skip to content

Instantly share code, notes, and snippets.

View alanef's full-sized avatar

Alan Fuller alanef

View GitHub Profile
@alanef
alanef / example.php
Last active December 30, 2019 12:05
Santized input php example
<?php
if (
isset( $_GET['id'] ) &&
isset( $_GET['name'] ) &&
isset( $_GET['phone'] ) &&
isset( $_GET['email'] ) &&
( ( $id = filter_var( $_GET['id'], FILTER_SANITIZE_NUMBER_INT ) ) == '01' ) &&
( ( $name = filter_var( $_GET['name'], FILTER_SANITIZE_STRING ) ) == 'robi' ) &&
( ( $phone = filter_var( $_GET['phone'], FILTER_SANITIZE_STRING ) ) == '61' ) &&
( ( $email = filter_var( $_GET['email'], FILTER_SANITIZE_EMAIL ) ) == 'afs' )
@alanef
alanef / adminpage.php
Last active January 21, 2020 17:49
Settings tabs
/* markyp at the top of my pages calls display tabs */
//snip
<div class="fs-settings-meta-box-wrap">
<form id="fs-smb-form" method="post" action="options.php">
<?php settings_fields( $this->option_group ); // options group
?>
<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
@alanef
alanef / readme.md
Created February 11, 2020 15:12
check element of an array

rather than always using a combination of if ( issett($array['element']) && 'test' === $array['element'] ) { }

This function can be called

if ( 'test' === xzy_get_element(,$array, 'element', 'test' ) ) { }

or if a boolean just

if ( xzy_get_element(,$array, 'element' ) ) { } // if missing default is false

@alanef
alanef / style.css
Last active February 1, 2021 22:28
/* ---- Style the calendar header ---- */
/* fix for somethemes that add margin to the end of all tables */
.wfea-calendar table {
margin-bottom: 0;
}
/* add color to the top row */
.wfea .fc-toolbar.fc-header-toolbar {
color: #fff;
background: #0c3a5b;
@alanef
alanef / functions.php
Last active February 14, 2020 17:50
Change the calendar styles
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* use the filter wfea_cal_options for the list view
//* the following example removes the event time
//* changes background to black
//* sets the pop up to youtube style
//* see full list of options here
@alanef
alanef / gist:463e413a1808c07c608b5b11f430e2c3
Last active April 28, 2020 15:43
Styling Calendar list images
/*
* change the image size in cal-list
*/
.wfea-calendar-list .fc-list-item-title div.cal-list-link-wrap div.cal-list-img-wrap img.cal-list {
height: 5em;
}
/*
* go a step further and align everything in the middle
*/
.wfea-calendar-list .fc-list-item td {
<?php
/*
Plugin Name: Allow Editor to Manage Options
Plugin URI: https://fullworks.net/
Description: Allow Editor manage_otption capabaility
Author: Alan
*/
add_action( 'init', function () {
$role = get_role( 'editor' );
<?php
echo '<a href="?go">Download</a>';
if (isset($_GET['go'])) {
header('Content-Type: text/html; charset=utf-8');
header('Content-Disposition: attachment; filename="out.pdf"');
echo file_get_contents("out.pdf");
}
global $wpdb;
$querystr = "
SELECT $wpdb->posts.ID
FROM $wpdb->posts
WHERE
$wpdb->posts.post_status = 'publish'
AND $wpdb->posts.post_type = 'post
AND ABS(DATEDIFF(CONCAT('2000',SUBSTRING($wpdb->posts.post_date_gmt,5)), CONCAT('2000',SUBSTRING(NOW(),5))))< 16
";
$ids = $wpdb->get_results($querystr, ARRAY_N);
<?php
add_filter(
/**
* Filter the autoresponder content
* this can be used to add custom shortcodes
*
* @param $msg
* @param $id
* @param $payment
*