Changeset 3080904
- Timestamp:
- 05/03/2024 11:33:05 AM (2 years ago)
- Location:
- badge/trunk
- Files:
-
- 2 edited
-
DisplayBadge.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
badge/trunk/DisplayBadge.php
r2155756 r3080904 1 1 <?php 2 /* 3 Plugin Name: Display Badge4 Plugin URI: https://damn.org.za/widgets/5 Description: Individual Badge Version of DisplayBadges6 Author: Eugéne Roux7 Version: 1.58 Author URI: https://damn.org.za/2 /** 3 * Plugin Name: Display Badge 4 * Plugin URI: https://damn.org.za/widgets/ 5 * Description: Individual Badge Version of DisplayBadges 6 * Version: 1.6 7 * Author: Eugéne Roux 8 * Author URI: https://damn.org.za/ 9 9 */ 10 10 11 //12 // DisplayBadge Class13 //14 11 class DisplayBadge extends WP_Widget { 15 // 16 // constructor 17 // 18 public function DisplayBadge() { 19 $widget_ops = array( 'classname' => 'widget_badges', 'description' => __( "Display a Badge within the widget in the style of 'DisplayBadges' for those time you only need to display a few or don't have the inclination of creating them as files." )); 20 $this->WP_Widget( 'badge', __( 'Badge', 'badge_widget' ), $widget_ops ); 12 13 /** 14 * Sets up the widgets name etc 15 */ 16 public function __construct() { 17 $widget_ops = array( 18 'classname' => 'badge_widget', 19 'description' => "Display a Badge within the widget in the style of 'DisplayBadges' for those time you only need to display a few or don't have the inclination of creating them as files.", 20 ); 21 parent::__construct( 'badge_widget', 'Display Badge', $widget_ops ); 22 21 23 $this->widget_defaults = array( 22 24 'padbadge' => true, … … 27 29 'badgeNote' => '', 28 30 ); 29 30 31 } 31 32 32 // 33 // @see WP_Widget::widget 34 // 35 public function widget($args, $instance) { 33 /** 34 * Outputs the content of the widget 35 * 36 * @param array $args 37 * @param array $instance 38 */ 39 public function widget( $args, $instance ) { 40 // outputs the content of the widget 36 41 extract( $args ); 37 42 $id = $args['widget_id']; … … 100 105 } 101 106 102 // 103 // @see WP_Widget::update 104 // 105 public function update($new_instance, $old_instance) { 106 $instance = $old_instance; 107 $instance['title'] = strip_tags( $new_instance['title'] ); 108 $instance['destURL'] = $new_instance['destURL']; 109 $instance['destIMG'] = $new_instance['destIMG']; 110 $instance['badgeNote'] = $new_instance['badgeNote']; 111 $instance['displayframe'] = ( isset( $new_instance['displayframe'] ) ? 1 : 0 ); 112 $instance['padbadge'] = ( isset( $new_instance['padbadge'] ) ? 1 : 0 ); 113 $instance['dropshadow'] = ( isset( $new_instance['dropshadow'] ) ? 1 : 0 ); 114 return $instance; 115 } 116 117 // 118 // @see WP_Widget::form 119 // 107 /** 108 * Outputs the options form on admin 109 * 110 * @param array $instance The widget options 111 */ 120 112 public function form( $instance ) { 113 // outputs the options form on admin 121 114 $instance = wp_parse_args( $instance, $this->widget_defaults ); 122 115 extract( $instance ); … … 158 151 print( "</label>\n" ); 159 152 print( "\t</p>\n" ); 153 } 160 154 161 } 155 /** 156 * Sanitize widget form values as they are saved. 157 * 158 * @see WP_Widget::update() 159 * 160 * @param array $new_instance Values just sent to be saved. 161 * @param array $old_instance Previously saved values from database. 162 * 163 * @return array Updated safe values to be saved. 164 */ 165 public function update( $new_instance, $old_instance ) { 166 $instance = $old_instance; 167 $instance['title'] = strip_tags( $new_instance['title'] ); 168 $instance['destURL'] = $new_instance['destURL']; 169 $instance['destIMG'] = $new_instance['destIMG']; 170 $instance['badgeNote'] = $new_instance['badgeNote']; 171 $instance['displayframe'] = ( isset( $new_instance['displayframe'] ) ? 1 : 0 ); 172 $instance['padbadge'] = ( isset( $new_instance['padbadge'] ) ? 1 : 0 ); 173 $instance['dropshadow'] = ( isset( $new_instance['dropshadow'] ) ? 1 : 0 ); 174 return $instance; 175 // $instance = array(); 176 // $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? sanitize_text_field( $new_instance['title'] ) : ''; 177 // return $instance; 178 } 179 162 180 } 163 181 164 //165 182 // register DisplayBadge widget 166 // 167 add_action('widgets_init', create_function('', 'return register_widget( "DisplayBadge" );')); 183 function register_badge_widget() { 184 register_widget( 'DisplayBadge' ); 185 } 186 add_action( 'widgets_init', 'register_badge_widget' ); 187 188 ?> -
badge/trunk/readme.txt
r2755100 r3080904 3 3 Contributors: eroux 4 4 Tags: snippets, badges, admin, administration, jadb 5 Requires at least: 2.86 Tested up to: 6. 0.05 Requires at least: 6.0 6 Tested up to: 6.5.2 7 7 Stable tag: trunk 8 8
Note: See TracChangeset
for help on using the changeset viewer.