Skip to content

Instantly share code, notes, and snippets.

View soderlind's full-sized avatar

Per Søderlind soderlind

View GitHub Profile
<?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 July 27, 2024 12:00
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';
@soderlind
soderlind / README.md
Last active March 16, 2021 22:57
WP Ajax transient demo.
@soderlind
soderlind / expect-header-fix.php
Created March 10, 2021 23:17 — forked from carlalexander/expect-header-fix.php
WordPress "Expect" header fix
<?php
/**
* By default, cURL sends the "Expect" header all the time which severely impacts
* performance. Instead, we'll send it if the body is larger than 1 mb like
* Guzzle does.
*/
function add_expect_header(array $arguments)
{
$arguments['headers']['expect'] = !empty($arguments['body']) && strlen($arguments['body']) > 1048576 ? '100-Continue' : '';
@soderlind
soderlind / .codeclimate.yml
Created November 24, 2020 19:14
codeclimate config file for WordPress projects
---
engines:
csslint:
enabled: true
duplication:
enabled: true
config:
languages:
- javascript
- php
@soderlind
soderlind / functions.php
Created May 5, 2020 23:39
custom logo in wp-login.php
// Add CSS within in wp-login, place in (child) theme functions.php
add_action('login_enqueue_scripts', function(){
wp_enqueue_style('login-styles', get_stylesheet_directory_uri().'/login.css');
});