Skip to content

Instantly share code, notes, and snippets.

View kimcoleman's full-sized avatar

Kim Coleman kimcoleman

View GitHub Profile
@kimcoleman
kimcoleman / my_sws_apply_sitewide_sales_discount_to_live_price.php
Last active November 18, 2023 19:11
Sitewide Sales compatibility with RightPress Product Prices - Live Update.
<?php
/**
* Sitewide Sales compatibility with RightPress Product Prices - Live Update.
*/
function my_sws_apply_sitewide_sales_discount_to_live_price($price, $product) {
// Return early if Sitewide Sales is not active.
if ( ! defined ( 'SWSALES_VERSION' ) ) {
return $price;
}
@kimcoleman
kimcoleman / pmpro-tag-delete-inactive-users.php
Last active October 31, 2023 12:06 — forked from ideadude/tag_and_delete_inactive_users.php
Script to tag and delete inactive PMPro Members and users from WordPress.
<?php
/**
* Script to locate, tag, export, then delete inactive users in your Paid Memberships Pro / WordPress website.
*
* Once this snippet is in the site, admins can run the process by visiting /?delete_inactive_users=1 in the WordPress admin.
* Always back up user data before running any bulk delete script and remove this code after the process is done.
*/
function my_pmpro_tag_inactive_users() {
if ( ! defined( 'PMPRO_VERSION' ) ) {
exit;
@kimcoleman
kimcoleman / my_pmpro_has_membership_access_on_date.php
Last active October 30, 2023 11:36
Filter to only allow access to a protected post by post ID after a specific calendar date.
<?php
/**
* Filter to only allow access to a protected post by post ID after a specific calendar date.
*/
function my_pmpro_has_membership_access_on_date( $hasaccess, $post, $user ) {
// If they already don't have access, return.
if ( ! $hasaccess ) {
return $hasaccess;
}
@kimcoleman
kimcoleman / my-custom-page-template.php
Created October 27, 2023 11:33
An example template that uses the pmpro_has_membership_access function to protect content.
<?php
/**
* Template Name: My Custom Template
*
* An example template that uses the pmpro_has_membership_access function to protect content.
*
*/
get_header(); ?>
@kimcoleman
kimcoleman / add-credit-card-image-to-checkout.php
Last active October 12, 2023 20:10 — forked from andrewlimaza/add-credit-card-image-to-checkout.php
Display credit card logos before the submit button on the Paid Memberships Pro Membership Checkout page.
<?php
/**
* Display credit card logos before the submit button on the Paid Memberships Pro Membership Checkout page.
*
* Download the icons from https://www.paidmembershipspro.com/add-credit-card-and-paypal-logos-to-checkout/
* Place the image file in the correct location according to your customizations structure.
*/
function pmpro_add_my_logos_to_checkout(){
global $pmpro_level;
@kimcoleman
kimcoleman / export_woocommerce_subscription_user_data.txt
Created August 7, 2023 17:38
MySQL command to export WooCommerce subscription data, including User ID, Product, and Next Payment Date
SELECT
p.ID as 'Subscription ID',
pm1.meta_value as 'User ID',
oitems.order_item_name as 'Product',
pm2.meta_value as 'Next Payment Date'
FROM wp_posts p
INNER JOIN wp_postmeta pm1 ON pm1.post_id = p.ID
INNER JOIN wp_postmeta pm2 ON pm2.post_id = p.ID
INNER JOIN wp_woocommerce_order_items oitems ON oitems.order_id = p.ID
WHERE
@kimcoleman
kimcoleman / common-blocks-theme-unit-test.html
Last active June 14, 2023 11:50
Theme Unit Test - Common Blocks Data
<!-- wp:paragraph -->
<p>The Common category includes the following blocks:<em> Paragraph, image, headings, list, gallery, quote, audio, cover, video.</em></p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>The paragraph block is the default block type.&nbsp; It should not have any alignment of any kind. It should just flow like you would normally expect. Nothing fancy. Just straight up text, free flowing, with love.</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>This paragraph is left aligned.</p>
@kimcoleman
kimcoleman / my_swsales_hide_from_premium_members.php
Created February 7, 2023 18:07
Hide the active sale from users with level ID 1, 2, or 3.
<?php
/**
* Hide the active sale from users with level ID 1, 2, or 3.
*/
function my_swsales_hide_from_premium_members( ) {
// Return early if this is the admin.
if ( is_admin() ) {
return;
}
@kimcoleman
kimcoleman / top-banner-reusable-block-single-product-50-percent.html
Created October 28, 2022 10:38
Top Banner Demo: Black Friday 2022 - Single Product 50% Off
<!-- wp:group {"gradient":"vivid-cyan-blue-to-vivid-purple"} -->
<div class="wp-block-group has-vivid-cyan-blue-to-vivid-purple-gradient-background has-background"><!-- wp:columns {"verticalAlignment":"center"} -->
<div class="wp-block-columns are-vertically-aligned-center"><!-- wp:column {"verticalAlignment":"center","width":"66.66%"} -->
<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:66.66%"><!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group"><!-- wp:heading {"level":3,"textColor":"white","className":"is-style-highlight"} -->
<h3 class="is-style-highlight has-white-color has-text-color">Black Friday Sale</h3>
<!-- /wp:heading -->
<!-- wp:heading {"level":3,"textColor":"palette-color-8"} -->
<h3 class="has-palette-color-8-color has-text-color">50% Off Our Best-Selling Serum</h3>
@kimcoleman
kimcoleman / top-banner-reusable-block-all-products-40-percent.html
Created October 28, 2022 10:38
Top Banner Demo: Black Friday 2022 - All Products 40% Off
<!-- wp:group {"gradient":"luminous-vivid-orange-to-vivid-red"} -->
<div class="wp-block-group has-luminous-vivid-orange-to-vivid-red-gradient-background has-background"><!-- wp:group {"align":"wide","textColor":"palette-color-8","layout":{"type":"flex","flexWrap":"wrap","justifyContent":"center"},"fontSize":"medium"} -->
<div class="wp-block-group alignwide has-palette-color-8-color has-text-color has-medium-font-size"><!-- wp:paragraph {"className":"is-style-default"} -->
<p class="is-style-default"><strong><mark style="background-color:#fc7ed8" class="has-inline-color">BLACK FRIDAY 2022</mark></strong></p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>Save 40% on everything in the store!</p>
<!-- /wp:paragraph -->