@ 2024-04-29T13:48:46Z <?php
class WP_Term {
public $foo = 'foo';
public $data; // Change the visibility to protected or private and the script will throw an error.
}
$_POST['action'] = 'action';
function wp_parse_args( $args, $defaults = array() ) {
if ( is_object( $args ) ) {
$parsed_args = get_object_vars( $args );
} elseif ( is_array( $args ) ) {
$parsed_args =& $args;
} else {
wp_parse_str( $args, $parsed_args );
}
if ( is_array( $defaults ) && $defaults ) {
return array_merge( $defaults, $parsed_args );
}
return $parsed_args;
}
class WP_Ajax_Response {
public $responses = array();
public function add( $args = '' ) {
$defaults = array(
'what' => 'object',
'action' => false,
'id' => '0',
'old_id' => false,
'position' => 1,
'data' => '',
'supplemental' => array(),
);
$parsed_args = wp_parse_args( $args, $defaults );
$position = preg_replace( '/[^a-z0-9:_-]/i', '', $parsed_args['position'] );
$id = $parsed_args['id'];
$what = $parsed_args['what'];
$action = $parsed_args['action'];
$old_id = $parsed_args['old_id'];
$data = $parsed_args['data'];
$response = "<response_data><![CDATA[$data]]></response_data>";
$s = '';
if ( is_array( $parsed_args['supplemental'] ) ) {
foreach ( $parsed_args['supplemental'] as $k => $v ) {
$s .= "<$k><![CDATA[$v]]></$k>";
}
$s = "<supplemental>$s</supplemental>";
}
if ( false === $action ) {
$action = $_POST['action'];
}
$x = '';
$x .= "<response action='{$action}_$id'>"; // 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 .= '</response>';
$this->responses[] = $x;
return $x;
}
}
$response = new WP_Ajax_Response();
$tag = new WP_Term();
$response->add(
array(
'what' => 'term',
'supplemental' => (array) $tag,
)
);
libxml_use_internal_errors( true );
$xml = simplexml_load_string( $response->responses[0], 'SimpleXMLElement' );
if ( $xml === false ) {
echo 'Failed loading XML: ';
foreach ( libxml_get_errors() as $error ) {
// Display each error
echo '<br>', $error->message . "\n";
}
// Clear the error buffer to free memory
libxml_clear_errors();
} else {
// Your XML is correctly parsed, proceed with your logic
echo 'XML loaded successfully.' . "\n";
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.4.12 0.013 0.008 22.48 8.4.11 0.012 0.007 21.16 8.4.10 0.013 0.008 18.43 8.4.9 0.014 0.008 20.89 8.4.8 0.006 0.005 19.11 8.4.7 0.009 0.008 18.20 8.4.6 0.010 0.004 19.02 8.4.5 0.012 0.010 20.10 8.4.4 0.007 0.013 19.02 8.4.3 0.010 0.010 19.14 8.4.2 0.012 0.012 20.70 8.4.1 0.000 0.009 20.03 8.3.25 0.013 0.005 19.22 8.3.24 0.010 0.006 16.87 8.3.23 0.011 0.009 17.56 8.3.22 0.010 0.006 19.13 8.3.21 0.010 0.009 16.94 8.3.20 0.011 0.008 16.93 8.3.19 0.008 0.002 17.41 8.3.18 0.013 0.007 16.95 8.3.17 0.011 0.007 20.88 8.3.16 0.008 0.000 17.38 8.3.15 0.011 0.011 17.51 8.3.14 0.008 0.000 18.82 8.3.13 0.000 0.009 17.06 8.3.12 0.003 0.007 19.41 8.3.11 0.003 0.006 20.94 8.3.10 0.000 0.009 24.06 8.3.9 0.004 0.004 26.77 8.3.8 0.013 0.000 17.13 8.3.7 0.015 0.006 18.81 8.3.6 0.017 0.007 25.92 8.3.5 0.011 0.006 25.92 8.3.4 0.008 0.008 25.92 8.2.29 0.010 0.010 17.17 8.2.28 0.011 0.008 18.95 8.2.27 0.006 0.003 17.67 8.2.26 0.007 0.011 16.73 8.2.25 0.006 0.003 18.81 8.2.24 0.016 0.003 17.41 8.2.23 0.006 0.003 22.58 8.2.22 0.007 0.003 37.54 8.2.21 0.004 0.004 26.77 8.2.20 0.003 0.007 19.04 8.2.19 0.010 0.007 16.72 8.2.18 0.018 0.007 25.92 8.2.17 0.017 0.003 25.92 8.1.33 0.009 0.007 16.83 8.1.32 0.013 0.006 16.50 8.1.31 0.004 0.004 16.95 8.1.30 0.006 0.003 20.35 8.1.29 0.003 0.007 18.88 8.1.28 0.006 0.013 25.92
preferences:dark mode live preview ace vim emacs key bindings
48.69 ms | 403 KiB | 5 Q