/**
  * Show the subscription template when view a subscription instead of loading the default order template.
  *
  * @param $located
  * @param $template_name
  * @param $args
  * @param $template_path
  * @param $default_path
  * @since 2.0
  */
 public static function add_view_subscription_template($located, $template_name, $args, $template_path, $default_path)
 {
     global $wp;
     if ('myaccount/my-account.php' == $template_name && !empty($wp->query_vars['view-subscription']) && WC_Subscriptions::is_woocommerce_pre('2.6')) {
         $located = wc_locate_template('myaccount/view-subscription.php', $template_path, plugin_dir_path(WC_Subscriptions::$plugin_file) . 'templates/');
     }
     return $located;
 }
 /**
  * Get Plugin Template
  *
  * It's possible to overwrite the template from theme.
  * Put your custom template in woocommerce/product-vendors folder
  *
  * @param        $filename
  * @param array  $args
  * @param string $section
  * @use  wc_get_template()
  * @since 1.0
  * @return void
  */
 function yith_wcpv_get_template($filename, $args = array(), $section = '')
 {
     $ext = strpos($filename, '.php') === false ? '.php' : '';
     $template_name = $section . '/' . $filename . $ext;
     $template_path = WC()->template_path() . 'product-vendors/';
     $default_path = YITH_WPV_TEMPLATE_PATH;
     if (defined('YITH_WPV_PREMIUM')) {
         $premium_template = str_replace('.php', '-premium.php', $template_name);
         $located_premium = wc_locate_template($premium_template, $template_path, $default_path);
         $template_name = file_exists($located_premium) ? $premium_template : $template_name;
     }
     wc_get_template($template_name, $args, $template_path, $default_path);
 }
Пример #3
0
 /**
  * Get template for Brands plugin
  *
  * @param $filename string Template name (with or without extension)
  * @param $args mixed Array of params to use in the template
  * @param $section string Subdirectory where to search
  */
 function yith_wcbr_get_template($filename, $args = array(), $section = '')
 {
     $ext = strpos($filename, '.php') === false ? '.php' : '';
     $template_name = $section . '/' . $filename . $ext;
     $template_path = WC()->template_path() . 'yith-wcbr/';
     $default_path = YITH_WCBR_DIR . 'templates/';
     if (defined('YITH_WCBR_PREMIUM')) {
         $premium_template = str_replace('.php', '-premium.php', $template_name);
         $located_premium = wc_locate_template($premium_template, $template_path, $default_path);
         $template_name = file_exists($located_premium) ? $premium_template : $template_name;
     }
     wc_get_template($template_name, $args, $template_path, $default_path);
 }
 /**
  * Show the cancel and skip subscription template when the cancel action has been pressed.
  * Show a confirmation template when the customer decides to cancel the subscription.
  * Show a succesfull skipped subscription template when the customer decides to skip a subscription.
  * Show a succesfull unskipped subscription template when the customer decides to unskip a subscription.
  *
  * @since  1.0.0
  * @access public
  * @static
  * @param  $located
  * @param  $template_name
  * @param  $args
  * @param  $template_path
  * @param  $default_path
  */
 public static function add_skip_subscription_template($located, $template_name, $args, $template_path, $default_path)
 {
     global $wp;
     if ('myaccount/my-account.php' == $template_name && !empty($wp->query_vars['cancel-subscription'])) {
         $located = wc_locate_template('myaccount/cancel-subscription.php', $template_path, WCSO_PLUGIN_DIR . '/templates/');
     }
     if ('myaccount/my-account.php' == $template_name && !empty($wp->query_vars['confirm-cancel'])) {
         $located = wc_locate_template('myaccount/confirm-cancel.php', $template_path, WCSO_PLUGIN_DIR . '/templates/');
     }
     if ('myaccount/my-account.php' == $template_name && !empty($wp->query_vars['subscription-skipped'])) {
         $located = wc_locate_template('myaccount/subscription-successfully-skipped.php', $template_path, WCSO_PLUGIN_DIR . '/templates/');
     }
     if ('myaccount/my-account.php' == $template_name && !empty($wp->query_vars['subscription-unskipped'])) {
         $located = wc_locate_template('myaccount/subscription-unskipped.php', $template_path, WCSO_PLUGIN_DIR . '/templates/');
     }
     return $located;
 }
