wp-parsidate
Last commit date
css
12 years ago
js
12 years ago
languages
12 years ago
lib
12 years ago
admin.php
12 years ago
index.php
12 years ago
readme.txt
12 years ago
screenshot-1.png
12 years ago
screenshot-2.png
12 years ago
widegets.php
12 years ago
wp-parsidate.php
12 years ago
widegets.php
78 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @author lord_viper |
| 4 | * @copyright 2013 |
| 5 | */ |
| 6 | class parsidate_archive extends WP_Widget |
| 7 | { |
| 8 | public function __construct() |
| 9 | { |
| 10 | parent::WP_Widget(false,'بایگانی تاریخ خورشیدی','description=بایگانی تاریخ خورشیدی'); |
| 11 | } |
| 12 | |
| 13 | public function form($instance) |
| 14 | { |
| 15 | $type=(empty($instance['parsidate_archive_type'])?'monthly':$instance['parsidate_archive_type']); |
| 16 | ?> |
| 17 | <p style="text-align:right; direction:rtl"> |
| 18 | <label>عنوان:</label> |
| 19 | <input style="width: 200px;" id="<?php echo $this->get_field_id('parsidate_archive_title'); ?>" name="<?php echo $this->get_field_name('parsidate_archive_title'); ?>" type="text" value="<?php echo (empty($instance['parsidate_archive_title'])?'بایگانی تاریخ خورشیدی':$instance['parsidate_archive_title']) ?>" /> |
| 20 | <br /> |
| 21 | <input type="radio" id="parsidate_archive_type1" name="<?php echo $this->get_field_name('parsidate_archive_type'); ?>" value="yearly" <?php checked($type,'yearly'); ?>/><label id="parsidate_archive_type1">سالانه</label><br /> |
| 22 | <input type="radio" id="parsidate_archive_type2" name="<?php echo $this->get_field_name('parsidate_archive_type'); ?>" value="monthly" <?php checked($type,'monthly'); ?>/><label id="parsidate_archive_type2">� |
| 23 | اهانه</label><br /> |
| 24 | <input type="radio" id="parsidate_archive_type3" name="<?php echo $this->get_field_name('parsidate_archive_type'); ?>" value="daily" <?php checked($type,'daily'); ?>/><label id="parsidate_archive_type3">روزانه</label><br /> |
| 25 | <br /> |
| 26 | <input type="checkbox" name="<?php echo $this->get_field_name('parsidate_archive_count'); ?>" id="<?php echo $this->get_field_id('parsidate_archive_count'); ?>" <?php echo $instance['parsidate_archive_count']; ?>/> |
| 27 | <label for="<?php echo $this->get_field_id('parsidate_archive_count'); ?>">ن� |
| 28 | ایش تعداد نوشته ها</label> |
| 29 | <br /> |
| 30 | <input type="checkbox" name="<?php echo $this->get_field_name('parsidate_archive_list'); ?>" id="<?php echo $this->get_field_id('parsidate_archive_list'); ?>" <?php echo $instance['parsidate_archive_list']; ?>/> |
| 31 | <label for="<?php echo $this->get_field_id('parsidate_archive_list'); ?>">ن� |
| 32 | ایش به صورت لیست بازشو</label> |
| 33 | </p> |
| 34 | <?php |
| 35 | } |
| 36 | |
| 37 | public function update($new_instance, $old_instance ) |
| 38 | { |
| 39 | $instance=$old_instance; |
| 40 | $instance['parsidate_archive_title']= strip_tags($new_instance['parsidate_archive_title']); |
| 41 | $instance['parsidate_archive_count']= (empty($new_instance['parsidate_archive_count']))?'':'checked'; |
| 42 | $instance['parsidate_archive_list'] = (empty($new_instance['parsidate_archive_list'] ))?'':'checked'; |
| 43 | $instance['parsidate_archive_type'] = $new_instance['parsidate_archive_type']; |
| 44 | return $instance; |
| 45 | } |
| 46 | |
| 47 | public function widget($args ,$instance) |
| 48 | { |
| 49 | extract($args); |
| 50 | $type = $instance['parsidate_archive_type']; |
| 51 | $title = (empty($instance['parsidate_archive_title']))?'بایگانی تاریخ خورشیدی':$instance['parsidate_archive_title']; |
| 52 | $post_count = (empty($instance['parsidate_archive_count']))?false:true; |
| 53 | $ddl_style = (empty($instance['parsidate_archive_list'] ))?false:true; |
| 54 | echo "$before_widget |
| 55 | $before_title $title $after_title"; |
| 56 | if($ddl_style) |
| 57 | { |
| 58 | echo "<select name='parsidate_archive_list' onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value='0'>".esc_attr($title)."</option>"; |
| 59 | wp_get_parchives("type=$type&format=option&show_post_count=$post_count",$ddl_style); |
| 60 | echo '</select>'; |
| 61 | } |
| 62 | else |
| 63 | { |
| 64 | echo '<ul>'; |
| 65 | wp_get_parchives("type=$type&show_post_count=$post_count",$ddl_style); |
| 66 | echo '</ul>'; |
| 67 | } |
| 68 | echo $after_widget; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | add_action( 'widgets_init', 'register_wpb_widgets' ); |
| 73 | |
| 74 | function register_wpb_widgets() |
| 75 | { |
| 76 | register_widget('parsidate_archive'); |
| 77 | } |
| 78 | ?> |