本文整理匯總了PHP中GVCommon::get_link_html方法的典型用法代碼示例。如果您正苦於以下問題:PHP GVCommon::get_link_html方法的具體用法?PHP GVCommon::get_link_html怎麽用?PHP GVCommon::get_link_html使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GVCommon
的用法示例。
在下文中一共展示了GVCommon::get_link_html方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: test_get_link_html
/**
* @group link_html
* @covers ::gravityview_get_link()
* @covers GVCommon::get_link_html
*/
function test_get_link_html()
{
$this->assertEquals('<a href="#">Basic</a>', GVCommon::get_link_html('#', 'Basic'));
$this->assertEquals('<a title="New Title" href="#">Basic</a>', GVCommon::get_link_html('#', 'Basic', array('title' => 'New Title')));
$this->assertEquals('<a title="New Title" href="#">Basic</a>', GVCommon::get_link_html('#', 'Basic', array('title' => 'New Title')));
$this->assertEquals('<a onclick="alert("Javascript!");" href="#">Basic</a>', GVCommon::get_link_html('#', 'Basic', array('onclick' => 'alert("Javascript!");')));
// Make sure running esc_url_raw
$href = '//?dangerous=alert("example");"%20;';
$this->assertEquals('<a href="' . esc_url_raw($href) . '">Basic</a>', GVCommon::get_link_html($href, 'Basic'));
// Test gravityview/get_link/allowed_atts filter
add_filter('gravityview/get_link/allowed_atts', array($this, '_filter_test_get_link_html'));
$this->assertEquals('<a href="#">Basic</a>', GVCommon::get_link_html('#', 'Basic', array('onclick' => 'alert("Javascript!");')));
remove_filter('', array($this, '_filter_test_get_link_html'));
}
示例2: gravityview_get_link
/**
* Generate an HTML anchor tag with a list of supported attributes
*
* @see GVCommon::get_link_html()
*
* @since 1.6
*
* @param string $href URL of the link.
* @param string $anchor_text The text or HTML inside the anchor. This is not sanitized in the function.
* @param array $atts Attributes to be added to the anchor tag
*
* @return string HTML output of anchor link. If empty $href, returns NULL
*/
function gravityview_get_link($href = '', $anchor_text = '', $atts = array())
{
return GVCommon::get_link_html($href, $anchor_text, $atts);
}