Skip to content

Instantly share code, notes, and snippets.

View wpscholar's full-sized avatar
😀
Happy

Micah Wood wpscholar

😀
Happy
View GitHub Profile
@wpscholar
wpscholar / createInterpolateElement.jsx
Created February 14, 2025 14:20
An example of how to use the createInterpolateElement in React to properly translate a string containing HTML or a React component.
// See https://developer.wordpress.org/block-editor/reference-guides/packages/packages-element/#createinterpolateelement
import { __ } from '@wordpress/i18n';
import { createInterpolateElement } from '@wordpress/element';
function MyComponent() {
return createInterpolateElement(
__( 'Please <Link>visit our site</Link> for more info.', 'text-domain' ),
{
Link: <a href="https://example.com" />,
@wpscholar
wpscholar / phpcs.xml
Created February 12, 2025 17:31
PHPCS I18N
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="newfold-module-performance" />
</properties>
</rule>
@wpscholar
wpscholar / order-posts-by-taxonomy.php
Last active September 28, 2024 22:45
Order WordPress posts based on their taxonomy name.
<?php
use WP_Query;
/**
* Class OrderPostsByTaxonomy
*
* @link https://scribu.net/wordpress/sortable-taxonomy-columns.html
*
* Handles the ordering of posts based on their associated taxonomy.
@wpscholar
wpscholar / disable-rankmath-sitemap-caching.php
Created August 31, 2023 21:09
Disable RankMath Sitemap Caching
<?php
/**
* Plugin Name: Disable RankMath Sitemap Caching
*/
add_filter( 'rank_math/sitemap/enable_caching', '__return_false');
@wpscholar
wpscholar / wp-enqueue-scripts.php
Created August 18, 2023 18:07
Example Enqueue
<?php
add_action(
'wp_enqueue_scripts',
function() {
...
}
);
@wpscholar
wpscholar / add-featured-image-to-rss-feed.php
Last active August 16, 2023 14:02
Add the featured image to RSS feed(s)
@wpscholar
wpscholar / woo-add-cart-fee.php
Last active May 10, 2023 01:14
WooCommerce: Add a 4% Credit Card Processing Fee to the Checkout Page
<?php
/**
* WooCommerce Add Fee to the Checkout Page
*
* @package WooCommerceAddFeeToCheckout
* @author Micah Wood
* @copyright Copyright 2023 by Micah Wood - All rights reserved.
* @license GPL2.0-or-later
*
* @wordpress-plugin
@wpscholar
wpscholar / university-customer-role-assignment.php
Last active January 28, 2023 04:20
A WordPress plugin that changes the user role to "University Customer" if a user registers with a .edu email address.
<?php
/**
* University Customer Role Assignment
*
* @package UniversityCustomerRoleAssignment
* @author Micah Wood
* @copyright Copyright 2023 by Micah Wood - All rights reserved.
* @license GPL2.0-or-later
*
@wpscholar
wpscholar / connect-tech-demo.cy
Created November 7, 2022 16:53
A Chrome recording converted into a Cypress test.
describe("Connect.tech Demo", () => {
it("tests Connect.tech Demo", () => {
cy.viewport(952, 976);
cy.visit("https://www.google.com/");
cy.get("body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input").click();
cy.get("body > div.L3eUgb > div.o3j99.ikrT4e.om7nvf > form > div:nth-child(1) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input").type("seo");
@wpscholar
wpscholar / connect-tech-demo.json
Created November 7, 2022 16:51
A Chrome recording that can be downloaded and replayed in the browser.
{
"title": "Connect.tech Demo",
"steps": [
{
"type": "setViewport",
"width": 952,
"height": 976,
"deviceScaleFactor": 1,
"isMobile": false,
"hasTouch": false,