Skip to content

Instantly share code, notes, and snippets.

View karks88's full-sized avatar

Eric Karkovack karks88

View GitHub Profile
@lgladdy
lgladdy / acf-unsafe-html-detection-backtrace.php
Last active January 30, 2024 17:23
Print backtrace on the frontend when potentially unsafe HTML is removed
<?php
add_action( 'acf/will_remove_unsafe_html', 'print_backtrace_for_unsafe_html_removal', 10, 4 );
add_action( 'acf/removed_unsafe_html', 'print_backtrace_for_unsafe_html_removal', 10, 4 );
function print_backtrace_for_unsafe_html_removal( $function, $selector, $field_object, $post_id ) {
echo '<h4 style="color:red">Detected Potentially Unsafe HTML Modification</h4>';
echo '<pre>';
debug_print_backtrace();
echo '</pre>';
}
@scottopolis
scottopolis / ga-track-outbound.js
Last active January 4, 2024 21:14
Google Analytics track all outbound links with no markup change
// listen for all clicks on anything. You could change document to a selector like #content to make it more efficient.
$(document).on('click', function( e ) {
// if this is a link, and the href does not contain our domain, it's an external link. Track it.
if( e.target.href && e.target.href.indexOf( window.location.hostname ) < 0 ) {
ga('send', 'event', {
eventCategory: 'Outbound Link',
eventAction: 'click',
eventLabel: e.target.href, // the outbound link url will appear as the event label in GA. Find under Behavior -> Events -> Event Label
transport: 'beacon' // not supported in some versions of IE
});

Your First Block

To make things simple, we're going to make a semi-structured way to display a mailing address.

We're going to start with a file tree that looks like this:

address-block
  ├ blocks
  | ├ address.jsx
@kellenmace
kellenmace / add-unfiltered_html-capability-to-admins-or-editors.php
Last active September 20, 2022 18:29
Add unfiltered_html Capability to Admins or Editors in WordPress Multisite
<?php
/**
* Enable unfiltered_html capability for Editors.
*
* @param array $caps The user's capabilities.
* @param string $cap Capability name.
* @param int $user_id The user ID.
* @return array $caps The user's capabilities, with 'unfiltered_html' potentially added.
*/
@jesseeproductions
jesseeproductions / remove-categories-not-replated.php
Last active June 30, 2020 15:07
Removes categories "tech" from list and month views
/*
* The Events Calendar Remove Events from Month and List Views
* add coding to theme's functions.php
* @version 3.12
* modify here with event category slugs: array( 'concert', 'convention' )
*/
add_action( 'pre_get_posts', 'tribe_exclude_events_category_month_list' );
function tribe_exclude_events_category_month_list( $query ) {
if ( isset( $query->query_vars['eventDisplay'] ) && ! is_singular( 'tribe_events' ) ) {
@annalinneajohansson
annalinneajohansson / plugin-settings.php
Last active February 23, 2023 04:42
A base for a WordPress plugin settings page, using the Settings API #add_options_page #add_action #admin_init #register_setting #add_settings_section
<?php
# http://kovshenin.com/2012/the-wordpress-settings-api/
# http://codex.wordpress.org/Settings_API
add_action( 'admin_menu', 'my_admin_menu' );
function my_admin_menu() {
add_options_page( __('My Plugin Options', 'textdomain' ), __('My Plugin Options', 'textdomain' ), 'manage_options', 'my-plugin', 'my_options_page' );
}
add_action( 'admin_init', 'my_admin_init' );