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.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.4.0 4.4.1 4.4.10 4.4.11 4.4.12 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 5.10 5.10.1 5.10.2 5.11 5.11.1 5.11.2 5.11.3 5.11.4 5.12 5.12.1 5.12.2 5.12.3 5.12.4 5.12.5 5.12.6 5.6.10 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 5.6.7 5.6.8 5.6.9 5.7.0 5.7.1 5.7.10 5.7.12 5.7.13 5.7.2 5.7.3 5.7.4 5.7.5 5.7.6 5.7.7 5.7.8 5.7.9 5.8.0 5.8.1 5.8.10 5.8.11 5.8.12 5.8.13 5.8.14 5.8.2 5.8.3 5.8.4
advanced-custom-fields / core / actions / export.php
advanced-custom-fields / core / actions Last commit date
export.php 13 years ago
export.php
221 lines
1 <?php
2 /*--------------------------------------------------------------------------------------
3 *
4 * ACF Export
5 *
6 * @author Elliot Condon
7 * @since 3.0.2
8 *
9 *-------------------------------------------------------------------------------------*/
10
11 // includes
12 require_once('../../../../../wp-load.php');
13 require_once('../../../../../wp-admin/admin.php');
14
15
16 // check for posts
17 if(!isset($_POST['acf_posts']))
18 {
19 wp_die(__("No ACF groups selected",'acf'));
20 }
21
22
23 /**
24 * Version number for the export format.
25 *
26 * Bump this when something changes that might affect compatibility.
27 *
28 * @since 2.5.0
29 */
30 define( 'WXR_VERSION', '1.1' );
31
32
33 /**
34 * Wrap given string in XML CDATA tag.
35 *
36 * @since 2.1.0
37 *
38 * @param string $str String to wrap in XML CDATA tag.
39 */
40 function wxr_cdata( $str ) {
41 if ( seems_utf8( $str ) == false )
42 $str = utf8_encode( $str );
43
44 // $str = ent2ncr(esc_html($str));
45 $str = "<![CDATA[$str" . ( ( substr( $str, -1 ) == ']' ) ? ' ' : '' ) . ']]>';
46
47 return $str;
48 }
49
50 /**
51 * Return the URL of the site
52 *
53 * @since 2.5.0
54 *
55 * @return string Site URL.
56 */
57 function wxr_site_url() {
58 // ms: the base url
59 if ( is_multisite() )
60 return network_home_url();
61 // wp: the blog url
62 else
63 return get_bloginfo_rss( 'url' );
64 }
65
66 /**
67 * Output a tag_description XML tag from a given tag object
68 *
69 * @since 2.3.0
70 *
71 * @param object $tag Tag Object
72 */
73 function wxr_tag_description( $tag ) {
74 if ( empty( $tag->description ) )
75 return;
76
77 echo '<wp:tag_description>' . wxr_cdata( $tag->description ) . '</wp:tag_description>';
78 }
79
80 /**
81 * Output a term_name XML tag from a given term object
82 *
83 * @since 2.9.0
84 *
85 * @param object $term Term Object
86 */
87 function wxr_term_name( $term ) {
88 if ( empty( $term->name ) )
89 return;
90
91 echo '<wp:term_name>' . wxr_cdata( $term->name ) . '</wp:term_name>';
92 }
93
94 /**
95 * Output a term_description XML tag from a given term object
96 *
97 * @since 2.9.0
98 *
99 * @param object $term Term Object
100 */
101 function wxr_term_description( $term ) {
102 if ( empty( $term->description ) )
103 return;
104
105 echo '<wp:term_description>' . wxr_cdata( $term->description ) . '</wp:term_description>';
106 }
107
108 /**
109 * Output list of authors with posts
110 *
111 * @since 3.1.0
112 */
113 function wxr_authors_list() {
114 global $wpdb;
115
116 $authors = array();
117 $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts" );
118 foreach ( (array) $results as $result )
119 $authors[] = get_userdata( $result->post_author );
120
121 $authors = array_filter( $authors );
122
123 foreach( $authors as $author ) {
124 echo "\t<wp:author>";
125 echo '<wp:author_id>' . $author->ID . '</wp:author_id>';
126 echo '<wp:author_login>' . $author->user_login . '</wp:author_login>';
127 echo '<wp:author_email>' . $author->user_email . '</wp:author_email>';
128 echo '<wp:author_display_name>' . wxr_cdata( $author->display_name ) . '</wp:author_display_name>';
129 echo '<wp:author_first_name>' . wxr_cdata( $author->user_firstname ) . '</wp:author_first_name>';
130 echo '<wp:author_last_name>' . wxr_cdata( $author->user_lastname ) . '</wp:author_last_name>';
131 echo "</wp:author>\n";
132 }
133 }
134
135 header( 'Content-Description: File Transfer' );
136 header( 'Content-Disposition: attachment; filename=advanced-custom-field-export.xml' );
137 header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
138
139
140 echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n";
141
142 ?>
143 <!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
144 <!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
145 <!-- You may use this file to transfer that content from one site to another. -->
146 <!-- This file is not intended to serve as a complete backup of your site. -->
147
148 <!-- To import this information into a WordPress site follow these steps: -->
149 <!-- 1. Log in to that site as an administrator. -->
150 <!-- 2. Go to Tools: Import in the WordPress admin panel. -->
151 <!-- 3. Install the "WordPress" importer from the list. -->
152 <!-- 4. Activate & Run Importer. -->
153 <!-- 5. Upload this file using the form provided on that page. -->
154 <!-- 6. You will first be asked to map the authors in this export file to users -->
155 <!-- on the site. For each author, you may choose to map to an -->
156 <!-- existing user on the site or to create a new user. -->
157 <!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
158 <!-- contained in this file into your site. -->
159
160 <?php the_generator( 'export' ); ?>
161 <rss version="2.0"
162 xmlns:excerpt="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/excerpt/"
163 xmlns:content="http://purl.org/rss/1.0/modules/content/"
164 xmlns:wfw="http://wellformedweb.org/CommentAPI/"
165 xmlns:dc="http://purl.org/dc/elements/1.1/"
166 xmlns:wp="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/"
167 >
168
169 <channel>
170 <title><?php bloginfo_rss( 'name' ); ?></title>
171 <link><?php bloginfo_rss( 'url' ); ?></link>
172 <description><?php bloginfo_rss( 'description' ); ?></description>
173 <pubDate><?php echo date( 'D, d M Y H:i:s +0000' ); ?></pubDate>
174 <language><?php echo get_option( 'rss_language' ); ?></language>
175 <wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
176 <wp:base_site_url><?php echo wxr_site_url(); ?></wp:base_site_url>
177 <wp:base_blog_url><?php bloginfo_rss( 'url' ); ?></wp:base_blog_url>
178 <?php wxr_authors_list(); ?>
179 <?php if ( $_POST['acf_posts'] ) {
180
181 global $wp_query;
182 $wp_query->in_the_loop = true; // Fake being in the loop.
183
184 $where = 'WHERE ID IN (' . join( ',', $_POST['acf_posts'] ) . ')';
185 $posts = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} $where" );
186
187 // Begin Loop
188 foreach ( $posts as $post ) {
189 setup_postdata( $post );
190 ?>
191 <item>
192 <title><?php echo apply_filters( 'the_title_rss', $post->post_title ); ?></title>
193 <link><?php the_permalink_rss() ?></link>
194 <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate>
195 <dc:creator><?php echo get_the_author_meta( 'login' ); ?></dc:creator>
196 <guid isPermaLink="false"><?php esc_url( the_guid() ); ?></guid>
197 <wp:post_id><?php echo $post->ID; ?></wp:post_id>
198 <wp:post_date><?php echo $post->post_date; ?></wp:post_date>
199 <wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt>
200 <wp:comment_status><?php echo $post->comment_status; ?></wp:comment_status>
201 <wp:ping_status><?php echo $post->ping_status; ?></wp:ping_status>
202 <wp:post_name><?php echo $post->post_name; ?></wp:post_name>
203 <wp:status><?php echo $post->post_status; ?></wp:status>
204 <wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent>
205 <wp:menu_order><?php echo $post->menu_order; ?></wp:menu_order>
206 <wp:post_type><?php echo $post->post_type; ?></wp:post_type>
207 <wp:post_password><?php echo $post->post_password; ?></wp:post_password>
208 <?php $postmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
209 foreach( $postmeta as $meta ) : if ( $meta->meta_key != '_edit_lock' ) : ?>
210 <wp:postmeta>
211 <wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
212 <wp:meta_value><?php echo wxr_cdata( $meta->meta_value ); ?></wp:meta_value>
213 </wp:postmeta>
214 <?php endif; endforeach; ?>
215 </item>
216 <?php
217 }
218 }
219 ?>
220 </channel>
221 </rss>