Version Description
- Translation fixes for WP 3.7
- Remove donation link
Download this release
Release Info
Developer | Otto42 |
Plugin | PHP Code Widget |
Version | 2.2 |
Comparing to | |
See all releases |
Code changes from version 2.1 to 2.2
- execphp.php +11 -38
- php-code-widget.pot +48 -0
- readme.txt +19 -38
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
execphp.php
CHANGED
@@ -1,37 +1,20 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
Plugin Name:
|
4 |
-
Plugin URI: http://
|
5 |
Description: Like the Text widget, but it will take PHP code as well. Heavily derived from the Text widget code in WordPress.
|
6 |
Author: Otto
|
7 |
-
Version: 2.
|
|
|
8 |
Author URI: http://ottodestruct.com
|
9 |
-
License: GPL2
|
10 |
-
|
11 |
-
Copyright 2009 Samuel Wood (email : otto@ottodestruct.com)
|
12 |
-
|
13 |
-
This program is free software; you can redistribute it and/or modify
|
14 |
-
it under the terms of the GNU General Public License version 2,
|
15 |
-
as published by the Free Software Foundation.
|
16 |
-
|
17 |
-
You may NOT assume that you can use any other version of the GPL.
|
18 |
-
|
19 |
-
This program is distributed in the hope that it will be useful,
|
20 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
-
GNU General Public License for more details.
|
23 |
-
|
24 |
-
The license for this software can likely be found here:
|
25 |
-
http://www.gnu.org/licenses/gpl-2.0.html
|
26 |
-
|
27 |
*/
|
28 |
|
29 |
class PHP_Code_Widget extends WP_Widget {
|
30 |
-
|
31 |
function PHP_Code_Widget() {
|
32 |
-
|
|
|
33 |
$control_ops = array('width' => 400, 'height' => 350);
|
34 |
-
$this->WP_Widget('execphp', __('PHP Code'), $widget_ops, $control_ops);
|
35 |
}
|
36 |
|
37 |
function widget( $args, $instance ) {
|
@@ -39,12 +22,12 @@ class PHP_Code_Widget extends WP_Widget {
|
|
39 |
$title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance );
|
40 |
$text = apply_filters( 'widget_execphp', $instance['text'], $instance );
|
41 |
echo $before_widget;
|
42 |
-
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
|
43 |
ob_start();
|
44 |
eval('?>'.$text);
|
45 |
$text = ob_get_contents();
|
46 |
ob_end_clean();
|
47 |
-
?>
|
48 |
<div class="execphpwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div>
|
49 |
<?php
|
50 |
echo $after_widget;
|
@@ -66,24 +49,14 @@ class PHP_Code_Widget extends WP_Widget {
|
|
66 |
$title = strip_tags($instance['title']);
|
67 |
$text = format_to_edit($instance['text']);
|
68 |
?>
|
69 |
-
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
|
70 |
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
|
71 |
|
72 |
<textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
|
73 |
|
74 |
-
<p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs.'); ?></label></p>
|
75 |
<?php
|
76 |
}
|
77 |
}
|
78 |
|
79 |
add_action('widgets_init', create_function('', 'return register_widget("PHP_Code_Widget");'));
|
80 |
-
|
81 |
-
// donate link on manage plugin page
|
82 |
-
add_filter('plugin_row_meta', 'execphp_donate_link', 10, 2);
|
83 |
-
function execphp_donate_link($links, $file) {
|
84 |
-
if ($file == plugin_basename(__FILE__)) {
|
85 |
-
$donate_link = '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=otto%40ottodestruct%2ecom">Donate</a>';
|
86 |
-
$links[] = $donate_link;
|
87 |
-
}
|
88 |
-
return $links;
|
89 |
-
}
|
1 |
<?php
|
2 |
/*
|
3 |
+
Plugin Name: PHP Code Widget
|
4 |
+
Plugin URI: http://ottopress.com/wordpress-plugins/php-code-widget/
|
5 |
Description: Like the Text widget, but it will take PHP code as well. Heavily derived from the Text widget code in WordPress.
|
6 |
Author: Otto
|
7 |
+
Version: 2.2
|
8 |
+
Text Domain: php-code-widget
|
9 |
Author URI: http://ottodestruct.com
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
class PHP_Code_Widget extends WP_Widget {
|
|
|
13 |
function PHP_Code_Widget() {
|
14 |
+
load_plugin_textdomain( 'php-code-widget', false, dirname( plugin_basename( __FILE__ ) ) );
|
15 |
+
$widget_ops = array('classname' => 'widget_execphp', 'description' => __('Arbitrary text, HTML, or PHP Code', 'php-code-widget'));
|
16 |
$control_ops = array('width' => 400, 'height' => 350);
|
17 |
+
$this->WP_Widget('execphp', __('PHP Code', 'php-code-widget'), $widget_ops, $control_ops);
|
18 |
}
|
19 |
|
20 |
function widget( $args, $instance ) {
|
22 |
$title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance );
|
23 |
$text = apply_filters( 'widget_execphp', $instance['text'], $instance );
|
24 |
echo $before_widget;
|
25 |
+
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
|
26 |
ob_start();
|
27 |
eval('?>'.$text);
|
28 |
$text = ob_get_contents();
|
29 |
ob_end_clean();
|
30 |
+
?>
|
31 |
<div class="execphpwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div>
|
32 |
<?php
|
33 |
echo $after_widget;
|
49 |
$title = strip_tags($instance['title']);
|
50 |
$text = format_to_edit($instance['text']);
|
51 |
?>
|
52 |
+
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'php-code-widget'); ?></label>
|
53 |
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
|
54 |
|
55 |
<textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
|
56 |
|
57 |
+
<p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs.', 'php-code-widget'); ?></label></p>
|
58 |
<?php
|
59 |
}
|
60 |
}
|
61 |
|
62 |
add_action('widgets_init', create_function('', 'return register_widget("PHP_Code_Widget");'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
php-code-widget.pot
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2013 PHP Code Widget
|
2 |
+
# This file is distributed under the same license as the PHP Code Widget package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: PHP Code Widget 2.2\n"
|
6 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/php-code-widget\n"
|
7 |
+
"POT-Creation-Date: 2013-10-22 18:55:57+00:00\n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2013-MO-DA HO:MI+ZONE\n"
|
12 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
+
|
15 |
+
#: execphp.php:14
|
16 |
+
msgid "Arbitrary text, HTML, or PHP Code"
|
17 |
+
msgstr ""
|
18 |
+
|
19 |
+
#: execphp.php:16
|
20 |
+
msgid "PHP Code"
|
21 |
+
msgstr ""
|
22 |
+
|
23 |
+
#: execphp.php:51
|
24 |
+
msgid "Title:"
|
25 |
+
msgstr ""
|
26 |
+
|
27 |
+
#: execphp.php:56
|
28 |
+
msgid "Automatically add paragraphs."
|
29 |
+
msgstr ""
|
30 |
+
#. Plugin Name of the plugin/theme
|
31 |
+
msgid "PHP Code Widget"
|
32 |
+
msgstr ""
|
33 |
+
|
34 |
+
#. Plugin URI of the plugin/theme
|
35 |
+
msgid "http://ottopress.com/wordpress-plugins/php-code-widget/"
|
36 |
+
msgstr ""
|
37 |
+
|
38 |
+
#. Description of the plugin/theme
|
39 |
+
msgid "Like the Text widget, but it will take PHP code as well. Heavily derived from the Text widget code in WordPress."
|
40 |
+
msgstr ""
|
41 |
+
|
42 |
+
#. Author of the plugin/theme
|
43 |
+
msgid "Otto"
|
44 |
+
msgstr ""
|
45 |
+
|
46 |
+
#. Author URI of the plugin/theme
|
47 |
+
msgid "http://ottodestruct.com"
|
48 |
+
msgstr ""
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: Otto42
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=otto%40ottodestruct%2ecom
|
4 |
Tags: php, widget, execphp
|
5 |
Requires at least: 2.8
|
6 |
-
Tested up to:
|
7 |
-
Stable tag: 2.
|
8 |
License: GPLv2
|
9 |
License URI: http://www.opensource.org/licenses/GPL-2.0
|
10 |
|
@@ -12,53 +12,31 @@ Like the Text widget, but also allows working PHP code to be inserted.
|
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
The normal Text widget allows you to insert arbitrary Text and/or HTML code.
|
16 |
-
This allows that too, but also parses any inserted PHP code and executes it.
|
17 |
-
This makes it easier to migrate to a widget-based theme.
|
18 |
|
19 |
-
|
20 |
-
recognized.
|
21 |
|
22 |
-
|
23 |
-
Copy the code you have in them elsewhere first, then recreate your widgets
|
24 |
-
afterwards.
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
* http://www.facebook.com/pages/Nothing-to-See-Here/241409175928000
|
29 |
-
* http://www.facebook.com/ottopress
|
30 |
-
|
31 |
-
Or follow my sites on Twitter!
|
32 |
-
|
33 |
-
* http://twitter.com/ottodestruct
|
34 |
-
|
35 |
-
|
36 |
-
== Installation ==
|
37 |
-
|
38 |
-
1. Upload `execphp.php` to the `/wp-content/plugins/` directory
|
39 |
-
1. Activate the plugin through the 'Plugins' menu in WordPress
|
40 |
-
1. Use the widget like any other widget.
|
41 |
|
42 |
== Frequently Asked Questions ==
|
43 |
|
44 |
-
= There's some kind of error on line
|
45 |
|
46 |
That error means that your PHP code is incorrect or otherwise broken.
|
47 |
|
48 |
-
=
|
|
|
|
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
53 |
|
54 |
-
|
55 |
-
make. Any errors coming out of the "execphp.php" file are errors in code you
|
56 |
-
put into one of the widgets. The reason that it shows the error being in the
|
57 |
-
execphp.php file is because that is where your code is actually being run
|
58 |
-
from.
|
59 |
|
60 |
-
|
61 |
-
is yours. Please don't email me about that error.
|
62 |
|
63 |
== Screenshots ==
|
64 |
|
@@ -66,10 +44,13 @@ is yours. Please don't email me about that error.
|
|
66 |
2. The output of the widget on the site.
|
67 |
|
68 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
69 |
= 2.1 =
|
70 |
* Fixed broken wpautop filter. Checkbox on widget works now.
|
71 |
|
72 |
= 2.0 =
|
73 |
* Changed widget to use new Class methods for creating widget. This simplifies the widget and should eliminate any problems with it losing code or disappearing from sidebars and so forth.
|
74 |
-
* WARNING: Version 2.0 REQUIRES WordPress 2.8 and up. It will not work with older versions.
|
75 |
-
* WARNING: Upgrading this widget from 1.x might cause the widget to LOSE YOUR EXISTING SIDEBAR CODE. Copy and paste the existing code somewhere else before upgrading (just in case), then recreate the widgets afterwards.
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=otto%40ottodestruct%2ecom
|
4 |
Tags: php, widget, execphp
|
5 |
Requires at least: 2.8
|
6 |
+
Tested up to: 4.0
|
7 |
+
Stable tag: 2.2
|
8 |
License: GPLv2
|
9 |
License URI: http://www.opensource.org/licenses/GPL-2.0
|
10 |
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
The normal Text widget allows you to insert arbitrary Text and/or HTML code. This allows that too, but also parses any PHP code in the text widget and executes it.
|
|
|
|
|
16 |
|
17 |
+
This can make it easier to migrate to a widget-based theme. However, this plugin should not be used long term, as anybody with access to edit the widgets on your site will be able to execute arbitrary PHP code.
|
|
|
18 |
|
19 |
+
All PHP code must be enclosed in the standard php opening and closing tags ( `<?php` and `?>` ) for it to be recognized and executed.
|
|
|
|
|
20 |
|
21 |
+
Only users with the unfiltered_html role will be allowed to insert unfiltered HTML. This includes PHP code, so users without admin or editor permissions will not be able to use this to execute code, even if they have widget editing permissions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
== Frequently Asked Questions ==
|
24 |
|
25 |
+
= There's some kind of error on line 26! =
|
26 |
|
27 |
That error means that your PHP code is incorrect or otherwise broken.
|
28 |
|
29 |
+
= But my code is fine! =
|
30 |
+
|
31 |
+
No, it's not. Really.
|
32 |
|
33 |
+
This widget has no real errors in it, it's about the simplest widget one can possibly make. Any errors coming out of the "execphp.php" file are errors in code you put into one of the widgets. The reason that it shows the error being in the execphp.php file is because that is where your widget's code is actually being run.
|
34 |
|
35 |
+
So, if it says that you have an error on line 26, I assure you, the problem is yours. Please don't email me about that error.
|
36 |
|
37 |
+
= I have code that works normally in a template but doesn't work when in the widget? =
|
|
|
|
|
|
|
|
|
38 |
|
39 |
+
Code in a template runs in the global context. Code in the widget will run in a function context. Make sure that you declare any global variables as global before attempting to use them.
|
|
|
40 |
|
41 |
== Screenshots ==
|
42 |
|
44 |
2. The output of the widget on the site.
|
45 |
|
46 |
== Changelog ==
|
47 |
+
|
48 |
+
= 2.2 =
|
49 |
+
* Translation fixes for WP 3.7
|
50 |
+
* Remove donation link
|
51 |
+
|
52 |
= 2.1 =
|
53 |
* Fixed broken wpautop filter. Checkbox on widget works now.
|
54 |
|
55 |
= 2.0 =
|
56 |
* Changed widget to use new Class methods for creating widget. This simplifies the widget and should eliminate any problems with it losing code or disappearing from sidebars and so forth.
|
|
|
|
screenshot-1.png
DELETED
Binary file
|
screenshot-2.png
DELETED
Binary file
|