Skip to content

Commit 0c55be7

Browse files
author
Milan Ricoul
authored
Merge pull request #83 from BeAPI/feature/editor-style-min
feat (theme) : get minified editor-style if production env
2 parents 99f1b78 + 8225cca commit 0c55be7

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

inc/services/assets.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ public function get_min_file( $type ) {
145145
case 'css':
146146
$file = $assets['app.css'];
147147
break;
148+
case 'editor-style':
149+
$file = $assets['editor-style.css'];
150+
break;
148151
case 'js':
149152
$file = $assets['app.js'];
150153
break;

inc/services/theme.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
namespace BEA\Theme\Framework\Services;
4+
use BEA\Theme\Framework\Framework;
45
use BEA\Theme\Framework\Service;
56
use BEA\Theme\Framework\Service_Container;
67

@@ -71,6 +72,22 @@ private function i18n() {
7172
* editor style
7273
*/
7374
private function editor_style() {
74-
add_editor_style('dist/assets/editor-style.css');
75+
/**
76+
* Default file
77+
**/
78+
$file = 'editor-style.css';
79+
80+
if ( ! defined( 'SCRIPT_DEBUG' ) || false === SCRIPT_DEBUG ) {
81+
$file = Framework::get_container()->get_service( 'assets' )->get_min_file( 'editor-style' );
82+
}
83+
84+
/**
85+
* Do not enqueue a inexistant file on admin
86+
*/
87+
if ( ! is_file( get_theme_file_path( 'dist/assets/' . $file ) ) ) {
88+
return;
89+
}
90+
91+
add_editor_style( 'dist/assets/' . $file );
7592
}
7693
}

0 commit comments

Comments
 (0)