widget_calendar.php
53 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @author lord_viper |
| 5 | * @copyright 2013 |
| 6 | */ |
| 7 | class parsidate_calendar extends WP_Widget { |
| 8 | public function __construct() { |
| 9 | global $wp_version; |
| 10 | if ( version_compare( $wp_version, '4.3', '>=' ) ) { |
| 11 | parent::__construct( false, __( 'Jalali Date Calender', 'wp-parsidate' ), 'description=' . __( 'Jalali Date Calender', 'wp-parsidate' ) ); |
| 12 | } else { |
| 13 | parent::WP_Widget( false, __( 'Jalali Date Calender', 'wp-parsidate' ), 'description=' . __( 'Jalali Date Calender', 'wp-parsidate' ) ); |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | public function form( $instance ) { |
| 18 | global $wpp_settings; |
| 19 | ?> |
| 20 | <p style="text-align:right; direction:rtl"> |
| 21 | <label><?php _e( 'Title:', 'wp-parsidate' ) ?></label> |
| 22 | <input style="width: 200px;" id="<?php echo $this->get_field_id( 'parsidate_calendar_title' ); ?>" |
| 23 | name="<?php echo $this->get_field_name( 'parsidate_calendar_title' ); ?>" type="text" |
| 24 | value="<?php echo( empty( $instance['parsidate_calendar_title'] ) ? __( 'Jalali Date Calender', 'wp-parsidate' ) : $instance['parsidate_calendar_title'] ) ?>"/> |
| 25 | </p> |
| 26 | <?php |
| 27 | if ( $wpp_settings['conv_permalinks'] == 'disable' ) { |
| 28 | echo "<p style='color: #ff8153'>" . __( 'For use widget, active "Fix permalinks dates" option in plugin settings.', 'wp-parsidate' ) . "</p>"; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | public function update( $new_instance, $old_instance ) { |
| 33 | $instance = $old_instance; |
| 34 | $instance['parsidate_calendar_title'] = strip_tags( $new_instance['parsidate_calendar_title'] ); |
| 35 | |
| 36 | return $instance; |
| 37 | } |
| 38 | |
| 39 | public function widget( $args, $instance ) { |
| 40 | global $wpp_settings; |
| 41 | if ( $wpp_settings['conv_permalinks'] == 'disable' ) { |
| 42 | return; |
| 43 | } |
| 44 | echo $args['before_widget']; |
| 45 | if ( ! empty( $instance['parsidate_calendar_title'] ) ) { |
| 46 | echo $args['before_title'] . apply_filters( 'widget_title', $instance['parsidate_calendar_title'] ) . $args['after_title']; |
| 47 | } |
| 48 | wpp_get_calendar(); |
| 49 | echo $args['after_widget']; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | ?> |