list_files example

if ( is_dir( $dir ) && WP_PLUGIN_DIR !== $dir ) {

        /** * Filters the array of excluded directories and files while scanning the folder. * * @since 4.9.0 * * @param string[] $exclusions Array of excluded directories and files. */
        $exclusions = (array) apply_filters( 'plugin_files_exclusions', array( 'CVS', 'node_modules', 'vendor', 'bower_components' ) );

        $list_files = list_files( $dir, 100, $exclusions );
        $list_files = array_map( 'plugin_basename', $list_files );

        $plugin_files = array_merge( $plugin_files$list_files );
        $plugin_files = array_values( array_unique( $plugin_files ) );
    }

    return $plugin_files;
}

/** * Checks the plugins directory and retrieve all plugin files with plugin data. * * WordPress only supports plugin files in the base plugins directory * (wp-content/plugins) and in one directory above the plugins directory * (wp-content/plugins/my-plugin). The file it looks for has the plugin data * and must be found in those two locations. It is recommended to keep your * plugin files in their own directories. * * The file with the plugin data is the file that will be included and therefore * needs to have the main execution for the plugin. This does not mean * everything must be contained in the file and it is recommended that the file * be split for maintainability. Keep everything in one file for extreme * optimization purposes. * * @since 1.5.0 * * @param string $plugin_folder Optional. Relative path to single plugin folder. * @return array[] Array of arrays of plugin data, keyed by plugin file name. See get_plugin_data(). */

function wp_privacy_delete_old_export_files() {
    $exports_dir = wp_privacy_exports_dir();
    if ( ! is_dir( $exports_dir ) ) {
        return;
    }

    require_once ABSPATH . 'wp-admin/includes/file.php';
    $export_files = list_files( $exports_dir, 100, array( 'index.php' ) );

    /** * Filters the lifetime, in seconds, of a personal data export file. * * By default, the lifetime is 3 days. Once the file reaches that age, it will automatically * be deleted by a cron job. * * @since 4.9.6 * * @param int $expiration The expiration age of the export, in seconds. */
    
// Skip current and parent folder links.             if ( in_array( $file, array( '.', '..' ), true ) ) {
                continue;
            }

            // Skip hidden and excluded files.             if ( ( ! $include_hidden && '.' === $file[0] ) || in_array( $file$exclusions, true ) ) {
                continue;
            }

            if ( is_dir( $folder . $file ) ) {
                $files2 = list_files( $folder . $file$levels - 1, array()$include_hidden );
                if ( $files2 ) {
                    $files = array_merge( $files$files2 );
                } else {
                    $files[] = $folder . $file . '/';
                }
            } else {
                $files[] = $folder . $file;
            }
        }

        closedir( $dir );
    }
Home | Imprint | This part of the site doesn't use cookies.