get_dropins

The timeline below displays how wordpress function get_dropins has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Checks the wp-content directory and retrieve all drop-ins with any plugin data.
 *
 * @since 3.0.0
 * @return array[] Array of arrays of dropin plugin data, keyed by plugin file name. See get_plugin_data().
 */
function get_dropins()
{
    $dropins = array();
    $plugin_files = array();
    $_dropins = _get_dropins();
    // Files in wp-content directory.
    $plugins_dir = @opendir(WP_CONTENT_DIR);
    if ($plugins_dir) {
        while (($file = readdir($plugins_dir)) !== false) {
            if (isset($_dropins[$file])) {
                $plugin_files[] = $file;
            }
        }
    } else {
        return $dropins;
    }
    closedir($plugins_dir);
    if (empty($plugin_files)) {
        return $dropins;
    }
    foreach ($plugin_files as $plugin_file) {
        if (!is_readable(WP_CONTENT_DIR . "/{$plugin_file}")) {
            continue;
        }
        // Do not apply markup/translate as it will be cached.
        $plugin_data = get_plugin_data(WP_CONTENT_DIR . "/{$plugin_file}", false, false);
        if (empty($plugin_data['Name'])) {
            $plugin_data['Name'] = $plugin_file;
        }
        $dropins[$plugin_file] = $plugin_data;
    }
    uksort($dropins, 'strnatcasecmp');
    return $dropins;
}

WordPress Version: 5.4

/**
 * Check the wp-content directory and retrieve all drop-ins with any plugin data.
 *
 * @since 3.0.0
 * @return array[] Array of arrays of dropin plugin data, keyed by plugin file name. See `get_plugin_data()`.
 */
function get_dropins()
{
    $dropins = array();
    $plugin_files = array();
    $_dropins = _get_dropins();
    // Files in wp-content directory.
    $plugins_dir = @opendir(WP_CONTENT_DIR);
    if ($plugins_dir) {
        while (($file = readdir($plugins_dir)) !== false) {
            if (isset($_dropins[$file])) {
                $plugin_files[] = $file;
            }
        }
    } else {
        return $dropins;
    }
    closedir($plugins_dir);
    if (empty($plugin_files)) {
        return $dropins;
    }
    foreach ($plugin_files as $plugin_file) {
        if (!is_readable(WP_CONTENT_DIR . "/{$plugin_file}")) {
            continue;
        }
        // Do not apply markup/translate as it will be cached.
        $plugin_data = get_plugin_data(WP_CONTENT_DIR . "/{$plugin_file}", false, false);
        if (empty($plugin_data['Name'])) {
            $plugin_data['Name'] = $plugin_file;
        }
        $dropins[$plugin_file] = $plugin_data;
    }
    uksort($dropins, 'strnatcasecmp');
    return $dropins;
}

WordPress Version: 5.3

/**
 * Check the wp-content directory and retrieve all drop-ins with any plugin data.
 *
 * @since 3.0.0
 * @return array Key is the file path and the value is an array of the plugin data.
 */
function get_dropins()
{
    $dropins = array();
    $plugin_files = array();
    $_dropins = _get_dropins();
    // These exist in the wp-content directory.
    $plugins_dir = @opendir(WP_CONTENT_DIR);
    if ($plugins_dir) {
        while (($file = readdir($plugins_dir)) !== false) {
            if (isset($_dropins[$file])) {
                $plugin_files[] = $file;
            }
        }
    } else {
        return $dropins;
    }
    closedir($plugins_dir);
    if (empty($plugin_files)) {
        return $dropins;
    }
    foreach ($plugin_files as $plugin_file) {
        if (!is_readable(WP_CONTENT_DIR . "/{$plugin_file}")) {
            continue;
        }
        $plugin_data = get_plugin_data(WP_CONTENT_DIR . "/{$plugin_file}", false, false);
        //Do not apply markup/translate as it'll be cached.
        if (empty($plugin_data['Name'])) {
            $plugin_data['Name'] = $plugin_file;
        }
        $dropins[$plugin_file] = $plugin_data;
    }
    uksort($dropins, 'strnatcasecmp');
    return $dropins;
}

WordPress Version: 3.7

/**
 * Check the wp-content directory and retrieve all drop-ins with any plugin data.
 *
 * @since 3.0.0
 * @return array Key is the file path and the value is an array of the plugin data.
 */
function get_dropins()
{
    $dropins = array();
    $plugin_files = array();
    $_dropins = _get_dropins();
    // These exist in the wp-content directory
    if ($plugins_dir = @opendir(WP_CONTENT_DIR)) {
        while (($file = readdir($plugins_dir)) !== false) {
            if (isset($_dropins[$file])) {
                $plugin_files[] = $file;
            }
        }
    } else {
        return $dropins;
    }
    @closedir($plugins_dir);
    if (empty($plugin_files)) {
        return $dropins;
    }
    foreach ($plugin_files as $plugin_file) {
        if (!is_readable(WP_CONTENT_DIR . "/{$plugin_file}")) {
            continue;
        }
        $plugin_data = get_plugin_data(WP_CONTENT_DIR . "/{$plugin_file}", false, false);
        //Do not apply markup/translate as it'll be cached.
        if (empty($plugin_data['Name'])) {
            $plugin_data['Name'] = $plugin_file;
        }
        $dropins[$plugin_file] = $plugin_data;
    }
    uksort($dropins, 'strnatcasecmp');
    return $dropins;
}