From 370fd7f344aee591fd2bf79c26d0ef1fa093971e Mon Sep 17 00:00:00 2001 From: GaryJones Date: Mon, 31 Dec 2012 03:00:17 +0000 Subject: [PATCH 1/2] Refactor creation of transient key name. Fixes https://github.com/bradyvercher/wp-blazer-six-gist-oembed/issues/5 --- class-blazer-six-gist-oembed.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/class-blazer-six-gist-oembed.php b/class-blazer-six-gist-oembed.php index b8c9342..62a6fc4 100644 --- a/class-blazer-six-gist-oembed.php +++ b/class-blazer-six-gist-oembed.php @@ -192,7 +192,7 @@ public function shortcode( $attr ) { // Short-circuit the shortcode output and just delete the transient. // This is set to true when posts are updated. if ( $this->delete_shortcode_transients ) { - delete_transient( 'gist_html_' . $shortcode_hash ); + delete_transient( $this->transient_key( $shortcode_hash ) ); return; } @@ -353,7 +353,7 @@ public function get_gist_html( $url, $args, $fetch = false ) { $shortcode_hash = $this->shortcode_hash( 'gist', $args ); $raw_key = '_gist_raw_' . md5( $url ); - $transient_key = 'gist_html_' . $shortcode_hash; + $transient_key = $this->transient_key( $shortcode_hash ); $html = get_transient( $transient_key ); @@ -581,4 +581,15 @@ protected function shortcode_hash( $tag, $args ) { ksort( $args ); return md5( $tag . '_' . serialize( $args ) ); } + + /** + * Get the transient key. + * + * @param string $hash The identifier part of the key. + * + * @return string + */ + protected function transient_key( $identifier ) { + return 'gist_html_' . $identifier; + } } From 65e9de150ed366b8177be2282d0d288c8ce2753b Mon Sep 17 00:00:00 2001 From: GaryJones Date: Mon, 31 Dec 2012 03:03:38 +0000 Subject: [PATCH 2/2] Fix documentation typo for transient key name method. --- class-blazer-six-gist-oembed.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/class-blazer-six-gist-oembed.php b/class-blazer-six-gist-oembed.php index 62a6fc4..113ba39 100644 --- a/class-blazer-six-gist-oembed.php +++ b/class-blazer-six-gist-oembed.php @@ -585,7 +585,9 @@ protected function shortcode_hash( $tag, $args ) { /** * Get the transient key. * - * @param string $hash The identifier part of the key. + * @since 1.1.0 + * + * @param string $identifier The identifier part of the key. * * @return string */