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