WordPress.org

Ready to get started?Download WordPress

Forums

CF Internal Link Shortcode
Support for other attributes? (2 posts)

  1. Jeff Cohan
    Member
    Posted 1 year ago #

    Very nice plugin; thanks!

    Any plans to extend the plugin to support other attributes, especially "title" and "target"?

    http://wordpress.org/extend/plugins/internal-link-shortcode/

  2. Jeff Cohan
    Member
    Posted 1 year ago #

    Would this revision do it: ???

    function cfplsc_shortcode($atts, $wrapped = null) {
    	extract(shortcode_atts(array(
    		'id' => null,
    		'text' => null,
    		'class' => null,
    		'rel' => null,
    		'title' => null,
    		'target' => null
    	), $atts));
    	$wrapped = trim($wrapped);
    	if (!empty($wrapped)) {
    		$text = $wrapped;
    	}
    	$text = trim($text);
    	$id = intval($id);
    	if (empty($id)) {
    		return $text;
    	}
    	$url = get_permalink($id);
    	if (empty($text)) {
    		$text = get_the_title($id);
    	}
    	empty($class) 	? $class = '' 	: $class = 		' class="'.esc_attr($class).'"';
    	empty($rel) 	? $rel = '' 	: $rel = 		' rel="'.esc_attr($rel).'"';
    	empty($title) 	? $title = '' 	: $title = 		' title="'.esc_attr($title).'"';
    	empty($target) 	? $target = '' 	: $target = 	' target="'.esc_attr($target).'"';
    	return '<a>'.esc_html($text).'</a>';
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.