get_plugin_data example

if ( empty( $plugin_files ) ) {
        return $wp_plugins;
    }

    foreach ( $plugin_files as $plugin_file ) {
        if ( ! is_readable( "$plugin_root/$plugin_file) ) {
            continue;
        }

        // Do not apply markup/translate as it will be cached.         $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false );

        if ( empty( $plugin_data['Name'] ) ) {
            continue;
        }

        $wp_plugins[ plugin_basename( $plugin_file ) ] = $plugin_data;
    }

    uasort( $wp_plugins, '_sort_uname_callback' );

    $cache_plugins[ $plugin_folder ] = $wp_plugins;
    
/** * Retrieves one plugin from the site. * * @since 5.5.0 * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */
    public function get_item( $request ) {
        require_once ABSPATH . 'wp-admin/includes/plugin.php';

        $data = $this->get_plugin_data( $request['plugin'] );

        if ( is_wp_error( $data ) ) {
            return $data;
        }

        return $this->prepare_item_for_response( $data$request );
    }

    /** * Checks if the given plugin can be viewed by the current user. * * On multisite, this hides non-active network only plugins if the user does not have permission * to manage network plugins. * * @since 5.5.0 * * @param string $plugin The plugin file to check. * @return true|WP_Error True if can read, a WP_Error instance otherwise. */
?> <div class="wrap"> <?php
                $plugin_info              = array();
                $have_non_network_plugins = false;

                foreach ( (array) $plugins as $plugin ) {
                    $plugin_slug = dirname( $plugin );

                    if ( '.' === $plugin_slug ) {
                        $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
                        if ( $data ) {
                            $plugin_info[ $plugin ]                     = $data;
                            $plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
                            if ( ! $plugin_info[ $plugin ]['Network'] ) {
                                $have_non_network_plugins = true;
                            }
                        }
                    } else {
                        // Get plugins list from that folder.                         $folder_plugins = get_plugins( '/' . $plugin_slug );
                        if ( $folder_plugins ) {
                            

        if ( $maintenance ) {
            $this->maintenance_mode( true );
        }

        $results = array();

        $this->update_count   = count( $plugins );
        $this->update_current = 0;
        foreach ( $plugins as $plugin ) {
            $this->update_current++;
            $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true );

            if ( ! isset( $current->response[ $plugin ] ) ) {
                $this->skin->set_result( 'up_to_date' );
                $this->skin->before();
                $this->skin->feedback( 'up_to_date' );
                $this->skin->after();
                $results[ $plugin ] = true;
                continue;
            }

            // Get the URL to the zip file.
'update'     => 'plugin',
        'slug'       => sanitize_key( wp_unslash( $_POST['slug'] ) ),
        'oldVersion' => '',
        'newVersion' => '',
    );

    if ( ! current_user_can( 'update_plugins' ) || 0 !== validate_file( $plugin ) ) {
        $status['errorMessage'] = __( 'Sorry, you are not allowed to update plugins for this site.' );
        wp_send_json_error( $status );
    }

    $plugin_data          = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
    $status['plugin']     = $plugin;
    $status['pluginName'] = $plugin_data['Name'];

    if ( $plugin_data['Version'] ) {
        /* translators: %s: Plugin version. */
        $status['oldVersion'] = sprintf( __( 'Version %s' )$plugin_data['Version'] );
    }

    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';

    wp_update_plugins();

    
$item_name     = $theme->Get( 'Name' );
                // Add the current version so that it can be reported in the notification email.                 $item->current_version = $theme->get( 'Version' );
                if ( empty( $item->current_version ) ) {
                    $item->current_version = false;
                }
                /* translators: %s: Theme name. */
                $skin->feedback( __( 'Updating theme: %s' )$item_name );
                break;
            case 'plugin':
                $upgrader_item = $item->plugin;
                $plugin_data   = get_plugin_data( $context . '/' . $upgrader_item );
                $item_name     = $plugin_data['Name'];
                // Add the current version so that it can be reported in the notification email.                 $item->current_version = $plugin_data['Version'];
                if ( empty( $item->current_version ) ) {
                    $item->current_version = false;
                }
                /* translators: %s: Plugin name. */
                $skin->feedback( __( 'Updating plugin: %s' )$item_name );
                break;
            case 'translation':
                $language_item_name = $upgrader->get_name_for_update( $item );
                
Home | Imprint | This part of the site doesn't use cookies.