Skip to content

Instantly share code, notes, and snippets.

Avatar
🌻

Peter Wilson peterwilsoncc

🌻
View GitHub Profile
View remove-orderby-when-counting-comments.php
<?php
/**
* Plugin Name: Remove orderby when counting comments.
*/
namespace PWCC\Test58368;
/**
* Remove orderby when counting comments.
*
@peterwilsoncc
peterwilsoncc / safe-css-featured-image-block-fix.php
Last active October 26, 2022 01:51
Fix object-fit/featured image block bug introduced in WP 6.0.3
View safe-css-featured-image-block-fix.php
View an-unsplit-term.php
<?php
/**
* Prevent the term splitting job from being fired.
*/
add_filter(
'pre_schedule_event',
function( $pre, $event ) {
if ( $event->hook === 'wp_split_shared_term_batch' ) {
return false;
@peterwilsoncc
peterwilsoncc / backport.sh
Created May 20, 2022 00:22
Backport a WP commit without having to check out the entire repo.
View backport.sh
#!/bin/bash
# Based on https://gist.github.com/johnbillion/22dcc4ae736a3e8d022c
# Modifications
# - Uses the format recommended in the handbook
# - Pulls the current branch from `svn info` rather than using the directory basename
#
# Note: The commit message created will need some edits:
# - move the merges line between props and the ticket reference
# - add the username of the person who provided dev-review if required
@peterwilsoncc
peterwilsoncc / .htaccess
Last active April 10, 2022 00:27
Root directory of WP sub-directory install.
View .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@peterwilsoncc
peterwilsoncc / 40878.php
Created November 8, 2021 00:08
Notes for WP ticket #40878
View 40878.php
<?php
register_post_type(
'nav_menu_item',
[
// Unlisted items remain unchanged.
'map_meta_cap' => true,
'capabilities' => [
// Meta Capabilities.
'edit_post' => 'edit_post',
@peterwilsoncc
peterwilsoncc / composer.json
Last active October 18, 2021 01:08
Using WP.org MVP sniffs in a project.
View composer.json
{
"name": "awesomemotive/seedprod-plugins",
"type": "project",
"require-dev": {
"wordpress/wporg-code-analysis": "1.0.0"
},
"scripts": {
},
"repositories": [
{
View 48556-testing-plugin.php
<?php
/**
* A testing plugin for trac ticket #48556.
*
* As a testing plugin, this includes a nasty hack to allow for easily
* viewing WP_Query dumps.
*
* **THIS SHOULD NEVER BE RUN ON A PUBLIC FACING SITE**
*/
namespace Trac\WPQ_Update;
View metaboxes.php
<?php
namespace PWCC;
/**
* Register meta box(es).
*/
function wpdocs_register_meta_boxes() {
add_meta_box( 'meta-box-id', __( 'My Meta Box', 'textdomain' ), __NAMESPACE__ . '\\wpdocs_my_display_callback', 'post' );
}
View plugin-header-check.yaml
name: Version checks
on:
push:
branches:
- master
pull_request:
jobs:
# Compares the header information in the readme.txt and the main plugin file