Skip to content

Instantly share code, notes, and snippets.

View plaidpowered's full-sized avatar
:shipit:
Always Be Committing

Paul plaidpowered

:shipit:
Always Be Committing
  • Coastal GA
View GitHub Profile
@plaidpowered
plaidpowered / post-editor-classes.php
Created May 27, 2022 15:56
Add template classes to WordPress admin post editor
add_filter( 'admin_body_class', 'add_admin_body_template_class' );
function add_admin_body_template_class( $classes ) {
if ( ! is_admin() ) {
return $classes;
}
$queried_post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT );
if ( ! $queried_post_id ) {
@plaidpowered
plaidpowered / cf7ajax.js
Last active April 12, 2021 17:40
WORK IN PROGRESS: Are you annoyed by all the scripts that are loaded into your page with Contact Form 7? Here is an incredibly simple, dependency-free (no jQuery) replacement that implements CF7's REST API to provide AJAX form validation and feedback.
/**
* Please note: This file uses ES6 code structures and likely needs to be transpiled for better browser support in your application.
*
* To use this, you'll need to enqueue it with a localized variable that passes the CF7 feedback endpoint, for example,
*
wp_register_script( 'cf7-ajax-script', 'path/to/cf7ajax.js', [], '0.1', true );
wp_localize_script( 'cf7-ajax-script', 'cf7FeedbackEndpoint', get_rest_url( null, 'contact-form-7/v1/contact-forms/###/feedback' ) );
wp_enqueue_script( 'cf7-ajax-script' );
@plaidpowered
plaidpowered / domain-mapping.php
Last active August 13, 2020 14:07
Mapping Additional Domains with WordPress Multisite
<?php
class DomainMapper {
/**
* Where we store the fully qualified domain URL throughout the lifecycle of the WordPress stack.
*/
private $domain = null;
/**
@plaidpowered
plaidpowered / Get person content - Ajax
Last active December 18, 2019 22:01 — forked from nikolab/Get person content - Ajax
Get person content - Ajax
//team showcase
var $xhrObject;
$(document).unbind("click").on("click", ".tshowcase-box", function (event) {
$this = $(this);
$this.siblings().removeClass('active');
$('.person-content-wrap').hide();
$this.toggleClass('active');
var url = $(this).find('a').attr('href'); //get url