WordPress.org

Make WordPress Core

Ticket #3875: testplugin.php

File testplugin.php, 1.5 KB (added by darkdragon, 13 years 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/*
3Plugin Name: Plugin Test
4Plugin URI: http://www.santosj.name
5Description: Horriblely break WordPress
6Author: Jacob Santos
7Version: code base
8Author URI: http://www.santosj.name
9*/
10
11new TestPlugin();
12
13class 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}