-
Notifications
You must be signed in to change notification settings - Fork 2
/
wp-jalali.php
196 lines (176 loc) · 5.12 KB
/
wp-jalali.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
/**
* Plugin Name: wp-jalali
* Version: 5.1
* Plugin URI: http://wp-persian.com/wp-jalali
* Description: Full Jalali calendar support for Wordpress and localization improvements for Persian/Afghan/Tajik users.
* Author: WP Persian Team
* Author URI: http://wp-persian.com
* Text Domain: wp-parsidate
* Domain Path: parsi-languages
* License: GPL3
*
* Copyright 2005-2020 Wordpress Persian Project (email : [email protected])
* wp-jalali is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
*
* wp-jalali is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WP-Parsidate.
*
*
* WordPress Parsi Package, Adds Persian language & Jalali date support to your blog
*
* Developers:
* Mani Monajjemi
* Gonahkar
* Reza Moallemi
* Zakrot Web Solutions
* WP Parsi team
*/
if (!defined('ABSPATH')) exit; //No direct access allowed
final class WP_Parsidate
{
/**
* @var WP_Parsidate Class instance
*/
public static $instance = null;
private function __construct()
{
$this->define_const();
$this->setup_vars();
$this->include_files();
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'parsi_settings_link'));
add_action('widgets_init', array($this, 'register_widget'));
}
/**
* Sets up constants for plugin
*
* @return void
* @since 2.0
*/
private function define_const()
{
if (!defined('WP_PARSI_ROOT')) {
define('WP_PARSI_ROOT', __FILE__);
}
if (!defined('WP_PARSI_DIR')) {
define('WP_PARSI_DIR', plugin_dir_path(WP_PARSI_ROOT));
}
if (!defined('WP_PARSI_URL')) {
define('WP_PARSI_URL', plugin_dir_url(WP_PARSI_ROOT));
}
if (!defined('WP_PARSI_VER')) {
define('WP_PARSI_VER', '2.2');
}
}
/**
* Sets up global variables
*
* @return void
* @since 2.0
*/
private function setup_vars()
{
global $persian_month_names;
$persian_month_names = array(
'',
'فروردین',
'اردیبهشت',
'خرداد',
'تیر',
'مرداد',
'شهریور',
'مهر',
'آبان',
'آذر',
'دی',
'بهمن',
'اسفند'
);
}
/**
* Includes files for plugin
*
* @return void
* @since 2.0
*/
public function include_files()
{
require_once(WP_PARSI_DIR . 'includes/settings.php');
global $wpp_settings;
$wpp_settings = wp_parsi_get_settings();
$files = array(
'parsidate',
'jalali',
'general',
'fixes-archive',
'fixes-permalinks',
'fixes-dates',
'fixes-misc',
'admin/styles-fix',
//'admin/datepicker-rtl',
'admin/gutenberg-jalali-calendar',
'admin/lists-fix',
'admin/widgets',
'fixes-calendar',
'fixes-archives',
'plugins/woocommerce',
//'plugins/fixes-woo',
'plugins/edd',
'plugins/disable',
'widget/widget_archive',
'widget/widget_calendar'
);
foreach ($files as $file) {
require_once(WP_PARSI_DIR . 'includes/' . $file . '.php');
}
if (get_locale() == 'fa_IR') {
load_textdomain('wp-parsidate', WP_PARSI_DIR . 'languages/fa_IR.mo');
}
}
/**
* Returns an instance of WP_Parsidate class, makes instance if not exists
*
* @return WP_Parsidate Instance of WP_Parsidate
* @since 2.0
*/
public static function get_instance()
{
if (self::$instance == null) {
self::$instance = new WP_Parsidate();
}
return self::$instance;
}
/**
* Add Setting Link To Install Plugin
*
* @param array $links
*
* @return array
*/
public static function parsi_settings_link($links)
{
$settings_link = array('<a href="' . menu_page_url('wp-parsi-settings', false) . '">' . __('settings', 'wp-parsidate') . '</a>');
return array_merge($links, $settings_link);
}
/**
* Register Plugin Widgets
*
* @return boolean
* @since 2.0
*/
public function register_widget()
{
register_widget('parsidate_archive');
register_widget('parsidate_calendar');
return true;
}
}
return WP_Parsidate::get_instance();