If you want to save the generated css to a file, take a look at file_get_contents()
and file_put_contents()
native PHP functions. https://www.php.net/manual/en/function.file-put-contents.php
You can also find some Q&A’s on the topic both in SO and WPSE, e.g. https://stackoverflow.com/questions/25559913/write-from-wordpress-plugin-to-text-file-with-php
You can then enqueue the created css file inside wp_enqueue_scripts like any other css file. You might want to wrap the enqueue inside a file_exists
conditional check to avoid potential errors.
Another option could be that you enqueue the dynamic css in wp_enqueue_scripts, but wrapped in a suitable if statement.
Related Posts:
- Google Maps API throws “Uncaught ReferenceError: google is not defined” only when using AJAX
- Initialize TinyMCE editor / visual editor after AJAX insert
- Using Ajax with a Class file
- WP-AJAX vs WP REST API: What to use for requests to the website from outside?
- SSL breaks customizer: page isn’t returned from ajax
- Stop admin-ajax?
- How to verify nonce from Bulk/Quick Edit in save_post?
- How to implement AJAX post navigation into WordPress?
- wp_ajax_[service] returning 0
- Trying to load content of a post via AJAX
- Insert Post using Ajax
- How can I automatically login using a URL?
- Ajax function returns -1
- Problems with creating sortable sections in customizer
- Is it OK to use a system cron to trigger a function hooked into the AJAX API
- Filter WP user acf field by ajax
- Ajax Request not coming back to class
- How to make ajax content indexable by search engines?
- Ajax requests with different WordPress Address and Site Address setup
- Conditional action hooks
- AJAX requests broken due to HTTPS for wp-admin
- query vars in url work but not in ajax call
- is_home doesn’t affect content
- Is it safe to use $_POST directly in my plugin instead of using admin-ajax.php to receive data from ajax?
- How to make get_theme_mod work with AJAX in the customizer preview
- How to declare a JS variable in an AJAX call
- is_page() conditional not working inside an AJAX function
- jQuery Ajax passing empty parameters to my function?
- Fatal error: Call to undefined function get_post() with ajax
- Convert this relative path to absolute
- how to send Ajax request in wordpress backend
- How to solve “Updating failed” with 403 Error when trying to save a Site or Post in Gutenberg?
- problem with WordPress ajax
- How to set post_id to 0 when you upload image via Add media button. (async-upload.php)
- Ajax simple experiment
- How to make tabulator ajax call in wordpress?
- How would you update a frontend form with AJAX
- Updating User Meta with Array on Click of Button AJAX
- Why is on status span no search results?
- eventON plugin AJAX call triggers website crash
- Radio buttons live refresh in the customizer
- Admin ajax add tag callback
- Stop auto load wp-admin admin-ajax.php
- wp_enqueue_script() doesn’t work with AJAX
- Dynamically add more fields/remove last field in a form
- Ajax Request for both logged and non logged users
- AJAX call inside plugin class not triggering
- Force redirect single.php to index
- Any plugin or Script to integrate ajax selection module into WordPress page
- WordPress Heartbeat API cannot parse data
- Cache plugins and ajax nonce verification
- Ajax function on #publish only saves as draft – how to make it publish?
- AJAX call broken after actualization
- WP_Ajax Hook doesn’t execute this PHP code
- How to include php-generated javascript?
- Serve a different theme based on window size
- Ajax function not returning any results
- post values to custom post type which has advanced custom fields
- wp_mail doesn’t work when logged in?
- How to continuously send feedback via AJAX responses to my client?
- get current taxonomy post with ajax
- WordPress Ajax Filter
- Need help with Access-Control-Allow-Origin
- Send email via ajax
- wp_ajax handler with multiple class instances
- admin-ajax.php (aborted) error when using jQuery.get
- Storing temporary data for a custom post type
- I get a 0 after the result of my ajax requests
- Load page HTML content through AJAX
- Not getting an ajax readystatechange on my page
- Display full WordPress post under search form using AJAX
- Ajax callback not work
- WordPress Select Option Load Custom Fields
- Add ajax to plugin in admin area
- Search live Ajax
- Ajax login fails: script sets cookies, but is_user_logged_in() returns false
- Using wp_send_json_success instead of $result[‘message’], die, etc
- do_action won’t work in ajax callback
- 400 Bad request while submitting form using AJAX
- AJAX POST Value not being returned – WordPress – AutoTrader API
- Its possible to ajax update the content of the admin custom post type list
- WordPress custom ajax login not working on mobile browsers
- Ajax call on class returns old data
- how to enable ajax on submitting of contact form 7?
- delete post meta data in array WordPress
- How to trigger lost password email using REST API?
- Display post thumbnail after clicking on post id with AJAX
- Using AJAX on Contact-form the WordPress way
- Error while submitting form using AJAX and php
- How to fetch meta_value and meta_key in matrix after ajax request by post_id
- Manually cache a special, non-WP-but-using-WP page (e.g. Ajax results) with W3TC
- Is it a good idea to init ajax functions only while ‘DOING_AJAX’
- register_setting and AJAX?
- ajax response is 0 instead of ‘script’ [duplicate]
- A refreshless WordPress website
- Dynamic dependent select box getting null value
- get_template_part() does not render after the ajax request
- $wpdb Ajax not redirecting to main page
- wordpress ajax bad request 400
- Custom WP rest api endpoint only working on non https?