When it comes to WP, you can’t get values from the site by just loading a PHP file. You need to also load a lot of the WordPress code. The best way to do this is by using the admin-ajax script. I posted the basics of a solution for this about 2 years ago here https://wordpress.org/support/topic/best-way-to-create-a-css-file-dynamically?replies=22#post-4857705