TRADITIONAL | HEADLESS |
---|---|
WP_DEBUG_DISPLAY |
👉 Enable WPGraphQL Debug Mode & inspect response errors |
die() / wp_die() / var_dump() |
👉 wp_send_json() or Enable GraphQL Debug Mode and use graphql_debug() |
Postman/REST client | 👉 Enable GraphiQL IDE |
WP_DEBUG_LOG |
👉 Still works! |
Xdebug on page load | 👉 Xdebug triggered by GraphiQL request in the wp-admin |
Query Monitor | 👉 Enable GraphQL Query Logs |
NewRelic/Profiling tools | 👉 Enable GraphQL Tracing |
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 | |
/** | |
* Set Organization posts to 'private' for unauthenticated users. | |
* | |
* @param boolean $is_private Whether the model is private | |
* @param string $model_name Name of the model the filter is currently being executed in | |
* @param mixed $data The un-modeled incoming data | |
* @param string|null $visibility The visibility that has currently been set for the data at this point | |
* @param null|int $owner The user ID for the owner of this piece of data |
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 fetch = require("node-fetch"); | |
const xml2js = require("xml2js"); | |
const he = require("he"); | |
const TRANSCRIPTION_CHAR_KEY = "transcription"; | |
// Test | |
(async () => { | |
const videoId = "ht14hTTDklA"; // HWPR Pagination video | |
// const videoId = "rB9ql0L0cUQ"; // Video with manually added captions |
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 | |
// Get all tag url paths for sitemap. | |
add_action('graphql_register_types', function () { | |
register_graphql_field('RootQuery', 'getTagUrlPaths', [ | |
'type' => ['list_of' => 'String'], | |
'args' => [ | |
'pageNo' => [ | |
'type' => 'Int', | |
'description' => __('Page number', 'text-domain'), |
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 { gql, useLazyQuery } from "@apollo/client"; | |
import Layout from "../components/Layout"; | |
interface Post { | |
databaseId: number; | |
title: string; | |
}; | |
interface PostEdge { |
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
// Dynamically import an NPM module from dev.jspm.io to try it out. | |
// Run this in your browser console. | |
(async function() { | |
const axios = (await import('https://dev.jspm.io/axios')).default; | |
const response = await axios.get('https://pokeapi.co/api/v2/pokemon/'); | |
console.log(response.data); | |
})(); |
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 React, { Suspense } from "react" | |
import hasMounted from "../hooks/useHasMounted" | |
const SomeNpmPackage = React.lazy(() => import("some-npm-package")) | |
function LazyLoadedComponent() { | |
if (!hasMounted) return null | |
return ( | |
<Suspense fallback={<p>Loading...</p>}> |
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 React, { Suspense } from "react" | |
import hasMounted from "../hooks/useHasMounted" | |
const PWAPrompt = React.lazy(() => import("react-ios-pwa-prompt")) | |
function PWAInstallPrompt() { | |
if (!hasMounted) return null | |
const isMobileChrome = navigator.userAgent.includes("CriOS") |
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 React, { createContext, useContext } from "react" | |
import useSound from "use-sound" | |
import popDownSound from "../sounds/pop-down.mp3" | |
import marioCoinSound from "../sounds/mario-coin.mp3" | |
import applauseSound from "../sounds/applause.mp3" | |
import fanfareSound from "../sounds/fanfare.mp3" | |
const SoundsContext = createContext() |
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 Greeting() { | |
const hasMounted = useHasMounted(); | |
const username = hasMounted ? localStorage.getItem("username") : null; | |
return <p>Welcome back {username}!</p>; | |
} |