<?php 

function pm_filter_page_meta_tags($meta, $args) {
	$post_meta = $args[0];
	$get = $args[1];
	if($post_meta['permalink'] == "invoice") {
		$invoice = new pm_invoice();
		$invoice->get_invoice_by_id($get['id']);
		$name_on_invoice = ($invoice->invoice->name == NULL || $invoice->invoice->name == "") ? $invoice->name : $invoice->invoice->name;
		$title = $invoice->invoice->invoice_number. ' | ' . $name_on_invoice;
		$adjustments = [
			'title' => $title,
			'og:title' => $title,
			'description' => "Invoice number ".$invoice->invoice->invoice_number." issued by ".get_option('company_name')." to ".$name_on_invoice,
			'twitter:title' => $title,
			'twitter:description' => "Invoice number ".$invoice->invoice->invoice_number." issued by ".get_option('company_name')." to ".$name_on_invoice
		];
		$meta = array_merge($meta, $adjustments);
	}
	return $meta;
}