/** * Init the status page. */ public function status_page() { WC_Admin_Status::output(); }
$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); if ($core_version && (empty($theme_version) || version_compare($theme_version, $core_version, '<'))) { if (!$outdated_templates) { $outdated_templates = true; } $found_files[$plugin_name][] = sprintf(__('<code>%s</code> version <strong style="color:red">%s</strong> is out of date. The core version is %s', 'woocommerce'), str_replace(WP_CONTENT_DIR . '/themes/', '', $theme_file), $theme_version ? $theme_version : '-', $core_version); } else { $found_files[$plugin_name][] = sprintf('<code>%s</code>', str_replace(WP_CONTENT_DIR . '/themes/', '', $theme_file)); } } } } if (!empty($found_files)) { foreach ($found_files as $plugin_name => $found_plugin_files) { ?> <tr>
/** * 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); }
/** * 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'; } }
exit; } $current_tab = !empty($_REQUEST['tab']) ? sanitize_title($_REQUEST['tab']) : 'status'; ?> <div class="wrap woocommerce"> <div class="icon32 icon32-woocommerce-status" id="icon-woocommerce"><br /></div><h2 class="nav-tab-wrapper woo-nav-tab-wrapper"> <?php $tabs = array('status' => __('System Status', 'woocommerce'), 'tools' => __('Tools', 'woocommerce'), 'logs' => __('Logs', 'woocommerce')); foreach ($tabs as $name => $label) { echo '<a href="' . admin_url('admin.php?page=wc-status&tab=' . $name) . '" class="nav-tab '; if ($current_tab == $name) { echo 'nav-tab-active'; } echo '">' . $label . '</a>'; } ?> </h2> <?php switch ($current_tab) { case "tools": WC_Admin_Status::status_tools(); break; case "logs": WC_Admin_Status::status_logs(); break; default: WC_Admin_Status::status_report(); break; } ?> </div>
/** * 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; }
public function get_OverRided() { $template_files = WC_QD_INSTALL::get_template_list(); $overrided = array(); if (is_array($template_files)) { foreach ($template_files as $file) { $theme_file = false; if (file_exists(get_stylesheet_directory() . '/' . $file)) { $theme_file = get_stylesheet_directory() . '/' . $file; } elseif (file_exists(get_stylesheet_directory() . WC_QD_THEME_TEMPLATE . $file)) { $theme_file = get_stylesheet_directory() . WC_QD_THEME_TEMPLATE . $file; } elseif (file_exists(get_template_directory() . '/' . $file)) { $theme_file = get_template_directory() . '/' . $file; } elseif (file_exists(get_template_directory() . WC_QD_THEME_TEMPLATE . $file)) { $theme_file = get_template_directory() . WC_QD_THEME_TEMPLATE . $file; } if ($theme_file !== false) { $core_version = WC_Admin_Status::get_file_version(WC_QD_TEMPLATE . $file); $theme_version = WC_Admin_Status::get_file_version($theme_file); if ($core_version && $theme_version && version_compare($theme_version, $core_version, '<')) { $overrided[] = array('file' => $file, 'corev' => $core_version, 'themev' => $theme_version, 'is_old' => true); } else { $overrided[] = array('file' => $file, 'corev' => $core_version, 'themev' => $theme_version, 'is_old' => false); } } } } return $overrided; }
/** * Checks For Template Version */ public static function check_template_files() { $template_files = self::get_template_list(); $outdated = false; if (is_array($template_files)) { foreach ($template_files as $file) { $theme_file = false; if (file_exists(get_stylesheet_directory() . '/' . $file)) { $theme_file = get_stylesheet_directory() . '/' . $file; } elseif (file_exists(get_stylesheet_directory() . WC_QD_THEME_TEMPLATE . $file)) { $theme_file = get_stylesheet_directory() . WC_QD_THEME_TEMPLATE . $file; } elseif (file_exists(get_template_directory() . '/' . $file)) { $theme_file = get_template_directory() . '/' . $file; } elseif (file_exists(get_template_directory() . WC_QD_THEME_TEMPLATE . $file)) { $theme_file = get_template_directory() . WC_QD_THEME_TEMPLATE . $file; } if ($theme_file !== false) { $core_version = WC_Admin_Status::get_file_version(WC_QD_TEMPLATE . $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) { $theme = wp_get_theme(); $message = sprintf(__('<p> <strong>Your theme (%s) contains outdated copies of some WooCommerce Quick Donation template files.</strong> These files may need updating to ensure they are compatible with the current version of WooCommerce Quick Donation. You can see which files are affected from the %ssystem status page%s. If in doubt, check with the author of the theme. </p> <p class="submit">%sLear More About Templates%s %s</p>', WC_QD_TXT), esc_html($theme['Name']), '<a href="' . admin_url('admin.php?page=wc-status') . '">', '</a>', '<a target="_blank" href="" class="button-primary" href="">', '</a>', wc_qd_remove_link('class="button" ')); wc_qd_notice($message, 'error', array('times' => 0, 'wraper' => false)); } } }
/** * Gets the last 10 lines from the Connect for WooCommerce log, if it exists */ protected function get_debug_log_data() { $data = new stdClass(); $data->key = ''; $data->file = ''; $data->tail = array(); if (method_exists('WC_Admin_Status', 'scan_log_files')) { $logs = WC_Admin_Status::scan_log_files(); foreach ($logs as $log_key => $log_file) { if ("wc-connect-" === substr($log_key, 0, 11)) { $complete_log = file(WC_LOG_DIR . $log_file); $data->key = $log_key; $data->file = $log_file; $data->tail = array_slice($complete_log, -10); } } } return $data; }