Skip to content

Instantly share code, notes, and snippets.

Mark Howells-Mead markhowellsmead

Block or report user

Report or block markhowellsmead

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@markhowellsmead
markhowellsmead / block.jsx
Created Aug 22, 2019
Gutenberg: Starter Block Code
View block.jsx
const { RichText } = wp.blockEditor;
const { _x } = wp.i18n;
wp.blocks.registerBlockType('sht/starter-block', {
title: _x('Starter Block', 'Block title', 'sha'),
icon: 'heading',
category: 'sht/theme',
attributes: {
title: {
type: 'string',
@markhowellsmead
markhowellsmead / block.jsx
Created Aug 20, 2019
Gutenberg: MediaUpload Component (add to InspectorControls)
View block.jsx
const {MediaUpload, MediaUploadCheck} = wp.blockEditor;
<MediaUploadCheck>
<MediaUpload
onSelect={clienticon => {
getLazySrcs(clienticon.id, 'smallsquare').then(clienticon => this.props.setAttributes({clienticon}));
}}
allowedTypes={['image/jpg', 'image/jpeg', 'image/png']}
@markhowellsmead
markhowellsmead / gutenberg-content.txt
Last active Aug 14, 2019
Dummy content for Gutenberg Theme development (from permanenttourist.ch)
View gutenberg-content.txt
<!-- wp:cover {"url":"https://permanenttourist.ch/wp-content/uploads/2019/05/20190502-DSCF7619.jpg","id":45071,"hasParallax":true,"align":"full"} -->
<div class="wp-block-cover alignfull has-background-dim has-parallax" style="background-image:url(https://permanenttourist.ch/wp-content/uploads/2019/05/20190502-DSCF7619.jpg)"><div class="wp-block-cover__inner-container"><!-- wp:heading {"level":1} -->
<h1>WordPress Gutenberg</h1>
<!-- /wp:heading -->
<!-- wp:paragraph {"align":"left","customFontSize":15} -->
<p style="font-size:15px;text-align:left">The Block Unit Tests provide a trial page, which allows you to test the active WordPress Theme and make sure that all of the Gutenberg Blocks work as expected.</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
@markhowellsmead
markhowellsmead / Forms.php
Created Aug 8, 2019
Create user from Gravity Forms submission (incomplete!)
View Forms.php
<?php
/**
* This is only part of a Package for WordPress
* Call function from within a master function which has been hooked to gform_after_submission
*/
private function userFromSubmission($entry, $form)
{
$submitted_email = '';
@markhowellsmead
markhowellsmead / custom_meta_query.php
Last active Jul 26, 2019
WordPress - filter admin results by custom meta date field value
View custom_meta_query.php
<?php
add_filter('parse_query', [$this, 'filterByYear']);
add_action('restrict_manage_posts', [$this, 'yearFilter']);
public function filterByYear($query)
{
global $pagenow, $typenow;
@markhowellsmead
markhowellsmead / set-filter-by-tax.php
Last active Jul 26, 2019 — forked from marushu/set-filter-by-tax.php
Supports multiple filters.
View set-filter-by-tax.php
<?php
add_action('restrict_manage_posts', [$this, 'taxonomyFilter']);
add_filter('parse_query', [$this, 'filterByTaxonomy']);
public function taxonomyFilter()
{
global $typenow;
@markhowellsmead
markhowellsmead / BackgroundImageElement.jsx
Last active Jul 9, 2019
BackgroundImageElement for Gutenberg Block use
View BackgroundImageElement.jsx
/**
* BackgroundImageElement
* Outputs a figure and image for use as a background image (using object-fit
* in CSS - not provided). The HTML output contains the aria attribute
* 'aria-hidden' as background images are purely decorative.
* This version includes LazySizes CSS classes and a NOSCRIPT tag for use
* in projects by sayhello.ch.
*
* { backgroundImage } is a WordPress Image Object
*
@markhowellsmead
markhowellsmead / PostSelector.jsx
Last active Jul 5, 2019
React Component for Gutenberg - Post Selector using `withSelect`
View PostSelector.jsx
const { _x } = wp.i18n;
const { ServerSideRender, PanelBody, SelectControl } = wp.components;
const { select, withSelect } = wp.data;
const { InspectorControls } = wp.editor;
const { Component } = wp.element;
class PostSelector extends Component {
constructor() {
super( ...arguments );
@markhowellsmead
markhowellsmead / block.jsx
Created Jul 1, 2019
React Component for Gutenberg - Post Selector
View block.jsx
const { _x } = wp.i18n;
import { PostSelector } from './components/postselector.jsx';
wp.blocks.registerBlockType('sht/clubgallery-teaser', {
title: _x('Bildergalerie - Teaser', 'Block title', 'sha'),
icon: 'format-gallery',
category: 'sht/flugbasis',
supports: {
align: [
@markhowellsmead
markhowellsmead / block.jsx
Created Jun 27, 2019
Gutenberg: get authors via API and create a mapped HTML list of the results
View block.jsx
// https://developer.wordpress.org/block-editor/packages/packages-core-data/#example
const { withSelect } = wp.data;
function renderAuthorList( { authors } ) {
return (
<ul>
{ authors.map( ( author ) => (
<li key={ author.id }>{ author.name }</li>
) ) }
You can’t perform that action at this time.