Created
February 22, 2017 15:39
-
-
Save rodica-andronache/1be36acd064b0314f7bce8b4ae990f3e to your computer and use it in GitHub Desktop.
Shiny install/updates for plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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