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