コード例 #1
0
			<td class="help">&nbsp;</td>
			<td><?php 
    _e('Your theme has a woocommerce.php file, you will not be able to override the woocommerce/archive-product.php custom template since woocommerce.php has priority over archive-product.php. This is intended to prevent display issues.', 'woocommerce');
    ?>
</td>
		</tr>
		<?php 
}
?>
		<?php 
$template_paths = apply_filters('woocommerce_template_overrides_scan_paths', array('WooCommerce' => WC()->plugin_path() . '/templates/'));
$scanned_files = array();
$found_files = array();
$outdated_templates = false;
foreach ($template_paths as $plugin_name => $template_path) {
    $scanned_files = WC_Admin_Status::scan_template_files($template_path);
    foreach ($scanned_files as $file) {
        if (file_exists(get_stylesheet_directory() . '/' . $file)) {
            $theme_file = get_stylesheet_directory() . '/' . $file;
        } elseif (file_exists(get_stylesheet_directory() . '/woocommerce/' . $file)) {
            $theme_file = get_stylesheet_directory() . '/woocommerce/' . $file;
        } elseif (file_exists(get_template_directory() . '/' . $file)) {
            $theme_file = get_template_directory() . '/' . $file;
        } elseif (file_exists(get_template_directory() . '/woocommerce/' . $file)) {
            $theme_file = get_template_directory() . '/woocommerce/' . $file;
        } else {
            $theme_file = false;
        }
        if (!empty($theme_file)) {
            $core_version = WC_Admin_Status::get_file_version($template_path . $file);
            $theme_version = WC_Admin_Status::get_file_version($theme_file);
コード例 #2
0
 /**
  * Show a notice highlighting bad template files
  */
 public function template_file_check_notice()
 {
     if (isset($_GET['page']) && 'wc-status' == $_GET['page']) {
         return;
     }
     $core_templates = WC_Admin_Status::scan_template_files(WC()->plugin_path() . '/templates');
     $outdated = false;
     foreach ($core_templates as $file) {
         $theme_file = false;
         if (file_exists(get_stylesheet_directory() . '/' . $file)) {
             $theme_file = get_stylesheet_directory() . '/' . $file;
         } elseif (file_exists(get_stylesheet_directory() . '/woocommerce/' . $file)) {
             $theme_file = get_stylesheet_directory() . '/woocommerce/' . $file;
         } elseif (file_exists(get_template_directory() . '/' . $file)) {
             $theme_file = get_template_directory() . '/' . $file;
         } elseif (file_exists(get_template_directory() . '/woocommerce/' . $file)) {
             $theme_file = get_template_directory() . '/woocommerce/' . $file;
         }
         if ($theme_file) {
             $core_version = WC_Admin_Status::get_file_version(WC()->plugin_path() . '/templates/' . $file);
             $theme_version = WC_Admin_Status::get_file_version($theme_file);
             if ($core_version && $theme_version && version_compare($theme_version, $core_version, '<')) {
                 $outdated = true;
                 break;
             }
         }
     }
     if ($outdated) {
         include 'views/html-notice-template-check.php';
     }
 }
 /**
  * Get info on the current active theme, info on parent theme (if presnet)
  * and a list of template overrides.
  *
  * @return array
  */
 public function get_theme_info()
 {
     $active_theme = wp_get_theme();
     // Get parent theme info if this theme is a child theme, otherwise
     // pass empty info in the response.
     if (is_child_theme()) {
         $parent_theme = wp_get_theme($active_theme->Template);
         $parent_theme_info = array('parent_name' => $parent_theme->Name, 'parent_version' => $parent_theme->Version, 'parent_version_latest' => WC_Admin_Status::get_latest_theme_version($parent_theme), 'parent_author_url' => $parent_theme->{'Author URI'});
     } else {
         $parent_theme_info = array('parent_name' => '', 'parent_version' => '', 'parent_version_latest' => '', 'parent_author_url' => '');
     }
     /**
      * Scan the theme directory for all WC templates to see if our theme
      * overrides any of them.
      */
     $override_files = array();
     $outdated_templates = false;
     $scan_files = WC_Admin_Status::scan_template_files(WC()->plugin_path() . '/templates/');
     foreach ($scan_files as $file) {
         if (file_exists(get_stylesheet_directory() . '/' . $file)) {
             $theme_file = get_stylesheet_directory() . '/' . $file;
         } elseif (file_exists(get_stylesheet_directory() . '/' . WC()->template_path() . $file)) {
             $theme_file = get_stylesheet_directory() . '/' . WC()->template_path() . $file;
         } elseif (file_exists(get_template_directory() . '/' . $file)) {
             $theme_file = get_template_directory() . '/' . $file;
         } elseif (file_exists(get_template_directory() . '/' . WC()->template_path() . $file)) {
             $theme_file = get_template_directory() . '/' . WC()->template_path() . $file;
         } else {
             $theme_file = false;
         }
         if (!empty($theme_file)) {
             $core_version = WC_Admin_Status::get_file_version(WC()->plugin_path() . '/templates/' . $file);
             $theme_version = WC_Admin_Status::get_file_version($theme_file);
             if ($core_version && (empty($theme_version) || version_compare($theme_version, $core_version, '<'))) {
                 if (!$outdated_templates) {
                     $outdated_templates = true;
                 }
             }
             $override_files[] = array('file' => str_replace(WP_CONTENT_DIR . '/themes/', '', $theme_file), 'version' => $theme_version, 'core_version' => $core_version);
         }
     }
     $active_theme_info = array('name' => $active_theme->Name, 'version' => $active_theme->Version, 'version_latest' => WC_Admin_Status::get_latest_theme_version($active_theme), 'author_url' => esc_url_raw($active_theme->{'Author URI'}), 'is_child_theme' => is_child_theme(), 'has_woocommerce_support' => current_theme_supports('woocommerce') || in_array($active_theme->template, wc_get_core_supported_themes()), 'has_woocommerce_file' => file_exists(get_stylesheet_directory() . '/woocommerce.php') || file_exists(get_template_directory() . '/woocommerce.php'), 'has_outdated_templates' => $outdated_templates, 'overrides' => $override_files);
     return array_merge($active_theme_info, $parent_theme_info);
 }
コード例 #4
0
	<thead>
		<tr>
			<th colspan="2"><?php 
_e('Templates', 'woocommerce');
?>
</th>
		</tr>
	</thead>

	<tbody>
		<?php 
$template_paths = apply_filters('woocommerce_template_overrides_scan_paths', array('WooCommerce' => WC()->plugin_path() . '/templates/'));
$scanned_files = array();
$found_files = array();
foreach ($template_paths as $plugin_name => $template_path) {
    $scanned_files[$plugin_name] = WC_Admin_Status::scan_template_files($template_path);
}
foreach ($scanned_files as $plugin_name => $files) {
    foreach ($files as $file) {
        if (file_exists(get_stylesheet_directory() . '/' . $file)) {
            $theme_file = get_stylesheet_directory() . '/' . $file;
        } elseif (file_exists(get_stylesheet_directory() . '/woocommerce/' . $file)) {
            $theme_file = get_stylesheet_directory() . '/woocommerce/' . $file;
        } elseif (file_exists(get_template_directory() . '/' . $file)) {
            $theme_file = get_template_directory() . '/' . $file;
        } elseif (file_exists(get_template_directory() . '/woocommerce/' . $file)) {
            $theme_file = get_template_directory() . '/woocommerce/' . $file;
        } else {
            $theme_file = false;
        }
        if ($theme_file) {
コード例 #5
0
 /**
  * Look for any template override and return filenames
  * @return array
  */
 private static function get_all_template_overrides()
 {
     $override_data = array();
     $template_paths = apply_filters('woocommerce_template_overrides_scan_paths', array('WooCommerce' => WC()->plugin_path() . '/templates/'));
     $scanned_files = array();
     require_once WC()->plugin_path() . '/includes/admin/class-wc-admin-status.php';
     foreach ($template_paths as $plugin_name => $template_path) {
         $scanned_files[$plugin_name] = WC_Admin_Status::scan_template_files($template_path);
     }
     foreach ($scanned_files as $plugin_name => $files) {
         foreach ($files as $file) {
             if (file_exists(get_stylesheet_directory() . '/' . $file)) {
                 $theme_file = get_stylesheet_directory() . '/' . $file;
             } elseif (file_exists(get_stylesheet_directory() . '/woocommerce/' . $file)) {
                 $theme_file = get_stylesheet_directory() . '/woocommerce/' . $file;
             } elseif (file_exists(get_template_directory() . '/' . $file)) {
                 $theme_file = get_template_directory() . '/' . $file;
             } elseif (file_exists(get_template_directory() . '/woocommerce/' . $file)) {
                 $theme_file = get_template_directory() . '/woocommerce/' . $file;
             } else {
                 $theme_file = false;
             }
             if ($theme_file !== false) {
                 $override_data[] = basename($theme_file);
             }
         }
     }
     return $override_data;
 }
コード例 #6
0
 /**
  * Gets ALl Core Templates
  */
 public static function get_template_list()
 {
     $core_tempalte_list = WC_Admin_Status::scan_template_files(WC_QD_TEMPLATE);
     return $core_tempalte_list;
 }