Skip to content

Commit

Permalink
License transient is never used (fix #19) (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
dac514 authored and Ned Zimmerman committed Jul 10, 2017
1 parent fb9e8ad commit 61b80af
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,7 @@ function pressbooks_copyright_license() {
$post_meta = get_post_meta( $id );
$link = get_permalink( $id );
$html = $license = $copyright_holder = '';
$transient = get_transient( "license-inf-$id" );
$updated = [ $license, $copyright_holder, $title ];
$changed = false;
$transient_id = "license-inf-$id";
$lang = ( ! empty( $book_meta['pb_language'] ) ) ? $book_meta['pb_language'] : 'en' ;

// Copyright holder, set in order of precedence
Expand All @@ -303,9 +301,12 @@ function pressbooks_copyright_license() {
$license = $book_meta['pb_book_license'];
}

// check if the user has changed anything
// check if the user has changed anything
$transient = get_transient( $transient_id );
$changed = false;
if ( is_array( $transient ) ) {
foreach ( $updated as $val ) {
$updated = [ $license, $copyright_holder, $title ];
foreach ( $updated as $key => $val ) {
if ( ! array_key_exists( $val, $transient ) ) {
$changed = true;
}
Expand Down Expand Up @@ -338,7 +339,7 @@ function pressbooks_copyright_license() {
$title => '',
];
// expires in 24 hours
set_transient( "license-inf-$id", $value, 86400 );
set_transient( $transient_id, $value, DAY_IN_SECONDS );
} else {
$html = $transient[ $license ] ;
}
Expand Down

0 comments on commit 61b80af

Please sign in to comment.