$value ) { $class_name = 'FacebookPixelPlugin\\Integration\\' . $value; $class_name::inject_pixel_code(); } add_action( 'wp_footer', array( $this, 'send_pending_events' ) ); } } /** * Sends any pending Facebook server-side events. * * This method checks if there are any pending Facebook server-side events, * and if so, it sends them by triggering the `send_server_events` action. * * @return void */ public function send_pending_events() { $pending_events = FacebookServerSideEvent::get_instance()->get_pending_events(); if ( count( $pending_events ) > 0 ) { do_action( 'send_server_events', $pending_events, count( $pending_events ) ); } } /** * Injects the Facebook pixel base code, Open Bridge configuration code * if CAI is enabled, Facebook pixel initialization code and Facebook * pixel page view code. * * This method is hooked into the `wp_head` action and is responsible * for injecting the necessary code to enable the Facebook pixel for * the current page. It uses the `FacebookPixel` class to generate * the necessary code and injects it into the page. * * @return void */ public function inject_pixel_code() { $pixel_id = FacebookPixel::get_pixel_id(); if ( ( isset( self::$render_cache[ FacebookPluginConfig::IS_PIXEL_RENDERED ] ) && true === self::$render_cache[ FacebookPluginConfig::IS_PIXEL_RENDERED ] ) || empty( $pixel_id ) ) { return; } self::$render_cache[ FacebookPluginConfig::IS_PIXEL_RENDERED ] = true; echo FacebookPixel::get_pixel_base_code(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $capi_integration_status = FacebookWordpressOptions::get_capi_integration_status(); // Only include user info for frontend users, not internal/admin users. $user_info = FacebookPluginUtils::is_internal_user() ? array() : FacebookWordpressOptions::get_user_info(); echo FacebookPixel::get_pixel_init_code( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped FacebookWordpressOptions::get_agent_string(), $user_info, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped '1' === $capi_integration_status // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ); echo FacebookPixel::get_pixel_page_view_code(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** * Injects the Facebook Pixel noscript code. * * This method is responsible for adding the noscript version of the * Facebook Pixel code to the page. It uses the `get_pixel_noscript_code` * method from the `FacebookPixel` class to generate the necessary code. * * @return void */ public function inject_pixel_noscript_code() { echo FacebookPixel::get_pixel_noscript_code(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } }