Why can’t I save encrypted data in a transient?

So the answer was to use base64_encode and base64_decode. So basically doing something like this to set the transient: $json_contact_info = json_encode( $contact_info ); $transient_data = encrypt_text( $json_contact_info ); $transient_array = base64_encode( $transient_data ); $transient_set = set_transient( $transient_name, $transient_array, 60 * 60 * 24 * 7 ); And then to get the transient: $decrypted_transient_data = … Read more

Ajax call to transients

Without object caching plugins transients are stored using options API and, if set to expire, they have auto-load disabled. Meaning: First request to transient needs to fetch it from database. Subsequent requests will get data from memory. However note that “memory” here is memory space of single specific page load. It’s not shared and not … Read more

Set transient name

It looks you’re using different transient names in get_ and set_. Try the following: $transient_key = ‘apidata_json_cache’; $expiration = 2*60; // 2 Minutes if( false === ( $feed = get_transient( $transient_key ) ) ) { echo ‘<!–Fresh data–>’; /*data extraction process here, which is than stored in $feed*/ set_transient( $transient_key, $feed, $expiration ); }

Button to clear transients

I have managed to do the following. I made a clear cache button: function advanza_direct_plugin_delete_transients() { delete_transient( ‘advanza_direct_terms_of_service’ ); delete_transient( ‘advanza_direct_privacy_policy’ ); // at the end redirect to target page exit( wp_redirect( admin_url( ‘admin.php?page=advanza-direct-plugin-settings’ ) ) ); } add_action( ‘admin_post_advanza_direct_plugin_delete_transients’, ‘advanza_direct_plugin_delete_transients’ ); I put this where I have my admin logic: <form action=”<?php echo admin_url(‘admin-post.php’); … Read more

Unique Transients user id for Non-Logged In users

Use sessions when they are appropriate. Our fellow mod @EAMann has written a useful session class for exactly these cases. There is a plugin described here that offers a different API. Just make sure to start the session only when you really need one. Google and other crawler don’t accept cookies, so you would end … Read more

Clear Transients

Unfortunately, expired entries will only be deleted if you attempt to access the transient again. If you don’t access the transient then, even though it’s expired, WordPress will not remove it. This is a known “issue” and is due to be corrected at some point in the WordPress core code. -Copied from: Artiss Transient Cleaner … Read more

Set transient with get posts error

If what you want is for this function to run once a day and loop through all matching posts (removing img tags), I think this should do the trick: <?php function remove_images_form_past_posts() { if ( get_transient(‘images_removed_from_past’) ) return; $args = array( ‘post_type’ => ‘post’, ‘year’ => 2013, ‘monthnum’ => 1, ‘day’ =>28, ‘post_status’ =>’publish’, ‘category’ … Read more