Tag Info

Hot answers tagged

8

If it's getting too hard and complicated, you can simply add new buttons by using jQuery. Simply clone an existing or create a new button, and append it to the editor's toolbar. You can wrap the javascript with a php function, and run it in the admin footer or something. Or you can use the edButton function. Here is a dirty and fast written example for ...


6

The toolbar / editor used on Stack Exchange websites (and in my plug-in WP-MarkDown) is PageDown. This comes with three JavaScript files: One that handles MarkDown to HTML conversion One that handles sanitization One that handles the editor (the toolbar and previewer) Included in the latter are the MarkDown keyboard shortcuts you mentioned. The ...


6

I tried for a bit and could not get this to work perfectly, but it's close, it's hard to extend with the <form> for the popup styles being hardcoded, thought possible with more work. To get started you can: Enqueue the link popup javascript and styles, the main .js file is wp-includes/wplink.js. Depending on where you loading this you might need to ...


5

I am using the plugin AddQuicktag from @bueltge in some blogs to create a separate <i> button: That creates a nice little button with the text i!, and WordPress will not touch it.


4

It should be 'media_buttons' => FALSE. array ( 'textarea_rows' => 5, 'media_buttons' => FALSE, 'teeny' => TRUE, 'tinymce' => TRUE ) … creates this editor:


4

