# shopbuilder/1.0.0/app/Controllers/Hooks/ActionHooks.php

ShopBuilder – WooCommerce Builder For Elementor, version 1.0.0. 92 lines.

- Page: https://pluginprobe.com/plugins/shopbuilder/1.0.0/code/app/Controllers/Hooks/ActionHooks.php
- Raw: https://pluginprobe.com/plugins/shopbuilder/1.0.0/raw/app/Controllers/Hooks/ActionHooks.php
- Modified: 2023-03-09T09:36:06+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/shopbuilder/1.0.0/code/app/Controllers/Hooks/ActionHooks.php#L10-L20`.

```php
<?php
/**
 * Main ActionHooks class.
 *
 * @package RadiusTheme\SB
 */

namespace RadiusTheme\SB\Controllers\Hooks;

use RadiusTheme\SB\Elementor\Render\Render;
use RadiusTheme\SB\Helpers\Fns;
use RadiusTheme\SB\Models\GeneralList;

defined( 'ABSPATH' ) || exit();

/**
 * Main ActionHooks class.
 */
class ActionHooks {
	/**
	 * Init Hooks.
	 *
	 * @return void
	 */
	public static function init_hooks() {
		add_action( 'wp_head', [ __CLASS__, 'og_metatags_for_sharing' ], 1 );
        add_action( 'woocommerce_share' , [ __CLASS__, 'shopbuilder_share' ], 20 );
        add_action( 'rtsb_wcqv_product_summary', [ __CLASS__, 'shopbuilder_share' ], 40 );
	}

    /**
     * Meta tags for social sharing.
     *
     * @return void
     */
    public static function shopbuilder_share() {

        $generalList = GeneralList::instance()->get_data();

        if(
            empty( $generalList['social_share']['share_platforms_to_product_page'] ) ||
            'on' !== $generalList['social_share']['share_platforms_to_product_page'] ||
            empty( $generalList['social_share']['share_platforms'] )
        ){
            return;
        }

        $share_platforms = [];
        foreach ( $generalList['social_share']['share_platforms'] as $value ){
            $share_platforms[$value] = [
                'share_items' => $value,
                'share_text'  => ucwords( $value ),
            ];
        }
        $settings['share_platforms'] = $share_platforms;
        $settings['layout'] = ! empty( $generalList['social_share']['share_icon_layout'] ) ? $generalList['social_share']['share_icon_layout'] : 1 ;
        $settings['show_share_icon'] = 1;// TODO:: Implement Later ! empty( $generalList['social_share']['share_icon_show_to_product_page'] ) && 'on' === $generalList['social_share']['share_icon_show_to_product_page'];
        Fns::print_html( Render::instance()->social_share_view( 'elementor/general/social-share', $settings ), true );

    }
	/**
	 * Meta tags for social sharing.
	 *
	 * @return void
	 */
	public static function og_metatags_for_sharing() {
		global $post;

		if ( ! isset( $post ) ) {
			return;
		}

		if ( ! is_singular( 'product' ) ) {
			return;
		}

		Fns::print_html( '<meta property="og:url" content="' . get_the_permalink() . '" />', true );
		Fns::print_html( '<meta property="og:type" content="article" />', true );
		Fns::print_html( '<meta property="og:title" content="' . $post->post_title . '" />', true );
		Fns::print_html( '<meta property="og:description" content="' . wp_trim_words( $post->post_content, 150 ) . '" />' );

		$attachment = get_the_post_thumbnail_url();

		if ( ! empty( $attachment ) ) {
			Fns::print_html( '<meta property="og:image" content="' . $attachment . '" />', true );
		}

		Fns::print_html( '<meta property="og:site_name" content="' . get_bloginfo( 'name' ) . '" />', true );
		Fns::print_html( '<meta name="twitter:card" content="summary" />', true );
	}
}

```
