Skip to content

Instantly share code, notes, and snippets.

const Home: NextPage = () => {
const { data, loading } = useQuery(GET_PRODUCTS)
return loading ? 'Loading...' : <ProductList products={data.getAllProducts.data} /> ;
}
<?php
get_header();
$term = get_queried_object();
$term_children = get_term_children($term->term_id, $term->taxonomy);
$has_children = !is_wp_error($term_children) && ! empty( $term_children );
$term_title = single_term_title();
$term_description = term_description();
@igmoweb
igmoweb / bootstrap.js
Created June 17, 2021 09:35
WordPress and Altis e2e tests, a proof of concept
import 'core-js/stable';
import 'regenerator-runtime/runtime';
import { get } from 'lodash';
import {
clearLocalStorage,
enablePageDialogAccept,
setBrowserViewport,
loginUser
} from '@wordpress/e2e-test-utils';
<?php
const FIELD_NAME = 'field_name';
add_action( 'rest_api_init', __NAMESPACE__ . '\\register_api_fields' );
function register_api_fields() {
register_rest_field(
'post',
FIELD_NAME,
// Always run
useEffect( () => {
// code to run
} );
// As componentDidMount (run once)
useEffect( () => {
// code to run
}, [] );
@igmoweb
igmoweb / sample-pricing-table.html
Created August 27, 2020 08:58
A very basic one
<table>
<tr>
<th class="superhead">Spectrum</th>
<th class="superhead">Spectrum</th>
<th class="superhead">Spectrum</th>
</tr>
<tr>
<th>hsjflhewf jewh fkwefhdjf</th>
<th></th>
<th></th>
import { InspectorControls } from '@wordpress/block-editor';
import { PanelBody } from '@wordpress/components';
const BlockSettings = () => {
return <InspectorControls>
<PanelBody
title="My panel body"
>
Hello world
</PanelBody>
# from WP Slack:
# If you’re wanting to know whether a feature is in a version of WordPress that you support, one option is to go to the WordPress develop github mirror, select a branch corresponding to a WordPress version, and then look at the package.json file for that version to see what @wordpress/* package versions are in that release.
.boxed {
vertical-align: baseline;
border: 1px solid #ec8777;
background: linear-gradient(to right, #e5a98c, #f5a593, #f7a6a0);
border-radius: 4px;
padding: 3px 7px;
}
import './style.scss';
const { toggleFormat, registerFormatType } = wp.richText;
const { RichTextToolbarButton } = wp.blockEditor;
const formatName = 'igmoweb/boxed-format';
const formatTitle = 'Boxed';
const BoxedButton = ( { onChange, value, isActive } ) => {
const toggleBoxedFormat = () => {