PluginProbe ʕ •ᴥ•ʔ
پارسی دیت – Parsi Date / 4.0.0
پارسی دیت – Parsi Date v4.0.0
6.1 5.1.6 5.1.7 5.1.8 5.1.8.2 6.0 trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.0.0-alpha 2.1 2.1.1 2.1.2 2.1.3 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0.1 2.3.0.2 2.3.1 2.3.2 2.3.3 2.3.4 3.0.1 3.0.2 3.0.3 4.0.0 4.0.1 4.0.2 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5
wp-parsidate / includes / widget / widget_archive.php
wp-parsidate / includes / widget Last commit date
widget_archive.php 4 years ago widget_calendar.php 4 years ago
widget_archive.php
174 lines
1 <?php
2
3 defined('ABSPATH') OR exit('No direct script access allowed');
4
5 /**
6 * @author lord_viper
7 * @copyright 2013
8 */
9 class parsidate_archive extends WP_Widget {
10 public function __construct() {
11 global $wp_version;
12
13 // backwards compatibility
14 if ( version_compare( $wp_version, '4.3', '>=' ) ) {
15 parent::__construct( false, __( 'Jalali Date Archives', 'wp-parsidate' ),
16 'description=' . __( 'Jalali Date Archives', 'wp-parsidate' ) );
17 } else {
18 parent::WP_Widget( false, __( 'Jalali Date Archives', 'wp-parsidate' ),
19 'description=' . __( 'Jalali Date Archives', 'wp-parsidate' ) );
20 }
21 }
22
23 /**
24 * Outputs the settings update form.
25 *
26 * @since 2.8.0
27 *
28 * @param array $instance Current settings.
29 * @return void Default return is 'noform'.
30 */
31 public function form( $instance ) {
32 global $wpp_settings;
33
34 $type = isset( $instance['parsidate_archive_type'] ) ? $instance['parsidate_archive_type'] : 'monthly';
35 $instance['parsidate_archive_title'] = isset( $instance['parsidate_archive_title'] ) ? strip_tags( $instance['parsidate_archive_title'] ) : __( 'Jalali Date Archives',
36 'wp-parsidate' );
37 $instance['parsidate_archive_count'] = isset( $instance['parsidate_archive_count'] ) ? $instance['parsidate_archive_count'] : 0;
38 $instance['parsidate_archive_list'] = isset( $instance['parsidate_archive_list'] ) ? $instance['parsidate_archive_list'] : 0;
39 ?>
40 <p style="text-align:right; direction:rtl">
41
42 <label for="<?php echo $this->get_field_id( 'parsidate_archive_title' ); ?>"><?php _e( 'Title' ) ?>:</label>
43
44 <input style="width: 200px;" id="<?php echo $this->get_field_id( 'parsidate_archive_title' ); ?>"
45 name="<?php echo $this->get_field_name( 'parsidate_archive_title' ); ?>" type="text"
46 value="<?php echo( empty( $instance['parsidate_archive_title'] ) ? __( 'Jalali Date Archives',
47 'wp-parsidate' ) : $instance['parsidate_archive_title'] ) ?>"/>
48
49 <br><br>
50
51 <span><?php _e( 'How to display', 'wp-parsidate' ) ?>:</span><br>
52
53 <label>
54 <input type="radio" id="parsidate_archive_type1"
55 name="<?php echo $this->get_field_name( 'parsidate_archive_type' ); ?>"
56 value="yearly" <?php checked( $type, 'yearly' ); ?>/>
57 <?php _e( 'Yearly', 'wp-parsidate' ) ?>
58 </label>
59
60 <br/>
61
62 <label>
63 <input type="radio" id="parsidate_archive_type2"
64 name="<?php echo $this->get_field_name( 'parsidate_archive_type' ); ?>"
65 value="monthly" <?php checked( $type, 'monthly' ); ?>/>
66 <?php _e( 'Monthly', 'wp-parsidate' ) ?>
67 </label>
68
69 <br/>
70
71 <label>
72 <input type="radio" id="parsidate_archive_type3"
73 name="<?php echo $this->get_field_name( 'parsidate_archive_type' ); ?>"
74 value="daily" <?php checked( $type, 'daily' ); ?>/>
75 <?php _e( 'Daily', 'wp-parsidate' ) ?>
76 </label>
77
78 <br/>
79 <br/>
80
81 <input type="checkbox" name="<?php echo $this->get_field_name( 'parsidate_archive_count' ); ?>"
82 id="<?php echo $this->get_field_id( 'parsidate_archive_count' ); ?>"
83 value="1" <?php checked( $instance['parsidate_archive_count'], 1 ); ?>/>
84
85 <label for="<?php echo $this->get_field_id( 'parsidate_archive_count' ); ?>">
86 <?php _e( 'Show post counts', 'wp-parsidate' ) ?>
87 </label>
88
89 <br/>
90
91 <input type="checkbox" name="<?php echo $this->get_field_name( 'parsidate_archive_list' ); ?>"
92 id="<?php echo $this->get_field_id( 'parsidate_archive_list' ); ?>"
93 value="1" <?php echo checked( $instance['parsidate_archive_list'], 1 ); ?>/>
94
95 <label for="<?php echo $this->get_field_id( 'parsidate_archive_list' ); ?>">
96 <?php _e( 'Display as dropdown', 'wp-parsidate' ) ?>
97 </label>
98
99 </p>
100 <?php
101 if ( empty($wpp_settings['conv_permalinks'] ) ) {
102 echo "<p style='color: #ff8153'>" . __( 'For use widget, active "Fix permalinks dates" option in plugin settings.',
103 'wp-parsidate' ) . "</p>";
104 }
105 }
106
107 /**
108 * Updates a particular instance of a widget.
109 *
110 * This function should check that `$new_instance` is set correctly. The newly-calculated
111 * value of `$instance` should be returned. If false is returned, the instance won't be
112 * saved/updated.
113 *
114 * @since 2.8.0
115 *
116 * @param array $new_instance New settings for this instance as input by the user via
117 * WP_Widget::form().
118 * @param array $old_instance Old settings for this instance.
119 * @return array Settings to save or bool false to cancel saving.
120 */
121 public function update( $new_instance, $old_instance ) {
122 $instance = $old_instance;
123 $instance['parsidate_archive_title'] = isset( $new_instance['parsidate_archive_title'] ) ? strip_tags( $new_instance['parsidate_archive_title'] ) : __( 'Jalali Date Archives', 'wp-parsidate' );
124 $instance['parsidate_archive_count'] = isset( $new_instance['parsidate_archive_count'] ) ? $new_instance['parsidate_archive_count'] : 0;
125 $instance['parsidate_archive_list'] = isset( $new_instance['parsidate_archive_list'] ) ? $new_instance['parsidate_archive_list'] : 0;
126 $instance['parsidate_archive_type'] = isset( $new_instance['parsidate_archive_type'] ) ? $new_instance['parsidate_archive_type'] : 'monthly';
127
128 return $instance;
129 }
130
131 /**
132 * Echoes the widget content.
133 *
134 * Subclasses should override this function to generate their widget code.
135 *
136 * @since 2.8.0
137 *
138 * @param array $args Display arguments including 'before_title', 'after_title',
139 * 'before_widget', and 'after_widget'.
140 * @param array $instance The settings for the particular instance of the widget.
141 */
142 public function widget( $args, $instance ) {
143 if ( wpp_is_active('conv_permalinks' ) ) {
144 return;
145 }
146
147 $type = isset( $instance['parsidate_archive_type'] ) ? $instance['parsidate_archive_type'] : 'monthly';
148 $title = isset( $instance['parsidate_archive_title'] ) ? $instance['parsidate_archive_title'] : __( 'Jalali Date Archives', 'wp-parsidate' );
149 $post_count = isset( $instance['parsidate_archive_count'] ) ? $instance['parsidate_archive_count'] : false;
150 $ddl_style = isset( $instance['parsidate_archive_list'] ) && $instance['parsidate_archive_list'];
151
152 echo $args['before_widget'];
153 if ( ! empty( $instance['parsidate_archive_title'] ) ) {
154 echo $args['before_title'] . apply_filters( 'widget_title',
155 $instance['parsidate_archive_title'] ) . $args['after_title'];
156 }
157
158 if ( $ddl_style ) {
159 echo "<select name='parsidate_archive_list' onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value='0'>" . esc_attr( $title ) . "</option>";
160
161 wp_get_parchives( "type=$type&format=option&show_post_count=$post_count" );
162
163 echo '</select>';
164 } else {
165 echo '<ul>';
166
167 wpp_get_archives( "type=$type&show_post_count=$post_count" );
168
169 echo '</ul>';
170 }
171
172 echo $args['after_widget'];
173 }
174 }