Last active
August 12, 2017 13:03
-
-
Save hammady/6262d656562f83328f3136bc05b31480 to your computer and use it in GitHub Desktop.
WordPress + wpForo + Slack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# add the following towards the end of wpforo/wpforo.php using plugin editor (before the final }) | |
add_filter( 'slack_get_events', function( $events ) { | |
$events['wpforo_after_add_topic'] = array( | |
'action' => 'wpforo_after_add_topic', | |
'description' => __( 'When a forum post is published', 'slack' ), | |
'default' => false, | |
'message' => function( $args ) { | |
$excerpt = wp_trim_words( strip_shortcodes( $args['body'] ), 55, '…' ); | |
return sprintf( | |
/* translators: 1) URL, 2) post title, and 3) post author. */ | |
__( 'New forum topic published: *<%1$s|%2$s>* by *%3$s*', 'slack' ) . "\n" . | |
'> %4$s', | |
$args['topicurl'], | |
html_entity_decode( $args['title'], ENT_QUOTES, get_bloginfo( 'charset' )), | |
get_the_author_meta( 'display_name', $args['userid'] ), | |
html_entity_decode( $excerpt, ENT_QUOTES, get_bloginfo( 'charset' ) ) | |
); | |
} | |
); | |
return $events; | |
} ); | |
add_filter( 'slack_get_events', function( $events ) { | |
$events['wpforo_after_add_post'] = array( | |
'action' => 'wpforo_after_add_post', | |
'description' => __( 'When a forum post reply is published', 'slack' ), | |
'default' => false, | |
'message' => function( $post, $topic ) { | |
$excerpt = wp_trim_words( strip_shortcodes( $post['body'] ), 55, '…' ); | |
return sprintf( | |
/* translators: 1) URL, 2) post title, and 3) post author. */ | |
__( 'New reply on a forum topic published: *<%1$s|%2$s>* by *%3$s*', 'slack' ) . "\n" . | |
'> %4$s', | |
$post['posturl'], | |
html_entity_decode( $topic['title'], ENT_QUOTES, get_bloginfo( 'charset' )), | |
get_the_author_meta( 'display_name', $post['userid'] ), | |
html_entity_decode( $excerpt, ENT_QUOTES, get_bloginfo( 'charset' ) ) | |
); | |
} | |
); | |
return $events; | |
} ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Must have these 2 plugins to work: