Skip to content

Instantly share code, notes, and snippets.

@pattyok
pattyok / editor.js
Last active May 23, 2023 15:52
WordPress Block Transform from ACF Repeater Block
/** Transform from an ACF block with repeating rows, to a custom block with child blocks
the content field on the ACF Block is a WYSIWIG Editor so we translate it to RAW HTML and pass it as inner blocks to the new accordion panel **/
wp.hooks.addFilter(
'blocks.registerBlockType',
'local27/accordion-transform',
function( settings, name ) {
if ( name === 'acf/accordion' ) {
settings.transforms = {
to: [
@pattyok
pattyok / loaders.js
Last active April 6, 2022 07:37
Webpack Config
const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const FileLoader = {
test: /\.(png|jpe?g|gif)$/i,
type: 'asset/resource',
};
@pattyok
pattyok / functions.php
Last active February 1, 2022 23:06
Add Background Support to Cover Block
add_filter( 'block_type_metadata_settings', 'filter_metadata_registration', 10, 2 );
public function filter_metadata_registration( $settings, $metadata ) {
if ( 'core/cover' == $metadata['name'] ) {
if ( is_array( $settings['supports']['color'] ) ) {
$settings['supports']['color']['background'] = true;
} else {
$settings['supports']['color'] = array(
@pattyok
pattyok / theme.json
Created July 12, 2021 23:03
Theme.json WordPress
{
"version": 1,
"settings": {
"color": {
"custom": false,
"customGradient": false,
"link": false,
"gradients": [],
"duotone": [],
"palette": [
@pattyok
pattyok / index.js
Created March 16, 2020 22:06
New Block
import edit from './edit';
import { registerBlockType } from '@wordpress/blocks';
import {__} from '@wordpress/i18n';
registerBlockType("mytheme-blocks/firstblock", {
title: __("First Block", "mytheme-blocks"),
description: __("Our first block", "mytheme-blocks"),
category: "layout",
icon: "admin-network",
@pattyok
pattyok / functions.php
Created November 22, 2019 23:20
WordPress: When you want to pull in existing records from SalesForce via object-sync-to-salesforce
<?php
//Add this to your functions file TEMPORARILY (just long enough to do the first sync), then remove
add_filter( 'object_sync_for_salesforce_pull_query_modify', __NAMESPACE__ . '\\change_pull_query', 10, 4 );
// can always reduce this number if all the arguments are not necessary
function change_pull_query( $soql, $type, $salesforce_mapping, $mapped_fields ) {
$soql->conditions[0]['value'] = '2015-11-22T22:49:09Z';//change this date to early enough to capture your records
return $soql;
@pattyok
pattyok / us_states.md
Last active November 15, 2019 19:15
ACF State Selector

Click Raw and Copy into the Select field

AL : Alabama AK : Alaska AZ : Arizona AR : Arkansas CA : California CO : Colorado CT : Connecticut DE : Delaware

@pattyok
pattyok / runphp.sh
Created November 2, 2019 17:40
Run PHP server on Mac
php -S 127.0.0.1:8080
@pattyok
pattyok / .eslintrc.json
Last active April 28, 2020 22:05
WordPress Coding Standards Setup
{
"extends": [
"plugin:@wordpress/eslint-plugin/recommended"
]
}
@pattyok
pattyok / taxonomy_filter.php
Last active July 19, 2019 14:30
WordPress: Create taxonomy filter for post admin screen
add_action( 'restrict_manage_posts', 'dated_pubs_table_filtering', 10, 2 );
function dated_pubs_table_filtering( $post_type, $which ) {
if ( 'dated_publications' === $post_type ) {
// A list of taxonomy slugs to filter by.
$taxonomies = array( 'dated_pub_type' );
foreach ( $taxonomies as $taxonomy_slug ) {
// Retrieve taxonomy data.
$taxonomy_obj = get_taxonomy( $taxonomy_slug );