backward.php
4 weeks ago
get_taxonomies_by_object_type.php
4 weeks ago
pmxe_filter.php
4 weeks ago
pmxe_functions.php
4 weeks ago
pmxe_prepare_price.php
4 weeks ago
pmxe_render_xml_attributes.php
4 weeks ago
pmxe_render_xml_element.php
4 weeks ago
pmxe_render_xml_text.php
4 weeks ago
str_getcsv.php
4 weeks ago
wp_all_export_check_children_assign.php
4 weeks ago
wp_all_export_clear_xss.php
4 weeks ago
wp_all_export_comments_clauses.php
4 weeks ago
wp_all_export_generate_export_file.php
4 weeks ago
wp_all_export_get_cpt_name.php
4 weeks ago
wp_all_export_get_export_format.php
4 weeks ago
wp_all_export_is_compatible.php
4 weeks ago
wp_all_export_parse_field_name.php
4 weeks ago
wp_all_export_posts_join.php
4 weeks ago
wp_all_export_posts_where.php
4 weeks ago
wp_all_export_pre_user_query.php
4 weeks ago
wp_all_export_prepare_template_csv.php
4 weeks ago
wp_all_export_prepare_template_xml.php
4 weeks ago
wp_all_export_rand_char.php
4 weeks ago
wp_all_export_remove_colons.php
4 weeks ago
wp_all_export_remove_source.php
4 weeks ago
wp_all_export_reverse_rules_html.php
4 weeks ago
wp_all_export_rmdir.php
4 weeks ago
wp_all_export_secure_file.php
4 weeks ago
wp_all_export_terms_clauses.php
4 weeks ago
wp_all_export_url_title.php
4 weeks ago
wp_all_export_write_article.php
4 weeks ago
wp_redirect_or_javascript.php
4 weeks ago
pmxe_render_xml_element.php
57 lines
| 1 | <?php |
| 2 | |
| 3 | defined( 'ABSPATH' ) || exit; |
| 4 | |
| 5 | function pmxe_render_xml_element($el, $shorten = false, $path = '/', $ind = 1, $lvl = 0) |
| 6 | { |
| 7 | $path .= $el->nodeName; |
| 8 | $alternativePath = $path; |
| 9 | if ( ! $el->parentNode instanceof DOMDocument and $ind > 0) { |
| 10 | $path .= "[$ind]"; |
| 11 | } |
| 12 | |
| 13 | echo '<div class="xml-element lvl-' . intval($lvl) . ' lvl-mod4-' . (intval($lvl) % 4) . '" title="' . esc_attr($path) . '">'; |
| 14 | |
| 15 | if ($el->hasChildNodes()) { |
| 16 | $is_render_collapsed = $ind > 1; |
| 17 | if ($el->childNodes->length > 1 or ! $el->childNodes->item(0) instanceof DOMText or strlen(trim($el->childNodes->item(0)->wholeText)) > 40) { |
| 18 | echo '<div class="xml-expander">' . ($is_render_collapsed ? '+' : '-') . '</div>'; |
| 19 | } |
| 20 | echo '<div class="xml-tag opening"><<span class="xml-tag-name">' . esc_html($el->nodeName) . '</span>'; pmxe_render_xml_attributes($el, $path . '/'); echo '></div>'; |
| 21 | if (1 == $el->childNodes->length and $el->childNodes->item(0) instanceof DOMText) { |
| 22 | pmxe_render_xml_text(trim($el->childNodes->item(0)->wholeText), $shorten, $is_render_collapsed); |
| 23 | } else { |
| 24 | echo '<div class="xml-content' . ($is_render_collapsed ? ' collapsed' : '') . '">'; |
| 25 | $indexes = array(); |
| 26 | foreach ($el->childNodes as $eli => $child) { |
| 27 | if ($child instanceof DOMElement) { |
| 28 | empty($indexes[$child->nodeName]) and $indexes[$child->nodeName] = 0; $indexes[$child->nodeName]++; |
| 29 | pmxe_render_xml_element($child, $shorten, $path . '/', $indexes[$child->nodeName], $lvl + 1); |
| 30 | } elseif ($child instanceof DOMCdataSection) { |
| 31 | pmxe_render_xml_text(trim($child->wholeText), $shorten, false, true); |
| 32 | } elseif ($child instanceof DOMText) { |
| 33 | if ( $el->childNodes->item($eli - 1) and ($el->childNodes->item($eli - 1) instanceof DOMCdataSection) ){ |
| 34 | |
| 35 | } |
| 36 | elseif( $el->childNodes->item($eli + 1) and ($el->childNodes->item($eli + 1) instanceof DOMCdataSection) ){ |
| 37 | |
| 38 | } |
| 39 | else{ |
| 40 | pmxe_render_xml_text(trim($child->wholeText), $shorten); |
| 41 | } |
| 42 | } elseif ($child instanceof DOMComment) { |
| 43 | if (preg_match('%\[pmxi_more:(\d+)\]%', $child->nodeValue, $mtch)) { |
| 44 | $no = intval($mtch[1]); |
| 45 | /* translators: 1: count, 2: singular/plural noun */ |
| 46 | 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>'; |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | echo '</div>'; |
| 51 | } |
| 52 | echo '<div class="xml-tag closing"></<span class="xml-tag-name">' . esc_html($el->nodeName) . '</span>></div>'; |
| 53 | } else { |
| 54 | echo '<div class="xml-tag opening empty"><<span class="xml-tag-name">' . esc_html($el->nodeName) . '</span>'; pmxe_render_xml_attributes($el); echo '/></div>'; |
| 55 | } |
| 56 | echo '</div>'; |
| 57 | } |