Plugin Directory

Changeset 3080904


Ignore:
Timestamp:
05/03/2024 11:33:05 AM (2 years ago)
Author:
eroux
Message:

Update for 6.5

Location:
badge/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • badge/trunk/DisplayBadge.php

    r2155756 r3080904  
    11<?php
    2 /*
    3    Plugin Name: Display Badge
    4    Plugin URI: https://damn.org.za/widgets/
    5    Description: Individual Badge Version of DisplayBadges
    6     Author: Eugéne Roux
    7     Version: 1.5
    8    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/
    99 */
    1010
    11 //
    12 //  DisplayBadge Class
    13 //
    1411class 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
    2123        $this->widget_defaults = array(
    2224            'padbadge' => true,
     
    2729            'badgeNote' => '',
    2830        );
    29 
    3031    }
    3132
    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
    3641        extract( $args );
    3742        $id = $args['widget_id'];
     
    100105    }
    101106
    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     */
    120112    public function form( $instance ) {
     113        // outputs the options form on admin
    121114        $instance = wp_parse_args( $instance, $this->widget_defaults );
    122115        extract( $instance );
     
    158151        print( "</label>\n" );
    159152        print( "\t</p>\n" );
     153    }
    160154
    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
    162180}
    163181
    164 //
    165182// register DisplayBadge widget
    166 //
    167 add_action('widgets_init', create_function('', 'return register_widget( "DisplayBadge" );'));
     183function register_badge_widget() {
     184    register_widget( 'DisplayBadge' );
     185}
     186add_action( 'widgets_init', 'register_badge_widget' );
     187
     188?>
  • badge/trunk/readme.txt

    r2755100 r3080904  
    33Contributors: eroux
    44Tags: snippets, badges, admin, administration, jadb
    5 Requires at least: 2.8
    6 Tested up to: 6.0.0
     5Requires at least: 6.0
     6Tested up to: 6.5.2
    77Stable tag: trunk
    88
Note: See TracChangeset for help on using the changeset viewer.