Skip to content

Instantly share code, notes, and snippets.

@Peetra
Forked from trepmal/qtags.php
Created January 3, 2012 17:20
Show Gist options
  • Select an option

  • Save Peetra/1555891 to your computer and use it in GitHub Desktop.

Select an option

Save Peetra/1555891 to your computer and use it in GitHub Desktop.
Quicktags API for my Bubble Buttons in the html editor/WP
<?php /* Peetra modified git clone git://gist.github.com/1555891.git gist-1555891 one for use at www.bubble-witch-saga.se, TY trepmal! =)
put the file in a suitable named folder in /wp-content/plugins/ and activate it via wp-admin --> Plugins
Plugin Name: Peetras Custom Made Editor Addons
Description: Buttons and ready made content that are time consuming to write for each post
Author: Kailey Lampert,
Author URI: http://kaileylampert.com/
*/
add_action( 'admin_print_footer_scripts', 'bubble_type_buttons', 30 ); // 30 is the maximum number of additional buttons
function bubble_type_buttons()
{
?>
<script type="text/javascript">
// SYNTAX: QTags.addButton( 'position', 'button-label', 'first time click]', 'second time click' );
// EMPTY button shell FOR COPY/PASTE
// QTags.addButton( 'k_', '', '', '');
QTags.addButton( 'k_01', 'lck', prompt_userLCK );
function prompt_userLCK(e, c, ed) {
prmt = prompt('How many Lock Bubbles?');
if ( prmt === null ) return;
prmtChain = prompt('How many Chains?');
if ( prmtChain === null) return;
rtrn = '<br><img title=\"Ghost Lock on Chain\" src=\"/wp-content/uploads/bubbletypes/locked-keyhole-bubble.png\" alt=\"Ghost Lock on Chain\" /> ' + prmt + ' <a href=\"lock-bubbles/\" title=\"Lock Bubbles\"> Lock Bubbles</a>(' + prmtChain + ' chains)';
this.tagStart = rtrn;
QTags.TagButton.prototype.callback.call(this, e, c, ed);
}
QTags.addButton( 'k_02', 'bmb', prompt_userBMB );
function prompt_userBMB(f, g, fd) {
prmt = prompt('How many Bomb Bubbles?');
if ( prmt === null ) return;
rtrn = '<br><img title=\"Bomb Bubble\" src=\"/wp-content/uploads/bubbletypes/bomb-bubble.png\" alt=\"Bomb Bubble\" /> ' + prmt + ' <a href=\"/bomb-bubbles/\" title=\"Bomb Bubbles\"> Bomb Bubbles</a>';
this.tagStart = rtrn;
QTags.TagButton.prototype.callback.call(this, f, g, fd);
}
QTags.addButton( 'k_03', 'dsk', '<br><img title=\"skull-doom-bubble.png\" src=\"/wp-content/uploads/bubbletypes/skull-doom-bubble.png\" alt=\"skull-doom-bubble.png\" /> <a href=\"/doom-aka-skull-bubbles/\" title=\"Doom aka Skull Bubbles\">Doom Skull Bubbles</a>');
QTags.addButton( 'k_04', 'spb', '<br><img title=\"yellow spider bubble\" src=\"/wp-content/uploads/bubbletypes/yellow-spider-bubble.png\" alt=\"yellow-spider-bubble\" /> <a href=\"/spider-bubbles/\" title=\"Spider Bubbles\">Spider Bubbles</a>' );
QTags.addButton( 'k_05', 'inf', '<br><img title=\"Infected bubble\" src=\"/wp-content/uploads/bubbletypes/Infected-bubble-transparent-bg.gif\" alt=\"Infected Bubble\" /> <a href=\"/infected-bubbles/\" title=\"Infected Bubbles\">Infected Bubbles</a>');
QTags.addButton( 'k_06', 'cr', '<br><img title=\"Crystal Bubble\" src=\"/wp-content/uploads/bubbletypes/crystal-bubble-transparent-bg.gif\" alt=\"Crystal Bubble\" /> <a href=\"/crystal-bubbles/\" title=\"Crystal Bubbles\">Crystal Bubbles</a>');
QTags.addButton( 'k_07', 'bl', '<br><img title=\"Iron Bubble\" src=\"/wp-content/uploads/bubbletypes/black-bubble-is-hard-as-rock.png\" alt=\"black bubble-is-hard-as-rock\" /> <a href=\"/morph-bubbles/\" title=\"Morph Bubble\">Black Bubbles</a>');
QTags.addButton( 'k_08', 'mor', '<br> <img title=\"Morph Bubbles\" src=\"/wp-content/uploads/bubbletypes/morph-bubble.png\" alt=\"Morph Bubble\" /> <a href=\"/morph-bubbles/\" title=\"Morph Bubble\"> Morph Bubbles</a>');
QTags.addButton( 'k_09', 'rb', '<img title=\"Rainbow Bubble\" src=\"/wp-content/uploads/bubbletypes/rainbow-bubble.gif\" alt=\"Rainbow Bubble\" /> <a href=\"/rainbow-ball/\" title=\"Rainbow Bubble\">Rainbow Bubbles</a>');
</script>
<?php
}
// content always there, when I start a new post http://justintadlock.com/archives/2009/04/05/how-to-preset-text-in-the-wordpress-post-editor
add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content )
{
$content = "<strong>Starting Bubbles</strong>:
<strong>Recommended Potions</strong>:
<strong>Points needed for 1, 2, 3 Star</strong>:
<strong>Special bubbles</strong>:";
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment