backward.php
2 months ago
get_taxonomies_by_object_type.php
2 months ago
pmxe_filter.php
2 months ago
pmxe_functions.php
2 months ago
pmxe_prepare_price.php
2 months ago
pmxe_render_xml_attributes.php
2 months ago
pmxe_render_xml_element.php
2 months ago
pmxe_render_xml_text.php
2 months ago
str_getcsv.php
2 months ago
wp_all_export_check_children_assign.php
2 months ago
wp_all_export_clear_xss.php
2 months ago
wp_all_export_comments_clauses.php
2 months ago
wp_all_export_generate_export_file.php
2 months ago
wp_all_export_get_cpt_name.php
2 months ago
wp_all_export_get_export_format.php
2 months ago
wp_all_export_is_compatible.php
2 months ago
wp_all_export_parse_field_name.php
2 months ago
wp_all_export_posts_join.php
2 months ago
wp_all_export_posts_where.php
2 months ago
wp_all_export_pre_user_query.php
2 months ago
wp_all_export_prepare_template_csv.php
2 months ago
wp_all_export_prepare_template_xml.php
2 months ago
wp_all_export_rand_char.php
2 months ago
wp_all_export_remove_colons.php
2 months ago
wp_all_export_remove_source.php
2 months ago
wp_all_export_reverse_rules_html.php
2 months ago
wp_all_export_rmdir.php
2 months ago
wp_all_export_secure_file.php
2 months ago
wp_all_export_terms_clauses.php
2 months ago
wp_all_export_url_title.php
2 months ago
wp_all_export_write_article.php
2 months ago
wp_redirect_or_javascript.php
2 months ago
pmxe_render_xml_text.php
29 lines
| 1 | <?php |
| 2 | |
| 3 | defined( 'ABSPATH' ) || exit; |
| 4 | |
| 5 | function pmxe_render_xml_text($text, $shorten = false, $is_render_collapsed = false) |
| 6 | { |
| 7 | if (empty($text)) { |
| 8 | return; // do not display empty text nodes |
| 9 | } |
| 10 | |
| 11 | if (preg_match('%\[more:(\d+)\]%', $text, $mtch)) { |
| 12 | $no = intval($mtch[1]); |
| 13 | /* translators: 1: count, 2: singular/plural noun */ |
| 14 | echo '<div class="xml-more">[ ⇓ ' . wp_kses_post(sprintf(__('<strong>%1$s</strong> %2$s more', 'wp-all-export'), $no, _n('element', 'elements', $no, 'wp-all-export'))) . ' ⇓ ]</div>'; |
| 15 | return; |
| 16 | } |
| 17 | $more = ''; |
| 18 | if ($shorten and preg_match('%^(.*?\s+){20}(?=\S)%', $text, $mtch)) { |
| 19 | $text = $mtch[0]; |
| 20 | $more = '<span class="xml-more">[' . esc_html__('more', 'wp-all-export') . ']</span>'; |
| 21 | } |
| 22 | $text = esc_html($text); |
| 23 | // $text = preg_replace('%(?<!\s)\b(?!\s|\W[\w\s])|\w{20}%', '$0​', $text); // put explicit breaks for xml content to wrap |
| 24 | $is_cdata = ( strpos($text, 'CDATABEGIN') !== false ); |
| 25 | $text = str_replace('CDATABEGIN', '<![CDATA[', $text); |
| 26 | $text = str_replace('CDATACLOSE', ']]>', $text); |
| 27 | $is_short = strlen($text) <= 40; |
| 28 | echo '<div class="xml-content textonly' . ($is_short ? ' short' : '') . ($is_cdata ? ' cdata' : '') . ($is_render_collapsed ? ' collapsed' : '') . '">' . esc_html($text) . wp_kses_post($more) . '</div>'; |
| 29 | } |