You appear to be a bot. Output may be restricted
Description
Implement [bw_link] shortcode for a link to a post or an external URLIf the id or first unnamed parameter is numeric we treat this as a post ID else we interpret the given parameter to find what could be a suitable URL. If nothing is specified we simply link to ourselves.
Usage
$string = bw_link( $atts, $content, $tag );
Parameters
- $atts
- ( array ) optional – array of shortcode parameters
- $content
- ( string ) optional –
- $tag
- ( string ) optional –
Returns
string the expanded shortcodeTO DO
Add support for URL and text to be entered in any order. We can't simply change it to "text,1" since this makes the link text wrong for this example[bw_link text="Defence Sector" href="#front-page-3" class="button"]
Not quite sure why! Source
File name: oik/shortcodes/oik-link.phpLines:
1 to 24 of 24
function bw_link( $atts=null, $content=null, $tag=null ) { $id = bw_array_get_from( $atts, "id,0", null ); $class = bw_array_get( $atts, "class", "bw_link" ); $text = bw_array_get( $atts, "text", null ); $title = bw_array_get( $atts, "title", null ); if ( $id && is_numeric( $id ) ) { $url = get_permalink( $id ); if ( !$text ) { $text = get_the_title( $id ); } } else { $url = bw_array_get_from( $atts, "href,url,src,link", $id ); if ( !$url ) { $url = get_permalink(); $text = get_the_title(); } if ( !$text ) { $text = bw_link_text_from_url( $url ); } $url = bw_link_url( $url, $atts ); } BW_::alink( $class, $url, $text, $title ); return( bw_ret()); }View on GitHub View on Trac