Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Created November 15, 2015 15:29
Show Gist options
  • Save wpscholar/b38b3e33077435a4df79 to your computer and use it in GitHub Desktop.
Save wpscholar/b38b3e33077435a4df79 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