Skip to content

Instantly share code, notes, and snippets.

// initial page load's url
// Change port number to your local WP instance.
function url() {
return "http://localhost:4759/wp-admin/site-editor.php?postType=wp_template&postId=twentytwentytwo%2F%2Ffront-page";
}
// The setup method doesn't seem to get called
// async function setup(page) {
// await page.$eval("#user_login", (el) => (el.value = "admin"));
// await page.$eval("#user_pass", (el) => (el.value = "password"));
// await page.click("#wp-submit");
@glendaviesnz
glendaviesnz / range-mark-changes.css
Created July 18, 2022 03:02
Changes to make a range control segmented
.components-range-control__mark {
height: 4px;
width: 3px;
background-color: #ffffff;
z-index: 1;
}
.components-range-control__marks {
margin-top: 17px;
}
@glendaviesnz
glendaviesnz / cover-styles.css
Created January 31, 2022 01:46
Missing styles for Cover block in 5.9
.wp-block-cover-image.has-background-dim.has-background-dim-10:not(.has-background-gradient)::before,
.wp-block-cover-image.has-background-dim.has-background-dim-10 .wp-block-cover__gradient-background,
.wp-block-cover.has-background-dim.has-background-dim-10:not(.has-background-gradient)::before,
.wp-block-cover.has-background-dim.has-background-dim-10 .wp-block-cover__gradient-background {
opacity: 0.1;
}
.wp-block-cover-image.has-background-dim.has-background-dim-20:not(.has-background-gradient)::before,
.wp-block-cover-image.has-background-dim.has-background-dim-20 .wp-block-cover__gradient-background,
.wp-block-cover.has-background-dim.has-background-dim-20:not(.has-background-gradient)::before,
.wp-block-cover.has-background-dim.has-background-dim-20 .wp-block-cover__gradient-background {
@glendaviesnz
glendaviesnz / docker-compose.yml
Created September 3, 2021 04:01
Basic WordPress docker compose file
version: '3.7'
services:
mysql:
image: mariadb
ports:
- '3306'
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
volumes:
@glendaviesnz
glendaviesnz / transform-v1-gallery.js
Created July 16, 2021 02:57
V1 gallery - v2 gallery transform
@glendaviesnz
glendaviesnz / index.js
Created June 15, 2021 03:56
Image size control with custom hook for dimension handling
/**
* External dependencies
*/
import { isEmpty, noop } from 'lodash';
/**
* WordPress dependencies
*/
import {
Button,
@glendaviesnz
glendaviesnz / useDimensionHandler.js
Created June 15, 2021 03:53
Draft image dimensions hood
**
* WordPress dependencies
*/
import { useEffect, useState } from '@wordpress/element';
export default function useDimensionHander(
defaultWidth,
customWidth,
defaultHeight,
customHeight,
@glendaviesnz
glendaviesnz / gallery-v2-deprecations.js
Created May 21, 2021 03:54
Gutenberg Gallery Block Refactor Deprecations
@glendaviesnz
glendaviesnz / gallery-block-transform-filter.php
Last active May 12, 2021 01:30
Gutenberg Gallery Block Refactor - Transform Back to Unordered List
export function httpUpload(file) {
return Observable.create((observer) => {
var config = {
onUploadProgress: (progressEvent) => {
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
observer.next({ progress: percentCompleted });
}
};
axios.post(`${appConfig.apiUrl}/upload`, file, config)
.then((response) => {