mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-09-01 03:58:07 +08:00
19 lines
No EOL
433 B
PHP
19 lines
No EOL
433 B
PHP
<?php
|
|
|
|
class MainWP_Tools {
|
|
public static function execute_snippet( $code ) {
|
|
ob_start();
|
|
$result = eval( $code );
|
|
$output = ob_get_contents();
|
|
ob_end_clean();
|
|
$return = array();
|
|
if ( ( false === $result ) && ( $error = error_get_last() ) ) {
|
|
$return['status'] = 'FAIL';
|
|
$return['result'] = $error['message'];
|
|
} else {
|
|
$return['status'] = 'SUCCESS';
|
|
$return['result'] = $output;
|
|
}
|
|
return $return;
|
|
}
|
|
} |