Skip to content

Instantly share code, notes, and snippets.

@jimboobrien
Forked from wpscholar/post-content-appender.php
Created September 20, 2017 22:41
Show Gist options
  • Save jimboobrien/1d537940de76e0132464e1b7903acc67 to your computer and use it in GitHub Desktop.
Save jimboobrien/1d537940de76e0132464e1b7903acc67 to your computer and use it in GitHub Desktop.
Sample class to demonstrate how classes can be used in WordPress.
<?php
/**
* Class PostContentAppender
*/
class PostContentAppender {
protected $append = '';
public function __construct( $append ) {
$this->append = $append;
add_action( 'the_content', array( $this, 'append_content' ) );
}
public function append_content( $content ) {
return $content . $this->append;
}
}
$appender = new PostContentAppender('<p>Posted by Micah Wood</p>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment