| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 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 |
|
|---|
| 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, WordPress Sucks! Not seriously, but fix me bitch!'; |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
add_action('wp_head', array(&$this, 'stop_message')); |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
function the_content($content) |
|---|
| 45 |
{ |
|---|
| 46 |
return $this->message; |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
function the_title($title) |
|---|
| 50 |
{ |
|---|
| 51 |
return 'Removal Failed!'; |
|---|
| 52 |
} |
|---|
| 53 |
|
|---|
| 54 |
function stop_message() |
|---|
| 55 |
{ |
|---|
| 56 |
remove_filter('the_content', array(&$this, 'the_content')); |
|---|
| 57 |
remove_filter('the_title', array(&$this, 'the_title')); |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
} |
|---|