本文整理汇总了PHP中export_wp函数的典型用法代码示例。如果您正苦于以下问题:PHP export_wp函数的具体用法?PHP export_wp怎么用?PHP export_wp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了export_wp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: make_export
function make_export()
{
if ($this->request->isset_GET('download') && ($this->request->isset_GET('page') && $this->request->GET('page') == 'tf_export')) {
remove_filter('the_title_rss', 'strip_tags');
remove_filter('the_title_rss', 'ent2ncr', 8);
remove_filter('the_title_rss', 'esc_html');
add_filter('the_title_rss', array($this, 'tfuse_post_title_export'), 99, 1);
ob_start();
require_once './includes/export.php';
export_wp(array('content' => 'all'));
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
header_remove('Content-Description');
header_remove('Content-Disposition');
} else {
header("Content-Description: ");
header("Content-Disposition: ");
}
$buffer = ob_get_contents();
ob_end_clean();
$buffer = explode('</rss>', $buffer);
$tmp = explode('/', site_url());
$multi = is_multisite() ? '-' . end($tmp) : '';
$this->export_wp_filename = 'wordpress-' . TF_THEME_PREFIX . $multi . '.xml_.txt';
$this->content = $buffer[0] . $this->tfuse_options_export() . '</rss>';
// $this->download_export($this->content);
// die();
}
}
示例2: cherry_plugin_export_xml
function cherry_plugin_export_xml()
{
ob_start();
export_wp();
$xml = ob_get_clean();
$xml = iconv('utf-8', 'utf-8//IGNORE', $xml);
$xml = preg_replace('/[^\\x{0009}\\x{000a}\\x{000d}\\x{0020}-\\x{D7FF}\\x{E000}-\\x{FFFD}]+/u', '', $xml);
$xml_dir = UPLOAD_BASE_DIR . '/sample_data.xml';
file_put_contents($xml_dir, $xml);
return $xml_dir;
}
示例3: transform
/**
* Procedure for "format/wxr" rewrite rule.
*/
function transform()
{
// Check permissions
if (!current_user_can('manage_options')) {
$timestamp = absint(@$_REQUEST['timestamp']);
$hashkey = @$_REQUEST['hashkey'];
if (!$this->verifyNonce($timestamp, $hashkey)) {
wp_die(__('Invalid permission error', 'pressbooks'));
}
}
// ------------------------------------------------------------------------------------------------------------
// WXR, Start!
require_once ABSPATH . 'wp-admin/includes/export.php';
export_wp();
}
示例4: rebuild
/**
* Rebuild every demo file
*/
public function rebuild(ctImport $xmlImporter, ctNHP_Options $options)
{
//echo ctImport::getThemeOptionsPath();exit;
//theme options
if (file_put_contents(ctImport::getThemeOptionsPath(), $options->export()) === false) {
throw new Exception("Cannot save file to: " . ctImport::getThemeOptionsPath());
}
$this->export(self::EXPORT_FILE);
error_reporting(E_ERROR);
require_once ABSPATH . 'wp-admin/includes/export.php';
flush();
ob_start();
export_wp(array('content' => 'all'));
$xml = ob_get_contents();
ob_end_clean();
file_put_contents(ctImport::getXmlPath(), $xml);
}
示例5: sprintf
$start_date = sprintf("%04d-%02d-%02d", $aa_start, $mm_start, 1);
} else {
$start_date = 'all';
}
if ($mm_end != 'all' && $aa_end > 0) {
if ($mm_end == 12) {
$mm_end = 1;
$aa_end++;
} else {
$mm_end++;
}
$end_date = sprintf("%04d-%02d-%02d", $aa_end, $mm_end, 1);
} else {
$end_date = 'all';
}
export_wp($author, $category, $post_type, $status, $start_date, $end_date);
die;
}
require_once 'admin-header.php';
$months = "";
for ($i = 1; $i < 13; $i++) {
$months .= "\t\t\t<option value=\"" . zeroise($i, 2) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($i)) . "</option>\n";
}
?>
<div class="wrap">
<?php
screen_icon();
?>
<h2><?php
echo esc_html($title);
示例6: export_wp
/**
* Export function as it is defined in the original code of export_wp defined in wp-admin/includes/export.php
*/
private function export_wp($args = array())
{
require_once ABSPATH . 'wp-admin/includes/export.php';
global $wpdb;
/**
* This is mostly the original code of export_wp defined in wp-admin/includes/export.php
*/
$defaults = array('post_type' => 'all', 'post__in' => false, 'author' => false, 'category' => false, 'start_date' => false, 'end_date' => false, 'status' => false, 'skip_comments' => false, 'file_item_count' => 1000);
$args = wp_parse_args($args, $defaults);
WP_CLI::line("Exporting with export_wp with arguments: " . var_export($args, true));
do_action('export_wp');
$sitename = sanitize_key(get_bloginfo('name'));
if (!empty($sitename)) {
$sitename .= '.';
}
$append = array(date('Y-m-d'));
foreach (array_keys($args) as $arg_key) {
if ($defaults[$arg_key] != $args[$arg_key] && 'post__in' != $arg_key) {
$append[] = "{$arg_key}-" . (string) $args[$arg_key];
}
}
$file_name_base = sanitize_file_name($sitename . 'wordpress.' . implode(".", $append));
if ('all' != $args['post_type'] && post_type_exists($args['post_type'])) {
$ptype = get_post_type_object($args['post_type']);
if (!$ptype->can_export) {
$args['post_type'] = 'post';
}
$where = $wpdb->prepare("{$wpdb->posts}.post_type = %s", $args['post_type']);
} else {
$post_types = get_post_types(array('can_export' => true));
$esses = array_fill(0, count($post_types), '%s');
$where = $wpdb->prepare("{$wpdb->posts}.post_type IN (" . implode(',', $esses) . ')', $post_types);
}
if ($args['status'] && ('post' == $args['post_type'] || 'page' == $args['post_type'])) {
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_status = %s", $args['status']);
} else {
$where .= " AND {$wpdb->posts}.post_status != 'auto-draft'";
}
$join = '';
if ($args['category'] && 'post' == $args['post_type']) {
if ($term = term_exists($args['category'], 'category')) {
$join = "INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)";
$where .= $wpdb->prepare(" AND {$wpdb->term_relationships}.term_taxonomy_id = %d", $term['term_taxonomy_id']);
}
}
if ($args['author']) {
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_author = %d", $args['author']);
}
if ($args['start_date']) {
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_date >= %s", date('Y-m-d 00:00:00', strtotime($args['start_date'])));
}
if ($args['end_date']) {
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_date <= %s", date('Y-m-d 23:59:59', strtotime($args['end_date'])));
}
// grab a snapshot of post IDs, just in case it changes during the export
if (empty($args['post__in'])) {
$all_the_post_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} {$join} WHERE {$where} ORDER BY post_date ASC, post_parent ASC");
} else {
$all_the_post_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE ID IN ({$args['post__in']}) ORDER BY post_date ASC, post_parent ASC");
}
// Make sure we're getting all of the attachments for these posts too
if ('all' != $args['post_type'] || !empty($args['post__in'])) {
$all_post_ids_with_attachments = array();
while ($post_ids = array_splice($all_the_post_ids, 0, 100)) {
$attachment_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_parent IN (" . implode(",", array_map('intval', $post_ids)) . ")");
$all_post_ids_with_attachments = array_merge($all_post_ids_with_attachments, $post_ids, (array) $attachment_ids);
}
$all_the_post_ids = $all_post_ids_with_attachments;
}
// get the requested terms ready, empty unless posts filtered by category or all content
$cats = $tags = $terms = array();
if (isset($term) && $term) {
$cat = get_term($term['term_id'], 'category');
$cats = array($cat->term_id => $cat);
unset($term, $cat);
} else {
if ('all' == $args['post_type']) {
$categories = (array) get_categories(array('get' => 'all'));
$tags = (array) get_tags(array('get' => 'all'));
$custom_taxonomies = get_taxonomies(array('_builtin' => false));
$custom_terms = (array) get_terms($custom_taxonomies, array('get' => 'all'));
// put categories in order with no child going before its parent
while ($cat = array_shift($categories)) {
if ($cat->parent == 0 || isset($cats[$cat->parent])) {
$cats[$cat->term_id] = $cat;
} else {
$categories[] = $cat;
}
}
// put terms in order with no child going before its parent
while ($t = array_shift($custom_terms)) {
if ($t->parent == 0 || isset($terms[$t->parent])) {
$terms[$t->term_id] = $t;
} else {
$custom_terms[] = $t;
}
}
//.........这里部分代码省略.........
示例7: apply_filters
$args['status'] = $_GET['page_status'];
}
} else {
$args['content'] = $_GET['content'];
}
}
}
/**
* Filter the export args.
*
* @since 3.5.0
*
* @param array $args The arguments to send to the exporter.
*/
$args = apply_filters('export_args', $args);
export_wp($args);
die;
}
require_once ABSPATH . 'wp-admin/admin-header.php';
/**
* Create the date options fields for exporting a given post type.
*
* @global wpdb $wpdb WordPress database object.
* @global WP_Locale $wp_locale Date and Time Locale object.
*
* @since 3.1.0
*
* @param string $post_type The post type. Default 'post'.
*/
function export_date_options($post_type = 'post')
{
示例8: codeless_export_content
function codeless_export_content()
{
ob_start();
if (!function_exists('export_wp')) {
$export = ABSPATH . 'wp-admin/includes/export.php';
require_once $export;
}
export_wp();
$output = ob_get_clean();
if ($this->save('content.xml', $output)) {
$this->message = __("Content exported successfully", "redux-framework");
return 1;
} else {
return 2;
}
}
示例9: require_once
<?php
require_once ('admin.php');
require_once('includes/export.php');
$title = __('Export');
$parent_file = 'edit.php';
if ( isset( $_GET['download'] ) ) {
export_wp( $_GET['author'] );
die();
}
require_once ('admin-header.php');
?>
<div class="wrap">
<h2><?php _e('Export'); ?></h2>
<p><?php _e('When you click the button below WordPress will create an XML file for you to save to your computer.'); ?></p>
<p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, pages, comments, custom fields, categories, and tags.'); ?></p>
<p><?php _e('Once you’ve saved the download file, you can use the Import function on another WordPress blog to import this blog.'); ?></p>
<form action="" method="get">
<h3><?php _e('Options'); ?></h3>
<table class="form-table">
<tr>
<th><?php _e('Restrict Author'); ?></th>
<td>
<select name="author">
<option value="all" selected="selected"><?php _e('All Authors'); ?></option>
<?php
$authors = $wpdb->get_col( "SELECT post_author FROM $wpdb->posts GROUP BY post_author" );
foreach ( $authors as $id ) {
示例10: run_export
/**
* The actual export is done here
*/
function run_export()
{
if (is_admin() && isset($_GET['wp-attachment-export-download'])) {
if (current_user_can('administrator') && isset($_REQUEST['wp_attachment_export_nonce']) && wp_verify_nonce($_REQUEST['wp_attachment_export_nonce'], 'wp_attachment_export_download')) {
require_once ABSPATH . '/wp-admin/includes/export.php';
$args = array();
$args['content'] = $_GET['content'];
export_wp($args);
die;
} else {
wp_nonce_ays('wp_attachment_export_download');
}
}
}
示例11: isset
}
$post_type = isset($_GET['post_type']) ? stripslashes_deep($_GET['post_type']) : 'all';
$status = isset($_GET['status']) ? stripslashes_deep($_GET['status']) : 'all';
$mm_start = isset($_GET['mm_start']) ? $_GET['mm_start'] : 'all';
$mm_end = isset($_GET['mm_end']) ? $_GET['mm_end'] : 'all';
if ($mm_start != 'all') {
$start_date = sprintf("%04d-%02d-%02d", substr($mm_start, 0, 4), substr($mm_start, 5, 2), 1);
} else {
$start_date = 'all';
}
if ($mm_end != 'all') {
$end_date = sprintf("%04d-%02d-%02d", substr($mm_end, 0, 4), substr($mm_end, 5, 2), 1);
} else {
$end_date = 'all';
}
export_wp(array('author' => $author, 'taxonomy' => $taxonomy, 'post_type' => $post_type, 'post_status' => $status, 'start_date' => $start_date, 'end_date' => $end_date));
die;
}
require_once 'admin-header.php';
$dateoptions = $edateoptions = '';
$types = "'" . implode("', '", get_post_types(array('public' => true, 'can_export' => true), 'names')) . "'";
$stati = "'" . implode("', '", get_post_stati(array('internal' => false), 'names')) . "'";
if ($monthyears = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, YEAR(DATE_ADD(post_date, INTERVAL 1 MONTH)) AS `eyear`, MONTH(DATE_ADD(post_date, INTERVAL 1 MONTH)) AS `emonth` FROM {$wpdb->posts} WHERE post_type IN ({$types}) AND post_status IN ({$stati}) ORDER BY post_date ASC ")) {
foreach ($monthyears as $k => $monthyear) {
$monthyears[$k]->lmonth = $wp_locale->get_month($monthyear->month, 2);
}
for ($s = 0, $e = count($monthyears) - 1; $e >= 0; $s++, $e--) {
$dateoptions .= "\t<option value=\"" . $monthyears[$s]->year . '-' . zeroise($monthyears[$s]->month, 2) . '">' . $monthyears[$s]->lmonth . ' ' . $monthyears[$s]->year . "</option>\n";
$edateoptions .= "\t<option value=\"" . $monthyears[$e]->eyear . '-' . zeroise($monthyears[$e]->emonth, 2) . '">' . $monthyears[$e]->lmonth . ' ' . $monthyears[$e]->year . "</option>\n";
}
}
示例12: do_export_xml
/**
* Export content into XML file
*
* @since 1.0.0
* @return string
*/
function do_export_xml()
{
ob_start();
$use_custom_export = apply_filters('cherry_data_manager_use_custom_export', false);
if ($use_custom_export && function_exists($use_custom_export)) {
call_user_func($use_custom_export);
} else {
export_wp();
}
$xml = ob_get_clean();
$xml = iconv('utf-8', 'utf-8//IGNORE', $xml);
$xml = preg_replace('/[^\\x{0009}\\x{000a}\\x{000d}\\x{0020}-\\x{D7FF}\\x{E000}-\\x{FFFD}]+/u', '', $xml);
$upload_dir = wp_upload_dir();
$upload_base_dir = $upload_dir['basedir'];
$xml_dir = $upload_base_dir . '/sample_data.xml';
file_put_contents($xml_dir, $xml);
return $xml_dir;
}
示例13: job_run
/**
* @param $job_object
* @return bool
*/
public function job_run(&$job_object)
{
$job_object->substeps_todo = 2;
$job_object->log(sprintf(__('%d. Trying to create a WordPress export to XML file …', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']));
//build filename
$job_object->temp['wpexportfile'] = $job_object->generate_filename($job_object->job['wpexportfile'], 'xml');
//check export file for writing
if (!touch(BackWPup::get_plugin_data('TEMP') . $job_object->temp['wpexportfile'])) {
$job_object->log(__('WP Export file could not generated.', 'backwpup'), E_USER_ERROR);
return FALSE;
}
//include WP export function
$this->job_object =& $job_object;
$this->job_object->temp['wp_export_part'] = 0;
require_once ABSPATH . 'wp-admin/includes/export.php';
ob_start(array($this, 'ob_callback'), 1024 * 1024);
//start output buffering
$args = array('content' => $job_object->job['wpexportcontent']);
@export_wp($args);
//WP export
ob_end_clean();
//End output buffering
if (filesize(BackWPup::get_plugin_data('TEMP') . $this->job_object->temp['wpexportfile']) < 1500) {
$job_object->log(__('Could not generate a WordPress export file.', 'backwpup'), E_USER_ERROR);
return FALSE;
}
if (extension_loaded('simplexml') && class_exists('DOMDocument')) {
$job_object->log(__('Check WP Export file …', 'backwpup'));
$job_object->need_free_memory(filesize(BackWPup::get_plugin_data('TEMP') . $this->job_object->temp['wpexportfile']) * 2);
$valid = TRUE;
$internal_errors = libxml_use_internal_errors(TRUE);
$dom = new DOMDocument();
$old_value = NULL;
if (function_exists('libxml_disable_entity_loader')) {
$old_value = libxml_disable_entity_loader(TRUE);
}
$success = $dom->loadXML(file_get_contents(BackWPup::get_plugin_data('TEMP') . $this->job_object->temp['wpexportfile']));
if (!is_null($old_value)) {
libxml_disable_entity_loader($old_value);
}
if (!$success || isset($dom->doctype)) {
$errors = libxml_get_errors();
$valid = FALSE;
foreach ($errors as $error) {
switch ($error->level) {
case LIBXML_ERR_WARNING:
$job_object->log(E_USER_WARNING, sprintf(__('XML WARNING (%s): %s', 'backwpup'), $error->code, trim($error->message)), BackWPup::get_plugin_data('TEMP') . $job_object->temp['wpexportfile'], $error->line);
break;
case LIBXML_ERR_ERROR:
$job_object->log(E_USER_WARNING, sprintf(__('XML RECOVERABLE (%s): %s', 'backwpup'), $error->code, trim($error->message)), BackWPup::get_plugin_data('TEMP') . $job_object->temp['wpexportfile'], $error->line);
break;
case LIBXML_ERR_FATAL:
$job_object->log(E_USER_WARNING, sprintf(__('XML ERROR (%s): %s', 'backwpup'), $error->code, trim($error->message)), BackWPup::get_plugin_data('TEMP') . $job_object->temp['wpexportfile'], $error->line);
break;
}
}
} else {
$xml = simplexml_import_dom($dom);
unset($dom);
// halt if loading produces an error
if (!$xml) {
$job_object->log(__('There was an error when reading this WXR file', 'backwpup'), E_USER_ERROR);
$valid = FALSE;
} else {
$wxr_version = $xml->xpath('/rss/channel/wp:wxr_version');
if (!$wxr_version) {
$job_object->log(__('This does not appear to be a WXR file, missing/invalid WXR version number', 'backwpup'), E_USER_ERROR);
$valid = FALSE;
}
$wxr_version = (string) trim($wxr_version[0]);
// confirm that we are dealing with the correct file format
if (!preg_match('/^\\d+\\.\\d+$/', $wxr_version)) {
$job_object->log(__('This does not appear to be a WXR file, missing/invalid WXR version number', 'backwpup'), E_USER_ERROR);
$valid = FALSE;
}
}
}
libxml_use_internal_errors($internal_errors);
if ($valid) {
$job_object->log(__('WP Export file is a valid WXR file.', 'backwpup'));
}
} else {
$job_object->log(__('WP Export file can not checked, because no XML extension loaded with the file can checked.', 'backwpup'));
}
$job_object->substeps_done++;
//Compress file
if (!empty($job_object->job['wpexportfilecompression'])) {
$job_object->log(__('Compressing file …', 'backwpup'));
try {
$compress = new BackWPup_Create_Archive(BackWPup::get_plugin_data('TEMP') . $job_object->temp['wpexportfile'] . $job_object->job['wpexportfilecompression']);
if ($compress->add_file(BackWPup::get_plugin_data('TEMP') . $job_object->temp['wpexportfile'])) {
unset($compress);
unlink(BackWPup::get_plugin_data('TEMP') . $job_object->temp['wpexportfile']);
$job_object->temp['wpexportfile'] .= $job_object->job['wpexportfilecompression'];
$job_object->log(__('Compressing done.', 'backwpup'));
}
//.........这里部分代码省略.........
示例14: export_sliders
function export_sliders()
{
if (isset($_POST['export_button']) && $_POST['export_button']) {
// Load Importer API
require_once ABSPATH . 'wp-admin/includes/export.php';
ob_start();
export_wp(array('content' => 'slide'));
$export = ob_get_contents();
ob_get_clean();
$terms = get_terms('slide-page', array('hide_empty' => 1));
foreach ($terms as $term) {
$term_meta = get_option('taxonomy_' . $term->term_id);
$export_terms[$term->slug] = $term_meta;
}
$json_export_terms = json_encode($export_terms);
$upload_dir = wp_upload_dir();
$base_dir = trailingslashit($upload_dir['basedir']);
$fs_dir = $base_dir . 't4p_slider/';
$loop = new WP_Query(array('post_type' => 'slide', 'posts_per_page' => -1, 'meta_key' => '_thumbnail_id'));
while ($loop->have_posts()) {
$loop->the_post();
$post_image_id = get_post_thumbnail_id(get_the_ID());
$image_path = get_attached_file($post_image_id);
if (isset($image_path) && $image_path) {
$ext = pathinfo($image_path, PATHINFO_EXTENSION);
@copy($image_path, $fs_dir . $post_image_id . '.' . $ext);
}
}
wp_reset_query();
$url = wp_nonce_url('edit.php?post_type=slide&page=fs_export_import');
if (false === ($creds = request_filesystem_credentials($url, '', false, false, null))) {
return;
// stop processing here
}
wp_mkdir_p($fs_dir);
if (WP_Filesystem($creds)) {
global $wp_filesystem;
if (!$wp_filesystem->put_contents($fs_dir . 'sliders.xml', $export, FS_CHMOD_FILE) || !$wp_filesystem->put_contents($fs_dir . 'settings.json', $json_export_terms, FS_CHMOD_FILE)) {
echo 'Couldn\'t export sliders, make sure wp-content/uploads is writeable.';
} else {
// Initialize archive object
$zip = new ZipArchive();
$zip->open('t4p_slider.zip', ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
foreach (new DirectoryIterator($fs_dir) as $file) {
if ($file->isDot()) {
continue;
}
$zip->addFile($fs_dir . $file->getFilename(), $file->getFilename());
}
$zip_file = $zip->filename;
// Zip archive will be created only after closing object
$zip->close();
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="t4p_slider.zip"');
header('Content-length: ' . filesize($zip_file));
header('Pragma: no-cache');
header('Expires: 0');
readfile($zip_file);
foreach (new DirectoryIterator($fs_dir) as $file) {
if ($file->isDot()) {
continue;
}
@unlink($fs_dir . $file->getFilename());
}
}
}
}
}
示例15: export_xml
public static function export_xml()
{
$ids = array();
foreach ($items as $i) {
$ids[] = (int) $i;
unset($i);
}
$ids = implode(',', array_filter($id, 'is_numeric'));
export_wp(array('content' => 'frm_display'));
$sitename = sanitize_key(get_bloginfo('name'));
if (!empty($sitename)) {
$sitename .= '.';
}
$filename = $sitename . 'wordpress.' . date('Y-m-d') . '.xml';
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename=' . $filename);
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
// grab a snapshot of post IDs, just in case it changes during the export
$post_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'frm_display' and ID in (" . $ids . ")");
add_filter('wxr_export_skip_postmeta', 'wxr_filter_postmeta', 10, 2);
include FrmAppHelper::plugin_path() . '/pro/classes/views/displays/xml.php';
die;
}