Skip to content

Instantly share code, notes, and snippets.

View wbcomdev's full-sized avatar

Wbcom Dev wbcomdev

View GitHub Profile
@wbcomdev
wbcomdev / class-referrals-reports-tab.php
Created July 25, 2018 18:06
Affiliate Total Unpaid Earning tile
Please navigate to file includes/admin/reports/tabs/class-referrals-reports-tab.php and replace the total unpaid earning tile code with the following code:
$total_unpaid_earnings = 0;
$referrals = affiliate_wp()->referrals->get_referrals( array(
'number' => -1,
'status' => 'unpaid',
'affiliate_id' => $this->affiliate_id,
'date' => $this->date_query ? $this->date_query : ''
) );
foreach ( $referrals as $referral ) {
/**
* Display member types at member directory tabs.
*/
function wb_member_types_display_directory_tabs() {
$member_types = bp_get_member_types( array(), 'objects' );
foreach ( $member_types as $member_type ) :
?>
<li id="members-<?php echo esc_attr( $member_type->name ); ?>">
<a href="<?php bp_members_directory_permalink(); ?>"><?php printf( '%s <span>%d</span>', $member_type->labels['name'], wb_members_by_count_member_types( $member_type->name ) ); ?></a>
</li>
/**
* Hide add friend button from specific user roles.
*/
function wb_hide_add_friend_button_for_some_user( $button ) {
$user_roles = wp_get_current_user()->roles;
if ( in_array( 'customer', $user_roles ) || in_array( 'subscriber', $user_roles ) || in_array( 'administrator', $user_roles ) ) {
return '';
}
return $button;
}
/**
* Hide add friend button for specific members type.
*/
function wb_hide_add_friend_button_from_members_types( $button ) {
$displayed_user_id = bp_displayed_user_id();
$user_id = ( $displayed_user_id ) ? $displayed_user_id : bp_get_member_user_id();
$member_type = bp_get_member_type( $user_id );
/**
* Display recently active group members tab in single group page.
*/
function wb_recently_active_group_member_tab() {
global $bp;
$user_access = false;
$group_link = '';
if ( bp_is_active( 'groups' ) && ! empty( $bp->groups->current_group ) ) {
$group_link = $bp->root_domain . '/' . bp_get_groups_root_slug() . '/' . $bp->groups->current_group->slug . '/';
$user_access = $bp->groups->current_group->user_has_access;
<?php
/**
* Wb WordPress Widget for display Posts with different filter.
*/
class Wb_Display_Post_Diff_Fillter extends WP_Widget {
/**
* Working as display post, we get things done better.
*
* @since 1.0.3
/**
* Change Limit on Number of Variations for Dynamic Variable Product Dropdowns
*
* @param mixed $qty Quantity of Product
* @param mixed $product Get a woocommerce product.
*/
function wb_wc_ajax_variation_threshold( $qty, $product ) {
return 10;
}
/**
* Allow HTML in term (category, tag) descriptions
*/
foreach ( array( 'pre_term_description' ) as $filter ) {
remove_filter( $filter, 'wp_filter_kses' );
if ( ! current_user_can( 'unfiltered_html' ) ) {
add_filter( $filter, 'wp_filter_post_kses' );
}
}
/**
* Override loop template and show quantities next to add to cart buttons.
*/
function wb_quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) {
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
$html .= woocommerce_quantity_input( array(), $product, false );
$html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>';
$html .= '</form>';
}
/**
* Change the default country on the checkout page.
*/
function wb_change_default_checkout_country() {
// Enter the country code here.
return 'XX';
}
/**
* Change the default state on the checkout page.
*/