IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
596 | 596 | } |
597 | 597 | |
598 | 598 | /** |
| 599 | * Determines if a transient is valid. |
| 600 | * |
| 601 | * If the transient does not exist, does not have a value, or has expired, |
| 602 | * then the return value will be false. |
| 603 | * |
| 604 | * @since 4.7.0 |
| 605 | * |
| 606 | * @param string $transient Transient name. Expected to not be SQL-escaped. |
| 607 | * |
| 608 | * @return bool |
| 609 | */ |
| 610 | function valid_transient( $transient ) { |
| 611 | |
| 612 | $transient_timeout = '_transient_timeout_' . $transient; |
| 613 | $timeout = get_option( $transient_timeout ); |
| 614 | |
| 615 | // No transient found. |
| 616 | if ( false === $timeout ) { |
| 617 | return false; |
| 618 | } |
| 619 | // Expired transient detected. |
| 620 | elseif ( false !== $timeout && $timeout < time() ) { |
| 621 | delete_option( '_transient_' . $transient ); |
| 622 | delete_option( $transient_timeout ); |
| 623 | |
| 624 | return false; |
| 625 | } |
| 626 | |
| 627 | // Transient is valid. |
| 628 | return true; |
| 629 | } |
| 630 | |
| 631 | /** |
599 | 632 | * Get the value of a transient. |
600 | 633 | * |
601 | 634 | * If the transient does not exist, does not have a value, or has expired, |
… |
… |
|
635 | 668 | if ( ! wp_installing() ) { |
636 | 669 | // If option is not in alloptions, it is not autoloaded and thus has a timeout |
637 | 670 | $alloptions = wp_load_alloptions(); |
638 | | if ( !isset( $alloptions[$transient_option] ) ) { |
639 | | $transient_timeout = '_transient_timeout_' . $transient; |
640 | | $timeout = get_option( $transient_timeout ); |
641 | | if ( false !== $timeout && $timeout < time() ) { |
642 | | delete_option( $transient_option ); |
643 | | delete_option( $transient_timeout ); |
644 | | $value = false; |
645 | | } |
646 | | } |
647 | | } |
| 671 | if ( !isset( $alloptions[$transient_option] ) && ! valid_transient( $transient ) ) { |
| 672 | $value = false; |
| 673 | } |
| 674 | } |
648 | 675 | |
649 | 676 | if ( ! isset( $value ) ) |
650 | 677 | $value = get_option( $transient_option ); |
… |
… |
|
1527 | 1554 | } |
1528 | 1555 | |
1529 | 1556 | /** |
| 1557 | * Determines if a site transient is valid. |
| 1558 | * |
| 1559 | * If the transient does not exist, does not have a value, or has expired, |
| 1560 | * then the return value will be false. |
| 1561 | * |
| 1562 | * @since 4.7.0 |
| 1563 | * |
| 1564 | * @param string $transient Transient name. Expected to not be SQL-escaped. |
| 1565 | * |
| 1566 | * @return bool |
| 1567 | */ |
| 1568 | function valid_site_transient( $transient ) { |
| 1569 | |
| 1570 | $transient_timeout = '_site_transient_timeout_' . $transient; |
| 1571 | $timeout = get_site_option( $transient_timeout ); |
| 1572 | |
| 1573 | // No transient found. |
| 1574 | if ( false === $timeout ) { |
| 1575 | return false; |
| 1576 | } |
| 1577 | // Expired transient detected. |
| 1578 | elseif ( false !== $timeout && $timeout < time() ) { |
| 1579 | delete_site_option( '_site_transient_' . $transient ); |
| 1580 | delete_site_option( $transient_timeout ); |
| 1581 | |
| 1582 | return false; |
| 1583 | } |
| 1584 | |
| 1585 | // Transient is valid. |
| 1586 | return true; |
| 1587 | } |
| 1588 | |
| 1589 | /** |
1530 | 1590 | * Get the value of a site transient. |
1531 | 1591 | * |
1532 | 1592 | * If the transient does not exist, does not have a value, or has expired, |
… |
… |
|
1567 | 1627 | } else { |
1568 | 1628 | // Core transients that do not have a timeout. Listed here so querying timeouts can be avoided. |
1569 | 1629 | $no_timeout = array('update_core', 'update_plugins', 'update_themes'); |
1570 | | $transient_option = '_site_transient_' . $transient; |
1571 | | if ( ! in_array( $transient, $no_timeout ) ) { |
1572 | | $transient_timeout = '_site_transient_timeout_' . $transient; |
1573 | | $timeout = get_site_option( $transient_timeout ); |
1574 | | if ( false !== $timeout && $timeout < time() ) { |
1575 | | delete_site_option( $transient_option ); |
1576 | | delete_site_option( $transient_timeout ); |
1577 | | $value = false; |
1578 | | } |
1579 | | } |
| 1630 | if ( ! in_array( $transient, $no_timeout ) && ! valid_site_transient( $transient ) ) { |
| 1631 | $value = false; |
| 1632 | } |
1580 | 1633 | |
1581 | 1634 | if ( ! isset( $value ) ) |
1582 | | $value = get_site_option( $transient_option ); |
| 1635 | $value = get_site_option( '_site_transient_' . $transient ); |
1583 | 1636 | } |
1584 | 1637 | |
1585 | 1638 | /** |