Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rodica-andronache/1be36acd064b0314f7bce8b4ae990f3e to your computer and use it in GitHub Desktop.
Save rodica-andronache/1be36acd064b0314f7bce8b4ae990f3e to your computer and use it in GitHub Desktop.
Shiny install/updates for plugins
public function style_and_scripts() {
...
wp_enqueue_style( 'plugin-install' );
wp_enqueue_script( 'plugin-install' );
wp_enqueue_script( 'updates' );
...
}
public function create_action_link( $state, $slug ) {
switch ( $state ) {
case 'install':
return wp_nonce_url(
add_query_arg(
array(
'action' => 'install-plugin',
'plugin' => $slug
),
network_admin_url( 'update.php' )
),
'install-plugin_' . $slug
);
break;
case 'deactivate':
return add_query_arg( array(
'action' => 'deactivate',
'plugin' => rawurlencode( $slug . '/' . $slug . '.php' ),
'plugin_status' => 'all',
'paged' => '1',
'_wpnonce' => wp_create_nonce( 'deactivate-plugin_' . $slug . '/' . $slug . '.php' ),
), network_admin_url( 'plugins.php' ) );
break;
case 'activate':
return add_query_arg( array(
'action' => 'activate',
'plugin' => rawurlencode( $slug . '/' . $slug . '.php' ),
'plugin_status' => 'all',
'paged' => '1',
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $slug . '/' . $slug . '.php' ),
), network_admin_url( 'plugins.php' ) );
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment