Skip to content

Instantly share code, notes, and snippets.

View pattonwebz's full-sized avatar
🏠
Working from home

William Patton pattonwebz

🏠
Working from home
View GitHub Profile
@pattonwebz
pattonwebz / wpf-all-sites.php
Created June 19, 2025 17:57 — forked from jack-arturo/wpf-all-sites.php
Stores log of all sites that call home looking for updates
<?php
/*
Plugin Name: WPF All Sites
Plugin URI: verygoodplugins.com
Description: Stores log of all sites that call home looking for updates
Version: 1.0
Author: vergoodplugins
Author URI: verygoodplugins.com
License:
document.addEventListener("DOMContentLoaded", function () {
/*
* Find any insteances of the selector in oldTag and replace it with the tag from newTag.
*/
function replaceHeadingLevel(oldTag, newTag) {
document.querySelectorAll(oldTag).forEach(function (element) {
var newHeading = document.createElement(newTag);
newHeading.innerHTML = element.innerHTML;
// Copy attributes from old heading to new heading.
<?php
/**
* Fix incorrect heading order in post content.
*
* @param string $content The post content.
* @return string Modified content with correct heading structure.
*/
function fix_heading_order_in_content( $content ) {
// Replace incorrect H2 with H3 (example scenario).
$content = preg_replace( '/<h2([^>]*)>(.*?)<\/h2>/', '<h3$1>$2</h3>', $content );
<?php
// Somewhere inside the template you should find headers. Add a conditional to use h1 on single article
// header and h2 otherwise.
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php if ( is_singular() ) : ?>
<h1 class="entry-title"><?php the_title(); ?></h1> <!-- Ensure this is H1 -->
<?php else : ?>
<h2 class="entry-title">
@pattonwebz
pattonwebz / ftrontend-highlighter-visible-to-logged-in-users.php
Created January 29, 2025 20:34
Show frontend highlighter to any user that is logged in
<?php
add_filter( 'edac_filter_frontend_highlighter_visibility', function () {
return is_logged_in();
} );
@pattonwebz
pattonwebz / all_users_see_highlighter.php
Created January 29, 2025 20:31
Allow everyone to see the frontend highlighter
<?php
add_filter( 'edac_filter_frontend_highlighter_visibility', '__return_true' );
@pattonwebz
pattonwebz / filter_cookie.php
Last active May 1, 2024 20:58
Filters the cookies being set by affwp and updates them when it's a matching ID to use a 30 day expiry.
@pattonwebz
pattonwebz / disable_core_search.php
Created December 5, 2022 20:28
Disable core search query handling
<?php
function disable_core_search_query_handling($query, $error = true) {
if (is_search() && !is_admin()) {
$query->is_search = false;
$query->query_vars['s'] = false;
$query->query['s'] = false;
// to error
<style>
.compare-table--wrapper {
background: #f5f5f5;
max-width: 740px;
border-radius: 24px;
margin: 0 auto;
}
.compare-table {
border-collapse: separate;
@pattonwebz
pattonwebz / grok-pattern.md
Created December 28, 2020 14:56 — forked from iamstoick/grok-pattern.md
Pantheon nginx-access.log Grok pattern
%{IPORHOST:remoteaddress} - - \[%{HTTPDATE:timelocal}\]  "%{WORD:httpmethod} %{URIPATHPARAM:request} HTTP/%{NUMBER:httpversion}" %{NUMBER:response} (?:%{NUMBER:bytes}|-) (?:"(?:%{URI:referrer}|-)"|%{QS:referrer}) %{QS:useragent} %{BASE10NUM:request_duration} %{QS:xforwardedfor}