Version Description
- Conflict timezone with wordpress default timezone #issue
Download this release
Release Info
Developer | mostafa.s1990 |
Plugin | Parsi Date |
Version | 2.2.3 |
Comparing to | |
See all releases |
Code changes from version 2.2.2 to 2.2.3
- README.md +19 -0
- includes/admin/lists-fix.php +49 -43
- includes/admin/other-fix.php +33 -37
- includes/admin/styles-fix.php +23 -17
- includes/fixes-archive.php +14 -13
- includes/fixes-archives.php +151 -172
- includes/fixes-calendar.php +202 -201
- includes/fixes-dates.php +68 -63
- includes/fixes-misc.php +20 -20
- includes/fixes-permalinks.php +284 -280
- includes/general.php +74 -57
- includes/install.php +12 -11
- includes/parsidate.php +313 -298
- includes/plugins/edd.php +71 -66
- includes/plugins/woocommerce.php +55 -51
- includes/settings.php +338 -316
- includes/widget/widget_archive.php +1 -1
- includes/widget/widget_calendar.php +33 -32
- readme.txt +3 -0
- wp-parsidate.php +176 -174
README.md
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Persian date support for WordPress
|
2 |
+
|
3 |
+
Description
|
4 |
+
-----------
|
5 |
+
|
6 |
+
This package is made by Persian developers to bring so much better experience of Persian WordPress. It includes Shamsi (Jalali) calendar, character issues fixes and Right-To-Left fix for WordPress back-end environment.
|
7 |
+
|
8 |
+
List of some features:
|
9 |
+
|
10 |
+
- Shamsi (Jalali) date in Posts, comments, pages, archives, search, categories
|
11 |
+
- Shamsi (Jalali) date in Permalinks
|
12 |
+
- Shamsi (Jalali) date in admin sections such as posts lists, comments lists, pages lists
|
13 |
+
- Shamsi (Jalali) date in post quick edit, comment quick edit, page quick edit of admin panel
|
14 |
+
- Shamsi (Jalali) calender widget
|
15 |
+
- Shamsi (Jalali) archive widget
|
16 |
+
- RTL and fixed tinymce editor
|
17 |
+
- Poweful and fast function for fixing Arabic (ي , ك) to Persian (ی , ک)
|
18 |
+
- Poweful and fast function for Persian numbers
|
19 |
+
- Low resources usage
|
includes/admin/lists-fix.php
CHANGED
@@ -13,22 +13,26 @@
|
|
13 |
* @author Ehsaan
|
14 |
* @return void
|
15 |
*/
|
16 |
-
function wpp_enqueue_admin_scripts()
|
17 |
-
|
18 |
-
|
|
|
19 |
}
|
20 |
-
|
|
|
21 |
|
22 |
/**
|
23 |
* Hooks admin functions for restrict posts in edit pages
|
24 |
*
|
25 |
* @return void
|
26 |
*/
|
27 |
-
function wpp_backend_init()
|
28 |
-
|
29 |
-
|
|
|
30 |
}
|
31 |
-
|
|
|
32 |
|
33 |
/**
|
34 |
* Limits posts to a certain date, if date setted
|
@@ -36,14 +40,15 @@ add_action( 'load-edit.php', 'wpp_backend_init' );
|
|
36 |
* @param string $where Query pointer
|
37 |
* @return string New Pointer
|
38 |
*/
|
39 |
-
function wpp_admin_posts_where(
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
45 |
|
46 |
-
|
47 |
}
|
48 |
|
49 |
/**
|
@@ -52,40 +57,41 @@ function wpp_admin_posts_where( $where ) {
|
|
52 |
* @author Parsa Kafi
|
53 |
* @return void
|
54 |
*/
|
55 |
-
function wpp_restrict_posts()
|
56 |
-
|
|
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
|
65 |
-
|
66 |
FROM $wpdb->posts
|
67 |
WHERE post_type='$post_type' {$post_status_w} AND date( post_date ) <> '0000-00-00'
|
68 |
ORDER BY post_date";
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
72 |
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
$date = parsidate( 'Ym', $date, 'eng' );
|
80 |
-
$year = substr( $date, 0, 4 );
|
81 |
-
$month = substr( $date, 4, 2 );
|
82 |
-
$month = $persian_month_names[intval( $month )];
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
$predate = $date;
|
89 |
-
}
|
90 |
-
echo '</select>';
|
91 |
}
|
13 |
* @author Ehsaan
|
14 |
* @return void
|
15 |
*/
|
16 |
+
function wpp_enqueue_admin_scripts()
|
17 |
+
{
|
18 |
+
wp_register_script('wpp_admin', WP_PARSI_URL . 'assets/js/admin.js', false, WP_PARSI_VER);
|
19 |
+
wp_enqueue_script('wpp_admin');
|
20 |
}
|
21 |
+
|
22 |
+
add_action('admin_enqueue_scripts', 'wpp_enqueue_admin_scripts');
|
23 |
|
24 |
/**
|
25 |
* Hooks admin functions for restrict posts in edit pages
|
26 |
*
|
27 |
* @return void
|
28 |
*/
|
29 |
+
function wpp_backend_init()
|
30 |
+
{
|
31 |
+
add_action('restrict_manage_posts', 'wpp_restrict_posts');
|
32 |
+
add_filter('posts_where', 'wpp_admin_posts_where');
|
33 |
}
|
34 |
+
|
35 |
+
add_action('load-edit.php', 'wpp_backend_init');
|
36 |
|
37 |
/**
|
38 |
* Limits posts to a certain date, if date setted
|
40 |
* @param string $where Query pointer
|
41 |
* @return string New Pointer
|
42 |
*/
|
43 |
+
function wpp_admin_posts_where($where)
|
44 |
+
{
|
45 |
+
global $wp_query;
|
46 |
+
if (isset($_GET['mfa']) && $_GET['mfa'] != '0') {
|
47 |
+
$wp_query->query_vars['m'] = $_GET['mfa'];
|
48 |
+
$where = wpp_posts_where($where);
|
49 |
+
}
|
50 |
|
51 |
+
return $where;
|
52 |
}
|
53 |
|
54 |
/**
|
57 |
* @author Parsa Kafi
|
58 |
* @return void
|
59 |
*/
|
60 |
+
function wpp_restrict_posts()
|
61 |
+
{
|
62 |
+
global $post_type, $post_status, $wpdb, $persian_month_names;
|
63 |
|
64 |
+
$post_status_w = "AND post_status <> 'auto-draft'";
|
65 |
+
if ($post_status != "") {
|
66 |
+
if (is_string($post_status))
|
67 |
+
$post_status_w .= " AND post_status = '$post_status'";
|
68 |
+
} else
|
69 |
+
$post_status_w .= " AND post_status <> 'trash'";
|
70 |
|
71 |
+
$sql = "SELECT DISTINCT date( post_date ) AS date
|
72 |
FROM $wpdb->posts
|
73 |
WHERE post_type='$post_type' {$post_status_w} AND date( post_date ) <> '0000-00-00'
|
74 |
ORDER BY post_date";
|
75 |
+
$list = $wpdb->get_col($sql);
|
76 |
+
if (empty($list))
|
77 |
+
return;
|
78 |
+
|
79 |
+
$m = isset($_GET['mfa']) ? (int)$_GET['mfa'] : 0;
|
80 |
+
$predate = '';
|
81 |
|
82 |
+
echo '<select name="mfa">';
|
83 |
+
echo '<option ' . selected($m, 0, false) . ' value="0">' . __('Show All Dates', 'wp-parsidate') . '</option>' . PHP_EOL;
|
84 |
+
foreach ($list as $date) {
|
85 |
+
$date = parsidate('Ym', $date, 'eng');
|
86 |
+
$year = substr($date, 0, 4);
|
87 |
+
$month = substr($date, 4, 2);
|
88 |
+
$month = $persian_month_names[intval($month)];
|
89 |
|
90 |
+
if ($predate != $date) {
|
91 |
+
echo sprintf('<option %s value="%s">%s</option>', selected($m, $date, false), $date, $month . ' ' . fixnumber($year));
|
92 |
+
}
|
|
|
|
|
|
|
|
|
93 |
|
94 |
+
$predate = $date;
|
95 |
+
}
|
96 |
+
echo '</select>';
|
|
|
|
|
|
|
|
|
97 |
}
|
includes/admin/other-fix.php
CHANGED
@@ -5,50 +5,46 @@
|
|
5 |
* @package WP-Parsidate
|
6 |
* @subpackage Admin/Other
|
7 |
*/
|
8 |
-
|
9 |
-
if ( ! defined( 'ABSPATH' ) ) exit; // No direct access allowed
|
10 |
|
11 |
-
if(
|
|
|
|
|
12 |
/**
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
{
|
27 |
-
preg_match('/<a href="(.+)">/', $link, $href);
|
28 |
-
if(! wp_http_validate_url($href[1]))
|
29 |
-
{
|
30 |
preg_match('!https?://\S+!', $link, $url);
|
31 |
-
$link_f = ' صورت '.'<a href="'
|
32 |
$buffer = str_replace($link, $link_f, $buffer);
|
33 |
}
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
global $pagenow;
|
46 |
-
if($pagenow == 'plugins.php')
|
47 |
ob_start("wpp_plugins_update_link_fix");
|
48 |
-
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
}
|
5 |
* @package WP-Parsidate
|
6 |
* @subpackage Admin/Other
|
7 |
*/
|
|
|
|
|
8 |
|
9 |
+
if (!defined('ABSPATH')) exit; // No direct access allowed
|
10 |
+
|
11 |
+
if (is_admin()) {
|
12 |
/**
|
13 |
+
* Fix Broken Plugins Update Link
|
14 |
+
*
|
15 |
+
* @author Parsa Kafi
|
16 |
+
* @parms string $buffer admin page
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
function wpp_plugins_update_link_fix($buffer)
|
20 |
+
{
|
21 |
+
if (get_locale() == 'fa_IR') {
|
22 |
+
if (preg_match_all('(صورت <a.*?>خودکار بهروز کنید<\/a>)', $buffer, $update_links)) {
|
23 |
+
foreach ($update_links[0] as $link) {
|
24 |
+
preg_match('/<a href="(.+)">/', $link, $href);
|
25 |
+
if (!wp_http_validate_url($href[1])) {
|
|
|
|
|
|
|
|
|
26 |
preg_match('!https?://\S+!', $link, $url);
|
27 |
+
$link_f = ' صورت ' . '<a href="' . $url[0] . '"> خودکار بهروز کنید</a>';
|
28 |
$buffer = str_replace($link, $link_f, $buffer);
|
29 |
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
return $buffer;
|
35 |
+
}
|
36 |
|
37 |
+
add_action('init', 'wpp_admin_buffer_start');
|
38 |
+
add_action('admin_footer', 'wpp_admin_buffer_end');
|
39 |
+
function wpp_admin_buffer_start()
|
40 |
+
{
|
41 |
global $pagenow;
|
42 |
+
if ($pagenow == 'plugins.php')
|
43 |
ob_start("wpp_plugins_update_link_fix");
|
44 |
+
}
|
45 |
|
46 |
+
function wpp_admin_buffer_end()
|
47 |
+
{
|
48 |
+
ob_end_flush();
|
49 |
+
}
|
50 |
}
|
includes/admin/styles-fix.php
CHANGED
@@ -13,11 +13,13 @@
|
|
13 |
* @since 2.0
|
14 |
* @return void
|
15 |
*/
|
16 |
-
function wpp_fix_editor_rtl()
|
17 |
-
|
|
|
18 |
}
|
19 |
-
|
20 |
-
add_action(
|
|
|
21 |
|
22 |
/**
|
23 |
* Fixes TinyMCE font
|
@@ -25,28 +27,32 @@ add_action( 'admin_print_styles-theme-editor.php', 'wpp_fix_editor_rtl', 10 );
|
|
25 |
* @since 2.0
|
26 |
* @return void
|
27 |
*/
|
28 |
-
function wpp_fix_tinymce_font()
|
|
|
29 |
global $wpp_settings;
|
30 |
|
31 |
-
add_editor_style(
|
32 |
-
if (
|
33 |
-
|
34 |
-
|
35 |
}
|
36 |
-
|
|
|
37 |
|
38 |
/**
|
39 |
* Style for whole Admin side
|
40 |
*
|
41 |
-
* @since
|
42 |
-
* @return
|
43 |
*/
|
44 |
-
function wpp_enqueue_admin()
|
|
|
45 |
global $wpp_settings;
|
46 |
|
47 |
-
if (
|
48 |
-
wp_enqueue_style(
|
49 |
-
wp_enqueue_style(
|
50 |
}
|
51 |
}
|
52 |
-
|
|
13 |
* @since 2.0
|
14 |
* @return void
|
15 |
*/
|
16 |
+
function wpp_fix_editor_rtl()
|
17 |
+
{
|
18 |
+
wp_enqueue_style('functions', WP_PARSI_URL . 'assets/css/admin-fix.css', false, WP_PARSI_VER, 'all');
|
19 |
}
|
20 |
+
|
21 |
+
add_action('admin_print_styles-plugin-editor.php', 'wpp_fix_editor_rtl', 10);
|
22 |
+
add_action('admin_print_styles-theme-editor.php', 'wpp_fix_editor_rtl', 10);
|
23 |
|
24 |
/**
|
25 |
* Fixes TinyMCE font
|
27 |
* @since 2.0
|
28 |
* @return void
|
29 |
*/
|
30 |
+
function wpp_fix_tinymce_font()
|
31 |
+
{
|
32 |
global $wpp_settings;
|
33 |
|
34 |
+
add_editor_style(WP_PARSI_URL . 'assets/css/editor.css');
|
35 |
+
if (!isset($wpp_settings['droidsans_editor']) || $wpp_settings['droidsans_editor'] != 'disable') {
|
36 |
+
add_editor_style(WP_PARSI_URL . 'assets/css/editor-font.css');
|
37 |
+
}
|
38 |
}
|
39 |
+
|
40 |
+
add_filter('init', 'wpp_fix_tinymce_font', 9);
|
41 |
|
42 |
/**
|
43 |
* Style for whole Admin side
|
44 |
*
|
45 |
+
* @since 2.1.5
|
46 |
+
* @return void
|
47 |
*/
|
48 |
+
function wpp_enqueue_admin()
|
49 |
+
{
|
50 |
global $wpp_settings;
|
51 |
|
52 |
+
if (!isset($wpp_settings['droidsans_admin']) || $wpp_settings['droidsans_admin'] != 'disable') {
|
53 |
+
wp_enqueue_style('wp-parsi-fonts', WP_PARSI_URL . 'assets/css/admin-fonts.css', false, WP_PARSI_VER, 'all');
|
54 |
+
wp_enqueue_style('wp-parsi-admin', WP_PARSI_URL . 'assets/css/admin-styles.css', false, WP_PARSI_VER, 'all');
|
55 |
}
|
56 |
}
|
57 |
+
|
58 |
+
add_action('admin_enqueue_scripts', 'wpp_enqueue_admin');
|
includes/fixes-archive.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* @author Mobin Ghasempoor
|
8 |
*/
|
9 |
|
10 |
-
add_filter('wp_title','wpp_fix_title');
|
11 |
|
12 |
/**
|
13 |
* Fixes titles for archives
|
@@ -17,22 +17,23 @@ add_filter('wp_title','wpp_fix_title');
|
|
17 |
* @param string $seplocation Seperator location
|
18 |
* @return string New archive title
|
19 |
*/
|
20 |
-
function wpp_fix_title(
|
21 |
-
|
22 |
-
|
|
|
23 |
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
33 |
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
|
38 |
}
|
7 |
* @author Mobin Ghasempoor
|
8 |
*/
|
9 |
|
10 |
+
add_filter('wp_title', 'wpp_fix_title');
|
11 |
|
12 |
/**
|
13 |
* Fixes titles for archives
|
17 |
* @param string $seplocation Seperator location
|
18 |
* @return string New archive title
|
19 |
*/
|
20 |
+
function wpp_fix_title($title, $sep = '»', $seplocation = 'right')
|
21 |
+
{
|
22 |
+
global $persian_month_names, $wp_query, $wpp_settings;
|
23 |
+
$query = $wp_query->query;
|
24 |
|
25 |
+
if (!is_archive() || (is_archive() && !isset($query['monthnum'])) || ($wpp_settings['persian_date'] == 'disable'))
|
26 |
+
return $title;
|
27 |
|
28 |
+
if ($seplocation == 'right')
|
29 |
+
$query = array_reverse($query);
|
30 |
|
31 |
+
$query['monthnum'] = $persian_month_names[intval($query['monthnum'])];
|
32 |
|
33 |
+
$title = implode(" $sep ", $query) . " $sep ";
|
34 |
|
35 |
+
if ($wpp_settings['conv_page_title'] != 'disable')
|
36 |
+
$title = fixnumber($title);
|
37 |
|
38 |
+
return $title;
|
39 |
}
|
includes/fixes-archives.php
CHANGED
@@ -1,175 +1,154 @@
|
|
1 |
<?php
|
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 |
-
$count=$dt->count;
|
155 |
-
}
|
156 |
-
}
|
157 |
-
echo_marchive($old_date,$format,$before,$count,$show_post_count);
|
158 |
-
}
|
159 |
-
elseif($type=='daily')
|
160 |
-
{
|
161 |
-
foreach($results as $row)
|
162 |
-
{
|
163 |
-
$date = parsidate('Y,m,d',$row->date,'eng');
|
164 |
-
$date=explode(',',$date);
|
165 |
-
if($show_post_count)
|
166 |
-
$count=' ('.fixnumber($row->count).')';
|
167 |
-
else
|
168 |
-
$count = '';
|
169 |
-
$text = fixnumber($date[2]).' '.$persian_month_names[intval($date[1])].' '.fixnumber($date[0]);
|
170 |
-
echo get_archives_link(get_day_link($date[0],$date[1],$date[2]),$text,$format, $before, $count);
|
171 |
-
}
|
172 |
-
}
|
173 |
-
}
|
174 |
-
}
|
175 |
?>
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Create Persian Archives
|
5 |
+
*
|
6 |
+
* @param string $args
|
7 |
+
* @return string
|
8 |
+
*/
|
9 |
+
function wpp_get_archives($args = '')
|
10 |
+
{
|
11 |
+
global $wpdb, $wp_locale, $persian_month_names;
|
12 |
+
$defaults = array(
|
13 |
+
'type' => 'monthly', 'limit' => '',
|
14 |
+
'format' => 'html', 'before' => '',
|
15 |
+
'after' => '', 'show_post_count' => false,
|
16 |
+
'echo' => 1, 'order' => 'DESC');
|
17 |
+
|
18 |
+
$r = wp_parse_args($args, $defaults);
|
19 |
+
extract($r, EXTR_SKIP);
|
20 |
+
$archive_link_m = home_url("'?m='");
|
21 |
+
|
22 |
+
$results = $wpdb->get_results("SELECT date( post_date )as date,count(ID)as count FROM $wpdb->posts WHERE post_date < NOW() AND post_type = 'post' AND post_status = 'publish' group by date ORDER BY post_date DESC");
|
23 |
+
if (!empty($results)) {
|
24 |
+
if ($type == 'yearly') {
|
25 |
+
$old_date = parsidate('Y', $results[0]->date, 'eng');
|
26 |
+
$count = $results[0]->count;
|
27 |
+
$c = count($results);
|
28 |
+
for ($i = 1; $i < $c; $i++) {
|
29 |
+
$dt = $results[$i];
|
30 |
+
$date = parsidate('Y', $dt->date, 'eng');
|
31 |
+
if ($date == $old_date)
|
32 |
+
$count += $dt->count;
|
33 |
+
else {
|
34 |
+
echo_yarchive($old_date, $format, $before, $count, $show_post_count);
|
35 |
+
$old_date = $date;
|
36 |
+
$count = $dt->count;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
echo_yarchive($old_date, $format, $before, $count, $show_post_count);
|
40 |
+
} elseif ($type == 'monthly') {
|
41 |
+
$old_date = parsidate('Ym', $results[0]->date, 'eng');
|
42 |
+
$count = $results[0]->count;
|
43 |
+
$c = count($results);
|
44 |
+
for ($i = 1; $i < $c; $i++) {
|
45 |
+
$dt = $results[$i];
|
46 |
+
$date = parsidate('Ym', $dt->date, 'eng');
|
47 |
+
if ($date == $old_date)
|
48 |
+
$count += $dt->count;
|
49 |
+
else {
|
50 |
+
echo_marchive($old_date, $format, $before, $count, $show_post_count);
|
51 |
+
$old_date = $date;
|
52 |
+
$count = $dt->count;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
echo_marchive($old_date, $format, $before, $count, $show_post_count);
|
56 |
+
} elseif ($type == 'daily') {
|
57 |
+
foreach ($results as $row) {
|
58 |
+
$date = parsidate('Y,m,d', $row->date, 'eng');
|
59 |
+
$date = explode(',', $date);
|
60 |
+
if ($show_post_count)
|
61 |
+
$count = ' (' . fixnumber($row->count) . ')';
|
62 |
+
else
|
63 |
+
$count = '';
|
64 |
+
$text = fixnumber($date[2]) . ' ' . $persian_month_names[intval($date[1])] . ' ' . fixnumber($date[0]);
|
65 |
+
echo get_archives_link(get_day_link($date[0], $date[1], $date[2]), $text, $format, $before, $count);
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
function echo_yarchive($year, $format, $before, $count, $show_post_count)
|
72 |
+
{
|
73 |
+
if ($show_post_count)
|
74 |
+
$count = ' (' . fixnumber($count) . ')';
|
75 |
+
else
|
76 |
+
$count = '';
|
77 |
+
echo get_archives_link(get_year_link($year), fixnumber($year), $format, $before, $count);
|
78 |
+
}
|
79 |
+
|
80 |
+
function echo_marchive($old_date, $format, $before, $count, $show_post_count)
|
81 |
+
{
|
82 |
+
global $persian_month_names;
|
83 |
+
$year = substr($old_date, 0, 4);
|
84 |
+
$month = substr($old_date, 4, 2);
|
85 |
+
if ($show_post_count)
|
86 |
+
$count = ' (' . fixnumber($count) . ')';
|
87 |
+
else
|
88 |
+
$count = '';
|
89 |
+
echo get_archives_link(get_month_link($year, $month), $persian_month_names[intval($month)] . ' ' . fixnumber($year), $format, $before, $count);
|
90 |
+
}
|
91 |
+
|
92 |
+
function wp_get_parchives($args = '')
|
93 |
+
{
|
94 |
+
global $wpdb, $wp_locale, $persian_month_names;
|
95 |
+
$defaults = array(
|
96 |
+
'type' => 'monthly', 'limit' => '',
|
97 |
+
'format' => 'html', 'before' => '',
|
98 |
+
'after' => '', 'show_post_count' => false,
|
99 |
+
'echo' => 1, 'order' => 'DESC');
|
100 |
+
|
101 |
+
$r = wp_parse_args($args, $defaults);
|
102 |
+
extract($r, EXTR_SKIP);
|
103 |
+
$archive_link_m = home_url("'?m='");
|
104 |
+
|
105 |
+
$results = $wpdb->get_results("SELECT date( post_date )as date,count(ID)as count FROM $wpdb->posts WHERE post_date < NOW() AND post_type = 'post' AND post_status = 'publish' group by date ORDER BY post_date DESC");
|
106 |
+
if (!empty($results)) {
|
107 |
+
if ($type == 'yearly') {
|
108 |
+
$old_date = parsidate('Y', $results[0]->date, 'eng');
|
109 |
+
$count = $results[0]->count;
|
110 |
+
$c = count($results);
|
111 |
+
for ($i = 1; $i < $c; $i++) {
|
112 |
+
$dt = $results[$i];
|
113 |
+
$date = parsidate('Y', $dt->date, 'eng');
|
114 |
+
if ($date == $old_date)
|
115 |
+
$count += $dt->count;
|
116 |
+
else {
|
117 |
+
echo_yarchive($old_date, $format, $before, $count, $show_post_count);
|
118 |
+
$old_date = $date;
|
119 |
+
$count = $dt->count;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
echo_yarchive($old_date, $format, $before, $count, $show_post_count);
|
123 |
+
} elseif ($type == 'monthly') {
|
124 |
+
$old_date = parsidate('Ym', $results[0]->date, 'eng');
|
125 |
+
$count = $results[0]->count;
|
126 |
+
$c = count($results);
|
127 |
+
for ($i = 1; $i < $c; $i++) {
|
128 |
+
$dt = $results[$i];
|
129 |
+
$date = parsidate('Ym', $dt->date, 'eng');
|
130 |
+
if ($date == $old_date)
|
131 |
+
$count += $dt->count;
|
132 |
+
else {
|
133 |
+
echo_marchive($old_date, $format, $before, $count, $show_post_count);
|
134 |
+
$old_date = $date;
|
135 |
+
$count = $dt->count;
|
136 |
+
}
|
137 |
+
}
|
138 |
+
echo_marchive($old_date, $format, $before, $count, $show_post_count);
|
139 |
+
} elseif ($type == 'daily') {
|
140 |
+
foreach ($results as $row) {
|
141 |
+
$date = parsidate('Y,m,d', $row->date, 'eng');
|
142 |
+
$date = explode(',', $date);
|
143 |
+
if ($show_post_count)
|
144 |
+
$count = ' (' . fixnumber($row->count) . ')';
|
145 |
+
else
|
146 |
+
$count = '';
|
147 |
+
$text = fixnumber($date[2]) . ' ' . $persian_month_names[intval($date[1])] . ' ' . fixnumber($date[0]);
|
148 |
+
echo get_archives_link(get_day_link($date[0], $date[1], $date[2]), $text, $format, $before, $count);
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
?>
|
includes/fixes-calendar.php
CHANGED
@@ -1,239 +1,238 @@
|
|
1 |
<?php
|
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 |
-
$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
89 |
FROM $wpdb->posts
|
90 |
WHERE post_date < '$start'
|
91 |
AND post_type = 'post' AND post_status = 'publish'
|
92 |
ORDER BY post_date DESC
|
93 |
LIMIT 1");
|
94 |
-
|
95 |
FROM $wpdb->posts
|
96 |
WHERE post_date >= '$end'
|
97 |
AND post_type = 'post' AND post_status = 'publish'
|
98 |
ORDER BY post_date ASC
|
99 |
LIMIT 1");
|
100 |
|
101 |
-
|
102 |
-
<caption>' . $pd->persian_month_names[(int)$jthismonth
|
103 |
<thead>
|
104 |
<tr>';
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
108 |
|
109 |
-
|
110 |
-
|
|
|
111 |
|
112 |
-
|
113 |
</tr>
|
114 |
</thead>
|
115 |
|
116 |
<tfoot>
|
117 |
<tr>';
|
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 |
</tr>
|
150 |
</tfoot>
|
151 |
|
152 |
<tbody>
|
153 |
<tr>';
|
154 |
|
155 |
-
|
156 |
|
157 |
-
|
158 |
FROM $wpdb->posts
|
159 |
WHERE post_date > '$start' AND post_date < '$end'
|
160 |
AND post_type = 'post'
|
161 |
AND post_status = 'publish'";
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
|
|
179 |
FROM $wpdb->posts WHERE post_date >= '$start'
|
180 |
AND post_date <= '$end'
|
181 |
AND post_type = 'post' AND post_status = 'publish'");
|
182 |
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
}
|
232 |
-
$pad = 7 - calendar_week_mod($pd->gregurian_date('w',"$jthisyear-$jthismonth-$day",'eng')-$week_begins);
|
233 |
if ($pad != 0 && $pad != 7)
|
234 |
-
|
235 |
-
|
236 |
-
echo $calendar_output ."\n\t</tr>\n\t</tbody>\n\t</table>";
|
237 |
}
|
238 |
|
239 |
/**
|
@@ -242,10 +241,12 @@
|
|
242 |
* @param string $date
|
243 |
* @return int
|
244 |
*/
|
245 |
-
function wppd_get_pad($date)
|
246 |
-
|
247 |
-
|
|
|
248 |
|
249 |
-
|
250 |
}
|
|
|
251 |
?>
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Create Persian Calendar
|
5 |
+
*
|
6 |
+
* @param string $args
|
7 |
+
* @author Mobin Ghasempoor
|
8 |
+
* @author Parsa Kafi
|
9 |
+
* @return string
|
10 |
+
*/
|
11 |
+
function wpp_get_calendar($args = '')
|
12 |
+
{
|
13 |
+
global $wp_query, $wpdb, $m, $monthnum, $year, $day, $posts;
|
14 |
+
|
15 |
+
$pd = bn_parsidate::getInstance();
|
16 |
+
$jm = $monthnum;
|
17 |
+
if ($m != '') {
|
18 |
+
$m = preg_replace("/[^0-9]/", "", $m);
|
19 |
+
$jy = substr($m, 0, 4);
|
20 |
+
} elseif ($year !== '') {
|
21 |
+
$jy = $year;
|
22 |
+
}
|
23 |
+
|
24 |
+
if ($jy > 1500)
|
25 |
+
list($jy, $jm, $jd) = $pd->gregorian_to_persian($year, $monthnum, $day);
|
26 |
+
|
27 |
+
if (!$posts) {
|
28 |
+
$gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
|
29 |
+
if (!$gotsome)
|
30 |
+
return;
|
31 |
+
}
|
32 |
+
|
33 |
+
$week_begins = intval(get_option('start_of_week'));
|
34 |
+
$w = isset($_GET['w']) ? intval($_GET['w']) : '';
|
35 |
+
$is_gregorian = false;
|
36 |
+
|
37 |
+
if (!empty($jm) && !empty($jy)) {
|
38 |
+
$thismonth = '' . zeroise(intval($jm), 2);
|
39 |
+
$thisyear = '' . intval($jy);
|
40 |
+
|
41 |
+
} elseif (!empty($w)) {
|
42 |
+
$thisyear = '' . intval(substr($m, 0, 4));
|
43 |
+
$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
|
44 |
+
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
|
45 |
+
|
46 |
+
} elseif (!empty($m)) {
|
47 |
+
$thisyear = '' . intval(substr($m, 0, 4));
|
48 |
+
if (strlen($m) < 6)
|
49 |
+
$thismonth = '01';
|
50 |
+
else
|
51 |
+
$thismonth = '' . zeroise(intval(substr($m, 4, 2)), 2);
|
52 |
+
|
53 |
+
} else {
|
54 |
+
$is_gregorian = true;
|
55 |
+
$thisyear = gmdate('Y', current_time('timestamp') + get_option('gmt_offset') * 3600);
|
56 |
+
$thismonth = gmdate('m', current_time('timestamp') + get_option('gmt_offset') * 3600);
|
57 |
+
$thisday = gmdate('d', current_time('timestamp') + get_option('gmt_offset') * 3600);
|
58 |
+
}
|
59 |
+
|
60 |
+
//print_r($wp_query->query_vars);
|
61 |
+
|
62 |
+
if ($is_gregorian) {
|
63 |
+
list($jthisyear, $jthismonth, $jthisday) = $pd->gregorian_to_persian($thisyear, $thismonth, $thisday);
|
64 |
+
$unixmonth = $pd->gregurian_date('Y-m-d 00:00:00', "$jthisyear-$jthismonth-01");
|
65 |
+
} else {
|
66 |
+
$gdate = $pd->persian_to_gregorian($thisyear, $thismonth, 1);
|
67 |
+
$unixmonth = mktime(0, 0, 0, $gdate[1], 1, $gdate[0]);
|
68 |
+
$jthisyear = $thisyear;
|
69 |
+
$jthismonth = $thismonth;
|
70 |
+
}
|
71 |
+
|
72 |
+
$jnextmonth = $jthismonth + 1;
|
73 |
+
$jnextyear = $jthisyear;
|
74 |
+
|
75 |
+
|
76 |
+
if ($jnextmonth > 12) {
|
77 |
+
$jnextmonth = 1;
|
78 |
+
$jnextyear++;
|
79 |
+
}
|
80 |
+
|
81 |
+
$start = $pd->gregurian_date('Y-m-d 00:00:00', "$jthisyear-$jthismonth-01");
|
82 |
+
$end = $pd->gregurian_date('Y-m-d 23:59:59', "$jnextyear-$jthismonth-" . $pd->j_days_in_month[$jthismonth - 1]);
|
83 |
+
|
84 |
+
//echo "Start Date: ".$start.", End Date: ".$end."<br>";
|
85 |
+
|
86 |
+
$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
|
|
|
|
87 |
FROM $wpdb->posts
|
88 |
WHERE post_date < '$start'
|
89 |
AND post_type = 'post' AND post_status = 'publish'
|
90 |
ORDER BY post_date DESC
|
91 |
LIMIT 1");
|
92 |
+
$next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
93 |
FROM $wpdb->posts
|
94 |
WHERE post_date >= '$end'
|
95 |
AND post_type = 'post' AND post_status = 'publish'
|
96 |
ORDER BY post_date ASC
|
97 |
LIMIT 1");
|
98 |
|
99 |
+
$calendar_output = '<table id="wp-calendar" style="direction: rtl" class="widget_calendar">
|
100 |
+
<caption>' . $pd->persian_month_names[(int)$jthismonth] . ' ' . $pd->persian_date('Y', $unixmonth) . '</caption>
|
101 |
<thead>
|
102 |
<tr>';
|
103 |
+
$myweek = array();
|
104 |
+
for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
|
105 |
+
$myweek[] = $pd->persian_day_small[($wdcount + $week_begins) % 7];
|
106 |
+
}
|
107 |
|
108 |
+
foreach ($myweek as $wd) {
|
109 |
+
$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$wd</th>";
|
110 |
+
}
|
111 |
|
112 |
+
$calendar_output .= '
|
113 |
</tr>
|
114 |
</thead>
|
115 |
|
116 |
<tfoot>
|
117 |
<tr>';
|
118 |
|
119 |
+
if ($previous) {
|
120 |
+
$previous_month = $jthismonth - 1;
|
121 |
+
$previous_year = $jthisyear;
|
122 |
+
if ($previous_month == 0) {
|
123 |
+
$previous_month = 12;
|
124 |
+
$previous_year--;
|
125 |
+
}
|
126 |
+
|
127 |
+
$calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link($previous_year, $previous_month) .
|
128 |
+
'">« ' . $pd->persian_month_names[$previous_month] . '</a></td>';
|
129 |
+
} else {
|
130 |
+
$calendar_output .= "\n\t\t" . '<td colspan="3" id="prev" class="pad"> </td>';
|
131 |
+
}
|
132 |
+
|
133 |
+
$calendar_output .= "\n\t\t" . '<td class="pad"> </td>';
|
134 |
+
|
135 |
+
if ($next) {
|
136 |
+
$next_month = $jthismonth + 1;
|
137 |
+
$next_year = $jthisyear;
|
138 |
+
if ($next_month == 13) {
|
139 |
+
$next_month = 1;
|
140 |
+
$next_year++;
|
141 |
+
}
|
142 |
+
$calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link($next_year, $next_month) .
|
143 |
+
'">' . $pd->persian_month_names[$next_month] . ' »</a></td>';
|
144 |
+
} else {
|
145 |
+
$calendar_output .= "\n\t\t" . '<td colspan="3" id="next" class="pad"> </td>';
|
146 |
+
}
|
147 |
+
|
148 |
+
$calendar_output .= '
|
149 |
</tr>
|
150 |
</tfoot>
|
151 |
|
152 |
<tbody>
|
153 |
<tr>';
|
154 |
|
155 |
+
//____________________________________________________________________________________________________________________________________
|
156 |
|
157 |
+
$sql = "SELECT DISTINCT DAYOFMONTH(post_date),MONTH(post_date),YEAR(post_date)
|
158 |
FROM $wpdb->posts
|
159 |
WHERE post_date > '$start' AND post_date < '$end'
|
160 |
AND post_type = 'post'
|
161 |
AND post_status = 'publish'";
|
162 |
+
$dayswithposts = $wpdb->get_results($sql, ARRAY_N);
|
163 |
+
|
164 |
+
if ($dayswithposts) {
|
165 |
+
foreach ($dayswithposts as $daywith) {
|
166 |
+
$daywithpost[] = $pd->persian_date('j', "$daywith[2]-$daywith[1]-$daywith[0]", 'eng');
|
167 |
+
}
|
168 |
+
|
169 |
+
} else {
|
170 |
+
$daywithpost = array();
|
171 |
+
}
|
172 |
+
|
173 |
+
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
|
174 |
+
$ak_title_separator = "\n";
|
175 |
+
else
|
176 |
+
$ak_title_separator = ', ';
|
177 |
+
|
178 |
+
$ak_titles_for_day = array();
|
179 |
+
$ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom, MONTH(post_date) as month, YEAR(post_date) as year
|
180 |
FROM $wpdb->posts WHERE post_date >= '$start'
|
181 |
AND post_date <= '$end'
|
182 |
AND post_type = 'post' AND post_status = 'publish'");
|
183 |
|
184 |
+
if ($ak_post_titles) {
|
185 |
+
foreach ($ak_post_titles as $ak_post_title) {
|
186 |
+
/** This filter is documented in wp-includes/post-template.php */
|
187 |
+
$post_title = esc_attr(apply_filters('the_title', $ak_post_title->post_title, $ak_post_title->ID));
|
188 |
+
$ak_post_title->dom = $pd->persian_date('j', "$ak_post_title->year-$ak_post_title->month-$ak_post_title->dom", 'eng');
|
189 |
+
|
190 |
+
if (empty($ak_titles_for_day['day_' . $ak_post_title->dom]))
|
191 |
+
$ak_titles_for_day['day_' . $ak_post_title->dom] = '';
|
192 |
+
if (empty($ak_titles_for_day[$ak_post_title->dom])) // first one
|
193 |
+
$ak_titles_for_day[$ak_post_title->dom] = $post_title;
|
194 |
+
else
|
195 |
+
$ak_titles_for_day[$ak_post_title->dom] .= $ak_title_separator . $post_title;
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
//$pad = calendar_week_mod(date('w',strtotime($unixmonth))-$week_begins);
|
200 |
+
|
201 |
+
$pad = wppd_get_pad($jthisyear . "-" . $jthismonth);
|
202 |
+
//echo "<br />begin=$week_begins<br />pad=$pad<br />";
|
203 |
+
|
204 |
+
if (0 != $pad)
|
205 |
+
$calendar_output .= "\n\t\t" . '<td colspan="' . $pad . '" class="pad"> </td>';
|
206 |
+
|
207 |
+
$daysinmonth = intval($pd->persian_date('t', $unixmonth, 'eng'));
|
208 |
+
|
209 |
+
for ($day = 1; $day <= $daysinmonth; ++$day) {
|
210 |
+
list($thiyear, $thismonth, $thisday) = $pd->persian_to_gregorian($jthisyear, $jthismonth, $day);
|
211 |
+
if (isset($newrow) && $newrow)
|
212 |
+
$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
|
213 |
+
$newrow = false;
|
214 |
+
|
215 |
+
if ($thisday == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time() + (get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time() + (get_option('gmt_offset') * 3600)))
|
216 |
+
$calendar_output .= '<td id="today">';
|
217 |
+
else
|
218 |
+
$calendar_output .= '<td>';
|
219 |
+
|
220 |
+
$p_day = (empty($val['sep_datesnum']) ? $day : per_number($day));
|
221 |
+
|
222 |
+
if (in_array($day, $daywithpost)) // any posts today?
|
223 |
+
$calendar_output .= '<a href="' . get_day_link($jthisyear, $jthismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$p_day</a>";
|
224 |
+
else
|
225 |
+
$calendar_output .= $p_day;
|
226 |
+
$calendar_output .= '</td>';
|
227 |
+
|
228 |
+
if (6 == calendar_week_mod($pd->gregurian_date('w', "$jthisyear-$jthismonth-$day") - $week_begins))
|
229 |
+
$newrow = true;
|
230 |
+
}
|
231 |
+
$pad = 7 - calendar_week_mod($pd->gregurian_date('w', "$jthisyear-$jthismonth-$day", 'eng') - $week_begins);
|
|
|
|
|
232 |
if ($pad != 0 && $pad != 7)
|
233 |
+
$calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . $pad . '"> </td>';
|
234 |
+
|
235 |
+
echo $calendar_output . "\n\t</tr>\n\t</tbody>\n\t</table>";
|
236 |
}
|
237 |
|
238 |
/**
|
241 |
* @param string $date
|
242 |
* @return int
|
243 |
*/
|
244 |
+
function wppd_get_pad($date)
|
245 |
+
{
|
246 |
+
$pd = bn_parsidate::getInstance();
|
247 |
+
$p = $pd->persian_date("w", $pd->gregurian_date("Y-m-d", $date . "-01"), "eng");
|
248 |
|
249 |
+
return $p;
|
250 |
}
|
251 |
+
|
252 |
?>
|
includes/fixes-dates.php
CHANGED
@@ -9,14 +9,14 @@
|
|
9 |
|
10 |
global $wpp_settings;
|
11 |
|
12 |
-
if (
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
}
|
21 |
|
22 |
/**
|
@@ -26,20 +26,21 @@ if ( $wpp_settings['persian_date'] != 'disable' ) {
|
|
26 |
* @param string $format Date format
|
27 |
* @return string Formatted date
|
28 |
*/
|
29 |
-
function wpp_fix_post_date(
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
43 |
}
|
44 |
|
45 |
/**
|
@@ -49,15 +50,16 @@ function wpp_fix_post_date( $time, $format = '' ) {
|
|
49 |
* @param string $format Date format
|
50 |
* @return string Formatted date
|
51 |
*/
|
52 |
-
function wpp_fix_post_time(
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
61 |
}
|
62 |
|
63 |
/**
|
@@ -67,15 +69,16 @@ function wpp_fix_post_time( $time, $format = '' ) {
|
|
67 |
* @param string $fomat Date format
|
68 |
* @return string Formatted date
|
69 |
*/
|
70 |
-
function wpp_fix_comment_time(
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
79 |
}
|
80 |
|
81 |
/**
|
@@ -85,15 +88,16 @@ function wpp_fix_comment_time( $time, $format = '' ) {
|
|
85 |
* @param string $fomat Date format
|
86 |
* @return string Formatted date
|
87 |
*/
|
88 |
-
function wpp_fix_comment_date(
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
97 |
}
|
98 |
|
99 |
/**
|
@@ -104,22 +108,23 @@ function wpp_fix_comment_date( $time, $format = '' ) {
|
|
104 |
* @param string $gmt GMT timestamp
|
105 |
* @return string Formatted time
|
106 |
*/
|
107 |
-
function wpp_fix_i18n(
|
108 |
-
|
|
|
109 |
|
110 |
-
|
111 |
-
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
}
|
9 |
|
10 |
global $wpp_settings;
|
11 |
|
12 |
+
if ($wpp_settings['persian_date'] != 'disable') {
|
13 |
+
add_filter('the_time', 'wpp_fix_post_time', 10, 2);
|
14 |
+
add_filter('the_date', 'wpp_fix_post_date', 10, 2);
|
15 |
+
add_filter('get_comment_time', 'wpp_fix_comment_time', 10, 2);
|
16 |
+
add_filter('get_comment_date', 'wpp_fix_comment_date', 10, 2);
|
17 |
+
add_filter('get_post_modified_time', 'wpp_fix_post_date', 10, 2);
|
18 |
+
|
19 |
+
add_action('date_i18n', 'wpp_fix_i18n', 10, 3);
|
20 |
}
|
21 |
|
22 |
/**
|
26 |
* @param string $format Date format
|
27 |
* @return string Formatted date
|
28 |
*/
|
29 |
+
function wpp_fix_post_date($time, $format = '')
|
30 |
+
{
|
31 |
+
global $post, $wpp_settings;
|
32 |
+
|
33 |
+
// It's seems some plugin like acf does not exits $post.
|
34 |
+
if (empty($post))
|
35 |
+
return $time;
|
36 |
+
|
37 |
+
if (empty($format))
|
38 |
+
$format = get_option('date_format');
|
39 |
+
|
40 |
+
if ($wpp_settings['conv_dates'] == 'disable')
|
41 |
+
return parsidate($format, $post->post_date, 'eng');
|
42 |
+
else
|
43 |
+
return parsidate($format, $post->post_date);
|
44 |
}
|
45 |
|
46 |
/**
|
50 |
* @param string $format Date format
|
51 |
* @return string Formatted date
|
52 |
*/
|
53 |
+
function wpp_fix_post_time($time, $format = '')
|
54 |
+
{
|
55 |
+
global $post, $wpp_settings;
|
56 |
+
if (empty($format))
|
57 |
+
$format = get_option('time_format');
|
58 |
+
|
59 |
+
if ($wpp_settings['conv_dates'] == 'disable')
|
60 |
+
return parsidate($format, $post->post_date, 'eng');
|
61 |
+
else
|
62 |
+
return parsidate($format, $post->post_date);
|
63 |
}
|
64 |
|
65 |
/**
|
69 |
* @param string $fomat Date format
|
70 |
* @return string Formatted date
|
71 |
*/
|
72 |
+
function wpp_fix_comment_time($time, $format = '')
|
73 |
+
{
|
74 |
+
global $comment, $wpp_settings;
|
75 |
+
if (empty($format))
|
76 |
+
$format = get_option('time_format');
|
77 |
+
|
78 |
+
if ($wpp_settings['conv_dates'] == 'disable')
|
79 |
+
return parsidate($format, $comment->comment_date, 'eng');
|
80 |
+
else
|
81 |
+
return parsidate($format, $comment->comment_date);
|
82 |
}
|
83 |
|
84 |
/**
|
88 |
* @param string $fomat Date format
|
89 |
* @return string Formatted date
|
90 |
*/
|
91 |
+
function wpp_fix_comment_date($time, $format = '')
|
92 |
+
{
|
93 |
+
global $comment, $wpp_settings;
|
94 |
+
if (empty($format))
|
95 |
+
$format = get_option('date_format');
|
96 |
+
|
97 |
+
if ($wpp_settings['conv_dates'] == 'disable')
|
98 |
+
return parsidate($format, $comment->comment_date, 'eng');
|
99 |
+
else
|
100 |
+
return parsidate($format, $comment->comment_date);
|
101 |
}
|
102 |
|
103 |
/**
|
108 |
* @param string $gmt GMT timestamp
|
109 |
* @return string Formatted time
|
110 |
*/
|
111 |
+
function wpp_fix_i18n($format_string, $timestamp, $gmt)
|
112 |
+
{
|
113 |
+
global $wpp_settings;
|
114 |
|
115 |
+
if (function_exists('debug_backtrace')) {
|
116 |
+
$callers = debug_backtrace();
|
117 |
|
118 |
+
// WordPress SEO OpenGraph Dates fix
|
119 |
+
if (isset($callers[6]['class']) && $callers[6]['class'] == 'WPSEO_OpenGraph') return $format_string;
|
120 |
+
if (isset($callers[6]['function']) && $callers[6]['function'] == 'get_the_modified_date') return $format_string;
|
121 |
|
122 |
+
// WooCommerce order detail fix
|
123 |
+
if (isset($callers['4']['class']) && $callers['4']['class'] == 'WC_Meta_Box_Order_Data') return $format_string;
|
124 |
+
}
|
125 |
|
126 |
+
if ($wpp_settings['conv_dates'] == 'disable')
|
127 |
+
return parsidate($timestamp, $gmt, 'eng');
|
128 |
+
else
|
129 |
+
return parsidate($timestamp, $gmt);
|
130 |
}
|
includes/fixes-misc.php
CHANGED
@@ -10,31 +10,31 @@
|
|
10 |
|
11 |
global $wpp_settings;
|
12 |
|
13 |
-
if (
|
14 |
-
|
15 |
|
16 |
-
if (
|
17 |
-
|
18 |
|
19 |
-
if (
|
20 |
-
|
21 |
|
22 |
-
if (
|
23 |
-
|
24 |
|
25 |
-
if (
|
26 |
-
|
27 |
|
28 |
-
if (
|
29 |
-
|
30 |
|
31 |
-
if (
|
32 |
-
|
33 |
|
34 |
-
if (
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
}
|
10 |
|
11 |
global $wpp_settings;
|
12 |
|
13 |
+
if (isset($wpp_settings['conv_page_title']) && $wpp_settings['conv_page_title'] != 'disable')
|
14 |
+
add_filter('wp_title', 'fixnumber', 20);
|
15 |
|
16 |
+
if (isset($wpp_settings['conv_title']) && $wpp_settings['conv_title'] != 'disable')
|
17 |
+
add_filter('the_title', 'fixnumber', 20);
|
18 |
|
19 |
+
if (isset($wpp_settings['conv_contents']) && $wpp_settings['conv_contents'] != 'disable')
|
20 |
+
add_filter('the_content', 'fixnumber');
|
21 |
|
22 |
+
if (isset($wpp_settings['conv_excerpt']) && $wpp_settings['conv_excerpt'] != 'disable')
|
23 |
+
add_filter('the_excerpt', 'fixnumber');
|
24 |
|
25 |
+
if (isset($wpp_settings['conv_comments']) && $wpp_settings['conv_comments'] != 'disable')
|
26 |
+
add_filter('comment_text', 'fixnumber');
|
27 |
|
28 |
+
if (isset($wpp_settings['conv_comment_count']) && $wpp_settings['conv_comment_count'] != 'disable')
|
29 |
+
add_filter('comments_number', 'fixnumber');
|
30 |
|
31 |
+
if (isset($wpp_settings['conv_cats']) && $wpp_settings['conv_cats'] != 'disable')
|
32 |
+
add_filter('wp_list_categories', 'fixnumber');
|
33 |
|
34 |
+
if (isset($wpp_settings['conv_arabic']) && $wpp_settings['conv_arabic'] != 'disable') {
|
35 |
+
add_filter('the_content', 'fixarabic');
|
36 |
+
add_filter('the_title', 'fixarabic');
|
37 |
+
add_filter('comment_text', 'fixarabic');
|
38 |
+
add_filter('wp_list_categories', 'fixarabic');
|
39 |
+
add_filter('the_excerpt', 'fixarabic');
|
40 |
}
|
includes/fixes-permalinks.php
CHANGED
@@ -8,10 +8,10 @@
|
|
8 |
*/
|
9 |
global $wpp_settings;
|
10 |
|
11 |
-
if (
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
}
|
16 |
|
17 |
/**
|
@@ -20,104 +20,105 @@ if ( $wpp_settings['conv_permalinks'] == 'enable' ) {
|
|
20 |
* @param string $where
|
21 |
* @return string
|
22 |
*/
|
23 |
-
function wpp_posts_where(
|
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 |
/**
|
@@ -126,106 +127,107 @@ function wpp_posts_where( $where ) {
|
|
126 |
* @param WP_Query $query
|
127 |
* @return mixed
|
128 |
*/
|
129 |
-
function wpp_pre_get_posts(
|
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 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
|
|
224 |
|
225 |
// $query->set('')
|
226 |
|
227 |
-
|
228 |
-
|
229 |
}
|
230 |
|
231 |
/**
|
@@ -236,86 +238,88 @@ function wpp_pre_get_posts( $query ) {
|
|
236 |
* @param bool $leavename
|
237 |
* @return string New permalink
|
238 |
*/
|
239 |
-
function wpp_permalink(
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
|
|
320 |
}
|
|
|
321 |
?>
|
8 |
*/
|
9 |
global $wpp_settings;
|
10 |
|
11 |
+
if ($wpp_settings['conv_permalinks'] == 'enable') {
|
12 |
+
add_filter('posts_where', 'wpp_posts_where');
|
13 |
+
add_action('pre_get_posts', 'wpp_pre_get_posts');
|
14 |
+
add_filter('post_link', 'wpp_permalink', 10, 3);
|
15 |
}
|
16 |
|
17 |
/**
|
20 |
* @param string $where
|
21 |
* @return string
|
22 |
*/
|
23 |
+
function wpp_posts_where($where)
|
24 |
+
{
|
25 |
+
global $wp_query, $wpdb;
|
26 |
+
if (empty($wp_query->query_vars))
|
27 |
+
return $where;
|
28 |
+
|
29 |
+
$pd = bn_parsidate::getInstance();
|
30 |
+
|
31 |
+
$m = (isset($wp_query->query_vars['m'])) ? $wp_query->query_vars['m'] : '';
|
32 |
+
$hour = (isset($wp_query->query_vars['hour'])) ? $wp_query->query_vars['hour'] : '';
|
33 |
+
$minute = (isset($wp_query->query_vars['minute'])) ? $wp_query->query_vars['minute'] : '';
|
34 |
+
$second = (isset($wp_query->query_vars['second'])) ? $wp_query->query_vars['second'] : '';
|
35 |
+
$year = (isset($wp_query->query_vars['year'])) ? $wp_query->query_vars['year'] : '';
|
36 |
+
$month = (isset($wp_query->query_vars['month'])) ? $wp_query->query_vars['month'] : '';
|
37 |
+
$day = (isset($wp_query->query_vars['day'])) ? $wp_query->query_vars['day'] : '';
|
38 |
+
|
39 |
+
if (!empty($m)) {
|
40 |
+
$len = strlen($m);
|
41 |
+
$year = substr($m, 0, 4);
|
42 |
+
if ($len > 5)
|
43 |
+
$month = substr($m, 4, 2);
|
44 |
+
if ($len > 7)
|
45 |
+
$day = substr($m, 6, 2);
|
46 |
+
if ($len > 9)
|
47 |
+
$hour = substr($m, 8, 2);
|
48 |
+
if ($len > 11)
|
49 |
+
$minute = substr($m, 10, 2);
|
50 |
+
if ($len > 13)
|
51 |
+
$second = substr($m, 12, 2);
|
52 |
+
}
|
53 |
+
|
54 |
+
if (empty($year) || $year > 1700)
|
55 |
+
return $where;
|
56 |
+
|
57 |
+
$stamon = 1;
|
58 |
+
$staday = 1;
|
59 |
+
$stahou = '00';
|
60 |
+
$stamin = '00';
|
61 |
+
$stasec = '00';
|
62 |
+
$endmon = 1;
|
63 |
+
$endday = 1;
|
64 |
+
$endhou = '00';
|
65 |
+
$endmin = '00';
|
66 |
+
$endsec = '00';
|
67 |
+
|
68 |
+
$stayear = $year;
|
69 |
+
$endyear = $year + 1;
|
70 |
+
|
71 |
+
if ($month != '') {
|
72 |
+
$stamon = $month;
|
73 |
+
$endmon = ($month == 12 ? 1 : $month + 1);
|
74 |
+
$endyear = ($endmon == 1 ? $stayear + 1 : $stayear);
|
75 |
+
}
|
76 |
+
|
77 |
+
if ($day != '') {
|
78 |
+
$staday = $day;
|
79 |
+
$endday = ($day == $pd->j_days_in_month[(int)$month - 1] ? 1 : $day + 1);
|
80 |
+
$endmon = ($endday == 1 ? $stamon + 1 : $stamon);
|
81 |
+
}
|
82 |
+
|
83 |
+
if ($hour != '') {
|
84 |
+
$stahou = $hour;
|
85 |
+
$endhou = ($hour == 24 ? '00' : $hour + 1);
|
86 |
+
$endday = ($endhou == '00' ? $staday + 1 : $staday);
|
87 |
+
}
|
88 |
+
|
89 |
+
if ($minute != '') {
|
90 |
+
$stamin = $minute;
|
91 |
+
$endmin = ($minute == 59 ? '00' : $minute + 1);
|
92 |
+
$endhou = ($endmin == '00' ? $stahou + 1 : $stahou);
|
93 |
+
}
|
94 |
+
|
95 |
+
if ($second != '') {
|
96 |
+
$stasec = $second;
|
97 |
+
$endsec = ($second == 59 ? '00' : $second + 1);
|
98 |
+
$endmin = ($endsec == '00' ? $stamin + 1 : $stamin);
|
99 |
+
}
|
100 |
+
|
101 |
+
$stadate = "$stayear-$stamon-$staday";
|
102 |
+
$enddate = "$endyear-$endmon-$endday";
|
103 |
+
$stadate = gregdate('Y-m-d', $stadate);
|
104 |
+
$enddate = gregdate('Y-m-d', $enddate);
|
105 |
+
$stadate .= " $stahou:$stamin:$stasec";
|
106 |
+
$enddate .= " $endhou:$endmin:$endsec";
|
107 |
+
|
108 |
+
$patterns = array('/YEAR\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
109 |
+
'/DAYOFMONTH\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
110 |
+
'/MONTH\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
111 |
+
'/HOUR\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
112 |
+
'/MINUTE\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
113 |
+
'/SECOND\((.*?)post_date\s*\)\s*=\s*[0-9\']*/');
|
114 |
+
foreach ($patterns as $pattern)
|
115 |
+
$where = preg_replace($pattern, '1=1', $where);
|
116 |
+
|
117 |
+
$prefixp = "{$wpdb->posts}.";
|
118 |
+
$prefixp = (strpos($where, $prefixp) == false) ? '' : $prefixp;
|
119 |
+
|
120 |
+
$where .= " AND {$prefixp}post_date >= '$stadate' AND {$prefixp}post_date < '$enddate' ";
|
121 |
+
return $where;
|
122 |
}
|
123 |
|
124 |
/**
|
127 |
* @param WP_Query $query
|
128 |
* @return mixed
|
129 |
*/
|
130 |
+
function wpp_pre_get_posts($query)
|
131 |
+
{
|
132 |
+
global $wpdb;
|
133 |
+
|
134 |
+
$permalink = $query->query;
|
135 |
+
$year = '';
|
136 |
+
$monthnum = '';
|
137 |
+
$day = '';//start
|
138 |
+
|
139 |
+
if (isset($permalink['year']))
|
140 |
+
$year = $permalink['year'];
|
141 |
+
if (isset($permalink['monthnum']))
|
142 |
+
$monthnum = $permalink['monthnum'];
|
143 |
+
if (isset($permalink['day']))
|
144 |
+
$day = $permalink['day'];
|
145 |
+
if ($year > 1700)
|
146 |
+
return $query;
|
147 |
+
|
148 |
+
$out = false;
|
149 |
+
$pd = bn_parsidate::getInstance();
|
150 |
+
if (isset($permalink['name'])) {
|
151 |
+
$var = $wpdb->get_var("SELECT post_date FROM {$wpdb->prefix}posts WHERE post_name='{$permalink['name']}' ORDER BY id");
|
152 |
+
$per = parsidate('Y-m-d', $var, 'eng');
|
153 |
+
//update_option('options', $per );
|
154 |
+
$per = explode('-', $per);
|
155 |
+
$out = true;
|
156 |
+
|
157 |
+
if ($year != $per[0])
|
158 |
+
$out = false;
|
159 |
+
if ($out && $monthnum != $per[1])
|
160 |
+
$out = false;
|
161 |
+
if ($out && $day != $per[2])
|
162 |
+
$out = false;
|
163 |
+
|
164 |
+
} elseif (isset($permalink['post_id'])) {
|
165 |
+
$out = true;
|
166 |
+
$var = $wpdb->get_var("SELECT post_date FROM {$wpdb->prefix}posts WHERE ID={$permalink['post_id']}");
|
167 |
+
} elseif (!empty($year) && !empty($monthnum) && !empty($day)) {
|
168 |
+
$out = true;
|
169 |
+
$var = gregdate('Y-m-d', "$year-$monthnum-$day");
|
170 |
+
} elseif (!empty($year) && !empty($monthnum)) {
|
171 |
+
$stadate = $pd->persian_to_gregorian($year, $monthnum, 1);
|
172 |
+
$enddate = $pd->persian_to_gregorian($year, $monthnum, $pd->j_days_in_month[($monthnum - 1)]);
|
173 |
+
$date_query = array(
|
174 |
+
array(
|
175 |
+
'after' => array(
|
176 |
+
'year' => $stadate[0],
|
177 |
+
'month' => $stadate[1],
|
178 |
+
'day' => $stadate[2] - 1,
|
179 |
+
),
|
180 |
+
'before' => array(
|
181 |
+
'year' => $enddate[0],
|
182 |
+
'month' => $enddate[1],
|
183 |
+
'day' => $enddate[2] + 1,
|
184 |
+
),
|
185 |
+
'inclusive' => TRUE,
|
186 |
+
),
|
187 |
+
);
|
188 |
+
$query->set('date_query', $date_query);
|
189 |
+
|
190 |
+
// commented for get year & month in calander widget
|
191 |
+
// $query->set('year', '');
|
192 |
+
// $query->set('monthnum', '');
|
193 |
+
$out = false;
|
194 |
+
|
195 |
+
} elseif (!empty($year)) {
|
196 |
+
$stadate = $pd->persian_to_gregorian($year, 1, 1);
|
197 |
+
$enddate = $pd->persian_to_gregorian(($year + 1), 1, 1);
|
198 |
+
$date_query = array(
|
199 |
+
array(
|
200 |
+
'after' => array(
|
201 |
+
'year' => $stadate[0],
|
202 |
+
'month' => $stadate[1],
|
203 |
+
'day' => $stadate[2] - 1,
|
204 |
+
),
|
205 |
+
'before' => array(
|
206 |
+
'year' => $enddate[0],
|
207 |
+
'month' => $enddate[1],
|
208 |
+
'day' => $enddate[2],
|
209 |
+
),
|
210 |
+
'inclusive' => TRUE,
|
211 |
+
),
|
212 |
+
);
|
213 |
+
$query->set('date_query', $date_query);
|
214 |
+
// $query->set('year', '');
|
215 |
+
$out = false;
|
216 |
+
}
|
217 |
+
|
218 |
+
if ($out) {
|
219 |
+
preg_match_all('!\d+!', $var, $matches);
|
220 |
+
$var = $matches[0];
|
221 |
+
|
222 |
+
$query->set('year', $var[0]);
|
223 |
+
$query->set('monthnum', $var[1]);
|
224 |
+
$query->set('day', $var[2]);
|
225 |
+
}
|
226 |
|
227 |
// $query->set('')
|
228 |
|
229 |
+
return $query;
|
230 |
+
|
231 |
}
|
232 |
|
233 |
/**
|
238 |
* @param bool $leavename
|
239 |
* @return string New permalink
|
240 |
*/
|
241 |
+
function wpp_permalink($perma, $post, $leavename = false)
|
242 |
+
{
|
243 |
+
if (empty($post->ID))
|
244 |
+
return false;
|
245 |
+
if ($post->post_type == 'page' || $post->post_status == 'static')
|
246 |
+
return get_page_link($post->ID);
|
247 |
+
elseif ($post->post_type == 'attachment')
|
248 |
+
return get_attachment_link($post->ID);
|
249 |
+
elseif (in_array($post->post_type, get_post_types(array('_builtin' => false))))
|
250 |
+
return get_post_permalink($post->ID);
|
251 |
+
|
252 |
+
$permalink = get_option('permalink_structure');
|
253 |
+
preg_match_all('/%([^\/]*)%/', $permalink, $rewritecode);
|
254 |
+
$rewritecode = $rewritecode[0];
|
255 |
+
if ('' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft'))) {
|
256 |
+
if ($leavename)
|
257 |
+
$rewritecode = array_diff($rewritecode, array('%postname%', '%pagename%'));
|
258 |
+
|
259 |
+
$date = explode(' ', parsidate('Y m d H i s', $post->post_date, 'eng'));
|
260 |
+
$out = array();
|
261 |
+
|
262 |
+
foreach ($rewritecode as $rewrite) {
|
263 |
+
switch ($rewrite) {
|
264 |
+
case '%year%':
|
265 |
+
$out[] = $date[0];
|
266 |
+
break;
|
267 |
+
case '%monthnum%':
|
268 |
+
$out[] = $date[1];
|
269 |
+
break;
|
270 |
+
case '%day%':
|
271 |
+
$out[] = $date[2];
|
272 |
+
break;
|
273 |
+
case '%hour%':
|
274 |
+
$out[] = $date[3];
|
275 |
+
break;
|
276 |
+
case '%minute%':
|
277 |
+
$out[] = $date[4];
|
278 |
+
break;
|
279 |
+
case '%second%':
|
280 |
+
$out[] = $date[5];
|
281 |
+
break;
|
282 |
+
case '%post_id%':
|
283 |
+
$out[] = $post->ID;
|
284 |
+
break;
|
285 |
+
case '%postname%':
|
286 |
+
$out[] = $post->post_name;
|
287 |
+
break;
|
288 |
+
case '%category%':
|
289 |
+
$category = '';
|
290 |
+
$cats = get_the_category($post->ID);
|
291 |
+
if ($cats) {
|
292 |
+
usort($cats, '_usort_terms_by_ID');
|
293 |
+
$category = $cats[0]->slug;
|
294 |
+
if ($parent = $cats[0]->parent)
|
295 |
+
$category = get_category_parents($parent, false, '/', true);
|
296 |
+
|
297 |
+
if ($cats[0]->parent != 0)
|
298 |
+
$category .= $cats[0]->slug;
|
299 |
+
}
|
300 |
+
if (empty($category)) {
|
301 |
+
$default_category = get_term(get_option('default_category'), 'category');
|
302 |
+
$category = is_wp_error($default_category) ? '' : $default_category->slug;
|
303 |
+
}
|
304 |
+
$out[] = $category;
|
305 |
+
break;
|
306 |
+
case '%author%':
|
307 |
+
$authordata = get_userdata($post->post_author);
|
308 |
+
$out[] = $authordata->user_nicename;
|
309 |
+
break;
|
310 |
+
case '%pagename%':
|
311 |
+
$out[] = $post->post_name;
|
312 |
+
break;
|
313 |
+
default:
|
314 |
+
unset($rewritecode[array_search($rewrite, $rewritecode)]);
|
315 |
+
break;
|
316 |
+
}
|
317 |
+
}
|
318 |
+
$permalink = home_url(str_replace($rewritecode, $out, $permalink));
|
319 |
+
return user_trailingslashit($permalink, 'single');
|
320 |
+
} else {
|
321 |
+
return home_url("?p=$post->ID");
|
322 |
+
}
|
323 |
}
|
324 |
+
|
325 |
?>
|
includes/general.php
CHANGED
@@ -9,10 +9,10 @@
|
|
9 |
*/
|
10 |
global $wpp_settings;
|
11 |
|
12 |
-
add_filter(
|
13 |
-
add_filter(
|
14 |
-
add_action(
|
15 |
-
add_action(
|
16 |
|
17 |
/**
|
18 |
* Change Locale WordPress Admin and Front-end user
|
@@ -20,18 +20,27 @@ add_action( 'admin_init', 'wpp_dismiss_notice_action' );
|
|
20 |
* @param String $locale
|
21 |
* @return String
|
22 |
*/
|
23 |
-
function wp_parsi_set_locale($locale)
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
|
37 |
|
@@ -41,15 +50,16 @@ function wp_parsi_set_locale($locale) {
|
|
41 |
* @since 1.0
|
42 |
* @return bool True when page is feed, false when page isn't feed
|
43 |
*/
|
44 |
-
function wpp_is_feed()
|
45 |
-
|
46 |
-
|
|
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
-
|
53 |
}
|
54 |
|
55 |
/**
|
@@ -58,12 +68,13 @@ function wpp_is_feed() {
|
|
58 |
* @param string $number Numbers
|
59 |
* @return string Formatted numbers
|
60 |
*/
|
61 |
-
function per_number(
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
67 |
}
|
68 |
|
69 |
/**
|
@@ -72,12 +83,13 @@ function per_number( $number ) {
|
|
72 |
* @param string $number Numbers
|
73 |
* @return string Formatted numbers
|
74 |
*/
|
75 |
-
function eng_number(
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
81 |
}
|
82 |
|
83 |
/**
|
@@ -86,10 +98,11 @@ function eng_number( $number ) {
|
|
86 |
* @param string $content Post content
|
87 |
* @return string Formatted content
|
88 |
*/
|
89 |
-
function persian_number(
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
93 |
}
|
94 |
|
95 |
/**
|
@@ -98,8 +111,9 @@ function persian_number( $content ) {
|
|
98 |
* @param string $content
|
99 |
* @return mixed
|
100 |
*/
|
101 |
-
function fixnumber(
|
102 |
-
|
|
|
103 |
}
|
104 |
|
105 |
/**
|
@@ -108,8 +122,9 @@ function fixnumber( $content ) {
|
|
108 |
* @param string $content
|
109 |
* @return mixed
|
110 |
*/
|
111 |
-
function fixarabic(
|
112 |
-
|
|
|
113 |
}
|
114 |
|
115 |
/**
|
@@ -119,7 +134,7 @@ function fixarabic( $content ) {
|
|
119 |
*/
|
120 |
function wpp_login_headerurl()
|
121 |
{
|
122 |
-
|
123 |
}
|
124 |
|
125 |
/**
|
@@ -129,17 +144,18 @@ function wpp_login_headerurl()
|
|
129 |
* @author Ehsaan
|
130 |
* @return void
|
131 |
*/
|
132 |
-
function wpp_activation_notice()
|
133 |
-
|
|
|
134 |
|
135 |
-
|
136 |
-
|
137 |
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
}
|
144 |
|
145 |
/**
|
@@ -148,8 +164,9 @@ function wpp_activation_notice() {
|
|
148 |
* @author Ehsaan
|
149 |
* @return void
|
150 |
*/
|
151 |
-
function wpp_dismiss_notice_action()
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
155 |
}
|
9 |
*/
|
10 |
global $wpp_settings;
|
11 |
|
12 |
+
add_filter('login_headerurl', 'wpp_login_headerurl', 10, 2);
|
13 |
+
add_filter('locale', 'wp_parsi_set_locale');
|
14 |
+
add_action('admin_notices', 'wpp_activation_notice');
|
15 |
+
add_action('admin_init', 'wpp_dismiss_notice_action');
|
16 |
|
17 |
/**
|
18 |
* Change Locale WordPress Admin and Front-end user
|
20 |
* @param String $locale
|
21 |
* @return String
|
22 |
*/
|
23 |
+
function wp_parsi_set_locale($locale)
|
24 |
+
{
|
25 |
+
$settings = get_option('wpp_settings');
|
26 |
+
if ($settings['admin_lang'] == 'enable') {
|
27 |
+
$admin_locale = "fa_IR";
|
28 |
+
} elseif ($settings['admin_lang'] == 'disable') {
|
29 |
+
$admin_locale = "en_US";
|
30 |
+
}
|
31 |
+
if ($settings['user_lang'] == 'enable') {
|
32 |
+
$user_locale = "fa_IR";
|
33 |
+
} elseif ($settings['user_lang'] == 'disable') {
|
34 |
+
$user_locale = "en_US";
|
35 |
+
}
|
36 |
+
|
37 |
+
$locale_s = (is_admin()) ? $admin_locale : $user_locale;
|
38 |
+
|
39 |
+
if (!empty($locale_s))
|
40 |
+
$locale = $locale_s;
|
41 |
+
|
42 |
+
setlocale(LC_ALL, $locale);
|
43 |
+
return $locale;
|
44 |
}
|
45 |
|
46 |
|
50 |
* @since 1.0
|
51 |
* @return bool True when page is feed, false when page isn't feed
|
52 |
*/
|
53 |
+
function wpp_is_feed()
|
54 |
+
{
|
55 |
+
if (is_feed())
|
56 |
+
return true;
|
57 |
|
58 |
+
$path = $_SERVER['REQUEST_URI'];
|
59 |
+
$exts = array('xml', 'gz', 'xsl');
|
60 |
+
$ext = pathinfo($path, PATHINFO_EXTENSION);
|
61 |
|
62 |
+
return in_array($ext, $exts);
|
63 |
}
|
64 |
|
65 |
/**
|
68 |
* @param string $number Numbers
|
69 |
* @return string Formatted numbers
|
70 |
*/
|
71 |
+
function per_number($number)
|
72 |
+
{
|
73 |
+
return str_replace(
|
74 |
+
range(0, 9),
|
75 |
+
array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'),
|
76 |
+
$number
|
77 |
+
);
|
78 |
}
|
79 |
|
80 |
/**
|
83 |
* @param string $number Numbers
|
84 |
* @return string Formatted numbers
|
85 |
*/
|
86 |
+
function eng_number($number)
|
87 |
+
{
|
88 |
+
return str_replace(
|
89 |
+
array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'),
|
90 |
+
range(0, 9),
|
91 |
+
$number
|
92 |
+
);
|
93 |
}
|
94 |
|
95 |
/**
|
98 |
* @param string $content Post content
|
99 |
* @return string Formatted content
|
100 |
*/
|
101 |
+
function persian_number($content)
|
102 |
+
{
|
103 |
+
return (
|
104 |
+
isset($content[1]) ? per_number($content[1]) : $content[0]
|
105 |
+
);
|
106 |
}
|
107 |
|
108 |
/**
|
111 |
* @param string $content
|
112 |
* @return mixed
|
113 |
*/
|
114 |
+
function fixnumber($content)
|
115 |
+
{
|
116 |
+
return preg_replace_callback('/(?:&#\d{2,4};)|(?:[0]?[a-z][\x20-\x3B=\x3F-\x7F]*)|(\d+[\.\d]*)|<\s*[^>]+>/i', 'persian_number', $content);
|
117 |
}
|
118 |
|
119 |
/**
|
122 |
* @param string $content
|
123 |
* @return mixed
|
124 |
*/
|
125 |
+
function fixarabic($content)
|
126 |
+
{
|
127 |
+
return str_replace(array('ي', 'ك', '٤', '٥', '٦', 'ة'), array('ی', 'ک', '۴', '۵', '۶', 'ه'), $content);
|
128 |
}
|
129 |
|
130 |
/**
|
134 |
*/
|
135 |
function wpp_login_headerurl()
|
136 |
{
|
137 |
+
return 'http://wp-parsi.com';
|
138 |
}
|
139 |
|
140 |
/**
|
144 |
* @author Ehsaan
|
145 |
* @return void
|
146 |
*/
|
147 |
+
function wpp_activation_notice()
|
148 |
+
{
|
149 |
+
$dismissed = get_option('wpp_dismissed', false);
|
150 |
|
151 |
+
if (!$dismissed) {
|
152 |
+
global $wpp_settings;
|
153 |
|
154 |
+
if ($wpp_settings['persian_date'] != 'enable') {
|
155 |
+
$output = sprintf(__('<div class="updated wpp-message"><p>ParsiDate activated, you may need to configure it to work properly. <a href="%s">Go to configuartion page</a> – <a href="%s">Dismiss</a></p></div>', 'wp-parsidate'), admin_url('admin.php?page=wp-parsi-settings'), add_query_arg('wpp-action', 'dismiss-notice'));
|
156 |
+
echo $output;
|
157 |
+
}
|
158 |
+
}
|
159 |
}
|
160 |
|
161 |
/**
|
164 |
* @author Ehsaan
|
165 |
* @return void
|
166 |
*/
|
167 |
+
function wpp_dismiss_notice_action()
|
168 |
+
{
|
169 |
+
if (isset($_GET['wpp-action']) && $_GET['wpp-action'] == 'dismiss-notice') {
|
170 |
+
update_option('wpp_dismissed', true);
|
171 |
+
}
|
172 |
}
|
includes/install.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* @subpackage Core/Install
|
8 |
*/
|
9 |
|
10 |
-
register_activation_hook(
|
11 |
|
12 |
/**
|
13 |
* Copys files from plugin languages folder to global languages folder
|
@@ -15,17 +15,18 @@ register_activation_hook( WP_PARSI_ROOT, 'wpp_install' );
|
|
15 |
* @since 1.0
|
16 |
* @return void
|
17 |
*/
|
18 |
-
function wpp_install()
|
19 |
-
|
20 |
-
/*if ( ! is_dir( WP_CONTENT_DIR . '/languages' ) )
|
21 |
-
mkdir( WP_CONTENT_DIR . '/languages/' );
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
$files = glob( $source );
|
26 |
|
27 |
-
|
28 |
-
|
|
|
29 |
|
30 |
-
|
|
|
|
|
|
|
31 |
}
|
7 |
* @subpackage Core/Install
|
8 |
*/
|
9 |
|
10 |
+
register_activation_hook(WP_PARSI_ROOT, 'wpp_install');
|
11 |
|
12 |
/**
|
13 |
* Copys files from plugin languages folder to global languages folder
|
15 |
* @since 1.0
|
16 |
* @return void
|
17 |
*/
|
18 |
+
function wpp_install()
|
19 |
+
{
|
|
|
|
|
20 |
|
21 |
+
/*if ( ! is_dir( WP_CONTENT_DIR . '/languages' ) )
|
22 |
+
mkdir( WP_CONTENT_DIR . '/languages/' );
|
|
|
23 |
|
24 |
+
$source = WP_PARSI_DIR . 'languages/*';
|
25 |
+
$destination = WP_CONTENT_DIR . '/languages/';
|
26 |
+
$files = glob( $source );
|
27 |
|
28 |
+
foreach( $files as $file )
|
29 |
+
@ copy( $file, $destination . basename( $file ) );*/
|
30 |
+
|
31 |
+
update_option('wpp_settings', array());
|
32 |
}
|
includes/parsidate.php
CHANGED
@@ -11,311 +11,326 @@ Reza Gholampanahi for convert function*/
|
|
11 |
|
12 |
class bn_parsidate
|
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 |
-
* bn_parsidate::trim_number()
|
130 |
-
* convert english number to persian number
|
131 |
-
* @param mixed $num
|
132 |
-
* @param string $sp
|
133 |
-
* @return string
|
134 |
-
*/
|
135 |
-
public function trim_number($num,$sp='٫')
|
136 |
-
{
|
137 |
-
$eng = array('0','1','2','3','4','5','6','7','8','9','.');
|
138 |
-
$per = array('۰','۱','۲','۳','۴','۵','۶','۷','۸','۹',$sp);
|
139 |
-
$number = filter_var($num, FILTER_SANITIZE_NUMBER_INT);
|
140 |
-
return empty($number)?str_replace($per,$eng,$num):str_replace($eng,$per,$num);
|
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 |
-
$timestamp =is_numeric($date) && (int)$date == $date?$date:strtotime($date);
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
$out.=$this->persian_day_small[$date['wday']];
|
186 |
-
break;
|
187 |
-
case'l':
|
188 |
-
$out.=$this->persian_day_names[$date['wday']];
|
189 |
-
break;
|
190 |
-
case 'j':
|
191 |
-
$out.=$date['mday'];
|
192 |
-
break;
|
193 |
-
case'N':
|
194 |
-
$out.=$this->week_day($date['wday'])+1;
|
195 |
-
break;
|
196 |
-
case'w':
|
197 |
-
$out.=$this->week_day($date['wday']);
|
198 |
-
break;
|
199 |
-
case'z':
|
200 |
-
$out.=$this->j_days_in_month[$date['mon']]+$date['mday'];
|
201 |
-
break;
|
202 |
-
//week
|
203 |
-
case'W':
|
204 |
-
$yday=$this->j_days_sum_month[$date['mon']-1]+$date['mday'];
|
205 |
-
$out.=intval($yday/7);
|
206 |
-
break;
|
207 |
-
//month
|
208 |
-
case'f':
|
209 |
-
$mon=$date['mon'];
|
210 |
-
switch($mon)
|
211 |
-
{
|
212 |
-
case($mon<4):
|
213 |
-
$out.=$this->sesson[0];
|
214 |
-
break;
|
215 |
-
case($mon<7):
|
216 |
-
$out.=$this->sesson[1];
|
217 |
-
break;
|
218 |
-
case($mon<10):
|
219 |
-
$out.=$this->sesson[2];
|
220 |
-
break;
|
221 |
-
case($mon>9):
|
222 |
-
$out.=$this->sesson[3];
|
223 |
-
break;
|
224 |
-
}
|
225 |
-
break;
|
226 |
-
case'F':
|
227 |
-
$out.=$this->persian_month_names[(int)$date['mon']];
|
228 |
-
break;
|
229 |
-
case'm':
|
230 |
-
$out.=($date['mon']<10)?'0'.$date['mon']:$date['mon'];
|
231 |
-
break;
|
232 |
-
case'M':
|
233 |
-
$out.=$this->persian_short_month_names[(int)$date['mon']];
|
234 |
-
break;
|
235 |
-
case'n':
|
236 |
-
$out.=$date['mon'];
|
237 |
-
break;
|
238 |
-
case'S':
|
239 |
-
$out.='ام';
|
240 |
-
break;
|
241 |
-
case't':
|
242 |
-
$out.=$this->j_days_in_month[(int)$date['mon']-1];
|
243 |
-
break;
|
244 |
-
//year
|
245 |
-
case'L':
|
246 |
-
$out.=(($date['year']%4)==0)?1:0;
|
247 |
-
break;
|
248 |
-
case'o':case'Y':
|
249 |
-
$out.=$date['year'];
|
250 |
-
break;
|
251 |
-
case'y':
|
252 |
-
$out.=substr($date['year'],2,2);
|
253 |
-
break;
|
254 |
-
//time
|
255 |
-
case'a':
|
256 |
-
$out.=($date['hours']<12)?'ق.ظ':'ب.ظ';
|
257 |
-
break;
|
258 |
-
case'A':
|
259 |
-
$out.=($date['hours']<12)?'قبل از ظهر':'بعد از ظهر';
|
260 |
-
break;
|
261 |
-
case'B':
|
262 |
-
$out.=(int)(1+($date['mon']/3));
|
263 |
-
break;
|
264 |
-
case'g':
|
265 |
-
$out.=($date['hours']>12)?$date['hours']-12:$date['hours'];
|
266 |
-
break;
|
267 |
-
case'G':
|
268 |
-
$out.=$date['hours'];
|
269 |
-
break;
|
270 |
-
case'h':
|
271 |
-
$hour=($date['hours']>12)?$date['hours']-12:$date['hours'];
|
272 |
-
$out.=($hour<10)?'0'.$hour:$hour;
|
273 |
-
break;
|
274 |
-
case'H':
|
275 |
-
$out.=($date['hours']<10)?'0'.$date['hours']:$date['hours'];
|
276 |
-
break;
|
277 |
-
case'i':
|
278 |
-
$out.=($date['minutes']<10)?'0'.$date['minutes']:$date['minutes'];
|
279 |
-
break;
|
280 |
-
case's':
|
281 |
-
$out.=($date['seconds']<10)?'0'.$date['seconds']:$date['seconds'];
|
282 |
-
break;
|
283 |
-
//full date time
|
284 |
-
case'c':
|
285 |
-
$out=$date['year'].'/'.$date['mon'].'/'.$date['mday'].' '.$date['hours'].':'.(($date['minutes']<10)?'0'.$date['minutes']:$date['minutes']).':'.(($date['seconds']<10)?'0'.$date['seconds']:$date['seconds']);//2004-02-12T15:19:21+00:00
|
286 |
-
break;
|
287 |
-
case'r':
|
288 |
-
$out=$this->persian_day_names[$date['wday']].','.$date['mday'].' '.$this->persian_month_names[(int)$date['mon']].' '.$date['year'].' '.$date['hours'].':'.(($date['minutes']<10)?'0'.$date['minutes']:$date['minutes']).':'.(($date['seconds']<10)?'0'.$date['seconds']:$date['seconds']) ;//Thu, 21 Dec 2000 16:01:07
|
289 |
-
break;
|
290 |
-
case'U':
|
291 |
-
$out=$timestamp;
|
292 |
-
break;
|
293 |
-
//others
|
294 |
-
case'e':case'I':case'i':case'O':case'P':case'T':case'Z':case'u':break;
|
295 |
-
default:$out.=$format[$i];
|
296 |
-
}
|
297 |
-
}
|
298 |
-
if($lang=='per')
|
299 |
-
return self::trim_number($out);
|
300 |
-
else
|
301 |
-
return $out;
|
302 |
-
}
|
303 |
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
}
|
|
|
319 |
/*
|
320 |
* parsidate function
|
321 |
*/
|
@@ -328,11 +343,11 @@ class bn_parsidate
|
|
328 |
* @param string $lang
|
329 |
* @return datetime
|
330 |
*/
|
331 |
-
function parsidate($input
|
332 |
{
|
333 |
-
|
334 |
-
$bndate = $bndate->persian_date($input
|
335 |
-
|
336 |
}
|
337 |
|
338 |
/**
|
@@ -343,9 +358,9 @@ function parsidate($input,$datetime='now',$lang='per')
|
|
343 |
* @param mixed $datetime
|
344 |
* @return datetime
|
345 |
*/
|
346 |
-
function gregdate($input
|
347 |
{
|
348 |
-
|
349 |
-
$bndate = $bndate->gregurian_date($input
|
350 |
-
|
351 |
}
|
11 |
|
12 |
class bn_parsidate
|
13 |
{
|
14 |
+
protected static $instance;
|
15 |
+
public $persian_month_names = array('', 'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند');
|
16 |
+
public $persian_short_month_names = array('', 'فرو', 'ارد', 'خرد', 'تیر', 'مرد', 'شهر', 'مهر', 'آبا', 'آذر', 'دی', 'بهم', 'اسف');
|
17 |
+
public $sesson = array('بهار', 'تابستان', 'پاییز', 'زمستان');
|
18 |
|
19 |
+
public $persian_day_names = array('یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه');
|
20 |
+
public $persian_day_small = array('ی', 'د', 'س', 'چ', 'پ', 'ج', 'ش');
|
21 |
|
22 |
+
public $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
|
23 |
+
private $j_days_sum_month = array(0, 0, 31, 62, 93, 124, 155, 186, 216, 246, 276, 306, 336);
|
24 |
|
25 |
+
private $g_days_sum_month = array(0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334);
|
26 |
|
27 |
|
28 |
+
/**
|
29 |
+
* Constructor
|
30 |
+
*/
|
31 |
+
function __construct()
|
32 |
+
{
|
33 |
+
if ($this->IsLeapYear($this->persian_date("Y", time(), "eng"))) {
|
34 |
+
$this->j_days_in_month[11] = 30;
|
35 |
+
}
|
36 |
+
}
|
37 |
|
38 |
+
/**
|
39 |
+
* bn_parsidate::IsLeapYear()
|
40 |
+
* check year is leap
|
41 |
+
*
|
42 |
+
* @param mixed $year
|
43 |
+
* @return boolean
|
44 |
+
*/
|
45 |
+
private function IsLeapYear($year)
|
46 |
+
{
|
47 |
+
if ((($year % 4) == 0 && ($year % 100) != 0) || (($year % 400) == 0) && ($year % 100) == 0)
|
48 |
+
return true;
|
49 |
+
else
|
50 |
+
return false;
|
51 |
+
}
|
52 |
|
53 |
+
/**
|
54 |
+
* bn_parsidate::persian_date()
|
55 |
+
* convert gregorian datetime to persian datetime
|
56 |
+
*
|
57 |
+
* @param mixed $format
|
58 |
+
* @param string $date
|
59 |
+
* @param string $lang
|
60 |
+
* @return datetime
|
61 |
+
*/
|
62 |
+
public function persian_date($format, $date = 'now', $lang = 'per')
|
63 |
+
{
|
64 |
+
$j_days_in_month = array(31, 62, 93, 124, 155, 186, 216, 246, 276, 306, 336, 365);
|
65 |
+
$timestamp = is_numeric($date) && (int)$date == $date ? $date : strtotime($date);
|
|
|
66 |
|
67 |
+
$date = getdate($timestamp);
|
68 |
+
list($date['year'], $date['mon'], $date['mday']) = self::gregorian_to_persian($date['year'], $date['mon'], $date['mday']);
|
69 |
+
$date['mon'] = (int)$date['mon'];
|
70 |
+
$date['mday'] = (int)$date['mday'];
|
71 |
+
$out = '';
|
72 |
+
for ($i = 0; $i < strlen($format); $i++) {
|
73 |
+
Switch ($format[$i]) {
|
74 |
+
//day
|
75 |
+
case 'd':
|
76 |
+
$out .= ($date['mday'] < 10) ? '0' . $date['mday'] : $date['mday'];
|
77 |
+
break;
|
78 |
+
case 'D':
|
79 |
+
$out .= $this->persian_day_small[$date['wday']];
|
80 |
+
break;
|
81 |
+
case'l':
|
82 |
+
$out .= $this->persian_day_names[$date['wday']];
|
83 |
+
break;
|
84 |
+
case 'j':
|
85 |
+
$out .= $date['mday'];
|
86 |
+
break;
|
87 |
+
case'N':
|
88 |
+
$out .= $this->week_day($date['wday']) + 1;
|
89 |
+
break;
|
90 |
+
case'w':
|
91 |
+
$out .= $this->week_day($date['wday']);
|
92 |
+
break;
|
93 |
+
case'z':
|
94 |
+
$out .= $this->j_days_in_month[$date['mon']] + $date['mday'];
|
95 |
+
break;
|
96 |
+
//week
|
97 |
+
case'W':
|
98 |
+
$yday = $this->j_days_sum_month[$date['mon'] - 1] + $date['mday'];
|
99 |
+
$out .= intval($yday / 7);
|
100 |
+
break;
|
101 |
+
//month
|
102 |
+
case'f':
|
103 |
+
$mon = $date['mon'];
|
104 |
+
switch ($mon) {
|
105 |
+
case($mon < 4):
|
106 |
+
$out .= $this->sesson[0];
|
107 |
+
break;
|
108 |
+
case($mon < 7):
|
109 |
+
$out .= $this->sesson[1];
|
110 |
+
break;
|
111 |
+
case($mon < 10):
|
112 |
+
$out .= $this->sesson[2];
|
113 |
+
break;
|
114 |
+
case($mon > 9):
|
115 |
+
$out .= $this->sesson[3];
|
116 |
+
break;
|
117 |
+
}
|
118 |
+
break;
|
119 |
+
case'F':
|
120 |
+
$out .= $this->persian_month_names[(int)$date['mon']];
|
121 |
+
break;
|
122 |
+
case'm':
|
123 |
+
$out .= ($date['mon'] < 10) ? '0' . $date['mon'] : $date['mon'];
|
124 |
+
break;
|
125 |
+
case'M':
|
126 |
+
$out .= $this->persian_short_month_names[(int)$date['mon']];
|
127 |
+
break;
|
128 |
+
case'n':
|
129 |
+
$out .= $date['mon'];
|
130 |
+
break;
|
131 |
+
case'S':
|
132 |
+
$out .= 'ام';
|
133 |
+
break;
|
134 |
+
case't':
|
135 |
+
$out .= $this->j_days_in_month[(int)$date['mon'] - 1];
|
136 |
+
break;
|
137 |
+
//year
|
138 |
+
case'L':
|
139 |
+
$out .= (($date['year'] % 4) == 0) ? 1 : 0;
|
140 |
+
break;
|
141 |
+
case'o':
|
142 |
+
case'Y':
|
143 |
+
$out .= $date['year'];
|
144 |
+
break;
|
145 |
+
case'y':
|
146 |
+
$out .= substr($date['year'], 2, 2);
|
147 |
+
break;
|
148 |
+
//time
|
149 |
+
case'a':
|
150 |
+
$out .= ($date['hours'] < 12) ? 'ق.ظ' : 'ب.ظ';
|
151 |
+
break;
|
152 |
+
case'A':
|
153 |
+
$out .= ($date['hours'] < 12) ? 'قبل از ظهر' : 'بعد از ظهر';
|
154 |
+
break;
|
155 |
+
case'B':
|
156 |
+
$out .= (int)(1 + ($date['mon'] / 3));
|
157 |
+
break;
|
158 |
+
case'g':
|
159 |
+
$out .= ($date['hours'] > 12) ? $date['hours'] - 12 : $date['hours'];
|
160 |
+
break;
|
161 |
+
case'G':
|
162 |
+
$out .= $date['hours'];
|
163 |
+
break;
|
164 |
+
case'h':
|
165 |
+
$hour = ($date['hours'] > 12) ? $date['hours'] - 12 : $date['hours'];
|
166 |
+
$out .= ($hour < 10) ? '0' . $hour : $hour;
|
167 |
+
break;
|
168 |
+
case'H':
|
169 |
+
$out .= ($date['hours'] < 10) ? '0' . $date['hours'] : $date['hours'];
|
170 |
+
break;
|
171 |
+
case'i':
|
172 |
+
$out .= ($date['minutes'] < 10) ? '0' . $date['minutes'] : $date['minutes'];
|
173 |
+
break;
|
174 |
+
case's':
|
175 |
+
$out .= ($date['seconds'] < 10) ? '0' . $date['seconds'] : $date['seconds'];
|
176 |
+
break;
|
177 |
+
//full date time
|
178 |
+
case'c':
|
179 |
+
$out = $date['year'] . '/' . $date['mon'] . '/' . $date['mday'] . ' ' . $date['hours'] . ':' . (($date['minutes'] < 10) ? '0' . $date['minutes'] : $date['minutes']) . ':' . (($date['seconds'] < 10) ? '0' . $date['seconds'] : $date['seconds']);//2004-02-12T15:19:21+00:00
|
180 |
+
break;
|
181 |
+
case'r':
|
182 |
+
$out = $this->persian_day_names[$date['wday']] . ',' . $date['mday'] . ' ' . $this->persian_month_names[(int)$date['mon']] . ' ' . $date['year'] . ' ' . $date['hours'] . ':' . (($date['minutes'] < 10) ? '0' . $date['minutes'] : $date['minutes']) . ':' . (($date['seconds'] < 10) ? '0' . $date['seconds'] : $date['seconds']);//Thu, 21 Dec 2000 16:01:07
|
183 |
+
break;
|
184 |
+
case'U':
|
185 |
+
$out = $timestamp;
|
186 |
+
break;
|
187 |
+
//others
|
188 |
+
case'e':
|
189 |
+
case'I':
|
190 |
+
case'i':
|
191 |
+
case'O':
|
192 |
+
case'P':
|
193 |
+
case'T':
|
194 |
+
case'Z':
|
195 |
+
case'u':
|
196 |
+
break;
|
197 |
+
default:
|
198 |
+
$out .= $format[$i];
|
199 |
+
}
|
200 |
+
}
|
201 |
+
if ($lang == 'per')
|
202 |
+
return self::trim_number($out);
|
203 |
+
else
|
204 |
+
return $out;
|
205 |
+
}
|
206 |
|
207 |
+
/**
|
208 |
+
* bn_parsidate::gregorian_to_persian()
|
209 |
+
* convert gregorian date to persian date
|
210 |
+
*
|
211 |
+
* @param mixed $gy
|
212 |
+
* @param mixed $gm
|
213 |
+
* @param mixed $gd
|
214 |
+
* @return array
|
215 |
+
*/
|
216 |
+
function gregorian_to_persian($gy, $gm, $gd)
|
217 |
+
{
|
218 |
+
$dayofyear = $this->g_days_sum_month[(int)$gm] + $gd;
|
219 |
+
if (self::IsLeapYear($gy) and $gm > 2)
|
220 |
+
$dayofyear++;
|
221 |
+
$d_33 = (int)((($gy - 16) % 132) * 0.0305);
|
222 |
+
$leap = $gy % 4;
|
223 |
+
$a = (($d_33 == 1 or $d_33 == 2) and ($d_33 == $leap or $leap == 1)) ? 78 : (($d_33 == 3 and $leap == 0) ? 80 : 79);
|
224 |
+
$b = ($d_33 == 3 or $d_33 < ($leap - 1) or $leap == 0) ? 286 : 287;
|
225 |
+
if ((int)(($gy - 10) / 63) == 30) {
|
226 |
+
$b--;
|
227 |
+
$a++;
|
228 |
+
}
|
229 |
+
if ($dayofyear > $a) {
|
230 |
+
$jy = $gy - 621;
|
231 |
+
$jd = $dayofyear - $a;
|
232 |
+
} else {
|
233 |
+
$jy = $gy - 622;
|
234 |
+
$jd = $dayofyear + $b;
|
235 |
+
}
|
236 |
+
for ($i = 0; $i < 11 and $jd > $this->j_days_in_month[$i]; $i++)
|
237 |
+
$jd -= $this->j_days_in_month[$i];
|
238 |
+
$jm = ++$i;
|
239 |
+
return array($jy, strlen($jm) == 1 ? '0' . $jm : $jm, strlen($jd) == 1 ? '0' . $jd : $jd);
|
240 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
|
242 |
+
/**
|
243 |
+
* Get day of the week shamsi/jalali
|
244 |
+
* @author Parsa Kafi
|
245 |
+
* @param int $wday
|
246 |
+
* @return int
|
247 |
+
*/
|
248 |
+
private function week_day($wday)
|
249 |
+
{
|
250 |
+
if ($wday == 6)
|
251 |
+
return 0;
|
252 |
+
else
|
253 |
+
return ++$wday;
|
254 |
+
}
|
255 |
|
256 |
+
/**
|
257 |
+
* bn_parsidate::trim_number()
|
258 |
+
* convert english number to persian number
|
259 |
+
* @param mixed $num
|
260 |
+
* @param string $sp
|
261 |
+
* @return string
|
262 |
+
*/
|
263 |
+
public function trim_number($num, $sp = '٫')
|
264 |
+
{
|
265 |
+
$eng = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.');
|
266 |
+
$per = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', $sp);
|
267 |
+
$number = filter_var($num, FILTER_SANITIZE_NUMBER_INT);
|
268 |
+
return empty($number) ? str_replace($per, $eng, $num) : str_replace($eng, $per, $num);
|
269 |
+
}
|
270 |
|
271 |
+
/**
|
272 |
+
* bn_parsidate::getInstance()
|
273 |
+
* create instance of bn_parsidate class
|
274 |
+
*
|
275 |
+
* @return instance
|
276 |
+
*/
|
277 |
+
public static function getInstance()
|
278 |
+
{
|
279 |
+
if (!isset(self::$instance))
|
280 |
+
self::$instance = new self();
|
281 |
+
return self::$instance;
|
282 |
+
}
|
|
|
283 |
|
284 |
+
/**
|
285 |
+
* bn_parsidate::gregurian_date()
|
286 |
+
* convert persian datetime to gregorian datetime
|
287 |
+
* @param mixed $format
|
288 |
+
* @param mixed $persiandate
|
289 |
+
* @return datetime
|
290 |
+
*/
|
291 |
+
public function gregurian_date($format, $persiandate)
|
292 |
+
{
|
293 |
+
preg_match_all('!\d+!', $persiandate, $matches);
|
294 |
+
$matches = $matches[0];
|
295 |
+
list($year, $mon, $day) = self::persian_to_gregorian($matches[0], $matches[1], $matches[2]);
|
296 |
+
return date($format, mktime((isset($matches[3]) ? $matches[3] : 0), (isset($matches[4]) ? $matches[4] : 0), (isset($matches[5]) ? $matches[5] : 0), $mon, $day, $year));
|
297 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
|
299 |
+
/**
|
300 |
+
* bn_parsidate::persian_to_gregorian()
|
301 |
+
* convert persian date to gregorian date
|
302 |
+
*
|
303 |
+
* @param mixed $jy
|
304 |
+
* @param mixed $jm
|
305 |
+
* @param mixed $jd
|
306 |
+
* @return array
|
307 |
+
*/
|
308 |
+
public function persian_to_gregorian($jy, $jm, $jd)
|
309 |
+
{
|
310 |
+
$doyj = ($jm - 2 > -1 ? $this->j_days_sum_month[(int)$jm] + $jd : $jd);
|
311 |
+
$d4 = ($jy + 1) % 4;
|
312 |
+
$d33 = (int)((($jy - 55) % 132) * .0305);
|
313 |
+
$a = ($d33 != 3 and $d4 <= $d33) ? 287 : 286;
|
314 |
+
$b = (($d33 == 1 or $d33 == 2) and ($d33 == $d4 or $d4 == 1)) ? 78 : (($d33 == 3 and $d4 == 0) ? 80 : 79);
|
315 |
+
if ((int)(($jy - 19) / 63) == 20) {
|
316 |
+
$a--;
|
317 |
+
$b++;
|
318 |
+
}
|
319 |
+
if ($doyj <= $a) {
|
320 |
+
$gy = $jy + 621;
|
321 |
+
$gd = $doyj + $b;
|
322 |
+
} else {
|
323 |
+
$gy = $jy + 622;
|
324 |
+
$gd = $doyj - $a;
|
325 |
+
}
|
326 |
+
foreach (array(0, 31, ($gy % 4 == 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) as $gm => $days) {
|
327 |
+
if ($gd <= $days) break;
|
328 |
+
$gd -= $days;
|
329 |
+
}
|
330 |
+
return array($gy, $gm, $gd);
|
331 |
+
}
|
332 |
}
|
333 |
+
|
334 |
/*
|
335 |
* parsidate function
|
336 |
*/
|
343 |
* @param string $lang
|
344 |
* @return datetime
|
345 |
*/
|
346 |
+
function parsidate($input, $datetime = 'now', $lang = 'per')
|
347 |
{
|
348 |
+
$bndate = bn_parsidate::getInstance();
|
349 |
+
$bndate = $bndate->persian_date($input, $datetime, $lang);
|
350 |
+
return $bndate;
|
351 |
}
|
352 |
|
353 |
/**
|
358 |
* @param mixed $datetime
|
359 |
* @return datetime
|
360 |
*/
|
361 |
+
function gregdate($input, $datetime)
|
362 |
{
|
363 |
+
$bndate = bn_parsidate::getInstance();
|
364 |
+
$bndate = $bndate->gregurian_date($input, $datetime);
|
365 |
+
return $bndate;
|
366 |
}
|
includes/plugins/edd.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Makes EDD compatible with WP-Parsidate plugin
|
4 |
*
|
@@ -6,80 +7,84 @@
|
|
6 |
* @subpackage Plugins/EDD
|
7 |
* @author Ehsaan
|
8 |
*/
|
|
|
|
|
|
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
*/
|
18 |
-
public static function getInstance() {
|
19 |
-
if ( self::$instance == null )
|
20 |
-
self::$instance = new WPP_EDD();
|
21 |
|
22 |
-
|
23 |
-
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
global $wpp_settings;
|
30 |
-
add_filter( 'wpp_plugins_compability_settings', array( $this, 'add_settings' ) );
|
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 |
return WPP_EDD::getInstance();
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Makes EDD compatible with WP-Parsidate plugin
|
5 |
*
|
7 |
* @subpackage Plugins/EDD
|
8 |
* @author Ehsaan
|
9 |
*/
|
10 |
+
class WPP_EDD
|
11 |
+
{
|
12 |
+
public static $instance = null;
|
13 |
|
14 |
+
/**
|
15 |
+
* Hooks required tags
|
16 |
+
*/
|
17 |
+
private function __construct()
|
18 |
+
{
|
19 |
+
global $wpp_settings;
|
20 |
+
add_filter('wpp_plugins_compability_settings', array($this, 'add_settings'));
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
if (isset($wpp_settings['edd_prices']) && $wpp_settings['edd_prices'] != 'disable') {
|
23 |
+
add_filter('edd_rial_currency_filter_after', 'per_number', 10, 2);
|
24 |
+
}
|
25 |
|
26 |
+
if (isset($wpp_settings['edd_rial_fix']) && $wpp_settings['edd_rial_fix'] != 'disable') {
|
27 |
+
add_filter('edd_rial_currency_filter_after', array($this, 'rial_fix'), 10, 2);
|
28 |
+
}
|
29 |
+
}
|
|
|
|
|
30 |
|
31 |
+
/**
|
32 |
+
* Returns an instance of class
|
33 |
+
*
|
34 |
+
* @return WPP_WooCommerce
|
35 |
+
*/
|
36 |
+
public static function getInstance()
|
37 |
+
{
|
38 |
+
if (self::$instance == null)
|
39 |
+
self::$instance = new WPP_EDD();
|
40 |
|
41 |
+
return self::$instance;
|
42 |
+
}
|
|
|
|
|
43 |
|
44 |
+
/**
|
45 |
+
* RIAL fix for EDD
|
46 |
+
*/
|
47 |
+
public function rial_fix($price, $did)
|
48 |
+
{
|
49 |
+
return str_replace('RIAL', 'ریال', $price);
|
50 |
+
}
|
51 |
|
52 |
+
/**
|
53 |
+
* Adds settings for toggle fixing
|
54 |
+
*
|
55 |
+
* @param array $old_settings Old settings
|
56 |
+
* @return array New settings
|
57 |
+
*/
|
58 |
+
public function add_settings($old_settings)
|
59 |
+
{
|
60 |
+
$options = array(
|
61 |
+
'enable' => __('Enable', 'wp-parsidate'),
|
62 |
+
'disable' => __('Disable', 'wp-parsidate')
|
63 |
+
);
|
64 |
+
$settings = array(
|
65 |
+
'edd' => array(
|
66 |
+
'id' => 'edd',
|
67 |
+
'name' => __('Easy Digital Downloads', 'wp-parsidate'),
|
68 |
+
'type' => 'header'
|
69 |
+
),
|
70 |
+
'edd_prices' => array(
|
71 |
+
'id' => 'edd_prices',
|
72 |
+
'name' => __('Fix prices', 'wp-parsidate'),
|
73 |
+
'type' => 'radio',
|
74 |
+
'options' => $options,
|
75 |
+
'std' => 'disable'
|
76 |
+
),
|
77 |
+
'edd_rial_fix' => array(
|
78 |
+
'id' => 'edd_rial_fix',
|
79 |
+
'name' => __('Replace ریال with RIAL', 'wp-parsidate'),
|
80 |
+
'type' => 'radio',
|
81 |
+
'options' => $options,
|
82 |
+
'std' => 'disable'
|
83 |
+
)
|
84 |
+
);
|
85 |
|
86 |
+
return array_merge($old_settings, $settings);
|
87 |
+
}
|
88 |
}
|
89 |
|
90 |
return WPP_EDD::getInstance();
|
includes/plugins/woocommerce.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Makes WooCommerce compatible with WP-Parsidate plugin
|
4 |
*
|
@@ -7,63 +8,66 @@
|
|
7 |
* @author Ehsaan
|
8 |
* @author Farhan Nisi
|
9 |
*/
|
|
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
*/
|
19 |
-
public static function getInstance() {
|
20 |
-
if ( self::$instance == null )
|
21 |
-
self::$instance = new WPP_WooCommerce();
|
22 |
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
add_filter( 'woocommerce_price_html', 'per_number' );
|
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 |
return WPP_WooCommerce::getInstance();
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Makes WooCommerce compatible with WP-Parsidate plugin
|
5 |
*
|
8 |
* @author Ehsaan
|
9 |
* @author Farhan Nisi
|
10 |
*/
|
11 |
+
class WPP_WooCommerce
|
12 |
+
{
|
13 |
+
public static $instance = null;
|
14 |
|
15 |
+
/**
|
16 |
+
* Hooks required tags
|
17 |
+
*/
|
18 |
+
private function __construct()
|
19 |
+
{
|
20 |
+
global $wpp_settings;
|
21 |
+
add_filter('wpp_plugins_compability_settings', array($this, 'add_settings'));
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
if (isset($wpp_settings['woo_per_price']) && $wpp_settings['woo_per_price'] != 'disable') {
|
24 |
+
add_filter('woocommerce_sale_price_html', 'per_number');
|
25 |
+
add_filter('woocommerce_price_html', 'per_number');
|
26 |
+
}
|
27 |
+
}
|
28 |
|
29 |
+
/**
|
30 |
+
* Returns an instance of class
|
31 |
+
*
|
32 |
+
* @return WPP_WooCommerce
|
33 |
+
*/
|
34 |
+
public static function getInstance()
|
35 |
+
{
|
36 |
+
if (self::$instance == null)
|
37 |
+
self::$instance = new WPP_WooCommerce();
|
38 |
|
39 |
+
return self::$instance;
|
40 |
+
}
|
|
|
|
|
|
|
41 |
|
42 |
+
/**
|
43 |
+
* Adds settings for toggle fixing
|
44 |
+
*
|
45 |
+
* @param array $old_settings Old settings
|
46 |
+
* @return array New settings
|
47 |
+
*/
|
48 |
+
public function add_settings($old_settings)
|
49 |
+
{
|
50 |
+
$options = array(
|
51 |
+
'enable' => __('Enable', 'wp-parsidate'),
|
52 |
+
'disable' => __('Disable', 'wp-parsidate')
|
53 |
+
);
|
54 |
+
$settings = array(
|
55 |
+
'woocommerce' => array(
|
56 |
+
'id' => 'woocommerce',
|
57 |
+
'name' => __('WooCommerce', 'wp-parsidate'),
|
58 |
+
'type' => 'header'
|
59 |
+
),
|
60 |
+
'woo_per_price' => array(
|
61 |
+
'id' => 'woo_per_price',
|
62 |
+
'name' => __('Fix prices', 'wp-parsidate'),
|
63 |
+
'type' => 'radio',
|
64 |
+
'options' => $options,
|
65 |
+
'std' => 'disable'
|
66 |
+
)
|
67 |
+
);
|
68 |
|
69 |
+
return array_merge($old_settings, $settings);
|
70 |
+
}
|
71 |
}
|
72 |
|
73 |
return WPP_WooCommerce::getInstance();
|
includes/settings.php
CHANGED
@@ -8,29 +8,30 @@
|
|
8 |
* @package WP-Parsidate
|
9 |
* @subpackage Admin/Settings
|
10 |
*/
|
11 |
-
if (
|
12 |
|
13 |
-
add_action(
|
14 |
|
15 |
/**
|
16 |
* Add WP-Parsidate admin page settings
|
17 |
* */
|
18 |
-
function wpp_add_settings_menu()
|
|
|
19 |
global $wpp_settings;
|
20 |
|
21 |
-
if (
|
22 |
add_submenu_page(
|
23 |
'options-general.php',
|
24 |
-
__(
|
25 |
-
__(
|
26 |
'manage_options',
|
27 |
'wp-parsi-settings',
|
28 |
'wpp_render_settings'
|
29 |
);
|
30 |
} else {
|
31 |
add_menu_page(
|
32 |
-
__('Parsi Settings','wp-parsidate')
|
33 |
-
__('Parsi Settings','wp-parsidate')
|
34 |
'manage_options',
|
35 |
'wp-parsi-settings',
|
36 |
'wpp_render_settings',
|
@@ -45,30 +46,31 @@ function wpp_add_settings_menu() {
|
|
45 |
* @since 2.0
|
46 |
* @return array Parsi Settings
|
47 |
*/
|
48 |
-
function wp_parsi_get_settings()
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
'
|
54 |
-
'
|
55 |
-
'
|
56 |
-
'
|
57 |
-
'
|
58 |
-
'
|
59 |
-
'
|
60 |
-
'
|
61 |
-
'
|
62 |
-
'
|
63 |
-
'
|
64 |
-
'
|
65 |
-
'
|
66 |
-
'
|
67 |
-
'
|
68 |
-
|
|
|
69 |
}
|
70 |
|
71 |
-
return apply_filters(
|
72 |
}
|
73 |
|
74 |
/**
|
@@ -77,11 +79,12 @@ function wp_parsi_get_settings() {
|
|
77 |
* @since 2.0
|
78 |
* @return void
|
79 |
*/
|
80 |
-
function wpp_register_settings()
|
81 |
-
|
82 |
-
|
|
|
83 |
|
84 |
-
foreach(
|
85 |
add_settings_section(
|
86 |
'wpp_settings_' . $tab,
|
87 |
__return_null(),
|
@@ -89,31 +92,32 @@ function wpp_register_settings() {
|
|
89 |
'wpp_settings_' . $tab
|
90 |
);
|
91 |
|
92 |
-
foreach(
|
93 |
-
$name = isset(
|
94 |
|
95 |
add_settings_field(
|
96 |
'wpp_settings[' . $option['id'] . ']',
|
97 |
$name,
|
98 |
-
function_exists(
|
99 |
'wpp_settings_' . $tab,
|
100 |
'wpp_settings_' . $tab,
|
101 |
array(
|
102 |
-
'id'
|
103 |
-
'desc'
|
104 |
-
'name'
|
105 |
'section' => $tab,
|
106 |
-
'size'
|
107 |
-
'options' => isset(
|
108 |
-
'std'
|
109 |
)
|
110 |
);
|
111 |
|
112 |
-
register_setting(
|
113 |
}
|
114 |
}
|
115 |
}
|
116 |
-
|
|
|
117 |
|
118 |
/**
|
119 |
* Gets settings tabs
|
@@ -121,13 +125,14 @@ add_action( 'admin_init', 'wpp_register_settings' );
|
|
121 |
* @since 2.0
|
122 |
* @return array Tabs list
|
123 |
*/
|
124 |
-
function wpp_get_tabs()
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
|
|
131 |
}
|
132 |
|
133 |
/**
|
@@ -137,57 +142,58 @@ function wpp_get_tabs() {
|
|
137 |
* @param array $input Settings input
|
138 |
* @return array New settings
|
139 |
*/
|
140 |
-
function wpp_settings_sanitize(
|
|
|
141 |
|
142 |
global $wpp_settings;
|
143 |
|
144 |
-
if(
|
145 |
return $input;
|
146 |
|
147 |
-
parse_str(
|
148 |
|
149 |
-
$settings
|
150 |
-
$tab
|
151 |
|
152 |
-
$input
|
153 |
-
$input
|
154 |
|
155 |
// Loop through each setting being saved and pass it through a sanitization filter
|
156 |
-
foreach(
|
157 |
|
158 |
// Get the setting type (checkbox, select, etc)
|
159 |
-
$type = isset(
|
160 |
|
161 |
-
if(
|
162 |
// Field type specific filter
|
163 |
-
$input[
|
164 |
}
|
165 |
|
166 |
// General filter
|
167 |
-
$input[
|
168 |
}
|
169 |
|
170 |
|
171 |
// Loop through the whitelist and unset any that are empty for the tab being saved
|
172 |
-
if(
|
173 |
-
foreach(
|
174 |
|
175 |
// settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
|
176 |
-
if(
|
177 |
$key = $value['id'];
|
178 |
}
|
179 |
|
180 |
-
if(
|
181 |
-
unset(
|
182 |
}
|
183 |
|
184 |
}
|
185 |
}
|
186 |
|
187 |
// Merge our new settings with the existing
|
188 |
-
$output = array_merge(
|
189 |
|
190 |
-
add_settings_error(
|
191 |
|
192 |
return $output;
|
193 |
|
@@ -199,194 +205,199 @@ function wpp_settings_sanitize( $input = array() ) {
|
|
199 |
* @since 2.0
|
200 |
* @return array Fields
|
201 |
*/
|
202 |
-
function wpp_get_registered_settings()
|
|
|
203 |
$options = array(
|
204 |
-
'enable'
|
205 |
-
'disable'
|
206 |
);
|
207 |
-
|
208 |
-
|
209 |
-
'admin_lang'
|
210 |
-
'id'
|
211 |
-
'name'
|
212 |
-
'type'
|
213 |
-
'options'
|
214 |
-
'std'
|
215 |
-
'desc'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
),
|
217 |
-
'
|
218 |
-
'id'
|
219 |
-
'name'
|
220 |
-
'type'
|
221 |
-
'options'
|
222 |
-
'std'
|
223 |
-
'desc' => __( 'This option change WordPress locale in theme', 'wp-parsidate' )
|
224 |
),
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
'desc' => __( 'By enabling this, Dates will convert to Shamsi (Jalali) dates', 'wp-parsidate' )
|
232 |
-
),
|
233 |
-
'submenu_move' => array(
|
234 |
-
'id' => 'submenu_move',
|
235 |
-
'name' => __( 'Move page to submenu?', 'wp-parsidate' ),
|
236 |
-
'type' => 'radio',
|
237 |
-
'options' => $options,
|
238 |
-
'std' => 'disable',
|
239 |
-
'desc' => __( 'With enabling this option, page item will be moved to Settings menu as submenu.', 'wp-parsidate' )
|
240 |
),
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
),
|
248 |
-
'conv_page_title' => array(
|
249 |
-
'id' => 'conv_page_title',
|
250 |
-
'name' => __( 'Page title', 'wp-parsidate' ),
|
251 |
-
'type' => 'radio',
|
252 |
-
'options' => $options,
|
253 |
-
'std' => 'disable'
|
254 |
-
),
|
255 |
-
'conv_title' => array(
|
256 |
-
'id' => 'conv_title',
|
257 |
-
'name' => __( 'Post title', 'wp-parsidate' ),
|
258 |
-
'type' => 'radio',
|
259 |
-
'options' => $options,
|
260 |
-
'std' => 'disable'
|
261 |
-
),
|
262 |
-
'conv_contents' => array(
|
263 |
-
'id' => 'conv_contents',
|
264 |
-
'name' => __( 'Post content', 'wp-parsidate' ),
|
265 |
-
'type' => 'radio',
|
266 |
-
'options' => $options,
|
267 |
-
'std' => 'enable'
|
268 |
-
),
|
269 |
-
'conv_excerpt' => array(
|
270 |
-
'id' => 'conv_excerpt',
|
271 |
-
'name' => __( 'Post excerpt', 'wp-parsidate' ),
|
272 |
-
'type' => 'radio',
|
273 |
-
'options' => $options,
|
274 |
-
'std' => 'disable'
|
275 |
-
),
|
276 |
-
'conv_comments' => array(
|
277 |
-
'id' => 'conv_comments',
|
278 |
-
'name' => __( 'Comments text', 'wp-parsidate' ),
|
279 |
-
'type' => 'radio',
|
280 |
-
'options' => $options,
|
281 |
-
'std' => 'disable'
|
282 |
-
),
|
283 |
-
'conv_comment_count'=> array(
|
284 |
-
'id' => 'conv_comment_count',
|
285 |
-
'name' => __( 'Comments count', 'wp-parsidate' ),
|
286 |
-
'type' => 'radio',
|
287 |
-
'options' => $options,
|
288 |
-
'std' => 'disable'
|
289 |
-
),
|
290 |
-
'conv_dates' => array(
|
291 |
-
'id' => 'conv_dates',
|
292 |
-
'name' => __( 'Dates', 'wp-parsidate' ),
|
293 |
-
'type' => 'radio',
|
294 |
-
'options' => $options,
|
295 |
-
'std' => 'disable'
|
296 |
-
),
|
297 |
-
'conv_cats' => array(
|
298 |
-
'id' => 'conv_cats',
|
299 |
-
'name' => __( 'Categories', 'wp-parsidate' ),
|
300 |
-
'type' => 'radio',
|
301 |
-
'options' => $options,
|
302 |
-
'std' => 'disable'
|
303 |
-
),
|
304 |
-
'sep' => array(
|
305 |
-
'id' => 'sep',
|
306 |
-
'type' => 'header'
|
307 |
),
|
308 |
-
'
|
309 |
-
'id'
|
310 |
-
'name'
|
311 |
-
'type'
|
312 |
-
'options'
|
313 |
-
'std'
|
314 |
-
'desc' => __( 'Fixes arabic characters caused by wrong keyboard layouts', 'wp-parsidate' )
|
315 |
),
|
316 |
-
'
|
317 |
-
'id'
|
318 |
-
'name'
|
319 |
-
'type'
|
320 |
-
'options'
|
321 |
-
'std'
|
322 |
-
'desc' => __( 'By enabling this, dates in permalinks converted to Shamsi (Jalali) date', 'wp-parsidate' )
|
323 |
),
|
324 |
-
'
|
325 |
-
'id'
|
326 |
-
'
|
|
|
|
|
|
|
327 |
),
|
328 |
-
'
|
329 |
-
'id'
|
330 |
-
'
|
331 |
-
'type' => 'radio',
|
332 |
-
'options' => $options,
|
333 |
-
'std' => 'enable',
|
334 |
-
'desc' => __( 'Droid Sans Naskh and Roboto font families will be activated in admin side, if this is enabled', 'wp-parsidate' )
|
335 |
),
|
336 |
-
'
|
337 |
-
'id'
|
338 |
-
'name'
|
339 |
-
'type'
|
340 |
-
'options'
|
341 |
-
'std'
|
342 |
-
'desc'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
343 |
)
|
344 |
-
|
345 |
-
'plugins'
|
346 |
-
|
347 |
-
|
348 |
}
|
349 |
|
350 |
/* Form Callbacks Made by EDD Development Team */
|
351 |
-
function wpp_header_callback(
|
|
|
352 |
echo '<hr/>';
|
353 |
}
|
354 |
|
355 |
-
function wpp_checkbox_callback(
|
|
|
356 |
global $wpp_settings;
|
357 |
|
358 |
$checked = isset($wpp_settings[$args['id']]) ? checked(1, $wpp_settings[$args['id']], false) : '';
|
359 |
$html = '<input type="checkbox" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="1" ' . $checked . '/>';
|
360 |
-
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> '
|
361 |
|
362 |
echo $html;
|
363 |
}
|
364 |
|
365 |
-
function wpp_multicheck_callback(
|
366 |
-
|
|
|
367 |
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
|
378 |
-
|
379 |
}
|
380 |
|
381 |
-
function wpp_radio_callback(
|
|
|
382 |
global $wpp_settings;
|
383 |
|
384 |
-
foreach (
|
385 |
$checked = false;
|
386 |
|
387 |
-
if (
|
388 |
$checked = true;
|
389 |
-
|
390 |
$checked = true;
|
391 |
|
392 |
echo '<input name="wpp_settings[' . $args['id'] . ']"" id="wpp_settings[' . $args['id'] . '][' . $key . ']" type="radio" value="' . $key . '" ' . checked(true, $checked, false) . '/>';
|
@@ -396,208 +407,219 @@ function wpp_radio_callback( $args ) {
|
|
396 |
echo '<p class="description">' . $args['desc'] . '</p>';
|
397 |
}
|
398 |
|
399 |
-
function wpp_text_callback(
|
|
|
400 |
global $wpp_settings;
|
401 |
|
402 |
-
if (
|
403 |
-
$value = $wpp_settings[
|
404 |
else
|
405 |
-
$value = isset(
|
406 |
|
407 |
-
$size = (
|
408 |
-
$html = '<input type="text" class="' . $size . '-text" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr(
|
409 |
-
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> '
|
410 |
|
411 |
echo $html;
|
412 |
}
|
413 |
|
414 |
-
function wpp_number_callback(
|
|
|
415 |
global $wpp_settings;
|
416 |
|
417 |
-
if (
|
418 |
-
$value = $wpp_settings[
|
419 |
else
|
420 |
-
$value = isset(
|
421 |
|
422 |
-
$max
|
423 |
-
$min
|
424 |
-
$step = isset(
|
425 |
|
426 |
-
$size = (
|
427 |
-
$html = '<input type="number" step="' . esc_attr(
|
428 |
-
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> '
|
429 |
|
430 |
echo $html;
|
431 |
}
|
432 |
|
433 |
-
function wpp_textarea_callback(
|
|
|
434 |
global $wpp_settings;
|
435 |
|
436 |
-
if (
|
437 |
-
$value = $wpp_settings[
|
438 |
else
|
439 |
-
$value = isset(
|
440 |
|
441 |
-
$size = (
|
442 |
-
$html = '<textarea class="large-text" cols="50" rows="5" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']">' . esc_textarea(
|
443 |
-
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> '
|
444 |
|
445 |
echo $html;
|
446 |
}
|
447 |
|
448 |
-
function wpp_password_callback(
|
|
|
449 |
global $wpp_settings;
|
450 |
|
451 |
-
if (
|
452 |
-
$value = $wpp_settings[
|
453 |
else
|
454 |
-
$value = isset(
|
455 |
|
456 |
-
$size = (
|
457 |
-
$html = '<input type="password" class="' . $size . '-text" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr(
|
458 |
-
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> '
|
459 |
|
460 |
echo $html;
|
461 |
}
|
462 |
|
463 |
-
function wpp_missing_callback($args)
|
|
|
464 |
echo '–';
|
465 |
return false;
|
466 |
}
|
467 |
|
468 |
|
469 |
-
function wpp_select_callback($args)
|
|
|
470 |
global $wpp_settings;
|
471 |
|
472 |
-
if (
|
473 |
-
$value = $wpp_settings[
|
474 |
else
|
475 |
-
$value = isset(
|
476 |
|
477 |
$html = '<select id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']"/>';
|
478 |
|
479 |
-
foreach (
|
480 |
-
$selected = selected(
|
481 |
$html .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
|
482 |
endforeach;
|
483 |
|
484 |
$html .= '</select>';
|
485 |
-
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> '
|
486 |
|
487 |
echo $html;
|
488 |
}
|
489 |
|
490 |
-
function wpp_color_select_callback(
|
|
|
491 |
global $wpp_settings;
|
492 |
|
493 |
-
if (
|
494 |
-
$value = $wpp_settings[
|
495 |
else
|
496 |
-
$value = isset(
|
497 |
|
498 |
$html = '<select id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']"/>';
|
499 |
|
500 |
-
foreach (
|
501 |
-
$selected = selected(
|
502 |
$html .= '<option value="' . $option . '" ' . $selected . '>' . $color['label'] . '</option>';
|
503 |
endforeach;
|
504 |
|
505 |
$html .= '</select>';
|
506 |
-
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> '
|
507 |
|
508 |
echo $html;
|
509 |
}
|
510 |
|
511 |
-
function wpp_rich_editor_callback(
|
|
|
512 |
global $wpp_settings, $wp_version;
|
513 |
|
514 |
-
if (
|
515 |
-
$value = $wpp_settings[
|
516 |
else
|
517 |
-
$value = isset(
|
518 |
|
519 |
-
if (
|
520 |
-
$html = wp_editor(
|
521 |
} else {
|
522 |
-
$html = '<textarea class="large-text" rows="10" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']">' . esc_textarea(
|
523 |
}
|
524 |
|
525 |
-
$html .= '<br/><label for="wpp_settings[' . $args['id'] . ']"> '
|
526 |
|
527 |
echo $html;
|
528 |
}
|
529 |
|
530 |
-
function wpp_upload_callback(
|
|
|
531 |
global $wpp_settings;
|
532 |
|
533 |
-
if (
|
534 |
$value = $wpp_settings[$args['id']];
|
535 |
else
|
536 |
$value = isset($args['std']) ? $args['std'] : '';
|
537 |
|
538 |
-
$size = (
|
539 |
-
$html = '<input type="text" class="' . $size . '-text wpp_upload_field" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr(
|
540 |
-
$html .= '<span> <input type="button" class="wpp_settings_upload_button button-secondary" value="' . __(
|
541 |
-
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> '
|
542 |
|
543 |
echo $html;
|
544 |
}
|
545 |
|
546 |
-
function wpp_color_callback(
|
|
|
547 |
global $wpp_settings;
|
548 |
|
549 |
-
if (
|
550 |
-
$value = $wpp_settings[
|
551 |
else
|
552 |
-
$value = isset(
|
553 |
|
554 |
-
$default = isset(
|
555 |
|
556 |
-
$size = (
|
557 |
-
$html = '<input type="text" class="wpp-color-picker" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr(
|
558 |
-
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> '
|
559 |
|
560 |
echo $html;
|
561 |
}
|
562 |
|
563 |
-
function wpp_render_settings()
|
|
|
564 |
global $wpp_settings;
|
565 |
-
$active_tab = isset(
|
566 |
|
567 |
ob_start();
|
568 |
?>
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
<?php
|
573 |
-
foreach(
|
574 |
|
575 |
-
$tab_url = add_query_arg(
|
576 |
'settings-updated' => false,
|
577 |
'tab' => $tab_id
|
578 |
-
)
|
579 |
|
580 |
$active = $active_tab == $tab_id ? ' nav-tab-active' : '';
|
581 |
|
582 |
-
echo '<a href="' . esc_url(
|
583 |
-
|
584 |
echo '</a>';
|
585 |
}
|
586 |
?>
|
587 |
-
|
588 |
-
<?php echo settings_errors(
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
<?php submit_button(); ?>
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
<?php
|
602 |
echo ob_get_clean();
|
603 |
}
|
8 |
* @package WP-Parsidate
|
9 |
* @subpackage Admin/Settings
|
10 |
*/
|
11 |
+
if (!defined('ABSPATH')) exit; // No direct access allowed ;)
|
12 |
|
13 |
+
add_action('admin_menu', 'wpp_add_settings_menu', 11);
|
14 |
|
15 |
/**
|
16 |
* Add WP-Parsidate admin page settings
|
17 |
* */
|
18 |
+
function wpp_add_settings_menu()
|
19 |
+
{
|
20 |
global $wpp_settings;
|
21 |
|
22 |
+
if ($wpp_settings['submenu_move'] != 'disable') {
|
23 |
add_submenu_page(
|
24 |
'options-general.php',
|
25 |
+
__('Parsi Settings', 'wp-parsidate'),
|
26 |
+
__('Parsi Settings', 'wp-parsidate'),
|
27 |
'manage_options',
|
28 |
'wp-parsi-settings',
|
29 |
'wpp_render_settings'
|
30 |
);
|
31 |
} else {
|
32 |
add_menu_page(
|
33 |
+
__('Parsi Settings', 'wp-parsidate'),
|
34 |
+
__('Parsi Settings', 'wp-parsidate'),
|
35 |
'manage_options',
|
36 |
'wp-parsi-settings',
|
37 |
'wpp_render_settings',
|
46 |
* @since 2.0
|
47 |
* @return array Parsi Settings
|
48 |
*/
|
49 |
+
function wp_parsi_get_settings()
|
50 |
+
{
|
51 |
+
$settings = get_option('wpp_settings');
|
52 |
+
if (empty($settings)) {
|
53 |
+
update_option('wpp_settings', array(
|
54 |
+
'admin_lang' => 'enable',
|
55 |
+
'user_lang' => 'enable',
|
56 |
+
'submenu_move' => 'disable',
|
57 |
+
'persian_date' => 'disable',
|
58 |
+
'droidsans_editor' => 'enable',
|
59 |
+
'droidsans_admin' => 'enable',
|
60 |
+
'conv_title' => 'disable',
|
61 |
+
'conv_contents' => 'disable',
|
62 |
+
'conv_excerpt' => 'disable',
|
63 |
+
'conv_comments' => 'disable',
|
64 |
+
'conv_comment_count' => 'disable',
|
65 |
+
'conv_dates' => 'disable',
|
66 |
+
'conv_cats' => 'disable',
|
67 |
+
'conv_arabic' => 'disable',
|
68 |
+
'conv_permalinks' => 'disable',
|
69 |
+
'news_source' => 'parsi'
|
70 |
+
));
|
71 |
}
|
72 |
|
73 |
+
return apply_filters('wpp_get_settings', $settings);
|
74 |
}
|
75 |
|
76 |
/**
|
79 |
* @since 2.0
|
80 |
* @return void
|
81 |
*/
|
82 |
+
function wpp_register_settings()
|
83 |
+
{
|
84 |
+
if (false == get_option('wpp_settings'))
|
85 |
+
add_option('wpp_settings');
|
86 |
|
87 |
+
foreach (wpp_get_registered_settings() as $tab => $settings) {
|
88 |
add_settings_section(
|
89 |
'wpp_settings_' . $tab,
|
90 |
__return_null(),
|
92 |
'wpp_settings_' . $tab
|
93 |
);
|
94 |
|
95 |
+
foreach ($settings as $option) {
|
96 |
+
$name = isset($option['name']) ? $option['name'] : '';
|
97 |
|
98 |
add_settings_field(
|
99 |
'wpp_settings[' . $option['id'] . ']',
|
100 |
$name,
|
101 |
+
function_exists('wpp_' . $option['type'] . '_callback') ? 'wpp_' . $option['type'] . '_callback' : 'wpp_missing_callback',
|
102 |
'wpp_settings_' . $tab,
|
103 |
'wpp_settings_' . $tab,
|
104 |
array(
|
105 |
+
'id' => isset($option['id']) ? $option['id'] : null,
|
106 |
+
'desc' => !empty($option['desc']) ? $option['desc'] : '',
|
107 |
+
'name' => isset($option['name']) ? $option['name'] : null,
|
108 |
'section' => $tab,
|
109 |
+
'size' => isset($option['size']) ? $option['size'] : null,
|
110 |
+
'options' => isset($option['options']) ? $option['options'] : '',
|
111 |
+
'std' => isset($option['std']) ? $option['std'] : ''
|
112 |
)
|
113 |
);
|
114 |
|
115 |
+
register_setting('wpp_settings', 'wpp_settings', 'wpp_settings_sanitize');
|
116 |
}
|
117 |
}
|
118 |
}
|
119 |
+
|
120 |
+
add_action('admin_init', 'wpp_register_settings');
|
121 |
|
122 |
/**
|
123 |
* Gets settings tabs
|
125 |
* @since 2.0
|
126 |
* @return array Tabs list
|
127 |
*/
|
128 |
+
function wpp_get_tabs()
|
129 |
+
{
|
130 |
+
$tabs = array(
|
131 |
+
'core' => sprintf(__('%s Core', 'wp-parsidate'), '<span class="dashicons dashicons-admin-site"></span>'),
|
132 |
+
'conv' => sprintf(__('%s Converts', 'wp-parsidate'), '<span class="dashicons dashicons-admin-settings"></span>'),
|
133 |
+
'plugins' => sprintf(__('%s Plugins compability', 'wp-parsidate'), '<span class="dashicons dashicons-admin-plugins"></span>')
|
134 |
+
);
|
135 |
+
return $tabs;
|
136 |
}
|
137 |
|
138 |
/**
|
142 |
* @param array $input Settings input
|
143 |
* @return array New settings
|
144 |
*/
|
145 |
+
function wpp_settings_sanitize($input = array())
|
146 |
+
{
|
147 |
|
148 |
global $wpp_settings;
|
149 |
|
150 |
+
if (empty($_POST['_wp_http_referer']))
|
151 |
return $input;
|
152 |
|
153 |
+
parse_str($_POST['_wp_http_referer'], $referrer);
|
154 |
|
155 |
+
$settings = wpp_get_registered_settings();
|
156 |
+
$tab = isset($referrer['tab']) ? $referrer['tab'] : 'core';
|
157 |
|
158 |
+
$input = $input ? $input : array();
|
159 |
+
$input = apply_filters('wpp_settings_' . $tab . '_sanitize', $input);
|
160 |
|
161 |
// Loop through each setting being saved and pass it through a sanitization filter
|
162 |
+
foreach ($input as $key => $value) {
|
163 |
|
164 |
// Get the setting type (checkbox, select, etc)
|
165 |
+
$type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false;
|
166 |
|
167 |
+
if ($type) {
|
168 |
// Field type specific filter
|
169 |
+
$input[$key] = apply_filters('wpp_settings_sanitize_' . $type, $value, $key);
|
170 |
}
|
171 |
|
172 |
// General filter
|
173 |
+
$input[$key] = apply_filters('wpp_settings_sanitize', $value, $key);
|
174 |
}
|
175 |
|
176 |
|
177 |
// Loop through the whitelist and unset any that are empty for the tab being saved
|
178 |
+
if (!empty($settings[$tab])) {
|
179 |
+
foreach ($settings[$tab] as $key => $value) {
|
180 |
|
181 |
// settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
|
182 |
+
if (is_numeric($key)) {
|
183 |
$key = $value['id'];
|
184 |
}
|
185 |
|
186 |
+
if (empty($input[$key])) {
|
187 |
+
unset($wpp_settings[$key]);
|
188 |
}
|
189 |
|
190 |
}
|
191 |
}
|
192 |
|
193 |
// Merge our new settings with the existing
|
194 |
+
$output = array_merge($wpp_settings, $input);
|
195 |
|
196 |
+
add_settings_error('wpp-notices', '', __('Settings updated', 'wp-parsidate'), 'updated');
|
197 |
|
198 |
return $output;
|
199 |
|
205 |
* @since 2.0
|
206 |
* @return array Fields
|
207 |
*/
|
208 |
+
function wpp_get_registered_settings()
|
209 |
+
{
|
210 |
$options = array(
|
211 |
+
'enable' => __('Enable', 'wp-parsidate'),
|
212 |
+
'disable' => __('Disable', 'wp-parsidate')
|
213 |
);
|
214 |
+
$settings = apply_filters('wpp_registered_settings', array(
|
215 |
+
'core' => apply_filters('wpp_core_settings', array(
|
216 |
+
'admin_lang' => array(
|
217 |
+
'id' => 'admin_lang',
|
218 |
+
'name' => __('Change Locale in admin', 'wp-parsidate'),
|
219 |
+
'type' => 'radio',
|
220 |
+
'options' => $options,
|
221 |
+
'std' => 'enable',
|
222 |
+
'desc' => __('This option change WordPress locale in Admin', 'wp-parsidate')
|
223 |
+
),
|
224 |
+
'user_lang' => array(
|
225 |
+
'id' => 'user_lang',
|
226 |
+
'name' => __('Change Locale in theme', 'wp-parsidate'),
|
227 |
+
'type' => 'radio',
|
228 |
+
'options' => $options,
|
229 |
+
'std' => 'enable',
|
230 |
+
'desc' => __('This option change WordPress locale in theme', 'wp-parsidate')
|
231 |
+
),
|
232 |
+
'persian_date' => array(
|
233 |
+
'id' => 'persian_date',
|
234 |
+
'name' => __('Shamsi date', 'wp-parsidate'),
|
235 |
+
'type' => 'radio',
|
236 |
+
'options' => $options,
|
237 |
+
'std' => 'disable',
|
238 |
+
'desc' => __('By enabling this, Dates will convert to Shamsi (Jalali) dates', 'wp-parsidate')
|
239 |
+
),
|
240 |
+
'submenu_move' => array(
|
241 |
+
'id' => 'submenu_move',
|
242 |
+
'name' => __('Move page to submenu?', 'wp-parsidate'),
|
243 |
+
'type' => 'radio',
|
244 |
+
'options' => $options,
|
245 |
+
'std' => 'disable',
|
246 |
+
'desc' => __('With enabling this option, page item will be moved to Settings menu as submenu.', 'wp-parsidate')
|
247 |
+
),
|
248 |
+
)),
|
249 |
+
'conv' => apply_filters('wpp_conv_settings', array(
|
250 |
+
'conv_nums' => array(
|
251 |
+
'id' => 'conv_nums',
|
252 |
+
'name' => __('Persian digits', 'wp-parsidate'),
|
253 |
+
'type' => 'header'
|
254 |
+
),
|
255 |
+
'conv_page_title' => array(
|
256 |
+
'id' => 'conv_page_title',
|
257 |
+
'name' => __('Page title', 'wp-parsidate'),
|
258 |
+
'type' => 'radio',
|
259 |
+
'options' => $options,
|
260 |
+
'std' => 'disable'
|
261 |
+
),
|
262 |
+
'conv_title' => array(
|
263 |
+
'id' => 'conv_title',
|
264 |
+
'name' => __('Post title', 'wp-parsidate'),
|
265 |
+
'type' => 'radio',
|
266 |
+
'options' => $options,
|
267 |
+
'std' => 'disable'
|
268 |
),
|
269 |
+
'conv_contents' => array(
|
270 |
+
'id' => 'conv_contents',
|
271 |
+
'name' => __('Post content', 'wp-parsidate'),
|
272 |
+
'type' => 'radio',
|
273 |
+
'options' => $options,
|
274 |
+
'std' => 'enable'
|
|
|
275 |
),
|
276 |
+
'conv_excerpt' => array(
|
277 |
+
'id' => 'conv_excerpt',
|
278 |
+
'name' => __('Post excerpt', 'wp-parsidate'),
|
279 |
+
'type' => 'radio',
|
280 |
+
'options' => $options,
|
281 |
+
'std' => 'disable'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
),
|
283 |
+
'conv_comments' => array(
|
284 |
+
'id' => 'conv_comments',
|
285 |
+
'name' => __('Comments text', 'wp-parsidate'),
|
286 |
+
'type' => 'radio',
|
287 |
+
'options' => $options,
|
288 |
+
'std' => 'disable'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
),
|
290 |
+
'conv_comment_count' => array(
|
291 |
+
'id' => 'conv_comment_count',
|
292 |
+
'name' => __('Comments count', 'wp-parsidate'),
|
293 |
+
'type' => 'radio',
|
294 |
+
'options' => $options,
|
295 |
+
'std' => 'disable'
|
|
|
296 |
),
|
297 |
+
'conv_dates' => array(
|
298 |
+
'id' => 'conv_dates',
|
299 |
+
'name' => __('Dates', 'wp-parsidate'),
|
300 |
+
'type' => 'radio',
|
301 |
+
'options' => $options,
|
302 |
+
'std' => 'disable'
|
|
|
303 |
),
|
304 |
+
'conv_cats' => array(
|
305 |
+
'id' => 'conv_cats',
|
306 |
+
'name' => __('Categories', 'wp-parsidate'),
|
307 |
+
'type' => 'radio',
|
308 |
+
'options' => $options,
|
309 |
+
'std' => 'disable'
|
310 |
),
|
311 |
+
'sep' => array(
|
312 |
+
'id' => 'sep',
|
313 |
+
'type' => 'header'
|
|
|
|
|
|
|
|
|
314 |
),
|
315 |
+
'conv_arabic' => array(
|
316 |
+
'id' => 'conv_arabic',
|
317 |
+
'name' => __('Fix arabic characters', 'wp-parsidate'),
|
318 |
+
'type' => 'radio',
|
319 |
+
'options' => $options,
|
320 |
+
'std' => 'disable',
|
321 |
+
'desc' => __('Fixes arabic characters caused by wrong keyboard layouts', 'wp-parsidate')
|
322 |
+
),
|
323 |
+
'conv_permalinks' => array(
|
324 |
+
'id' => 'conv_permalinks',
|
325 |
+
'name' => __('Fix permalinks dates', 'wp-parsidate'),
|
326 |
+
'type' => 'radio',
|
327 |
+
'options' => $options,
|
328 |
+
'std' => 'disable',
|
329 |
+
'desc' => __('By enabling this, dates in permalinks converted to Shamsi (Jalali) date', 'wp-parsidate')
|
330 |
+
),
|
331 |
+
'sep_font' => array(
|
332 |
+
'id' => 'sep_font',
|
333 |
+
'type' => 'header'
|
334 |
+
),
|
335 |
+
'droidsans_admin' => array(
|
336 |
+
'id' => 'droidsans_admin',
|
337 |
+
'name' => __('Use Droid Sans font for admin side', 'wp-parsidate'),
|
338 |
+
'type' => 'radio',
|
339 |
+
'options' => $options,
|
340 |
+
'std' => 'enable',
|
341 |
+
'desc' => __('Droid Sans Naskh and Roboto font families will be activated in admin side, if this is enabled', 'wp-parsidate')
|
342 |
+
),
|
343 |
+
'droidsans_editor' => array(
|
344 |
+
'id' => 'droidsans_editor',
|
345 |
+
'name' => __('Use Droid Sans font for editors', 'wp-parsidate'),
|
346 |
+
'type' => 'radio',
|
347 |
+
'options' => $options,
|
348 |
+
'std' => 'enable',
|
349 |
+
'desc' => __('Droid Sans Naskh and Roboto font families will be activated in all rich editors in back end.', 'wp-parsidate')
|
350 |
)
|
351 |
+
)),
|
352 |
+
'plugins' => apply_filters('wpp_plugins_compability_settings', array())
|
353 |
+
));
|
354 |
+
return $settings;
|
355 |
}
|
356 |
|
357 |
/* Form Callbacks Made by EDD Development Team */
|
358 |
+
function wpp_header_callback($args)
|
359 |
+
{
|
360 |
echo '<hr/>';
|
361 |
}
|
362 |
|
363 |
+
function wpp_checkbox_callback($args)
|
364 |
+
{
|
365 |
global $wpp_settings;
|
366 |
|
367 |
$checked = isset($wpp_settings[$args['id']]) ? checked(1, $wpp_settings[$args['id']], false) : '';
|
368 |
$html = '<input type="checkbox" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="1" ' . $checked . '/>';
|
369 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
370 |
|
371 |
echo $html;
|
372 |
}
|
373 |
|
374 |
+
function wpp_multicheck_callback($args)
|
375 |
+
{
|
376 |
+
global $wpp_settings;
|
377 |
|
378 |
+
$html = '';
|
379 |
+
foreach ($args['options'] as $key => $value) {
|
380 |
+
$option_name = $args['id'] . '-' . $key;
|
381 |
+
wpp_checkbox_callback(array(
|
382 |
+
'id' => $option_name,
|
383 |
+
'desc' => $value
|
384 |
+
));
|
385 |
+
echo '<br>';
|
386 |
+
}
|
387 |
|
388 |
+
echo $html;
|
389 |
}
|
390 |
|
391 |
+
function wpp_radio_callback($args)
|
392 |
+
{
|
393 |
global $wpp_settings;
|
394 |
|
395 |
+
foreach ($args['options'] as $key => $option) :
|
396 |
$checked = false;
|
397 |
|
398 |
+
if (isset($wpp_settings[$args['id']]) && $wpp_settings[$args['id']] == $key)
|
399 |
$checked = true;
|
400 |
+
elseif (isset($args['std']) && $args['std'] == $key && !isset($wpp_settings[$args['id']]))
|
401 |
$checked = true;
|
402 |
|
403 |
echo '<input name="wpp_settings[' . $args['id'] . ']"" id="wpp_settings[' . $args['id'] . '][' . $key . ']" type="radio" value="' . $key . '" ' . checked(true, $checked, false) . '/>';
|
407 |
echo '<p class="description">' . $args['desc'] . '</p>';
|
408 |
}
|
409 |
|
410 |
+
function wpp_text_callback($args)
|
411 |
+
{
|
412 |
global $wpp_settings;
|
413 |
|
414 |
+
if (isset($wpp_settings[$args['id']]))
|
415 |
+
$value = $wpp_settings[$args['id']];
|
416 |
else
|
417 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
418 |
|
419 |
+
$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
|
420 |
+
$html = '<input type="text" class="' . $size . '-text" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
|
421 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
422 |
|
423 |
echo $html;
|
424 |
}
|
425 |
|
426 |
+
function wpp_number_callback($args)
|
427 |
+
{
|
428 |
global $wpp_settings;
|
429 |
|
430 |
+
if (isset($wpp_settings[$args['id']]))
|
431 |
+
$value = $wpp_settings[$args['id']];
|
432 |
else
|
433 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
434 |
|
435 |
+
$max = isset($args['max']) ? $args['max'] : 999999;
|
436 |
+
$min = isset($args['min']) ? $args['min'] : 0;
|
437 |
+
$step = isset($args['step']) ? $args['step'] : 1;
|
438 |
|
439 |
+
$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
|
440 |
+
$html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . $size . '-text" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
|
441 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
442 |
|
443 |
echo $html;
|
444 |
}
|
445 |
|
446 |
+
function wpp_textarea_callback($args)
|
447 |
+
{
|
448 |
global $wpp_settings;
|
449 |
|
450 |
+
if (isset($wpp_settings[$args['id']]))
|
451 |
+
$value = $wpp_settings[$args['id']];
|
452 |
else
|
453 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
454 |
|
455 |
+
$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
|
456 |
+
$html = '<textarea class="large-text" cols="50" rows="5" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
|
457 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
458 |
|
459 |
echo $html;
|
460 |
}
|
461 |
|
462 |
+
function wpp_password_callback($args)
|
463 |
+
{
|
464 |
global $wpp_settings;
|
465 |
|
466 |
+
if (isset($wpp_settings[$args['id']]))
|
467 |
+
$value = $wpp_settings[$args['id']];
|
468 |
else
|
469 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
470 |
|
471 |
+
$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
|
472 |
+
$html = '<input type="password" class="' . $size . '-text" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr($value) . '"/>';
|
473 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
474 |
|
475 |
echo $html;
|
476 |
}
|
477 |
|
478 |
+
function wpp_missing_callback($args)
|
479 |
+
{
|
480 |
echo '–';
|
481 |
return false;
|
482 |
}
|
483 |
|
484 |
|
485 |
+
function wpp_select_callback($args)
|
486 |
+
{
|
487 |
global $wpp_settings;
|
488 |
|
489 |
+
if (isset($wpp_settings[$args['id']]))
|
490 |
+
$value = $wpp_settings[$args['id']];
|
491 |
else
|
492 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
493 |
|
494 |
$html = '<select id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']"/>';
|
495 |
|
496 |
+
foreach ($args['options'] as $option => $name) :
|
497 |
+
$selected = selected($option, $value, false);
|
498 |
$html .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
|
499 |
endforeach;
|
500 |
|
501 |
$html .= '</select>';
|
502 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
503 |
|
504 |
echo $html;
|
505 |
}
|
506 |
|
507 |
+
function wpp_color_select_callback($args)
|
508 |
+
{
|
509 |
global $wpp_settings;
|
510 |
|
511 |
+
if (isset($wpp_settings[$args['id']]))
|
512 |
+
$value = $wpp_settings[$args['id']];
|
513 |
else
|
514 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
515 |
|
516 |
$html = '<select id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']"/>';
|
517 |
|
518 |
+
foreach ($args['options'] as $option => $color) :
|
519 |
+
$selected = selected($option, $value, false);
|
520 |
$html .= '<option value="' . $option . '" ' . $selected . '>' . $color['label'] . '</option>';
|
521 |
endforeach;
|
522 |
|
523 |
$html .= '</select>';
|
524 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
525 |
|
526 |
echo $html;
|
527 |
}
|
528 |
|
529 |
+
function wpp_rich_editor_callback($args)
|
530 |
+
{
|
531 |
global $wpp_settings, $wp_version;
|
532 |
|
533 |
+
if (isset($wpp_settings[$args['id']]))
|
534 |
+
$value = $wpp_settings[$args['id']];
|
535 |
else
|
536 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
537 |
|
538 |
+
if ($wp_version >= 3.3 && function_exists('wp_editor')) {
|
539 |
+
$html = wp_editor(stripslashes($value), 'wpp_settings[' . $args['id'] . ']', array('textarea_name' => 'wpp_settings[' . $args['id'] . ']'));
|
540 |
} else {
|
541 |
+
$html = '<textarea class="large-text" rows="10" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
|
542 |
}
|
543 |
|
544 |
+
$html .= '<br/><label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
545 |
|
546 |
echo $html;
|
547 |
}
|
548 |
|
549 |
+
function wpp_upload_callback($args)
|
550 |
+
{
|
551 |
global $wpp_settings;
|
552 |
|
553 |
+
if (isset($wpp_settings[$args['id']]))
|
554 |
$value = $wpp_settings[$args['id']];
|
555 |
else
|
556 |
$value = isset($args['std']) ? $args['std'] : '';
|
557 |
|
558 |
+
$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
|
559 |
+
$html = '<input type="text" class="' . $size . '-text wpp_upload_field" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
|
560 |
+
$html .= '<span> <input type="button" class="wpp_settings_upload_button button-secondary" value="' . __('Upload File', 'wpp') . '"/></span>';
|
561 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
562 |
|
563 |
echo $html;
|
564 |
}
|
565 |
|
566 |
+
function wpp_color_callback($args)
|
567 |
+
{
|
568 |
global $wpp_settings;
|
569 |
|
570 |
+
if (isset($wpp_settings[$args['id']]))
|
571 |
+
$value = $wpp_settings[$args['id']];
|
572 |
else
|
573 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
574 |
|
575 |
+
$default = isset($args['std']) ? $args['std'] : '';
|
576 |
|
577 |
+
$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
|
578 |
+
$html = '<input type="text" class="wpp-color-picker" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />';
|
579 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
580 |
|
581 |
echo $html;
|
582 |
}
|
583 |
|
584 |
+
function wpp_render_settings()
|
585 |
+
{
|
586 |
global $wpp_settings;
|
587 |
+
$active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], wpp_get_tabs()) ? $_GET['tab'] : 'core';
|
588 |
|
589 |
ob_start();
|
590 |
?>
|
591 |
+
<div class="wrap wpp-settings-wrap">
|
592 |
+
<h2><?php _e('Parsi Settings', 'wp-parsidate') ?></h2>
|
593 |
+
<h2 class="nav-tab-wrapper">
|
594 |
<?php
|
595 |
+
foreach (wpp_get_tabs() as $tab_id => $tab_name) {
|
596 |
|
597 |
+
$tab_url = add_query_arg(array(
|
598 |
'settings-updated' => false,
|
599 |
'tab' => $tab_id
|
600 |
+
));
|
601 |
|
602 |
$active = $active_tab == $tab_id ? ' nav-tab-active' : '';
|
603 |
|
604 |
+
echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
|
605 |
+
echo $tab_name;
|
606 |
echo '</a>';
|
607 |
}
|
608 |
?>
|
609 |
+
</h2>
|
610 |
+
<?php echo settings_errors('wpp-notices'); ?>
|
611 |
+
<div id="tab_container">
|
612 |
+
<form method="post" action="options.php">
|
613 |
+
<table class="form-table">
|
614 |
+
<?php
|
615 |
+
settings_fields('wpp_settings');
|
616 |
+
do_settings_fields('wpp_settings_' . $active_tab, 'wpp_settings_' . $active_tab);
|
617 |
+
?>
|
618 |
+
</table>
|
619 |
<?php submit_button(); ?>
|
620 |
+
</form>
|
621 |
+
</div><!-- #tab_container-->
|
622 |
+
</div><!-- .wrap -->
|
623 |
<?php
|
624 |
echo ob_get_clean();
|
625 |
}
|
includes/widget/widget_archive.php
CHANGED
@@ -30,7 +30,7 @@ class parsidate_archive extends WP_Widget
|
|
30 |
<input style="width: 200px;" id="<?php echo $this->get_field_id('parsidate_archive_title'); ?>" name="<?php echo $this->get_field_name('parsidate_archive_title'); ?>" type="text" value="<?php echo (empty($instance['parsidate_archive_title'])? __('Jalali Date Archives','wp-parsidate') :$instance['parsidate_archive_title']) ?>" />
|
31 |
<br />
|
32 |
<label ><input type="radio" id="parsidate_archive_type1" name="<?php echo $this->get_field_name('parsidate_archive_type'); ?>" value="yearly" <?php checked($type,'yearly'); ?>/><label for="parsidate_archive_type1"><?php _e('Yearly','wp-parsidate') ?></label><br />
|
33 |
-
|
34 |
<label ><input type="radio" id="parsidate_archive_type3" name="<?php echo $this->get_field_name('parsidate_archive_type'); ?>" value="daily" <?php checked($type,'daily'); ?>/><?php _e('Daily','wp-parsidate') ?></label><br />
|
35 |
<br />
|
36 |
<input type="checkbox" name="<?php echo $this->get_field_name('parsidate_archive_count'); ?>" id="<?php echo $this->get_field_id('parsidate_archive_count'); ?>" value="1" <?php checked($instance['parsidate_archive_count'],1,true); ?>/>
|
30 |
<input style="width: 200px;" id="<?php echo $this->get_field_id('parsidate_archive_title'); ?>" name="<?php echo $this->get_field_name('parsidate_archive_title'); ?>" type="text" value="<?php echo (empty($instance['parsidate_archive_title'])? __('Jalali Date Archives','wp-parsidate') :$instance['parsidate_archive_title']) ?>" />
|
31 |
<br />
|
32 |
<label ><input type="radio" id="parsidate_archive_type1" name="<?php echo $this->get_field_name('parsidate_archive_type'); ?>" value="yearly" <?php checked($type,'yearly'); ?>/><label for="parsidate_archive_type1"><?php _e('Yearly','wp-parsidate') ?></label><br />
|
33 |
+
<label ><input type="radio" id="parsidate_archive_type2" name="<?php echo $this->get_field_name('parsidate_archive_type'); ?>" value="monthly" <?php checked($type,'monthly'); ?>/><?php _e('Monthly','wp-parsidate') ?></label><br />
|
34 |
<label ><input type="radio" id="parsidate_archive_type3" name="<?php echo $this->get_field_name('parsidate_archive_type'); ?>" value="daily" <?php checked($type,'daily'); ?>/><?php _e('Daily','wp-parsidate') ?></label><br />
|
35 |
<br />
|
36 |
<input type="checkbox" name="<?php echo $this->get_field_name('parsidate_archive_count'); ?>" id="<?php echo $this->get_field_id('parsidate_archive_count'); ?>" value="1" <?php checked($instance['parsidate_archive_count'],1,true); ?>/>
|
includes/widget/widget_calendar.php
CHANGED
@@ -1,44 +1,45 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* @author lord_viper
|
4 |
* @copyright 2013
|
5 |
*/
|
6 |
-
|
7 |
class parsidate_calendar extends WP_Widget
|
8 |
{
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
<p style="text-align:right; direction:rtl">
|
22 |
-
|
23 |
-
|
24 |
</p>
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
public function update($new_instance, $old_instance )
|
29 |
-
{
|
30 |
-
$instance = $old_instance;
|
31 |
-
$instance['parsidate_calendar_title'] = strip_tags($new_instance['parsidate_calendar_title']);
|
32 |
-
return $instance;
|
33 |
-
}
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
|
|
44 |
?>
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* @author lord_viper
|
5 |
* @copyright 2013
|
6 |
*/
|
|
|
7 |
class parsidate_calendar extends WP_Widget
|
8 |
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
global $wp_version;
|
12 |
+
if (version_compare($wp_version, '4.3', '>='))
|
13 |
+
parent::__construct(false, __('Jalali Date Calender', 'wp-parsidate'), 'description=' . __('Jalali Date Calender', 'wp-parsidate'));
|
14 |
+
else
|
15 |
+
parent::WP_Widget(false, __('Jalali Date Calender', 'wp-parsidate'), 'description=' . __('Jalali Date Calender', 'wp-parsidate'));
|
16 |
+
}
|
17 |
+
|
18 |
+
public function form($instance)
|
19 |
+
{
|
20 |
+
?>
|
21 |
<p style="text-align:right; direction:rtl">
|
22 |
+
<label><?php _e('Title:', 'wp-parsidate') ?></label>
|
23 |
+
<input style="width: 200px;" id="<?php echo $this->get_field_id('parsidate_calendar_title'); ?>" name="<?php echo $this->get_field_name('parsidate_calendar_title'); ?>" type="text" value="<?php echo(empty($instance['parsidate_calendar_title']) ? __('Jalali Date Calender', 'wp-parsidate') : $instance['parsidate_calendar_title']) ?>"/>
|
24 |
</p>
|
25 |
+
<?php
|
26 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
+
public function update($new_instance, $old_instance)
|
29 |
+
{
|
30 |
+
$instance = $old_instance;
|
31 |
+
$instance['parsidate_calendar_title'] = strip_tags($new_instance['parsidate_calendar_title']);
|
32 |
+
return $instance;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function widget($args, $instance)
|
36 |
+
{
|
37 |
+
extract($args);
|
38 |
+
$title = (empty($instance['parsidate_calendar_title'])) ? '' : $instance['parsidate_calendar_title'];
|
39 |
+
echo "$before_widget\n$before_title $title $after_title";
|
40 |
+
wpp_get_calendar();
|
41 |
+
echo $after_widget;
|
42 |
+
}
|
43 |
}
|
44 |
+
|
45 |
?>
|
readme.txt
CHANGED
@@ -41,6 +41,9 @@ List of some features:
|
|
41 |
4. 'Jalali Date Calender' in action
|
42 |
|
43 |
== Changelog ==
|
|
|
|
|
|
|
44 |
= 2.2.2 =
|
45 |
* Fix error in PHP 7
|
46 |
|
41 |
4. 'Jalali Date Calender' in action
|
42 |
|
43 |
== Changelog ==
|
44 |
+
= 2.2.3 =
|
45 |
+
* Conflict timezone with wordpress default timezone [#issue](https://github.com/wordpress-parsi/wp-parsidate/issues/1)
|
46 |
+
|
47 |
= 2.2.2 =
|
48 |
* Fix error in PHP 7
|
49 |
|
wp-parsidate.php
CHANGED
@@ -1,174 +1,176 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Plugin Name: WP-Parsidate
|
4 |
-
* Version: 2.2.
|
5 |
-
* Plugin URI: http://forum.wp-parsi.com/
|
6 |
-
* Description: Persian package for WordPress, Adds full RTL and Shamsi (Jalali) support for: posts, comments, pages, archives, search, categories, permalinks and all admin sections and TinyMce editor, lists, quick editor. This package has Jalali archive widget.
|
7 |
-
* Author: WP-Parsi Team
|
8 |
-
* Author URI: http://wp-parsi.com/
|
9 |
-
* Text Domain: wp-parsidate
|
10 |
-
* Domain Path: parsi-languages
|
11 |
-
*
|
12 |
-
* WordPress Parsi Package, Adds Persian language & Jalali date support to your blog
|
13 |
-
*
|
14 |
-
* Developers:
|
15 |
-
* Mobin Ghasempoor ( Senior programmer & Founder )
|
16 |
-
* Morteza Geransayeh ( Senior programmer & Manager )
|
17 |
-
* Ehsaan ( Programmer )
|
18 |
-
* Farhan Nisi ( Programmer )
|
19 |
-
*
|
20 |
-
*
|
21 |
-
*
|
22 |
-
* @author Mobin Ghasempoor
|
23 |
-
* @author Morteza Geransayeh
|
24 |
-
* @author Farhan Nisi
|
25 |
-
* @author Ehsaan
|
26 |
-
* @link http://wp-parsi.com/
|
27 |
-
* @version 2.2
|
28 |
-
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License v2.0
|
29 |
-
* @package WP-Parsidate
|
30 |
-
* @subpackage Core
|
31 |
-
*/
|
32 |
-
|
33 |
-
|
34 |
-
if (
|
35 |
-
|
36 |
-
final class WP_Parsidate
|
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 |
-
'fixes-
|
115 |
-
'fixes-
|
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 |
-
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: WP-Parsidate
|
4 |
+
* Version: 2.2.3
|
5 |
+
* Plugin URI: http://forum.wp-parsi.com/
|
6 |
+
* Description: Persian package for WordPress, Adds full RTL and Shamsi (Jalali) support for: posts, comments, pages, archives, search, categories, permalinks and all admin sections and TinyMce editor, lists, quick editor. This package has Jalali archive widget.
|
7 |
+
* Author: WP-Parsi Team
|
8 |
+
* Author URI: http://wp-parsi.com/
|
9 |
+
* Text Domain: wp-parsidate
|
10 |
+
* Domain Path: parsi-languages
|
11 |
+
*
|
12 |
+
* WordPress Parsi Package, Adds Persian language & Jalali date support to your blog
|
13 |
+
*
|
14 |
+
* Developers:
|
15 |
+
* Mobin Ghasempoor ( Senior programmer & Founder )
|
16 |
+
* Morteza Geransayeh ( Senior programmer & Manager )
|
17 |
+
* Ehsaan ( Programmer )
|
18 |
+
* Farhan Nisi ( Programmer )
|
19 |
+
* Parsa Kafi ( Programmer )
|
20 |
+
* Saeed Fard ( Analyst )
|
21 |
+
*
|
22 |
+
* @author Mobin Ghasempoor
|
23 |
+
* @author Morteza Geransayeh
|
24 |
+
* @author Farhan Nisi
|
25 |
+
* @author Ehsaan
|
26 |
+
* @link http://wp-parsi.com/
|
27 |
+
* @version 2.2
|
28 |
+
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License v2.0
|
29 |
+
* @package WP-Parsidate
|
30 |
+
* @subpackage Core
|
31 |
+
*/
|
32 |
+
|
33 |
+
|
34 |
+
if (!defined('ABSPATH')) exit; // No direct access allowed
|
35 |
+
|
36 |
+
final class WP_Parsidate
|
37 |
+
{
|
38 |
+
/**
|
39 |
+
* @var WP_Parsidate Class instance
|
40 |
+
*/
|
41 |
+
public static $instance = null;
|
42 |
+
|
43 |
+
private function __construct()
|
44 |
+
{
|
45 |
+
$this->consts();
|
46 |
+
$this->setup_vars();
|
47 |
+
$this->include_files();
|
48 |
+
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'parsi_settings_link'));
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Sets up constants for plugin
|
53 |
+
*
|
54 |
+
* @since 2.0
|
55 |
+
* @return void
|
56 |
+
*/
|
57 |
+
private function consts()
|
58 |
+
{
|
59 |
+
if (!defined('WP_PARSI_ROOT'))
|
60 |
+
define('WP_PARSI_ROOT', __FILE__);
|
61 |
+
|
62 |
+
if (!defined('WP_PARSI_DIR'))
|
63 |
+
define('WP_PARSI_DIR', plugin_dir_path(WP_PARSI_ROOT));
|
64 |
+
|
65 |
+
if (!defined('WP_PARSI_URL'))
|
66 |
+
define('WP_PARSI_URL', plugin_dir_url(WP_PARSI_ROOT));
|
67 |
+
|
68 |
+
if (!defined('WP_PARSI_VER'))
|
69 |
+
define('WP_PARSI_VER', '2.2');
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Sets up global variables
|
74 |
+
*
|
75 |
+
* @since 2.0
|
76 |
+
* @return void
|
77 |
+
*/
|
78 |
+
private function setup_vars()
|
79 |
+
{
|
80 |
+
global $persian_month_names, $timezone;
|
81 |
+
$persian_month_names = array('',
|
82 |
+
'فروردین',
|
83 |
+
'اردیبهشت',
|
84 |
+
'خرداد',
|
85 |
+
'تیر',
|
86 |
+
'مرداد',
|
87 |
+
'شهریور',
|
88 |
+
'مهر',
|
89 |
+
'آبان',
|
90 |
+
'آذر',
|
91 |
+
'دی',
|
92 |
+
'بهمن',
|
93 |
+
'اسفند'
|
94 |
+
);
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Includes files for plugin
|
99 |
+
*
|
100 |
+
* @since 2.0
|
101 |
+
* @return void
|
102 |
+
*/
|
103 |
+
public function include_files()
|
104 |
+
{
|
105 |
+
require_once(WP_PARSI_DIR . 'includes/settings.php');
|
106 |
+
global $wpp_settings;
|
107 |
+
$wpp_settings = wp_parsi_get_settings();
|
108 |
+
|
109 |
+
$files = array(
|
110 |
+
'parsidate',
|
111 |
+
'general',
|
112 |
+
'fixes-archive',
|
113 |
+
'fixes-permalinks',
|
114 |
+
'fixes-dates',
|
115 |
+
'fixes-misc',
|
116 |
+
'admin/styles-fix',
|
117 |
+
'admin/lists-fix',
|
118 |
+
'admin/other-fix',
|
119 |
+
'fixes-calendar',
|
120 |
+
'fixes-archives',
|
121 |
+
'plugins/woocommerce',
|
122 |
+
'plugins/edd',
|
123 |
+
'widget/widget_archive',
|
124 |
+
'widget/widget_calendar'
|
125 |
+
);
|
126 |
+
|
127 |
+
foreach ($files as $file)
|
128 |
+
require_once(WP_PARSI_DIR . 'includes/' . $file . '.php');
|
129 |
+
|
130 |
+
if (get_locale() == 'fa_IR')
|
131 |
+
load_textdomain('wp-parsidate', WP_PARSI_DIR . 'parsi-languages/fa_IR.mo');
|
132 |
+
|
133 |
+
add_action('widgets_init', array($this, 'register_widget'));
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Returns an instance of WP_Parsidate class, makes instance if not exists
|
138 |
+
*
|
139 |
+
* @since 2.0
|
140 |
+
* @return WP_Parsidate Instance of WP_Parsidate
|
141 |
+
*/
|
142 |
+
public static function get_instance()
|
143 |
+
{
|
144 |
+
if (self::$instance == null)
|
145 |
+
self::$instance = new WP_Parsidate();
|
146 |
+
|
147 |
+
return self::$instance;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Add Setting Link To Install Plugin
|
152 |
+
*
|
153 |
+
* @param string $links
|
154 |
+
* @return array
|
155 |
+
*/
|
156 |
+
public static function parsi_settings_link($links)
|
157 |
+
{
|
158 |
+
$mylinks = array('<a href="' . menu_page_url('wp-parsi-settings', FALSE) . '">' . __('settings', 'wp-parsidate') . '</a>');
|
159 |
+
return array_merge($links, $mylinks);
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Register Plugin Widgets
|
164 |
+
*
|
165 |
+
* @since 2.0
|
166 |
+
* @return boolean
|
167 |
+
*/
|
168 |
+
public function register_widget()
|
169 |
+
{
|
170 |
+
register_widget('parsidate_archive');
|
171 |
+
register_widget('parsidate_calendar');
|
172 |
+
return true;
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
return WP_Parsidate::get_instance();
|