public function output() { $attachments = array(); if ($this->query->have_posts()) { while ($this->query->have_posts()) { $this->query->the_post(); global $post; $invoice = WC_Germanized_Pro()->invoice_factory->get_invoice($post); if ($invoice->has_attachment()) { $attachments[$invoice->id] = array('path' => $invoice->get_pdf_path(), 'filename' => $invoice->get_filename()); } } } if (!empty($attachments)) { $upload_dir = WC_germanized_pro()->get_upload_dir(); $this->filename = wp_unique_filename($upload_dir['path'], $this->filename); $this->filepath = trailingslashit($upload_dir['path']) . $this->filename; $zip = new ZipArchive(); $zip->open($this->filepath, ZipArchive::CREATE); foreach ($attachments as $attachment) { $zip->addFile($attachment['path'], $attachment['filename']); } $zip->close(); header('Content-Length: ' . filesize($this->filepath)); readfile($this->filepath); } }
public function load_styles() { $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; $css = WC_germanized_pro()->plugin_path() . '/themes/assets/css/wc-gzdp-' . $this->name . $suffix . '.css'; if (file_exists($css)) { wp_register_style('wc-gzdp-' . $this->name, WC_germanized_pro()->plugin_url() . '/themes/assets/css/wc-gzdp-' . $this->name . $suffix . '.css', array(), WC_GERMANIZED_PRO_VERSION); wp_enqueue_style('wc-gzdp-' . $this->name); } }
public static function confirm_order() { if (current_user_can('edit_shop_orders') && check_admin_referer('woocommerce-gzdp-confirm-order')) { $order_id = absint($_GET['order_id']); if ($order_id) { $order = wc_get_order($order_id); WC_germanized_pro()->contract_helper->confirm_order($order->id); } } wp_safe_redirect(wp_get_referer() ? wp_get_referer() : admin_url('edit.php?post_type=shop_order')); die; }
public function add_admin_assets() { $screen = get_current_screen(); wp_enqueue_style('wc-gzdp-admin', WC_germanized_pro()->plugin_url() . '/assets/css/admin/wc-gzdp-admin' . $this->suffix . '.css', array(), WC_GERMANIZED_PRO_VERSION); if (in_array($screen->id, array('shop_order', 'edit-shop_order'))) { // Invoice JS wp_enqueue_script('wc-gzdp-admin-invoice', WC_germanized_pro()->plugin_url() . '/assets/js/admin/invoice' . $this->suffix . '.js', array('jquery'), WC_GERMANIZED_PRO_VERSION, true); // Order JS wp_enqueue_script('wc-gzdp-admin-order', WC_germanized_pro()->plugin_url() . '/assets/js/admin/order' . $this->suffix . '.js', array('jquery'), WC_GERMANIZED_PRO_VERSION, true); } else { if ($screen->id == 'woocommerce_page_wc-settings') { wp_enqueue_media(); wp_enqueue_style('wc-gzd-fontawesome', WC_germanized()->plugin_url() . '/assets/css/font-awesome.min.css', array(), WC_GERMANIZED_VERSION); wp_register_script('wc-gzdp-admin-settings', WC_germanized_pro()->plugin_url() . '/assets/js/admin/settings' . $this->suffix . '.js', array('jquery'), WC_GERMANIZED_PRO_VERSION, true); wp_localize_script('wc-gzdp-admin-settings', 'wc_gzdp_attachment_field', array('title' => _x('Choose Attachment', 'admin-field', 'woocommerce-germanized-pro'), 'insert' => _x('Set attachment', 'admin-field', 'woocommerce-germanized-pro'), 'unset' => _x('Unset attachment', 'admin-field', 'woocommerce-germanized-pro'), 'ajax_url' => admin_url('admin-ajax.php'))); wp_localize_script('wc-gzdp-admin-settings', 'wc_gzdp', array('ajax_url' => admin_url('admin-ajax.php'))); wp_enqueue_script('wc-gzdp-admin-settings'); } } do_action('woocommerce_gzdp_admin_assets'); }
public function set_upload_writeable_notice() { if (!wp_is_writable(WC_germanized_pro()->plugin_path() . '/uploads')) { ?> <div class="error"> <p><?php printf(_x('Seems to be that your PDF upload directory (%s) is not writeable. Please set <a href="%s" target="_blank">file permissions</a>.', 'invoices', 'woocommerce-germanized-pro'), WC_germanized_pro()->plugin_path() . '/uploads/', 'http://codex.wordpress.org/Changing_File_Permissions'); ?> </p> </div> <?php } }
function wc_gzdp_get_invoice($invoice = false, $type = 'simple') { return WC_germanized_pro()->invoice_factory->get_invoice($invoice, $type); }
public function stop_checkout_theme_override($template, $template_name, $template_path) { if ($template_name == 'checkout/form-checkout.php') { // Maybe force template override if (get_option('woocommerce_gzdp_checkout_force_template_override') == 'yes') { $template = WC()->plugin_path() . '/templates/' . $template_name; } // Allow theme override by using woocommerce-germanized-pro/checkout/multistep/form-checkout.php template if ($loc = locate_template(WC_germanized_pro()->template_path() . 'checkout/multistep/form-checkout.php')) { $template = $loc; } else { $template = apply_filters('woocommerce_gzdp_checkout_template_not_found', $template, 'checkout/multistep/form-checkout.php', $template_path); } } return $template; }
/** * Handle updates */ public function update() { // Do updates $current_db_version = get_option('woocommerce_gzdp_db_version'); update_option('woocommerce_gzdp_db_version', WC_germanized_pro()->version); }
public function save($settings) { $generator = sanitize_title($_POST['generator']); $product = WC_germanized_pro()->get_vd_product(); // Delete hidden options $options = $this->get_options($generator . '_'); if (!empty($options)) { foreach ($options as $key => $option) { if (!isset($_POST[$generator . '_' . $key])) { delete_option($generator . '_' . $key); } } } if (!$product->is_registered()) { WC_Admin_Settings::add_error(_x('Please register WooCommerce Germanized Pro to enable the Generator.', 'generator', 'woocommerce-germanized-pro')); } $version = $this->get_version($generator); $remote = VD()->api->generator_version_check($product, $generator); if (!$remote) { return; } if (version_compare($version, $remote->version, "<")) { WC_Admin_Settings::add_error(_x('Seems like the Generator Version is not up to date. Please refresh before generating.', 'generator', 'woocommerce-germanized-pro')); } // Get data $data = array(); if (!empty($settings)) { foreach ($settings as $key => $setting) { if (isset($_POST[$setting['id']])) { $data[$setting['id']] = apply_filters('woocommerce_gzdp_generator_setting_' . $setting['id'], !is_array($_POST[$setting['id']]) ? esc_attr($_POST[$setting['id']]) : (array) $_POST[$setting['id']], $setting); } } } $result = VD()->api->generator_result_check($product, $generator, $data, $this->get_options('woocommerce_', $remote->settings)); if (!$result) { WC_Admin_Settings::add_error(_x('There seems to be a problem while generating. Is your update flatrate still active?', 'generator', 'woocommerce-germanized-pro')); } else { $this->populate_settings_observal($generator); set_transient('woocommerce_gzdp_generator_' . $generator, $result, 3 * HOUR_IN_SECONDS); set_transient('woocommerce_gzdp_generator_success_' . $generator, $result, 3 * HOUR_IN_SECONDS); } remove_action('woocommerce_gzd_after_save_section_' . $generator, array($this, 'save'), 0); }
* @param string $path * @param string $textdomain * @param string $prefix */ public function load_translation($path, $textdomain, $prefix) { if (is_readable($path . $prefix . '-de_DE.mo')) { load_textdomain($textdomain, $path . $prefix . '-de_DE.mo'); } } /** * Show action links on the plugin screen * * @param mixed $links * @return array */ public function action_links($links) { return array_merge(array('<a href="' . admin_url('admin.php?page=wc-settings&tab=germanized') . '">' . __('Settings', 'woocommerce') . '</a>', '<a href="https://vendidero.de/mein-konto">' . __('Support', 'woocommerce-germanized-pro') . '</a>'), $links); } } } /** * Returns the global instance of WooCommerce Germanized */ function WC_germanized_pro() { return WooCommerce_Germanized_Pro::instance(); } $GLOBALS['woocommerce_germanized_pro'] = WC_germanized_pro();
public function add_emails($emails) { if (!isset($emails['WC_Email_Customer_Processing_Order'])) { return $emails; } // Swap emails to disable automatic order confirmation $emails['WC_GZDP_Email_Customer_Order_Confirmation'] = (include WC_germanized_pro()->plugin_path() . '/includes/emails/class-wc-gzdp-email-customer-order-confirmation.php'); $emails['WC_Email_Customer_Processing_Order'] = (include WC_germanized_pro()->plugin_path() . '/includes/emails/class-wc-gzdp-email-customer-processing-order.php'); return $emails; }