/** * Returns the wrapper element if it exists including specified id, class, * microdata, prefix and suffix. * * @access public * @param bool $open_tag (default: true) Whether or not to output the opening or closing tag * @return string */ public function display($open_tag = true) { $element = HAG_Utils::sanitize_element($this->options['wrapper_element']); if (empty($element) && $open_tag) { return $this->options['prefix']; } if (empty($element) && !$open_tag) { return $this->options['suffix']; } if (!$open_tag) { return sprintf('%s</%s>', $this->options['suffix'], $element); } $class = HAG_Utils::sanitize_class($this->options['wrapper_class']); $id = HAG_Utils::sanitize_class($this->options['wrapper_id']); $wrapper = array(); $wrapper[] = sprintf('<%s', $element); if (!empty($id)) { $wrapper[] = sprintf('id="%s"', $id); } if (!empty($class)) { $wrapper[] = sprintf('class="%s"', $class); } if ($this->options['microdata']) { $wrapper[] = 'itemprop="breadcrumb"'; } $wrapper[] = sprintf('>%s', $this->options['prefix']); return implode(' ', $wrapper); }
/** * Gets the crumb's link if it exists. * * @access private * @param bool $open_tag (default: true) Whether or not to return the open or close tag * @return string */ private function get_link($open_tag = true) { $has_link = $this->has_link(); // Closing tag if (!$open_tag && (!$has_link || empty($this->url))) { return '</span>'; } if (!$open_tag) { return '</a>'; } // Get stuff $element = $this->get_element(); $class = HAG_Utils::sanitize_class($this->get_class() . ' ' . $this->options['link_class']); $id = $this->get_id(); $link = array(); // Start opening tag if (!$has_link || empty($this->url)) { $link[] = '<span'; } else { $link[] = sprintf('<a href="%s"', $this->url); } // Add id if (empty($element) && !empty($id)) { $link[] = sprintf(' id="%s"', $id); } // Add class if (empty($element) && !empty($class)) { $link[] = sprintf(' class="%s"', $class); } // End opening tag $link[] = '>'; return implode('', $link); }