PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.0.3
ShopBuilder – WooCommerce Builder For Elementor v2.0.3
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 / Controllers / Hooks / ActionHooks.php

ActionHooks.php in ShopBuilder – WooCommerce Builder For Elementor 2.0.3, at app/Controllers/Hooks/ActionHooks.php

134 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main ActionHooks class.
4 *
5 * @package RadiusTheme\SB
6 */
7
8 namespace RadiusTheme\SB\Controllers\Hooks;
9
10 use RadiusTheme\SB\Elementor\Render\Render;
11 use RadiusTheme\SB\Helpers\Fns;
12 use RadiusTheme\SB\Models\GeneralList;
13 use RadiusTheme\SB\Helpers\BuilderFns;
14
15 defined( 'ABSPATH' ) || exit();
16
17 /**
18 * Main ActionHooks class.
19 */
20 class ActionHooks {
21 /**
22 * Init Hooks.
23 *
24 * @return void
25 */
26 public static function init_hooks() {
27 add_action( 'wp_head', [ __CLASS__, 'og_metatags_for_sharing' ], 1 );
28 add_action( 'woocommerce_share', [ __CLASS__, 'shopbuilder_share' ], 20 );
29 add_action( 'rtsb/wcqv/product/summary', [ __CLASS__, 'shopbuilder_share' ], 40 );
30 add_action( 'rtsb/shop/product/image', [ __CLASS__, 'render_image' ], 10, 2 );
31
32 add_action(
33 'admin_init',
34 function () {
35 remove_post_type_support( BuilderFns::$post_type_tb, 'revisions' );
36 }
37 );
38 }
39
40 /**
41 * Meta tags for social sharing.
42 *
43 * @return void
44 */
45 public static function shopbuilder_share() {
46 $generalList = GeneralList::instance()->get_data();
47
48 if (
49 empty( $generalList['social_share']['share_platforms_to_product_page'] ) ||
50 'on' !== $generalList['social_share']['share_platforms_to_product_page'] ||
51 empty( $generalList['social_share']['share_platforms'] )
52 ) {
53 return;
54 }
55
56 $share_platforms = [];
57
58 foreach ( $generalList['social_share']['share_platforms'] as $value ) {
59 $share_platforms[ $value ] = [
60 'share_items' => $value,
61 'share_text' => ucwords( $value ),
62 ];
63 }
64
65 $settings['share_platforms'] = $share_platforms;
66 $settings['layout'] = ! empty( $generalList['social_share']['share_icon_layout'] ) ? $generalList['social_share']['share_icon_layout'] : 1;
67 $settings['show_share_icon'] = 1;
68
69 // TODO:: Implement Later ! empty( $generalList['social_share']['share_icon_show_to_product_page'] ) && 'on' === $generalList['social_share']['share_icon_show_to_product_page'];
70 Fns::print_html( Render::instance()->social_share_view( 'elementor/general/social-share', $settings ), true );
71 }
72
73 /**
74 * Meta tags for social sharing.
75 *
76 * @return void
77 */
78 public static function og_metatags_for_sharing() {
79 global $post;
80
81 if ( ! isset( $post ) ) {
82 return;
83 }
84
85 if ( ! is_singular( 'product' ) ) {
86 return;
87 }
88
89 Fns::print_html( '<meta property="og:url" content="' . get_the_permalink() . '" />', true );
90 Fns::print_html( '<meta property="og:type" content="article" />', true );
91 Fns::print_html( '<meta property="og:title" content="' . $post->post_title . '" />', true );
92 Fns::print_html( '<meta property="og:description" content="' . wp_trim_words( $post->post_content, 150 ) . '" />' );
93
94 $attachment = get_the_post_thumbnail_url();
95
96 if ( ! empty( $attachment ) ) {
97 Fns::print_html( '<meta property="og:image" content="' . $attachment . '" />', true );
98 }
99
100 Fns::print_html( '<meta property="og:site_name" content="' . get_bloginfo( 'name' ) . '" />', true );
101 Fns::print_html( '<meta name="twitter:card" content="summary" />', true );
102 }
103
104 /**
105 * Render image.
106 *
107 * @param array $args Image args.
108 * @param array $settings Settings array.
109 *
110 * @return void
111 */
112 public static function render_image( $args, $settings ) {
113 if ( $args['image_link'] ) {
114 $aria_label = esc_attr(
115 /* translators: Product Name */
116 sprintf( __( 'Image link for Product: %s', 'shopbuilder' ), $args['title'] )
117 );
118 ?>
119 <figure>
120 <a class="woocommerce-LoopProduct-link rtsb-img-link" href="<?php echo esc_url( $args['p_link'] ); ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>">
121 <?php
122 Fns::get_product_image( $args['img_html'], $args['hover_img_html'] );
123 ?>
124 </a>
125 </figure>
126 <?php
127 } else {
128 echo '<figure class="rtsb-img-link">';
129 Fns::get_product_image( $args['img_html'], $args['hover_img_html'] );
130 echo '</figure>';
131 }
132 }
133 }
134