if ( 'update-selected' === $action ) { if ( ! current_user_can( 'update_plugins' ) ) { wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) ); }
$upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) ); $upgrader->bulk_upgrade( $plugins );
iframe_footer();
} elseif ( 'upgrade-plugin' === $action ) { if ( ! current_user_can( 'update_plugins' ) ) { wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) ); }
} elseif ( 'activate-plugin' === $action ) { if ( ! current_user_can( 'update_plugins' ) ) { wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) ); }
} elseif ( 'upload-plugin-cancel-overwrite' === $action ) { if ( ! current_user_can( 'upload_plugins' ) ) { wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) ); }
// Make sure the attachment still exists, or File_Upload_Upgrader will call wp_die() // that shows a generic "Please select a file" error. if ( ! empty( $_GET['package'] ) ) { $attachment_id = (int) $_GET['package'];
if ( get_post( $attachment_id ) ) { $file_upload = new File_Upload_Upgrader( 'pluginzip', 'package' ); $file_upload->cleanup(); } }
} elseif ( 'upload-theme-cancel-overwrite' === $action ) { if ( ! current_user_can( 'upload_themes' ) ) { wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) ); }
// Make sure the attachment still exists, or File_Upload_Upgrader will call wp_die() // that shows a generic "Please select a file" error. if ( ! empty( $_GET['package'] ) ) { $attachment_id = (int) $_GET['package'];
if ( get_post( $attachment_id ) ) { $file_upload = new File_Upload_Upgrader( 'themezip', 'package' ); $file_upload->cleanup(); } }
wp_redirect( self_admin_url( 'theme-install.php' ) ); exit; } else { /** * Fires when a custom plugin or theme update request is received. * * The dynamic portion of the hook name, `$action`, refers to the action * provided in the request for wp-admin/update.php. Can be used to * provide custom update functionality for themes and plugins. * * @since 2.8.0 */ do_action( "update-custom_{$action}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores } }