.circleci
assets
bin
data
inc
admin-pages
api
builders
checkout
compat
contracts
country
database
debug
deprecated
development
domain-mapping
duplication
exception
functions
admin.php
array-helpers.php
assets.php
broadcast.php
checkout-form.php
checkout.php
color.php
countries.php
currency.php
customer.php
danger.php
date.php
debug.php
discount-code.php
documentation.php
domain.php
element.php
email.php
env.php
event.php
financial.php
form.php
fs.php
gateway.php
generator.php
geolocation.php
helper.php
http.php
invoice.php
legacy.php
limitations.php
markup-helpers.php
membership.php
mock.php
model.php
number-helpers.php
options.php
pages.php
payment.php
product.php
reflection.php
rest.php
scheduler.php
session.php
settings.php
site-context.php
site.php
sort.php
string-helpers.php
sunrise.php
tax.php
template.php
translation.php
url.php
user.php
webhook.php
gateways
helpers
installers
integrations
internal
invoices
limitations
limits
list-tables
loaders
managers
mercator
models
next
objects
site-templates
sso
tax
traits
ui
updater
class-admin-notices.php
class-admin-themes-compatibility.php
class-ajax.php
class-api.php
class-async-calls.php
class-autoloader.php
class-cron.php
class-current.php
class-dashboard-statistics.php
class-dashboard-widgets.php
class-documentation.php
class-domain-mapping.php
class-faker.php
class-geolocation.php
class-helper.php
class-hooks.php
class-license.php
class-light-ajax.php
class-logger.php
class-maintenance-mode.php
class-newsletter.php
class-requirements.php
class-scripts.php
class-session-cookie.php
class-settings.php
class-sunrise.php
class-user-switching.php
class-views.php
class-whitelabel.php
class-wp-ultimo.php
lang
patches
tests
views
.gitignore
.phpcs.xml.dist
LICENSE
autoload.php
composer.json
composer.lock
constants.php
loco.xml
phpunit.xml.dist
readme.txt
sunrise.php
uninstall.php
wp-multisite-waas.php
50 lines
867 B
PHP
50 lines
867 B
PHP
<?php
|
|
/**
|
|
* Generator Functions
|
|
*
|
|
* @package WP_Ultimo\Functions
|
|
* @since 2.0.11
|
|
*/
|
|
|
|
// Exit if accessed directly
|
|
defined('ABSPATH') || exit;
|
|
|
|
/**
|
|
* Generate CSV file
|
|
*
|
|
* @param string $file_name File name.
|
|
* @param array $data Content.
|
|
* @return void
|
|
*/
|
|
function wu_generate_csv($file_name, $data = array()) {
|
|
|
|
$fp = fopen('php://output', 'w');
|
|
|
|
if ($fp && $data) {
|
|
|
|
header('Content-Type: text/csv; charset=utf-8');
|
|
|
|
header('Content-Disposition: attachment; filename="' . $file_name . '.csv"');
|
|
|
|
header('Pragma: no-cache');
|
|
|
|
header('Expires: 0');
|
|
|
|
foreach ($data as $data_line) {
|
|
|
|
if (is_array($data_line)) {
|
|
|
|
fputcsv($fp, array_values($data_line));
|
|
|
|
} elseif (is_object($data_line)) {
|
|
|
|
fputcsv($fp, array_values(get_object_vars($data_line)));
|
|
|
|
} // end if;
|
|
|
|
} // end foreach;
|
|
|
|
} // end if;
|
|
|
|
} // end wu_generate_csv;
|