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
<?php | |
/** | |
* Change the default shortcode button text for both shortcodes | |
*/ | |
add_filter( 'wcepe_external_product_shortcode', 'wcepe_change_default_button_text' ); | |
add_filter( 'wcepe_recent_external_products_shortcode', 'wcepe_change_default_button_text' ); | |
function wcepe_change_default_button_text( $atts ) { |
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_action( 'woocommerce_attribute_label', 'wc_ninja_change_attribute_label', 20, 3 ); | |
function wc_ninja_change_attribute_label( $label, $name, $product ) { | |
// Check if on single product page and if the attribute name is 'color' | |
if ( is_product() && 'color' === $name ) { | |
global $product; | |
// Change the label text based on the product ID | |
switch ( $product->id ) { | |
case '357': | |
$label = 'Custom Label One'; |
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
<?php | |
/** | |
* Co-Author Plus ES query fix. | |
* | |
* With CAP, authors are attached either with the traditional | |
* author field or via an "author" taxonomy. So we need to check both. | |
*/ | |
add_filter( 'es_posts_request', function( $es_args, $query ) { | |
if ( ! $query->is_author() ) { |
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 Tracking Code to the Order Recieved Page | |
*/ | |
function wc_ninja_checkout_analytics( $order_id ) { | |
$order = new WC_Order( $order_id ); | |
$currency = $order->get_order_currency(); | |
$total = $order->get_total(); | |
$date = $order->order_date; | |
?> | |
<!-- Paste Tracking Code Under Here --> |
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
<?php | |
/* | |
* Jetpack's JSON API Authorization flow needs to run free of the 2FA checks. | |
* JP already does additional validation on top of the normal login, so we can rely on that as the 2fa here. | |
* | |
* First we hook into wp_login right before the VIP Two_Factor_Core plugin does. | |
* Then if the situation is right, remove the additional 2FA login step. | |
*/ | |
add_action( 'wp_login', function( $user_login, $user ) { |
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
<?php | |
// Prevent 2FA from being enforced for JP JSON API requests. | |
add_filter( 'wpcom_vip_is_two_factor_forced', function( $forced ) { | |
$current_user = wp_get_current_user(); | |
if ( vip_is_jetpack_xml_rpc_json_api_request() && isset( $current_user->user_login ) && 'example_username' === $current_user->user_login ) { | |
$forced = false; | |
} | |
return $forced; |
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
<?php | |
if ( ! class_exists( 'WPCOM_VIP_CLI_Command' ) || ! ( defined( 'WP_CLI' ) && WP_CLI ) ) { | |
return; | |
} | |
WP_CLI::add_command( 'vip-remove-old-revisions', 'VIP_Remove_Old_Revisions_Command' ); | |
class VIP_Remove_Old_Revisions_Command extends WPCOM_VIP_CLI_Command { |
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_action( 'woocommerce_after_cart_table', 'wc_ninja_remove_cart_addons', 10 ); | |
function wc_ninja_remove_cart_addons() { | |
global $sfn_cart_addons; | |
remove_action( 'woocommerce_after_cart_table', array( $sfn_cart_addons, 'cart_display_addons' ), 20 ); | |
} |
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 wc_ninja_role_base_shipping_method( $rates, $package ) { | |
// Make sure flat rate is available | |
if ( isset( $rates['flat_rate'] ) && ! current_user_can( 'wholesale' ) ) { | |
unset($rates['flat_rate']); | |
} | |
return $rates; | |
} | |
add_filter( 'woocommerce_package_rates', 'wc_ninja_role_base_shipping_method', 10, 2 ); |
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( 'woocommerce_product_add_to_cart_url', 'wc_ninja_edit_add_to_cart_url', 10, 2 ); | |
function wc_ninja_edit_add_to_cart_url( $url, $product ) { | |
if ( 'simple' === $product->get_type() ) { | |
$url = $product->get_permalink(); | |
} | |
return $url; | |
} | |
add_filter( 'woocommerce_product_add_to_cart_text', 'wc_ninja_edit_add_to_cart_text', 10, 2 ); |