Skip to content
Browse files

Add webcomic() conditional template tag.

  • Loading branch information...
1 parent 4b585e7 commit 9e6e1679141edbee7a3aee03cb2b0e0b30be6a66 Michael Sisk committed Sep 19, 2012
Showing with 41 additions and 0 deletions.
  1. +41 −0 -/php/tags.php
View
41 -/php/tags.php
@@ -141,6 +141,24 @@ public static function sort_webcomic_collections_updated( $a, $b ) {
// Conditional Tags
///
+ /** Is a compatible version of Webcomic installed?
+ *
+ * This is mostly useful for constructing Webcomic-ready themes to
+ * verify that a compatible version of Webcomic is installed, but we
+ * can also check for an arbitrary version by passing it via the
+ * `$version` parameter.
+ *
+ * @param string $version Minimum version to check for. Defaults to the active themes version.
+ * @return boolean
+ * @uses Webcomic::$version
+ * @uses Webcomic::$theme_version
+ */
+ public static function webcomic( $version = '' ) {
+ $version = $version ? $version : self::$theme_version;
+
+ return ( $version and version_compare( self::$version, $version, '>=' ) );
+ }
+
/** Is the query for any single webcomic?
*
* Specific collection checks should be done using the is_singular()
@@ -2725,6 +2743,29 @@ function get_webcomic_collections( $config = false ) {
// Conditional Tags
///
+if ( !function_exists( 'webcomic' ) ) {
+ /** Is a compatible version of Webcomic installed?
+ *
+ * <code>
+ * if ( webcomic() ) {
+ * // the current theme is compatible with this version of Webcomic
+ * }
+ *
+ * if ( webcomic( 5 ) ) {
+ * // Webcomic 5 (or greater) is installed
+ * }
+ * </code>
+ *
+ * @package Webcomic
+ * @param string $version Minimum version to check for. Defaults to the active themes version.
+ * @return boolean
+ * @uses WebcomicTag::webcomic()
+ */
+ function webcomic( $version = '' ) {
+ return WebcomicTag::webcomic( $version );
+ }
+}
+
if ( !function_exists( 'is_webcomic' ) ) {
/** Is the query for any single webcomic?
*

0 comments on commit 9e6e167

Please sign in to comment.
Something went wrong with that request. Please try again.