← All changes
|
includes/admin/settings/integration/facebook-integration.php
+8
-2
1.2.9
→
2.7.0
View file →
| @@ -83,9 +83,9 @@ | ||
| 83 | 83 | // phpcs:enable |
| 84 | 84 | |
| 85 | 85 | $facebook_script .= $this->facebook_pixel_events( self::$post, $fb_tracking_id ); |
| 86 | 86 | |
| 87 | - echo $facebook_script; | |
| 87 | + echo $facebook_script; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Inline pixel script; tracking IDs escaped with esc_js. | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * Facebook pixel events scripts. |
| @@ -100,9 +100,11 @@ | ||
| 100 | 100 | if ( empty( $fb_pixel_events ) ) { |
| 101 | 101 | return; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $sellkit_page_meta = $post_meta[0]['type']['key']; | |
| 104 | + $first_index = array_key_first( $post_meta ); | |
| 105 | + | |
| 106 | + $sellkit_page_meta = $post_meta[ $first_index ]['type']['key']; | |
| 105 | 107 | $fb_events_script = ''; |
| 106 | 108 | |
| 107 | 109 | foreach ( $fb_pixel_events as $event ) { |
| 108 | 110 | $function_name = "fb_pixel_{$event}"; |
| @@ -184,8 +186,12 @@ | ||
| 184 | 186 | */ |
| 185 | 187 | private function get_cart_data( $event ) { |
| 186 | 188 | $cart_data = []; |
| 187 | 189 | $products = []; |
| 190 | + | |
| 191 | + if ( ! sellkit()->has_valid_dependencies() ) { | |
| 192 | + return wp_json_encode( [] ); | |
| 193 | + } | |
| 188 | 194 | |
| 189 | 195 | $cart_total = WC()->cart->cart_contents_total + WC()->cart->tax_total; |
| 190 | 196 | |
| 191 | 197 | $products = $this->get_products_data( WC()->cart->get_cart(), 'fb' ); |