Skip to content

Instantly share code, notes, and snippets.

View soderlind's full-sized avatar

Per Søderlind soderlind

View GitHub Profile
@soderlind
soderlind / README.md
Last active January 23, 2024 16:06
WordPress Playground blueprint for a block plugin.

Live Preview for Jobbnorge Block

Plugin Previews are now available for opt-in, I've added a live preview to my block plugin

On wordpress.org, there are two things required for a plugin preview button to appear to all users:

  1. A valid blueprint.json file must be provided in the plugins assets/blueprints sub-directory.
  2. The plugin preview must be set to “public” from the plugin’s Advanced view by a committer.

Read the blueprint documentation for more information.

@soderlind
soderlind / afd-housekeeping.md
Last active December 19, 2023 03:21
Me talking with Copilot Chat

@soderlind: I need a bash script that read a list of domains from disk and use az cli to remove the domains from azure front door. I have several azure front doors in the resource group.

GitHub Copilot: Here's a step-by-step plan for the bash script:

  1. Define the script shebang to specify that the script should be run using bash.
  2. Read the file line by line using a while loop.
  3. Inside the loop, use the az network front-door frontend-endpoint delete command to delete the domain from each Azure Front Door in the resource group.
  4. The command requires the names of the resource group, the Front Door, and the endpoint (domain). You'll need to loop over each Front Door in the resource group.
  5. To get the list of Front Doors, use the az network front-door list command with the resource group name.
  6. Parse the output of the list command to extract the names of the Front Doors.
@soderlind
soderlind / hardcode-number-of-items.php
Created August 28, 2023 08:27
WordPress Admin: Hardcode max number of items per page.
<?php
/**
* name
*
* @package Soderlind\MuPlugins\HardcodeNumberOfItems
* @author Per Soderlind
* @copyright 2021 Per Soderlind
* @license GPL-2.0+
*
@soderlind
soderlind / plausible-2f-fix.php
Last active May 25, 2023 09:53
Fix for Plausible Analytics %2f removal from shard link
<?php
/**
* Plugin Name: Plausible 2f Fix
* Description: Fix for Plausible Analytics %2f removal from shard link.
* Plugin URI: https://gist.github.com/soderlind/6d6735baeab379b4d7e1e5497cd8581b
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
declare( strict_types = 1 );
<?php
add_action( 'muplugins_loaded',function() : void {
$my_rest_endpoint = '/wp-json/super-admin-all-sites-menu/v1/sites/';
$request_uri = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
/**
* Bail if not the correct request.
*/
@soderlind
soderlind / mu-super-admin-all-sites-menu.php
Last active April 7, 2022 11:37
Fast REST Response for Super Admin All Sites Menu (https://github.com/soderlind/super-admin-all-sites-menu), save in mu-plugins
<?php
/**
* name: Fast REST Response for Super Admin All Sites Menu
*
* @package Soderlind\Multisite\MU
* @author Per Soderlind
* @copyright 2021 Per Soderlind
* @license GPL-2.0+
*
* @wordpress-plugin
@soderlind
soderlind / webpack.config.js
Last active February 28, 2022 16:58
Add a banner to build/index.js, when running "wp-scripts build"
"use strict";
const defaultConfig = require("@wordpress/scripts/config/webpack.config");
const packageJSON = require("./package.json");
const webpack = require("webpack");
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
...defaultConfig,
module: {
...defaultConfig.module,
@soderlind
soderlind / deploy-develop.yml
Last active December 22, 2021 08:59
GitHub Action: Deploy WordPress to Azure Container Registry
name: Development deploy
on:
repository_dispatch:
types: trigger-development-deploy
workflow_dispatch:
push:
branches:
@soderlind
soderlind / example.php
Last active September 25, 2021 20:33
WordPress Multisite, gets all site transient keys in the database with a specific prefix.
<?php
foreach ( get_site_transient_keys_with_prefix( 'my_tranients_prefix_' ) as $transient ) {
delete_site_transient( $transient );
}
@soderlind
soderlind / hardwire-njnjaform-from.php
Created July 5, 2021 21:10
Hardwire Ninja Forms from name and from address.
<?php
/**
* Hardwire Ninja Forms from name and from address.
*/
add_filter( 'ninja_forms_run_action_settings', function ( $action_settings, $form_id, $action_id, $form_settings ) {
if ( 'email' === $action_settings['type'] ) {
$action_settings['from_name'] = 'from name';
$action_settings['from_address'] = 'from@name.tld';