Пример #5
0
/**
 * Get other templates (e.g. product attributes) passing attributes and including the file.
 *
 * @access public
 * @param string $template_name
 * @param array $args (default: array())
 * @param string $template_path (default: '')
 * @param string $default_path (default: '')
 */
function wc_get_template($template_name, $args = array(), $template_path = '', $default_path = '')
{
    if ($args && is_array($args)) {
        extract($args);
    }
    $located = wc_locate_template($template_name, $template_path, $default_path);
    if (!file_exists($located)) {
        _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1');
        return;
    }
    // Allow 3rd party plugin filter template file from their plugin
    $located = apply_filters('wc_get_template', $located, $template_name, $args, $template_path, $default_path);
    do_action('woocommerce_before_template_part', $template_name, $template_path, $located, $args);
    include $located;
    do_action('woocommerce_after_template_part', $template_name, $template_path, $located, $args);
}
/**
 * @deprecated
 */
function woocommerce_locate_template($template_name, $template_path = '', $default_path = '')
{
    return wc_locate_template($template_name, $template_path, $default_path);
}
 /**
  * Change single add to cart template
  *
  * @param $located
  * @param $template_name
  * @param $args
  * @param $template_path
  * @param $default_path
  *
  * @return string Located file
  *
  * @since    1.7
  * @author   Andrea Grillo <*****@*****.**>
  */
 public function hide_single_add_to_cart($located, $template_name, $args, $template_path, $default_path)
 {
     if (is_singular('product') && preg_match('/single-product\\/add-to-cart\\/(\\S+).php/', $template_name)) {
         $vendor = yith_get_vendor('current', 'product');
         if ($vendor->is_on_vacation()) {
             if ('disabled' == $vendor->vacation_selling) {
                 $located = wc_locate_template('single-product/store-vacation.php', WC()->template_path(), YITH_WPV_TEMPLATE_PATH . '/woocommerce/');
             } elseif ('enabled' == $vendor->vacation_selling) {
                 add_action('woocommerce_before_template_part', array($this, 'add_vacation_template'), 10, 4);
             }
         }
     }
     return $located;
 }
 public function locate_template($template)
 {
     $default_path = WC_QD_TEMPLATE;
     $template_path = WC_CORE_TEMPLATE . 'donation/';
     $template = $template;
     $locate = wc_locate_template($template, $template_path, $default_path);
     return $locate;
 }
 public function wc_get_template($located, $template_name, $args, $template_path, $default_path)
 {
     if ("single-product/rating.php" != $template_name) {
         return $located;
     }
     $located = wc_locate_template("ywar-rating.php", $template_path, $default_path);
     if (file_exists($located)) {
         return $located;
     }
     return YITH_YWAR_TEMPLATES_DIR . 'ywar-rating.php';
 }
 public function get_text_data($mail)
 {
     if ($text_data = get_transient('woo_email_manager_text_' . $mail->id)) {
         return $text_data;
     }
     $template = $mail->template_html;
     if ($mail->get_option('type') === 'plain') {
         $template = $mail->template_plain;
     }
     $template_file = wc_locate_template($template);
     // Parse text in email
     $file = fopen($template_file, 'r');
     $content = '';
     if ($file) {
         $content = fread($file, filesize($template_file));
     }
     $gettexts = array();
     if (!empty($content)) {
         preg_match_all('/_(_|e|x)\\(.*,.?(\'|\\").*(\'|\\").?\\)/', $content, $matches);
         if (!empty($matches[0])) {
             foreach ($matches[0] as $string) {
                 $string = str_replace('"', "'", $string);
                 $items = explode("'", $string);
                 if (!isset($items[3])) {
                     continue;
                 }
                 $gettexts[] = array('text' => trim($items[1]), 'textdomain' => strpos($string, '_x') !== false && isset($items[5]) ? trim($items[5]) : trim($items[3]), 'specified' => strpos($string, '_x') !== false && isset($items[3]) ? $items[3] : false);
             }
         }
     }
     set_transient('woo_email_manager_text_' . $mail->id, $gettexts, WEEK_IN_SECONDS);
     return $gettexts;
 }
