\n\n\n"; /** * The base tracking snippet with Enchanced match support. * Documentation: https://help.pinterest.com/en/business/article/enhanced-match * * @var string */ private static $base_tag_em = "\n\n\n"; /** * The noscript base tracking snippet. * Documentation: https://help.pinterest.com/en/business/article/install-the-pinterest-tag * * @var string */ private static $noscript_base_tag = ''; /** * A list of events that are to be printed out. * * @var array */ private static $events = array(); /** * A list of events that are to be stored. * * @var array */ private static $deferred_events = array(); /** * Initialises hooks a tracker need to operate. * * @since 1.4.0 * * @return void */ public function init_hooks() { add_action( 'wp_footer', array( $this, 'print_script' ) ); add_action( 'wp_footer', array( $this, 'print_noscript' ) ); add_action( 'shutdown', array( $this, 'save_deferred_events' ) ); } /** * Disables hooks a tracker could set. * * @since 1.4.0 * * @return void */ public function disable_hooks() { remove_action( 'wp_footer', array( $this, 'print_script' ) ); remove_action( 'wp_footer', array( $this, 'print_noscript' ) ); remove_action( 'shutdown', array( $this, 'save_deferred_events' ) ); } /** * Renders Pinterest Tag script part. * * @since 1.4.0 * * @return void */ public function print_script() { $active_tag = Pinterest_For_Woocommerce()::get_setting( 'tracking_tag' ); $email = Pinterest_For_Woocommerce()::get_setting( 'enhanced_match_support' ) ? static::maybe_get_hashed_customer_email() : ''; $script = ! empty( $email ) ? self::$base_tag_em : self::$base_tag; $script = str_replace( array( self::TAG_ID_SLUG, self::HASHED_EMAIL_SLUG ), array( sanitize_key( $active_tag ), $email ), $script ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $script; $events = array_merge( static::$events, static::load_deferred_events() ); if ( ! empty( $events ) ) { //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo ''; } //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo ''; } /** * Renders Pinterest Tag