Skip to content

Instantly share code, notes, and snippets.

View flexseth's full-sized avatar

Seth Miller flexseth

View GitHub Profile
@flexseth
flexseth / import-users.xml
Created March 30, 2024 21:00
Import two "new" users to WordPress
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
@flexseth
flexseth / FetchSample.jsx
Created March 12, 2022 17:37
useEffect WordPress API Fetch hook - initialize data from Users
// Note: the empty deps array [] means
// this useEffect will run once
// similar to componentDidMount()
useEffect(() => {
apiFetch( { path: '/wp/v2/users?roles=author,editor,administrator' } )
.then (
( users ) => {
setIsLoaded(true);
setUsers(users)
@flexseth
flexseth / import-useState.jsx
Created March 9, 2022 23:09
Import useState for WordPress initialization and example
/**
* React hook to manage state as block changes.
* This is used with setAttributes to set block settings
*
* @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-element/#usestate
*/
import { useState } from '@wordpress/element';
@flexseth
flexseth / jetpack-settings.json
Created February 8, 2022 18:54
Jetpack Settings Config
{
"modules": [
{
"publicize": {
"urls": {
"fb": "knotyart",
"instagram": "knotyart",
"twitter": "bestofglass"
},
"autogreet": "Welcome to Knoty Art!",
@flexseth
flexseth / woocommerce-show-cart-thumbnails.php
Created November 8, 2021 01:09
Show thumbnails in the WooCommerce Cart preview
/** MyStyle: Show thumbnail in cart larger than default 32px **/
.woocommerce-cart table.cart img {
width: auto;
min-width: 32px;
max-width: 100px;
}
@media(max-width:768px) {
/** Show thumbnail row in cart on mobile **/
.woocommerce-page table.cart .product-thumbnail {
@flexseth
flexseth / refunds-and-returns-policy-for-wordpress.html
Last active November 6, 2021 20:17
Returns & Refunds Policy Page block pattern for WooCommerce (Gutenberg)
<!-- Add this to the HTML Editor in Gutenberg (not the block editor) -->
<!-- source: https://gist.github.com/flexseth/2564bea3d080ecfa0f4d8e86654d1b5b
<!-- Must be running the Gutenberg plugin for this to work -->
<!-- wp:paragraph -->
<p><b>This is a sample page.</b></p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p></p>
@flexseth
flexseth / disable-rss-in-wordpress.php
Created November 3, 2021 22:23
Disable RSS in WordPress
<?php /* Do NOT include the opening PHP tag
function itsme_disable_feed() {
wp_die( __( 'No feed available, please visit the <a href="'. esc_url( home_url( '/' ) ) .'">homepage</a>!' ) );
}
add_action('do_feed', 'itsme_disable_feed', 1);
add_action('do_feed_rdf', 'itsme_disable_feed', 1);
add_action('do_feed_rss', 'itsme_disable_feed', 1);
add_action('do_feed_rss2', 'itsme_disable_feed', 1);
@flexseth
flexseth / woocommerce-add-to-cart-button.php
Created May 3, 2020 22:16
WooCommerce Add to Cart button modify
<?php
// To change add to cart text on single product page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' );
function woocommerce_custom_single_add_to_cart_text() {
return __( 'Buy Now', 'woocommerce' );
}
// To change add to cart text on product archives(Collection) page
add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' );
@flexseth
flexseth / woocommerce-lightboxes.php
Created May 2, 2020 02:34
Add theme support for WooCommerce Lightboxes, Zoom, Other Image Enhancements
<?php
// Add product gallery support.
if ( class_exists( 'WooCommerce' ) ) {
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_theme_support( 'wc-product-gallery-zoom' );
}
@flexseth
flexseth / change-wording-woocommerce-store-notice.php
Last active April 30, 2020 19:44
Change WooCommerce Store Notice (top of page)
<?php
/*
* Change WooCommerce store notice text
*
*/
function fp_replace_dismiss( $notice ){
return str_replace( 'Dismiss', 'X', $notice );
}
add_filter( 'woocommerce_demo_store','fp_replace_dismiss' );