Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Working remotely, as usual

Adam Silverstein adamsilverstein

💭
Working remotely, as usual
View GitHub Profile
@adamsilverstein
adamsilverstein / prefer-gd.php
Created Sep 16, 2021
Prefer GD over Imagick when choosing the default image editor.
View prefer-gd.php
<?php
/**
* Prefer GD over Imagick.
*
* @wordpress-plugin
* Plugin Name: Prefer GD over Imagick.
* Description: Switches the default image editor choice order.
* Plugin URI:
* Version: 1.0.0
* Author: Adam Silverstein, Google
View multisite upload filetypes filter.php
<?php
// Ensure all network sites include WebP support.
add_filter(
'site_option_upload_filetypes',
function ( $filetypes ) {
$filetypes = explode( ' ', $filetypes );
if ( ! in_array( 'webp', $filetypes, true ) ) {
$filetypes[] = 'webp';
$filetypes = implode( ' ', $filetypes );
}
View Site Kit - LogApi requests.diff
diff --git a/includes/Core/Authentication/Clients/OAuth_Client.php b/includes/Core/Authentication/Clients/OAuth_Client.php
index 3039cc9d0..a08b2e4a4 100644
--- a/includes/Core/Authentication/Clients/OAuth_Client.php
+++ b/includes/Core/Authentication/Clients/OAuth_Client.php
@@ -229,18 +229,50 @@ final class OAuth_Client {
// Enable exponential retries, try up to three times.
$client->setConfig( 'retry', array( 'retries' => 3 ) );
+ $client->setLogger(new class implements \Google\Site_Kit_Dependencies\Psr\Log\LoggerInterface {
+ public function emergency($message, array $context = array()) {
View url-change-compat.php
<?php
/**
* Ensures Site Kit URL Change compatibility.
*
* @wordpress-plugin
* Plugin Name: Site Kit URL Change compatibility
* Description: Ensures Site Kit URL Change compatibility.
* Plugin URI:
* Version: 1.0.0
* Author: Adam Silverstein, Google
View post.json
{
id: 63,
date: "2020-11-05T22:17:57",
date_gmt: "2020-11-05T22:17:57",
guid: {
rendered: "http://wpdev.localhost/?p=63"
},
modified: "2020-11-05T22:17:57",
modified_gmt: "2020-11-05T22:17:57",
slug: "welcome-to-the-gutenberg-editor",
View google-site-kit-language-loader.php
<?php
/**
* Ensures Site Kit loads languages correctly.
*
* @author Adam Silverstein, Google
* @license Apache 2.0
* @copyright 2020 Google Inc.
*
* @wordpress-plugin
* Plugin Name: Site Kit Language Loader
View pass-author-name.diff
diff --git a/lib/rest-api.php b/lib/rest-api.php
index 8ad8653091..72944e6d79 100644
--- a/lib/rest-api.php
+++ b/lib/rest-api.php
@@ -52,6 +52,25 @@ function gutenberg_filter_oembed_result( $response, $handler, $request ) {
}
add_filter( 'rest_request_after_callbacks', 'gutenberg_filter_oembed_result', 10, 3 );
+add_action( 'rest_api_init', function() {
+ global $post;
View gist:712dae49f0df58f0204c32e171b68e5c
<?php
/**
* Ensures Site Kit WPML compatibility.
*
* @wordpress-plugin
* Plugin Name: Fix Site Kit WPML compatibility
* Description: Ensures Site Kit WPML compatibility.
* Plugin URI:
* Version: 1.0.0
* Author: Adam Silverstein, Google
View tests.diff
diff --git a/packages/editor/src/components/post-author/index.js b/packages/editor/src/components/post-author/index.js
index bdd9c30596..623a0ad82b 100644
--- a/packages/editor/src/components/post-author/index.js
+++ b/packages/editor/src/components/post-author/index.js
@@ -17,8 +17,7 @@ import { compose, withInstanceId } from '@wordpress/compose';
*/
import PostAuthorCheck from './check';
-function PostAuthor( { authors, postAuthor, onUpdateAuthor } ) {
-
View site-monitoring-app-script.js
// Created by Adam Silverstein, based on original work by Rick Viscomi (@rick_viscomi)
// Adapted from https://ithoughthecamewithyou.com/post/automate-google-pagespeed-insights-with-apps-script by Robert Ellison
// @copyright 2020 Google LLC
var scriptProperties = PropertiesService.getScriptProperties();
var pageSpeedApiKey = scriptProperties.getProperty('PSI_API_KEY');
function queueAllDomains() { {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadsheet.getSheetByName('Alerts');