Ticket #3875: testplugin.php

File testplugin.php, 1.5 kB (added by darkdragon, 1 year ago)

Proof of Concept of Bug and Proof that Patch works! If you get the not so friendly message, then the current plugin.php needs to be patched.

Line 
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, 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 }