Skip to content

Commit

Permalink
Pretend to activate plugin inside wp-admin (#524)
Browse files Browse the repository at this point in the history
Plugins should be activated inside wp-admin. This commit pretends to do that by defining `WP_ADMIN` so that `is_admin()` evaluates to true.
  • Loading branch information
akirk committed Jun 5, 2023
1 parent c5b3c05 commit 92cf3e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Expand Up @@ -34,6 +34,7 @@ export const activatePlugin: StepHandler<ActivatePluginStep> = async (

const result = await playground.run({
code: `<?php
define( 'WP_ADMIN', true );
${requiredFiles.map((file) => `require_once( '${file}' );`).join('\n')}
$plugin_path = '${pluginPath}';
if (!is_dir($plugin_path)) {
Expand Down
Expand Up @@ -25,8 +25,9 @@ export const activateTheme: StepHandler<ActivateThemeStep> = async (
}
await playground.run({
code: `<?php
require_once( '${wpLoadPath}' );
switch_theme( '${themeFolderName}' );
`,
define( 'WP_ADMIN', true );
require_once( '${wpLoadPath}' );
switch_theme( '${themeFolderName}' );
`,
});
};

0 comments on commit 92cf3e4

Please sign in to comment.