PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 1.1.2
ShopBuilder – WooCommerce Builder For Elementor v1.1.2
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 1.1.2, at app/Controllers/Hooks/ActionHooks.php

93 lines 2.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
14 defined( 'ABSPATH' ) || exit();
15
16 /**
17 * Main ActionHooks class.
18 */
19 class ActionHooks {
20 /**
21 * Init Hooks.
22 *
23 * @return void
24 */
25 public static function init_hooks() {
26 add_action( 'wp_head', [ __CLASS__, 'og_metatags_for_sharing' ], 1 );
27 add_action( 'woocommerce_share', [ __CLASS__, 'shopbuilder_share' ], 20 );
28 add_action( 'rtsb/wcqv/product/summary', [ __CLASS__, 'shopbuilder_share' ], 40 );
29 }
30
31 /**
32 * Meta tags for social sharing.
33 *
34 * @return void
35 */
36 public static function shopbuilder_share() {
37
38 $generalList = GeneralList::instance()->get_data();
39
40 if (
41 empty( $generalList['social_share']['share_platforms_to_product_page'] ) ||
42 'on' !== $generalList['social_share']['share_platforms_to_product_page'] ||
43 empty( $generalList['social_share']['share_platforms'] )
44 ) {
45 return;
46 }
47
48 $share_platforms = [];
49 foreach ( $generalList['social_share']['share_platforms'] as $value ) {
50 $share_platforms[ $value ] = [
51 'share_items' => $value,
52 'share_text' => ucwords( $value ),
53 ];
54 }
55 $settings['share_platforms'] = $share_platforms;
56 $settings['layout'] = ! empty( $generalList['social_share']['share_icon_layout'] ) ? $generalList['social_share']['share_icon_layout'] : 1;
57 $settings['show_share_icon'] = 1;
58 // TODO:: Implement Later ! empty( $generalList['social_share']['share_icon_show_to_product_page'] ) && 'on' === $generalList['social_share']['share_icon_show_to_product_page'];
59 Fns::print_html( Render::instance()->social_share_view( 'elementor/general/social-share', $settings ), true );
60
61 }
62 /**
63 * Meta tags for social sharing.
64 *
65 * @return void
66 */
67 public static function og_metatags_for_sharing() {
68 global $post;
69
70 if ( ! isset( $post ) ) {
71 return;
72 }
73
74 if ( ! is_singular( 'product' ) ) {
75 return;
76 }
77
78 Fns::print_html( '<meta property="og:url" content="' . get_the_permalink() . '" />', true );
79 Fns::print_html( '<meta property="og:type" content="article" />', true );
80 Fns::print_html( '<meta property="og:title" content="' . $post->post_title . '" />', true );
81 Fns::print_html( '<meta property="og:description" content="' . wp_trim_words( $post->post_content, 150 ) . '" />' );
82
83 $attachment = get_the_post_thumbnail_url();
84
85 if ( ! empty( $attachment ) ) {
86 Fns::print_html( '<meta property="og:image" content="' . $attachment . '" />', true );
87 }
88
89 Fns::print_html( '<meta property="og:site_name" content="' . get_bloginfo( 'name' ) . '" />', true );
90 Fns::print_html( '<meta name="twitter:card" content="summary" />', true );
91 }
92 }
93