PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.21
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.21
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / classes / views / xml / posts_xml.php

posts_xml.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.21, at classes/views/xml/posts_xml.php

130 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Generate the XML for export for posts and form actions.
4 *
5 * @phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect
6 *
7 * @package Formidable
8 */
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 die( 'You are not allowed to call this page directly.' );
12 }
13
14 if ( ! $item_ids ) {
15 return;
16 }
17
18 global $wp_query;
19 // Fake being in the loop.
20 $wp_query->in_the_loop = true;
21
22 // fetch 20 posts at a time rather than loading the entire table into memory
23 while ( $next_posts = array_splice( $item_ids, 0, 20 ) ) {
24 $posts = FrmDb::get_results( $wpdb->posts, array( 'ID' => $next_posts ) );
25
26 // Begin Loop
27 foreach ( $posts as $post ) {
28 setup_postdata( $post );
29 $is_sticky = is_sticky( $post->ID ) ? 1 : 0;
30 ?>
31 <view>
32 <title><?php echo esc_html( apply_filters( 'the_title_rss', $post->post_title ) ); ?></title>
33 <link><?php the_permalink_rss(); ?></link>
34 <post_author><?php echo FrmXMLHelper::cdata( get_the_author_meta( 'login' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></post_author>
35 <description></description>
36 <content><?php echo FrmXMLHelper::cdata( apply_filters( 'the_content_export', $post->post_content ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></content>
37 <excerpt><?php echo FrmXMLHelper::cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></excerpt>
38 <post_id><?php echo esc_html( $post->ID ); ?></post_id>
39 <post_date><?php echo esc_html( $post->post_date ); ?></post_date>
40 <post_date_gmt><?php echo esc_html( $post->post_date_gmt ); ?></post_date_gmt>
41 <comment_status><?php echo esc_html( $post->comment_status ); ?></comment_status>
42 <ping_status><?php echo esc_html( $post->ping_status ); ?></ping_status>
43 <post_name><?php echo esc_html( $post->post_name ); ?></post_name>
44 <status><?php echo esc_html( $post->post_status ); ?></status>
45 <post_parent><?php echo esc_html( $post->post_parent ); ?></post_parent>
46 <menu_order><?php echo esc_html( $post->menu_order ); ?></menu_order>
47 <post_type><?php echo esc_html( $post->post_type ); ?></post_type>
48 <post_password><?php echo FrmXMLHelper::cdata( $post->post_password ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></post_password>
49 <is_sticky><?php echo esc_html( $is_sticky ); ?></is_sticky>
50 <?php if ( 'attachment' === $post->post_type ) : ?>
51 <attachment_url><?php echo esc_url( wp_get_attachment_url( $post->ID ) ); ?></attachment_url>
52 <?php
53 endif;
54
55 $postmeta = FrmDb::get_results( $wpdb->postmeta, array( 'post_id' => $post->ID ) );
56 foreach ( $postmeta as $meta ) :
57 if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) ) {
58 continue;
59 }
60 ?>
61 <postmeta>
62 <meta_key><?php echo esc_html( $meta->meta_key ); ?></meta_key>
63 <meta_value><?php echo FrmXMLHelper::cdata( $meta->meta_value ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></meta_value>
64 </postmeta>
65 <?php
66 endforeach;
67
68 $taxonomies = get_object_taxonomies( $post->post_type );
69 if ( ! empty( $taxonomies ) ) {
70 $terms = wp_get_object_terms( $post->ID, $taxonomies );
71
72 foreach ( (array) $terms as $term ) {
73 ?>
74 <category domain="<?php echo esc_attr( $term->taxonomy ); ?>" nicename="<?php echo esc_attr( $term->slug ); ?>"><?php echo FrmXMLHelper::cdata( $term->name ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></category>
75 <?php
76 }
77 }
78
79 if ( 'frm_display' === $post->post_type && is_callable( 'FrmViewsLayout::get_layouts_for_view' ) ) {
80 $layouts = FrmViewsLayout::get_layouts_for_view( $post->ID );
81 if ( is_array( $layouts ) ) {
82 foreach ( $layouts as $layout ) {
83 ?>
84 <layout>
85 <type><?php echo esc_html( $layout->type ); ?></type>
86 <data><?php echo FrmXMLHelper::cdata( $layout->data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></data>
87 </layout>
88 <?php
89 }
90 }
91 }
92 ?>
93 </view>
94 <?php
95 }//end foreach
96 }//end while
97
98 if ( empty( $taxonomies ) ) {
99 return;
100 }
101
102 global $frm_inc_tax;
103 if ( empty( $frm_inc_tax ) ) {
104 $frm_inc_tax = array();
105 }
106
107 $parent_slugs = FrmXMLController::get_parent_terms_slugs( $terms );
108
109 foreach ( (array) $terms as $term ) {
110 if ( in_array( $term->term_id, $frm_inc_tax, true ) ) {
111 continue;
112 }
113
114 $frm_inc_tax[] = $term->term_id;
115 $label = 'category' === $term->taxonomy || 'tag' === $term->taxonomy ? $term->taxonomy : 'term';
116 ?>
117 <term><term_id><?php echo esc_html( $term->term_id ); ?></term_id><term_taxonomy><?php echo esc_html( $term->taxonomy ); ?></term_taxonomy><?php
118 if ( ! empty( $parent_slugs[ $term->parent ] ) ) {
119 echo '<term_parent>' . esc_html( $parent_slugs[ $term->parent ] ) . '</term_parent>';
120 }
121 if ( ! empty( $term->name ) ) {
122 echo '<term_name>' . FrmXMLHelper::cdata( $term->name ) . '</term_name>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
123 }
124 if ( ! empty( $term->description ) ) {
125 echo '<term_description>' . FrmXMLHelper::cdata( $term->description ) . '</term_description>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
126 }
127 echo '<term_slug>' . esc_html( $term->slug ) . '</term_slug>';
128 echo '</term>';
129 }//end foreach
130