coffee2code.com/wp-plugins/hide-or-cut-post-text
Hide (so no one, or only users above a certain userlevel, can see) or cut (so only viewable on post’s permalink page) portion(s) of a post’s text. Link text for cuts can be defined per-cut or omitted, and if used, cut links are uniquely anchored. Quicktag buttons for the new tags are automatically created (but can be disabled).
This plugin gets you four basic features (actual two plus a pair of worthwhile variations):
1.) Hide portion(s) of post text
Any text falling between <!–hide–> and <!–/hide–> will be hidden from visitors, with no indication any text was hidden. Why? Maybe you want to leave yourself a note that no one else (who doesn’t have the ability to edit your post) can ever see. Maybe you want to remove section(s) of a post without removing the post entirely, and you don’t want to lose the original text, or lose track of it by pasting the text elsewhere. I’ve used it to remove documentation for a deprecated plugin. You can include comments to yourself about the hide via <!–hide=PUT YOUR NOTES HERE–>. *NEW* You can also hide text for users below a given user level while showing the text for those at or above the user level: in this manner : <!–hide=”Only high level users should see this” userlevel=9–>Secret stuff here…<!–/hide–>.
2.) Cut portion(s) of post text
While there are various cut plugins already, this was a fallout of my needing the hide feature, and just as well, I like the way this works. Basically, sections of post text falling between <!–cut–> and <!–/cut–> will only be displayed on the post’s permalink page. In place of the cut text in non-single pages is a link (by default it says “Read more…”). Customize the cut link text like so <!–cut=Read what I just cut…–>. Each cut link links to a unique anchor in the individual archive page.
3.) Single/individual archive only
This is a variation of the previous feature. Any text falling between <!–show=single–> and <!–/single–> will only appear in the post’s permalink page, but unlike a typical cut, non-permalink pages will not in any way reflect that text had been cut. I use this on coffee2code.com for each of my plugin announcements; on the permalink page, at the top of the post, you’ll notice there is a navigation bar that links down into the different sections of the post, but on the front page you don’t see the navigation bar.
4.) Non-single pages only
Any text falling between <!–show=nonsingle–> and <!–/show–> will only be visible in non-single pages (any page that the post would appear alongside other posts… i.e. the main page, yearly archive, monthly archive, daily archive, etc). The permalink page for the post will not in any way reflect that text had been cut.
Note: Users who have installed v0.9 of this plugin may want to undo the manually edits to quicktags.js that created the
“cut” and “hide” buttons so that the preferred method for dynamic button creation implemented by this version can be used.
If not, no biggie.
Note: The <!–cut=none–> tag is being phased out in favor of <!–show=single–>
- Download the file hide-or-cut-text.zip and unzip it into your /wp-content/plugins/ directory.
-OR-
Copy and paste the the code ( hide-or-cut-text.phps ) into a file called hide-or-cut-text.php, and put that file into your /wp-content/plugins/ directory. Please ensure you do not introduce any spaces or other characters before the <?php or after the ?> - Optional: Change configuration options in the file to your liking
- In the arguments to function hide_or_cut_text(), $allowed_types is a space-separated list that can include ‘cut’, ‘hide’, and/or ‘show’ (to indicate which you wish to use); the default is ‘cut hide show’; you probably don’t need to change this because you could simply not make use of the tags in your post if you don’t want to
- In the arguments to function cut_link_handler(), change $default_linktext to be the string used for the link for cut text when no per-cut link text is defined
- If you don’t want ANY quicktags created for you in the Post Edit admin page, find and comment out the following line in the code (by putting two forward slashes before it, i.e. “//”):
add_filter('admin_footer', 'add_cuthideshow_buttons');
If you don’t want one or two of the three buttons from being created, edit the array in the function add_cuthideshow_buttons() to remove the button(s).
- Activate the plugin from your WordPress admin ‘Plugins’ page.
function c2c_hide_or_cut_text ($text, $allowed_types='cut hide show')
- $text : The text to be parsed for hiding/cutting appropriately tagged areas (basically the post content)
- $allowed_types : a space-separated list of tags you want to allow to be parsed from your post content; can be ‘cut’, ‘hide’, and/or ‘show’; the default is ‘cut hide show’; you probably don’t need to change this because you could simply not make use of the tags in your post if you don’t want to
function c2c_cut_link_handler ($linktext, $default_linktext='Read more...')
A helper function called by hide_or_cut_text().
- $linktext : custom per-cut link text as parsed from original text
- $default_linktext : the string used for the link for cut text when no per-cut text is defined
See this post for an example of post text (as seen in the admin edit post page).
This post is the rendered example of the previous sample post text.
- 11 Apr 2005 : v1.2 —
- Fix so that userlevel= will be acknowledged even when no comment text is provided for a ‘hide’
- userlevel= argument can now optionally be double-quoted
- 28 Mar 2005 : v1.1 —
- Added the function
c2c_hide_handler()
to support ability to define userlevel= attribute to hide tag; only users at or above the specified userlevel are shown the text - Switch from using
$single
tois_single()
- Prepended all functions with “c2c_”
- Removed shortcut specifier in JavaScript calls to create QuickTag buttons
- Changed license from BSD-New to MIT
- Plugin is no longer WordPress 1.2 compatible
- Added the function
- 17 Aug 2004 : v0.91 — Various fixes and new features:
- New tags: <!–show=single–> (replaces the soon-to-be-phased-out <!–cut=none–>) and <!–show=nonsingle–>
- Per-cut link text and ‘hide’ comments can be double-quoted: <!–cut = “Read what I cut…” –>
- Quicktag buttons (the buttons appearing over the text entry field when writing a post) are now automatically created for ‘cut’, ‘hide’, and ‘show’ by this plugin.
- The newline character has been removed from the output of the cut-link links to allow for inline cutting.
- The second argument to hide_or_cut_text(),
$types
, was changed to$allowed_types
, which is now a space-separated list of the tags to allow.
- 25 Jul 2004 : v0.9 — Released to the public
Copyright (c) 2004-2005 by Scott Reilly (aka coffee2code)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47 replies on “Plugin: Hide or Cut Post Text”
[…] have text that only you can see (in the edit screen) to blog entries. Documentation is at coffee2code This entry was poste […]
[…] led under: Blogging — Hendikins @ 2:54 pm
I’ve just installed the Hide or Cut Post Text Plugin for WordPress. < !-cut=I wonder if the [...]
[…] ere was a cut function. There wasn’t, but there’s a plugin for it. Run over to here if you want it too. Be prepared for extreme ove […]
Is there a way to do the opposite and cut certain portions of the post from the permalink page but viewable in any other page?
There will be soon. Stay tuned.
It would be really neat if the “hide” text were visible to the page admin (viewlevel=10) and not visible to other viewers!
Just discovered this plugin. Really wanted something like this ever since I saw it on Live Journal. Works great! Thanks!!
oddities with the new 1.5 Strayhorn include the [more] tag not working when you only show a single post.
i thought this plug would be a much better alternative…
seems it suffers from the same issues.
[hide] works as expected
[show] and [cut] don’t function on the index, as only one post is showing.
i’d like to ONLY show the contents between the tag when i am at a permalink, some text to demonstrate that there’s more would be good too.
somehow even this plug is thinking that the index is a permalink.
c’mon 1.5.1!
[…] pe can already do! I still like it better, even though the CSS is all messy and confusing. Hide or Cut Post Text comes from coffee2code.com.< !–/cut–> […]
[…] so this ought to work, you know? If not, then I guess I just have to say good bye to this ever clever plugin. This entry was posted […]
[…] quo; gsdf sdfgsdg sdfg g asdasdasdasd This post demonstrates the Hide or Cut Post Text plugin. The content that generates this post c […]
[…] « asdasdasdasd asdasdas This post demonstrates the Hide or Cut Post Text plugin. The content that generates this post c […]
Just wondering if you’d consider this extra feature:
A tag (perhaps ?) that will allow you to only display part of a post to the general public but the entire post to those that are registered on my site and logged in.
This is what I want to do: create discography pages for a band site with all of the album info available to the general public. Those that are registered on my site and logged in will be able to see that information PLUS a Flash Play button next to each song.
Something like this site:
www.dubtribe.com/index.php?p=53
But with the play button ONLY appearing if the person is logged in.
Is this a possible addition to your plugin, or should I just use the PHP Exec Plugin and wrap the play button in php code that detects whether the person is logged in?
(Code to display the play button.)
(Do not display the play button.
[…] ber nicht mobil-tauglich (auf private setzen, custom field definieren etc). Jetzt habe ich hide or cut post text entdeckt, was mehr oder weniger als Nebenprodu […]
Plugin updated to v1.1
A bit belated in adding this comment, but the plugin was updated on 28 Mar 2005 with the following changes:
* Added the function c2c_hide_handler() to support ability to define userlevel= attribute to hide tag; only users at or above the specified userlevel are shown the text
* Switch from using $single to is_single() (‘single’ now works in WP1.5 without the need for the bugfix coming in WP1.5.1)
* Prepended all functions with “c2c_”
* Removed shortcut specifier in JavaScript calls to create QuickTag buttons
* Changed license from BSD-New to MIT
* Plugin is no longer WordPress 1.2 compatible
fernando: With v1.1 of the plugin, the ‘show’ and ‘cut’ tags should now work as expected.
Mau, hcm: v1.1 also introduces a feature which addresses what you want. You can use the ‘hide’ tag to hide text from users below a given userlevel. Under the “Notes” section above, in the explanation of the ‘hide’ tag, you’ll find out how to use it.
I’ve been using this plugin for quite awhile now and i really love it, thanks for such a great and useful plugin!
Awesome stuff! Love the plugin! I did notice that a forward slash is getting added before apostrophes, though. Anyone else see that?
After updating to WP1.5.1, I notice posts within a Category selection shows the text of a cut-link (in my case: “>>> Read more”) appears, but its no longer hot-linked to the post. I could swear this worked in v1.5. Any ideas on how to make it functional within Categories again?
Continues to work fine on blog front.
Cheers!
[…] 005 Testing. I got this new plugin called, “hide or cut text” . If you use the “read more” opt […]
[…] my main post, too I thought I found a solution by using my just discovered and installed Hide or Cut Post Text WP plugin, wherein I could display the ad on t […]
Yeah, I’m getting the same forward slash being added on apostrophes—anyone have a solution for that? Thanks.
Great plugin otherwise.
don´t works for me. 🙁
i got wordpress 1.5.2.
is it only for 1.5?
ah works now. in posts.
but it does not works in pages?
[…] coffee2code.com » Plugin per ocultar text d’un post [en] — Classificat com plugins wordpress […]
Does anyone know how to define the userlevel so that anyone who is logged in can see the hidden text?
userlevel=0 doesnt work, and userlevel=1 requires me to upgrade anyone who creates an account…
any ideas?
Tim
[…] After getting sick of seeing long entries on this site, I’ve decided to install a “lj-cut” type plugin. It works very well. Click here to download. […]
[…] Well, the lovely Jessie just shared this Hide or Cut Post Text plugin on her blog, and thank goodness!! I’ve been looking for one (that actually works ). So now I’m trying it out […]
[…] I’m also thinking about installing several other WordPress plugins. I’ve been looking for an extended entry plugin, but the only one that I can find that does what I want is one that I CANNOT get to work here. See, what I want is not really an excerpt plugin, which just posts excerpts of every entry, but rather a plugin that “cuts” entries like the LJ-cut feature of LiveJournal. I just want something that I can use to split up longer entries so they don’t take up so much room on my main pages. If anyone knows of anything other than wp-Cut (dead link), please tell me. Hide or Cut Post Text is the plugin I was able to install, but I had no success in getting the thing to work. WP just spat the code back out at me rather than executing it. […]
[…] www.coffee2code.com/archives/2004/07/25/plugin-hide-or-cut-post-text/ […]
What would be good in this plugin, is an option to tell those viewing a post that it has been cut or hidden.
So if you have cut a post for unregistered viewers they can see that it is available if they register, or that this post is available to moderators and so on.
[…] » Plugin: Hide or Cut Post Text « « Blog Archive coffee2code.com “Any text falling between and will be hidden from visitors, with no indication any text was hidden. Why? Maybe you want to leave yourself a note that no one else (who doesn’t have the ability to edit your post) can ever see” This is very useful — I often want to put personal notes to myself about something. 0 votes | […]
grrrr. why is it not working for me? it still shows.
i post my entry with and
but what’s wrong?
it there suppose to be a space between the anchors or something?
The dynamic button creation method doesn´t seem to work in my case (WP 2.0.2 – plugin version 1.2 first time installed and working).
How to add them manually to quicktags.js?
Thank you for this great piece of code.
[…] You can get the plugin here: Hide or Cut Post Text by Scott Reilly. […]
I installed this plug-in with the sole purpose of using the cut feature. On my most recent entry I wanted to to cut the text where my girl survey starts so people who didn’t want to read it didn’t have to. When I went to edit my post, I put the cut tags in but still nothing is working. What am I doing wrong?
Okay. I’ve installed the plugin a long time ago, but never got around to work out what’s wrong.
Tried it today again and still it wont work.
What’s wrong?
does it work with 2.05?
Works fine. Thank you!
The closing tag for
<!--show=single-->
should be<!--/show-->
instead of<!--/single-->
. Right?I just installed your plugin! It works beautifully with the latest version of wordpress (2.06). My question is, If i use the hide functions without the user level, will my registered users still be able to view the text that i have hidden? or no?? When i used the userlevel function the hidden text was still viewable. So i don’t know if i’m doing it right. With the part “users with higher level should view this” is that where we put the hidden text? or is it where it says “secret stuff”.
The plugin doesn’t work with the latest version of wordpress 2.1; when I go to “write” in the admin area it doesn’t show the quicktags anymore of the “cut”, “hide”, “show” etc. The quicktags only show when i edit the post; and i don’t know why. I hope you will consider updating this plugin for the latest version of wordpress, because i really, really, REALLY enjoy using it on my website. 🙂
Seconding request for 2.1 support. 🙂
I’m working on a (better) LiveJournal->Wordpress converter, and it would be awesome to use your plug-in for lj-cut conversion.
Yeah, I’m having the same issue that Julie is having. And I love this plug-in and I didn’t even use it more than once! Please make it compatible with 2.1. *sad puppy eyes*
[…] post demonstrates the Hide or Cut Post Text plugin. The content that generates this post can be found in the previous […]
[…] installed Hide or Cut Post Text and integrated my LiveJournal and InsaneJournal crossposters with LJ Crossposter Plus so that I can […]
[…] Duplicate “lj-cut” functionality: Hide or Cut Post Text. […]
[…] I’ve found the following plugin (although I’ve yet to load a plugin to WordPress):Â coffee2code.com/archives/2004/07/25/plugin-hide-or-cut-post-text/ Published […]