Skip to content

Instantly share code, notes, and snippets.

View paulgibbs's full-sized avatar

Paul Wong-Gibbs paulgibbs

View GitHub Profile
@paulgibbs
paulgibbs / my-plugin.php
Created November 26, 2024 11:30
put Xprofile fields into a Group (BuddyPress)
<?php
// Increment used to store xprofile data for a user ID that's unlikely to exist.
const GROUP_USER_ID_INCREMENT = 1000000;
/**
* Add xprofile profile fields to a BuddyPress Group.
*/
class Groups_Extension_Profile_Fields extends \BP_Group_Extension
{
@paulgibbs
paulgibbs / gist:70b9f26bdf20d04440098aec36b46fe6
Created October 14, 2024 12:33
Gutenberg ServerSideRendered block
<div {...useBlockProps()}>
<Disabled>
<ServerSideRender
skipBlockSupportAttributes
block="my/nlock"
attributes={attributes}
/>
</Disabled>
</div>
@paulgibbs
paulgibbs / gist:6f2a944552fc9bfbd7e530f150362a8f
Last active August 19, 2024 09:49
Cloudflare reverse proxy via workers - generated by ChatGPT
export default {
async fetch(request, env, ctx) {
return handleRequest(request)
}
}
async function handleRequest(request) {
const url = new URL(request.url)
if (url.pathname.startsWith('/app2/')) {
@paulgibbs
paulgibbs / lighthouse.yml
Last active June 9, 2023 19:04
Indigo Tree LHCI
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
name: Run Lighthouse checks
on:
workflow_dispatch:
push:
branches:
- main
schedule:
- cron: "12 2 * * *"
<?php
function pggh_post_type_filter( $use_block_editor, $post_type ) {
if ( 'page' === $post_type ) {
return false;
}
return $use_block_editor;
}
add_filter( 'use_block_editor_for_post_type', 'pggh_post_type_filter', 10, 2 );
cy
.window()
.its('wp')
.then(wp => {
wp.blocks.getBlockTypes().forEach(({ name }) => {
wp.data.dispatch('core/editor').insertBlocks( wp.blocks.createBlock(name, {}) );
});
});
@paulgibbs
paulgibbs / old.php
Created July 2, 2020 13:56
php generators example
<?php
/**
* Plugin Name: Paul Test
*/
namespace PaulGibbs;
use Generator;
use WP_Query;
@paulgibbs
paulgibbs / Paul.php
Created March 4, 2020 13:36
replace a taxonomy template with a rendered post template
<?php
/**
* Plugin Name: Render a specific Post on a Taxonomy archive page.
* Plugin Author: Paul Gibbs.
* License: public domain
*/
namespace paul;
use WP_Post;
{"version":1,"resource":"file:///Users/paulgibbs/Sites/platform/my-platform/.gitignore","entries":[{"id":"TIY3","timestamp":1650021010387}]}
<?php
/**
* Hello World.
*/
namespace HelloWorld;
$_tests_dir = getenv( 'WP_TESTS_DIR' ) ?: getenv( 'WP_PHPUNIT__DIR' );
require_once $_tests_dir . '/includes/functions.php';