Skip to content

Instantly share code, notes, and snippets.

View landbryo's full-sized avatar
🤠
Always Excitied

Landon Otis landbryo

🤠
Always Excitied
View GitHub Profile
@landbryo
landbryo / rewrite-rules.php
Created February 28, 2024 01:44
Rewrite rules export
<?php
$rules = array (
'ad/([0-9]+)/[^/]+/?$' => 'index.php?permalink_id=$matches[1]',
'^wp-json/?$' => 'index.php?rest_route=/',
'^wp-json/(.*)?' => 'index.php?rest_route=/$matches[1]',
'^index.php/wp-json/?$' => 'index.php?rest_route=/',
'^index.php/wp-json/(.*)?' => 'index.php?rest_route=/$matches[1]',
'^wp-sitemap\\.xml$' => 'index.php?sitemap=index',
'^wp-sitemap\\.xsl$' => 'index.php?sitemap-stylesheet=sitemap',
@landbryo
landbryo / graphql-error.json
Created February 6, 2024 17:02
Package GraphQL error
{
"errors": [
{
"debugMessage": "Vox_Media\\Vox_Media_Theme\\Components\\Packages\\Package_Resource::Vox_Media\\Vox_Media_Theme\\Components\\Packages\\{closure}(): Argument #1 ($post) must be of type WP_Post, bool given",
"message": "Internal server error",
"extensions": {
"category": "internal"
},
"locations": [
{
@landbryo
landbryo / enable-dropcap.php
Created December 20, 2023 18:19
Enable the dropcap feature by modifying the theme.json
<?php
/**
* Add drop cap support to the theme.json file.
*
* @param array $theme_json The theme.json json.
*
* @link https://developer.wordpress.org/block-editor/developers/themes/theme-json/#typography
*/
add_filter( 'wp_theme_json_data_theme', function( $theme_json ) {
@landbryo
landbryo / modify-paragraph-controls.js
Created December 20, 2023 18:15
Modify paragraph controls to add "Lead" and "Endmark" toggles.
import { createHigherOrderComponent } from '@wordpress/compose';
import { InspectorControls } from "@wordpress/block-editor";
import { __experimentalToolsPanelItem as ToolsPanelItem, ToggleControl, } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
const editParagraphAttributes = function ( settings, name ) {
if ( 'core/paragraph' === name ) {
settings.supports = {
...settings.supports,
@landbryo
landbryo / sample-getty-image-meta.json
Created December 12, 2023 15:35
Sample Getty Image Metadata
{
"width": 612,
"height": 408,
"file": "2023/12/gettyimages-1463514722-612x612-1.jpg",
"filesize": 82069,
"sizes": {
"medium": {
"file": "gettyimages-1463514722-612x612-1-300x200.jpg",
"width": 300,
"height": 200,
@landbryo
landbryo / disable-login-cookie-bookmarket.js
Created October 16, 2023 22:39
Disable Login Cookie Bookmarklet
@landbryo
landbryo / enable-login-cookie-bookmarklet.js
Created October 16, 2023 22:38
Enable Login Cookie Bookmarklet
@landbryo
landbryo / additional-authors-partial.php
Created October 16, 2023 18:07
Filter posts SQL query to include additional authors.
<?php
/**
* Hooks
*
* @return void
*/
public function init() {
// Filter author query to include posts author was added to as an additional author.
add_filter( 'posts_where', [ $this, 'filter_where' ], 10, 2 );
@landbryo
landbryo / gravity-complex-calculation.md
Last active September 9, 2023 20:18
Example Gravity Form Complex Calculation

Complex calculations in Gravity Forms may not work in the order that you'd expect. In this scenario, instead of subtracting the total value of the calculations from the value of field 15, we have to force the order of operation by subtracting it at the end, which creates a negative number. To return the number to positive, we multiply the total value by -1.

(
    ( {:15} * ( {:3} * 0.01 ) ) + 
    ( {:15} * ( {:16} * 0.01 ) ) + 
    ( {:15} * ( {:17} * 0.01 ) ) + 
    ( {:15} * ( {:7} * 0.01 ) ) - 
    ( {:15} ) 
) * -1
@landbryo
landbryo / mrss-example-item-description-cdata.xml
Created September 5, 2023 22:12
Example mRSS feed using non-spec custom parameters
<item>
<link>https://www.nerdwallet.com/article/mortgages/fthb-affordability-q22023</link>
<guid>https://www.nerdwallet.com/article/mortgages/fthb-affordability-q22023</guid>
<description>
<![CDATA[
<p>This second quarter analysis finds high rates and higher prices made for another tough quarter for potential first-time home buyers.</p>
<ul>
<li>
<a href="https://www.drsquatch.com">Sasquatch Found Working at Arbys</a>