Actually, looking at this I have managed to add a pdf button to the tinymce, but I would like to attach it to this plugin: http://wordpress.org/extend... in order to write the shortcode around the link like this: [gview file="http://url.to/file.pdf"] is that possible? how could that be done?
Do you think a similiar tinymce button could be added for a google pdf viewer script like this one: http://davismetro.com/gde/u... or indeed a shortcode like this: http://wpsnipp.com/index.ph...
How could this be done?
Wow, thanks for the phenomenally fast response.
Seeing your response, going to the pages you recommended, and re-reading what you wrote in the post really helped me to gain a better understanding of what I missed. I was thinking you were skipping a necessary step about creating buttons from shortcodes. I'll restate what I understand now, just to make sure I've got it:
You were saying that rather than teach us in this post how to create a quicktag button in the HTML editor -- because we could just type in what we needed directly with a shortcode -- you were going to focus on creating a button in the Visual Editor, because that's what the technologically challenged most need. Right? OK, think I got it. Thanks.
With regard to TinyMCE Advanced, going through the instructions, I couldn't see where it specifically allows me to add my own, but as you mentioned, it probably won't interfere, either.
Thanks again, Brett.
Hey Brett, really dig this nearly-complete treatment, because I'm looking to do just this kind of thing in the next few days.
I'm a complete php/js newbie who's been cobbling together my programming skills in dancing through the WP codex and blogs like yours in just the past week or so, though I've seen precious few that detail it like this. So, I've got a couple questions/clarifications/requests, if you're not sleeping and not tied up with other projects. ;-)
<ol>
<li>
You mentioned above that you essentially skipped the "Adding a button to the "quick tags" in the HTML editor" part because it's a cinch. I've never heard of this. Any tips where I can find out more?
</li>
<li>
I'm using the plugin TinyMCE Advanced. Does this support -- or complicate -- what you've presented here? I've only gotten exposure to TinyMCE in the past few days, so don't know if it's best to use a plugin or if there's a better way to do it.
</li>
</ol>
Thanks man.
For QuickTags I just found AddQuickTag and set it up to make Markdown links. Worked like a charm in WP 3.0.1. Just FYI.
You might check this out for QuickTags, though I have no idea how it plays with WP 3:
http://rmnl.net/wp-addquicktag-plugin-for-adding-quicktags/
Also, just google for "Adding quicktag buttons to wordpress" and you'll find it. It's a pretty simple javascript function you can just keep extending, but you'll want to do it through external hooks, so skip the tutorials that tell you to modify files inside of wp-include.
I haven't used TinyMCE Advanced for a long time, I can't remember if it has the ability to add its own buttons or not. Either way, it shouldn't conflict. The method here is a standard method of extending the editor and should play nicely with any plugin which implements that method.
Hi Brett,
This is a unrelated question and I hope you don't mind me asking it here but I am struggling to add TinyMCE editor to an existing plugin I am using. I have research it for quite some time and tried many different approaches but I can't seem to get it working :-(
Would you have any idea how I go about it? I am quite new to wordpress so still learning.
Thanks
Nice! Would be really slick if this were all wrapped up nicely in a plugin. Any possibility of that in the near future?
Possibly, if I find myself up late at night, unable to sleep and without other pressing projects (that's when most of this stuff gets written :). I'll see what I can do.
I'll echo the other users' comments above -- thanks a lot for taking the time to document this process in such a thorough and helpful way! It takes long enough to figure this stuff out for oneself, and the community out here appreciates the added effort you put in.
Unfortunately on my part, I went through and followed the tutorial step by step, but for the life of me I can't get the button to appear. I've compared it with the code from other apps that do get the button to appear, and it appears to make exactly the same calls, etc. -- but it still won't work for me for some reason.
I was curious, and dropped in your code line for line -- and still no button.
I've tried everything I can think of for debugging, and am at a dead end -- do you have any thoughts of what else I should look for? (Note - I'm trying to add a button so that the admin can paste in a lengthy shortcode automatically.)
Thanks again for the tutorial, and thanks in advance for any suggestions you might have.
Robert
I also haven't tested this with Wordpress 3.0 yet, but will be upgrading her site soon and can update here if that turns out to be the problem.
Anything I would suggest is already in the code above. If you're adding the custom php functions to your functions.php file and putting the JS in editor_plugin.js (and have the matching png file for the button), I don't know why it wouldn't show up for you.
Do you have other custom functions that you know are working in functions.php? You could also throw a console.log statement into the editor js and see if it was being called appropriately…
Thanks for taking the time to write up such a thorough description of the process, though I'm not sure its as easy as you say ;)
FWIW, I created a WordPress Idea to add a functions.php function that would be a wrapper for this kind of logic, so non-js coders could easily add buttons with just one function call: http://wordpress.org/extend...
What I need is a button that behaves the way the bold and italic ones do, managing opening/closing intelligently like the quicktags in the html view do. If I don't find something more specifically appropriate i'll take a stab with your code and see if I can get it to work.
Where would you install this to? I want to make a simple button that adds a Back to top graphical link. but I don't know where to put the directory.
This tutorial is designed to go into your theme's directory, and uses the functions.php file that you'll find there. Do you plan to have just one "back to top" button per post/page? If that's the case, you might want to consider adding one automatically after the content using a hook or by just adding it to the template. If you have multiple buttons, though, and you have an anchor to jump to, then that would be a cool button to add!