Skip to content

Instantly share code, notes, and snippets.

View su_lightbox
[su_lightbox type="inline" src="#my-custom-popup"] Click here to open lightbox with HTML content [/su_lightbox]
[su_lightbox_content id="my-custom-popup"]
<h3>Custom HTML content</h3>
Any <strong>HTML</strong> <em>tags</em> can be used here. Other shortcodes are also [su_highlight]allowed[/su_highlight].
[/su_lightbox_content]
@plugin-republic
plugin-republic / prefix_check_user_role.php
Created Oct 20, 2020
Display notice to user if their account is pending
View prefix_check_user_role.php
<?php
/**
* Display notice to user if their account is pending
*/
function prefix_check_user_role() {
if( wc_current_user_has_role( 'pending' ) ) {
wc_add_notice(
'Your account is still pending',
'notice'
);
@plugin-republic
plugin-republic / wcmo_user_approval_message.php
Last active Oct 26, 2020
Filter the content of the user approval and rejection messages
View wcmo_user_approval_message.php
<?php
/**
* Filter the content of the user approval message
* @param $message The message content
* @param $url The url to redirect the user to
* @param $user The user object
*/
function prefix_user_approval_message( $message, $url, $user ) {
$message = 'My new message goes here';
@plugin-republic
plugin-republic / wcdpp_product_has_deposit.php
Last active Oct 12, 2020
Programmatically set whether a product should have a deposit option
View wcdpp_product_has_deposit.php
<?php
/**
* Programmatically set whether a product should have a deposit option
* Set the global value for 'Accept Deposits' to 'Some Products'
*/
function prefix_product_has_deposit( $has_deposit, $product_id ) {
// All the products in this list will not have a deposit option
if( in_array( $product_id, array( 123, 456, 789 ) ) {
$has_deposit = false;
} else {
@plugin-republic
plugin-republic / pewc_filter_field_description.php
Created Oct 8, 2020
How to allow shortcodes in add-on field descriptions
View pewc_filter_field_description.php
<?php
/**
* Allow shortcodes in field description
*/
function prefix_shortcode_in_description( $description, $item, $additional_info='' ) {
$field_description = ! empty( $item['field_description'] ) ? $item['field_description'] : '';
$description = sprintf(
'<p class="pewc-description">%s%s</p>',
do_shortcode( $field_description ),
$additional_info
View wcmo_role_expiration_date.php
<?php
/**
* Set fixed expiry date
*/
function prefix_role_expiration_date( $expires, $role, $user_id ) {
$expires = '25 October 2020';
return strtotime( $expires );
}
add_filter( 'wcmo_role_expiration_date', 'prefix_role_expiration_date', 10, 3 );
View tester_remove_child_arrows.php
<?php
/**
* Don't replace 'Remove' link with arrow for child items in the cart
*/
function tester_remove_child_arrows() {
remove_action( 'woocommerce_cart_item_remove_link', 'pewc_cart_item_remove_link', 10, 2 );
}
add_action( 'init', 'tester_remove_child_arrows' );
@plugin-republic
plugin-republic / pewc-child-product.css
Created Sep 25, 2020
Hide child product rows in the cart
View pewc-child-product.css
tr.pewc-child-product {
display: none;
}
View wcmo_user_needs_approval.php
<?php
/**
* Filter user approval - for example, allow certain emails to bypas approval
*/
function prefix_user_needs_approval( $needs_approval, $user ) {
// Do your checks here
return $needs_approval;
}
apply_filters( 'wcmo_user_needs_approval', 'prefix_user_needs_approval', 10, 2 );
View wcmo_registration_fields.php
<?php
/**
* Add custom field to registration form
*/
function my_prefix_registration_fields( $fields ) {
// Add a text field
$fields['new_field'] = array(
'label' => __( 'New Field', 'wcmo' ),
'type' => 'text',
'priority' => 250,
You can’t perform that action at this time.