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 / 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 geraldvillorente/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}
@pattonwebz
pattonwebz / functions.php
Created April 12, 2018 03:19
Halt theme activation if attempting to activate on unsupported older php versions.
<?php
/**
* Define the min version you support. Here I use 5.6 as example but change it to match your support version.
*/
define( 'PREFIX_MIN_PHP_VERSION', '5.6' );
/**
* Attach a function to check php version on the `after_theme_switch` hook.
*/
add_action( 'after_switch_theme', 'prefix_test_for_min_php' );
@pattonwebz
pattonwebz / bs3-version.php
Created February 10, 2018 16:04
Code for bootstrap 3 responsive navbars in wordpress using wp-bootstrap-navwalker class
<?php
/**
* The register_nav_menus call should go inside your themes setup function
* (usually found inside functions.php).
*/
register_nav_menus(
array(
'footer_nav' => __( 'Footer Menu', 'mytheme' ), // example of adding a menu location
'top_menu' => __( 'Top Menu', 'mytheme' ), // we will be using this top_menu location
@pattonwebz
pattonwebz / open-authors-reports.js
Created December 15, 2017 19:35
check child theme authors aren't uploading too frequently - opens submission reports of all authors currently in the queue viewed
function openInNewTab(url) {
var win = window;
win.open(url, '_blank');
win.blur;
window.focus();
}
function get_authors() {
var authors = [];
jQuery('td.reporter').each( function() {
authors.push( jQuery( this ).text().trim() );
@pattonwebz
pattonwebz / reset.sh
Last active November 12, 2017 18:35
called with: sh reset.sh {url to theme zip file}.
#!/bin/bash
# clear databse
wp db reset --yes
# Install WP with long title
wp core install --url=http://theme-review.loc --title="This is a really long long title to check if this theme design doesn't break with the long site title" --admin_user=admin --admin_password=admin --admin_email=example@example.com
# Update wp.
wp core update
@pattonwebz
pattonwebz / pwwp_debug_logger.php
Created October 9, 2017 16:20
Function to handle some basic php logging with some logic for handling wp_error and any object/arrays.
<?php
/**
* Puts messages into the error log
*
* Using php error_log put messages into the log depending on what kind of
* variable they are.
*
* @author William Patton - will@pattonwebz.com
*
* @param mixed $error this is the error we'll be outputting. Type is ambiguous.
@pattonwebz
pattonwebz / filter-opengraph-image-per-posttype.php
Last active October 9, 2017 17:41
How to use the filter in yoast seo to redefine a default image for only certain CPT that is used in the open graph tags.
<?php
/**
* Filters the image used in social meta tags added by yoast seo plugin.
*
* This is used to set a default social share image for various post types.
*
* @param string $image string containing link to image that is used in tags.
* @return string string containing maybe updated url to image
*/
function pwwp_filter_yoast_opengraph_image( $image = '' ) {