Plugin Directory

Changeset 616397


Ignore:
Timestamp:
10/23/2012 05:20:36 PM (13 years ago)
Author:
fred91
Message:
 
Location:
simplicy-random-post/trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • simplicy-random-post/trunk/func/function.php

    r609758 r616397  
    1313        $_num_cat=$_GET['cat'];
    1414        $_num_month=$_GET['month'];
    15         $_thumbsrand=$_GET['thumbsrand'];
     15        $_thumb_w=$_GET['thumb_w'];
     16        $_thumb_h=$_GET['thumb_h'];
    1617        $_thumbsaffiche=$_GET['thumbsaffiche'];
     18        $_dateaffiche=$_GET['dateaffiche'];
    1719        $_excerpt=$_GET['excerpt'];
    1820        $_length=$_GET['length'];
    1921        $_auto=$_GET['auto'];
    2022        $_time=$_GET['time'];
    21         echo WARP_sp1_Random_posts("number=$_num&cat=$_num_cat&year=$_num_year&month=$_num_month&thumbsaffiche=$_thumbsaffiche&thumbsrand=$_thumbsrand&excerpt=$_excerpt&length=$_length&auto=$_auto&time=$_time");
     23        echo WARP_sp1_Random_posts("number=$_num&cat=$_num_cat&year=$_num_year&month=$_num_month&thumbsaffiche=$_thumbsaffiche&dateaffiche=$_dateaffiche&thumb_w=$_thumb_w&thumb_h=$_thumb_h&excerpt=$_excerpt&length=$_length&auto=$_auto&time=$_time");
    2224        die();
    2325    }
     
    2830   
    2931function WARP_sp1_Random_posts($args=''){
    30     $defargs=array('number' => 8,'cmtcount' => 0,'month' => 0,'year' => 0,'thumbsaffiche' => 0, 'excerpt' => 0, 'length' => 100, 'auto' => 0, 'time' => 60);
     32    $defargs=array('number' => 8,'cmtcount' => 0,'month' => 0,'year' => 0,'thumbsaffiche' => 0,'dateaffiche' => 0, 'excerpt' => 0, 'length' => 100, 'auto' => 0, 'time' => 60);
    3133    $args = wp_parse_args($args, $defargs);$output='';$number=$args['number'];$month=$args['month'];$year=$args['year'];$cat=$args['cat'];
    3234   
     
    5557           
    5658            if (has_post_thumbnail()) {
    57             $thumb = get_post_thumbnail_id(); $img_url = wp_get_attachment_url( $thumb,'full' ); $image = sp_post_ramdom_resize( $img_url, $args['thumbsrand'], $args['thumbsrand'], true );
     59            $thumb = get_post_thumbnail_id(); $img_url = wp_get_attachment_url( $thumb,'full' ); $image = sp_post_ramdom_resize( $img_url, $args['thumb_w'], $args['thumb_h'], true );
    5860            $output.='<div class="SP-random-post-clear-top"></div>';   
    5961            // image fin
    60             if($args['thumbsaffiche']!=0)$output.='<img  class="simplicy-random-post-img" width="'.$args['thumbsrand'].'" height="'.$args['thumbsrand'].'" src="'.$image.'" alt="" />'; }
     62            if($args['thumbsaffiche']!=0)$output.='<img  class="simplicy-random-post-img" width="'.$args['thumb_w'].'" height="'.$args['thumb_h'].'" src="'.$image.'" alt="" />'; }
    6163            $output.='<li id="random-post-'.get_the_ID().'" class="simplicy-random-post"><div class="random-post-title"><a title="'.get_the_title().'" href="'.get_permalink().'">'.get_the_title().'</a>';
    6264           
    63             $output.='<dd class="simplicy-date_random-post">'.get_the_date().'</dd>';
     65            if($args['dateaffiche']!=0)$output.='<dd class="simplicy-date_random-post">'.get_the_date().'</dd>';
    6466         
    6567            $output.='</div>';
    6668             
    67             if($args['excerpt']!=0)$output.='<div class="random-post-excerpt">'.WARP_SP_Random_posts_substr(strip_tags(get_the_content()),(int)$args['length']).'</div>';;
     69            if($args['excerpt']!=0)$output.='<div class="random-post-excerpt">'.simplicy_random_content((int)$args['length']).'</div>';
    6870            $output.='</li><div class="SP-random-post"></div>';
    6971           
     
    7274        endwhile;
    7375        wp_reset_query();
    74         $output.='<li id="random-post-more" class="simplicy-random-post" style="text-align:center"><div><a style="width:100%;height:100%" href="javascript:;" onclick="WARP_.get_random_posts(\'number='.$args['number'].'&month='.$args['month'].'&year='.$args['year'].'&cat='.$args['cat'].'&thumbsaffiche='.$args['thumbsaffiche'].'&excerpt='.$args['excerpt'].'&length='.$args['length'].'&thumbsrand='.$args['thumbsrand'].'&auto='.$args['auto'].'&time='.$args['time'].'\')"><div class="icon-reload"></div></a>'.($args['auto']?'<span id="refreshTime">'.$args['time'].'</span>':'').'</div></li>';
     76        $output.='<li id="random-post-more" class="simplicy-random-post" style="text-align:center"><div><a style="width:100%;height:100%" href="javascript:;" onclick="WARP_.get_random_posts(\'number='.$args['number'].'&month='.$args['month'].'&year='.$args['year'].'&cat='.$args['cat'].'&thumbsaffiche='.$args['thumbsaffiche'].'&dateaffiche='.$args['dateaffiche'].'&excerpt='.$args['excerpt'].'&length='.$args['length'].'&thumb_w='.$args['thumb_w'].'&thumb_h='.$args['thumb_h'].'&auto='.$args['auto'].'&time='.$args['time'].'\')"><div class="icon-reload"></div></a>'.($args['auto']?'<span id="refreshTime">'.$args['time'].'</span>':'').'</div></li>';
    7577        return $output;
    7678    }else{
     
    113115        'month'=>0,
    114116        'thumbsaffiche'=>false,
     117        'dateaffiche'=>false,
    115118        'excerpt'=>false,
    116119        'length'=>35,
    117120        'auto'=>false,
    118121        'time'=>60));
    119         echo '<p><label for="'.$this->get_field_name('title').'">'.__('Titre du Widget', 'SP-Random-Post').'<input style="width:265px;" name="'.$this->get_field_name('title').'" type="text" value="'.htmlspecialchars($instance['title']).'" /></label></p>';
    120         echo '<p><label for="'.$this->get_field_name('number').'">'.__('Nombre d&acute;article al&eacute;atoire', 'SP-Random-Post').'<input style="width:40px;float: right;" name="'.$this->get_field_name('number').'" type="text" value="'.htmlspecialchars($instance['number']).'" /></label></p>';
     122echo '<p><label for="'.$this->get_field_name('title').'">'.__('Titre <small>(Title)</small>', 'SP-Random-Post').'<input style="width:100%;" name="'.$this->get_field_name('title').'" type="text" value="'.htmlspecialchars($instance['title']).'" /></label></p>';
     123
     124echo'<fieldset>
     125     <legend>Articles <small>(Posts)</small></legend>';
     126echo '<p><label for="'.$this->get_field_name('number').'">'.__('Nombre d&acute;article al&eacute;atoire', 'SP-Random-Post').'<input style="width:40px;float: right;" name="'.$this->get_field_name('number').'" type="text" value="'.htmlspecialchars($instance['number']).'" /></label></br><small>(Random post number)</small></p>';
    121127       
    122128// Mois de publication
    123 echo '<p><label for="'.$this->get_field_name('month').'">'.__('Ici vous pouvez indiquer le mois de publication', 'SP-Random-Post').'<input style="width:40px;float: right;" name="'.$this->get_field_name('month').'" type="text" value="'.htmlspecialchars($instance['month']).'" /></label></p>';
     129echo '<p><label for="'.$this->get_field_name('month').'">'.__('Ici vous pouvez indiquer le mois de publication', 'SP-Random-Post').'<input style="width:40px;float: right;" name="'.$this->get_field_name('month').'" type="text" value="'.htmlspecialchars($instance['month']).'" /></label></br><small>(Here you can specify the month of publication)</small></p>';
    124130//fin
    125131
    126132// Année de publication
    127 echo '<p><label for="'.$this->get_field_name('year').'">'.__('Ici vous pouvez indiquer l&acute;ann&eacute;e de publication', 'SP-Random-Post').'<input style="width:40px;float: right;" name="'.$this->get_field_name('year').'" type="text" value="'.htmlspecialchars($instance['year']).'" /></label></p>';
     133echo '<p><label for="'.$this->get_field_name('year').'">'.__('Ici vous pouvez indiquer l&acute;ann&eacute;e de publication', 'SP-Random-Post').'<input style="width:40px;float: right;" name="'.$this->get_field_name('year').'" type="text" value="'.htmlspecialchars($instance['year']).'" /></label></br><small>(Here you can enter the year of publication)</small></p>';
    128134//fin
    129 
     135echo '<p><input style="" name="'.$this->get_field_name('excerpt').'" type="checkbox" value="checkbox" ';if($instance['excerpt'])echo 'checked="checked"';echo '/><label for="'.$this->get_field_name('excerpt').'">'.__('Cochez cette case pour afficher un extrait', 'SP-Random-Post').'</label></br><small>(Check this box to display an excerpt)</small></p>';
     136
     137echo '<p><label for="'.$this->get_field_name('length').'">'.__('Longueur de l&acute;extrait :', 'SP-Random-Post').'<input style="width:40px;float: right;" name="'.$this->get_field_name('length').'" type="text" value="'.htmlspecialchars($instance['length']).'" /></label></br><small>(Length of excerpt)</small></p>';
     138
     139echo '<p><input style="" name="'.$this->get_field_name('dateaffiche').'" type="checkbox" value="checkbox" ';if($instance['dateaffiche'])echo 'checked="checked"';echo '/><label for="'.$this->get_field_name('dateaffiche').'">'.__('Cochez cette case pour afficher la date', 'SP-Random-Post').'</label></br><small>(Check this box to display the date)</small></p>';
    130140?>
    131 <p>
    132             <label>
    133                 <?php _e( 'Categorie' ); ?>:
    134                 <?php wp_dropdown_categories( array( 'show_option_all' => __('ALL'),'hide_empty'  => 0,'name' => $this->get_field_name("cat"), 'selected' => $instance["cat"] ) ); ?>
    135             </label>
    136         </p>
     141<p>         
     142<label><?php _e( 'Categorie' ); ?>:</label>
     143<?php wp_dropdown_categories( array( 'show_option_all' => __('ALL'),'hide_empty'  => 0,'name' => $this->get_field_name("cat"), 'selected' => $instance["cat"] ) ); ?>
     144</br><small>(Category)</small>
     145</p>
    137146<?php
     147echo'</fieldset>';
    138148// image
    139     echo '<p><input style="" name="'.$this->get_field_name('thumbsaffiche').'" type="checkbox" value="checkbox" ';if($instance['thumbsaffiche'])echo 'checked="checked"';echo '/><label for="'.$this->get_field_name('thumbsaffiche').'">'.__('Voulez-vous afficher une vignette ?', 'SP-Random-Post').'</label></p>';
    140    
    141 echo '<p><label for="'.$this->get_field_name('thumbsrand').'">'.__('Taille de la Vignette', 'SP-Random-Post').'<input style="width:40px;float: right;" name="'.$this->get_field_name('thumbsrand').'" type="text" value="'.htmlspecialchars($instance['thumbsrand']).'" /></label></p>';
     149echo'<fieldset>
     150     <legend>Vignette <small>(Thumbnail)</small></legend>';
     151echo '<p><input style="" name="'.$this->get_field_name('thumbsaffiche').'" type="checkbox" value="checkbox" ';if($instance['thumbsaffiche'])echo 'checked="checked"';echo '/><label for="'.$this->get_field_name('thumbsaffiche').'">'.__('Cochez cette case pour afficher une vignette </br><small>(Check this box to display a thumbnail)</small>', 'SP-Random-Post').'</label></p>';
     152   
     153echo '<p><label for="'.$this->get_field_name('thumb_w').'">'.__('Largeur de la Vignette ', 'SP-Random-Post').'<input style="width:40px; float:right;margin-right:60px;" name="'.$this->get_field_name('thumb_w').'" type="text" value="'.htmlspecialchars($instance['thumb_w']).'" /></label></br><small>(Thumbnail width)</small></p>';
     154
     155echo '<p><label for="'.$this->get_field_name('thumb_h').'">'.__('Hauteur de la Vignette ', 'SP-Random-Post').'<input style="width:40px; float:right;margin-right:60px;" name="'.$this->get_field_name('thumb_h').'" type="text" value="'.htmlspecialchars($instance['thumb_h']).'" /></label></br><small>(Thumbnail height)</small></p>';
     156echo'</fieldset>';
    142157// image fin
    143         echo '<p><input style="" name="'.$this->get_field_name('excerpt').'" type="checkbox" value="checkbox" ';if($instance['excerpt'])echo 'checked="checked"';echo '/><label for="'.$this->get_field_name('excerpt').'">'.__('Afficher un extrait ?', 'SP-Random-Post').'</label></p>';
    144 
    145         echo '<p><label for="'.$this->get_field_name('length').'">'.__('Longueur de l&acute;extrait :', 'SP-Random-Post').'<input style="width:40px;float: right;" name="'.$this->get_field_name('length').'" type="text" value="'.htmlspecialchars($instance['length']).'" /></label></p>';
    146         echo '<p><input style="" name="'.$this->get_field_name('auto').'" type="checkbox" value="checkbox" ';if($instance['auto'])echo 'checked="checked"';echo '/><label for="'.$this->get_field_name('auto').'">'.__('actualisation automatique?', 'SP-Random-Post').'</label></p>';
    147         echo '<p><label for="'.$this->get_field_name('time').'">'.__('Intervalle en seconde de actualisation automatique', 'SP-Random-Post').'<input style="width:40px;" name="'.$this->get_field_name('time').'" type="text" value="'.htmlspecialchars($instance['time']).'" /></label></p>';
     158
     159
     160echo'</br>';
     161echo'<fieldset>
     162     <legend>Auto actualisation <small>(Auto update)</small></legend>';
     163echo '<p><input style="" name="'.$this->get_field_name('auto').'" type="checkbox" value="checkbox" ';if($instance['auto'])echo 'checked="checked"';echo '/><label for="'.$this->get_field_name('auto').'">'.__('Cochez cette case pour l&acute;actualisation automatique', 'SP-Random-Post').'</label></br><small>(Select this checkbox to refresh automatically)</small></p>';
     164
     165echo '<p><label for="'.$this->get_field_name('time').'">'.__('Intervalle en seconde de actualisation automatique', 'SP-Random-Post').'<input style="width:40px;float: right;" name="'.$this->get_field_name('time').'" type="text" value="'.htmlspecialchars($instance['time']).'" /></label></br><small>(Second interval auto-refresh)</small></p>';
     166
     167echo'</fieldset>';
    148168    }
    149169    function update($new_instance,$old_instance){
     
    154174        $instance['cat'] = (int)$new_instance['cat'];
    155175        $instance['year'] = (int)$new_instance['year'];
    156         $instance['thumbsrand'] = (int)$new_instance['thumbsrand'];
     176        $instance['thumb_w'] = (int)$new_instance['thumb_w'];
     177        $instance['thumb_h'] = (int)$new_instance['thumb_h'];
    157178        $instance['thumbsaffiche'] = (bool)$new_instance['thumbsaffiche'];
     179        $instance['dateaffiche'] = (bool)$new_instance['dateaffiche'];
    158180        $instance['excerpt'] = (bool)$new_instance['excerpt'];
    159181        $instance['length'] = (int)$new_instance['length'];
     
    164186    function widget($args,$instance){
    165187        extract($args);
    166         $myargs='number='.$instance['number'].'&thumbsrand='.((int)$instance['thumbsrand']).'&thumbsaffiche='.((int)$instance['thumbsaffiche']).'&excerpt='.((int)$instance['excerpt']).'&length='.(int)$instance['length'].'&month='.(int)$instance['month'].'&year='.(int)$instance['year'].'&cat='.(int)$instance['cat'].'&auto='.((int)$instance['auto']).'&time='.(int)$instance['time'];
     188        $myargs='number='.$instance['number'].'&thumb_w='.((int)$instance['thumb_w']).'&thumb_h='.((int)$instance['thumb_h']).'&thumbsaffiche='.((int)$instance['thumbsaffiche']).'&dateaffiche='.((int)$instance['dateaffiche']).'&excerpt='.((int)$instance['excerpt']).'&length='.(int)$instance['length'].                  '&month='.(int)$instance['month'].'&year='.(int)$instance['year'].'&cat='.(int)$instance['cat'].'&auto='.((int)$instance['auto']).'&time='.(int)$instance['time'];
    167189        $title = apply_filters('widget_title',empty($instance['title']) ? __('Random Posts', 'SP-Random-Post') : $instance['title']);
    168190        echo '<li id="random-post-widget" class="widget"><h3 class="widget-title" >'.$title.'</h3>';
  • simplicy-random-post/trunk/readme.txt

    r609758 r616397  
    5353Version 1.6 (08/10/2012)<br />
    5454<p> Changing the image function </p>
     55Version 1.7 (23/10/2012)<br />
     56<p> adding options </p>
    5557
    5658
  • simplicy-random-post/trunk/sp-random-post.php

    r609758 r616397  
    22/*
    33Plugin Name: Simplicy Random Post
    4 Plugin URI: http://www.naxialis.com
     4Plugin URI: http://www.naxialis.com/simplicy-random-post
    55Description: Afficher des articles al&eacute;atoire dans votre sidebar.
    6 Version: 1.6
     6Version: 1.7
    77Author: naxialis
    88Author URI: http://www.naxialis.com
    99*/
    10 load_plugin_textdomain('SP-Random-Post', false, basename(dirname(__FILE__)) . '/lang');
    1110require_once(dirname(__FILE__).'/func/function.php');
    1211/* Register our stylesheet. */
    1312wp_enqueue_style('simplicy_random_post', '/wp-content/plugins/simplicy-random-post/css/simplicy_random_post.css');
     13/* Register our stylesheet Admin. */
     14wp_enqueue_style('admin', '/wp-content/plugins/simplicy-random-post/css/admin.css');
     15
     16// Excerpt length filter
     17     function simplicy_random_content($limit) {
     18     $excerpt = explode(' ', get_the_excerpt(), $limit);
     19      if (count($excerpt)>=$limit) {
     20        array_pop($excerpt);
     21        $excerpt = implode(" ",$excerpt).'';
     22      } else {
     23        $excerpt = implode(" ",$excerpt);
     24      }
     25      $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
     26     
     27     
     28     
     29      return $excerpt;
     30    }
    1431?>
Note: See TracChangeset for help on using the changeset viewer.