| 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | Plugin Name: Plugin Test
|
|---|
| 4 | Plugin URI: http://www.santosj.name
|
|---|
| 5 | Description: Horriblely break WordPress
|
|---|
| 6 | Author: Jacob Santos
|
|---|
| 7 | Version: code base
|
|---|
| 8 | Author URI: http://www.santosj.name
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | new TestPlugin();
|
|---|
| 12 |
|
|---|
| 13 | class TestPlugin
|
|---|
| 14 | {
|
|---|
| 15 | var $message = 'Hey, message was not updated! WTF?';
|
|---|
| 16 |
|
|---|
| 17 | function TestPlugin()
|
|---|
| 18 | {
|
|---|
| 19 | $this->construct();
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | function __construct()
|
|---|
| 23 | {
|
|---|
| 24 | add_action('init', array(&$this, 'init'));
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | function init()
|
|---|
| 28 | {
|
|---|
| 29 | add_filter('the_content', array(&$this, 'the_content'));
|
|---|
| 30 | add_filter('the_title', array(&$this, 'the_title'));
|
|---|
| 31 |
|
|---|
| 32 | // This illustrates, why it is useful to remove a plugin
|
|---|
| 33 | // It could be further illustrated by plugins that wish to check and
|
|---|
| 34 | // remove filters from other plugins and then add them again. Or
|
|---|
| 35 | // move their own hooks that are no longer needed, while still in
|
|---|
| 36 | // loop.
|
|---|
| 37 |
|
|---|
| 38 | $this->message = 'Removal Failed! Not seriously, but fix me!';
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 | add_action('wp_head', array(&$this, 'stop_message'));
|
|---|
| 42 | add_action('admin_head', array(&$this, 'stop_message'));
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | function the_content($content)
|
|---|
| 46 | {
|
|---|
| 47 | return $this->message;
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | function the_title($title)
|
|---|
| 51 | {
|
|---|
| 52 | return 'Removal Failed!';
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | function stop_message()
|
|---|
| 56 | {
|
|---|
| 57 | remove_filter('the_content', array(&$this, 'the_content'));
|
|---|
| 58 | remove_filter('the_title', array(&$this, 'the_title'));
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | }
|
|---|