| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for displaying outdated template files in theme/child-themes |
| 4 |
* |
| 5 |
* @author ThimPress |
| 6 |
* @package LearnPress/Admin/Views |
| 7 |
* @version 3.0.0 |
| 8 |
*/ |
| 9 |
|
| 10 |
defined( 'ABSPATH' ) || die(); |
| 11 |
|
| 12 |
$templates = LP_Outdated_Template_Helper::get_theme_templates(); |
| 13 |
$counts = LP_Outdated_Template_Helper::$counts; |
| 14 |
$theme = wp_get_theme(); |
| 15 |
$template_dir = get_template_directory(); |
| 16 |
$stylesheet_dir = get_stylesheet_directory(); |
| 17 |
$child_theme_folder = ''; |
| 18 |
$theme_folder = ''; |
| 19 |
|
| 20 |
if ( $template_dir != $stylesheet_dir ) { |
| 21 |
$child_theme_folder = basename( $stylesheet_dir ); |
| 22 |
$theme_folder = basename( $template_dir ); |
| 23 |
} |
| 24 |
?> |
| 25 |
|
| 26 |
<table class="lp-template-overrides widefat" cellspacing="0"> |
| 27 |
<thead> |
| 28 |
<tr> |
| 29 |
<th colspan="3"> |
| 30 |
<h4><?php printf( __( 'Override Templates (%s)', 'learnpress' ), esc_html( $theme['Name'] ) ); ?></h4> |
| 31 |
</th> |
| 32 |
</tr> |
| 33 |
</thead> |
| 34 |
<tbody id="learn-press-template-files"> |
| 35 |
|
| 36 |
<?php if ( $templates ) : ?> |
| 37 |
<tr> |
| 38 |
<th class="template-file"> |
| 39 |
<?php _e( 'File', 'learnpress' ); ?> |
| 40 |
<p> |
| 41 |
<a href="" class="learn-press-filter-template current" |
| 42 |
data-template=""><?php printf( __( 'All (%d)', 'learnpress' ), $counts['all'] ); ?></a> |
| 43 |
<?php if ( $theme_folder && $child_theme_folder ) { ?> |
| 44 |
<a href="" class="learn-press-filter-template" |
| 45 |
data-template="<?php echo esc_attr( $theme_folder ); ?>"><?php echo learn_press_get_theme_name( $theme_folder ); ?></a> |
| 46 |
<a href="" class="learn-press-filter-template" |
| 47 |
data-template="<?php echo esc_attr( $child_theme_folder ); ?>"><?php echo learn_press_get_theme_name( $child_theme_folder ); ?></a> |
| 48 |
<?php } ?> |
| 49 |
<a href="" class="learn-press-filter-template" |
| 50 |
data-filter="outdated"><?php printf( __( 'Outdated (%d)', 'learnpress' ), $counts['outdated'] ); ?></a> |
| 51 |
<a href="" class="learn-press-filter-template" |
| 52 |
data-filter="unversioned"><?php printf( __( 'Unversioned (%d)', 'learnpress' ), $counts['unversioned'] ); ?></a> |
| 53 |
</p> |
| 54 |
</th> |
| 55 |
<th class="template-version"> |
| 56 |
<?php _e( 'Version', 'learnpress' ); ?> |
| 57 |
</th> |
| 58 |
<th class="core-version"><?php _e( 'Core version', 'learnpress' ); ?></th> |
| 59 |
</tr> |
| 60 |
|
| 61 |
<?php foreach ( $templates as $template ) : ?> |
| 62 |
<?php |
| 63 |
$template_folder = ''; |
| 64 |
if ( $child_theme_folder && strpos( $template[0], $child_theme_folder ) !== false ) { |
| 65 |
$template_folder = $child_theme_folder; |
| 66 |
} else { |
| 67 |
$template_folder = $theme_folder; |
| 68 |
} |
| 69 |
$template_class = $template[3] ? 'outdated' : ( $template[1] == '-' && $template[2] == '-' ? '' : 'up-to-date' ); |
| 70 |
$filter = $template[3] ? 'outdated' : ( $template[1] == '-' ? 'unversioned' : '' ); |
| 71 |
?> |
| 72 |
|
| 73 |
<tr data-template="<?php echo esc_attr( $template_folder ); ?>" |
| 74 |
<?php |
| 75 |
if ( $template[3] ) { |
| 76 |
echo 'data-filter-outdated="yes"'; |
| 77 |
} |
| 78 |
?> |
| 79 |
<?php |
| 80 |
if ( $template[1] == '-' ) { |
| 81 |
echo 'data-filter-unversioned="yes"'; |
| 82 |
} |
| 83 |
?> |
| 84 |
class="template-row <?php echo esc_attr( $template_class ); ?>"> |
| 85 |
<td class="template-file"><code><?php echo esc_html( $template[0] ); ?></code></td> |
| 86 |
<td class="template-version"> |
| 87 |
<span><?php echo esc_html( $template[1] ); ?></span> |
| 88 |
</td> |
| 89 |
<td class="core-version"><span><?php echo esc_html( $template[2] ); ?></span></td> |
| 90 |
</tr> |
| 91 |
<?php endforeach; ?> |
| 92 |
<?php endif; ?> |
| 93 |
|
| 94 |
<tr id="learn-press-no-templates" class="<?php echo esc_attr( $templates ? 'hide-if-js' : '' ); ?>"> |
| 95 |
<td colspan="3"> |
| 96 |
<p><?php _e( 'There is no template file has overwritten', 'learnpress' ); ?></p> |
| 97 |
</td> |
| 98 |
</tr> |
| 99 |
</tbody> |
| 100 |
</table> |
| 101 |
|
| 102 |
|