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_calendar.php
wp-parsidate / includes / widget Last commit date
widget_archive.php 1 year ago widget_calendar.php 1 year ago
widget_calendar.php
133 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_calendar extends WP_Widget {
10 public function __construct() {
11 global $wp_version;
12
13 if ( version_compare( $wp_version, '4.3', '>=' ) ) {
14 parent::__construct( false, __( 'Jalali Date Calender', 'wp-parsidate' ), 'description=' . __( 'Jalali Date Calender', 'wp-parsidate' ) );
15 } else {
16 parent::WP_Widget( false, __( 'Jalali Date Calender', 'wp-parsidate' ), 'description=' . __( 'Jalali Date Calender', 'wp-parsidate' ) );
17 }
18 }
19
20 /**
21 * Outputs the settings update form.
22 *
23 * @param array $instance Current settings.
24 *
25 * @return void Default return is 'noform'.
26 * @since 2.8.0
27 *
28 */
29 public function form( $instance ) {
30 $title = ! empty( $instance['parsidate_calendar_title'] ) ? $instance['parsidate_calendar_title'] : __( 'Jalali Date Calender', 'wp-parsidate' );
31 $theme = ! empty( $instance['theme_color'] ) ? $instance['theme_color'] : 'light-mode';
32
33 if ( ! wpp_is_active( 'conv_permalinks' ) ) {
34 echo "<p style='color: #ff8153'>" . __( 'For use widget, active "Fix permalinks dates" option in plugin settings.', 'wp-parsidate' ) . "</p>";
35 }
36 ?>
37 <p style="text-align:right; direction:rtl">
38 <label for="<?php echo $this->get_field_id( 'parsidate_calendar_title' ); ?>">
39 <?php _e( 'Title:', 'wp-parsidate' ) ?></label>
40
41 <input style="width:calc(100% - 120px);float:left"
42 id="<?php echo $this->get_field_id( 'parsidate_calendar_title' ); ?>"
43 name="<?php echo $this->get_field_name( 'parsidate_calendar_title' ); ?>" type="text"
44 value="<?php echo esc_attr( $title ); ?>"/>
45 </p>
46
47 <p style="text-align:right; direction:rtl">
48 <label for="<?php echo $this->get_field_id( 'theme-color' ); ?>">
49 <?php _e( 'Theme color:', 'wp-parsidate' ) ?></label>
50
51 <select style="width:calc(100% - 120px);float:left" id="<?php echo $this->get_field_id( 'theme-color' ); ?>"
52 name="<?php echo $this->get_field_name( 'theme-color' ); ?>">
53 <option value="light-mode" <?php selected( $theme, 'light-mode' ); ?>>
54 <?php _e( 'Light Mode', 'wp-parsidate' ) ?>
55 </option>
56 <option value="dark-mode" <?php selected( $theme, 'dark-mode' ); ?>>
57 <?php _e( 'Dark Mode', 'wp-parsidate' ) ?>
58 </option>
59 </select>
60 </p>
61 <?php
62 }
63
64 /**
65 * Updates a particular instance of a widget.
66 *
67 * This function should check that `$new_instance` is set correctly. The newly-calculated
68 * value of `$instance` should be returned. If false is returned, the instance won't be
69 * saved/updated.
70 *
71 * @param array $new_instance New settings for this instance as input by the user via
72 * WP_Widget::form().
73 * @param array $old_instance Old settings for this instance.
74 *
75 * @return array Settings to save or bool false to cancel saving.
76 * @since 2.8.0
77 *
78 */
79 public function update( $new_instance, $old_instance ) {
80 $instance = $old_instance;
81 $instance['parsidate_calendar_title'] = esc_html( $new_instance['parsidate_calendar_title'] );
82 $instance['theme_color'] = esc_attr( $new_instance['theme-color'] );
83
84 return $instance;
85 }
86
87 /**
88 * Echoes the widget content.
89 *
90 * Subclasses should override this function to generate their widget code.
91 *
92 * @param array $args Display arguments including 'before_title', 'after_title',
93 * 'before_widget', and 'after_widget'.
94 * @param array $instance The settings for the particular instance of the widget.
95 *
96 * @since 2.8.0
97 *
98 */
99 public function widget( $args, $instance ) {
100 if ( ! wpp_is_active( 'conv_permalinks' ) ) {
101 return;
102 }
103
104 $theme = ! empty( $instance['theme_color'] ) ? $instance['theme_color'] : 'light-mode';
105 $widget_id = $args['widget_id'];
106
107 echo $args['before_widget'];
108
109 if ( ! empty( $instance['parsidate_calendar_title'] ) ) {
110 echo $args['before_title'] . apply_filters( 'widget_title', $instance['parsidate_calendar_title'] ) . $args['after_title'];
111 }
112
113 wpp_get_calendar();
114
115 echo $args['after_widget'];
116
117 if ( $theme === 'dark-mode' ) {
118 echo "<style>#$widget_id{background:#141414;border-radius:8px 8px 4px 4px;" .
119 "overflow:hidden;box-shadow:0 0 5px 0 #000;text-align:center;padding-top:15px;color:#dcdcdc}" .
120 "#$widget_id table{direction:rtl;border-radius:12px;overflow:hidden;" .
121 "background:#1d1d1d;box-shadow:inset 0 0 0 6px #141414}#$widget_id table th," .
122 "#$widget_id table td{border:0}#$widget_id table th:last-child," .
123 "#$widget_id table tr td:last-child{color:#f28a8a}</style>";
124 } else {
125 echo "<style>#$widget_id{background:#dbdbdb;border-radius:12px;overflow:hidden;" .
126 "box-shadow:0 0 15px 0 #0000004f,inset 0 0 0 1px #8080806e;text-align:center;padding-top:15px;" .
127 "color:#1e1e1e}#$widget_id table{direction:rtl;border-radius:9px;overflow:hidden;" .
128 "background:#fdfdfd;box-shadow:0 -13px 14px 0 #8080801a}#$widget_id table th," .
129 "#$widget_id table td{border:0}#$widget_id table th:last-child," .
130 "#$widget_id table tr td:last-child{color:#bf4a4a}</style>";
131 }
132 }
133 }