'Lock active, skipping execution.' ] )) ; } wp_send_json_success( [ 'message' => 'Lock active, skipping execution.' ] ); } // Set a temporary lock to prevent duplicate requests set_transient( 'oc_theme_fetch_lock' , true , 5 * MINUTE_IN_SECONDS ); // Fetch themes and process them $theme_data = onecom_fetch_themes( 1 , true ); $oci_theme_fetch = $theme_data->collection; merge_classic_wp_themes( $oci_theme_fetch ); // Log execution for debugging error_log( 'oc_prefetch_themes executed' ); // Remove the lock after execution delete_transient( 'oc_theme_fetch_lock' ); if (defined('PHPUNIT_RUNNING') && PHPUNIT_RUNNING) { return(json_encode([ 'message' => 'Theme fetch completed.' ])) ; } // Send JSON response indicating success wp_send_json_success( [ 'message' => 'Theme fetch completed.' ] ); } }