Stealth Publish

Author:Scott Reilly
Version:2.3
Last update:2013-01-04
Compatibility:WP 2.9 – 3.5.1
Comments:go here
Download:[ zip ]
Description:

Prevent specified posts from being featured on the front page or in feeds, and from notifying external services of publication. Beneficial in instances where you want to publish new content without any fanfare and just want the post added to archive and category pages and its own permalink page.

Extended Description

Prevent specified posts from being featured on the front page or in feeds, and from notifying external services of publication. Beneficial in instances where you want to publish new content without any fanfare and just want the post added to archive and category pages and its own permalink page.

Posts which are saved with the checkbox “Stealth publish?” checked will no longer be featured on the front page of the blog, nor will the post be included in any feeds.

A stealth published post will also not notify any external services about the publication. This includes not sending out pingbacks, trackbacks, and pings to update services such as pingomatic.com. This behavior can be overridden via the ‘c2c_stealth_publish_silent’ filter (see Filters section).

NOTE: Use of other plugins making their own queries against the database to find posts will likely allow a post to appear on the front page. But use of the standard WordPress functions for retrieving posts (as done for the main posts query and the recent posts widget) should not allow stealth published posts to appear on the home page.

NOTE: If you use this plugin, you do not need to use my Silent Publish plugin as that functionality is incorporated into this plugin. Alternatively, if you like the silent publishing feature but want your new posts to appear on your blog’s front page and in feeds, then just use the “Silent Publish” plugin.

Links: Plugin Homepage | Plugin Directory Page | Author Homepage

Find out more at the plugin’s WordPress Plugin Repository page.

Screenshots

Click to see full-size image.

  • stealth-publish screenshot 1

    A screenshot of the ‘Publish’ sidebar box on the Add New Post admin page. The ‘Stealth publish?’ checkbox is integrated alongside the existing fields.

  • stealth-publish screenshot 2

    A screenshot of the ‘Stealth publish?’ checkbox displaying help text when hovering over the checkbox.


Installation

  1. Whether installing or updating, whether this plugin or any other, it is always advisable to back-up your data before starting
  2. Unzip stealth-publish.zip inside the /wp-content/plugins/ directory (or install via the built-in WordPress plugin installer)
  3. Activate the plugin through the ‘Plugins’ admin menu in WordPress
  4. For posts that you do not want to be featured on the front page and feeds, check the “Stealth publish?” checkbox when creating/editing a post

Filters

The plugin is further customizable via three filters. Typically, these customizations would be put into your active theme’s functions.php file, or used by another plugin.

c2c_stealth_publish_meta_key (filter)

The ‘c2c_stealth_publish_meta_key’ filter allows you to override the name of the custom field key used by the plugin to store a post’s stealth publish status. This isn’t a common need.

Arguments:

  • $custom_field_key (string): The custom field key to be used by the plugin. By default this is ‘_stealth-publish’.

Example:

add_filter( 'c2c_stealth_publish_meta_key', 'override_stealth_publish_key' );
function override_stealth_publish_key( $custom_field_key ) {
    return '_my_custom_stealth-publish';
}

c2c_stealth_publish_silent (filter)

The ‘c2c_stealth_publish_silent’ filter allows you to override whether the plugin also ensure the post gets published silently (i.e. without sending out pingbacks, tracbacks, and pings to update services).

Arguments:

  • $publish_silently (bool): Should stealth published posts also be published silently? By default this is ‘true’.
  • $post_id (int): The ID of the post being published.

Example:

// Disable silent publishing for stealth published posts
add_filter( 'c2c_stealth_publish_silent', 'override_stealth_publish_silent' );
function override_stealth_publish_silent( $publish_silently, $post_id ) {
    return false;
}

c2c_stealth_publish_default (filter)

The ‘c2c_stealth_publish_default’ filter allows you to override the default state of the ‘Stealth Publish?’ checkbox.

Arguments:

  • $state (boolean): The default state of the checkbox. By default this is false.
  • $post (WP_Post): The post currently being created/edited.

Example:

// Have the Stealth Publish? checkbox checked by default.
add_filter( 'c2c_stealth_publish_default', '__return_true' );

Frequently Asked Questions

Q. Why would I want to stealth publish a post?
A. This is probably the kind of thing that you would recognize the need for or you don’t. It’s beneficial in instances where you want to publish new content without any fanfare and just want the post added to archive and category pages and its own permalink page.

