Skip to content

Instantly share code, notes, and snippets.

View contemplate's full-sized avatar

Ted Barnett contemplate

View GitHub Profile
@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>
@contemplate
contemplate / functions.php
Created August 2, 2022 18:42
Disable LearnDash Video Progression
add_filter('learndash_user_can_bypass', 'custom_bypass_video_progression', 10, 4);
function custom_bypass_video_progression( $can_bypass, $user_id, $context, $args ){
if( $context == 'learndash_video_progression'){
$can_bypass = true;
}
return $can_bypass;
}
@contemplate
contemplate / functions.php
Created April 28, 2022 21:20
WordPress Redirect any pages that are in draft/trash to custom url
//redirect any draft/trashed posts to custom postmeta field: redirect_url_on_draft
add_action('wp', 'custom_redirect_on_draft');
function custom_redirect_on_draft(){
if ( !current_user_can( 'edit_pages' ) ) {
if (is_404()){
global $wp_query, $wpdb;
$page_id = $wpdb->get_var( $wp_query->request );
$post_status = get_post_status( $page_id );
$post_redirect = get_post_meta( $page_id, 'redirect_url_on_draft', true );
if(($post_status == 'trash' || $post_status == 'draft') && $post_redirect){
@contemplate
contemplate / functions.php
Last active May 14, 2024 23:47
WooCommerce - Disable guest checkout for certain products when Guest checkout is Enabled globally
/*--------------------------------------
Woocommerce - Disallow Guest Checkout on Certain products
----------------------------------------*/
// Display Guest Checkout Field
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_disable_gc_fields' );
function woo_add_disable_gc_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
@contemplate
contemplate / class-affiliatewp-leaderboard.php
Created September 3, 2021 19:02
AffiliateWP: leaderboard by referrer shortcode
<?php
/**
* Core: Plugin Bootstrap
*
* @package AffiliateWP Leaderboard
* @subpackage Core
* @copyright Copyright (c) 2021, Sandhills Development, LLC
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.1
*/
@contemplate
contemplate / functions.php
Created May 9, 2021 00:30
BBpress User Favorites Shortcode
/*-- BBpress User Favorites Shortcode [bbp-user-favorites] --*/
function bbp_user_favorites_shortcode( $atts ) {
$user_id = get_current_user_id();
ob_start();
if ( bbp_get_user_favorites( $user_id ) ) {
//bbp_get_template_part( 'pagination', 'topics' );
bbp_get_template_part( 'loop', 'topics' );
bbp_get_template_part( 'pagination', 'topics' );
} else { ?>
<aside class="bp-feedback bp-messages info">
@contemplate
contemplate / bp-custom.php
Created May 7, 2021 12:36
Buddypress: Expand autocomplete mentions list
//turn on @mentions for all users
define( 'BP_MESSAGES_AUTOCOMPLETE_ALL', true );
/*---- Expand Auto Complete -------*/
//https://github.com/buddypress/BuddyPress/blob/fe47890c1ab7e2cb24c005f1c35fb9c6c8c8ab7c/src/bp-core/classes/class-bp-members-suggestions.php#L85
function bp_filter_buddypress_auto_complete( $args ) {
$args['per_page'] = 100;
// $args['populate_extras'] = true;
//$args['search_terms'] = 'some term';
$args['search_wildcard'] = 'both';