Plugin Directory

Changeset 1219952


Ignore:
Timestamp:
08/13/2015 12:44:34 PM (11 years ago)
Author:
RossC
Message:

Switch to PHP5 style constructors for WP v4.3

Location:
recent-posts-by-category-widget/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • recent-posts-by-category-widget/trunk/readme.txt

    r995198 r1219952  
    2727== Changelog ==
    2828
     29= 1.2 =
     30* Switch to PHP5 style constructors for WP v4.3
     31
    2932= 1.1 =
    3033* Better use of 'widget_title' filter to allow hooks to be used on it.
  • recent-posts-by-category-widget/trunk/recent-posts-by-category-widget.php

    r995198 r1219952  
    44Plugin Name: Recent Posts by Category Widget
    55Description: Just like the default Recent Posts widget except you can choose a category to pull posts from.
    6 Version: 1.1
     6Version: 1.2
    77Author: Ross Cornell
    88Author URI: http://www.rosscornell.com
     
    1313// Register widget
    1414
    15 add_action( 'widgets_init', 'rpjc_register_widget_cat_recent_posts' );
    16 
    17 function rpjc_register_widget_cat_recent_posts() {
    18 
    19     register_widget( 'rpjc_widget_cat_recent_posts' );
    20 
    21 }
     15add_action( 'widgets_init', function() { register_widget( 'rpjc_widget_cat_recent_posts' ); } );
    2216
    2317class rpjc_widget_cat_recent_posts extends WP_Widget {
    2418
    25     // Process widget
    26 
    27     function rpjc_widget_cat_recent_posts() {
     19    public function __construct() {
    2820   
    29         $widget_ops = array(
    30 
    31             'classname'   => 'rpjc_widget_cat_recent_posts widget_recent_entries',
    32             'description' => 'Display recent blog posts from a specific category'
    33        
     21        parent::__construct(
     22   
     23            'rpjc_widget_cat_recent_posts',
     24            __( 'Recent Posts by Category', 'recent-posts-by-category-widget' ),
     25            array(
     26                'classname'   => 'rpjc_widget_cat_recent_posts widget_recent_entries',
     27                'description' => __( 'Display recent blog posts from a specific category', 'recent-posts-by-category-widget' )
     28            )
     29   
    3430        );
    35        
    36         $this->WP_Widget( 'rpjc_widget_cat_recent_posts', __( 'Recent Posts by Category' ), $widget_ops );
    3731   
    3832    }
    39    
     33
    4034    // Build the widget settings form
    4135
     
    5751       
    5852        <p>
    59             <label for="rpjc_widget_cat_recent_posts_username"><?php _e( 'Category' ); ?>:</label>             
     53            <label for="rpjc_widget_cat_recent_posts_category"><?php _e( 'Category' ); ?>:</label>             
    6054           
    6155            <?php
     
    112106        echo $before_widget;
    113107
    114         $title     = $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
     108        $title     = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
    115109        $category  = $instance['category'];
    116110        $number    = $instance['number'];
     
    146140        } else {
    147141
    148             echo 'No posts yet...';
     142            _e( 'No posts yet.', 'recent-posts-by-category-widget' );
    149143
    150144        }
Note: See TracChangeset for help on using the changeset viewer.