Skip to content

Instantly share code, notes, and snippets.

@ChrisHPZ
ChrisHPZ / functions.php
Last active August 5, 2021 14:34
Media: Introduce image_editor_output_format filter
<?php
function my_theme_setup() {
add_image_size( 'image-size-class', 1280, 720, true );
}
add_action( 'after_setup_theme', 'my_theme_setup' );
function my_theme_wp_image_editor_output_format( $formats ) {
$formats['image/jpg'] = 'image/webp';
return $formats;
@ChrisHPZ
ChrisHPZ / graphqlRequest.js
Created October 29, 2023 12:50
GraphQL Request
export async function graphqlRequest(query) {
const url = "removed-for-security";
const headers = { 'Content-Type' : 'application/json' };
const res = await fetch(url, {
headers,
method: 'POST',
body: JSON.stringify(query)
});
const resJson = await res.json();
@ChrisHPZ
ChrisHPZ / posts.js
Created October 29, 2023 12:52
Advanced Custom Fields Query
import { graphqlRequest } from "./graphqlRequest";
export async function getContactInfo() {
const query = {
query:`
query acfContactInfo {
aCFOptions {
optionsFields {
contactText
emailAddress
@ChrisHPZ
ChrisHPZ / footerContactRow.js
Created October 29, 2023 12:54
Component where returned prop fails
import { getContactInfo } from "../lib/posts";
import footerContactStyles from "../styles/footerContactRow.module.css";
export async function getStaticProps() {
const contactInfo = await getContactInfo();
return {
props: {
contactInfo: contactInfo
}