Skip to content

Instantly share code, notes, and snippets.

View contemplate's full-sized avatar

Ted Barnett contemplate

View GitHub Profile
@contemplate
contemplate / affwp-store-credit-disable-per-affiliate-when-globally-enabled.php
Created April 26, 2023 12:46
AffiliateWP - Store Credit - Disable Store Credit Per Affiliate
<?php
/**
* Plugin Name: AffiliateWP - Store Credit - Disable Store Credit Per Affiliate
* Plugin URI: https://affiliatewp.com
* Description: Disable store credit per affiliate if store credit is globally enabled for all affiliates
* Author: Tunbosun Ayinla
* Author URI: https://affiliatewp.com
* Version: 1.0
*/
@contemplate
contemplate / bbp-reply-ajax.js
Created January 3, 2023 01:13
Buddyboss Jump to Reply fix
// When click on notification then move to particular reply.
moveToReply: function () {
if ( window.location.href.indexOf( '#post-' ) > 0 ) {
var varUrl = window.location.href.split( '#post-' );
var postID = varUrl && undefined !== varUrl[1] ? varUrl[1] : '';
if ( !postID ) {
return;
}
var scrollTop;
if ($('#wpadminbar').length){
@contemplate
contemplate / functions.php
Created December 20, 2022 21:36
AffiliateWP: Add WooCommerce Customer Name to Referrals Table & Affiliate Area
/**
* Add customer name to reference column of the referrals page
*/
function affwp_custom_wc_referrals_user_link( $reference, $referral ) {
if ( ! ( 'woocommerce' == $referral->context || class_exists( 'WC_Order' ) ) ) {
return $reference;
}
$order = wc_get_order( $referral->reference );
if( ! $order ){
@contemplate
contemplate / functions.php
Created December 18, 2022 22:12
AffiliateWP: Block WC Coupon if not referred - enhanced
add_action( 'woocommerce_coupon_options', 'affwp_only_referral_coupon_option' );
add_action( 'woocommerce_coupon_options_save', 'affwp_store_only_referral_coupon_option' );
add_filter( 'woocommerce_coupon_is_valid', 'affwp_custom_block_coupon_if_no_referrer', 10, 2 );
/**
* Add coupon option to enable only referral validity
*/
function affwp_only_referral_coupon_option() {
global $post;
@contemplate
contemplate / functions.php
Created November 19, 2022 19:58
Buddypress / Buddyboss exclude users from messaging & mention
//array of restricted user IDs
function bp_restricted_user_list(){
// These user's won't be able to receive the messages.
$restricted_user_ids = array( 102, 115, 220, 225 ); //Change these values to valid user IDs
return $restricted_user_ids;
}
/**
* Is user restricted from receiving message.
@contemplate
contemplate / metaboxes.php
Created November 11, 2022 23:53
MyBookTable get_user performance enhancement
<?php foreach( get_users( array( 'role__in' => array( 'administrator', 'editor', 'author', 'contributor' ) ) ) as $author) { ?>
@contemplate
contemplate / functions.php
Created September 7, 2022 13:48
WooCommerce Subscriptions: remove end date from My Account
// filter found here: https://github.com/wp-premium/woocommerce-subscriptions/blob/master/templates/myaccount/subscription-details.php
add_filter('wcs_subscription_details_table_dates_to_display', 'wc_remove_end_date_column', 10, 2);
function wc_remove_end_date_column($rows, $subscription){
unset($rows['end']);
return $rows;
}
@contemplate
contemplate / bp-xprofile-functions.php
Created August 9, 2022 12:21
BUDDYBOSS SHOW MORE SOCIAL ACCOUNTS
$is_more_link = count( array_filter( $original_option_values ) ) > 10;
@contemplate
contemplate / bb-forums.php
Created August 9, 2022 12:17
BUDDYBOSS ELEMENTOR FORUMS WIDGET AVATAR
<?php
$get_last_reply_id = bbp_get_topic_last_reply_id( bbp_get_topic_id() );
echo bbp_get_author_link( array( 'post_id' => $get_last_reply_id,'size' => '180' ) );
?>
@contemplate
contemplate / bb-forums.php
Created August 9, 2022 12:13
BUDDYBOSS ELEMENTOR FORUMS WIDGET LABEL HACK
<?php
// Add Forum Stickers
if( !empty( bbp_get_topic_forum_title()) ) { ?>
<span class="color bs-meta-item <?php echo ( bbp_is_single_forum() ) ? esc_attr( 'no-action' ) : ''; ?>" style="background: <?php echo color2rgba( textToColor( bbp_get_topic_forum_title() ), 0.6 ); ?>">
<?php if ( bbp_is_single_forum() ) {
?> <span class="no-links"><?php echo bbp_get_topic_forum_title(); ?></span> <?php
} else {
?> <a href="<?php echo esc_url( bbp_get_forum_permalink( bbp_get_topic_forum_id() ) ); ?>"><?php echo bbp_get_topic_forum_title(); ?></a>
<?php } ?>
</span>