Skip to content

Commit c6556af

Browse files
authored
Merge pull request #112 from wojsmol/fix-paths
fix mustache fites paths
2 parents 5609057 + ad69bd1 commit c6556af

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/Plugin_Command.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ protected function status_single( $args ) {
198198
if ( $this->has_update( $file ) )
199199
$version .= ' (%gUpdate available%n)';
200200

201-
echo WP_CLI::colorize( \WP_CLI\Utils\mustache_render( dirname( __DIR__ ) . '/templates/plugin-status.mustache', array(
201+
echo WP_CLI::colorize( \WP_CLI\Utils\mustache_render( self::get_template_path( 'plugin-status.mustache' ), array(
202202
'slug' => Utils\get_plugin_name( $file ),
203203
'status' => $status,
204204
'version' => $version,
@@ -1073,6 +1073,20 @@ protected function get_status( $file ) {
10731073
return 'inactive';
10741074
}
10751075

1076+
/**
1077+
* Gets the template path based on installation type.
1078+
*/
1079+
private static function get_template_path( $template ) {
1080+
$command_root = Utils\phar_safe_path( dirname( __DIR__ ) );
1081+
$template_path = "{$command_root}/templates/{$template}";
1082+
1083+
if ( ! file_exists( $template_path ) ) {
1084+
WP_CLI::error( "Couldn't find {$template}" );
1085+
}
1086+
1087+
return $template_path;
1088+
}
1089+
10761090
/**
10771091
* Gets the details of a plugin.
10781092
*

src/Theme_Command.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ protected function status_single( $args ) {
166166
if ( $this->has_update( $theme->get_stylesheet() ) )
167167
$version .= ' (%gUpdate available%n)';
168168

169-
echo WP_CLI::colorize( \WP_CLI\Utils\mustache_render( dirname( __DIR__ ) . '/templates/theme-status.mustache', array(
169+
echo WP_CLI::colorize( \WP_CLI\Utils\mustache_render( self::get_template_path( 'theme-status.mustache' ), array(
170170
'slug' => $theme->get_stylesheet(),
171171
'status' => $status,
172172
'version' => $version,
@@ -869,4 +869,18 @@ private function check_optional_args_and_all( $args, $all ) {
869869

870870
return $args;
871871
}
872+
873+
/**
874+
* Gets the template path based on installation type.
875+
*/
876+
private static function get_template_path( $template ) {
877+
$command_root = Utils\phar_safe_path( dirname( __DIR__ ) );
878+
$template_path = "{$command_root}/templates/{$template}";
879+
880+
if ( ! file_exists( $template_path ) ) {
881+
WP_CLI::error( "Couldn't find {$template}" );
882+
}
883+
884+
return $template_path;
885+
}
872886
}

0 commit comments

Comments
 (0)