New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Page not created on plugin activation #911
Comments
@faisal-alvi are you using a blueprint to install the plugin? IIRC the plugins are installed as |
We currently are using the {
"step": "installPlugin",
"pluginZipFile": {
"resource": "wordpress.org\/plugins",
"slug": "publisher-media-kit"
},
"options": {
"activate": true
}
} I tried changing this to use {
"step": "installPlugin",
"pluginZipFile": {
"resource": "wordpress.org\/plugins",
"slug": "publisher-media-kit"
},
"options": {
"activate": false
}
},
{
"step": "activatePlugin",
"pluginName": "Publisher Media Kit",
"pluginPath": "/wordpress/wp-content/plugins/publisher-media-kit"
} |
And I guess to be more clear, it doesn't appear in either case it's getting installed as an |
@dkotter thanks for double-checking that. in review, I noticed that the test import file is listed in the Blueprint steps after the plugin install and activation. I rearranged those so that the import file appears first, and it appears as though the Media Kit demo content was imported. {
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"landingPage": "/wp-admin/post.php?post=7&action=edit",
"preferredVersions": {
"php": "7.4",
"wp": "latest"
},
"phpExtensionBundles": [
"kitchen-sink"
],
"steps": [
{
"step": "login",
"username": "admin",
"password": "password"
},
{
"step": "importFile",
"file": {
"resource": "url",
"url": "https://raw.githubusercontent.com/10up/publisher-media-kit/65a081ba5d9f03270873d96baf7189d20fafcd7c/.wordpress-org/blueprints/demo-data.xml"
}
},
{
"step": "installPlugin",
"pluginZipFile": {
"resource": "wordpress.org/plugins",
"slug": "publisher-media-kit"
},
"options": {
"activate": true
}
}
]
} |
Thanks for the response. That |
Plugin activation runs without a "current user" which makes this check fail: if ( ! current_user_can( 'activate_plugins' ) ) {
return;
} I have a fix incoming. Thank you for reporting! |
…hemes Sets the current user to admin before activating plugins and themes. ## Rationale Issue #911 uncovered a problem where activating a plugin does not create a page in the following scenario: ```php function myplugin_activate() { if( current_user_can( 'activate_plugins' ) ) { create_page(); } } register_activation_hook( __FILE__, 'myplugin_activate' ); ``` The root cause is that the activatePlugin and activateTheme steps do not set the current user to admin before activating the plugin/theme. ## Testing instructions This PR comes with unit tests – confirm the CI checks pass.
…hemes (#984) Sets the current user to admin before activating plugins and themes. ## Rationale Issue #911 uncovered a problem where activating a plugin does not create a page in the following scenario: ```php function myplugin_activate() { if( current_user_can( 'activate_plugins' ) ) { create_page(); } } register_activation_hook( __FILE__, 'myplugin_activate' ); ``` The root cause is that the activatePlugin and activateTheme steps do not set the current user to admin before activating the plugin/theme. ## Testing instructions This PR comes with unit tests – confirm the CI checks pass. Closes #911
We are using the playground to show the preview of our Publisher Media Kit plugin.
The plugin creates a page on activation, but while using it in the playground, it does not work, and we have to import the Media Kit page from a test import file. The plugin is supposed to create this itself on activation, but it seems that the activation process that happens when the Playground is initialized doesn't trigger that functionality. This seems to be an issue with the playground.
The code when a plugin creates a page on activation is here:
Related PR: 10up/publisher-media-kit#175
The text was updated successfully, but these errors were encountered: