VariationSwatches
1 week ago
Wishlist
1 week ago
AdminMessage.php
1 week ago
AjaxSearch.php
1 week ago
Backorder.php
1 week ago
CatalogMode.php
1 year ago
Compare.php
1 week ago
DefaultTemplates.php
2 years ago
FlashSalesCountdown.php
1 year ago
MenuCart.php
4 months ago
MobilePanel.php
1 week ago
MultiStep.php
1 year ago
Notifications.php
1 week ago
QuickView.php
1 week ago
RecentlyViewedProducts.php
1 year ago
RenameLabel.php
4 months ago
Shopify.php
1 year ago
SingleAjaxAddToCart.php
1 week ago
SizeChart.php
1 week ago
StickyAddToCart.php
1 week ago
RenameLabel.php
124 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Rename label. |
| 4 | * |
| 5 | * @package ShopPress |
| 6 | */ |
| 7 | |
| 8 | namespace ShopPress\Modules; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | class RenameLabel { |
| 13 | /** |
| 14 | * Init. |
| 15 | * |
| 16 | * @since 1.2.0 |
| 17 | */ |
| 18 | public static function init() { |
| 19 | |
| 20 | if ( ! sp_get_module_settings( 'rename_label', 'status' ) ) { |
| 21 | return; |
| 22 | } |
| 23 | |
| 24 | add_filter( 'woocommerce_product_add_to_cart_text', array( __CLASS__, 'loop_add_to_cart' ), 99, 1 ); |
| 25 | add_filter( 'woocommerce_product_single_add_to_cart_text', array( __CLASS__, 'single_add_to_cart' ), 99, 1 ); |
| 26 | add_filter( 'woocommerce_product_description_tab_title', array( __CLASS__, 'description_tab' ), 99, 1 ); |
| 27 | add_filter( 'woocommerce_product_description_heading', array( __CLASS__, 'description_tab' ), 99, 1 ); |
| 28 | add_filter( 'woocommerce_product_additional_information_tab_title', array( __CLASS__, 'information_tab' ), 99, 1 ); |
| 29 | add_filter( 'woocommerce_product_additional_information_heading', array( __CLASS__, 'information_tab' ), 99, 1 ); |
| 30 | add_filter( 'woocommerce_product_reviews_tab_title', array( __CLASS__, 'reviews_tab' ), 99, 1 ); |
| 31 | add_filter( 'woocommerce_order_button_text', array( __CLASS__, 'order_button' ), 99, 1 ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Rename loop add to cart. |
| 36 | * |
| 37 | * @since 1.1.0 |
| 38 | */ |
| 39 | public static function loop_add_to_cart( $label ) { |
| 40 | $custom_label = sp_get_module_settings( 'rename_label', 'shop_cart_text' ); |
| 41 | |
| 42 | if ( $custom_label ) { |
| 43 | return $custom_label; |
| 44 | } |
| 45 | |
| 46 | return $label; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Rename single add to cart. |
| 51 | * |
| 52 | * @since 1.1.0 |
| 53 | */ |
| 54 | public static function single_add_to_cart( $label ) { |
| 55 | $custom_label = sp_get_module_settings( 'rename_label', 'single_cart_text' ); |
| 56 | |
| 57 | if ( $custom_label ) { |
| 58 | return $custom_label; |
| 59 | } |
| 60 | |
| 61 | return $label; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Rename description tab. |
| 66 | * |
| 67 | * @since 1.1.0 |
| 68 | */ |
| 69 | public static function description_tab( $label ) { |
| 70 | $custom_label = sp_get_module_settings( 'rename_label', 'single_description_tab_text' ); |
| 71 | |
| 72 | if ( $custom_label ) { |
| 73 | return $custom_label; |
| 74 | } |
| 75 | |
| 76 | return $label; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Rename information tab. |
| 81 | * |
| 82 | * @since 1.1.0 |
| 83 | */ |
| 84 | public static function information_tab( $label ) { |
| 85 | $custom_label = sp_get_module_settings( 'rename_label', 'single_information_tab_text' ); |
| 86 | |
| 87 | if ( $custom_label ) { |
| 88 | return $custom_label; |
| 89 | } |
| 90 | |
| 91 | return $label; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Rename reviews tab. |
| 96 | * |
| 97 | * @since 1.1.0 |
| 98 | */ |
| 99 | public static function reviews_tab( $label ) { |
| 100 | $custom_label = sp_get_module_settings( 'rename_label', 'single_reviews_tab_text' ); |
| 101 | |
| 102 | if ( $custom_label ) { |
| 103 | return $custom_label; |
| 104 | } |
| 105 | |
| 106 | return $label; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Rename order button. |
| 111 | * |
| 112 | * @since 1.1.0 |
| 113 | */ |
| 114 | public static function order_button( $label ) { |
| 115 | $custom_label = sp_get_module_settings( 'rename_label', 'checkout_order_button_text' ); |
| 116 | |
| 117 | if ( $custom_label ) { |
| 118 | return $custom_label; |
| 119 | } |
| 120 | |
| 121 | return $label; |
| 122 | } |
| 123 | } |
| 124 |