Skip to content

Instantly share code, notes, and snippets.

View djcowan's full-sized avatar

djcowan djcowan

View GitHub Profile
@djcowan
djcowan / .tsconfig
Last active August 27, 2024 00:20
Wordpress Block Typescript
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"checkJs": true,
"allowSyntheticDefaultImports": true,
"jsx": "preserve",
"target": "esnext",
"module": "esnext",
@djcowan
djcowan / variations.tsx
Last active September 19, 2024 11:30
Wordpress BlockVariation Array<BlockVariation> Type
import { RiCellphoneLine, RiCheckboxLine, RiUserFollowLine, RiCheckLine, RiCalendarLine, RiPhoneLine, type RemixiconComponentType, } from '@remixicon/react';
import type { BlockVariation } from "@wordpress/blocks";
const variations: Array<BlockVariation> = [
{
isDefault: true,
scope: [ 'inserter', 'transform' ],
@djcowan
djcowan / wp-extend-gutenberg.js
Created July 6, 2024 12:29 — forked from jeremyphillips/wp-extend-gutenberg.js
Extend Wordpress Gutenberg blocks via React
const { __ } = wp.i18n;
const { addFilter } = wp.hooks;
const { createHigherOrderComponent } = wp.compose;
const { Fragment, cloneElement } = wp.element;
const { InspectorControls } = wp.editor;
const { PanelBody, ToggleControl } = wp.components;
const blockHasParent = ( clientId ) => clientId !== wp.data.select( 'core/editor' ).getBlockHierarchyRootClientId( clientId );
// Filter supports props
addFilter(
@djcowan
djcowan / laravel_valet_setup.md
Created April 25, 2024 06:41 — forked from bradtraversy/laravel_valet_setup.md
Laravel Valet install on mac

Laravel Valet Setup (Mac)

This will get you setup with Laravel & Valet on your Mac. Quentin Watt has a good video tutorial on getting setup here as well

Install Homebrew

Go to https://brew.sh/ and copy the command and run in your terminal

It will be something like this...

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
/*
* @link <https://wordpress.org/support/topic/left-and-right-image-alignment-issues-with-fse-themes/>
* @author https://wordpress.org/support/users/jharries/
* @todo widewidth...
*/
@media only screen and (min-width : 768px) {
.is-layout-constrained figure.wp-block-image.alignleft {
margin-left: calc( ( 100% - var(--wp--style--global--content-size)) / 2 );
}
@djcowan
djcowan / example-wp-list-table.php
Created March 31, 2024 05:40 — forked from paulund/example-wp-list-table.php
An example code of using the WP_List_Table class. With Pagination.
<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/
@djcowan
djcowan / function.php
Created February 23, 2024 08:08 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
<?php
# SHORTS
# DIRECTORY SEPARATOR
define( 'DS', DIRECTORY_SEPARATOR );
# PATH SEPARATOR
define( 'PS', PATH_SEPARATOR );
# Absolute path to the WordPress directory.
! defined( 'ABSPATH' )
AND define( 'ABSPATH', dirname( __FILE__ ).DS );
@djcowan
djcowan / wp-config.php
Created August 30, 2023 23:32 — forked from MikeNGarrett/wp-config.php
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@djcowan
djcowan / wp-edit-post-js-after.js
Created May 30, 2023 01:47
wp-edit-post-js-after
<script id="wp-edit-post-js-after">
( function() {
window._wpLoadBlockEditor = new Promise( function( resolve ) {
wp.domReady( function() {
resolve( wp.editPost.initializeEditor( 'editor', "page", 8, {"alignWide":false,"allowedBlockTypes":true,"allowedMimeTypes":{"jpg|jpeg|jpe":"image\/jpeg","png":"image\/png","gif":"image\/gif","webp":"image\/webp","mov|qt":"video\/quicktime","avi":"video\/avi","mpeg|mpg|mpe":"video\/mpeg","3gp|3gpp":"video\/3gpp","3g2|3gp2":"video\/3gpp2","mid|midi":"audio\/midi","pdf":"application\/pdf","doc":"application\/msword","docx":"application\/vnd.openxmlformats-officedocument.wordprocessingml.document","docm":"application\/vnd.ms-word.document.macroEnabled.12","pot|pps|ppt":"application\/vnd.ms-powerpoint","pptx":"application\/vnd.openxmlformats-officedocument.presentationml.presentation","pptm":"application\/vnd.ms-powerpoint.presentation.macroEnabled.12","odt":"application\/vnd.oasis.opendocument.text","ppsx":"application\/vnd.openxmlformats-officedocument.presentationml.s