Silent Publish Silent Publish

Silent Publish

Created by: Scott Reilly

Rating:
Downloaded: 5k times

This plugin gives you the ability to publish a post without triggering pingbacks, trackbacks, or notifying update services.

A “Publish silently?” checkbox is added to the “Add New Post” and “Edit Post” admin pages (the latter only for unpublished posts). If checked when the post is published, that post will not trigger the pingbacks, trackbacks, and update service notifications that would typically occur.

In every other manner, the post is published as usual: it’ll appear on the front page, archives, and feeds as expected, and no other aspect of the post is affected.

While trackbacks and pingsbacks can already be disabled from the Add New Post/Page page, this plugin makes things easier by allowing a single checkbox to disable those things, in addition to disabling notification of update services which otherwise could only be disabled by clearing the value of the global setting, which would then affect all authors and any subsequently published posts.

If a post is silently published, a custom field ‘_silent-publish’ for the post is set to a value of 1 as a means of recording the action. However, this value is not used after publish for any purpose as of yet. Nor is the custom field unset or changed if the post is later re-published.

Also see my Stealth Publish plugin if you want to make a new post but prevent it from appearing on the front page of your blog and in feeds. (That plugin incorporates this plugin’s functionality, so you won’t need both.)

Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage

Hooks

The plugin is further customizable via three filters. Code using these filters should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain). Less ideally, you could put them in your active theme’s functions.php file.

c2c_silent_publish_meta_key (filter)

The ‘c2c_silent_publish_meta_key’ filter allows you to override the name of the custom field key used by the plugin to store a post’s silent 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 ‘_silent-publish’.

Example:

/**
 * Defines a custom meta key to be used by Silent Publish.
 *
 * @param string $custom_field_key The default custom field key name.
 * @return string
 */
function override_silent_publish_key( $custom_field_key ) {
    return '_my_custom_silent-publish';
}
add_filter( 'c2c_silent_publish_meta_key', 'override_silent_publish_key' );

c2c_silent_publish_default (filter)

The ‘c2c_silent_publish_default’ filter allows you to override the default state of the ‘Silent 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 Silent Publish? checkbox checked by default.
add_filter( 'c2c_silent_publish_default', '__return_true' );

c2c_silent_publish_post_types (filter)

The ‘c2c_silent_publish_post_types’ filter allows you to override the post types that can be silently published.

Arguments:

  • $post_types (array): Array of post type names.

Example:

/**
 * Disable Silent Publish for a custom public post type 'book'.
 *
 * @param array $post_types Array of post type names.
 * @return array
 */
function my_c2c_silent_publish_post_types( $post_types ) {
    $post_types = array_flip( $post_types );
    unset( $post_types[ 'book' ] );
    return array_keys( $post_types ).
}
add_filter( 'c2c_silent_publish_post_types', 'my_c2c_silent_publish_post_types' );

Screenshots

  • The "Status & Visibility" panel when creating a new post (when using the block editor) that shows the 'Silent publish?' checkbox used to enable silent publish. If you plan to make use of it, be sure to have it checked before publishing the post.
  • The "Status & Visibility" panel when editing a post that was published with silent publish enabled. The message "This post was silently published." is shown to indicate the post was silently published. If the post has been published without silent publish enabled, no text or checkbox would be shown in its place.
  • The 'Publish' sidebar box on the Add New Post admin page (for versions of WordPress older than 5.0, or later if the new block editor aka Gutenberg is disabled). The 'Publish silently?' checkbox is integrated alongside the existing fields.
  • The 'Publish' sidebar box when editing a post (under the classic editor) that was published with silent publish enabled. The message "This post was silently published." is shown to indicate the post was silently published. If the post has been published without silent publish enabled, no text or checkbox would be shown in its place.
  • The 'Silent publish?' checkbox displaying help text when hovering over the checkbox.
  • The quick edit panel, which also includes the 'Silent publish?' checkbox allowing the feature to be enabled for unpublished posts. And as seen in screenshots 2 and 4, if the post was already silently published the checkbox would instead display the message "This post was silently published.".
  • The admin post listing of posts showing the mute icon in the 'Date' column to indicate the post was (or will be) silently published.

Categories

Get New Themes & Resources