Transient not working for external data

You write “if ( false === $external_figures )” but forgot write “else” with echo $external_figures Example: if ( false !== $external_figures ) { echo $external_figures; }else{ ob_start(); $production_url=”my-url”; …

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 ); }

Using transients to store form notifications

I would use user ID then user IP if not logged in, you can store the result like the following: /* your form validation/submission logiccode goes here */ $max_execution_tim = @ini_get(‘max_execution_time’); $submission_result = array(‘message’ => ‘Worked!’, ‘status’ => ‘success’); // You can use this function: // https://stackoverflow.com/a/6718472/1321398 $user_ip = GetIP(); $transient_name = is_user_logged_in() ? “form_submission_user-” … Read more

Set user status to absent on WordPress

You are going to have to add some Javascript to the page that will check for a timeout. Remember that PHP is executed on the server, and the servers sends HTML to the visitor’s browser. One the page is generated, the server doesn’t do anything until the next request comes from that visitor (or anyone … Read more

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

wp_trash_post() duplicates post to trash

As the function name suggests, wp_trash_post() only trashes a post. If you want to have a post completely deleted then you can use wp_delete_post( int $postid, bool $force_delete = false ) instead. https://developer.wordpress.org/reference/functions/wp_delete_post/ When the post and page is permanently deleted, everything that is tied to it is deleted also. This includes comments, post meta … Read more

Check the stored / cached WP_Query with transients on post change

Use the save_post hook to check if a post that is being saved is a portfolio page and reset the transient. add_action( ‘save_post’, ‘reset_portfolio_transient’, 10,3 ); function reset_portfolio_transient( $post_id, $post, $update ) { // Only set for portfolio post_type if ( ‘portfolio’ !== get_post_type($post) ) { return; } // delete old tranisent delete_transient( ‘randomizeProfiles’ ); … Read more

Need help in setting up a transient using API Key and if possible updating it in the ACF field

As discussed in the comments, here’s an attempt to fetch both pda and upa in a single request: /** * Make a Moz v1 URL Metrics request for a given domain * * @see https://moz.com/help/links-api/v1-archive/v1-url-metrics * @see https://moz.com/help/links-api/v1-archive/response-fields * @param $domain */ function moz_v1_links_api_request($domain) { if ( !$domain ) { return NULL; } $cache_key = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)