Skip to content

Instantly share code, notes, and snippets.

View kimcoleman's full-sized avatar

Kim Coleman kimcoleman

View GitHub Profile
@kimcoleman
kimcoleman / protected_post_custom_post_thumbnail_html_css.css
Last active December 1, 2025 13:21
CSS to accompany the recipe on filtering the featured image and include an overlay if the post is protected.
/* Use this with the recipe here: https://gist.github.com/kimcoleman/faf2cd0a83f3ca7a5c6c368e371ad1f3 */
.pmpro_protected_post_featured_image {
position: relative;
overflow: hidden;
}
.pmpro_protected_post_featured_image img {
filter: grayscale(1) blur(5px);
}
.pmpro_protected_post_blur_mask {
-webkit-box-align: center;
@kimcoleman
kimcoleman / protected_post_custom_post_thumbnail_html.php
Last active January 25, 2022 19:23
Filter the featured image and include an overlay if the post is protected.
<?php
/**
* Filter the featured image and include an overlay if the post is protected.
* Use this with the recipe here: https://gist.github.com/kimcoleman/299bb458310e00d7282c090110c6b4f0
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
*
*/
/**
@kimcoleman
kimcoleman / stranger_studios_season_body_class.php
Created December 15, 2021 23:39
Add a season-specific class to the body tag.
<?php
/**
* Add a season-specific class to the body tag.
*
*/
function stranger_studios_season_body_class( $classes ) {
$months_winter = array( 1, 2, 11, 12 );
if ( in_array( date( 'm' ), $months_winter ) ) {
$classes[] = 'body_winter';
}
@kimcoleman
kimcoleman / my_swsales_show_banner_exclude_users_edd_examples.php
Last active June 23, 2022 12:42
Examples for how to hide the banners based on the user's EDD purchase history or role.
<?php
/**
* Examples for how to hide the banners based on the user's EDD purchase history.
*/
function my_swsales_show_banner_exclude_users_edd_examples( $show_banner, $active_sitewide_sale ) {
// Return early if there is no logged in user.
if ( ! is_user_logged_in( ) ) {
return $show_banner;
}
@kimcoleman
kimcoleman / my_set_pmpro_default_country.php
Last active November 19, 2021 16:24
Use the pmpro_default_country filter to pre-set the dropdown at checkout to your country of choice.
<?php
/** Use the pmpro_default_country filter to pre-set the dropdown at checkout to your country of choice.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
*
*/
function my_set_pmpro_default_country( $default_country ) {
// Set country code to "GB" for United Kingdom.
$default_country = "GB";
@kimcoleman
kimcoleman / pmpro-no-access.css
Created November 1, 2021 17:12
Custom CSS to blur excerpt text on premium content previews with Paid Memberships Pro
.pmpro-no-access p {
-webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0), rgba(0, 0, 0, .5));
}
@kimcoleman
kimcoleman / demo_sites_grid_shortcode.php
Created September 27, 2021 10:40
Shortcode to show a grid of all demo sites with featured image in the network.
<?php
/**
* Shortcode to show a grid of all demo sites with featured image in the network.
*
*/
function demo_sites_grid_shortcode( ) {
ob_start();
$subsites = get_sites();
if ( ! empty ( $subsites ) ) {
@kimcoleman
kimcoleman / sample_custom_memberlite_defaults.php
Created September 1, 2021 14:59
Example of removing a class name selector from the defaults for Memberlite primary background color elements.
<?php
/**
* Example of removing a class name selector from the defaults for Memberlite primary background color elements.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
*
*/
function sample_custom_memberlite_defaults( $memberlite_defaults ) {
$memberlite_defaults['color_primary_background_elements'] = '#mobile-navigation, #mobile-navigation-height-col, .masthead, .btn_primary, .btn_primary:link, .menu-toggle, .bg_primary, .banner_primary, .has-color-primary-background-color';
@kimcoleman
kimcoleman / custom_order_manage_memberslist_columns.php
Created August 30, 2021 16:07
Reorder default columns on the Members List. In this example, we are moving Username to the first in list.
<?php
/**
* Reorder default columns on the Members List. In this example, we are moving Username to the first in list.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
*/
@kimcoleman
kimcoleman / my_pmpro_set_application_fee_percentage.php
Created August 12, 2021 21:13 — forked from dparker1005/my_pmpro_set_application_fee_percentage.php
Modify the application fee percentage that is charged on Stripe transactions.
<?php
/**
* Modify the application fee percentage that is charged on Stripe transactions.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/