twig = new Environment($loader); $this->twig->addFilter(new Filter('svg', [$this, 'svgTag'])); $this->twig->addFilter(new Filter('prop', [$this, 'alpineProp'])); $this->twig->addFunction(new Func('cprop', function ($aprop, $modifier) { return $this->alpineProp($aprop, $modifier); })); } public function init() { add_action('wp_enqueue_scripts', [ $this, 'enqueue' ]); add_action('wp_ajax_nopriv_stepper_submit', [ $this, 'onSubmit' ]); add_shortcode('stepper', [ $this, 'handle' ]); } public function enqueue() { wp_enqueue_script('stepper-js', $this->url.'assets/public/app.js'); wp_enqueue_style('stepper-css', $this->url.'assets/public/app.css'); } public function handle() { echo $this->twig->render('stepper.twig.htm', [ 'sprite' => $this->url.'assets/public/sprite.svg' ]); } public function svgTag($e, $class = '') { return ''; } public function alpineProp($prop, $modifier) { $v = '$event.target.value'; $bv = '($event.target || $event.originalTarget).value'; return ':value="units.'.$modifier.'.to('.$prop.')" @focus="$event.target.value = '.$prop.'" @blur="console.log($event); '.$bv.' = units.'.$modifier.'.to('.$prop.');" @change="console.log(\'change\'); '.$prop.' = units.'.$modifier.'.from('.$v.');" onblur="console.log(\'RRRR\');"'; } public function onSubmit() { json_decode(file_get_contents('php://input')); wp_mail('info@jonas-ruettgers.de', 'Neue Finanzierungs-Anfrage', $this->twig->render('mail.twig.htm', json_decode(file_get_contents('php://input'), true)), [ 'From' => 'philipp@aweos.de' ]); die(); } }