array(), 'nonce' => '' ); $my_options = array_merge( $defaults, $_POST ); // validate nonce if( !wp_verify_nonce($my_options['nonce'], 'export') ) { wp_die(__("Error",'acf')); } // check for posts if( empty($my_options['acf_posts']) ) { wp_die(__("No ACF groups selected",'acf')); } /** * Version number for the export format. * * Bump this when something changes that might affect compatibility. * * @since 2.5.0 */ define( 'WXR_VERSION', '1.1' ); /* * fix_line_breaks * * This function will loop through all array pieces and correct double line breaks from DB to XML * * @type function * @date 2/12/2013 * @since 5.0.0 * * @param $v (mixed) * @return $v (mixed) */ function fix_line_breaks( $v ) { if( is_array($v) ) { foreach( array_keys($v) as $k ) { $v[ $k ] = fix_line_breaks( $v[ $k ] ); } } elseif( is_string($v) ) { $v = str_replace("\r\n", "\r", $v); } return $v; } /** * Wrap given string in XML CDATA tag. * * @since 2.1.0 * * @param string $str String to wrap in XML CDATA tag. */ function wxr_cdata( $str ) { if ( seems_utf8( $str ) == false ) $str = utf8_encode( $str ); // $str = ent2ncr(esc_html($str)); $str = "'; return $str; } /** * Return the URL of the site * * @since 2.5.0 * * @return string Site URL. */ function wxr_site_url() { // ms: the base url if ( is_multisite() ) return network_home_url(); // wp: the blog url else return get_site_url(); } /** * Output a tag_description XML tag from a given tag object * * @since 2.3.0 * * @param object $tag Tag Object */ function wxr_tag_description( $tag ) { if ( empty( $tag->description ) ) return; echo '' . wxr_cdata( $tag->description ) . ''; } /** * Output a term_name XML tag from a given term object * * @since 2.9.0 * * @param object $term Term Object */ function wxr_term_name( $term ) { if ( empty( $term->name ) ) return; echo '' . wxr_cdata( $term->name ) . ''; } /** * Output a term_description XML tag from a given term object * * @since 2.9.0 * * @param object $term Term Object */ function wxr_term_description( $term ) { if ( empty( $term->description ) ) return; echo '' . wxr_cdata( $term->description ) . ''; } /** * Output list of authors with posts * * @since 3.1.0 */ function wxr_authors_list() { global $wpdb; $authors = array(); $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts" ); foreach ( (array) $results as $result ) $authors[] = get_userdata( $result->post_author ); $authors = array_filter( $authors ); foreach( $authors as $author ) { echo "\t"; echo '' . $author->ID . ''; echo '' . $author->user_login . ''; echo '' . $author->user_email . ''; echo '' . wxr_cdata( $author->display_name ) . ''; echo '' . wxr_cdata( $author->user_firstname ) . ''; echo '' . wxr_cdata( $author->user_lastname ) . ''; echo "\n"; } } header( 'Content-Description: File Transfer' ); header( 'Content-Disposition: attachment; filename=advanced-custom-field-export.xml' ); header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); echo '\n"; ?> <?php bloginfo_rss( 'name' ); ?> in_the_loop = true; // Fake being in the loop. // create SQL with %d placeholders $where = 'WHERE ID IN (' . substr(str_repeat('%d,', count($my_options['acf_posts'])), 0, -1) . ')'; // now prepare the SQL based on the %d + $_POST data $posts = $wpdb->get_results( $wpdb->prepare("SELECT * FROM {$wpdb->posts} $where", $my_options['acf_posts'])); // Begin Loop foreach ( $posts as $post ) { setup_postdata( $post ); ?> <?php echo apply_filters( 'the_title_rss', $post->post_title ); ?> ID; ?> post_date; ?> post_date_gmt; ?> comment_status; ?> ping_status; ?> post_name; ?> post_status; ?> post_parent; ?> menu_order; ?> post_type; ?> post_password; ?> get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) ); foreach( $postmeta as $meta ) : if ( $meta->meta_key != '_edit_lock' ) : $meta->meta_value = maybe_unserialize( $meta->meta_value ); $meta->meta_value = fix_line_breaks( $meta->meta_value ); $meta->meta_value = maybe_serialize( $meta->meta_value ); ?> meta_key; ?> meta_value ); ?>