Q. Can I have the checkbox checked by default?
A. Yes. See the Filters section (under Other Notes) and look for the example using the ‘c2c_stealth_publish_default’ filter. You’ll have to put that code into your active theme’s functions.php file.

Q. Why is the checkbox still present when editing a post that has already been published?
A. The checkbox is always present since it continues to have an effect on published posts, such as preventing the post from appearing on the front page or in feeds. You may, after publication, decide to not have the post be stealthy. In such a case, you can do so directly by editing the post without needing to change it back to draft and then republishing it.

Q. How does the plugin know which posts are stealth published?
A. (This is a developer-level question that doesn’t affect general users.) The plugin assigns a custom field of “_stealth-publish” with a value of “1″. Unless, of course, the name of the custom field was changed via use of the ‘c2c_stealth_publish_meta_key’ filter.


Release Log

2.3

  • Deprecate ‘stealth_publish_meta_key’ filter in favor of ‘c2c_stealth_publish_meta_key’ (but keep it temporarily for backwards compatibility)
  • Deprecate ‘stealth_publish_silent’ filter in favor of ‘c2c_stealth_publish_silent’ (but keep it temporarily for backwards compatibility)
  • Don’t allow a blank string from ‘c2c_stealth_publish_meta_key’ to override the default meta key name
  • Remove private static $textdomain and its use; include textdomain name as string in translation calls
  • Remove function load_textdomain()
  • Add check to prevent execution of code if file is directly accessed
  • Re-license as GPLv2 or later (from X11)
  • Add ‘License’ and ‘License URI’ header tags to readme.txt and plugin file
  • Minor improvements to inline and readme documentation
  • Regenerate .pot
  • Minor code reformatting
  • Remove ending PHP close tag
  • Note compatibility through WP 3.5+
  • Tweak installation instructions in readme.txt
  • Update copyright date (2013)
  • Move screenshots into repo’s assets directory

2.2.1

  • Add version() to return plugin’s version
  • Update readme with example and documentation for new filter
  • Note compatibility through WP 3.3+
  • Update screenshots for WP 3.3
  • Use DIRECTORY_SEPARATOR instead of hardcoded ‘/’
  • Create ‘lang’ subdirectory and move .pot file into it
  • Regenerate .pot
  • Add ‘Domain Path’ directive to top of main plugin file
  • Add link to plugin directory page to readme.txt
  • Update copyright date (2012)

2.2

  • Fix bug where using Quick Edit on post caused Stealth Publish status to be cleared
  • Add filter ‘c2c_stealth_publish_default’ to allow configuring checkbox to be checked by default
  • Note compatibility through WP 3.2+
  • Minor code formatting changes (spacing)
  • Fix plugin homepage and author links in description in readme.txt

2.1

  • Switch from object instantiation to direct class invocation
  • Explicitly declare all functions public static and class variables private static
  • Note compatibility through WP 3.1+
  • Update copyright date (2011)

2.0.2

  • Bugfix for auto-save losing value of stealth publish status

2.0.1

  • Bugfix for WP 2.9.2 compatibility

2.0

  • Encapsulate all code in new c2c_StealthPublish class
  • Now also silently publish posts that are stealth published (i.e. don’t send out pingbacks, tracbacks, and pings to update services)
  • Add checkbox labeled “Stealth publish?” to Publish meta_box rather than requiring direct use of custom fields
  • Allow overriding of custom field used via ‘stealth_publish_meta_key’ filter (default value is ‘_stealth_publish’)
  • Add filter ‘stealth_publish_meta_key’ to allow overriding custom field key name
  • Add filter ‘stealth_publish_silent’ to allow overriding silent publish feature
  • Add class of ‘c2c-stealth-publish’ to admin UI div containing checkbox
  • Change custom field used to be a hidden custom field by prepending ‘_’ to the name
  • Accept second arg to stealth_publish_where()
  • Completely re-implemented find_stealth_published_post_ids()
  • Full support for localization
  • Store plugin instance in global variable, $c2c_stealth_publish, to allow for external manipulation
  • Remove docs from top of plugin file (all that and more are in readme.txt)
  • Minor code reformatting (spacing)
  • Add PHPDoc documentation
  • Note compatibility with WP 3.0+
  • Drop compatibility with versions of WP older than 2.9
  • Add screenshots
  • Update copyright date
  • Add package info to top of plugin file
  • Add Changelog, Filters, and Upgrade Notice sections to readme.txt
  • Add .pot file
  • Add to plugin repository

1.0

  • Initial release

Copyright & Disclaimer

Copyright © 2010-2013 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.