示例#1
0
 /**
  * Render the widget.
  * 
  * @param array $args General widget arguments.
  * @param array $instance Specific instance arguments.
  * @uses WebcomicTag::get_webcomic_collection()
  * @uses WebcomicTag::relative_webcomic_link()
  */
 public function widget($args, $instance)
 {
     extract($args);
     extract($instance);
     if (!empty($image) and $image = wp_get_attachment_image($image, 'full')) {
         $link = preg_replace('/alt=".+?"/', 'alt="' . esc_attr($link) . '"', $image);
     }
     if ($output = WebcomicTag::purchase_webcomic_link('%link', $link, get_the_ID())) {
         echo $before_widget, empty($title) ? '' : $before_title . $title . $after_title, $output, $after_widget;
     }
 }
示例#2
0
文件: tags.php 项目: ecerta/webcomic
 /**
  * Render a purchase webcomic link.
  * 
  * <code class="php">
  * // render a link to purchase the current webcomic
  * purchase_webcomic_link();
  * 
  * // render a link to a random webcomic with a small preview
  * purchase_webcomic_link( '%link', '%thumbnail' );
  * 
  * // render a link to purchase the webcomic with an ID of 42
  * purchase_webcomic_link( '%link', 'Purchase prints of %title', 42 );
  * </code>
  * 
  * <code class="bbcode">
  * // render a link to purchase the current webcomic
  * [purchase_webcomic_link]
  * 
  * // render a link to a random webcomic with a small preview
  * [purchase_webcomic_link link="%thumbnail"]
  * 
  * // render a link to purchase the webcomic with an ID of 42
  * [purchase_webcomic_link the_post="42"]Purchase prints of %title[/purchase_webcomic_link]
  * </code>
  * 
  * @package Webcomic
  * @param string $format Format string for the link. Should include the %link token, which will be replaced by the actual link.
  * @param string $link Format string for the link text. Accepts %title, %date, and image size tokens.
  * @param mixed $the_post The post object or ID to retrive the purchase link for.
  * @uses WebcomicTag::purchase_webcomic_link()
  */
 function purchase_webcomic_link($format = '%link', $link = '', $the_post = false)
 {
     echo WebcomicTag::purchase_webcomic_link($format, $link, $the_post);
 }
示例#3
0
 /**
  * Handle (relative)_webcomic_link shortcodes.
  * 
  * @param array $atts Shortcode attributes.
  * @param string $content Shortcode content.
  * @param string $name Shortcode name.
  * @return string
  * @uses WebcomicTag::relative_webcomic_link()
  * @uses WebcomicTag::purchase_webcomic_link()
  */
 public function the_webcomic_link($atts, $content, $name)
 {
     extract(shortcode_atts(array('format' => '%link', 'link' => '', 'in_same_term' => false, 'excluded_terms' => '', 'taxonomy' => 'storyline', 'collection' => '', 'the_post' => false, 'cache' => true), $atts));
     $relative = substr($name, 0, strpos($name, '_'));
     if ('first' === $relative and !$cache) {
         $relative = 'first-nocache';
     } elseif ('last' === $relative and !$cache) {
         $relative = 'last-nocache';
     } elseif ('random' === $relative and !$cache) {
         $relative = 'random-nocache';
     }
     if (!$link) {
         if ($content) {
             $link = do_shortcode($content);
         } elseif ('previous' === $relative) {
             $link = '&lsaquo;';
         } elseif ('next' === $relative) {
             $link = '&rsaquo;';
         } elseif ('first' === $relative or 'first-nocache' === $relative) {
             $link = '&laquo;';
         } elseif ('last' === $relative or 'last-nocache' === $relative) {
             $link = '&raquo;';
         } elseif ('random' === $relative or 'random-nocache' === $relative) {
             $link = '&infin;';
         } elseif ('purchase' === $relative) {
             $link = '&curren;';
         }
     }
     return 'purchase' === $relative ? WebcomicTag::purchase_webcomic_link($format, $link, $the_post) : WebcomicTag::relative_webcomic_link($format, $link, $relative, $in_same_term, $excluded_terms, $taxonomy, $collection);
 }