/** * Render the HTML for the screenshot. * * @access public * @since 8.2.5 * * @return string */ public function render() { $imageURI = $this->getSource(); $url = $this->getURL(); if (is_wp_error($imageURI)) { $html = '<p class="cn-error">' . implode('</p><p class="cn-error">', $imageURI->get_error_messages()) . '</p>'; } elseif (is_wp_error($url)) { $html = '<p class="cn-error">' . implode('</p><p class="cn-error">', $url->get_error_messages()) . '</p>'; } else { $image = sprintf('<img class="cn-screenshot" src="%1$s" %2$s %3$s width="%4$d"/>', $imageURI, $this->alt ? 'alt="' . $this->alt . '"' : '', !$this->link && $this->title ? 'title="' . $this->title . '"' : '', $this->width); $image = cnString::normalize($image); if ($this->link) { $link = sprintf('<a class="url" href="%1$s"%2$s %3$s target="%4$s">%5$s</a>', $url, $this->title ? ' title="' . $this->title . '"' : '', $this->follow ? '' : 'rel="nofollow"', $this->target, $image); $html = cnString::normalize($link); } else { $html = $image; } } $html = $this->before . $html . $this->after . PHP_EOL; if (!$this->return) { echo $html; } return $html; }
/** * Get the contact name. * * @access public * @since unknown * * @uses cnString::normalize() * * @param array $atts { * Optional * * @type string $format The format the name should be returned as. * Default '%first% %last%'. * Accepts any combination of the following tokens: '%first%', '%last%'' * } * * @param string $context The context in which it should be sanitized. * * @return string */ public function getContactName($atts = array(), $context = 'display') { $defaults = array('format' => '%first% %last%'); $atts = cnSanitize::args(apply_filters('cn_contact_name_atts', $atts), $defaults); $search = array('%first%', '%last%'); $replace = array(); $replace[] = $this->contactFirstName ? $this->getContactFirstName($context) : ''; $replace[] = $this->contactLastName ? $this->getContactLastName($context) : ''; $name = str_ireplace($search, $replace, $atts['format']); return cnString::normalize($name); }