/**
 * Get other templates (e.g. product attributes) passing attributes and including the file.
 *
 * @access public
 * @param mixed $template_name
 * @param array $args (default: array())
 * @param string $template_path (default: '')
 * @param string $default_path (default: '')
 * @return void
 */
function wc_get_template($template_name, $args = array(), $template_path = '', $default_path = '')
{
    if ($args && is_array($args)) {
        extract($args);
    }
    $located = wc_locate_template($template_name, $template_path, $default_path);
    do_action('woocommerce_before_template_part', $template_name, $template_path, $located, $args);
    include $located;
    do_action('woocommerce_after_template_part', $template_name, $template_path, $located, $args);
}
 public function get_template($located, $template_name, $args, $template_path, $default_path)
 {
     $file = '';
     $order_id = 0;
     $found = false;
     if (isset($args['order_id'])) {
         $order_id = $args['order_id'];
     }
     if (isset($args['order']->id)) {
         $order_id = $args['order']->id;
     }
     if (isset(self::$search_template['general'][$template_name])) {
         $file = WC_QD()->f()->locate_template(self::$search_template['general'][$template_name]);
         $found = true;
     }
     if (WC_QD()->check_donation_exists_cart()) {
         if (isset(self::$search_template['is_donation'][$template_name])) {
             $file = WC_QD()->f()->locate_template(self::$search_template['is_donation'][$template_name]);
             $found = true;
         }
     }
     if (WC_QD()->db()->_is_donation($order_id)) {
         if (isset(self::$search_template['after_order'][$template_name])) {
             $file = WC_QD()->f()->locate_template(self::$search_template['after_order'][$template_name]);
             $found = true;
         }
     }
     if ($found) {
         return $file;
     } else {
         $file = wc_locate_template($template_name);
         return $file;
     }
     return $located;
 }
 /**
  * Locate the template file for this email
  *
  * Looks for templates in the following order:
  * 1. emails/{$type}-order-status-email-{$slug}.php
  * 2. emails/{$type}-order-status-email-{$id}.php
  * 3. emails/{$type}-order-status-email.php
  *
  * Templates are looked for in current theme, then our plugin and then WC core.
  *
  * @since 1.0.0
  * @param string $type Optional. Type of template to locate. One of `html` or `plain`. Defaults to `html`
  * @return string Path to template file
  */
 public function locate_email_template($type = 'html')
 {
     $type_path = 'plain' == $type ? 'plain/' : '';
     $templates = array("emails/{$type_path}{$this->type}-order-status-email-{$this->post_id}.php", "emails/{$type_path}{$this->type}-order-status-email.php");
     if ($email_slug = sanitize_title($this->title)) {
         array_unshift($templates, "emails/{$type_path}{$this->type}-order-status-email-{$email_slug}.php");
     }
     $located_template = '';
     // Try to locate the template file, starting from most specific
     foreach ($templates as $template_path) {
         $located = wc_locate_template($template_path);
         if ($located && file_exists($located)) {
             $located_template = $template_path;
             break;
         }
     }
     return $located_template;
 }
 public function tm_wc_get_template($located = "", $template_name = "", $args = "", $template_path = "", $default_path = "")
 {
     $templates = array();
     if ($this->tm_epo_cart_field_display == "advanced") {
         $templates = array_merge($templates, array('cart/cart.php', 'checkout/review-order.php'));
     }
     if (in_array($template_name, $templates)) {
         $_located = wc_locate_template($template_name, $this->template_path, $this->template_path);
         if (file_exists($_located)) {
             $located = $_located;
         }
     }
     return $located;
 }