WordPress.org

Plugin Directory

Changeset 605246


Ignore:
Timestamp:
09/28/12 14:45:47 (5 years ago)
Author:
NebulosaWeb
Message:
 
Location:
simple-featured-posts-widget/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • simple-featured-posts-widget/trunk/readme.txt

    r570847 r605246  
    55Requires at least: 3.3 
    66Tested up to: 3.4 
    7 Stable tag: 1.1.1 
     7Stable tag: 1.2 
    88License: GPLv2 or later 
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    1414 
    1515Simple Featured Posts is a pratical widget that allows you to show a post list with thumbnails ordered by random or recent posts. You can also choose post's categories and how many posts you want to show. 
    16 This widget show the first image found in the post as thumbnail. 
     16This widget show the first image found in the post as thumbnail or thumbnail image of posts if supported by template. 
    1717 
    1818= Features = 
     
    4949== Changelog == 
    5050 
     51= 1.2 = 
     52* Now support post-thumbnails function 
     53* Thumbnail height setting 
     54 
    5155= 1.1.1 = 
    5256* Fixed a bug with thumbnail size. 
  • simple-featured-posts-widget/trunk/sfpw-func.php

    r570847 r605246  
    88    $first_img = $matches [1] [0]; 
    99 
    10     if(empty($first_img)){ //Defines a default image 
     10    if(empty($first_img)){ //<-     Defines a default image 
    1111        $first_img = plugin_dir_url(__FILE__)."images/default.png"; 
    1212    } 
  • simple-featured-posts-widget/trunk/sfpw.php

    r570847 r605246  
    55Description: Simple Featured Posts is a pratical widget that allows you to show a post list with thumbnails ordered by random or recent posts. You can also choose post's categories and how many posts you want to show. 
    66Author: Fabio Di Stasio 
    7 Version: 1.1.1 
     7Version: 1.2 
    88Author URI: http://nebulosaweb.com 
    99*/ 
     
    4242                    <?php  
    4343                        if($instance['image'] == 1){  
    44                             $size = imgSize(first_image()); 
    45                             if($instance['size'] == null or $instance['size'] == 0){ 
    46                                 $setWitdh = "150"; 
     44                             
     45                            if(has_post_thumbnail()){ //<- check if the post has a Post Thumbnail assigned to it 
     46                                $extractUrl = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail'); 
     47                                $imageUrl = $extractUrl[0]; 
    4748                            } 
    4849                            else{ 
    49                                 $setWitdh = $instance['size']; 
     50                                $imageUrl = first_image(); 
    5051                            } 
    5152                             
    52                             $h = @ceil($size[1]/($size[0]/$setWitdh)); 
    53                              
    54                             echo "<img width='".$setWitdh."' height='".$h."' src='".first_image()."' alt='".the_title('','',FALSE)."'/>"; 
     53                            if($instance['sizeH'] == NULL){ //<- if is set just width 
     54                                $size = imgSize(first_image()); 
     55                                if($instance['size'] == null or $instance['size'] == 0){ 
     56                                    $w = "150"; 
     57                                } 
     58                                else{ 
     59                                    $w = $instance['size']; 
     60                                } 
     61                                $h = @ceil($size[1]/($size[0]/$w)); 
     62                            } 
     63                            else{ 
     64                                $w = $instance['size']; 
     65                                $h = $instance['sizeH']; 
     66                            } 
     67                            echo "<img width='".$w."' height='".$h."' src='".$imageUrl."' alt='".the_title('','',FALSE)."'/>"; 
    5568                        }  
    5669                    ?> 
     
    6780        return $new_instance; 
    6881    } 
    69     function form( $instance ) { //setta i parametri di default del widget 
     82    function form( $instance ) { //<- set default parameters of widget 
    7083        if($instance){ 
    7184            $title = esc_attr($instance['title']); 
     
    7689            $date = $instance['date']; 
    7790            $size = $instance['size']; 
     91            $sizeH = $instance['sizeH']; 
    7892        } 
    7993        else{ 
     
    8599            $date = 1; 
    86100            $size = 150; 
     101            $sizeH = ''; 
    87102        }?> 
    88103        <p> 
     
    107122        </p> 
    108123        <p> 
     124            <input class="checkbox" <?php if($date == 1): ?>checked="checked"<?php endif?> id="<?php echo $this->get_field_id('date');?>" name="<?php echo $this->get_field_name('date');?>" type="checkbox" value="1"/> 
     125            <label for="<?php echo $this->get_field_id('date');?>"><?php _e('Show date','sfpw'); ?></label>  
     126        </p> 
     127        <p> 
    109128            <input class="checkbox" <?php if($image == 1): ?>checked="checked"<?php endif?> id="<?php echo $this->get_field_id('image');?>" name="<?php echo $this->get_field_name('image');?>" type="checkbox" value="1"/> 
    110129            <label for="<?php echo $this->get_field_id('imahe');?>"><?php _e('Show thumbnail','sfpw'); ?></label>  
    111130        </p> 
    112131        <p> 
    113             <input class="checkbox" <?php if($date == 1): ?>checked="checked"<?php endif?> id="<?php echo $this->get_field_id('date');?>" name="<?php echo $this->get_field_name('date');?>" type="checkbox" value="1"/> 
    114             <label for="<?php echo $this->get_field_id('date');?>"><?php _e('Show date','sfpw'); ?></label>  
     132            <label for="<?php echo $this->get_field_id('size');?>"><?php _e('Thumbnail witdh:','sfpw'); ?></label>  
     133            <input class="widefat" id="<?php echo $this->get_field_id('size');?>" name="<?php echo $this->get_field_name('size');?>" type="text" value="<?php echo $size; ?>"/> 
    115134        </p> 
    116135        <p> 
    117             <label for="<?php echo $this->get_field_id('size');?>"><?php _e('Thumbnail witdh:','sfpw'); ?></label>  
    118             <input class="widefat" id="<?php echo $this->get_field_id('size');?>" name="<?php echo $this->get_field_name('size');?>" type="text" value="<?php echo $size; ?>"/> 
     136            <label for="<?php echo $this->get_field_id('sizeH');?>"><?php _e('Thumbnail height:','sfpw'); ?></label>  
     137            <input class="widefat" id="<?php echo $this->get_field_id('sizeH');?>" name="<?php echo $this->get_field_name('sizeH');?>" type="text" value="<?php echo $sizeH; ?>"/> 
     138            <small>Automatically set if blank</small> 
    119139        </p> 
    120140        <?php 
Note: See TracChangeset for help on using the changeset viewer.