get_meta(Affilibee_Config::META_KEY_AFFILIATE_SLUG)) { return; } $cookie_name = Affilibee_Config::COOKIE_NAME; if (isset($_COOKIE[$cookie_name])) { // Sanitize and validate the cookie value. $affiliate_slug = sanitize_text_field(wp_unslash($_COOKIE[$cookie_name])); if (preg_match('/^[A-Za-z0-9_.-]{1,100}$/', $affiliate_slug)) { $order->update_meta_data(Affilibee_Config::META_KEY_AFFILIATE_SLUG, $affiliate_slug); $order->save(); } } } /** * Show attribution info in the order details panel (admin). */ public static function display_order_meta_section($order): void { if (!$order instanceof WC_Order) { $order = wc_get_order($order); if (!$order) { return; } } $affiliate_slug = $order->get_meta(Affilibee_Config::META_KEY_AFFILIATE_SLUG); if (!$affiliate_slug) { return; } printf( '
%s
', sprintf( /* translators: %s: affiliate slug */ esc_html__('This order was attributed to affiliate %s via Affilibee.', 'affilibee-for-woocommerce'), '' . esc_html($affiliate_slug) . '' ) ); } // Example UI for segment slugs (disabled by default). // public static function display_product_segment_slugs(): void // { // global $post; // if ( ! $post ) { // return; // } // $slugs = Affilibee_Helpers::get_product_segment_slugs( (int) $post->ID ); // echo ''; // } }