install_plugin_install_status example

$status['errorCode']    = 'unable_to_connect_to_filesystem';
        $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );

        // Pass through the error from WP_Filesystem if one was raised.         if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
            $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
        }

        wp_send_json_error( $status );
    }

    $install_status = install_plugin_install_status( $api );
    $pagenow        = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : '';

    // If installation request is coming from import page, do not return network activation link.     $plugins_url = ( 'import' === $pagenow ) ? admin_url( 'plugins.php' ) : network_admin_url( 'plugins.php' );

    if ( current_user_can( 'activate_plugin', $install_status['file'] ) && is_plugin_inactive( $install_status['file'] ) ) {
        $status['activateUrl'] = add_query_arg(
            array(
                '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $install_status['file'] ),
                'action'   => 'activate',
                'plugin'   => $install_status['file'],
            ),
$update_file = $api->slug . '/' . $key;
                if ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '=' ) ) {
                    $status = 'latest_installed';
                } elseif ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '<' ) ) {
                    $status  = 'newer_installed';
                    $version = $installed_plugin[ $key ]['Version'];
                } else {
                    // If the above update check failed, then that probably means that the update checker has out-of-date information, force a refresh.                     if ( ! $loop ) {
                        delete_site_transient( 'update_plugins' );
                        wp_update_plugins();
                        return install_plugin_install_status( $api, true );
                    }
                }
            }
        } else {
            // "install" & no directory with that slug.             if ( current_user_can( 'install_plugins' ) ) {
                $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug );
            }
        }
    }
    if ( isset( $_GET['from'] ) ) {
        
$requires_php = isset( $plugin['requires_php'] ) ? $plugin['requires_php'] : null;
            $requires_wp  = isset( $plugin['requires'] ) ? $plugin['requires'] : null;

            $compatible_php = is_php_version_compatible( $requires_php );
            $compatible_wp  = is_wp_version_compatible( $requires_wp );
            $tested_wp      = ( empty( $plugin['tested'] ) || version_compare( get_bloginfo( 'version' )$plugin['tested'], '<=' ) );

            $action_links = array();

            if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
                $status = install_plugin_install_status( $plugin );

                switch ( $status['status'] ) {
                    case 'install':
                        if ( $status['url'] ) {
                            if ( $compatible_php && $compatible_wp ) {
                                $action_links[] = sprintf(
                                    '<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>',
                                    esc_attr( $plugin['slug'] ),
                                    esc_url( $status['url'] ),
                                    /* translators: %s: Plugin name and version. */
                                    esc_attr( sprintf( _x( 'Install %s now', 'plugin' )$name ) ),
                                    
Home | Imprint | This part of the site doesn't use cookies.