| 1 |
<?php |
| 2 |
/** |
| 3 |
* Trait: Elementor Action Buttons. |
| 4 |
* |
| 5 |
* @package RadiusTheme\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Traits; |
| 9 |
|
| 10 |
use RadiusTheme\SB\Helpers\Fns; |
| 11 |
|
| 12 |
// Do not allow directly accessing this file. |
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit( 'This script cannot be accessed directly.' ); |
| 15 |
} |
| 16 |
|
| 17 |
trait ActionBtnTraits { |
| 18 |
|
| 19 |
/** |
| 20 |
* Icon |
| 21 |
* |
| 22 |
* @return array |
| 23 |
*/ |
| 24 |
public function get_style_depends() { |
| 25 |
return [ |
| 26 |
'elementor-icons-fa-regular', |
| 27 |
'elementor-icons-fa-solid', |
| 28 |
]; |
| 29 |
|
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Wishlist icon |
| 34 |
* |
| 35 |
* @param string $icon_html Icon Html. |
| 36 |
* @return string |
| 37 |
*/ |
| 38 |
public function wishlist_icon( $icon_html ) { |
| 39 |
$controllers = $this->get_settings_for_display(); |
| 40 |
|
| 41 |
if ( ! empty( $controllers['wishlist_icon'] ) ) { |
| 42 |
$icon_html = Fns::icons_manager( $controllers['wishlist_icon'], 'icon-default' ); |
| 43 |
$icon_html .= Fns::icons_manager( $controllers['wishlist_icon_added'], 'added-icon' ); |
| 44 |
} |
| 45 |
|
| 46 |
return $icon_html; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Compare icon |
| 51 |
* |
| 52 |
* @param string $icon_html Icon Html. |
| 53 |
* @return string |
| 54 |
*/ |
| 55 |
public function compare_icon( $icon_html ) { |
| 56 |
$controllers = $this->get_settings_for_display(); |
| 57 |
if ( ! empty( $controllers['comparison_icon'] ) ) { |
| 58 |
$icon_html = Fns::icons_manager( $controllers['comparison_icon'], 'icon-default' ); |
| 59 |
$icon_html .= Fns::icons_manager( $controllers['comparison_icon_added'], 'added-icon' ); |
| 60 |
} |
| 61 |
return $icon_html; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Compare icon |
| 66 |
* |
| 67 |
* @param string $icon_html Icon Html. |
| 68 |
* @return string |
| 69 |
*/ |
| 70 |
public function quick_view_icon( $icon_html ) { |
| 71 |
$controllers = $this->get_settings_for_display(); |
| 72 |
if ( ! empty( $controllers['quick_view_icon'] ) ) { |
| 73 |
$icon_html = Fns::icons_manager( $controllers['quick_view_icon'], 'icon-default' ); |
| 74 |
} |
| 75 |
return $icon_html; |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Icon Replace |
| 80 |
* |
| 81 |
* @return string |
| 82 |
*/ |
| 83 |
public function print_action_button( $link_html ) { |
| 84 |
$controllers = $this->get_settings_for_display(); |
| 85 |
ob_start(); |
| 86 |
global $product; |
| 87 |
echo "<div class='action-button-wrapper'>"; |
| 88 |
if ( Fns::is_module_active('wishlist') && ! empty( $controllers['wishlist_button'] ) ) { |
| 89 |
do_action( 'rtsb/modules/wishlist/print_button', $product->get_id() ); |
| 90 |
// do_action('rtsb/modules/wishlist/frontend/display' ); |
| 91 |
} |
| 92 |
if ( Fns::is_module_active('compare') && ! empty( $controllers['comparison_button'] ) ) { |
| 93 |
do_action( 'rtsb/modules/compare/print_button', $product->get_id() ); |
| 94 |
// do_action('rtsb/modules/compare/frontend/display' ); |
| 95 |
} |
| 96 |
if ( Fns::is_module_active('quick_view') && ! empty( $controllers['quick_view_button'] ) ) { |
| 97 |
do_action( 'rtsb/modules/quick_view/print_button', $product->get_id() ); |
| 98 |
// do_action('rtsb/modules/quick_view/frontend/display' ); |
| 99 |
} |
| 100 |
echo "</div>"; |
| 101 |
return $link_html. ob_get_clean(); |
| 102 |
} |
| 103 |
/** |
| 104 |
* Icon Replace |
| 105 |
* |
| 106 |
* @return void |
| 107 |
*/ |
| 108 |
public function action_button_icon_modify() { |
| 109 |
add_filter( 'rtsb/module/wishlist/icon_html', [ $this, 'wishlist_icon' ] ); |
| 110 |
add_filter( 'rtsb/module/compare/icon_html', [ $this, 'compare_icon' ] ); |
| 111 |
add_filter( 'rtsb/module/quick_view/icon_html', [ $this, 'quick_view_icon' ] ); |
| 112 |
add_filter( 'woocommerce_loop_add_to_cart_link', [ $this, 'print_action_button' ] ); |
| 113 |
} |
| 114 |
|
| 115 |
/** |
| 116 |
* Icon set to default |
| 117 |
* |
| 118 |
* @return void |
| 119 |
*/ |
| 120 |
public function action_button_icon_set_default() { |
| 121 |
remove_filter( 'rtsb/module/wishlist/icon_html', [ $this, 'wishlist_icon' ] ); |
| 122 |
remove_filter( 'rtsb/module/compare/icon_html', [ $this, 'compare_icon' ] ); |
| 123 |
remove_filter( 'rtsb/module/quick_view/icon_html', [ $this, 'quick_view_icon' ] ); |
| 124 |
remove_filter( 'woocommerce_loop_add_to_cart_link', [ $this, 'print_action_button' ] ); |
| 125 |
} |
| 126 |
} |
| 127 |
|