Hooks & Filters

Updated


Content Notify contains a number of useful filters so that you can customise various aspects of the plugin. These are:

Filter: Post Types

cn\post_types\exclude

Purpose: Exclude post types from appearing in the select box in both the front-end and admin subscription form.

Example:

1
2
3
4
5
6
7
function cn_filter_post_types( $post_types ) {
$post_types_additional = array( 'post' );
$post_types = array_merge( $post_types, $post_types_additional );

return $post_types;
}
add_filter( 'cn\post_types\exclude', 'cn_filter_post_types' );

Filter: Authors

cn\authors\exclude

Purpose: Exclude authors from appearing in the select box in both the front-end and admin subscription form.

Example:

1
2
3
4
5
6
function cn_filter_authors( $authors ) {
$authors = array( 'admin' );

return $authors;
}
add_filter( 'cn\authors\exclude', 'cn_filter_authors' );

Filter: Taxonomies

cn\taxonomies\exclude

Purpose: Exclude post types from appearing in the select box in both the front-end and admin subscription form.

Example:

1
2
3
4
5
6
7
function cn_filter_taxonomies( $taxonomies ) {
$taxonomies_additional = array( 'category' );
$taxonomies = array_merge( $taxonomies, $taxonomies_additional );

return $taxonomies;
}
add_filter( 'cn\taxonomies\exclude', 'cn_filter_taxonomies' );

Filter: Subject – Publish

cn\alert\subject\publish

Purpose: Filter for the subject field when a publish status is used on any post type.

Example:

1
2
3
4
5
6
function cn_filter_subject_publish( $subject ) {
$subject = __( 'New ' . $post_type_name[0]['single'] . ' Published - ' . $site_title, 'cn' );

return $subject;
}
add_filter( 'cn\alert\subject\publish', 'cn_filter_subject_publish' );

Filter: Subject – Update

cn\alert\subject\update

Purpose: Filter for the subject field when an update status is used on any post type.

Example:

1
2
3
4
5
6
function cn_filter_subject_update( $subject ) {
$subject = __( $post_type_name[0]['single'] . ' Updated - ' . $site_title, 'cn' );

return $subject;
}
add_filter( 'cn\alert\subject\update', 'cn_filter_subject_update' );

Filter: Message

cn\alert\message

Purpose: Filter for the message field used on any post type.

Example:

1
2
3
4
5
6
7
8
9
10
11
function cn_filter_message( $message ) {
$message = "
<h1>"
. $post->post_title . "</h1>
"
. $post->post_content . "

Unsubscribe: <a href="
' . $cn_unsubscribe_url . '">" . $cn_unsubscribe_url . "</a>
"
;

return $message;
}
add_filter( 'cn\alert\message', 'cn_filter_message' );