PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.6
ShopBuilder – WooCommerce Builder For Elementor v3.2.6
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / app / Traits / ActionBtnTraits.php

ActionBtnTraits.php in ShopBuilder – WooCommerce Builder For Elementor 3.2.6, at app/Traits/ActionBtnTraits.php

179 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 *
37 * @return string
38 */
39 public function wishlist_icon( $icon_html ) {
40 $controllers = $this->get_settings_for_display();
41
42 if ( ! empty( $controllers['wishlist_icon'] ) ) {
43 $icon_html = Fns::icons_manager( $controllers['wishlist_icon'], 'icon-default' );
44 $icon_html .= Fns::icons_manager( $controllers['wishlist_icon_added'], 'added-icon' );
45 }
46
47 return $icon_html;
48 }
49
50 /**
51 * Compare icon
52 *
53 * @param string $icon_html Icon Html.
54 *
55 * @return string
56 */
57 public function compare_icon( $icon_html ) {
58 $controllers = $this->get_settings_for_display();
59 if ( ! empty( $controllers['comparison_icon'] ) ) {
60 $icon_html = Fns::icons_manager( $controllers['comparison_icon'], 'icon-default' );
61 $icon_html .= Fns::icons_manager( $controllers['comparison_icon_added'], 'added-icon' );
62 }
63
64 return $icon_html;
65 }
66
67 /**
68 * Compare icon
69 *
70 * @param string $icon_html Icon Html.
71 *
72 * @return string
73 */
74 public function quick_view_icon( $icon_html ) {
75 $controllers = $this->get_settings_for_display();
76 if ( ! empty( $controllers['quick_view_icon'] ) ) {
77 $icon_html = Fns::icons_manager( $controllers['quick_view_icon'], 'icon-default' );
78 }
79
80 return $icon_html;
81 }
82
83 /**
84 * Icon Replace
85 *
86 * @return string
87 */
88 public function print_action_button( $position ) {
89 $controllers = $this->get_settings_for_display();
90
91 $wishlist_loop_btn_position = Fns::get_option( 'modules', 'wishlist', 'loop_btn_position', 'after_add_to_cart' );
92 $compare_loop_btn_position = Fns::get_option( 'modules', 'compare', 'loop_btn_position', 'after_add_to_cart' );
93 $quick_view_loop_btn_position = Fns::get_option( 'modules', 'quick_view', 'loop_btn_position', 'after_add_to_cart' );
94 $action_button = [];
95 global $product;
96 if ( Fns::is_module_active( 'wishlist' ) && ! empty( $controllers['wishlist_button'] ) && $position == $wishlist_loop_btn_position ) {
97 ob_start();
98 do_action( 'rtsb/modules/wishlist/print_button', $product->get_id() );
99 $action_button['wishlist'] = ob_get_clean();
100 }
101
102 if ( Fns::is_module_active( 'compare' ) && ! empty( $controllers['comparison_button'] ) && $position == $compare_loop_btn_position ) {
103 ob_start();
104 do_action( 'rtsb/modules/compare/print_button', $product->get_id() );
105 $action_button['compare'] = ob_get_clean();
106 }
107
108 if ( Fns::is_module_active( 'quick_view' ) && ! empty( $controllers['quick_view_button'] ) && $position == $quick_view_loop_btn_position ) {
109 ob_start();
110 do_action( 'rtsb/modules/quick_view/print_button', $product->get_id() );
111 $action_button['quick_view'] = ob_get_clean();
112 }
113
114 $action_button = apply_filters( 'rtsb/modules/actions/button/print_button', $action_button, $controllers, $position, $product );
115
116 if( ! count( $action_button ) ){
117 return ;
118 }
119
120 echo "<div class='action-button-wrapper'>";
121 foreach ( $action_button as $index => $item ) {
122 Fns::print_html( $item );
123 }
124 echo '</div>';
125
126 }
127
128 /**
129 * @return void
130 */
131 public function before_add_to_cart() {
132 $this->print_action_button( 'before_add_to_cart' );
133 }
134
135 /**
136 * @return void
137 */
138 public function after_add_to_cart() {
139 $this->print_action_button( 'after_add_to_cart' );
140 }
141
142 /**
143 * Icon Replace
144 *
145 * @return void
146 */
147 public function action_button_icon_modify() {
148 add_filter( 'rtsb/module/wishlist/icon_html', [ $this, 'wishlist_icon' ] );
149 add_filter( 'rtsb/module/compare/icon_html', [ $this, 'compare_icon' ] );
150 add_filter( 'rtsb/module/quick_view/icon_html', [ $this, 'quick_view_icon' ] );
151 // add_filter( 'woocommerce_loop_add_to_cart_link', [ $this, 'print_action_button' ] );
152 // before_add_to_cart
153 // woocommerce_after_shop_loop_item
154 add_action( 'woocommerce_after_shop_loop_item', [ $this, 'before_add_to_cart' ], 7 );
155 // after_add_to_cart
156 // woocommerce_after_shop_loop_item
157 add_action( 'woocommerce_after_shop_loop_item', [ $this, 'after_add_to_cart' ], 15 );
158 }
159
160 /**
161 * Icon set to default
162 *
163 * @return void
164 */
165 public function action_button_icon_set_default() {
166 remove_filter( 'rtsb/module/wishlist/icon_html', [ $this, 'wishlist_icon' ] );
167 remove_filter( 'rtsb/module/compare/icon_html', [ $this, 'compare_icon' ] );
168 remove_filter( 'rtsb/module/quick_view/icon_html', [ $this, 'quick_view_icon' ] );
169 // remove_filter( 'woocommerce_loop_add_to_cart_link', [ $this, 'print_action_button' ] );
170 // woocommerce_before_shop_loop_item
171 // before_add_to_cart
172 remove_action( 'woocommerce_after_shop_loop_item', [ $this, 'before_add_to_cart' ], 7 );
173 // woocommerce_after_shop_loop_item
174 // after_add_to_cart
175 remove_action( 'woocommerce_after_shop_loop_item', [ $this, 'after_add_to_cart' ], 15 );
176 // woocommerce_after_shop_loop_item
177 }
178 }
179