WordPress Rest API custom endpoint optional param

Is it possible to use register_rest_route() with optional parameters in url? Let’s say route is registered this way: register_rest_route( ‘api’, ‘/animals/(?P<id>\d+)’, [ ‘methods’ => WP_REST_Server::READABLE, ‘callback’ => ‘get_animals’, ‘args’ => [ ‘id’ ], ] ); It’s now possible to perform api call on url like /wp-json/api/animals/15, but is there a way to declare the param … Read more

How can I use WordPress functions in my stylesheet?

I have my style.php file looking like this. <?php header(‘Content-Type: text/css’);?> #div{ background:<?php echo get_option(‘bgcolor’);?>; } This does not work, but when I do this it works. <?php header(‘Content-Type: text/css’);?> #div{ background: <?php echo ‘blue’;?>; } What would be the problem? This is the mainfile.php <?php function test(){ global get_option(‘bgcolor’);?> <input type=”text” id=”bgcolor” name=”post_popup_settings[bgcolor]” value=”<?php … Read more