├── .gitignore ├── images ├── mtg.png └── deckbox_logo.png ├── screenshot-1.png ├── screenshot-2.png ├── resources ├── tooltip_extension.js ├── css │ └── wp_deckbox_mtg.css └── tinymce3 │ └── editor_plugin.js ├── lib └── bbp-do-shortcodes.php ├── script ├── run.sh └── wp_release ├── LICENSE.txt ├── README.md ├── readme.txt └── wp_deckbox_mtg.php /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea* 2 | .DS_Store -------------------------------------------------------------------------------- /images/mtg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deckbox/wordpress_mtg_tooltips/HEAD/images/mtg.png -------------------------------------------------------------------------------- /screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deckbox/wordpress_mtg_tooltips/HEAD/screenshot-1.png -------------------------------------------------------------------------------- /screenshot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deckbox/wordpress_mtg_tooltips/HEAD/screenshot-2.png -------------------------------------------------------------------------------- /images/deckbox_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deckbox/wordpress_mtg_tooltips/HEAD/images/deckbox_logo.png -------------------------------------------------------------------------------- /resources/tooltip_extension.js: -------------------------------------------------------------------------------- 1 | jQuery(document).ready(function($) { 2 | $('.mtg_deck_embedded a').mouseover(function(event) { 3 | $(this).parents('.mtg_deck').find('img.on_page').attr('src',$(this).attr('href') + '/tooltip'); 4 | event.stopPropagation(); 5 | }); 6 | }); 7 | -------------------------------------------------------------------------------- /resources/css/wp_deckbox_mtg.css: -------------------------------------------------------------------------------- 1 | .mtg_deck_title { 2 | text-decoration: underline; 3 | } 4 | 5 | table.mtg_deck { 6 | width: 100%; 7 | max-width: 510px; 8 | margin: 10px; 9 | text-align: left; 10 | } 11 | 12 | table.mtg_deck td { 13 | vertical-align: top; 14 | padding: 5px 2px; 15 | vertical-align: top; 16 | } 17 | 18 | table.mtg_deck td.card_box img { 19 | max-height: 310px !important; 20 | max-width: 310px !important; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /lib/bbp-do-shortcodes.php: -------------------------------------------------------------------------------- 1 | [args]\n\nTasks:\n" "${0}" 17 | compgen -A function | grep -v "^_" | cat -n 18 | } 19 | 20 | # This idea is heavily inspired by: https://github.com/adriancooney/Taskfile 21 | TIMEFORMAT=$'\nTask completed in %3lR' 22 | time "${@:-help}" -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2013 Sebastian Zaha 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without 8 | restriction, including without limitation the rights to use, 9 | copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following 12 | conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | OTHER DEALINGS IN THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Plugin for MTG Card Tooltips 2 | ============================ 3 | 4 | Enables card images to show on mouseover for Magic the Gathering cards. It 5 | provides a button (and corresponding shortcode tags) that wrap card names or 6 | deck listings and turn them into smart card links with image tooltips. 7 | 8 | 9 | More Information 10 | ---------------- 11 | 12 | For more details, screenshots and installation instructions please see the 13 | [official wordpress readme.txt](https://github.com/SebastianZaha/wordpress_mtg_tooltips/blob/master/readme.txt). 14 | 15 | For bbpress forum compatibility I have included in the distribution Pippin's 16 | fix for bbpress shortcodes [from here](http://wordpress.org/extend/plugins/bbpress-do-short-codes/). 17 | 18 | 19 | Examples 20 | -------- 21 | 22 | ``` 23 | [d title="Really Small Deck" style="embedded"] 24 | Creatures 25 | 2 Bloodbraid Elf 26 | 4 Grizzly Bears 27 | 28 | Spells 29 | 4 Lightning Bolt 30 | 31 | Sideboard 32 | 4 Cultivate 33 | [/d] 34 | ``` 35 | 36 | produces the following result: 37 | 38 |  39 | 40 | 41 | Support and Development 42 | ----------------------- 43 | 44 | The code in this plugin is inspired from other shortcode-type wordpress plugins that looked 45 | solid to me. The spacing and conventions try to stay close to the 46 | [pear standards](http://pear.php.net/manual/en/standards.php). I am not a PHP developer, so I'm 47 | pretty sure the code here is not *the right way to do it*. 48 | 49 | I'll gladly accept pull requests with improvements and / or code cleanup. 50 | 51 | -------------------------------------------------------------------------------- /resources/tinymce3/editor_plugin.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | tinymce.create('tinymce.plugins.DeckboxPlugin', { 3 | /** 4 | * Initializes the plugin, this will be executed after the plugin has been created. 5 | * This call is done before the editor instance has finished it's initialization so use the onInit event 6 | * of the editor instance to intercept that event. 7 | * 8 | * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. 9 | * @param {string} url Absolute URL to where the plugin is located. 10 | */ 11 | init : function(ed, url) { 12 | ed.addButton('deckbox', { 13 | title : 'Magic the Gathering card', 14 | image : url + '/../../images/mtg.png', 15 | onclick : function() { 16 | var txt = ed.selection.getContent(); 17 | ed.selection.setContent('[mtg_card]' + txt + '[/mtg_card]'); 18 | } 19 | }); 20 | }, 21 | 22 | /** 23 | * Creates control instances based in the incomming name. This method is normally not 24 | * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons 25 | * but you sometimes need to create more complex controls like listboxes, split buttons etc then this 26 | * method can be used to create those. 27 | * 28 | * @param {String} n Name of the control to create. 29 | * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control. 30 | * @return {tinymce.ui.Control} New control instance or null if no control was created. 31 | */ 32 | createControl : function(n, cm) { 33 | return null; 34 | }, 35 | 36 | /** 37 | * Returns information about the plugin as a name/value array. 38 | * The current keys are longname, author, authorurl, infourl and version. 39 | * 40 | * @return {Object} Name/value array containing information about the plugin. 41 | */ 42 | getInfo : function() { 43 | return { 44 | longname : "Magic the Gathering Card Tooltips", 45 | author : 'Sebastian Zaha', 46 | authorurl : 'https://deckbox.org', 47 | infourl : 'https://github.com/SebastianZaha/wordpress_mtg_tooltips', 48 | version : "3.1.0" 49 | }; 50 | } 51 | }); 52 | 53 | // Register plugin 54 | tinymce.PluginManager.add('deckbox', tinymce.plugins.DeckboxPlugin); 55 | })(); 56 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === Magic the Gathering Card Tooltips === 2 | Contributors: grimdonkey 3 | Tags: magic the gathering, deckbox, MtG, tcg, ccg, magic, cards, tooltips 4 | Requires at least: 2.8.6 5 | Tested up to: 6.7.1 6 | Stable tag: 3.6.0 7 | 8 | Easily transform Magic the Gathering card names into links that show the card image in a tooltip when hovering over them. You can also quickly create deck listings. 9 | 10 | == Description == 11 | 12 | The plugin adds shortcodes that transform mtg card names and decks to provide a mouseover image. For cards use the [mtg_card][/mtg_card] shortcode (or the shortened version [c][/c]). When viewing the post, the card name will show up as a link to the card's page on https://deckbox.org . Hovering over the link will show the card's image in a tooltip. 13 | 14 | A similar tag can be used to quickly create deck listings: [mtg_deck][/mtg_deck] (or the shortened version [d][/d]). A deck listing should contain a list of cards and categories. All cards have a number before their name. All other lines are interpreted as category names. Do *not* include card numbers on the category name lines, they will automatically be computed and displayed by the plugin. A short example follows. 15 | 16 | The default style for displaying decks is a card listing with each card having a mouseover tooltip. This style can be changed to an embedded view, where the listing has a card image to the right of the deck. This can be toggled in the plugin settings for all decks, or specifically for a deck by setting the style attribute to the tag, as can be seen below. 17 | 18 | [d title="Really Small Deck" style="embedded"] 19 | Creatures 20 | 2 Bloodbraid Elf 21 | 4 Grizzly Bears 22 | 23 | Spells 24 | 4 Lightning Bolt 25 | 26 | Sideboard 27 | 4 Cultivate 28 | [/d] 29 | 30 | The screenshot section includes an image of the above deck listing. 31 | 32 | == Installation == 33 | 34 | 1. Head over to the "Install Plugins" section of your Admin Panel, and use the "Upload" link to install the zip file. 35 | 2. Activate the plugin through the 'Plugins' menu. 36 | 3. Manually write the [c] tags for cards, or add a shortcode block for decks ([d]). 37 | 38 | Alternatively, you can search for "Magic the Gathering" from the Admin panel Plugins section, select this plugin and click 'Install'. 39 | 40 | == Frequently Asked Questions == 41 | 42 | = Do you support other games? = 43 | 44 | Yes, there is a separate plugin for World of Warcraft TCG card tooltips, you can find it at [http://wordpress.org/extend/plugins/world-of-warcraft-card-tooltips/](http://wordpress.org/extend/plugins/world-of-warcraft-card-tooltips/). 45 | 46 | = Is the 3.0 and 2.0 version compatible with the older ones? = 47 | 48 | Completely compatible: your old posts will remain the same as before, even though your new posts will use the tag syntax. 49 | 50 | == Screenshots == 51 | 52 | 1. The mouseover effect 53 | 2. An example of a really small deck listing, produced by the code shown in the description 54 | 55 | == Changelog == 56 | 57 | = 3.6.0 = 58 | * Cleanup plugin options processing and sanitization. Use a nonce in the form. 59 | 60 | = 3.5.0 = 61 | * Fix handling of the style attribute on deck tags 62 | * Test on latest wordpress (6.7.1) 63 | 64 | = 3.4.0 = 65 | * Rephrase the readme to refer to shortcode blocks in the visual editor, since newer wordpress versions do not have the old tinymce editor for which we had the icons. 66 | * Test on latest wordpress (6.6.2) 67 | 68 | = 3.3.0 = 69 | * Set table width to 100% for decks. max-width is still at 510px so it should 70 | not change anything for existing users. The max-width can be set from 71 | the plugin options to allow larger deckview sizes. 72 | 73 | = 3.2.0 = 74 | * Fixed tooltips on mobile, updated wp compat to 6.0. 75 | 76 | = 3.1.6 = 77 | * Improve responsiveness, do not force width in px. Move Lands by default to second column. 78 | 79 | = 3.1.5 = 80 | * Improve responsiveness, do not force width in px. Move Lands by default to second column. 81 | 82 | = 3.1.0 = 83 | * Added support for bbpress. Shortcodes are not working there by default. 84 | 85 | = 3.0.3 = 86 | * Small fix: removed unnecessary echo 87 | 88 | = 3.0.2 = 89 | * Added configuration options for font size and line height for deck listings 90 | 91 | = 3.0.1 = 92 | * Small fixes to the embedded view. 93 | 94 | = 3.0.0 = 95 | * Implement embedded view for decks (no floating card tooltips on mouseover, but the card image 96 | is present to the right of the listing) 97 | * Add a few new shortcodes [c], [card], [d] and [deck] 98 | * Add a customization option for the width of the deck listing display 99 | 100 | = 2.0.0 = 101 | * Rewrote the card button to use shortcode tags. 102 | * Implemented deck listing support. 103 | 104 | = 1.0.3 = 105 | * Button in editor was not showing. Now it works. 106 | 107 | = 1.0.2 = 108 | * Cleanup header information in php file to correctly represent released version. 109 | 110 | = 1.0.1 = 111 | * Test on newer Wordpress versions, cleanup readme file. 112 | 113 | = 1.0.0 = 114 | * Initial plugin release 115 | -------------------------------------------------------------------------------- /script/wp_release: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Defaults 4 | CURRENT_DIR=`pwd` 5 | PLUGIN_NAME='' 6 | SVN_REMOTE='' 7 | SVN_DIR='' 8 | SVN_MSG='Updating with version %s' 9 | SVN_USR='' 10 | SVN_PWD='' 11 | GIT_REMOTE='' 12 | GIT_COMMIT='' 13 | GIT_DIR='' 14 | 15 | help() { 16 | echo -e "\033[1;34mdeploy.sh\033[0m clones your git repository and pushes the content to a specified 17 | subversion repository. It's written to deploy new versions of Wordpress plugins. 18 | 19 | \033[0;34m-n \033[1;32mPlugin name\033[0m What's the name of your plugin? 20 | \033[0;34m-s \033[1;32mSVN remote\033[0m Where's your SVN repository? 21 | \033[0;34m-m \033[1;32mSVN message \033[0;33m[optional]\033[0m A message for the subversion commit (default: $SVN_MSG) 22 | \033[0;34m-u \033[1;32mSVN username \033[0;33m[optional]\033[0m Subversion remote username 23 | \033[0;34m-p \033[1;32mSVN password \033[0;33m[optional]\033[0m Subversion remote password 24 | \033[0;34m-g \033[1;32mGit remote\033[0m Where's your git repository? 25 | \033[0;34m-c \033[1;32mGit commit \033[0;33m[optional]\033[0m If you want to commit a specified commit 26 | " 27 | } 28 | 29 | # Some loading animation :) 30 | 31 | spinner() { 32 | s='.oOo' 33 | #ds=`date "+%H:%M:%S"` 34 | while [ `ps -p $1 -o pid=` ]; do 35 | for (( n=0; n<${#s}; n+=1 )); do 36 | if [ `ps -p $1 -o pid=` ]; then 37 | break; 38 | fi 39 | printf "$2${s:$n:1}$3"; sleep 0.1; printf "\r" 40 | done 41 | done 42 | #de=`date "+%H:%M:%S"` 43 | #echo -e "$2# [$ds-$de]$3" 44 | echo -e "$2#$3" 45 | } 46 | 47 | quit() { 48 | cd $CURRENT_DIR 49 | 50 | rm -Rf $GIT_DIR & 51 | spinner $! "\033[0;34m" " \033[0mRemoving temporary git clone" 52 | 53 | rm -Rf $SVN_DIR & 54 | spinner $! "\033[0;34m" " \033[0mRemoving temporary svn checkout" 55 | } 56 | 57 | # Gather options and arguments 58 | 59 | while getopts ":n:s:m:u:p:g:c:" opt; do 60 | case $opt in 61 | n ) PLUGIN_NAME=$OPTARG;; 62 | s ) SVN_REMOTE=$OPTARG;; 63 | m ) SVN_MSG=$OPTARG;; 64 | u ) SVN_USR=$OPTARG;; 65 | p ) SVN_PWD=$OPTARG;; 66 | g ) GIT_REMOTE=$OPTARG;; 67 | c ) GIT_COMMIT=$OPTARG;; 68 | \? ) help; echo -e "Option \033[1;34m-$OPTARG\033[0m does not exist"; exit;; 69 | : ) help; echo -e "Option \033[1;34m-$OPTARG\033[0m wants an argument"; exit;; 70 | esac 71 | done 72 | 73 | # Start display what we're doing 74 | 75 | echo -e "\033[0;34mDeploying wordpress plugin\033[0m" 76 | 77 | # Check plugin name 78 | 79 | if [ "$PLUGIN_NAME" ]; then 80 | echo -e "Plugin name: $PLUGIN_NAME" 81 | fi 82 | 83 | while [ ! "$PLUGIN_NAME" ]; do 84 | read -p "Plugin name: " PLUGIN_NAME 85 | done 86 | 87 | # Check git repository remote 88 | 89 | if [ "$GIT_REMOTE" ]; then 90 | echo -e "Git repository remote URL: $GIT_REMOTE" 91 | fi 92 | 93 | while [ ! "$GIT_REMOTE" ]; do 94 | read -p "Git repository remote URL: " GIT_REMOTE 95 | 96 | if [ ! "$GIT_COMMIT" ]; then 97 | read -p "Specify a commit (leave blank for ^HEAD): " GIT_COMMIT 98 | fi 99 | done 100 | 101 | # Clone the with git 102 | 103 | GIT_DIR="/tmp/$PLUGIN_NAME-git" 104 | if [ -d $GIT_DIR ]; then 105 | cd $GIT_DIR 106 | git pull -q origin & 107 | spinner $! "\033[0;34m" " \033[0mPulling in: $GIT_DIR" 108 | cd $CURRENT_DIR 109 | else 110 | git clone -q $GIT_REMOTE $GIT_DIR & 111 | spinner $! "\033[0;34m" " \033[0mCloning into: $GIT_DIR" 112 | fi 113 | 114 | # Get a specified commit, if there is one 115 | 116 | if [ "$GIT_COMMIT" ]; then 117 | cd $GIT_DIR; 118 | echo -e "Using commit: $GIT_COMMIT" 119 | git checkout -q $GIT_COMMIT 120 | cd $CURRENT_DIR; 121 | fi 122 | 123 | # Check version in readme.txt is the same as plugin file 124 | 125 | PLUGIN_FILE="$GIT_DIR/$PLUGIN_NAME.php" 126 | 127 | for FILE in `ls $GIT_DIR/*.php`; do 128 | if [ -f "$FILE" ]; then 129 | if grep -q "^Plugin Name:" $FILE & grep -q "^Version:" $FILE; then 130 | echo -e "Using $FILE" 131 | PLUGIN_FILE="$FILE" 132 | fi 133 | fi 134 | done 135 | 136 | if [ -f "$GIT_DIR/readme.txt" ] & [ -f "$PLUGIN_FILE" ]; then 137 | NEWVERSION1=`grep "^ \?\(* \)\?Stable tag" $GIT_DIR/readme.txt | awk '{ print $NF}'` 138 | NEWVERSION2=`grep "^Version" $PLUGIN_FILE | awk '{ print $NF}'` 139 | else 140 | echo -e "FAIL: Could not find $GIT_DIR/readme.txt and/or $PLUGIN_FILE" 141 | quit 142 | exit 143 | fi 144 | 145 | if [ "$NEWVERSION1" != "$NEWVERSION2" ]; then 146 | echo -e "FAIL: Versions don't match - $NEWVERSION1 != $NEWVERSION2" 147 | quit 148 | exit 149 | fi 150 | 151 | echo -e "Version to deploy: $NEWVERSION1" 152 | 153 | # Check svn repository 154 | 155 | if [ "$SVN_REMOTE" ]; then 156 | echo "Subversion repository remote URL: $SVN_REMOTE" 157 | fi 158 | 159 | while [ ! "$SVN_REMOTE" ]; do 160 | read -p "Subversion repository remote URL: " SVN_REMOTE 161 | 162 | if [ ! "$SVN_USR" ]; then 163 | read -p "Subversion repository username (optional): " SVN_USR 164 | fi 165 | 166 | if [ "$SVN_USR" ] & [ ! "$SVN_PWD" ]; then 167 | read -r "Subversion repository password (optional): " SVN_PWD 168 | fi 169 | done 170 | 171 | # Checkout the SVN repository 172 | 173 | SVN_DIR="/tmp/$PLUGIN_NAME-svn" 174 | if [ -d "$SVN_DIR" ]; then 175 | cd $SVN_DIR; 176 | svn --quiet up & 177 | spinner $! "\033[0;34m" " \033[0mUpdating: $SVN_DIR" 178 | cd $CURRENT_DIR; 179 | else 180 | svn --quiet co $SVN_REMOTE $SVN_DIR & 181 | spinner $! "\033[0;34m" " \033[0mCheckout into: $SVN_DIR" 182 | fi 183 | 184 | # Check if there's already a tag with version 185 | 186 | if [ -d "$SVN_DIR/tags/$NEWVERSION1" ]; then 187 | echo -e "Version $NEWVERSION1 already exist" 188 | quit 189 | exit 190 | fi 191 | 192 | # Copy files from git to svn directories 193 | 194 | cd $GIT_DIR 195 | git checkout-index -q -a -f --prefix=$SVN_DIR/trunk/ & 196 | spinner $! "\033[0;34m" " \033[0mCopying files to: $SVN_DIR/trunk" 197 | cd $CURRENT_DIR; 198 | 199 | # Change to SVN dir and commit changes 200 | 201 | echo -e "Committing subversion repository's trunk with files copied from git" 202 | cd $SVN_DIR/trunk 203 | SVN_MSG=$( printf "$SVN_MSG" $NEWVERSION1 ) 204 | if [ "$SVN_USR" ]; then 205 | SVN_USR="--username $SVN_USR" 206 | fi 207 | if [ "$SVN_PWD" ]; then 208 | SVN_PWD="--password $SVN_PWD" 209 | fi 210 | 211 | svn stat | grep '^?' | awk '{print $2}' | xargs svn add 212 | svn ci $SVN_USR $SVN_PWD -m "$SVN_MSG" 213 | 214 | echo -e "Committing new version tag: $NEWVERSION1" 215 | cd .. 216 | svn copy $SVN_REMOTE/trunk $SVN_REMOTE/tags/$NEWVERSION1 $SVN_USR $SVN_PWD -m "Version tag $NEWVERSION1" 217 | 218 | quit 219 | echo "COMPLETE" -------------------------------------------------------------------------------- /wp_deckbox_mtg.php: -------------------------------------------------------------------------------- 1 | _name = 'Magic the Gathering Card Tooltips'; 40 | $this->_optionName = 'deckbox_tooltip_options'; 41 | $this->_value = array(); 42 | $this->_styles = array('tooltip', 'embedded'); 43 | $this->_resources_dir = plugins_url().'/magic-the-gathering-card-tooltips/resources/'; 44 | $this->_images_dir = plugins_url().'/magic-the-gathering-card-tooltips/images/'; 45 | 46 | $this->loadSettings(); 47 | $this->init(); 48 | $this->handlePostback(); 49 | } 50 | 51 | function init() { 52 | add_action('admin_menu', array($this, 'add_option_menu')); 53 | $this->add_shortcodes(); 54 | $this->add_scripts(); 55 | $this->add_buttons(); 56 | } 57 | 58 | function init_css() { 59 | echo '' . "\n"; 61 | } 62 | 63 | function add_shortcodes() { 64 | add_shortcode('mtg_card', array($this,'parse_mtg_card')); 65 | add_shortcode('card', array($this,'parse_mtg_card')); 66 | add_shortcode('c', array($this,'parse_mtg_card')); 67 | add_shortcode('mtg_deck', array($this,'parse_mtg_deck')); 68 | add_shortcode('deck', array($this,'parse_mtg_deck')); 69 | add_shortcode('d', array($this,'parse_mtg_deck')); 70 | } 71 | 72 | function add_buttons() { 73 | if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) 74 | return; 75 | 76 | // Add only in Rich Editor mode 77 | if ( get_user_option('rich_editing') == 'true') { 78 | add_filter("mce_external_plugins", array($this,"add_tinymce_plugin")); 79 | add_filter('mce_buttons', array($this,'register_button')); 80 | } 81 | } 82 | 83 | function register_button($buttons) { 84 | array_push($buttons, "separator", "deckbox"); 85 | return $buttons; 86 | } 87 | 88 | function add_tinymce_plugin($plugin_array) { 89 | $plugin_array['deckbox'] = $this->_resources_dir.'tinymce3/editor_plugin.js'; 90 | return $plugin_array; 91 | } 92 | 93 | function add_scripts() { 94 | wp_enqueue_script('deckbox', 'https://deckbox.org/javascripts/tooltip.js'); 95 | wp_enqueue_script('deckbox_extensions', $this->_resources_dir.'tooltip_extension.js', array('jquery')); 96 | add_action('wp_head', array($this, 'init_css')); 97 | } 98 | 99 | function parse_mtg_card($atts, $content=null) { 100 | return '' . $content . ''; 101 | } 102 | 103 | function cleanup_shortcode_content($content) { 104 | $dirty_lines = preg_split("/[\n\r]/", $content); 105 | $lines = array(); 106 | 107 | foreach ($dirty_lines as $line) { 108 | $clean = trim(strip_tags($line)); 109 | if ($clean != "") { 110 | $lines[] = $clean; 111 | } 112 | } 113 | 114 | return $lines; 115 | } 116 | 117 | function parse_mtg_deck($atts, $content=null) { 118 | extract(shortcode_atts(array( 119 | "title" => null, 120 | "style" => null, 121 | ), $atts)); 122 | 123 | if ($title) { 124 | $response = '
| '; 132 | 133 | $lines = $this->cleanup_shortcode_content($content); 134 | $response .= $this->parse_mtg_deck_lines($lines, $style) . ' | '; 135 | $response .= '
';
194 | }
195 | $title .= ' Deckbox Tooltips';
196 |
197 | add_options_page('Deckbox Tooltips', $title, 'read', 'magic-the-gathering-card-tooltips',
198 | array($this, 'draw_menu'));
199 | }
200 |
201 | function draw_menu() {
202 | echo '
203 | settings saved