From f6ba569012c987cacb239ccaeca3a69b6f16bd1a Mon Sep 17 00:00:00 2001 From: Takashi Kitajima Date: Fri, 18 Nov 2016 01:14:16 +0900 Subject: [PATCH] Not loading main js file when child theme --- app/setup/scripts.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/setup/scripts.php b/app/setup/scripts.php index e0908d31..cdb710c7 100644 --- a/app/setup/scripts.php +++ b/app/setup/scripts.php @@ -24,6 +24,7 @@ class Scripts { protected $version; public function __construct() { + $this->theme = get_stylesheet(); $this->theme_uri = get_template_directory_uri(); $this->version = $this->_get_theme_version(); @@ -45,9 +46,15 @@ public function enqueue_comment_reply() { * @return void */ public function enqueue_main() { + if ( is_child_theme() ) { + $src = get_stylesheet_directory_uri() . '/assets/js/app.min.js'; + } else { + $src = $this->theme_uri . '/assets/js/app.min.js'; + } + wp_enqueue_script( - get_template(), - $this->theme_uri . '/assets/js/app.min.js', + $this->theme, + $src, [ 'jquery' ], $this->version, true