Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

{
"core": null,
"plugins": [
"https://downloads.wordpress.org/plugin/woocommerce.zip"
],
"config": {
"WP_DEBUG": true,
"SCRIPTS_DEBUG": true,
"WP_DEBUG_LOG": false,
"WP_DEBUG_DISPLAY": true
@Clorith
Clorith / disable-fullscreen-snippet.php
Last active February 17, 2022 00:32
Quick drop-in snippet to disable the default full-screen editing mode and welcome guide in WordPress when a user first visits the edit interface.
<?php
function wp378934573289_js_head_print() {
$screen = get_current_screen();
// Only add script in editor views.
if ( 'edit' !== $screen->parent_base ) {
return;
}
?>
@Clorith
Clorith / remove-super-admins.php
Created June 16, 2021 18:12
A script to be used with WP-CLI's `wp eval-file` to remove super-admins from all sub-sites in a network (except the primary site in the network when applicable).
<?php
// Fetch all superadmins on a site.
$super_admins = get_super_admins();
// Loop over all super admins
foreach ( $super_admins as $admin_slug ) {
// Get a user object for this user.
$user = get_user_by( 'slug', $admin_slug );
// Fail-safe, maybe the slug somehow couldn't be identified.
@Clorith
Clorith / options.html
Last active October 16, 2018 20:32
WordPress.org plugins topic highlighter
<form id="tamper-wp-topic-highlighter">
<hr>
<strong>Topics older than 1 week with no resolution</strong>
<br>
<div style="display: inline-block; width: 30%;">Background: </div>
<div style="display: inline-block;"><input type="text" id="tamper-wp-topic-highlighter-old" value="#ffc173" style="padding: 0 5px;"></div>
<br>
<div style="display: inline-block; width: 30%;">Text: </div>
<div style="display: inline-block;"><input type="text" id="tamper-wp-topic-highlighter-old-text" value="inherit" style="padding: 0 5px;"></div>
@Clorith
Clorith / functions.php
Created March 10, 2017 14:04
Override page templates in WordPress
<?php
/*
* Override the template engine when it's looking for a themes templates files, and output our own one instead
*/
add_filter( 'page_template','maybe_hijack_page' );
function maybe_hijack_page( $template ) {
// Check the page ID and hijack if it's ID 50, this can be any conditional!
if ( get_the_ID() == 50 ) {
@Clorith
Clorith / alsoviewing.meta.js
Last active March 22, 2020 04:36
WordPress.org also-viewing for the forums
// ==UserScript==
// @name WordPress.org Also Viewing
// @namespace http://jason.stallin.gs
// @description See when another person is viewing the same post.
// @author Clorith
// @grant none
// @include https://*.wordpress.org/support/topic/*
// @include https://*.wordpress.org/support/view/*
// @include https://wordpress.org/support/topic/*
// @include https://wordpress.org/support/view/*
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WordPress Rule" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
@Clorith
Clorith / plugin.php
Created December 11, 2015 15:22
Encourage your users to submit translations for your WordPress plugin
<?php
function language_detector_admin_notices() {
// Get the current language locale
$language = get_locale();
// Check if the nag screen has been disabled for this language
if ( false === get_option( 'plugin_slug_language_detector_' . $language, false ) ) {
// Check if a translation file already exists for this language
if ( $loaded = load_plugin_textdomain( 'text_domain', false, plugin_dir_path( __FILE__ ) . '/languages/' ) ) {
/**
* Load more content over ajax in a nice manner
*
* This script utilizes Font Awesome to give proper visual feedback
* while the new content is being fetched and loaded
*
* Usage:
* - Attach the class 'load-more-content' to any a tag in the DOM
* - Give this object a data attribute of data-content-area which indicates
* what part of the site is to be loaded in
@Clorith
Clorith / load-more-content.js
Last active October 21, 2021 11:06
jQuery script for loading more content over ajax.
/**
* Load more content over ajax in a nice manner
*
* This script utilizes Font Awesome to give proper visual feedback
* while the new content is being fetched and loaded
*
* Usage:
* - Attach the class 'load-more-content' to any a tag in the DOM
* - Give this object a data attribute of data-content-area which indicates
* what part of the site is to be loaded in