This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// include this in your theme's functions.php file | |
// Find & Replace all instances of 'prefix' and replace with the brand name. | |
// the file itself expects to be in /wp-content/themes/prefix/functions/modules/ | |
add_action( 'admin_menu', 'prefix_redirects_admin_menu' ); | |
function prefix_redirects_admin_menu() { | |
add_menu_page( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// include this file in your root index.php file to load before Wordpress loads. | |
// | |
// Related Gists: | |
// CSV template: https://gist.github.com/jordanmaslyn/94d450814d921420408a | |
// Plugin code: https://gist.github.com/jordanmaslyn/fbbcc571e6717e66b880 | |
// | |
// Make sure to replace THEME_NAME with your theme's actual name in the line below. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'admin_head-post.php', '_my_reset_image_insert_settings' ); | |
add_action( 'admin_head-post-new.php', '_my_reset_image_insert_settings' ); | |
function _my_reset_image_insert_settings() { | |
?> | |
<script> | |
if ( typeof setUserSetting !== 'undefined' ) { | |
setUserSetting( 'align', 'none' ); // none || left || center || right | |
setUserSetting( 'imgsize', 'medium' ); // thumbnail || medium || large || full | |
setUserSetting( 'urlbutton', 'none' ); // none || file || post | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_site_url( $url ) { | |
if( is_admin() ) { | |
return $url; | |
} // you probably don't want this in admin side | |
$replaced = array("buzzed", "blogspot."); | |
foreach ($replaced as $replace) { | |
if (strpos( parse_url($url, PHP_URL_HOST), $replace ) !== false) { | |
return str_replace($replaced, "", $url); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<h1>Frameworks</h1> | |
<ul> | |
<li repeat.for="framework of state.frameworks">${framework}</li> | |
</ul> | |
</template> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { GetServerSidePropsContext } from "next"; | |
const defaultWpUrl = 'https://example.wpengine.com'; | |
const localHost = 'localhost:3000'; | |
const prodHost = 'example.com'; | |
export default function Sitemap () {}; | |
export const getServerSideProps = async (context: GetServerSidePropsContext) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { createServer } = require('http'); | |
const { parse } = require('url'); | |
const next = require('next'); | |
const dev = process.env.NODE_ENV !== 'production'; | |
const app = next({ dev }); | |
const handle = app.getRequestHandler(); | |
const port = process.env.APP_PORT || 8080; | |
app.prepare().then(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Replacing domain for rest api requests from Gutenberg editor if youre using | |
* WP headless and WP_SITEURL & WP_HOME are not the same domain | |
* (has nothing to do with yoast) | |
*/ | |
add_filter('rest_url', function($url) { | |
$url = str_replace(home_url(), site_url(), $url); | |
return $url; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NextRequest, NextResponse } from "next/server"; | |
export function middleware(req: NextRequest) { | |
// PRIMARY_DOMAIN should be a full URL including protocol, e.g. https://www.google.com | |
const hasEnvVariable = !!process.env.PRIMARY_DOMAIN; | |
const isDevelopment = process.env.NODE_ENV === "development"; | |
if (!hasEnvVariable) { | |
!isDevelopment && | |
console.error( |