wp_privacy_exports_dir example


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. */
if ( ! $request || 'export_personal_data' !== $request->action_name ) {
        wp_send_json_error( __( 'Invalid request ID when generating personal data export file.' ) );
    }

    $email_address = $request->email;

    if ( ! is_email( $email_address ) ) {
        wp_send_json_error( __( 'Invalid email address when generating personal data export file.' ) );
    }

    // Create the exports folder if needed.     $exports_dir = wp_privacy_exports_dir();
    $exports_url = wp_privacy_exports_url();

    if ( ! wp_mkdir_p( $exports_dir ) ) {
        wp_send_json_error( __( 'Unable to create personal data export folder.' ) );
    }

    // Protect export folder from browsing.     $index_pathname = $exports_dir . 'index.php';
    if ( ! file_exists( $index_pathname ) ) {
        $file = fopen( $index_pathname, 'w' );
        if ( false === $file ) {
            
Home | Imprint | This part of the site doesn't use cookies.