From ed360b7557759d889cadce8ecbc792179ef3bbfd Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Thu, 31 Oct 2019 03:38:01 +0100 Subject: [PATCH 1/2] Load template functions in Runner --- php/WP_CLI/Runner.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/php/WP_CLI/Runner.php b/php/WP_CLI/Runner.php index 768fcecf3..374c4506f 100644 --- a/php/WP_CLI/Runner.php +++ b/php/WP_CLI/Runner.php @@ -1247,6 +1247,9 @@ public function load_wordpress() { // Load all the admin APIs, for convenience require ABSPATH . 'wp-admin/includes/admin.php'; + // Load template functions, as they might be needed by starter content. + require ABSPATH . 'wp-includes/link-template.php'; + add_filter( 'filesystem_method', function() { From ffad97da26ad0d679b2b649ed43ca2b8353357dc Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Sun, 3 Nov 2019 22:43:15 +0100 Subject: [PATCH 2/2] Only require template functions if not yet declared --- php/WP_CLI/Runner.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/php/WP_CLI/Runner.php b/php/WP_CLI/Runner.php index 374c4506f..9d2820383 100644 --- a/php/WP_CLI/Runner.php +++ b/php/WP_CLI/Runner.php @@ -1247,8 +1247,11 @@ public function load_wordpress() { // Load all the admin APIs, for convenience require ABSPATH . 'wp-admin/includes/admin.php'; - // Load template functions, as they might be needed by starter content. - require ABSPATH . 'wp-includes/link-template.php'; + // Maybe load template functions, as they might be needed by starter + // content. + if ( ! function_exists( 'get_theme_file_uri' ) ) { + require_once ABSPATH . 'wp-includes/link-template.php'; + } add_filter( 'filesystem_method',