/** * Constructor */ public function __construct() { // Define the templates self::$template_registrations = apply_filters('wcdn_template_registration', array(apply_filters('wcdn_template_registration_invoice', array('type' => 'invoice', 'labels' => array('name' => __('Invoice', 'woocommerce-delivery-notes'), 'name_plural' => __('Invoices', 'woocommerce-delivery-notes'), 'print' => __('Print Invoice', 'woocommerce-delivery-notes'), 'print_plural' => __('Print Invoices', 'woocommerce-delivery-notes'), 'message' => __('Invoice created.', 'woocommerce-delivery-notes'), 'message_plural' => __('Invoices created.', 'woocommerce-delivery-notes'), 'setting' => __('Show "Print Invoice" button', 'woocommerce-delivery-notes')))), apply_filters('wcdn_template_registration_delivery_note', array('type' => 'delivery-note', 'labels' => array('name' => __('Delivery Note', 'woocommerce-delivery-notes'), 'name_plural' => __('Delivery Notes', 'woocommerce-delivery-notes'), 'print' => __('Print Delivery Note', 'woocommerce-delivery-notes'), 'print_plural' => __('Print Delivery Notes', 'woocommerce-delivery-notes'), 'message' => __('Delivery Note created.', 'woocommerce-delivery-notes'), 'message_plural' => __('Delivery Notes created.', 'woocommerce-delivery-notes'), 'setting' => __('Show "Print Delivery Note" button', 'woocommerce-delivery-notes')))), apply_filters('wcdn_template_registration_receipt', array('type' => 'receipt', 'labels' => array('name' => __('Receipt', 'woocommerce-delivery-notes'), 'name_plural' => __('Receipts', 'woocommerce-delivery-notes'), 'print' => __('Print Receipt', 'woocommerce-delivery-notes'), 'print_plural' => __('Print Receipts', 'woocommerce-delivery-notes'), 'message' => __('Receipt created.', 'woocommerce-delivery-notes'), 'message_plural' => __('Receipts created.', 'woocommerce-delivery-notes'), 'setting' => __('Show "Print Receipt" button', 'woocommerce-delivery-notes')))))); // Add the default template as first item after filter hooks passed array_unshift(self::$template_registrations, array('type' => 'order', 'labels' => array('name' => __('Order', 'woocommerce-delivery-notes'), 'name_plural' => __('Orders', 'woocommerce-delivery-notes'), 'print' => __('Print Order', 'woocommerce-delivery-notes'), 'print_plural' => __('Print Orders', 'woocommerce-delivery-notes'), 'message' => null, 'message_plural' => null, 'setting' => null))); // Template styles self::$template_styles = apply_filters('wcdn_template_styles', array()); // Add the default style as first item after filter hooks passed array_unshift(self::$template_styles, array('name' => __('Default', 'woocommerce-delivery-notes'), 'type' => 'default', 'path' => WooCommerce_Delivery_Notes::$plugin_path . 'templates/print-order/', 'url' => WooCommerce_Delivery_Notes::$plugin_url . 'templates/print-order/')); // Default template $this->template = self::$template_registrations[0]; // Build all template locations $this->template_locations = $this->build_template_locations(); // Add the endpoint for the frontend $this->api_endpoints = array('print-order' => get_option('wcdn_print_order_page_endpoint', 'print-order')); // Insert the query vars $this->query_vars = array('print-order-type', 'print-order-email'); // Load the hooks add_action('init', array($this, 'load_hooks')); add_filter('query_vars', array($this, 'add_query_vars')); add_action('parse_request', array($this, 'parse_request')); add_action('template_redirect', array($this, 'template_redirect_theme')); add_action('wp_ajax_print_order', array($this, 'template_redirect_admin')); }
/** * Constructor */ public function __construct() { // Define the templates self::$templates = apply_filters('wcdn_template_registration', array(apply_filters('wcdn_template_registration_invoice', array('type' => 'invoice', 'labels' => array('name' => __('Invoice', 'woocommerce-delivery-notes'), 'name_plural' => __('Invoices', 'woocommerce-delivery-notes'), 'print' => __('Print Invoice', 'woocommerce-delivery-notes'), 'print_plural' => __('Print Invoices', 'woocommerce-delivery-notes'), 'message' => __('Invoice created.', 'woocommerce-delivery-notes'), 'message_plural' => __('Invoices created.', 'woocommerce-delivery-notes'), 'setting' => __('Enable Invoices', 'woocommerce-delivery-notes')))), apply_filters('wcdn_template_registration_delivery_note', array('type' => 'delivery-note', 'labels' => array('name' => __('Delivery Note', 'woocommerce-delivery-notes'), 'name_plural' => __('Delivery Notes', 'woocommerce-delivery-notes'), 'print' => __('Print Delivery Note', 'woocommerce-delivery-notes'), 'print_plural' => __('Print Delivery Notes', 'woocommerce-delivery-notes'), 'message' => __('Delivery Note created.', 'woocommerce-delivery-notes'), 'message_plural' => __('Delivery Notes created.', 'woocommerce-delivery-notes'), 'setting' => __('Enable Delivery Notes', 'woocommerce-delivery-notes')))), apply_filters('wcdn_template_registration_receipt', array('type' => 'receipt', 'labels' => array('name' => __('Receipt', 'woocommerce-delivery-notes'), 'name_plural' => __('Receipts', 'woocommerce-delivery-notes'), 'print' => __('Print Receipt', 'woocommerce-delivery-notes'), 'print_plural' => __('Print Receipts', 'woocommerce-delivery-notes'), 'message' => __('Receipt created.', 'woocommerce-delivery-notes'), 'message_plural' => __('Receipts created.', 'woocommerce-delivery-notes'), 'setting' => __('Enable Receipts', 'woocommerce-delivery-notes')))))); // Default empty template $this->template = array('type' => 'order', 'labels' => array('name' => __('Order', 'woocommerce-delivery-notes'), 'name_plural' => __('Orders', 'woocommerce-delivery-notes'), 'print' => __('Print Order', 'woocommerce-delivery-notes'), 'print_plural' => __('Print Orders', 'woocommerce-delivery-notes'), 'message' => null, 'message_plural' => null, 'setting' => null)); // Add the endpoint for the frontend $this->api_endpoints = array('print-order' => get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'print_order_page_endpoint', 'print-order')); // Insert the query vars $this->query_vars = array('print-order-type', 'print-order-email'); // Load the hooks add_action('init', array($this, 'load_hooks')); add_filter('query_vars', array($this, 'add_query_vars')); add_action('parse_request', array($this, 'parse_request')); add_action('template_redirect', array($this, 'template_redirect_theme')); add_action('wp_ajax_print_order', array($this, 'template_redirect_admin')); }