Ticket #14856: test-comment-text-args.php

File test-comment-text-args.php, 1.6 KB (added by simonwheatley, 3 years ago)

Small test plugin

Line 
1<?php
2
3/*
4Plugin Name: Test comment_text args param
5Plugin URI: http://simonwheatley.co.uk/wordpress/tctap
6Description: A quick plugin to test that the proposed comment_text filter <var>$args</var> parameter actually works.
7Version: 0.1
8Author: Simon Wheatley
9Author URI: http://simonwheatley.co.uk/wordpress/
10*/
11 
12/*  Copyright 2010 Simon Wheatley
13
14This program is free software; you can redistribute it and/or modify
15it under the terms of the GNU General Public License as published by
16the Free Software Foundation; either version 2 of the License, or
17(at your option) any later version.
18
19This program is distributed in the hope that it will be useful,
20but WITHOUT ANY WARRANTY; without even the implied warranty of
21MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22GNU General Public License for more details.
23
24You should have received a copy of the GNU General Public License
25along with this program; if not, write to the Free Software
26Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
28*/
29
30/**
31 * Hooks the WP comment_text filter and adds on a print_r of the
32 * $args formatting options passed in to test the proposed new
33 * $args parameter.
34 *
35 * @param string $comment_text The HTML content of the comment
36 * @param array $args The array of formatting options, if it exists
37 * @return string The HTML comment content
38 **/
39function tctap_comment_text( $comment_text, $comment_ID, $args ) {
40        $args_printout = print_r( $args, true );
41        $comment_text = "<hr /><pre>Comment ID: $comment_ID\n$args_printout</pre><hr />$comment_text";
42        return $comment_text;
43}
44add_filter( 'comment_text', 'tctap_comment_text', null, 3 );
45
46?>