postmeta}, {$wpdb->posts} WHERE meta_key = 'modula-images' AND post_id=ID AND post_type='modula-gallery'"; $metas = $wpdb->get_col( $query ); foreach ( $metas as $meta ) { $images = maybe_unserialize( $meta ); if ( is_array( $images ) ) { foreach ( $images as $image ) { if ( in_array( $image['id'], $already_exported ) ) { continue; }else{ $already_exported[] = $image['id']; } $post = get_post( $image['id'] ); setup_postdata( $post ); /** This filter is documented in wp-includes/feed.php */ $title = apply_filters( 'the_title_rss', $post->post_title ); /** * Filters the post content used for WXR exports. * * @since 2.5.0 * * @param string $post_content Content of the current post. */ $content = wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) ); /** * Filters the post excerpt used for WXR exports. * * @since 2.6.0 * * @param string $post_excerpt Excerpt for the current post. */ $excerpt = wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) ); ?> <?php echo esc_html( $title ); ?> ID ); ?> post_date ); ?> post_date_gmt ); ?> comment_status ); ?> ping_status ); ?> post_name ); ?> post_status ); ?> post_parent ); ?> menu_order ); ?> post_type ); ?> post_password ); ?> post_type == 'attachment' ) : ?> ID ) ); ?> get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) ); foreach ( $postmeta as $meta ) : /** * Filters whether to selectively skip post meta used for WXR exports. * * Returning a truthy value to the filter will skip the current meta * object from being exported. * * @since 3.3.0 * * @param bool $skip Whether to skip the current post meta. Default false. * @param string $meta_key Current meta key. * @param object $meta Current meta object. */ if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) ) { continue; } ?> meta_key ); ?> meta_value ); ?> processed_attachments[ $post['post_id'] ] = $post_id; }elseif ( 'modula-gallery' == $post['post_type'] ) { $this->processed_galleries[ $post['post_id'] ] = $post_id; } return $terms; } public function change_meta_on_import(){ if ( empty( $this->processed_galleries ) ) { return; } foreach ( $this->processed_galleries as $original_post_ID => $post_id ) { $modula_images = array(); $gallery_meta = get_post_meta( $post_id, 'modula-images', true ); if ( is_array( $gallery_meta ) ) { foreach ( $gallery_meta as $index => $modula_image ) { if ( ! isset( $this->processed_attachments[ $modula_image['id'] ] ) ) { $modula_images[ $index ] = $modula_image; continue; } if ( $this->processed_attachments[ $modula_image['id'] ] != $modula_image['id'] ) { $modula_image['id'] = $this->processed_attachments[ $modula_image['id'] ]; } $modula_images[ $index ] = $modula_image; } } update_post_meta( $post_id, 'modula-images', $modula_images ); } $arr = array( 'att' => $this->processed_attachments, 'galleries' => $this->processed_galleries ); $file = MODULA_PATH . 'import_file.txt'; file_put_contents($file, print_r( $arr, true ), FILE_APPEND ); } } new Modula_Importer_Exporter();