/** * Remove all scripts and styles from the estimate view and then add those specific to si. * @return */ public static function remove_scripts_and_styles() { if (SI_Invoice::is_invoice_query() && is_single()) { if (apply_filters('si_remove_scripts_styles_on_doc_pages', '__return_true')) { global $wp_scripts, $wp_styles; $allowed_scripts = apply_filters('si_allowed_doc_scripts', array('sprout_doc_scripts', 'qtip', 'dropdown')); $allowed_admin_scripts = apply_filters('si_allowed_admin_doc_scripts', array_merge(array('admin-bar'), $allowed_scripts)); if (current_user_can('edit_sprout_invoices')) { $wp_scripts->queue = $allowed_admin_scripts; } else { $wp_scripts->queue = $allowed_scripts; } $allowed_styles = apply_filters('si_allowed_doc_styles', array('sprout_doc_style', 'qtip', 'dropdown')); $allowed_admin_styles = apply_filters('si_allowed_admin_doc_styles', array_merge(array('admin-bar'), $allowed_styles)); if (current_user_can('edit_sprout_invoices')) { $wp_styles->queue = $allowed_admin_styles; } else { $wp_styles->queue = $allowed_styles; } do_action('si_doc_enqueue_filtered'); } else { // scripts wp_enqueue_script('sprout_doc_scripts'); wp_enqueue_script('dropdown'); wp_enqueue_script('qtip'); // Styles wp_enqueue_style('sprout_doc_style'); wp_enqueue_style('dropdown'); wp_enqueue_style('qtip'); } } }
/** * Override the template and use something custom. * @param string $template * @return string full path. */ public static function override_template($template) { // Invoicing if (SI_Invoice::is_invoice_query()) { if (is_single()) { if (!current_user_can('edit_sprout_invoices') && apply_filters('si_redirect_temp_status', true)) { $status = get_post_status(); if (SI_Invoice::STATUS_TEMP === $status) { wp_safe_redirect(add_query_arg(array('si_id' => get_the_id()), get_home_url())); exit; } } $custom_template = self::get_doc_current_template(get_the_id()); $custom_path = $custom_template != '' ? 'invoice/' . $custom_template : ''; $template = self::locate_template(array($custom_path, 'invoice-' . get_locale() . '.php', 'invoice.php', 'invoice/invoice.php'), $template); } else { $status = get_query_var(self::FILTER_QUERY_VAR); $template = self::locate_template(array('invoice/' . $status . '-invoices.php', $status . '-invoices.php', 'invoices.php', 'invoice/invoices.php'), $template); } $template = apply_filters('si_doc_template', $template, 'invoice'); } // Estimates if (SI_Estimate::is_estimate_query()) { if (is_single()) { if (!current_user_can('edit_sprout_invoices') && apply_filters('si_redirect_temp_status', true)) { $status = get_post_status(); if (SI_Estimate::STATUS_TEMP === $status) { wp_safe_redirect(add_query_arg(array('si_id' => get_the_id()), get_home_url())); exit; } } $custom_template = self::get_doc_current_template(get_the_id()); $custom_path = $custom_template != '' ? 'estimate/' . $custom_template : ''; $template = self::locate_template(array($custom_path, 'estimate-' . get_locale() . '.php', 'estimate.php', 'estimate/estimate.php'), $template); } else { $status = get_query_var(self::FILTER_QUERY_VAR); $template = self::locate_template(array('estimate/' . $status . '-estimates.php', $status . '-estimates.php', 'estimates.php', 'estimate/estimates.php'), $template); } $template = apply_filters('si_doc_template', $template, 'estimate'); } return $template; }
/** * Override the template and use something custom. * @param string $template * @return string full path. */ public static function override_template($template) { if (isset($_REQUEST[self::CHECKOUT_QUERY_VAR])) { if (SI_Invoice::is_invoice_query()) { $checkout = self::get_instance(); $current = $checkout->get_current_page(); $template = self::locate_template(array('checkout/' . $current . '.php', 'checkout-' . $current . '.php', 'checkout.php', 'invoice/checkout-' . $current . '.php', 'invoice/checkout.php', 'invoice.php', 'invoice/invoice.php'), $template); } } return $template; }
/** * Override the template and use something custom. * @param string $template * @return string full path. */ public static function override_template($template) { // Invoicing if (SI_Invoice::is_invoice_query()) { if (is_single()) { $custom_template = self::get_doc_current_template(get_the_id()); $custom_path = $custom_template != '' ? 'invoice/' . $custom_template : ''; $template = self::locate_template(array($custom_path, 'invoice-' . get_locale() . '.php', 'invoice.php', 'invoice/invoice.php'), $template); } else { $status = get_query_var(self::FILTER_QUERY_VAR); $template = self::locate_template(array('invoice/' . $status . '-invoices.php', $status . '-invoices.php', 'invoices.php', 'invoice/invoices.php'), $template); } $template = apply_filters('si_doc_template', $template, 'invoice'); } // Estimates if (SI_Estimate::is_estimate_query()) { if (is_single()) { $custom_template = self::get_doc_current_template(get_the_id()); $custom_path = $custom_template != '' ? 'estimate/' . $custom_template : ''; $template = self::locate_template(array($custom_path, 'estimate-' . get_locale() . '.php', 'estimate.php', 'estimate/estimate.php'), $template); } else { $status = get_query_var(self::FILTER_QUERY_VAR); $template = self::locate_template(array('estimate/' . $status . '-estimates.php', $status . '-estimates.php', 'estimates.php', 'estimate/estimates.php'), $template); } $template = apply_filters('si_doc_template', $template, 'estimate'); } return $template; }