PluginProbe ʕ •ᴥ•ʔ
پارسی دیت – Parsi Date / 6.2.1
پارسی دیت – Parsi Date v6.2.1
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 / inc / App / Core / ShamsiDate.php
wp-parsidate / inc / App / Core Last commit date
Core.php 3 weeks ago Debug.php 3 weeks ago FixDates.php 3 weeks ago FixPermalink.php 3 weeks ago FixTitle.php 3 weeks ago ShamsiDate.php 3 weeks ago
ShamsiDate.php
147 lines
1 <?php
2
3 namespace WPParsidate\App\Core;
4
5 use WPParsidate\Helper\WordPress;
6 use WPParsidate\Settings\Settings;
7
8 class ShamsiDate {
9 private const sectionID = 'shamsi-date';
10
11 public function __construct() {
12 add_filter( 'wp_parsidate_core_settings_sections', [ $this, 'addSectionSettings' ] );
13 add_action( 'init', [ $this, 'disableGutenbergBlocksWidget' ] );
14 }
15
16 /**
17 * disable wp widget block that introduced in WordPress 5.8
18 *
19 * @since 4.0.0
20 */
21 public function disableGutenbergBlocksWidget(): void {
22 if ( Settings::get( 'disable_widget_block', false ) ) {
23 add_filter( 'gutenberg_use_widgets_block_editor', '__return_false' );
24 add_filter( 'use_widgets_block_editor', '__return_false' );
25 }
26 }
27
28 public function addSectionSettings( array $sections ): array {
29 $settings = array(
30 // Date
31 'start_grid_date' => array(
32 'title' => esc_html__( 'Date', 'wp-parsidate' ),
33 'type' => 'startGrid',
34 ),
35 'persian_date' => array(
36 'id' => 'persian_date',
37 'title' => esc_html__( 'Shamsi date', 'wp-parsidate' ),
38 'type' => 'toggle',
39 'default' => false,
40 'desc' => esc_html__( 'By enabling this, Dates will convert to Shamsi (Jalali) dates', 'wp-parsidate' ),
41 'sanitize' => 'bool'
42 ),
43 'dual_date' => array(
44 'id' => 'dual_date',
45 'title' => esc_html__( 'Dual date', 'wp-parsidate' ),
46 'type' => 'toggle',
47 'default' => false,
48 'desc' => esc_html__( 'By enabling this, Gregorian dates will be displayed beside Shamsi (Jalali) dates.',
49 'wp-parsidate' ),
50 'sanitize' => 'bool'
51 ),
52 'months_name_type' => array(
53 'id' => 'months_name_type',
54 'title' => esc_html__( 'Months and week days name type', 'wp-parsidate' ),
55 'type' => 'select',
56 'options' => array(
57 'persian' => esc_html__( 'Persian', 'wp-parsidate' ),
58 'dari' => esc_html__( 'Dari', 'wp-parsidate' ),
59 'kurdish' => esc_html__( 'Kurdish', 'wp-parsidate' ),
60 'pashto' => esc_html__( 'Pashto', 'wp-parsidate' ),
61 ),
62 'default' => 'persian',
63 'sanitize' => 'text'
64 ),
65 'end_grid_date' => array(
66 'type' => 'endGrid',
67 ),
68
69 // Permalinks
70 'start_grid_permalinks' => array(
71 'title' => esc_html__( 'Permalinks', 'wp-parsidate' ),
72 'type' => 'startGrid',
73 ),
74 'conv_permalinks' => array(
75 'id' => 'conv_permalinks',
76 'title' => esc_html__( 'Fix permalinks dates', 'wp-parsidate' ),
77 'type' => 'toggle',
78 'default' => false,
79 'desc' => esc_html__( 'By enabling this, dates in permalinks converted to Shamsi (Jalali) date',
80 'wp-parsidate' ),
81 'sanitize' => 'bool'
82 ),
83 'end_grid_permalinks' => array(
84 'type' => 'endGrid',
85 ),
86
87 // Admin
88 'start_grid_admin' => array(
89 'title' => esc_html__( 'Admin', 'wp-parsidate' ),
90 'type' => 'startGrid',
91 ),
92 'disable_widget_block' => array(
93 'id' => 'disable_widget_block',
94 'title' => esc_html__( 'Disable Widget Block', 'wp-parsidate' ),
95 'type' => 'toggle',
96 'default' => false,
97 'desc' => esc_html__( 'By enabling this, Widget Block Editor disabled', 'wp-parsidate' ),
98 'sanitize' => 'bool'
99 ),
100 'enable_fonts' => array(
101 'id' => 'enable_fonts',
102 'title' => esc_html__( 'Vazir Font', 'wp-parsidate' ),
103 'type' => 'toggle',
104 'default' => false,
105 'desc' => esc_html__( 'By enabling this option, the Vazir font will be enable in whole admin area.',
106 'wp-parsidate' ),
107 'sanitize' => 'bool'
108 ),
109 'end_grid_admin' => array(
110 'type' => 'endGrid',
111 )
112 );
113
114 if ( WordPress::isMultilingualActive() ) {
115 $settings = array_merge( $settings, array(
116 'sep_multilingual' => array(
117 'type' => 'hr',
118 ),
119 'start_grid_multilingual' => array(
120 'title' => esc_html__( 'Multilingual', 'wp-parsidate' ),
121 'type' => 'startGrid',
122 ),
123 'multilingual_support' => array(
124 'id' => 'multilingual_support',
125 'title' => esc_html__( 'Multilingual compatibility', 'wp-parsidate' ),
126 'type' => 'toggle',
127 'default' => false,
128 'desc' => esc_html__( 'By enabling this, ParsiDate options only work in persian locale',
129 'wp-parsidate' ),
130 'sanitize' => 'bool'
131 ),
132 'end_grid_multilingual' => array(
133 'type' => 'endGrid',
134 ),
135 ) );
136 }
137
138 $sections[ self::sectionID ] = array(
139 'title' => esc_html__( 'Shamsi date', 'wp-parsidate' ),
140 'desc' => esc_html__( 'Shamsi date settings', 'wp-parsidate' ),
141 'settings' => $settings
142 );
143
144 return $sections;
145 }
146 }
147