public function bewpi_download_invoice_func($atts) { $order_id = $atts['order_id']; $title = $atts['title']; $order = wc_get_order($order_id); $invoice = new BEWPI_Invoice($order->id); if ($invoice->exists() && $invoice->is_download_allowed($order->post_status)) { $url = admin_url('admin-ajax.php?action=bewpi_download_invoice&order_id=' . $order->id . '&nonce=' . wp_create_nonce('bewpi_download_invoice')); $tags = array('{formatted_invoice_number}' => $invoice->get_formatted_number(), '{order_number}' => $order->id, '{formatted_invoice_date}' => $invoice->get_formatted_invoice_date(), '{formatted_order_date}' => $invoice->get_formatted_order_date()); foreach ($tags as $key => $value) { $title = str_replace($key, $value, $title); } // example: Download (PDF) Invoice [formatted_invoice_number] echo '<a href="' . $url . '" alt="' . $title . '">' . $title . '</a>'; } }