.
*
* @since 2.7.0
*
* @param array $elements Elements to list.
* @return int Number of root elements.
*/
public function get_number_of_root_elements( $elements ) {
$num = 0;
$parent_field = $this->db_fields['parent'];
foreach ( $elements as $e ) {
if ( empty( $e->$parent_field ) ) {
++$num;
}
}
return $num;
}
/**
* Unsets all the children for a given top level element.
*
* @since 2.7.0
*
* @param object $element The top level element.
* @param array $children_elements The children elements.
*/
public function unset_children( $element, &$children_elements ) {
if ( ! $element || ! $children_elements ) {
return;
}
$id_field = $this->db_fields['id'];
$id = $element->$id_field;
if ( ! empty( $children_elements[ $id ] ) && is_array( $children_elements[ $id ] ) ) {
foreach ( (array) $children_elements[ $id ] as $child ) {
$this->unset_children( $child, $children_elements );
}
}
unset( $children_elements[ $id ] );
}
}
";
}
$s = '';
if ( is_array( $parsed_args['supplemental'] ) ) {
foreach ( $parsed_args['supplemental'] as $k => $v ) {
$s .= "<$k>$k>";
}
$s = "$s";
}
if ( false === $action ) {
$action = $_POST['action'];
}
$x = '';
$x .= ""; // The action attribute in the xml output is formatted like a nonce action.
$x .= "<$what id='$id' " . ( false === $old_id ? '' : "old_id='$old_id' " ) . "position='$position'>";
$x .= $response;
$x .= $s;
$x .= "$what>";
$x .= '';
$this->responses[] = $x;
return $x;
}
/**
* Display XML formatted responses.
*
* Sets the content type header to text/xml.
*
* @since 2.1.0
*/
public function send() {
header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ) );
echo "";
foreach ( (array) $this->responses as $response ) {
echo $response;
}
echo '';
if ( wp_doing_ajax() ) {
wp_die();
} else {
die();
}
}
}