To do what you want, it's not necessary to have two shortcodes, just make your shortcode accept arguments:
add_shortcode('apple', 'apple');
function apple($args) {
$default = array('icon' => '');
$args = wp_parse_args($args, $default);
$content = '';
if ($args['icon']) {
$content.= '<img src="icon.png">';
}
$content.= '<a href="http://example.com/apple>Apple</a>';
return $content;
}
To use this, you would then enter your shortcode as follows:
[apple icon="yes"]
If it's simply a "yes/no" for the icon.
Or, you could make it so it loads the icon dynamically based on what you set icon
equal to, which would require some modifications to the function:
function apple($args) {
$default = array('icon' => '');
$args = wp_parse_args($args, $default);
$content = '';
if ($args['icon']) {
$content.= '<img src="' . $args['icon'] . '">';
}
$content.= '<a href="http://example.com/apple>Apple</a>';
return $content;
}
And your shortcode would then look like so:
[apple icon="my_icon.png"]
(Note, you'd probably need to pass in a fully qualified domain name, like so: [apple icon="http://example.com/images/my_icon.png"]
)