/** * Return the number of Webcomic-recognized attachments. * * <code class="php"> * // display the number of Webcomic-recognized attachments found on the current post * echo webcomic_count(); * * if ( 1 < webcomic_count() ) { * // the current post has more than one Webcomic-recognized attachment * } * * if ( 3 === webcomic_count( 42 ) { * // the post with an ID of 42 has exactly three Webcomic-recognized attachments. * } * </code> * * @package Webcomic * @param mixed $the_post The post object or ID to retrieve the attachment count for. * @return integer * @uses WebcomicTag::webcomic_count() */ function webcomic_count($the_post = false) { return WebcomicTag::webcomic_count($the_post); }
/** * Handle webcomic_count shortcode. * * @param array $atts Shortcode attributes. * @param string $content Shortcode content. * @return string * @uses WebcomicTag::webcomic_count() */ public function webcomic_count($atts, $content) { extract(shortcode_atts(array('if' => '', 'the_post' => false), $atts)); if ($content) { $c = WebcomicTag::webcomic_count($the_post); $m = array(); $o = false; if (preg_match('/^\\s*(=|!=|lt|gt|lte|gte)\\s*(\\d+)\\s*$/', $if, $m)) { $m[2] = (int) $m[2]; if ('=' === $m[1] and $c === $m[2] or '!=' === $m[1] and $c !== $m[2] or 'lt' === $m[1] and $c < $m[2] or 'gt' === $m[1] and $c > $m[2] or 'lte' === $m[1] and $c <= $m[2] or 'gte' === $m[1] and $c >= $m[2]) { $o = true; } if ($o) { return do_shortcode($content); } } } else { return WebcomicTag::webcomic_count($the_post); } }