mainwp-child/class/class-mainwp-tools.php
2020-03-26 14:05:04 +00:00

19 lines
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;
}
}