Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button href target #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions inc/bs_buttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ function bs_buttons( $params, $content=null ) {
'size' => 'default',
'type' => 'default',
'value' => 'button',
'href' => "#"
'href' => "#",
'target' => '_self'
), $params ) );

$content = preg_replace( '/<br class="nc".\/>/', '', $content );
$result = '<a class="btn btn-' . $size . ' btn-' . $type . '" href="' . $href . '">' . $value . '</a>';
$result = '<a class="btn btn-' . esc_attr($size). ' btn-' . esc_attr($type) . '" href="' . esc_url($href) . '" target="' . esc_attr($target) . '"" >' . $value . '</a>';
return force_balance_tags( $result );
}
add_shortcode( 'bs_button', 'bs_buttons' );
8 changes: 7 additions & 1 deletion js/plugins/buttons.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
var type = $('select[name=type]').val();
var value = $('input[name=value]').val();
var link = $('input[name=link]').val();
top.tinymce.activeEditor.insertContent('[bs_button size="'+size.toLowerCase()+'" type="'+type.toLowerCase()+'" value="'+value+'" href="'+link+'"]');
var target = $('select[name=target]').val();
top.tinymce.activeEditor.insertContent('[bs_button size="'+size.toLowerCase()+'" type="'+type.toLowerCase()+'" value="'+value+'" href="'+link+'" target="'+target+'"]');
top.tinymce.activeEditor.windowManager.close();
});
});
Expand Down Expand Up @@ -47,6 +48,11 @@
<input type="text" class="form-control" id="value" name="value" placeholder="Value" />
<label for="link">Link</label>
<input type="text" class="form-control" id="link" name="link" placeholder="#" />
<label for="target">Target</label>
<select class="form-control" id="target" name="target">
<option value="_self">_self</option>
<option value="_blank">_blank</option>
</select>
</div>
<button type="submit" id="insert" class="btn btn-primary">Insert</button>
</form>
Expand Down