/** * @test * it should switch theme to just stylesheet if no template */ public function it_should_switch_theme_to_just_stylesheet_if_no_template() { $this->config['theme'] = 'foo'; $this->wp->switch_theme('foo')->shouldBeCalled(); $this->wp->WP_CONTENT_DIR()->willReturn(''); $this->wp->do_action('after_switch_theme', 'foo')->shouldBeCalled(); $sut = $this->make_instance(); $sut->_switch_theme(); }
public function _switch_theme() { if (!empty($this->config['theme'])) { $stylesheet = is_array($this->config['theme']) ? end($this->config['theme']) : $this->config['theme']; $functionsFile = $this->wp->WP_CONTENT_DIR() . '/themes/' . $stylesheet . '/functions.php'; if (file_exists($functionsFile)) { require_once $functionsFile; } call_user_func([$this->wp, 'switch_theme'], $stylesheet); $this->wp->do_action('after_switch_theme', $stylesheet); } }