set_transient() public method

We do it this way (instead of set_site_transient) because of an issue where sitewide transients are always autoloaded https://core.trac.wordpress.org/ticket/22846
public set_transient ( string $transient, mixed $value, integer $expiration ) : boolean
$transient string Transient name. Expected to not be SQL-escaped. Must be 45 characters or fewer in length.
$value mixed Transient value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
$expiration integer Optional. Time until expiration in seconds. Default 0.
return boolean False if value was not set and true if value was set.
Esempio n. 1
0
 public function process_generate_math_page()
 {
     $salt = get_site_option('jetpack_protect_key') . get_site_option('admin_email');
     $ans = (int) $_POST['jetpack_protect_num'];
     $salted_ans = sha1($salt . $ans);
     $correct_ans = $_POST['jetpack_protect_answer'];
     if ($salted_ans != $correct_ans) {
         Jetpack_Protect_Math_Authenticate::generate_math_page(true);
     } else {
         $temp_pass = substr(sha1(rand(1, 100000000) . get_site_option('jetpack_protect_key')), 5, 25);
         Jetpack_Protect_Module::set_transient('jpp_math_pass_' . $temp_pass, 3, DAY_IN_SECONDS);
         setcookie('jpp_math_pass', $temp_pass, time() + DAY_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN, false);
         return true;
     }
 }