Skip to content

Instantly share code, notes, and snippets.

View bhubbard's full-sized avatar
:octocat:
Hello

Brandon Hubbard bhubbard

:octocat:
Hello
View GitHub Profile
@bhubbard
bhubbard / role-scope-listener.php
Created December 10, 2024 21:55
Role-Scoped Listener Pattern • Description: Extends WordPress hooks by allowing specific actions or filters to execute only for users with defined roles or capabilities. Ideal for ensuring role-based access to functionality or modifying content dynamically based on user permissions.
<?php
/**
* Role-Scoped Listener Class
*
* Allows specific WordPress hooks to be executed only for users with designated roles.
*/
class Role_Scoped_Listener {
/**
* The name of the WordPress hook.
*
@bhubbard
bhubbard / adaptive-hook-pattern.php
Created December 10, 2024 21:42
The Adaptive Hook Pattern Concept The Adaptive Hook Pattern is designed for WordPress projects where hooks need to dynamically adjust their behavior based on the context or runtime conditions. Unlike static hooks that always execute the same callback, adaptive hooks allow for flexible responses by modifying the callback logic or even switching t…
<?php
class AdaptiveHook {
private $hookName;
private $callbacks = [];
private $defaultCallback;
public function __construct(string $hookName, callable $defaultCallback) {
$this->hookName = $hookName;
$this->defaultCallback = $defaultCallback;
@bhubbard
bhubbard / scoped-hook-pattern.php
Created December 10, 2024 21:41
The Scoped Hook Pattern is designed for WordPress projects where specific actions or filters should be executed only within a particular scope or context. Unlike traditional hooks that execute globally, this pattern allows you to define scoped hooks that trigger only when certain conditions are met (e.g., a specific post type, user role, or admi…
<?php
class ScopedHook {
private $hookName;
private $callback;
private $condition;
public function __construct(string $hookName, callable $callback, callable $condition) {
$this->hookName = $hookName;
$this->callback = $callback;
@bhubbard
bhubbard / cascade_isolation.php
Last active December 10, 2024 21:39
Concept The “Impulse Programming Pattern” is designed for tasks that require a reactive, single-trigger response to changes in application state or environment variables. Unlike traditional observer patterns that continuously monitor state changes, the impulse pattern is event-specific, running a predefined set of actions the moment an impulse (…
<?php
/*
The Cascade Isolation Pattern is designed to manage a chain of dependent operations where the execution of each step in the chain is isolated from the others unless explicitly passed a “success state.” This pattern ensures that downstream operations in a chain won’t execute unless the preceding steps complete successfully.
This is particularly useful in applications requiring tightly controlled workflows, like multi-step transaction processing, data pipelines, or sequential validations.
*/
class CascadeStep {
private $callback;
<?php
/**
* Plugin Name: WP Cherwell API
* Plugin URI: https://example.com/wp-cherwell-api
* Description: A WordPress plugin that provides an API wrapper for Cherwell.
* Version: 1.0.0
* Author: Your Name
* Author URI: https://example.com
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
<?php
/**
* Plugin Name: WP Gemini API
* Plugin URI: https://example.com/wp-gemini-api
* Description: A WordPress plugin that provides an API wrapper for Gemini.
* Version: 1.0.0
* Author: Your Name
* Author URI: https://example.com
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
<?php
/**
* Plugin Name: WP Things URL Scheme
* Plugin URI: https://example.com/wp-things-url-scheme
* Description: A WordPress plugin that integrates with Things app using its URL Scheme.
* Version: 1.0.0
* Author: Your Name
* Author URI: https://example.com
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
<?php
/**
* Plugin Name: WP Microsoft Outlook API
* Plugin URI: https://example.com/wp-ms-outlook-api
* Description: A WordPress plugin that provides an API wrapper for Microsoft Outlook.
* Version: 1.0.0
* Author: Your Name
* Author URI: https://example.com
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
<?php
/**
* Plugin Name: WP Microsoft Teams API
* Plugin URI: https://example.com/wp-ms-teams-api
* Description: A WordPress plugin that provides an API wrapper for Microsoft Teams.
* Version: 1.0.0
* Author: Your Name
* Author URI: https://example.com
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
<?php
/**
* Plugin Name: WP Figma API
* Plugin URI: https://example.com/wp-figma-api
* Description: A WordPress plugin that provides an API wrapper for Figma.
* Version: 1.0.0
* Author: Your Name
* Author URI: https://example.com
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html