| @@ -277,8 +277,24 @@ | ||
| 277 | 277 | // Kill session data |
| 278 | 278 | $this->userdata = array(); |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | + public function getUserdata($item) | |
| 282 | + { | |
| 283 | + if( function_exists('get_user_meta') && function_exists('get_current_user_id') && ($currentUserId = get_current_user_id()) ){ | |
| 284 | + $prefix = $this->getPrefix(); | |
| 285 | + $userMetaName = $prefix . $item; | |
| 286 | + return get_user_meta( $currentUserId, $userMetaName, true ); | |
| 287 | + } | |
| 288 | + else { | |
| 289 | + $my_key = $this->getPrefix() . $item; | |
| 290 | + if( isset($_SESSION[$my_key]) ){ | |
| 291 | + return $_SESSION[$my_key]; | |
| 292 | + } | |
| 293 | + return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item]; | |
| 294 | + } | |
| 295 | + } | |
| 296 | + | |
| 281 | 297 | // -------------------------------------------------------------------- |
| 282 | 298 | |
| 283 | 299 | /** |
| 284 | 300 | * Fetch all session data |
| @@ -327,46 +343,13 @@ | ||
| 327 | 343 | |
| 328 | 344 | return $ret; |
| 329 | 345 | } |
| 330 | 346 | |
| 331 | - public function getUserdata($item) | |
| 332 | - { | |
| 333 | - if( function_exists('get_user_meta') && function_exists('get_current_user_id') && ($currentUserId = get_current_user_id()) ){ | |
| 334 | - $prefix = $this->getPrefix(); | |
| 335 | - | |
| 336 | - if( ( false === strpos($prefix, '_wpadmin_')) && ('scheduleView' == substr($item, 0, strlen('scheduleView'))) ){ | |
| 337 | - if( function_exists('get_the_ID') ){ | |
| 338 | - $pageId = get_the_ID(); | |
| 339 | - $prefix .= '_' . $pageId . '_'; | |
| 340 | - } | |
| 341 | - } | |
| 342 | - | |
| 343 | - $userMetaName = $prefix . $item; | |
| 344 | -// echo "GET USER DATA '$item' AS META '$userMetaName'<br>"; | |
| 345 | - return get_user_meta( $currentUserId, $userMetaName, true ); | |
| 346 | - } | |
| 347 | - else { | |
| 348 | - $my_key = $this->getPrefix() . $item; | |
| 349 | - if( isset($_SESSION[$my_key]) ){ | |
| 350 | - return $_SESSION[$my_key]; | |
| 351 | - } | |
| 352 | - return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item]; | |
| 353 | - } | |
| 354 | - } | |
| 355 | - | |
| 356 | 347 | public function setUserdata( $key, $value, $append = FALSE ) |
| 357 | 348 | { |
| 358 | 349 | // use user meta |
| 359 | 350 | if( function_exists('update_user_meta') && function_exists('get_current_user_id') && ($currentUserId = get_current_user_id()) ){ |
| 360 | 351 | $prefix = $this->getPrefix(); |
| 361 | - | |
| 362 | - if( ( false === strpos($prefix, '_wpadmin_')) && ('scheduleView' == substr($key, 0, strlen('scheduleView'))) ){ | |
| 363 | - if( function_exists('get_the_ID') ){ | |
| 364 | - $pageId = get_the_ID(); | |
| 365 | - $prefix .= '_' . $pageId . '_'; | |
| 366 | - } | |
| 367 | - } | |
| 368 | - | |
| 369 | 352 | $userMetaName = $prefix . $key; |
| 370 | 353 | update_user_meta( $currentUserId, $userMetaName, $value ); |
| 371 | 354 | } |
| 372 | 355 | else { |
| @@ -422,16 +405,8 @@ | ||
| 422 | 405 | public function unsetUserdata( $key ) |
| 423 | 406 | { |
| 424 | 407 | if( function_exists('delete_user_meta') && function_exists('get_current_user_id') && ($currentUserId = get_current_user_id()) ){ |
| 425 | 408 | $prefix = $this->getPrefix(); |
| 426 | - | |
| 427 | - if( ( false === strpos($prefix, '_wpadmin_')) && ('scheduleView' == substr($key, 0, strlen('scheduleView'))) ){ | |
| 428 | - if( function_exists('get_the_ID') ){ | |
| 429 | - $pageId = get_the_ID(); | |
| 430 | - $prefix .= '_' . $pageId . '_'; | |
| 431 | - } | |
| 432 | - } | |
| 433 | - | |
| 434 | 409 | $userMetaName = $prefix . $key; |
| 435 | 410 | delete_user_meta( $currentUserId, $userMetaName ); |
| 436 | 411 | } |
| 437 | 412 | else { |
| @@ -478,13 +453,8 @@ | ||
| 478 | 453 | } |
| 479 | 454 | |
| 480 | 455 | function getFlashdata( $key ) |
| 481 | 456 | { |
| 482 | - static $cache = array(); | |
| 483 | - if( array_key_exists($key, $cache) ){ | |
| 484 | - return $cache[$key]; | |
| 485 | - } | |
| 486 | - | |
| 487 | 457 | if( function_exists('get_transient') && function_exists('get_current_user_id') && ($currentUserId = get_current_user_id()) ){ |
| 488 | 458 | $prefix = $this->getPrefix(); |
| 489 | 459 | $prefix = $prefix . $currentUserId . '_'; |
| 490 | 460 | $transientName = $prefix . $key; |
| @@ -489,16 +459,15 @@ | ||
| 489 | 459 | $prefix = $prefix . $currentUserId . '_'; |
| 490 | 460 | $transientName = $prefix . $key; |
| 491 | 461 | $ret = get_transient( $transientName ); |
| 492 | 462 | delete_transient( $transientName ); |
| 463 | + return $ret; | |
| 493 | 464 | } |
| 494 | 465 | else { |
| 495 | 466 | $flashdata_key = $this->flashdata_key.':old:'.$key; |
| 496 | - $ret = $this->getUserdata($flashdata_key); | |
| 467 | + return $this->getUserdata($flashdata_key); | |
| 497 | 468 | } |
| 498 | 469 | |
| 499 | - $cache[ $key ] = $ret; | |
| 500 | - return $ret; | |
| 501 | 470 | } |
| 502 | 471 | |
| 503 | 472 | // ------------------------------------------------------------------------ |
| 504 | 473 | |