コード例 #1
0
<table class="tplc_status_table widefat" cellspacing="0" id="status">
	<thead>
	<tr>
		<th><?php 
_e('Templates', 'tl-template-checker');
?>
</th>
	</tr>
	</thead>
	<tbody>
	<?php 
$template_paths = array(get_template_directory() . '/');
$scanned_files = array();
$found_files = array();
foreach ($template_paths as $plugin_name => $template_path) {
    $scanned_files[$plugin_name] = TPLC_Admin_Status::scan_template_files($template_path);
}
foreach ($scanned_files as $plugin_name => $files) {
    foreach ($files as $file) {
        // skip if no php file
        if (!strpos($file, '.php')) {
            continue;
        }
        $child_path = get_stylesheet_directory() . '/' . $file;
        // Exclude functions.php
        if (file_exists($child_path) && basename($file) !== 'functions.php') {
            $theme_file = $child_path;
        } else {
            $theme_file = false;
        }
        if ($theme_file) {
コード例 #2
0
 /**
  * Scan the template files
  *
  * @access public
  * @param string $template_path
  * @return array
  */
 public static function scan_template_files($template_path)
 {
     $files = scandir($template_path);
     $result = array();
     if ($files) {
         foreach ($files as $key => $value) {
             if (!in_array($value, array(".", ".."))) {
                 if (is_dir($template_path . DIRECTORY_SEPARATOR . $value)) {
                     $sub_files = TPLC_Admin_Status::scan_template_files($template_path . DIRECTORY_SEPARATOR . $value);
                     foreach ($sub_files as $sub_file) {
                         $result[] = $value . DIRECTORY_SEPARATOR . $sub_file;
                     }
                 } else {
                     $result[] = $value;
                 }
             }
         }
     }
     return $result;
 }
コード例 #3
0
 /**
  * Show a notice highlighting bad template files
  */
 public function template_file_check_notice()
 {
     require_once 'class-tplc-admin-status.php';
     $template_path = get_template_directory() . '/';
     $parent_theme_templates = TPLC_Admin_Status::scan_template_files($template_path);
     // TPLC_Admin_Status::scan_template_files( WC()->plugin_path() . '/templates' );
     $outdated = false;
     foreach ($parent_theme_templates as $file) {
         $theme_file = false;
         $child_path = get_stylesheet_directory() . '/' . $file;
         // Exclude functions.php
         if (file_exists($child_path) && basename($file) !== 'functions.php') {
             $theme_file = $child_path;
         } else {
             $theme_file = false;
         }
         if ($theme_file) {
             $parent_version = TPLC_Admin_Status::get_file_version(get_template_directory() . '/' . $file);
             $child_version = TPLC_Admin_Status::get_file_version($theme_file);
             if ($parent_version && $child_version && version_compare($child_version, $parent_version, '<')) {
                 $outdated = true;
                 break;
             }
         }
     }
     if ($outdated) {
         include 'views/html-notice-template-check.php';
     } else {
         self::remove_notice('template_files');
     }
 }