With the quicktag_settings filter: function wpa_47010( $qtInit ) { $qtInit['buttons'] = 'strong,em,link,block,del,img,ul,ol,li,code,more,spell,close,fullscreen'; return $qtInit; } add_filter('quicktags_settings', 'wpa_47010'); The default is: $qtInit['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close'; Though ...


4

For posts: add_action('init', 'my_custom_init'); function my_custom_init() { remove_post_type_support( 'post', 'editor' ); } See Codex. For custom post types that you register, you can specify what 'features' it supports when you register it it use the 'supports' arguments. For custom post types that are not registered by you can use the above with ...


3

That's handled by a filter called wpautop (declared in wp-includes/formatting.php, line 189). You can remove it with this: remove_filter ('the_content','wpautop');


3

To avoid the line break when posting 2 images side by side assign the alignleft or alignright class to them and put them on the same line in the editor without skipping any spaces between them. Example: <img src="/wp-content/uploads/your_image.jpg" alt="" class="alignleft" /><img src="/wp-content/uploads/your_image2.jpg" alt="" ...


3

See the following in wp-includes/js/quicktags.dev.js /** * Main API function for adding a button to Quicktags * * Adds qt.Button or qt.TagButton depending on the args. The first three args are always required. * To be able to add button(s) to Quicktags, your script should be enqueued as dependent * on "quicktags" and outputted in ...


3

Add to function.php add_filter('tiny_mce_before_init', 'tiny_mce_before_init'); And function tiny_mce_before_init: function tiny_mce_before_init($init) { $init['setup'] = "function(ed) { ed.onBeforeSetContent.add(function(ed, o) { if ( o.content.indexOf('<pre') != -1) { o.content = ...


3

It needs a bit of javascript to do that. You need a listener and some actions. Here we go... At first enqueueing the javascript to the post and post new screens: PHP: add_action( 'plugins_loaded', 'keyboradshortcuts4htmleditor', 10, 0 ); function keyboradshortcuts4htmleditor(){ add_action( 'admin_print_scripts-post-new.php', ...


2

The list of allowed elements and attributes is stored in the global variable $allowedposttags which is set in wp-includes/kses.php. To override it create a simple mu plugin with the following content: <?php # -*- coding: utf-8 -*- /** * Plugin Name: Enable placeholder attribute for input elements in post tags. * Version: 2012.07.18 */ add_action( ...


2

The Problem It seems that you're using the normal theme template files for posts and pages to display your custom post type. This means, that you also got the wp_head() hook and other template, that output default (post/page specific) things. The solution Add a template file to your theme, that's named single-{$post_type}.php and nothing than the loop ...


2

Simple example that will add a Quicktag button that calls a Javascript function when it is clicked... <?PHP function _add_my_quicktags(){ ?> <script type="text/javascript"> QTags.addButton( 'alert', 'Alert Button', simple_alert ); function simple_alert() { alert('hello, example callback function'); } ...


2

1. Filtering the content Here's a one-function content filter to meet the above four requirements: add_filter( 'the_content', 'strip_some_paragraphs', 20 ); function strip_some_paragraphs( $content ) { $content = preg_replace( '/<p>(([\s]*)|[\s]*(<img[^>]*>|\[[^\]]*\])[\s]*)<\/p>/', '$3', $content ); ...


2

This is a duplicate of another question and (I'm sorry!) a bug in WP. As @Otto says in the comments to that question, this is an edge case problem (not many users know or care about using comments) and is not likely to get fixed soon unless you'd be interested in contributing. EDIT: I looked for more information on this in trac, and found a few related ...


2

Per the link provided in my comment to your question, if you wish to prevent the editing of files by WordPress, just disable the file editor. To do that add the following to your site's wp-config.php file: define('DISALLOW_FILE_EDIT',true); Or to disable the file editor and the plugin and theme installation/update system: ...


2

Because of the way that wpautop works, I would expect that if you had a newline, or or maybe a space in your URL. I can't seem to get a space or newline to save from the admin interface, but it is trivial to insert by editing the WP_HOME and WP_SITEURL constants into wp-config.php... but that causes every page to 404 or worse. There must be something ...


2

Along with what @Chris_O said, when you are in the editor for the pictures select Left on one and Right on the other. This applies the alignleft and alignright classes, respectively. Your theme has to have the CSS classes defined, if you have one from vendor, they are more then likely there, but in case they aren't, just go into the theme editor and add ...


2

Here is an alternative, rather than removing the editors, they are simply hidden from use for anyone who is not an Administrator. I prefer hiding, rather than removing. I'm sure there are cases for both. //Hide New Post Options from all except Administrator function hide_post_page_options() { if ( !current_user_can( 'administrator' ) ) return; ...


2

function extend_tinymce( $values ) { $elements = 'pre[id|class|title|rel]'; if ( isset( $values['extended_valid_elements'] ) ) { $values['extended_valid_elements'] .= ',' . $elements; } else { $values['extended_valid_elements'] = $elements; } return $values; } add_filter('tiny_mce_before_init', 'extend_tinymce'); The ...


2

That may be a bit problematic. I use the plugin SyntaxHighlighter Evolved, but as the plugin description says (my emphasis): TIP: Don't use the Visual editor if you don't want your code mangled. TinyMCE will "clean up" your HTML. Another option is to embed Gists (or similar) using a Shortcode to pass the URL and let PHP render the script tag (as ...


2

Background This issue revolves around the removal of empty <span></span> elements in TinyMCE when saving a post or switching between between the Visual and Text editor tabs. The problem is inherent to core functionality (as of trunk version 4.0-alpha-20140602) and is unchangeable via the standard WordPress APIs, as is mentioned in ticket #26986. ...


1

It's a simple solution/workaround, but a Shortcode could be used. As birgire noted, the whole anchor can be the Shortcode. And for ease of use, this article has a solution: adding a shortcode button in TinyMCE. You could have a dropdown with a selection of anchors, turning the fight in your favor ;) WP editor is really a PITA when it comes to this kind of ...


1

I am not aware of clean native solution, however there have been at least one plugin in the past Save Editor Scroll Position (note - very outdated) trying to address this and might serve like prior art. There is also open trac ticket #18943 Scroll back to previous editor position after post save/update, however without patch suggestions or core developer ...


1

It may help you to render content in your theme directly without the_content filter, although you would loose thigns like oembeds etc e.g.: echo $post->post_content; However this sounds like a symptom of a hack. If you have something complex like an embed then you should be using either oembed ( e.g. youtube, don't be pasting the raw embed stuff ) or ...


1

I had this issue once and it was caused, as Ashfame comments and Tom J Novell mentions, by a double hackery stuff. My functions.php was removing some the_content filters and a plugin (don't remember which) was doing the same. There are some basic troubleshooting steps that you may take. They are outlined in this post by the always cognoscenti Ipstenu. I'll ...


1

I'd say it's impossible... For one, there's no hook inside the file /wp-admin/theme-editor.php. And last but not least, if you try one of this, it dumps an error: /wp-admin/theme-editor.php?file=css%2Fstyle.css&theme=twentyeleven /wp-admin/theme-editor.php?file=css/style.css&theme=twentyeleven Case you find a workaround, this code injects a ...


1

Download and install HTML Editor Reloaded Plugin and go to setting pages and you can add your own new buttons. http://wordpress.org/extend/plugins/html-editor-reloaded/



Only top voted, non community-wiki answers of a minimum length are eligible