This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Override WP oEmbed | |
* @version 1.0 | |
*/ | |
add_filter( 'embed_oembed_html', 'mycred_override_video_shortcode', 999, 4 ); | |
function mycred_override_video_shortcode( $original, $url, $attr, $post_ID ) { | |
// If myCRED is not enabled | |
if ( ! function_exists( 'mycred_render_shortcode_video' ) ) return $original; | |
// Get cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_mycred_log_admin_screen() { | |
$args = array( | |
'number' => 10 | |
); | |
if ( isset( $_GET['user_id'] ) && ! empty( $_GET['user_id'] ) ) | |
$args['user_id'] = $_GET['user_id']; | |
if ( isset( $_GET['s'] ) && ! empty( $_GET['s'] ) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Insert buyCRED Button | |
* Inserts a buyCRED Button when a users order exceeds their current balance, | |
* allowing them to quickly buy more points in order to pay for the order. | |
* Required myCRED 1.4 or higher! | |
* @version 1.0 | |
*/ | |
add_action( 'after_setup_theme', 'mycred_load_woo_gateway_customization', 20 ); | |
function mycred_load_woo_gateway_customization() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Step 1. Catch Promotions | |
* @version 1.0 | |
*/ | |
add_action( 'mycred_user_got_promoted', 'mycred_pro_catch_promotions', 10, 2 ); | |
function mycred_pro_catch_promotions( $user_id, $rank_id ) { | |
// Save a temporary marker for this user so on the next page load | |
// the popup modal is shown | |
update_user_meta( $user_id, 'show_promotion_box', $rank_id ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Pay Sale Profit on Completed or Shipped Orders | |
* @version 1.0 | |
*/ | |
add_action( 'woocommerce_order_status_completed', 'mycred_pro_pay_profit_from_sale' ); | |
add_action( 'woocommerce_order_status_shipped', 'mycred_pro_pay_profit_from_sale' ); | |
function mycred_pro_pay_profit_from_sale( $order_id ) { | |
// Get current user id | |
$cui = get_current_user_id(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'default_title', 'mycred_pro_generate_coupon_code', 10, 2 ); | |
function mycred_pro_generate_coupon_code( $post_title, $post ) { | |
if ( ! isset( $post->post_type ) || $post->post_type != 'mycred_coupon' ) | |
return $post_title; | |
return wp_generate_password( 12, false, false ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_shortcode( 'mycred_content_sales', 'mycred_render_content_sales_shortcode' ); | |
function mycred_render_content_sales_shortcode( $attr ) { | |
global $wpdb; | |
$mycred_log = $wpdb->prefix . 'myCRED_log'; | |
$sales = $wpdb->get_results( " | |
SELECT DISTINCT ref_id AS post_id, COUNT( * ) AS sales | |
FROM {$mycred_log} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Custom Hook: Points based on taxonomy | |
* Register the hook so myCRED can load it. | |
* @since 1.0 | |
* @version 1.1 | |
*/ | |
add_action( 'mycred_setup_hooks', 'mycredpro_register_custom_taxonomy_hook' ); | |
function mycredpro_register_custom_taxonomy_hook( $installed ) { | |
$installed['publishing_ct_content'] = array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Custom myCRED Widget: Ranged Leaderboard | |
* Shows a leaderboard of users sorted by their point gains | |
* between two timestamps. Supports multiple point types. | |
* @author Gabriel S Merovingi | |
* @version 2.0 | |
*/ | |
add_action( 'widgets_init', 'mycred_register_ranged_leaderboard' ); | |
function mycred_register_ranged_leaderboard() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Custom myCRED Widget: This months leaderboard | |
* This widget will show this months leaderbaord with the option to set | |
* a title, the number of users to include and if it should be visible for | |
* non-members. | |
* @install Paste into your theme or child-themes functions.php file or custom plugin. | |
* @author Gabriel S Merovingi | |
* @version 1.1.1 | |
*/ | |
add_action( 'mycred_widgets_init', 'mycred_load_this_months_leaderboard_widget' ); |