示例#1
0
 /**
  * Locates template based on available sources - current theme directory, stylesheet directory and Jigoshop templates directory.
  *
  * @param string $template Template to find.
  *
  * @return string Path to located file.
  */
 public static function locateTemplate($template)
 {
     $file = locate_template(array('jigoshop/' . $template . '.php'), false, false);
     if (empty($file)) {
         $file = \JigoshopInit::getDir() . '/templates/' . $template . '.php';
     }
     return $file;
 }
示例#2
0
 /**
  * Loads proper template based on current page.
  *
  * @param $template string Template chain.
  *
  * @return string Template to load.
  */
 public function process($template)
 {
     if (!Pages::isJigoshop()) {
         return $template;
     }
     if ($this->page === null) {
         if (WP_DEBUG) {
             throw new Exception('Page object should already be set for Jigoshop pages, but none found.');
         }
         Registry::getInstance(JIGOSHOP_LOGGER)->addCritical('Page object should already be set for Jigoshop pages, but none found.');
         return false;
     }
     $content = $this->page->render();
     $template = $this->wp->getOption('template');
     $theme = $this->wp->wpGetTheme();
     if ($theme->get('Author') === 'WooThemes') {
         $template = 'woothemes';
     }
     if (!file_exists(\JigoshopInit::getDir() . '/templates/layout/' . $template . '.php')) {
         $template = 'default';
     }
     Render::output('layout/' . $template, array('content' => $content));
     return false;
 }
示例#3
0
 /**
  * Return fields with all template overrides.
  *
  * @return array
  */
 private function getOverrides()
 {
     $templatePaths = $this->wp->applyFilters('jigoshop\\admin\\system_info\\system_status\\overrides_scan_paths', array('jigoshop' => \JigoshopInit::getDir() . '/templates/'));
     $scannedFiles = array();
     $foundFiles = array();
     foreach ($templatePaths as $pluginName => $templatePath) {
         $scannedFiles[$pluginName] = $this->scanTemplateFiles($templatePath);
     }
     foreach ($scannedFiles as $pluginName => $files) {
         foreach ($files as $file) {
             $themeFile = $this->getTemplateFile($file);
             if (!empty($themeFile)) {
                 $coreVersion = $this->getFileVersion(\JigoshopInit::getDir() . '/templates/' . $file);
                 $themeVersion = $this->getFileVersion($themeFile);
                 if ($coreVersion && (empty($themeVersion) || version_compare($themeVersion, $coreVersion, '<'))) {
                     $foundFiles[$pluginName][] = sprintf(__('<code>%s</code> version %s is out of date.', 'jigoshop'), str_replace(WP_CONTENT_DIR . '/themes/', '', $themeFile), $themeVersion ? $themeVersion : '-');
                 } else {
                     $foundFiles[$pluginName][] = sprintf('<code>%s</code>', str_replace(WP_CONTENT_DIR . '/themes/', '', $themeFile));
                 }
             }
         }
     }
     $fields = array();
     if ($foundFiles) {
         foreach ($foundFiles as $pluginName => $foundPluginFiles) {
             $fields[] = array('id' => strtolower($pluginName), 'name' => strtolower($pluginName), 'title' => sprintf(__('%s Overrides', 'jigoshop'), $pluginName), 'tip' => '', 'type' => 'constant', 'value' => implode(', <br/>', $foundPluginFiles));
         }
     } else {
         $fields[] = array('id' => 'no_overrides', 'name' => 'no_overrides', 'title' => __('No Overrides', 'jigoshop'), 'tip' => '', 'type' => 'constant', 'value' => '');
     }
     return $fields;
 }