Changeset 791939 for php-code-widget/trunk/execphp.php
- Timestamp:
- 10/22/2013 06:26:26 PM (12 years ago)
- File:
-
- 1 edited
-
php-code-widget/trunk/execphp.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
php-code-widget/trunk/execphp.php
r204607 r791939 1 1 <?php 2 2 /* 3 Plugin Name: Executable PHP widget4 Plugin URI: http:// wordpress.org/extend/plugins/php-code-widget/3 Plugin Name: PHP Code Widget 4 Plugin URI: http://ottopress.com/wordpress-plugins/php-code-widget/ 5 5 Description: Like the Text widget, but it will take PHP code as well. Heavily derived from the Text widget code in WordPress. 6 6 Author: Otto 7 Version: 2.1 7 Version: 2.2 8 Text Domain: php-code-widget 8 9 Author URI: http://ottodestruct.com 9 License: GPL210 11 Copyright 2009 Samuel Wood (email : otto@ottodestruct.com)12 13 This program is free software; you can redistribute it and/or modify14 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 of21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the22 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.html26 27 10 */ 28 11 29 12 class PHP_Code_Widget extends WP_Widget { 30 31 13 function PHP_Code_Widget() { 32 $widget_ops = array('classname' => 'widget_execphp', 'description' => __('Arbitrary text, HTML, or PHP Code' ));14 $widget_ops = array('classname' => 'widget_execphp', 'description' => __('Arbitrary text, HTML, or PHP Code', 'php-code-widget')); 33 15 $control_ops = array('width' => 400, 'height' => 350); 34 $this->WP_Widget('execphp', __('PHP Code' ), $widget_ops, $control_ops);16 $this->WP_Widget('execphp', __('PHP Code', 'php-code-widget'), $widget_ops, $control_ops); 35 17 } 36 18 … … 40 22 $text = apply_filters( 'widget_execphp', $instance['text'], $instance ); 41 23 echo $before_widget; 42 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } 24 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } 43 25 ob_start(); 44 26 eval('?>'.$text); 45 27 $text = ob_get_contents(); 46 28 ob_end_clean(); 47 ?> 29 ?> 48 30 <div class="execphpwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div> 49 31 <?php … … 67 49 $text = format_to_edit($instance['text']); 68 50 ?> 69 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:' ); ?></label>51 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'php-code-widget'); ?></label> 70 52 <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 53 72 54 <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 55 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>56 <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> 75 57 <?php 76 58 } … … 78 60 79 61 add_action('widgets_init', create_function('', 'return register_widget("PHP_Code_Widget");')); 80 81 // donate link on manage plugin page82 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 }
Note: See TracChangeset
for help on using the changeset viewer.