PluginProbe ʕ •ᴥ•ʔ
پارسی دیت – Parsi Date / 5.1.2
پارسی دیت – Parsi Date v5.1.2
6.2.1 6.2 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 1 year ago widget_calendar.php 1 year ago
widget_archive.php
186 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 * @param array $instance Current settings.
27 *
28 * @return void Default return is 'noform'.
29 * @since 2.8.0
30 *
31 */
32 public function form( $instance ) {
33 global $wpp_settings;
34
35 $type = isset( $instance['parsidate_archive_type'] ) ? $instance['parsidate_archive_type'] : 'monthly';
36 $instance['parsidate_archive_title'] = isset( $instance['parsidate_archive_title'] ) ? strip_tags( $instance['parsidate_archive_title'] ) : __( 'Jalali Date Archives', '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="weekly" <?php checked( $type, 'weekly' ); ?>/>
75 <?php _e( 'Weekly', 'wp-parsidate' ) ?>
76 </label>
77
78 <br/>
79
80 <label>
81 <input type="radio" id="parsidate_archive_type4"
82 name="<?php echo $this->get_field_name( 'parsidate_archive_type' ); ?>"
83 value="daily" <?php checked( $type, 'daily' ); ?>/>
84 <?php _e( 'Daily', 'wp-parsidate' ) ?>
85 </label>
86
87 <br/>
88 <br/>
89
90 <input type="checkbox" name="<?php echo $this->get_field_name( 'parsidate_archive_count' ); ?>"
91 id="<?php echo $this->get_field_id( 'parsidate_archive_count' ); ?>"
92 value="1" <?php checked( $instance['parsidate_archive_count'], 1 ); ?>/>
93
94 <label for="<?php echo $this->get_field_id( 'parsidate_archive_count' ); ?>">
95 <?php _e( 'Show post counts', 'wp-parsidate' ) ?>
96 </label>
97
98 <br/>
99
100 <input type="checkbox" name="<?php echo $this->get_field_name( 'parsidate_archive_list' ); ?>"
101 id="<?php echo $this->get_field_id( 'parsidate_archive_list' ); ?>"
102 value="1" <?php echo checked( $instance['parsidate_archive_list'], 1 ); ?>/>
103
104 <label for="<?php echo $this->get_field_id( 'parsidate_archive_list' ); ?>">
105 <?php _e( 'Display as dropdown', 'wp-parsidate' ) ?>
106 </label>
107
108 </p>
109 <?php
110 if ( empty( $wpp_settings['conv_permalinks'] ) ) {
111 echo "<p style='color: #ff8153'>" . __( 'For use widget, active "Fix permalinks dates" option in plugin settings.',
112 'wp-parsidate' ) . "</p>";
113 }
114 }
115
116 /**
117 * Updates a particular instance of a widget.
118 *
119 * This function should check that `$new_instance` is set correctly. The newly-calculated
120 * value of `$instance` should be returned. If false is returned, the instance won't be
121 * saved/updated.
122 *
123 * @param array $new_instance New settings for this instance as input by the user via
124 * WP_Widget::form().
125 * @param array $old_instance Old settings for this instance.
126 *
127 * @return array Settings to save or bool false to cancel saving.
128 * @since 2.8.0
129 *
130 */
131 public function update( $new_instance, $old_instance ) {
132 $instance = $old_instance;
133 $instance['parsidate_archive_title'] = isset( $new_instance['parsidate_archive_title'] ) ? strip_tags( $new_instance['parsidate_archive_title'] ) : __( 'Jalali Date Archives', 'wp-parsidate' );
134 $instance['parsidate_archive_count'] = isset( $new_instance['parsidate_archive_count'] ) ? $new_instance['parsidate_archive_count'] : 0;
135 $instance['parsidate_archive_list'] = isset( $new_instance['parsidate_archive_list'] ) ? $new_instance['parsidate_archive_list'] : 0;
136 $instance['parsidate_archive_type'] = isset( $new_instance['parsidate_archive_type'] ) ? $new_instance['parsidate_archive_type'] : 'monthly';
137
138 return $instance;
139 }
140
141 /**
142 * Echoes the widget content.
143 *
144 * Subclasses should override this function to generate their widget code.
145 *
146 * @param array $args Display arguments including 'before_title', 'after_title',
147 * 'before_widget', and 'after_widget'.
148 * @param array $instance The settings for the particular instance of the widget.
149 *
150 * @since 2.8.0
151 *
152 */
153 public function widget( $args, $instance ) {
154 if ( ! wpp_is_active( 'conv_permalinks' ) ) {
155 return;
156 }
157
158 $type = isset( $instance['parsidate_archive_type'] ) ? $instance['parsidate_archive_type'] : 'monthly';
159 $title = isset( $instance['parsidate_archive_title'] ) ? $instance['parsidate_archive_title'] : __( 'Jalali Date Archives', 'wp-parsidate' );
160 $post_count = isset( $instance['parsidate_archive_count'] ) ? $instance['parsidate_archive_count'] : false;
161 $ddl_style = isset( $instance['parsidate_archive_list'] ) && $instance['parsidate_archive_list'];
162
163 echo $args['before_widget'];
164 if ( ! empty( $instance['parsidate_archive_title'] ) ) {
165 echo $args['before_title'] . apply_filters( 'widget_title',
166 $instance['parsidate_archive_title'] ) . $args['after_title'];
167 }
168
169 if ( $ddl_style ) {
170 echo "<select name='parsidate_archive_list' onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value='0'>" . esc_attr( $title ) . "</option>";
171
172 wp_get_parchives( "type=$type&format=option&show_post_count=$post_count" );
173
174 echo '</select>';
175 } else {
176 echo '<ul>';
177
178 wpp_get_archives( "type=$type&show_post_count=$post_count" );
179
180 echo '</ul>';
181 }
182
183 echo $args['after_widget'];
184 }
185 }
186