Skip to content

Instantly share code, notes, and snippets.

View alanef's full-sized avatar

Alan Fuller alanef

View GitHub Profile
<?php
/*
use like [myshortcode type=feedback]
*/
add_shortcode( 'myshortcode', function ( $atts ) {
$atts = shortcode_atts( array( 'type' => '' ) );
return apply_filter( 'myshortcode_' . $atts['type'], '' );
} );
<?php
/**
* Plugin Name: Custom Code Snippets - Display Eventbrite
* Version: 1.0
*/
add_filter( 'wfea_cal_extra_options',
function ( $options ) {
$options['fullcalendar']['showNonCurrentDates'] = false;
return $options;
@alanef
alanef / gist:8f5b51b7777065f83e3092c247dc6794
Created February 5, 2024 18:32
Restrict site to logged in user
<?php
/*
* Plugin Name: Restrict a site
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
// Hook 'redirect_if_not_logged_in' function into 'template_redirect' action
@alanef
alanef / gist:07d446e7fe05ae99338469a9e3959a00
Last active December 11, 2023 16:04
Close commens on all events
<?php
/*
* Plugin Name: Quick Event Manager Custom Snippet - Disable Comments on Events
*/
add_filter('comments_open', function ($open, $post_id) {
$post = get_post($post_id);
if ($post->post_type == 'event') {
return false;
}
return $open;
@alanef
alanef / gist:65f8ecc744c1f6669cba4b4e906a6c32
Created December 11, 2023 15:05
Filter to remove comments from Event Post Type
add_filter('qem_event_register', function($args) {
if(isset($args['supports']) && is_array($args['supports'])) {
$args['supports'] = array_diff($args['supports'], ['comments']);
}
return $args;
});
<?php
/* Plugin Name: Snippets for accordions layout - custom */
add_filter('wfea_layout_part_accordion_tab', function($text) {
return $text . ' | Click for timetables and bookings ';
}, 10,1);
add_filter('wfea_layout_part_organizer_name', function($text) {
return '';
}, 10,1);
@alanef
alanef / detect_playground.php
Last active March 20, 2024 14:34
Detect WP Playground
<?php
if ( 'PHP.wasm' === $_SERVER['SERVER_SOFTWARE'] && 'playground.wordpress.net' === $_SERVER['HTTP_HOST'] ) {
// inside playground.wordpress.net
}
public function is_cache_plugin_installed() {
return
function_exists( 'w3tc_flush_post' ) ||
function_exists( 'wp_cache_post_change' ) ||
function_exists( 'rocket_clean_post' ) ||
has_action( 'cachify_remove_post_cache' ) ||
has_action( 'litespeed_purge_post' ) ||
function_exists( 'wpfc_clear_post_cache_by_id' ) ||
class_exists( 'WPO_Page_Cache' ) ||
has_action( 'cache_enabler_clear_page_cache_by_post' ) ||
@alanef
alanef / phpcs_sec.xml
Created November 7, 2023 18:52
PHPCS WP Sec Rules 3.0
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Example Project"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<description>WP Security</description>
<rule ref="WordPress.Security.EscapeOutput">
</rule>
<rule ref="WordPress.Security.SafeRedirect">
</rule>
# Matomo
* Matomo Plugin Version: 4.15.2
* Config exists and is writable.: Yes ("$abs_path/wp-content/uploads/matomo/config/config.ini.php" )
* JS Tracker exists and is writable.: Yes ("$abs_path/wp-content/uploads/matomo/matomo.js" )
* Plugin directories: Yes ([{"pluginsPathAbsolute":"$abs_path\/wp-content\/plugins\/matomo\/plugins","webrootDirRelativeToMatomo":"..\/"}])
* Tmp directory writable: Yes ($abs_path/wp-content/cache/matomo)
* Matomo Version: 4.15.1
* Matomo Blog idSite: 1
* Matomo Install Version: 4.15.2 (Install date: 2023-10-17 21:32:21)