Version Description
- Now we support WordPress 5.3!
- Replace/add wp_date instead old function
- Small fix in Woocommerce dates
- Fix date in media files
- All core codes cleaned and beautified
Download this release
Release Info
Developer | man4toman |
Plugin | Parsi Date |
Version | 3.0.2 |
Comparing to | |
See all releases |
Code changes from version 3.0.1 to 3.0.2
- includes/admin/datepicker-rtl.php +13 -10
- includes/admin/gutenberg-jalali-calendar.php +32 -31
- includes/admin/lists-fix.php +53 -49
- includes/admin/styles-fix.php +5 -5
- includes/admin/widgets.php +20 -16
- includes/fixes-archive.php +23 -22
- includes/fixes-archives.php +118 -153
- includes/fixes-calendar.php +203 -202
- includes/fixes-dates.php +67 -27
- includes/fixes-permalinks.php +30 -33
- includes/general.php +11 -11
- includes/install.php +2 -2
- includes/parsidate.php +370 -357
- includes/plugins/disable.php +135 -128
- includes/plugins/edd.php +72 -67
- includes/plugins/fixes-woo.php +18 -16
- includes/plugins/woocommerce.php +56 -52
- includes/settings.php +466 -445
- includes/widget/widget_archive.php +77 -72
- includes/widget/widget_calendar.php +44 -41
- readme.txt +12 -5
- wp-parsidate.php +156 -150
includes/admin/datepicker-rtl.php
CHANGED
@@ -10,19 +10,22 @@
|
|
10 |
/**
|
11 |
* Fixes jQuery Datepicker RTL style and code
|
12 |
*
|
13 |
-
* @since 3.0
|
14 |
* @return void
|
|
|
15 |
*/
|
16 |
|
17 |
-
function wpp_enqueue_datepicker_css()
|
18 |
-
|
|
|
19 |
}
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
25 |
}
|
26 |
|
27 |
-
add_action(
|
28 |
-
add_action(
|
10 |
/**
|
11 |
* Fixes jQuery Datepicker RTL style and code
|
12 |
*
|
|
|
13 |
* @return void
|
14 |
+
* @since 3.0
|
15 |
*/
|
16 |
|
17 |
+
function wpp_enqueue_datepicker_css()
|
18 |
+
{
|
19 |
+
wp_enqueue_style('wp-parsi-datepicker', WP_PARSI_URL . 'assets/css/jquery-ui.css', false, WP_PARSI_VER, 'all');
|
20 |
}
|
21 |
+
|
22 |
+
function wpp_enqueue_datepicker_scripts()
|
23 |
+
{
|
24 |
+
wp_register_script('wpp_ui_datepicker', WP_PARSI_URL . 'assets/js/jquery-ui.js', false, WP_PARSI_VER);
|
25 |
+
wp_register_script('wpp_datepicker_fa', WP_PARSI_URL . 'assets/js/datepicker.js', false, WP_PARSI_VER);
|
26 |
+
wp_enqueue_script('wpp_ui_datepicker');
|
27 |
+
wp_enqueue_script('wpp_datepicker_fa');
|
28 |
}
|
29 |
|
30 |
+
add_action('admin_enqueue_scripts', 'wpp_enqueue_datepicker_css');
|
31 |
+
add_action('admin_enqueue_scripts', 'wpp_enqueue_datepicker_scripts', 9999);
|
includes/admin/gutenberg-jalali-calendar.php
CHANGED
@@ -11,8 +11,8 @@
|
|
11 |
*/
|
12 |
|
13 |
// Exit if accessed directly.
|
14 |
-
if (
|
15 |
-
|
16 |
}
|
17 |
|
18 |
/**
|
@@ -29,37 +29,38 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
29 |
* @uses {wp-date}
|
30 |
* @since 3.0.0
|
31 |
*/
|
32 |
-
if (
|
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 |
// Hook: Editor assets.
|
62 |
-
$wpp_options = get_option(
|
63 |
-
if (
|
64 |
-
|
65 |
}
|
11 |
*/
|
12 |
|
13 |
// Exit if accessed directly.
|
14 |
+
if (!defined('ABSPATH')) {
|
15 |
+
exit;
|
16 |
}
|
17 |
|
18 |
/**
|
29 |
* @uses {wp-date}
|
30 |
* @since 3.0.0
|
31 |
*/
|
32 |
+
if (!function_exists('wpp_gutenberg_jalali_calendar_editor_assets')) {
|
33 |
+
function wpp_gutenberg_jalali_calendar_editor_assets()
|
34 |
+
{
|
35 |
+
// Scripts.
|
36 |
+
wp_enqueue_script(
|
37 |
+
'wpp_gutenberg_jalali_calendar_editor_scripts',
|
38 |
+
WP_PARSI_URL . 'assets/js/gutenberg-jalali-calendar.build.js',
|
39 |
+
array(
|
40 |
+
'wp-plugins',
|
41 |
+
'wp-i18n',
|
42 |
+
'wp-compose',
|
43 |
+
'wp-components',
|
44 |
+
'wp-element',
|
45 |
+
'wp-editor',
|
46 |
+
'wp-edit-post',
|
47 |
+
'wp-data',
|
48 |
+
'wp-date'
|
49 |
+
),
|
50 |
+
true
|
51 |
+
);
|
52 |
|
53 |
+
// Styles.
|
54 |
+
wp_enqueue_style(
|
55 |
+
'wpp_gutenberg_jalali_calendar_editor_styles',
|
56 |
+
WP_PARSI_URL . 'assets/css/gutenberg-jalali-calendar.build.css',
|
57 |
+
array('wp-edit-blocks')
|
58 |
+
);
|
59 |
+
}
|
60 |
}
|
61 |
|
62 |
// Hook: Editor assets.
|
63 |
+
$wpp_options = get_option('wpp_settings');
|
64 |
+
if (version_compare(get_bloginfo('version'), '5.0.0', '>=') && $wpp_options['persian_date'] === 'enable') {
|
65 |
+
add_action('enqueue_block_editor_assets', 'wpp_gutenberg_jalali_calendar_editor_assets');
|
66 |
}
|
includes/admin/lists-fix.php
CHANGED
@@ -10,88 +10,92 @@
|
|
10 |
/**
|
11 |
* Enqueues admin scripts
|
12 |
*
|
13 |
-
* @author Ehsaan
|
14 |
* @return void
|
|
|
15 |
*/
|
16 |
-
function wpp_enqueue_admin_scripts()
|
17 |
-
|
18 |
-
|
|
|
19 |
}
|
20 |
|
21 |
-
add_action(
|
22 |
|
23 |
/**
|
24 |
* Hooks admin functions for restrict posts in edit pages
|
25 |
*
|
26 |
* @return void
|
27 |
*/
|
28 |
-
function wpp_backend_init()
|
29 |
-
|
30 |
-
|
|
|
31 |
}
|
32 |
|
33 |
-
add_action(
|
34 |
|
35 |
/**
|
36 |
* Limits posts to a certain date, if date setted
|
37 |
*
|
38 |
-
* @param
|
39 |
*
|
40 |
* @return string New Pointer
|
41 |
*/
|
42 |
-
function wpp_admin_posts_where(
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
48 |
|
49 |
-
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
* Restrict posts to given date
|
54 |
-
* @author Mobin Ghasempoor
|
55 |
-
* @author Parsa Kafi
|
56 |
* @return void
|
|
|
|
|
57 |
*/
|
58 |
-
function wpp_restrict_posts()
|
59 |
-
|
|
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
|
70 |
-
|
71 |
FROM $wpdb->posts
|
72 |
WHERE post_type='$post_type' {$post_status_w} AND date( post_date ) <> '0000-00-00'
|
73 |
ORDER BY post_date";
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
|
79 |
-
|
80 |
-
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
}
|
10 |
/**
|
11 |
* Enqueues admin scripts
|
12 |
*
|
|
|
13 |
* @return void
|
14 |
+
* @author Ehsaan
|
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
|
39 |
*
|
40 |
+
* @param string $where Query pointer
|
41 |
*
|
42 |
* @return string New Pointer
|
43 |
*/
|
44 |
+
function wpp_admin_posts_where($where)
|
45 |
+
{
|
46 |
+
global $wp_query;
|
47 |
+
if (isset($_GET['mfa']) && $_GET['mfa'] != '0') {
|
48 |
+
$wp_query->query_vars['m'] = $_GET['mfa'];
|
49 |
+
$where = wpp_posts_where($where, $wp_query);
|
50 |
+
}
|
51 |
|
52 |
+
return $where;
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
* Restrict posts to given date
|
|
|
|
|
57 |
* @return void
|
58 |
+
* @author Parsa Kafi
|
59 |
+
* @author Mobin Ghasempoor
|
60 |
*/
|
61 |
+
function wpp_restrict_posts()
|
62 |
+
{
|
63 |
+
global $post_type, $post_status, $wpdb, $persian_month_names;
|
64 |
|
65 |
+
$post_status_w = "AND post_status <> 'auto-draft'";
|
66 |
+
if ($post_status != "") {
|
67 |
+
if (is_string($post_status)) {
|
68 |
+
$post_status_w .= " AND post_status = '$post_status'";
|
69 |
+
}
|
70 |
+
} else {
|
71 |
+
$post_status_w .= " AND post_status <> 'trash'";
|
72 |
+
}
|
73 |
|
74 |
+
$sql = "SELECT DISTINCT date( post_date ) AS date
|
75 |
FROM $wpdb->posts
|
76 |
WHERE post_type='$post_type' {$post_status_w} AND date( post_date ) <> '0000-00-00'
|
77 |
ORDER BY post_date";
|
78 |
+
$list = $wpdb->get_col($sql);
|
79 |
+
if (empty($list)) {
|
80 |
+
return;
|
81 |
+
}
|
82 |
|
83 |
+
$m = isset($_GET['mfa']) ? (int)$_GET['mfa'] : 0;
|
84 |
+
$predate = '';
|
85 |
|
86 |
+
echo '<select name="mfa">';
|
87 |
+
echo '<option ' . selected($m, 0, false) . ' value="0">' . __('Show All Dates', 'wp-parsidate') . '</option>' . PHP_EOL;
|
88 |
+
foreach ($list as $date) {
|
89 |
+
$date = parsidate('Ym', $date, 'eng');
|
90 |
+
$year = substr($date, 0, 4);
|
91 |
+
$month = substr($date, 4, 2);
|
92 |
+
$month = $persian_month_names[intval($month)];
|
93 |
|
94 |
+
if ($predate != $date) {
|
95 |
+
echo sprintf('<option %s value="%s">%s</option>', selected($m, $date, false), $date, $month . ' ' . fixnumber($year));
|
96 |
+
}
|
97 |
|
98 |
+
$predate = $date;
|
99 |
+
}
|
100 |
+
echo '</select>';
|
101 |
}
|
includes/admin/styles-fix.php
CHANGED
@@ -10,12 +10,12 @@
|
|
10 |
/**
|
11 |
* Fixes themes and plugins RTL style, they should be LTR
|
12 |
*
|
13 |
-
* @since 2.0
|
14 |
* @return void
|
|
|
15 |
*/
|
16 |
function wpp_fix_editor_rtl()
|
17 |
{
|
18 |
-
|
19 |
}
|
20 |
|
21 |
add_action('admin_print_styles-plugin-editor.php', 'wpp_fix_editor_rtl', 10);
|
@@ -24,14 +24,14 @@ add_action('admin_print_styles-theme-editor.php', 'wpp_fix_editor_rtl', 10);
|
|
24 |
/**
|
25 |
* Fixes TinyMCE font
|
26 |
*
|
27 |
-
* @since 2.0
|
28 |
* @return void
|
|
|
29 |
*/
|
30 |
function wpp_fix_tinymce_font()
|
31 |
{
|
32 |
-
|
33 |
|
34 |
-
|
35 |
}
|
36 |
|
37 |
add_filter('init', 'wpp_fix_tinymce_font', 9);
|
10 |
/**
|
11 |
* Fixes themes and plugins RTL style, they should be LTR
|
12 |
*
|
|
|
13 |
* @return void
|
14 |
+
* @since 2.0
|
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);
|
24 |
/**
|
25 |
* Fixes TinyMCE font
|
26 |
*
|
|
|
27 |
* @return void
|
28 |
+
* @since 2.0
|
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 |
}
|
36 |
|
37 |
add_filter('init', 'wpp_fix_tinymce_font', 9);
|
includes/admin/widgets.php
CHANGED
@@ -7,47 +7,51 @@
|
|
7 |
* @subpackage Core/General
|
8 |
*/
|
9 |
|
10 |
-
add_filter(
|
11 |
-
add_filter(
|
12 |
-
add_filter(
|
13 |
-
add_filter(
|
14 |
|
15 |
/**
|
16 |
* Widget primary link
|
17 |
*
|
18 |
-
* @author Morteza Geransayeh
|
19 |
* @return string
|
|
|
20 |
*/
|
21 |
-
function wpp_dashboard_primary_link()
|
22 |
-
|
|
|
23 |
}
|
24 |
|
25 |
/**
|
26 |
* Widget primary feed
|
27 |
*
|
28 |
-
* @author Morteza Geransayeh
|
29 |
* @return string
|
|
|
30 |
*/
|
31 |
-
function wpp_dashboard_primary_feed()
|
32 |
-
|
|
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
* Widget secondary link
|
37 |
*
|
38 |
-
* @author Morteza Geransayeh
|
39 |
* @return string
|
|
|
40 |
*/
|
41 |
-
function wpp_dashboard_secondary_link()
|
42 |
-
|
|
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
* Widget secondary feed
|
47 |
*
|
48 |
-
* @author Morteza Geransayeh
|
49 |
* @return string
|
|
|
50 |
*/
|
51 |
-
function wpp_dashboard_secondary_feed()
|
52 |
-
|
|
|
53 |
}
|
7 |
* @subpackage Core/General
|
8 |
*/
|
9 |
|
10 |
+
add_filter('dashboard_primary_link', 'wpp_dashboard_primary_link', 999, 1);
|
11 |
+
add_filter('dashboard_primary_feed', 'wpp_dashboard_primary_feed', 999, 1);
|
12 |
+
add_filter('dashboard_secondary_link', 'wpp_dashboard_secondary_link', 999, 1);
|
13 |
+
add_filter('dashboard_secondary_feed', 'wpp_dashboard_secondary_feed', 999, 1);
|
14 |
|
15 |
/**
|
16 |
* Widget primary link
|
17 |
*
|
|
|
18 |
* @return string
|
19 |
+
* @author Morteza Geransayeh
|
20 |
*/
|
21 |
+
function wpp_dashboard_primary_link()
|
22 |
+
{
|
23 |
+
return 'https://wp-parsi.com/';
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
* Widget primary feed
|
28 |
*
|
|
|
29 |
* @return string
|
30 |
+
* @author Morteza Geransayeh
|
31 |
*/
|
32 |
+
function wpp_dashboard_primary_feed()
|
33 |
+
{
|
34 |
+
return 'https://wp-parsi.com/feed/';
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
* Widget secondary link
|
39 |
*
|
|
|
40 |
* @return string
|
41 |
+
* @author Morteza Geransayeh
|
42 |
*/
|
43 |
+
function wpp_dashboard_secondary_link()
|
44 |
+
{
|
45 |
+
return 'http://wp-planet.ir/';
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
* Widget secondary feed
|
50 |
*
|
|
|
51 |
* @return string
|
52 |
+
* @author Morteza Geransayeh
|
53 |
*/
|
54 |
+
function wpp_dashboard_secondary_feed()
|
55 |
+
{
|
56 |
+
return 'http://wp-planet.ir/feed';
|
57 |
}
|
includes/fixes-archive.php
CHANGED
@@ -7,38 +7,39 @@
|
|
7 |
* @author Mobin Ghasempoor
|
8 |
*/
|
9 |
|
10 |
-
add_filter(
|
11 |
-
add_filter(
|
12 |
|
13 |
/**
|
14 |
* Fixes titles for archives
|
15 |
*
|
16 |
-
* @param
|
17 |
-
* @param
|
18 |
-
* @param
|
19 |
*
|
20 |
* @return string New archive title
|
21 |
*/
|
22 |
-
function wpp_fix_title(
|
23 |
-
|
24 |
-
|
|
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
|
43 |
-
|
44 |
}
|
7 |
* @author Mobin Ghasempoor
|
8 |
*/
|
9 |
|
10 |
+
add_filter('wp_title', 'wpp_fix_title', 10000, 2);
|
11 |
+
add_filter('pre_get_document_title', 'wpp_fix_title', 10000); // WP 4.4+
|
12 |
|
13 |
/**
|
14 |
* Fixes titles for archives
|
15 |
*
|
16 |
+
* @param string $title Archive title
|
17 |
+
* @param string $sep Separator
|
18 |
+
* @param string $sep_location Separator location
|
19 |
*
|
20 |
* @return string New archive title
|
21 |
*/
|
22 |
+
function wpp_fix_title($title, $sep = '-', $sep_location = 'right')
|
23 |
+
{
|
24 |
+
global $persian_month_names, $wp_query, $wpp_settings;
|
25 |
+
$query = $wp_query->query;
|
26 |
|
27 |
+
if (!is_archive() || $wpp_settings['persian_date'] == 'disable') {
|
28 |
+
return $title;
|
29 |
+
}
|
30 |
|
31 |
+
if ($sep_location == 'right') {
|
32 |
+
$query = array_reverse($query);
|
33 |
+
}
|
34 |
|
35 |
+
if (isset($query['monthnum'])) {
|
36 |
+
$query['monthnum'] = $persian_month_names[intval($query['monthnum'])];
|
37 |
+
$title = implode(" ", $query) . " $sep " . get_bloginfo("name");
|
38 |
+
}
|
39 |
|
40 |
+
if (isset($wpp_settings['conv_page_title']) && $wpp_settings['conv_page_title'] != 'disable') {
|
41 |
+
$title = fixnumber($title);
|
42 |
+
}
|
43 |
|
44 |
+
return $title;
|
45 |
}
|
includes/fixes-archives.php
CHANGED
@@ -3,171 +3,136 @@
|
|
3 |
/**
|
4 |
* Create Persian Archives
|
5 |
*
|
6 |
-
* @param
|
7 |
*
|
8 |
* @return string
|
9 |
*/
|
10 |
-
function wpp_get_archives(
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
$post_type_object = get_post_type_object( $r['post_type'] );
|
26 |
-
if ( ! is_post_type_viewable( $post_type_object ) ) {
|
27 |
-
return;
|
28 |
-
}
|
29 |
-
$r['post_type'] = $post_type_object->name;
|
30 |
|
31 |
-
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
$c = count( $results );
|
38 |
-
for ( $i = 1; $i < $c; $i ++ ) {
|
39 |
-
$dt = $results[ $i ];
|
40 |
-
$date = parsidate( 'Y', $dt->date, 'eng' );
|
41 |
-
if ( $date === $old_date ) {
|
42 |
-
$count += $dt->count;
|
43 |
-
} else {
|
44 |
-
echo_yarchive( $old_date, $r['format'], $r['before'], $count, $r['show_post_count'],$r );
|
45 |
-
$old_date = $date;
|
46 |
-
$count = $dt->count;
|
47 |
-
}
|
48 |
-
}
|
49 |
-
echo_yarchive( $old_date, $r['format'], $r['before'], $count, $r['show_post_count'],$r );
|
50 |
-
} elseif ( $r['type'] == 'monthly' ) {
|
51 |
-
$old_date = parsidate( 'Ym', $results[0]->date, 'eng' );
|
52 |
-
$count = $results[0]->count;
|
53 |
-
$c = count( $results );
|
54 |
-
for ( $i = 1; $i < $c; $i ++ ) {
|
55 |
-
$dt = $results[ $i ];
|
56 |
-
$date = parsidate( 'Ym', $dt->date, 'eng' );
|
57 |
-
if ( $date == $old_date ) {
|
58 |
-
$count += $dt->count;
|
59 |
-
} else {
|
60 |
-
echo_marchive( $old_date, $r['format'], $r['before'], $count, $r['show_post_count'],$r );
|
61 |
-
$old_date = $date;
|
62 |
-
$count = $dt->count;
|
63 |
-
}
|
64 |
-
}
|
65 |
-
echo_marchive( $old_date, $r['format'], $r['before'], $count, $r['show_post_count'],$r );
|
66 |
-
} elseif ( $r['type'] == 'daily' ) {
|
67 |
-
foreach ( $results as $row ) {
|
68 |
-
$date = parsidate( 'Y,m,d', $row->date, 'eng' );
|
69 |
-
$date = explode( ',', $date );
|
70 |
-
if ( $r['show_post_count'] ) {
|
71 |
-
$count = ' (' . fixnumber( $row->count ) . ')';
|
72 |
-
} else {
|
73 |
-
$count = '';
|
74 |
-
}
|
75 |
-
$text = fixnumber( $date[2] ) . ' ' . $persian_month_names[ intval( $date[1] ) ] . ' ' . fixnumber( $date[0] );
|
76 |
-
echo get_archives_link( get_day_link( $date[0], $date[1], $date[2] ), $text, $r['format'], $r['before'], $count );
|
77 |
-
}
|
78 |
-
}
|
79 |
-
}
|
80 |
}
|
81 |
|
82 |
-
function echo_yarchive(
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
92 |
}
|
93 |
|
94 |
-
function echo_marchive(
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
106 |
|
107 |
-
|
108 |
}
|
109 |
|
110 |
-
function wp_get_parchives(
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
122 |
|
123 |
-
|
|
|
|
|
|
|
|
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
}
|
3 |
/**
|
4 |
* Create Persian Archives
|
5 |
*
|
6 |
+
* @param string $args
|
7 |
*
|
8 |
* @return string
|
9 |
*/
|
10 |
+
function wpp_get_archives($args = '')
|
11 |
+
{
|
12 |
+
global $wpdb, $persian_month_names;
|
13 |
+
$defaults = array(
|
14 |
+
'type' => 'monthly',
|
15 |
+
'limit' => '',
|
16 |
+
'format' => 'html',
|
17 |
+
'before' => '',
|
18 |
+
'after' => '',
|
19 |
+
'show_post_count' => false,
|
20 |
+
'echo' => 1,
|
21 |
+
'order' => 'DESC',
|
22 |
+
'post_type' => 'post'
|
23 |
+
);
|
24 |
+
$r = wp_parse_args($args, $defaults);
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
$post_type_object = get_post_type_object($r['post_type']);
|
27 |
+
if (!is_post_type_viewable($post_type_object)) {
|
28 |
+
return;
|
29 |
+
}
|
30 |
+
$r['post_type'] = $post_type_object->name;
|
31 |
|
32 |
+
$results = $wpdb->get_results("SELECT date( post_date )as date,count(ID)as count FROM $wpdb->posts WHERE post_date < NOW() AND post_type = '{$r['post_type']}' AND post_status = 'publish' group by date ORDER BY post_date DESC");
|
33 |
+
|
34 |
+
if (!empty($results))
|
35 |
+
wpp_print_archive($results, $r);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
|
38 |
+
function echo_yarchive($year, $format, $before, $count, $show_post_count, $r)
|
39 |
+
{
|
40 |
+
if ($show_post_count) {
|
41 |
+
$count = ' (' . fixnumber($count) . ')';
|
42 |
+
} else {
|
43 |
+
$count = '';
|
44 |
+
}
|
45 |
+
$url = get_year_link($year);
|
46 |
+
if ('post' !== $r['post_type'])
|
47 |
+
$url = add_query_arg('post_type', $r['post_type'], $url);
|
48 |
+
echo get_archives_link($url, fixnumber($year), $format, $before, $count);
|
49 |
}
|
50 |
|
51 |
+
function echo_marchive($old_date, $format, $before, $count, $show_post_count, $r)
|
52 |
+
{
|
53 |
+
global $persian_month_names;
|
54 |
+
$year = substr($old_date, 0, 4);
|
55 |
+
$month = substr($old_date, 4, 2);
|
56 |
+
if ($show_post_count) {
|
57 |
+
$count = ' (' . fixnumber($count) . ')';
|
58 |
+
} else {
|
59 |
+
$count = '';
|
60 |
+
}
|
61 |
+
$url = get_month_link($year, $month);
|
62 |
+
if ('post' !== $r['post_type'])
|
63 |
+
$url = add_query_arg('post_type', $r['post_type'], $url);
|
64 |
|
65 |
+
echo get_archives_link($url, $persian_month_names[intval($month)] . ' ' . fixnumber($year), $format, $before, $count);
|
66 |
}
|
67 |
|
68 |
+
function wp_get_parchives($args = '')
|
69 |
+
{
|
70 |
+
global $wpdb, $persian_month_names;
|
71 |
+
$defaults = array(
|
72 |
+
'type' => 'monthly',
|
73 |
+
'limit' => '',
|
74 |
+
'format' => 'html',
|
75 |
+
'before' => '',
|
76 |
+
'after' => '',
|
77 |
+
'show_post_count' => false,
|
78 |
+
'echo' => 1,
|
79 |
+
'order' => 'DESC'
|
80 |
+
);
|
81 |
+
|
82 |
+
$r = wp_parse_args($args, $defaults);
|
83 |
|
84 |
+
$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");
|
85 |
+
|
86 |
+
if (!empty($results))
|
87 |
+
wpp_print_archive($results, $r);
|
88 |
+
}
|
89 |
|
90 |
+
function wpp_print_archive($results, $args)
|
91 |
+
{
|
92 |
+
global $persian_month_names;
|
93 |
+
if ($args['type'] == 'yearly') {
|
94 |
+
$old_date = parsidate('Y', $results[0]->date, 'eng');
|
95 |
+
$count = $results[0]->count;
|
96 |
+
$c = count($results);
|
97 |
+
for ($i = 1; $i < $c; $i++) {
|
98 |
+
$dt = $results[$i];
|
99 |
+
$date = parsidate('Y', $dt->date, 'eng');
|
100 |
+
if ($date === $old_date) {
|
101 |
+
$count += $dt->count;
|
102 |
+
} else {
|
103 |
+
echo_yarchive($old_date, $args['format'], $args['before'], $count, $args['show_post_count']);
|
104 |
+
$old_date = $date;
|
105 |
+
$count = $dt->count;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
echo_yarchive($old_date, $args['format'], $args['before'], $count, $args['show_post_count']);
|
109 |
+
} elseif ($args['type'] == 'monthly') {
|
110 |
+
$old_date = parsidate('Ym', $results[0]->date, 'eng');
|
111 |
+
$count = $results[0]->count;
|
112 |
+
$c = count($results);
|
113 |
+
for ($i = 1; $i < $c; $i++) {
|
114 |
+
$dt = $results[$i];
|
115 |
+
$date = parsidate('Ym', $dt->date, 'eng');
|
116 |
+
if ($date === $old_date) {
|
117 |
+
$count += $dt->count;
|
118 |
+
} else {
|
119 |
+
echo_marchive($old_date, $args['format'], $args['before'], $count, $args['show_post_count']);
|
120 |
+
$old_date = $date;
|
121 |
+
$count = $dt->count;
|
122 |
+
}
|
123 |
+
}
|
124 |
+
echo_marchive($old_date, $args['format'], $args['before'], $count, $args['show_post_count']);
|
125 |
+
} elseif ($args['type'] == 'daily') {
|
126 |
+
foreach ($results as $row) {
|
127 |
+
$date = parsidate('Y,m,d', $row->date, 'eng');
|
128 |
+
$date = explode(',', $date);
|
129 |
+
if ($args['show_post_count']) {
|
130 |
+
$count = ' (' . fixnumber($row->count) . ')';
|
131 |
+
} else {
|
132 |
+
$count = '';
|
133 |
+
}
|
134 |
+
$text = fixnumber($date[2]) . ' ' . $persian_month_names[intval($date[1])] . ' ' . fixnumber($date[0]);
|
135 |
+
echo get_archives_link(get_day_link($date[0], $date[1], $date[2]), $text, $args['format'], $args['before'], $count);
|
136 |
+
}
|
137 |
+
}
|
138 |
}
|
includes/fixes-calendar.php
CHANGED
@@ -3,244 +3,245 @@
|
|
3 |
/**
|
4 |
* Create Persian Calendar
|
5 |
*
|
6 |
-
* @author Mobin Ghasempoor
|
7 |
-
* @author Parsa Kafi
|
8 |
* @return string
|
|
|
|
|
9 |
*/
|
10 |
-
function wpp_get_calendar()
|
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 |
FROM $wpdb->posts
|
89 |
WHERE post_date < '$start'
|
90 |
AND post_type = 'post' AND post_status = 'publish'
|
91 |
ORDER BY post_date DESC
|
92 |
-
LIMIT 1"
|
93 |
-
|
94 |
FROM $wpdb->posts
|
95 |
WHERE post_date >= '$end'
|
96 |
AND post_type = 'post' AND post_status = 'publish'
|
97 |
ORDER BY post_date ASC
|
98 |
-
LIMIT 1"
|
99 |
|
100 |
-
|
101 |
-
<caption>' . $pd->persian_month_names[
|
102 |
<thead>
|
103 |
<tr>';
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
|
113 |
-
|
114 |
</tr>
|
115 |
</thead>
|
116 |
|
117 |
<tfoot>
|
118 |
<tr>';
|
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 |
</tr>
|
151 |
</tfoot>
|
152 |
|
153 |
<tbody>
|
154 |
<tr>';
|
155 |
|
156 |
-
|
157 |
|
158 |
-
|
159 |
FROM $wpdb->posts
|
160 |
WHERE post_date > '$start' AND post_date < '$end'
|
161 |
AND post_type = 'post'
|
162 |
AND post_status = 'publish'";
|
163 |
-
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
|
180 |
-
|
181 |
-
|
182 |
FROM $wpdb->posts WHERE post_date >= '$start'
|
183 |
AND post_date <= '$end'
|
184 |
-
AND post_type = 'post' AND post_status = 'publish'"
|
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 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
}
|
3 |
/**
|
4 |
* Create Persian Calendar
|
5 |
*
|
|
|
|
|
6 |
* @return string
|
7 |
+
* @author Parsa Kafi
|
8 |
+
* @author Mobin Ghasempoor
|
9 |
*/
|
10 |
+
function wpp_get_calendar()
|
11 |
+
{
|
12 |
+
global $wpdb, $m, $monthnum, $year, $day, $posts;
|
13 |
+
$jy = 0;
|
14 |
+
$pd = bn_parsidate::getInstance();
|
15 |
+
$jm = $monthnum;
|
16 |
+
if ($m != '') {
|
17 |
+
$m = preg_replace("/[^0-9]/", "", $m);
|
18 |
+
$jy = substr($m, 0, 4);
|
19 |
+
} elseif ($year !== '') {
|
20 |
+
$jy = $year;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($jy > 1500) {
|
24 |
+
list($jy, $jm, $jd) = $pd->gregorian_to_persian($year, $monthnum, $day);
|
25 |
+
}
|
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 |
+
|
34 |
+
$week_begins = intval(get_option('start_of_week'));
|
35 |
+
$w = isset($_GET['w']) ? intval($_GET['w']) : '';
|
36 |
+
$is_gregorian = false;
|
37 |
+
|
38 |
+
if (!empty($jm) && !empty($jy)) {
|
39 |
+
$thismonth = '' . zeroise(intval($jm), 2);
|
40 |
+
$thisyear = '' . intval($jy);
|
41 |
+
|
42 |
+
} elseif (!empty($w)) {
|
43 |
+
$thisyear = '' . intval(substr($m, 0, 4));
|
44 |
+
$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
|
45 |
+
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
|
46 |
+
|
47 |
+
} elseif (!empty($m)) {
|
48 |
+
$thisyear = '' . intval(substr($m, 0, 4));
|
49 |
+
if (strlen($m) < 6) {
|
50 |
+
$thismonth = '01';
|
51 |
+
} else {
|
52 |
+
$thismonth = '' . zeroise(intval(substr($m, 4, 2)), 2);
|
53 |
+
}
|
54 |
+
|
55 |
+
} else {
|
56 |
+
$is_gregorian = true;
|
57 |
+
$thisyear = gmdate('Y', current_time('timestamp') + get_option('gmt_offset') * 3600);
|
58 |
+
$thismonth = gmdate('m', current_time('timestamp') + get_option('gmt_offset') * 3600);
|
59 |
+
$thisday = gmdate('d', current_time('timestamp') + get_option('gmt_offset') * 3600);
|
60 |
+
}
|
61 |
+
|
62 |
+
//print_r($wp_query->query_vars);
|
63 |
+
|
64 |
+
if ($is_gregorian) {
|
65 |
+
list($jthisyear, $jthismonth, $jthisday) = $pd->gregorian_to_persian($thisyear, $thismonth, $thisday);
|
66 |
+
$unixmonth = $pd->gregorian_date('Y-m-d 00:00:00', "$jthisyear-$jthismonth-01");
|
67 |
+
} else {
|
68 |
+
$gdate = $pd->persian_to_gregorian($thisyear, $thismonth, 1);
|
69 |
+
$unixmonth = mktime(0, 0, 0, $gdate[1], 1, $gdate[0]);
|
70 |
+
$jthisyear = $thisyear;
|
71 |
+
$jthismonth = $thismonth;
|
72 |
+
}
|
73 |
+
|
74 |
+
$jnextmonth = $jthismonth + 1;
|
75 |
+
$jnextyear = $jthisyear;
|
76 |
+
|
77 |
+
|
78 |
+
if ($jnextmonth > 12) {
|
79 |
+
$jnextmonth = 1;
|
80 |
+
$jnextyear++;
|
81 |
+
}
|
82 |
+
|
83 |
+
$start = $pd->gregorian_date('Y-m-d 00:00:00', "$jthisyear-$jthismonth-01");
|
84 |
+
$end = $pd->gregorian_date('Y-m-d 23:59:59', "$jnextyear-$jthismonth-" . $pd->j_days_in_month[$jthismonth - 1]);
|
85 |
+
|
86 |
+
//echo "Start Date: ".$start.", End Date: ".$end."<br>";
|
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 |
+
$next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
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 |
+
$calendar_output = '<table id="wp-calendar" style="direction: rtl" class="widget_calendar">
|
102 |
+
<caption>' . $pd->persian_month_names[(int)$jthismonth] . ' ' . $pd->persian_date('Y', $unixmonth) . '</caption>
|
103 |
<thead>
|
104 |
<tr>';
|
105 |
+
$myweek = array();
|
106 |
+
for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
|
107 |
+
$myweek[] = $pd->persian_day_small[($wdcount + $week_begins) % 7];
|
108 |
+
}
|
109 |
|
110 |
+
foreach ($myweek as $wd) {
|
111 |
+
$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$wd</th>";
|
112 |
+
}
|
113 |
|
114 |
+
$calendar_output .= '
|
115 |
</tr>
|
116 |
</thead>
|
117 |
|
118 |
<tfoot>
|
119 |
<tr>';
|
120 |
|
121 |
+
if ($previous) {
|
122 |
+
$previous_month = $jthismonth - 1;
|
123 |
+
$previous_year = $jthisyear;
|
124 |
+
if ($previous_month == 0) {
|
125 |
+
$previous_month = 12;
|
126 |
+
$previous_year--;
|
127 |
+
}
|
128 |
+
|
129 |
+
$calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link($previous_year, $previous_month) .
|
130 |
+
'">« ' . $pd->persian_month_names[$previous_month] . '</a></td>';
|
131 |
+
} else {
|
132 |
+
$calendar_output .= "\n\t\t" . '<td colspan="3" id="prev" class="pad"> </td>';
|
133 |
+
}
|
134 |
+
|
135 |
+
$calendar_output .= "\n\t\t" . '<td class="pad"> </td>';
|
136 |
+
|
137 |
+
if ($next) {
|
138 |
+
$next_month = $jthismonth + 1;
|
139 |
+
$next_year = $jthisyear;
|
140 |
+
if ($next_month == 13) {
|
141 |
+
$next_month = 1;
|
142 |
+
$next_year++;
|
143 |
+
}
|
144 |
+
$calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link($next_year, $next_month) .
|
145 |
+
'">' . $pd->persian_month_names[$next_month] . ' »</a></td>';
|
146 |
+
} else {
|
147 |
+
$calendar_output .= "\n\t\t" . '<td colspan="3" id="next" class="pad"> </td>';
|
148 |
+
}
|
149 |
+
|
150 |
+
$calendar_output .= '
|
151 |
</tr>
|
152 |
</tfoot>
|
153 |
|
154 |
<tbody>
|
155 |
<tr>';
|
156 |
|
157 |
+
//____________________________________________________________________________________________________________________________________
|
158 |
|
159 |
+
$sql = "SELECT DISTINCT DAYOFMONTH(post_date),MONTH(post_date),YEAR(post_date)
|
160 |
FROM $wpdb->posts
|
161 |
WHERE post_date > '$start' AND post_date < '$end'
|
162 |
AND post_type = 'post'
|
163 |
AND post_status = 'publish'";
|
164 |
+
$dayswithposts = $wpdb->get_results($sql, ARRAY_N);
|
165 |
|
166 |
+
if ($dayswithposts) {
|
167 |
+
foreach ($dayswithposts as $daywith) {
|
168 |
+
$daywithpost[] = $pd->persian_date('j', "$daywith[2]-$daywith[1]-$daywith[0]", 'eng');
|
169 |
+
}
|
170 |
|
171 |
+
} else {
|
172 |
+
$daywithpost = array();
|
173 |
+
}
|
174 |
|
175 |
+
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false) {
|
176 |
+
$ak_title_separator = "\n";
|
177 |
+
} else {
|
178 |
+
$ak_title_separator = ', ';
|
179 |
+
}
|
180 |
|
181 |
+
$ak_titles_for_day = array();
|
182 |
+
$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
|
183 |
FROM $wpdb->posts WHERE post_date >= '$start'
|
184 |
AND post_date <= '$end'
|
185 |
+
AND post_type = 'post' AND post_status = 'publish'");
|
186 |
+
|
187 |
+
if ($ak_post_titles) {
|
188 |
+
foreach ($ak_post_titles as $ak_post_title) {
|
189 |
+
/** This filter is documented in wp-includes/post-template.php */
|
190 |
+
$post_title = esc_attr(apply_filters('the_title', $ak_post_title->post_title, $ak_post_title->ID));
|
191 |
+
$ak_post_title->dom = $pd->persian_date('j', "$ak_post_title->year-$ak_post_title->month-$ak_post_title->dom", 'eng');
|
192 |
+
|
193 |
+
if (empty($ak_titles_for_day['day_' . $ak_post_title->dom])) {
|
194 |
+
$ak_titles_for_day['day_' . $ak_post_title->dom] = '';
|
195 |
+
}
|
196 |
+
if (empty($ak_titles_for_day[$ak_post_title->dom])) // first one
|
197 |
+
{
|
198 |
+
$ak_titles_for_day[$ak_post_title->dom] = $post_title;
|
199 |
+
} else {
|
200 |
+
$ak_titles_for_day[$ak_post_title->dom] .= $ak_title_separator . $post_title;
|
201 |
+
}
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
$pd = bn_parsidate::getInstance();
|
206 |
+
$pad = $pd->persian_date("w", $pd->gregorian_date("Y-m-d", $jthisyear . "-" . $jthismonth . "-01"), "eng");
|
207 |
+
|
208 |
+
if (0 != $pad) {
|
209 |
+
$calendar_output .= "\n\t\t" . '<td colspan="' . $pad . '" class="pad"> </td>';
|
210 |
+
}
|
211 |
+
|
212 |
+
$daysinmonth = intval($pd->persian_date('t', $unixmonth, 'eng'));
|
213 |
+
|
214 |
+
for ($day = 1; $day <= $daysinmonth; ++$day) {
|
215 |
+
list($thiyear, $thismonth, $thisday) = $pd->persian_to_gregorian($jthisyear, $jthismonth, $day);
|
216 |
+
if (isset($newrow) && $newrow) {
|
217 |
+
$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
|
218 |
+
}
|
219 |
+
$newrow = false;
|
220 |
+
|
221 |
+
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))) {
|
222 |
+
$calendar_output .= '<td id="today">';
|
223 |
+
} else {
|
224 |
+
$calendar_output .= '<td>';
|
225 |
+
}
|
226 |
+
|
227 |
+
$p_day = (empty($val['sep_datesnum']) ? $day : per_number($day));
|
228 |
+
|
229 |
+
if (in_array($day, $daywithpost)) // any posts today?
|
230 |
+
{
|
231 |
+
$calendar_output .= '<a href="' . get_day_link($jthisyear, $jthismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$p_day</a>";
|
232 |
+
} else {
|
233 |
+
$calendar_output .= $p_day;
|
234 |
+
}
|
235 |
+
$calendar_output .= '</td>';
|
236 |
+
|
237 |
+
if (6 == calendar_week_mod($pd->gregorian_date('w', "$jthisyear-$jthismonth-$day") - $week_begins)) {
|
238 |
+
$newrow = true;
|
239 |
+
}
|
240 |
+
}
|
241 |
+
$pad = 7 - calendar_week_mod($pd->gregorian_date('w', "$jthisyear-$jthismonth-$day", 'eng') - $week_begins);
|
242 |
+
if ($pad != 0 && $pad != 7) {
|
243 |
+
$calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . $pad . '"> </td>';
|
244 |
+
}
|
245 |
+
|
246 |
+
echo $calendar_output . "\n\t</tr>\n\t</tbody>\n\t</table>";
|
247 |
}
|
includes/fixes-dates.php
CHANGED
@@ -12,18 +12,20 @@ global $wpp_settings;
|
|
12 |
if (get_locale() == 'fa_IR' && $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', '
|
18 |
-
|
19 |
-
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
* Fixes post date and returns in Jalali format
|
24 |
*
|
25 |
-
* @param
|
26 |
-
* @param
|
27 |
*
|
28 |
* @return string Formatted date
|
29 |
*/
|
@@ -40,17 +42,37 @@ function wpp_fix_post_date($time, $format = '')
|
|
40 |
$format = get_option('date_format');
|
41 |
}
|
42 |
|
43 |
-
if(!disable_wpp())
|
44 |
-
|
45 |
|
46 |
return parsidate($format, $post->post_date, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per');
|
47 |
}
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
/**
|
50 |
* Fixes post time and returns in Jalali format
|
51 |
*
|
52 |
-
* @param
|
53 |
-
* @param
|
54 |
*
|
55 |
* @return string Formatted date
|
56 |
*/
|
@@ -65,16 +87,16 @@ function wpp_fix_post_time($time, $format = '')
|
|
65 |
if (empty($format)) {
|
66 |
$format = get_option('time_format');
|
67 |
}
|
68 |
-
if(!disable_wpp())
|
69 |
-
|
70 |
return parsidate($format, $post->post_date, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per');
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
* Fixes comment time and returns in Jalali format
|
75 |
*
|
76 |
-
* @param
|
77 |
-
* @param
|
78 |
*
|
79 |
* @return string Formatted date
|
80 |
*/
|
@@ -89,16 +111,16 @@ function wpp_fix_comment_time($time, $format = '')
|
|
89 |
if (empty($format)) {
|
90 |
$format = get_option('time_format');
|
91 |
}
|
92 |
-
if(!disable_wpp())
|
93 |
-
|
94 |
return parsidate($format, $comment->comment_date, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per');
|
95 |
}
|
96 |
|
97 |
/**
|
98 |
* Fixes comment date and returns in Jalali format
|
99 |
*
|
100 |
-
* @param
|
101 |
-
* @param
|
102 |
*
|
103 |
* @return string Formatted date
|
104 |
*/
|
@@ -113,27 +135,45 @@ function wpp_fix_comment_date($time, $format = '')
|
|
113 |
if (empty($format)) {
|
114 |
$format = get_option('date_format');
|
115 |
}
|
116 |
-
if(!disable_wpp())
|
117 |
-
|
118 |
return parsidate($format, $comment->comment_date, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per');
|
119 |
}
|
120 |
|
121 |
/**
|
122 |
* Fixes i18n date formatting and convert them to Jalali
|
123 |
*
|
124 |
-
* @param
|
125 |
-
* @param
|
126 |
-
* @param
|
|
|
|
|
|
|
127 |
*
|
128 |
* @return string Formatted time
|
129 |
*/
|
130 |
-
function wpp_fix_i18n($
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
{
|
132 |
global $wpp_settings;
|
133 |
-
if(!disable_wpp())
|
134 |
-
return $format_string;
|
135 |
|
136 |
-
|
|
|
|
|
|
|
137 |
}
|
138 |
|
139 |
function array_key_exists_r($needle, $haystack, $value = null)
|
@@ -151,4 +191,4 @@ function array_key_exists_r($needle, $haystack, $value = null)
|
|
151 |
return $result;
|
152 |
}
|
153 |
return $result;
|
154 |
-
}
|
12 |
if (get_locale() == 'fa_IR' && $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_the_time', 'wpp_fix_post_date', 10, 2);
|
16 |
+
add_filter('get_the_date', 'wpp_fix_post_date', 10, 2);
|
17 |
add_filter('get_comment_time', 'wpp_fix_comment_time', 10, 2);
|
18 |
add_filter('get_comment_date', 'wpp_fix_comment_date', 10, 2);
|
19 |
+
add_filter('get_post_modified_time', 'wpp_fix_post_modified_time', 10, 3);
|
20 |
+
add_filter('date_i18n', 'wpp_fix_i18n', 10, 4);
|
21 |
+
add_filter('wp_date', 'wpp_fix_i18n', 10, 4);
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
* Fixes post date and returns in Jalali format
|
26 |
*
|
27 |
+
* @param string $time Post time
|
28 |
+
* @param string $format Date format
|
29 |
*
|
30 |
* @return string Formatted date
|
31 |
*/
|
42 |
$format = get_option('date_format');
|
43 |
}
|
44 |
|
45 |
+
if (!disable_wpp())
|
46 |
+
return date($format, strtotime($post->post_modified));
|
47 |
|
48 |
return parsidate($format, $post->post_date, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per');
|
49 |
}
|
50 |
|
51 |
+
/**
|
52 |
+
* Fixes post date and returns in Jalali format
|
53 |
+
*
|
54 |
+
* @param string $time Post time
|
55 |
+
* @param string $format Date format
|
56 |
+
* @param bool $gmt retrieve the GMT time. Default false.
|
57 |
+
*
|
58 |
+
* @return string Formatted date
|
59 |
+
* @author Parsa Kafi
|
60 |
+
*/
|
61 |
+
function wpp_fix_post_modified_time($time, $format, $gmt)
|
62 |
+
{
|
63 |
+
global $wpp_settings;
|
64 |
+
|
65 |
+
if (!disable_wpp())
|
66 |
+
return $time;
|
67 |
+
|
68 |
+
return parsidate($format, $time, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per');
|
69 |
+
}
|
70 |
+
|
71 |
/**
|
72 |
* Fixes post time and returns in Jalali format
|
73 |
*
|
74 |
+
* @param string $time Post time
|
75 |
+
* @param string $format Date format
|
76 |
*
|
77 |
* @return string Formatted date
|
78 |
*/
|
87 |
if (empty($format)) {
|
88 |
$format = get_option('time_format');
|
89 |
}
|
90 |
+
if (!disable_wpp())
|
91 |
+
return date($format, strtotime($post->post_date));
|
92 |
return parsidate($format, $post->post_date, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per');
|
93 |
}
|
94 |
|
95 |
/**
|
96 |
* Fixes comment time and returns in Jalali format
|
97 |
*
|
98 |
+
* @param string $time Comment time
|
99 |
+
* @param string $format Date format
|
100 |
*
|
101 |
* @return string Formatted date
|
102 |
*/
|
111 |
if (empty($format)) {
|
112 |
$format = get_option('time_format');
|
113 |
}
|
114 |
+
if (!disable_wpp())
|
115 |
+
return date($format, strtotime($comment->comment_date));
|
116 |
return parsidate($format, $comment->comment_date, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per');
|
117 |
}
|
118 |
|
119 |
/**
|
120 |
* Fixes comment date and returns in Jalali format
|
121 |
*
|
122 |
+
* @param string $time Comment time
|
123 |
+
* @param string $format Date format
|
124 |
*
|
125 |
* @return string Formatted date
|
126 |
*/
|
135 |
if (empty($format)) {
|
136 |
$format = get_option('date_format');
|
137 |
}
|
138 |
+
if (!disable_wpp())
|
139 |
+
return date($format, strtotime($comment->comment_date));
|
140 |
return parsidate($format, $comment->comment_date, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per');
|
141 |
}
|
142 |
|
143 |
/**
|
144 |
* Fixes i18n date formatting and convert them to Jalali
|
145 |
*
|
146 |
+
* @param string $date Formatted date string.
|
147 |
+
* @param string $format Format to display the date.
|
148 |
+
* @param int $timestamp A sum of Unix timestamp and timezone offset in seconds.
|
149 |
+
* Might be without offset if input omitted timestamp but requested GMT.
|
150 |
+
* @param bool $gmt Whether to use GMT timezone. Only applies if timestamp was not provided.
|
151 |
+
* Default false.
|
152 |
*
|
153 |
* @return string Formatted time
|
154 |
*/
|
155 |
+
function wpp_fix_i18n($date, $format, $timestamp, $gmt)
|
156 |
+
{
|
157 |
+
global $wpp_settings, $post;
|
158 |
+
$post_id = !empty($post) ? $post->ID : null;
|
159 |
+
|
160 |
+
if (!disable_wpp())
|
161 |
+
return $format;
|
162 |
+
|
163 |
+
if ($post_id != null && get_post_type($post_id) == 'shop_order' && isset($_GET['post'])) // TODO: Remove after implement convert date for woocommerce
|
164 |
+
return $date;
|
165 |
+
else
|
166 |
+
return parsidate($format, $timestamp, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per');
|
167 |
+
}
|
168 |
+
|
169 |
+
function wpp_fix_wp_date($date, $format, $timestamp, $timezone)
|
170 |
{
|
171 |
global $wpp_settings;
|
|
|
|
|
172 |
|
173 |
+
if (!disable_wpp())
|
174 |
+
return $format;
|
175 |
+
|
176 |
+
return parsidate($format, $timestamp, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per');
|
177 |
}
|
178 |
|
179 |
function array_key_exists_r($needle, $haystack, $value = null)
|
191 |
return $result;
|
192 |
}
|
193 |
return $result;
|
194 |
+
}
|
includes/fixes-permalinks.php
CHANGED
@@ -17,34 +17,34 @@ if ($wpp_settings['conv_permalinks'] == 'enable') {
|
|
17 |
/**
|
18 |
* Converts post date pointer to Jalali pointer
|
19 |
*
|
20 |
-
* @param
|
21 |
-
* @param
|
22 |
*
|
23 |
* @return string
|
24 |
*/
|
25 |
-
function wpp_posts_where($where, $wp_query='')
|
26 |
{
|
27 |
global $wpdb;
|
28 |
-
if(empty($wp_query)){
|
29 |
-
|
30 |
}
|
31 |
-
|
32 |
if (!$wp_query->is_main_query() || empty($wp_query->query_vars)) {
|
33 |
return $where;
|
34 |
}
|
35 |
|
36 |
$pd = bn_parsidate::getInstance();
|
37 |
|
38 |
-
$m
|
39 |
-
$hour
|
40 |
$minute = (isset($wp_query->query_vars['minute'])) ? $wp_query->query_vars['minute'] : '';
|
41 |
$second = (isset($wp_query->query_vars['second'])) ? $wp_query->query_vars['second'] : '';
|
42 |
-
$year
|
43 |
-
$month
|
44 |
-
$day
|
45 |
|
46 |
if (!empty($m)) {
|
47 |
-
$len
|
48 |
$year = substr($m, 0, 4);
|
49 |
if ($len > 5) {
|
50 |
$month = substr($m, 4, 2);
|
@@ -84,7 +84,7 @@ function wpp_posts_where($where, $wp_query='')
|
|
84 |
if ($month != '') {
|
85 |
$stamon = $month;
|
86 |
$endmon = ($month == 12 ? 1 : $month + 1);
|
87 |
-
$endyear= ($endmon == 1 ? $stayear + 1 : $stayear);
|
88 |
}
|
89 |
|
90 |
if ($day != '') {
|
@@ -141,7 +141,7 @@ function wpp_posts_where($where, $wp_query='')
|
|
141 |
/**
|
142 |
* Converts post dates to Georgian dates for preventing errors
|
143 |
*
|
144 |
-
* @param
|
145 |
*
|
146 |
* @return mixed
|
147 |
*/
|
@@ -170,7 +170,7 @@ function wpp_pre_get_posts($query)
|
|
170 |
$out = false;
|
171 |
$pd = bn_parsidate::getInstance();
|
172 |
if (isset($permalink['name'])) {
|
173 |
-
$var = $wpdb->get_var("SELECT post_date FROM {$wpdb->prefix}posts WHERE post_name='{$permalink['name']}' ORDER BY id");
|
174 |
$per = parsidate('Y-m-d', $var, 'eng');
|
175 |
//update_option('options', $per );
|
176 |
$per = explode('-', $per);
|
@@ -198,13 +198,13 @@ function wpp_pre_get_posts($query)
|
|
198 |
array(
|
199 |
'after' => array(
|
200 |
'year' => $stadate[0],
|
201 |
-
'month'=> $stadate[1],
|
202 |
-
'day'
|
203 |
),
|
204 |
'before' => array(
|
205 |
'year' => $enddate[0],
|
206 |
-
'month'=> $enddate[1],
|
207 |
-
'day'
|
208 |
),
|
209 |
'inclusive' => true,
|
210 |
),
|
@@ -249,7 +249,7 @@ function wpp_pre_get_posts($query)
|
|
249 |
$query->is_404 = false;
|
250 |
$query->query_vars['error'] = '';
|
251 |
}//else
|
252 |
-
|
253 |
|
254 |
return $query;
|
255 |
}
|
@@ -257,9 +257,9 @@ function wpp_pre_get_posts($query)
|
|
257 |
/**
|
258 |
* Convert permalink structure to Jalali format
|
259 |
*
|
260 |
-
* @param
|
261 |
-
* @param
|
262 |
-
* @param
|
263 |
*
|
264 |
* @return string New permalink
|
265 |
*/
|
@@ -277,17 +277,17 @@ function wpp_permalink($perma, $post, $leavename = false)
|
|
277 |
}
|
278 |
|
279 |
$permalink = get_option('permalink_structure');
|
280 |
-
preg_match_all('/%([^\/]*)%/', $permalink, $
|
281 |
-
$
|
282 |
if ('' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft'))) {
|
283 |
if ($leavename) {
|
284 |
-
$
|
285 |
}
|
286 |
|
287 |
$date = explode(' ', parsidate('Y m d H i s', $post->post_date, 'eng'));
|
288 |
$out = array();
|
289 |
|
290 |
-
foreach ($
|
291 |
switch ($rewrite) {
|
292 |
case '%year%':
|
293 |
$out[] = $date[0];
|
@@ -318,7 +318,7 @@ function wpp_permalink($perma, $post, $leavename = false)
|
|
318 |
$cats = get_the_category($post->ID);
|
319 |
if ($cats) {
|
320 |
//usort($cats, '_usort_terms_by_ID');
|
321 |
-
$cats
|
322 |
$category = $cats[0]->slug;
|
323 |
if ($cats[0]->parent) {
|
324 |
$category = get_category_parents($cats[0]->parent, false, '/', true);
|
@@ -338,15 +338,12 @@ function wpp_permalink($perma, $post, $leavename = false)
|
|
338 |
$authordata = get_userdata($post->post_author);
|
339 |
$out[] = $authordata->user_nicename;
|
340 |
break;
|
341 |
-
case '%pagename%':
|
342 |
-
$out[] = $post->post_name;
|
343 |
-
break;
|
344 |
default:
|
345 |
-
unset($
|
346 |
break;
|
347 |
}
|
348 |
}
|
349 |
-
$permalink = home_url(str_replace($
|
350 |
|
351 |
return user_trailingslashit($permalink, 'single');
|
352 |
} else {
|
17 |
/**
|
18 |
* Converts post date pointer to Jalali pointer
|
19 |
*
|
20 |
+
* @param string $where
|
21 |
+
* @param string $wp_query
|
22 |
*
|
23 |
* @return string
|
24 |
*/
|
25 |
+
function wpp_posts_where($where, $wp_query = '')
|
26 |
{
|
27 |
global $wpdb;
|
28 |
+
if (empty($wp_query)) {
|
29 |
+
global $wp_query;
|
30 |
}
|
31 |
+
|
32 |
if (!$wp_query->is_main_query() || empty($wp_query->query_vars)) {
|
33 |
return $where;
|
34 |
}
|
35 |
|
36 |
$pd = bn_parsidate::getInstance();
|
37 |
|
38 |
+
$m = (isset($wp_query->query_vars['m'])) ? $wp_query->query_vars['m'] : '';
|
39 |
+
$hour = (isset($wp_query->query_vars['hour'])) ? $wp_query->query_vars['hour'] : '';
|
40 |
$minute = (isset($wp_query->query_vars['minute'])) ? $wp_query->query_vars['minute'] : '';
|
41 |
$second = (isset($wp_query->query_vars['second'])) ? $wp_query->query_vars['second'] : '';
|
42 |
+
$year = (isset($wp_query->query_vars['year'])) ? $wp_query->query_vars['year'] : '';
|
43 |
+
$month = (isset($wp_query->query_vars['monthnum'])) ? $wp_query->query_vars['monthnum'] : '';
|
44 |
+
$day = (isset($wp_query->query_vars['day'])) ? $wp_query->query_vars['day'] : '';
|
45 |
|
46 |
if (!empty($m)) {
|
47 |
+
$len = strlen($m);
|
48 |
$year = substr($m, 0, 4);
|
49 |
if ($len > 5) {
|
50 |
$month = substr($m, 4, 2);
|
84 |
if ($month != '') {
|
85 |
$stamon = $month;
|
86 |
$endmon = ($month == 12 ? 1 : $month + 1);
|
87 |
+
$endyear = ($endmon == 1 ? $stayear + 1 : $stayear);
|
88 |
}
|
89 |
|
90 |
if ($day != '') {
|
141 |
/**
|
142 |
* Converts post dates to Georgian dates for preventing errors
|
143 |
*
|
144 |
+
* @param WP_Query $query
|
145 |
*
|
146 |
* @return mixed
|
147 |
*/
|
170 |
$out = false;
|
171 |
$pd = bn_parsidate::getInstance();
|
172 |
if (isset($permalink['name'])) {
|
173 |
+
$var = $wpdb->get_var("SELECT post_date FROM {$wpdb->prefix}posts WHERE post_name='{$permalink['name']}' AND post_type!='attachment' ORDER BY id");
|
174 |
$per = parsidate('Y-m-d', $var, 'eng');
|
175 |
//update_option('options', $per );
|
176 |
$per = explode('-', $per);
|
198 |
array(
|
199 |
'after' => array(
|
200 |
'year' => $stadate[0],
|
201 |
+
'month' => $stadate[1],
|
202 |
+
'day' => $stadate[2] - 1,
|
203 |
),
|
204 |
'before' => array(
|
205 |
'year' => $enddate[0],
|
206 |
+
'month' => $enddate[1],
|
207 |
+
'day' => $enddate[2] + 1,
|
208 |
),
|
209 |
'inclusive' => true,
|
210 |
),
|
249 |
$query->is_404 = false;
|
250 |
$query->query_vars['error'] = '';
|
251 |
}//else
|
252 |
+
// $query->is_404 = true;
|
253 |
|
254 |
return $query;
|
255 |
}
|
257 |
/**
|
258 |
* Convert permalink structure to Jalali format
|
259 |
*
|
260 |
+
* @param mixed $perma
|
261 |
+
* @param WP_Post $post
|
262 |
+
* @param bool $leavename
|
263 |
*
|
264 |
* @return string New permalink
|
265 |
*/
|
277 |
}
|
278 |
|
279 |
$permalink = get_option('permalink_structure');
|
280 |
+
preg_match_all('/%([^\/]*)%/', $permalink, $rewriteCode);
|
281 |
+
$rewriteCode = $rewriteCode[0];
|
282 |
if ('' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft'))) {
|
283 |
if ($leavename) {
|
284 |
+
$rewriteCode = array_diff($rewriteCode, array('%postname%', '%pagename%'));
|
285 |
}
|
286 |
|
287 |
$date = explode(' ', parsidate('Y m d H i s', $post->post_date, 'eng'));
|
288 |
$out = array();
|
289 |
|
290 |
+
foreach ($rewriteCode as $rewrite) {
|
291 |
switch ($rewrite) {
|
292 |
case '%year%':
|
293 |
$out[] = $date[0];
|
318 |
$cats = get_the_category($post->ID);
|
319 |
if ($cats) {
|
320 |
//usort($cats, '_usort_terms_by_ID');
|
321 |
+
$cats = wp_list_sort($cats, array('term_id' => 'ASC',));
|
322 |
$category = $cats[0]->slug;
|
323 |
if ($cats[0]->parent) {
|
324 |
$category = get_category_parents($cats[0]->parent, false, '/', true);
|
338 |
$authordata = get_userdata($post->post_author);
|
339 |
$out[] = $authordata->user_nicename;
|
340 |
break;
|
|
|
|
|
|
|
341 |
default:
|
342 |
+
unset($rewriteCode[array_search($rewrite, $rewriteCode)]);
|
343 |
break;
|
344 |
}
|
345 |
}
|
346 |
+
$permalink = home_url(str_replace($rewriteCode, $out, $permalink));
|
347 |
|
348 |
return user_trailingslashit($permalink, 'single');
|
349 |
} else {
|
includes/general.php
CHANGED
@@ -17,11 +17,11 @@ add_action('admin_init', 'wpp_dismiss_notice_action');
|
|
17 |
|
18 |
/**
|
19 |
* Change Locale WordPress Admin and Front-end user
|
20 |
-
* @
|
21 |
-
*
|
22 |
-
* @param String $locale
|
23 |
*
|
24 |
* @return String
|
|
|
|
|
25 |
*/
|
26 |
function wp_parsi_set_locale($locale)
|
27 |
{
|
@@ -55,8 +55,8 @@ function wp_parsi_set_locale($locale)
|
|
55 |
/**
|
56 |
* Detects current page is feed or not
|
57 |
*
|
58 |
-
* @since 1.0
|
59 |
* @return bool True when page is feed, false when page isn't feed
|
|
|
60 |
*/
|
61 |
function wpp_is_feed()
|
62 |
{
|
@@ -74,7 +74,7 @@ function wpp_is_feed()
|
|
74 |
/**
|
75 |
* Converts English digits to Persian digits
|
76 |
*
|
77 |
-
* @param
|
78 |
*
|
79 |
* @return string Formatted numbers
|
80 |
*/
|
@@ -90,7 +90,7 @@ function per_number($number)
|
|
90 |
/**
|
91 |
* Converts Persian digits to English digits
|
92 |
*
|
93 |
-
* @param
|
94 |
*
|
95 |
* @return string Formatted numbers
|
96 |
*/
|
@@ -106,7 +106,7 @@ function eng_number($number)
|
|
106 |
/**
|
107 |
* Converts English numbers to Persian numbers in post contents
|
108 |
*
|
109 |
-
* @param
|
110 |
*
|
111 |
* @return string Formatted content
|
112 |
*/
|
@@ -120,7 +120,7 @@ function persian_number($content)
|
|
120 |
/**
|
121 |
* Fix numbers and convert them to Persian digits style
|
122 |
*
|
123 |
-
* @param
|
124 |
*
|
125 |
* @return mixed
|
126 |
*/
|
@@ -132,7 +132,7 @@ function fixnumber($content)
|
|
132 |
/**
|
133 |
* Fix arabic foreign characters
|
134 |
*
|
135 |
-
* @param
|
136 |
*
|
137 |
* @return mixed
|
138 |
*/
|
@@ -155,8 +155,8 @@ function wpp_login_headerurl()
|
|
155 |
* Notice for the activation.
|
156 |
* Added dismiss feature.
|
157 |
*
|
158 |
-
* @author Ehsaan
|
159 |
* @return void
|
|
|
160 |
*/
|
161 |
function wpp_activation_notice()
|
162 |
{
|
@@ -175,8 +175,8 @@ function wpp_activation_notice()
|
|
175 |
/**
|
176 |
* Dismiss the notice action
|
177 |
*
|
178 |
-
* @author Ehsaan
|
179 |
* @return void
|
|
|
180 |
*/
|
181 |
function wpp_dismiss_notice_action()
|
182 |
{
|
17 |
|
18 |
/**
|
19 |
* Change Locale WordPress Admin and Front-end user
|
20 |
+
* @param String $locale
|
|
|
|
|
21 |
*
|
22 |
* @return String
|
23 |
+
* @author
|
24 |
+
*
|
25 |
*/
|
26 |
function wp_parsi_set_locale($locale)
|
27 |
{
|
55 |
/**
|
56 |
* Detects current page is feed or not
|
57 |
*
|
|
|
58 |
* @return bool True when page is feed, false when page isn't feed
|
59 |
+
* @since 1.0
|
60 |
*/
|
61 |
function wpp_is_feed()
|
62 |
{
|
74 |
/**
|
75 |
* Converts English digits to Persian digits
|
76 |
*
|
77 |
+
* @param string $number Numbers
|
78 |
*
|
79 |
* @return string Formatted numbers
|
80 |
*/
|
90 |
/**
|
91 |
* Converts Persian digits to English digits
|
92 |
*
|
93 |
+
* @param string $number Numbers
|
94 |
*
|
95 |
* @return string Formatted numbers
|
96 |
*/
|
106 |
/**
|
107 |
* Converts English numbers to Persian numbers in post contents
|
108 |
*
|
109 |
+
* @param string $content Post content
|
110 |
*
|
111 |
* @return string Formatted content
|
112 |
*/
|
120 |
/**
|
121 |
* Fix numbers and convert them to Persian digits style
|
122 |
*
|
123 |
+
* @param string $content
|
124 |
*
|
125 |
* @return mixed
|
126 |
*/
|
132 |
/**
|
133 |
* Fix arabic foreign characters
|
134 |
*
|
135 |
+
* @param string $content
|
136 |
*
|
137 |
* @return mixed
|
138 |
*/
|
155 |
* Notice for the activation.
|
156 |
* Added dismiss feature.
|
157 |
*
|
|
|
158 |
* @return void
|
159 |
+
* @author Ehsaan
|
160 |
*/
|
161 |
function wpp_activation_notice()
|
162 |
{
|
175 |
/**
|
176 |
* Dismiss the notice action
|
177 |
*
|
|
|
178 |
* @return void
|
179 |
+
* @author Ehsaan
|
180 |
*/
|
181 |
function wpp_dismiss_notice_action()
|
182 |
{
|
includes/install.php
CHANGED
@@ -12,10 +12,10 @@ register_activation_hook(WP_PARSI_ROOT, 'wpp_install');
|
|
12 |
/**
|
13 |
* Copys files from plugin languages folder to global languages folder
|
14 |
*
|
15 |
-
* @since 1.0
|
16 |
* @return void
|
|
|
17 |
*/
|
18 |
function wpp_install()
|
19 |
{
|
20 |
-
|
21 |
}
|
12 |
/**
|
13 |
* Copys files from plugin languages folder to global languages folder
|
14 |
*
|
|
|
15 |
* @return void
|
16 |
+
* @since 1.0
|
17 |
*/
|
18 |
function wpp_install()
|
19 |
{
|
20 |
+
update_option('wpp_settings', array());
|
21 |
}
|
includes/parsidate.php
CHANGED
@@ -6,67 +6,71 @@
|
|
6 |
* @package WP-Parsidate
|
7 |
* @subpackage DateConversation
|
8 |
*/
|
|
|
9 |
/*Special thanks to :
|
10 |
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 |
-
public function IsPerLeapYear($year)
|
|
|
70 |
$mod = $year % 33;
|
71 |
|
72 |
if ($mod == 1 or $mod == 5 or $mod == 9 or $mod == 13 or $mod == 17 or $mod == 22 or $mod == 26 or $mod == 30) {
|
@@ -75,318 +79,325 @@ class bn_parsidate {
|
|
75 |
return false;
|
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 |
-
$len
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
if($date['mon']==12 && self::IsPerLeapYear($date['year']))
|
137 |
-
|
138 |
else
|
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 |
-
if($date['mon']==12 && self::IsPerLeapYear($date['year']))
|
181 |
-
|
182 |
else
|
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 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
}
|
249 |
-
if ( $lang == 'per' ) {
|
250 |
-
return self::trim_number( $out );
|
251 |
-
} else {
|
252 |
-
return $out;
|
253 |
-
}
|
254 |
-
}
|
255 |
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
* @param mixed $gd
|
263 |
-
*
|
264 |
-
* @return array
|
265 |
-
*/
|
266 |
-
function gregorian_to_persian( $gy, $gm, $gd ) {
|
267 |
-
$dayofyear = $this->g_days_sum_month[ (int) $gm ] + $gd;
|
268 |
-
if ( self::IsLeapYear( $gy ) and $gm > 2 ) {
|
269 |
-
$dayofyear ++;
|
270 |
-
}
|
271 |
-
$d_33 = (int) ( ( ( $gy - 16 ) % 132 ) * 0.0305 );
|
272 |
-
$leap = $gy % 4;
|
273 |
-
$a = ( ( $d_33 == 1 or $d_33 == 2 ) and ( $d_33 == $leap or $leap == 1 ) ) ? 78 : ( ( $d_33 == 3 and $leap == 0 ) ? 80 : 79 );
|
274 |
-
$b = ( $d_33 == 3 or $d_33 < ( $leap - 1 ) or $leap == 0 ) ? 286 : 287;
|
275 |
-
if ( (int) ( ( $gy - 10 ) / 63 ) == 30 ) {
|
276 |
-
$b --;
|
277 |
-
$a ++;
|
278 |
-
}
|
279 |
-
if ( $dayofyear > $a ) {
|
280 |
-
$jy = $gy - 621;
|
281 |
-
$jd = $dayofyear - $a;
|
282 |
-
} else {
|
283 |
-
$jy = $gy - 622;
|
284 |
-
$jd = $dayofyear + $b;
|
285 |
-
}
|
286 |
-
for ( $i = 0; $i < 11 and $jd > $this->j_days_in_month[ $i ]; $i ++ ) {
|
287 |
-
$jd -= $this->j_days_in_month[ $i ];
|
288 |
-
}
|
289 |
-
$jm = ++ $i;
|
290 |
|
291 |
-
|
292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
|
294 |
-
|
295 |
-
|
296 |
-
* @author Parsa Kafi
|
297 |
-
*
|
298 |
-
* @param int $wday
|
299 |
-
*
|
300 |
-
* @return int
|
301 |
-
*/
|
302 |
-
private function week_day( $wday ) {
|
303 |
|
304 |
-
|
305 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
|
|
320 |
|
321 |
-
|
322 |
-
|
323 |
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
|
|
334 |
|
335 |
-
|
336 |
-
|
337 |
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
|
|
351 |
|
352 |
-
|
353 |
-
|
354 |
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
|
|
390 |
}
|
391 |
|
392 |
/*
|
@@ -400,13 +411,14 @@ class bn_parsidate {
|
|
400 |
* @param string $datetime
|
401 |
* @param string $lang
|
402 |
*
|
403 |
-
* @return
|
404 |
*/
|
405 |
-
function parsidate(
|
406 |
-
|
407 |
-
|
|
|
408 |
|
409 |
-
|
410 |
}
|
411 |
|
412 |
/**
|
@@ -418,9 +430,10 @@ function parsidate( $input, $datetime = 'now', $lang = 'per' ) {
|
|
418 |
*
|
419 |
* @return datetime
|
420 |
*/
|
421 |
-
function gregdate(
|
422 |
-
|
423 |
-
|
|
|
424 |
|
425 |
-
|
426 |
}
|
6 |
* @package WP-Parsidate
|
7 |
* @subpackage DateConversation
|
8 |
*/
|
9 |
+
|
10 |
/*Special thanks to :
|
11 |
Reza Gholampanahi for convert function*/
|
12 |
|
13 |
+
class bn_parsidate
|
14 |
+
{
|
15 |
+
protected static $instance;
|
16 |
+
public $persian_month_names = array(
|
17 |
+
'',
|
18 |
+
'فروردین',
|
19 |
+
'اردیبهشت',
|
20 |
+
'خرداد',
|
21 |
+
'تیر',
|
22 |
+
'مرداد',
|
23 |
+
'شهریور',
|
24 |
+
'مهر',
|
25 |
+
'آبان',
|
26 |
+
'آذر',
|
27 |
+
'دی',
|
28 |
+
'بهمن',
|
29 |
+
'اسفند'
|
30 |
+
);
|
31 |
+
public $persian_short_month_names = array(
|
32 |
+
'',
|
33 |
+
'فروردین',
|
34 |
+
'اردیبهشت',
|
35 |
+
'خرداد',
|
36 |
+
'تیر',
|
37 |
+
'مرداد',
|
38 |
+
'شهریور',
|
39 |
+
'مهر',
|
40 |
+
'آبان',
|
41 |
+
'آذر',
|
42 |
+
'دی',
|
43 |
+
'بهمن',
|
44 |
+
'اسفند'
|
45 |
+
);
|
46 |
+
public $sesson = array('بهار', 'تابستان', 'پاییز', 'زمستان');
|
47 |
|
48 |
+
public $persian_day_names = array('یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه');
|
49 |
+
public $persian_day_small = array('ی', 'د', 'س', 'چ', 'پ', 'ج', 'ش');
|
50 |
|
51 |
+
public $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
|
52 |
+
private $j_days_sum_month = array(0, 0, 31, 62, 93, 124, 155, 186, 216, 246, 276, 306, 336);
|
53 |
|
54 |
+
private $g_days_sum_month = array(0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334);
|
55 |
|
56 |
|
57 |
+
/**
|
58 |
+
* Constructor
|
59 |
+
*/
|
60 |
+
function __construct()
|
61 |
+
{
|
62 |
+
}
|
63 |
|
64 |
/**
|
65 |
+
* bn_parsidate::IsPerLeapYear()
|
66 |
+
* check year is leap
|
67 |
+
*
|
68 |
+
* @param mixed $year
|
69 |
+
*
|
70 |
+
* @return boolean
|
71 |
+
*/
|
72 |
+
public function IsPerLeapYear($year)
|
73 |
+
{
|
74 |
$mod = $year % 33;
|
75 |
|
76 |
if ($mod == 1 or $mod == 5 or $mod == 9 or $mod == 13 or $mod == 17 or $mod == 22 or $mod == 26 or $mod == 30) {
|
79 |
return false;
|
80 |
}
|
81 |
|
82 |
+
/**
|
83 |
+
* bn_parsidate::IsLeapYear()
|
84 |
+
* check year is leap
|
85 |
+
*
|
86 |
+
* @param mixed $year
|
87 |
+
*
|
88 |
+
* @return boolean
|
89 |
+
*/
|
90 |
+
private function IsLeapYear($year)
|
91 |
+
{
|
92 |
+
if ((($year % 4) == 0 && ($year % 100) != 0) || (($year % 400) == 0) && ($year % 100) == 0) {
|
93 |
+
return true;
|
94 |
+
} else {
|
95 |
+
return false;
|
96 |
+
}
|
97 |
+
}
|
98 |
|
99 |
+
/**
|
100 |
+
* bn_parsidate::persian_date()
|
101 |
+
* convert gregorian datetime to persian datetime
|
102 |
+
*
|
103 |
+
* @param mixed $format
|
104 |
+
* @param string $date
|
105 |
+
* @param string $lang
|
106 |
+
*
|
107 |
+
* @return string
|
108 |
+
*/
|
109 |
+
public function persian_date($format, $date = 'now', $lang = 'per')
|
110 |
+
{
|
111 |
|
112 |
+
$j_days_in_month = array(31, 62, 93, 124, 155, 186, 216, 246, 276, 306, 336, 365);
|
113 |
+
$timestamp = is_numeric($date) && (int)$date == $date ? $date : strtotime($date);
|
114 |
+
$date = getdate($timestamp);
|
115 |
+
list($date['year'], $date['mon'], $date['mday']) = self::gregorian_to_persian($date['year'], $date['mon'], $date['mday']);
|
116 |
+
$date['mon'] = (int)$date['mon'];
|
117 |
+
$date['mday'] = (int)$date['mday'];
|
118 |
+
$out = '';
|
119 |
+
$len = strlen($format);
|
120 |
+
for ($i = 0; $i < $len; $i++) {
|
121 |
+
Switch ($format[$i]) {
|
122 |
+
//day
|
123 |
+
case'd':
|
124 |
+
$out .= ($date['mday'] < 10) ? '0' . $date['mday'] : $date['mday'];
|
125 |
+
break;
|
126 |
+
case'D':
|
127 |
+
$out .= $this->persian_day_small[$date['wday']];
|
128 |
+
break;
|
129 |
+
case'l':
|
130 |
+
$out .= $this->persian_day_names[$date['wday']];
|
131 |
+
break;
|
132 |
+
case'j':
|
133 |
+
$out .= $date['mday'];
|
134 |
+
break;
|
135 |
+
case'N':
|
136 |
+
$out .= $this->week_day($date['wday']) + 1;
|
137 |
+
break;
|
138 |
+
case'w':
|
139 |
+
$out .= $this->week_day($date['wday']);
|
140 |
+
break;
|
141 |
+
case'z':
|
142 |
+
if ($date['mon'] == 12 && self::IsPerLeapYear($date['year']))
|
143 |
+
$out .= 30 + $date['mday'];
|
144 |
else
|
145 |
+
$out .= $this->j_days_in_month[$date['mon']] + $date['mday'];
|
146 |
+
break;
|
147 |
+
//week
|
148 |
+
case'W':
|
149 |
+
$yday = $this->j_days_sum_month[$date['mon'] - 1] + $date['mday'];
|
150 |
+
$out .= intval($yday / 7);
|
151 |
+
break;
|
152 |
+
//month
|
153 |
+
case'f':
|
154 |
+
$mon = $date['mon'];
|
155 |
+
switch ($mon) {
|
156 |
+
case($mon < 4):
|
157 |
+
$out .= $this->sesson[0];
|
158 |
+
break;
|
159 |
+
case($mon < 7):
|
160 |
+
$out .= $this->sesson[1];
|
161 |
+
break;
|
162 |
+
case($mon < 10):
|
163 |
+
$out .= $this->sesson[2];
|
164 |
+
break;
|
165 |
+
case($mon > 9):
|
166 |
+
$out .= $this->sesson[3];
|
167 |
+
break;
|
168 |
+
}
|
169 |
+
break;
|
170 |
+
case'F':
|
171 |
+
$out .= $this->persian_month_names[(int)$date['mon']];
|
172 |
+
break;
|
173 |
+
case'm':
|
174 |
+
$out .= ($date['mon'] < 10) ? '0' . $date['mon'] : $date['mon'];
|
175 |
+
break;
|
176 |
+
case'M':
|
177 |
+
$out .= $this->persian_short_month_names[(int)$date['mon']];
|
178 |
+
break;
|
179 |
+
case'n':
|
180 |
+
$out .= $date['mon'];
|
181 |
+
break;
|
182 |
+
case'S':
|
183 |
+
$out .= 'ام';
|
184 |
+
break;
|
185 |
+
case't':
|
186 |
+
if ($date['mon'] == 12 && self::IsPerLeapYear($date['year']))
|
187 |
+
$out .= 30;
|
188 |
else
|
189 |
+
$out .= $this->j_days_in_month[(int)$date['mon'] - 1];
|
190 |
+
break;
|
191 |
+
//year
|
192 |
+
case'L':
|
193 |
+
$out .= (($date['year'] % 4) == 0) ? 1 : 0;
|
194 |
+
break;
|
195 |
+
case'o':
|
196 |
+
case'Y':
|
197 |
+
$out .= $date['year'];
|
198 |
+
break;
|
199 |
+
case'y':
|
200 |
+
$out .= substr($date['year'], 2, 2);
|
201 |
+
break;
|
202 |
+
//time
|
203 |
+
case'a':
|
204 |
+
$out .= ($date['hours'] < 12) ? 'ق.ظ' : 'ب.ظ';
|
205 |
+
break;
|
206 |
+
case'A':
|
207 |
+
$out .= ($date['hours'] < 12) ? 'قبل از ظهر' : 'بعد از ظهر';
|
208 |
+
break;
|
209 |
+
case'B':
|
210 |
+
$out .= (int)(1 + ($date['mon'] / 3));
|
211 |
+
break;
|
212 |
+
case'g':
|
213 |
+
$out .= ($date['hours'] > 12) ? $date['hours'] - 12 : $date['hours'];
|
214 |
+
break;
|
215 |
+
case'G':
|
216 |
+
$out .= $date['hours'];
|
217 |
+
break;
|
218 |
+
case'h':
|
219 |
+
$hour = ($date['hours'] > 12) ? $date['hours'] - 12 : $date['hours'];
|
220 |
+
$out .= ($hour < 10) ? '0' . $hour : $hour;
|
221 |
+
break;
|
222 |
+
case'H':
|
223 |
+
$out .= ($date['hours'] < 10) ? '0' . $date['hours'] : $date['hours'];
|
224 |
+
break;
|
225 |
+
case'i':
|
226 |
+
$out .= ($date['minutes'] < 10) ? '0' . $date['minutes'] : $date['minutes'];
|
227 |
+
break;
|
228 |
+
case's':
|
229 |
+
$out .= ($date['seconds'] < 10) ? '0' . $date['seconds'] : $date['seconds'];
|
230 |
+
break;
|
231 |
+
//full date time
|
232 |
+
case'c':
|
233 |
+
$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
|
234 |
+
break;
|
235 |
+
case'r':
|
236 |
+
$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
|
237 |
+
break;
|
238 |
+
case'U':
|
239 |
+
$out = $timestamp;
|
240 |
+
break;
|
241 |
+
//others
|
242 |
+
case'e':
|
243 |
+
case'I':
|
244 |
+
case'O':
|
245 |
+
case'P':
|
246 |
+
case'T':
|
247 |
+
case'Z':
|
248 |
+
case'u':
|
249 |
+
break;
|
250 |
+
default:
|
251 |
+
$out .= $format[$i];
|
252 |
+
}
|
253 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
|
255 |
+
if (strtolower($format) != 'u' && $lang == 'per') {
|
256 |
+
return self::trim_number($out);
|
257 |
+
} else {
|
258 |
+
return $out;
|
259 |
+
}
|
260 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
|
262 |
+
/**
|
263 |
+
* bn_parsidate::gregorian_to_persian()
|
264 |
+
* convert gregorian date to persian date
|
265 |
+
*
|
266 |
+
* @param mixed $gy
|
267 |
+
* @param mixed $gm
|
268 |
+
* @param mixed $gd
|
269 |
+
*
|
270 |
+
* @return array
|
271 |
+
*/
|
272 |
+
function gregorian_to_persian($gy, $gm, $gd)
|
273 |
+
{
|
274 |
+
$dayOfYear = $this->g_days_sum_month[(int)$gm] + $gd;
|
275 |
+
if (self::IsLeapYear($gy) and $gm > 2) {
|
276 |
+
$dayOfYear++;
|
277 |
+
}
|
278 |
+
$d_33 = (int)((($gy - 16) % 132) * 0.0305);
|
279 |
+
$leap = $gy % 4;
|
280 |
+
$a = (($d_33 == 1 or $d_33 == 2) and ($d_33 == $leap or $leap == 1)) ? 78 : (($d_33 == 3 and $leap == 0) ? 80 : 79);
|
281 |
+
$b = ($d_33 == 3 or $d_33 < ($leap - 1) or $leap == 0) ? 286 : 287;
|
282 |
+
if ((int)(($gy - 10) / 63) == 30) {
|
283 |
+
$b--;
|
284 |
+
$a++;
|
285 |
+
}
|
286 |
+
if ($dayOfYear > $a) {
|
287 |
+
$jy = $gy - 621;
|
288 |
+
$jd = $dayOfYear - $a;
|
289 |
+
} else {
|
290 |
+
$jy = $gy - 622;
|
291 |
+
$jd = $dayOfYear + $b;
|
292 |
+
}
|
293 |
+
for ($i = 0; $i < 11 and $jd > $this->j_days_in_month[$i]; $i++) {
|
294 |
+
$jd -= $this->j_days_in_month[$i];
|
295 |
+
}
|
296 |
+
$jm = ++$i;
|
297 |
|
298 |
+
return array($jy, strlen($jm) == 1 ? '0' . $jm : $jm, strlen($jd) == 1 ? '0' . $jd : $jd);
|
299 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
|
301 |
+
/**
|
302 |
+
* Get day of the week shamsi/jalali
|
303 |
+
* @param int $wday
|
304 |
+
*
|
305 |
+
* @return int
|
306 |
+
* @author Parsa Kafi
|
307 |
+
*
|
308 |
+
*/
|
309 |
+
private function week_day($wday)
|
310 |
+
{
|
311 |
+
return $wday == 6 ? 0 : ++$wday;
|
312 |
+
}
|
313 |
|
314 |
+
/**
|
315 |
+
* bn_parsidate::trim_number()
|
316 |
+
* convert english number to persian number
|
317 |
+
*
|
318 |
+
* @param mixed $num
|
319 |
+
* @param string $sp
|
320 |
+
*
|
321 |
+
* @return string
|
322 |
+
*/
|
323 |
+
public function trim_number($num, $sp = '٫')
|
324 |
+
{
|
325 |
+
$eng = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.');
|
326 |
+
$per = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', $sp);
|
327 |
+
$number = filter_var($num, FILTER_SANITIZE_NUMBER_INT);
|
328 |
|
329 |
+
return empty($number) ? str_replace($per, $eng, $num) : str_replace($eng, $per, $num);
|
330 |
+
}
|
331 |
|
332 |
+
/**
|
333 |
+
* bn_parsidate::getInstance()
|
334 |
+
* create instance of bn_parsidate class
|
335 |
+
*
|
336 |
+
* @return bn_parsidate
|
337 |
+
*/
|
338 |
+
public static function getInstance()
|
339 |
+
{
|
340 |
+
if (!isset(self::$instance)) {
|
341 |
+
self::$instance = new self();
|
342 |
+
}
|
343 |
|
344 |
+
return self::$instance;
|
345 |
+
}
|
346 |
|
347 |
+
/**
|
348 |
+
* bn_parsidate::gregorian_date()
|
349 |
+
* convert persian datetime to gregorian datetime
|
350 |
+
*
|
351 |
+
* @param mixed $format
|
352 |
+
* @param mixed $persiandate
|
353 |
+
*
|
354 |
+
* @return mixed
|
355 |
+
*/
|
356 |
+
public function gregorian_date($format, $persiandate)
|
357 |
+
{
|
358 |
+
preg_match_all('!\d+!', $persiandate, $matches);
|
359 |
+
$matches = $matches[0];
|
360 |
+
list($year, $mon, $day) = self::persian_to_gregorian($matches[0], $matches[1], $matches[2]);
|
361 |
|
362 |
+
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));
|
363 |
+
}
|
364 |
|
365 |
+
/**
|
366 |
+
* bn_parsidate::persian_to_gregorian()
|
367 |
+
* convert persian date to gregorian date
|
368 |
+
*
|
369 |
+
* @param mixed $jy
|
370 |
+
* @param mixed $jm
|
371 |
+
* @param mixed $jd
|
372 |
+
*
|
373 |
+
* @return array
|
374 |
+
*/
|
375 |
+
public function persian_to_gregorian($jy, $jm, $jd)
|
376 |
+
{
|
377 |
+
$doyj = ($jm - 2 > -1 ? $this->j_days_sum_month[(int)$jm] + $jd : $jd);
|
378 |
+
$d4 = ($jy + 1) % 4;
|
379 |
+
$d33 = (int)((($jy - 55) % 132) * .0305);
|
380 |
+
$a = ($d33 != 3 and $d4 <= $d33) ? 287 : 286;
|
381 |
+
$b = (($d33 == 1 or $d33 == 2) and ($d33 == $d4 or $d4 == 1)) ? 78 : (($d33 == 3 and $d4 == 0) ? 80 : 79);
|
382 |
+
if ((int)(($jy - 19) / 63) == 20) {
|
383 |
+
$a--;
|
384 |
+
$b++;
|
385 |
+
}
|
386 |
+
if ($doyj <= $a) {
|
387 |
+
$gy = $jy + 621;
|
388 |
+
$gd = $doyj + $b;
|
389 |
+
} else {
|
390 |
+
$gy = $jy + 622;
|
391 |
+
$gd = $doyj - $a;
|
392 |
+
}
|
393 |
+
foreach (array(0, 31, ($gy % 4 == 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) as $gm => $days) {
|
394 |
+
if ($gd <= $days) {
|
395 |
+
break;
|
396 |
+
}
|
397 |
+
$gd -= $days;
|
398 |
+
}
|
399 |
+
return array($gy, $gm, $gd);
|
400 |
+
}
|
401 |
}
|
402 |
|
403 |
/*
|
411 |
* @param string $datetime
|
412 |
* @param string $lang
|
413 |
*
|
414 |
+
* @return string
|
415 |
*/
|
416 |
+
function parsidate($input, $datetime = 'now', $lang = 'per')
|
417 |
+
{
|
418 |
+
$bndate = bn_parsidate::getInstance();
|
419 |
+
$bndate = $bndate->persian_date($input, $datetime, $lang);
|
420 |
|
421 |
+
return $bndate;
|
422 |
}
|
423 |
|
424 |
/**
|
430 |
*
|
431 |
* @return datetime
|
432 |
*/
|
433 |
+
function gregdate($input, $datetime)
|
434 |
+
{
|
435 |
+
$bndate = bn_parsidate::getInstance();
|
436 |
+
$bndate = $bndate->gregorian_date($input, $datetime);
|
437 |
|
438 |
+
return $bndate;
|
439 |
}
|
includes/plugins/disable.php
CHANGED
@@ -1,83 +1,87 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
continue;
|
11 |
-
|
12 |
-
}
|
13 |
}
|
|
|
14 |
|
15 |
-
|
|
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
break;
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
return true;
|
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 |
return $date[0];
|
62 |
|
63 |
-
|
64 |
|
65 |
-
|
66 |
return $date[0];
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
|
71 |
-
|
72 |
return $date[0];
|
73 |
-
|
74 |
-
}
|
75 |
-
return substr_replace($date[0],$dt,-20,10);
|
76 |
}
|
|
|
|
|
77 |
|
78 |
// add the filter
|
79 |
-
add_filter(
|
80 |
-
|
81 |
|
82 |
|
83 |
/**
|
@@ -87,77 +91,80 @@ add_filter( 'woocommerce_reports_get_order_report_query', 'wpp_woocommerce_admin
|
|
87 |
* @subpackage Plugins/EDD
|
88 |
* @author Ehsaan
|
89 |
*/
|
90 |
-
class WPP_Disable
|
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 |
-
public function rial_fix( $price, $did ) {
|
126 |
-
return str_replace( 'RIAL', 'ریال', $price );
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Adds settings for toggle fixing
|
131 |
-
*
|
132 |
-
* @param array $old_settings Old settings
|
133 |
-
*
|
134 |
-
* @return array New settings
|
135 |
-
*/
|
136 |
-
public function add_settings( $old_settings ) {
|
137 |
-
$options = array(
|
138 |
-
'enable' => __( 'Enable', 'wp-parsidate' ),
|
139 |
-
'disable' => __( 'Disable', 'wp-parsidate' )
|
140 |
-
);
|
141 |
-
$settings = array(
|
142 |
-
'dis' => array(
|
143 |
-
'id' => 'dis',
|
144 |
-
'name' => __( 'Hook deactivator', 'wp-parsidate' ),
|
145 |
-
'type' => 'header'
|
146 |
-
),
|
147 |
-
'dis_prices' => array(
|
148 |
-
'id' => 'dis_input',
|
149 |
-
'name' => __( 'Hook list', 'wp-parsidate' ),
|
150 |
-
'type' => 'textarea',
|
151 |
-
'options' => $options,
|
152 |
-
'std' => 'enable',
|
153 |
-
'desc' => __( 'Enter hook,class,function to remove parsidate filter from it', 'wp-parsidate' )
|
154 |
-
)
|
155 |
-
);
|
156 |
-
|
157 |
-
return array_merge( $old_settings, $settings );
|
158 |
-
}
|
159 |
-
}
|
160 |
|
161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
|
163 |
-
|
1 |
<?php
|
2 |
+
global $wpp_settings, $dis_hook;
|
3 |
+
if (isset($wpp_settings['dis_input'])) {
|
4 |
+
|
5 |
+
$dis_hook = array();
|
6 |
+
$lists = explode("\n", $wpp_settings['dis_input']);
|
7 |
+
foreach ($lists as $list) {
|
8 |
+
$list = explode(',', $list);
|
9 |
+
if (count($list) < 2)
|
10 |
continue;
|
11 |
+
$dis_hook[$list[0]][] = array('func' => $list[1], 'class' => (isset($list[2]) ? $list[2] : ''));
|
|
|
12 |
}
|
13 |
+
}
|
14 |
|
15 |
+
function disable_wpp()
|
16 |
+
{
|
17 |
|
18 |
+
global $dis_hook;
|
19 |
+
if (wpp_is_feed())
|
20 |
+
return false;
|
21 |
+
$calls = debug_backtrace();
|
22 |
+
unset($calls[0]);
|
23 |
+
unset($calls[1]);
|
24 |
+
unset($calls[2]);
|
25 |
|
26 |
+
foreach ($calls as $i => $call) {
|
27 |
+
unset($calls[$i]);
|
28 |
+
if ($call['function'] == 'apply_filters' and empty($call['class']))
|
29 |
break;
|
30 |
+
}
|
31 |
+
$func = $calls[++$i]['function'];
|
32 |
+
$hooks = $dis_hook[$func];
|
33 |
+
if (empty($hooks))
|
34 |
return true;
|
35 |
|
36 |
+
unset($calls[$i]);
|
37 |
+
|
38 |
+
foreach ($calls as $i => $call) {
|
39 |
+
foreach ($hooks as $hook) {
|
40 |
+
$hook['class'] = trim($hook['class']);
|
41 |
+
if ((isset($call['class']) and empty($hook['class'])) or (!isset($call['class']) and !empty($hook['class'])))
|
42 |
+
continue;
|
43 |
+
if (!empty($hook['func']) and ($call['function'] != trim($hook['func'])))
|
44 |
+
continue;
|
45 |
+
if ((!isset($call['class']) and empty($hook['class'])) or $call['class'] == $hook['class'])
|
46 |
+
return false;
|
|
|
47 |
}
|
48 |
+
}
|
49 |
+
return true;
|
50 |
+
}
|
51 |
|
52 |
|
53 |
+
function wpp_woocommerce_admin_report_data($report_data)
|
54 |
+
{
|
55 |
|
56 |
+
$report_data['where'] = preg_replace_callback("/posts.post_date\s.=?\s'([^']+)'/i", 'fix_date_woo_report', $report_data['where']);
|
57 |
+
return $report_data;
|
58 |
+
}
|
59 |
|
60 |
+
;
|
61 |
|
62 |
+
function fix_date_woo_report($date)
|
63 |
+
{
|
64 |
+
|
65 |
+
if (empty($_GET['start_date']) or empty($_GET['end_date']))
|
66 |
return $date[0];
|
67 |
|
68 |
+
if (strpos($date[0], '=') === false) {
|
69 |
|
70 |
+
if ((int)$_GET['end_date'] > 1900)
|
71 |
return $date[0];
|
72 |
+
$dt = gregdate('Y-m-d', $_GET['end_date']);
|
73 |
+
$dt = date('Y-m-d', strtotime("$dt +1 day"));
|
74 |
+
} else {
|
75 |
|
76 |
+
if ((int)$_GET['start_date'] > 1900)
|
77 |
return $date[0];
|
78 |
+
$dt = gregdate('Y-m-d', $_GET['start_date']);
|
|
|
|
|
79 |
}
|
80 |
+
return substr_replace($date[0], $dt, -20, 10);
|
81 |
+
}
|
82 |
|
83 |
// add the filter
|
84 |
+
add_filter('woocommerce_reports_get_order_report_query', 'wpp_woocommerce_admin_report_data', 10, 1);
|
|
|
85 |
|
86 |
|
87 |
/**
|
91 |
* @subpackage Plugins/EDD
|
92 |
* @author Ehsaan
|
93 |
*/
|
94 |
+
class WPP_Disable
|
95 |
+
{
|
96 |
+
public static $instance = null;
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Hooks required tags
|
100 |
+
*/
|
101 |
+
private function __construct()
|
102 |
+
{
|
103 |
+
global $wpp_settings;
|
104 |
+
add_filter('wpp_plugins_compability_settings', array($this, 'add_settings'));
|
105 |
+
|
106 |
+
if (isset($wpp_settings['dis_prices']) && $wpp_settings['dis_prices'] != 'disable') {
|
107 |
+
add_filter('dis_rial_currency_filter_after', 'per_number', 10, 2);
|
108 |
+
}
|
109 |
+
|
110 |
+
if (isset($wpp_settings['dis_rial_fix']) && $wpp_settings['dis_rial_fix'] != 'disable') {
|
111 |
+
add_filter('dis_rial_currency_filter_after', array($this, 'rial_fix'), 10, 2);
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Returns an instance of class
|
117 |
+
*
|
118 |
+
* @return WPP_Disable
|
119 |
+
*/
|
120 |
+
public static function getInstance()
|
121 |
+
{
|
122 |
+
if (self::$instance == null) {
|
123 |
+
self::$instance = new WPP_Disable();
|
124 |
+
}
|
125 |
+
|
126 |
+
return self::$instance;
|
127 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
+
/**
|
130 |
+
* RIAL fix for EDD
|
131 |
+
*/
|
132 |
+
public function rial_fix($price, $did)
|
133 |
+
{
|
134 |
+
return str_replace('RIAL', 'ریال', $price);
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Adds settings for toggle fixing
|
139 |
+
*
|
140 |
+
* @param array $old_settings Old settings
|
141 |
+
*
|
142 |
+
* @return array New settings
|
143 |
+
*/
|
144 |
+
public function add_settings($old_settings)
|
145 |
+
{
|
146 |
+
$options = array(
|
147 |
+
'enable' => __('Enable', 'wp-parsidate'),
|
148 |
+
'disable' => __('Disable', 'wp-parsidate')
|
149 |
+
);
|
150 |
+
$settings = array(
|
151 |
+
'dis' => array(
|
152 |
+
'id' => 'dis',
|
153 |
+
'name' => __('Hook deactivator', 'wp-parsidate'),
|
154 |
+
'type' => 'header'
|
155 |
+
),
|
156 |
+
'dis_prices' => array(
|
157 |
+
'id' => 'dis_input',
|
158 |
+
'name' => __('Hook list', 'wp-parsidate'),
|
159 |
+
'type' => 'textarea',
|
160 |
+
'options' => $options,
|
161 |
+
'std' => 'enable',
|
162 |
+
'desc' => __('Enter hook,class,function to remove parsidate filter from it', 'wp-parsidate')
|
163 |
+
)
|
164 |
+
);
|
165 |
+
|
166 |
+
return array_merge($old_settings, $settings);
|
167 |
+
}
|
168 |
+
}
|
169 |
|
170 |
+
return WPP_Disable::getInstance();
|
includes/plugins/edd.php
CHANGED
@@ -7,81 +7,86 @@
|
|
7 |
* @subpackage Plugins/EDD
|
8 |
* @author Ehsaan
|
9 |
*/
|
10 |
-
class WPP_EDD
|
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 |
return WPP_EDD::getInstance();
|
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_EDD
|
35 |
+
*/
|
36 |
+
public static function getInstance()
|
37 |
+
{
|
38 |
+
if (self::$instance == null) {
|
39 |
+
self::$instance = new WPP_EDD();
|
40 |
+
}
|
41 |
|
42 |
+
return self::$instance;
|
43 |
+
}
|
44 |
|
45 |
+
/**
|
46 |
+
* RIAL fix for EDD
|
47 |
+
*/
|
48 |
+
public function rial_fix($price, $did)
|
49 |
+
{
|
50 |
+
return str_replace('RIAL', 'ریال', $price);
|
51 |
+
}
|
52 |
|
53 |
+
/**
|
54 |
+
* Adds settings for toggle fixing
|
55 |
+
*
|
56 |
+
* @param array $old_settings Old settings
|
57 |
+
*
|
58 |
+
* @return array New settings
|
59 |
+
*/
|
60 |
+
public function add_settings($old_settings)
|
61 |
+
{
|
62 |
+
$options = array(
|
63 |
+
'enable' => __('Enable', 'wp-parsidate'),
|
64 |
+
'disable' => __('Disable', 'wp-parsidate')
|
65 |
+
);
|
66 |
+
$settings = array(
|
67 |
+
'edd' => array(
|
68 |
+
'id' => 'edd',
|
69 |
+
'name' => __('Easy Digital Downloads', 'wp-parsidate'),
|
70 |
+
'type' => 'header'
|
71 |
+
),
|
72 |
+
'edd_prices' => array(
|
73 |
+
'id' => 'edd_prices',
|
74 |
+
'name' => __('Fix prices', 'wp-parsidate'),
|
75 |
+
'type' => 'radio',
|
76 |
+
'options' => $options,
|
77 |
+
'std' => 'disable'
|
78 |
+
),
|
79 |
+
'edd_rial_fix' => array(
|
80 |
+
'id' => 'edd_rial_fix',
|
81 |
+
'name' => __('Replace ریال with RIAL', 'wp-parsidate'),
|
82 |
+
'type' => 'radio',
|
83 |
+
'options' => $options,
|
84 |
+
'std' => 'disable'
|
85 |
+
)
|
86 |
+
);
|
87 |
|
88 |
+
return array_merge($old_settings, $settings);
|
89 |
+
}
|
90 |
}
|
91 |
|
92 |
return WPP_EDD::getInstance();
|
includes/plugins/fixes-woo.php
CHANGED
@@ -1,32 +1,34 @@
|
|
1 |
<?php
|
2 |
-
add_filter(
|
3 |
|
4 |
-
function wpp_wc_save_post($data
|
|
|
5 |
|
6 |
-
if($data['post_type']=='shop_order')
|
7 |
-
$_POST['order_date'] = gregdate('Y-m-d'
|
8 |
-
if($data['post_type']=='product'){
|
9 |
-
if(isset($_POST['_sale_price_dates_from']) and !
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
}
|
16 |
return $data;
|
17 |
}
|
18 |
|
19 |
-
function getqtlangcustomfieldvalue($metadata, $object_id, $meta_key, $single)
|
|
|
20 |
|
21 |
-
if($meta_key=='_sale_price_dates_from'){
|
22 |
var_dump($_POST);
|
23 |
var_dump(func_get_args());//die;
|
24 |
}
|
25 |
-
if($meta_key=='_sale_price_dates_to'){
|
26 |
var_dump($_POST);
|
27 |
var_dump(func_get_args());//die;
|
28 |
}
|
29 |
|
30 |
}
|
31 |
-
|
32 |
-
|
1 |
<?php
|
2 |
+
add_filter('wp_insert_post_data', 'wpp_wc_save_post', '9999', 2);
|
3 |
|
4 |
+
function wpp_wc_save_post($data, $postarr)
|
5 |
+
{
|
6 |
|
7 |
+
if ($data['post_type'] == 'shop_order')
|
8 |
+
$_POST['order_date'] = gregdate('Y-m-d', $_POST['order_date']);
|
9 |
+
if ($data['post_type'] == 'product') {
|
10 |
+
if (isset($_POST['_sale_price_dates_from']) and !empty($_POST['_sale_price_dates_from'])) {
|
11 |
+
$_POST['_sale_price_dates_from'] = gregdate('Y-m-d', $_POST['_sale_price_dates_from']);
|
12 |
+
}
|
13 |
+
if (isset($_POST['_sale_price_dates_to']) and !empty($_POST['_sale_price_dates_to'])) {
|
14 |
+
$_POST['_sale_price_dates_to'] = gregdate('Y-m-d', $_POST['_sale_price_dates_to']);
|
15 |
+
}
|
16 |
}
|
17 |
return $data;
|
18 |
}
|
19 |
|
20 |
+
function getqtlangcustomfieldvalue($metadata, $object_id, $meta_key, $single)
|
21 |
+
{
|
22 |
|
23 |
+
if ($meta_key == '_sale_price_dates_from') {
|
24 |
var_dump($_POST);
|
25 |
var_dump(func_get_args());//die;
|
26 |
}
|
27 |
+
if ($meta_key == '_sale_price_dates_to') {
|
28 |
var_dump($_POST);
|
29 |
var_dump(func_get_args());//die;
|
30 |
}
|
31 |
|
32 |
}
|
33 |
+
|
34 |
+
add_filter('update_post_metadata', 'getqtlangcustomfieldvalue', 10, 4);
|
includes/plugins/woocommerce.php
CHANGED
@@ -8,64 +8,68 @@
|
|
8 |
* @author Ehsaan
|
9 |
* @author Farhan Nisi
|
10 |
*/
|
11 |
-
class WPP_WooCommerce
|
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 |
return WPP_WooCommerce::getInstance();
|
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 |
|
40 |
+
return self::$instance;
|
41 |
+
}
|
42 |
|
43 |
+
/**
|
44 |
+
* Adds settings for toggle fixing
|
45 |
+
*
|
46 |
+
* @param array $old_settings Old settings
|
47 |
+
*
|
48 |
+
* @return array New settings
|
49 |
+
*/
|
50 |
+
public function add_settings($old_settings)
|
51 |
+
{
|
52 |
+
$options = array(
|
53 |
+
'enable' => __('Enable', 'wp-parsidate'),
|
54 |
+
'disable' => __('Disable', 'wp-parsidate')
|
55 |
+
);
|
56 |
+
$settings = array(
|
57 |
+
'woocommerce' => array(
|
58 |
+
'id' => 'woocommerce',
|
59 |
+
'name' => __('WooCommerce', 'wp-parsidate'),
|
60 |
+
'type' => 'header'
|
61 |
+
),
|
62 |
+
'woo_per_price' => array(
|
63 |
+
'id' => 'woo_per_price',
|
64 |
+
'name' => __('Fix prices', 'wp-parsidate'),
|
65 |
+
'type' => 'radio',
|
66 |
+
'options' => $options,
|
67 |
+
'std' => 'disable'
|
68 |
+
)
|
69 |
+
);
|
70 |
|
71 |
+
return array_merge($old_settings, $settings);
|
72 |
+
}
|
73 |
}
|
74 |
|
75 |
return WPP_WooCommerce::getInstance();
|
includes/settings.php
CHANGED
@@ -10,595 +10,616 @@
|
|
10 |
* @package WP-Parsidate
|
11 |
* @subpackage Admin/Settings
|
12 |
*/
|
13 |
-
if (
|
14 |
-
|
15 |
} // No direct access allowed ;)
|
16 |
|
17 |
-
add_action(
|
18 |
|
19 |
/**
|
20 |
* Add WP-Parsidate admin page settings
|
21 |
* */
|
22 |
-
function wpp_add_settings_menu()
|
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 |
* Gets saved settings from WP core
|
48 |
*
|
49 |
-
* @since 2.0
|
50 |
* @return array Parsi Settings
|
|
|
51 |
*/
|
52 |
-
function wp_parsi_get_settings()
|
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 |
* Registers settings in WP core
|
78 |
*
|
79 |
-
* @since 2.0
|
80 |
* @return void
|
|
|
81 |
*/
|
82 |
-
function wpp_register_settings()
|
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 |
-
add_action(
|
121 |
|
122 |
/**
|
123 |
* Gets settings tabs
|
124 |
*
|
125 |
-
* @since 2.0
|
126 |
* @return array Tabs list
|
|
|
127 |
*/
|
128 |
-
function wpp_get_tabs()
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
136 |
}
|
137 |
|
138 |
/**
|
139 |
* Sanitizes and saves settings after submit
|
140 |
*
|
141 |
-
* @
|
142 |
-
*
|
143 |
-
* @param array $input Settings input
|
144 |
*
|
145 |
* @return array New settings
|
|
|
|
|
146 |
*/
|
147 |
-
function wpp_settings_sanitize(
|
|
|
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 |
* Get settings fields
|
203 |
*
|
204 |
-
* @since 2.0
|
205 |
* @return array Fields
|
|
|
206 |
*/
|
207 |
-
function wpp_get_registered_settings()
|
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 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
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 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
|
|
338 |
}
|
339 |
|
340 |
/* Form Callbacks Made by EDD Development Team */
|
341 |
-
function wpp_header_callback(
|
342 |
-
|
|
|
343 |
}
|
344 |
|
345 |
-
function wpp_checkbox_callback(
|
346 |
-
|
|
|
347 |
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
|
352 |
-
|
353 |
}
|
354 |
|
355 |
-
function wpp_multicheck_callback(
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
|
|
369 |
}
|
370 |
|
371 |
-
function wpp_radio_callback(
|
372 |
-
|
|
|
373 |
|
374 |
-
|
375 |
-
|
376 |
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
|
387 |
-
|
388 |
}
|
389 |
|
390 |
-
function wpp_text_callback(
|
391 |
-
|
|
|
392 |
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
|
403 |
-
|
404 |
}
|
405 |
|
406 |
-
function wpp_number_callback(
|
407 |
-
|
|
|
408 |
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
|
423 |
-
|
424 |
}
|
425 |
|
426 |
-
function wpp_textarea_callback(
|
427 |
-
|
|
|
428 |
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
|
439 |
-
|
440 |
}
|
441 |
|
442 |
-
function wpp_password_callback(
|
443 |
-
|
|
|
444 |
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
|
455 |
-
|
456 |
}
|
457 |
|
458 |
-
function wpp_missing_callback(
|
459 |
-
|
|
|
460 |
|
461 |
-
|
462 |
}
|
463 |
|
464 |
|
465 |
-
function wpp_select_callback(
|
466 |
-
|
|
|
467 |
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
|
474 |
-
|
475 |
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
|
481 |
-
|
482 |
-
|
483 |
|
484 |
-
|
485 |
}
|
486 |
|
487 |
-
function wpp_color_select_callback(
|
488 |
-
|
|
|
489 |
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
|
496 |
-
|
497 |
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
|
503 |
-
|
504 |
-
|
505 |
|
506 |
-
|
507 |
}
|
508 |
|
509 |
-
function wpp_rich_editor_callback(
|
510 |
-
|
|
|
511 |
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
|
524 |
-
|
525 |
|
526 |
-
|
527 |
}
|
528 |
|
529 |
-
function wpp_upload_callback(
|
530 |
-
|
|
|
531 |
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
|
543 |
-
|
544 |
}
|
545 |
|
546 |
-
function wpp_color_callback(
|
547 |
-
|
|
|
548 |
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
|
555 |
-
|
556 |
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
|
561 |
-
|
562 |
}
|
563 |
|
564 |
-
function wpp_render_settings()
|
565 |
-
|
566 |
-
|
|
|
567 |
|
568 |
-
|
569 |
-
|
570 |
<div class="wrap wpp-settings-wrap">
|
571 |
-
<h2><?php _e(
|
572 |
<h2 class="nav-tab-wrapper">
|
573 |
-
|
574 |
-
|
575 |
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
|
581 |
-
|
582 |
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
</h2>
|
589 |
-
|
590 |
<div id="tab_container">
|
591 |
<form method="post" action="options.php">
|
592 |
<table class="form-table">
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
</table>
|
598 |
-
|
599 |
</form>
|
600 |
</div><!-- #tab_container-->
|
601 |
</div><!-- .wrap -->
|
602 |
-
|
603 |
-
|
604 |
}
|
10 |
* @package WP-Parsidate
|
11 |
* @subpackage Admin/Settings
|
12 |
*/
|
13 |
+
if (!defined('ABSPATH')) {
|
14 |
+
exit;
|
15 |
} // No direct access allowed ;)
|
16 |
|
17 |
+
add_action('admin_menu', 'wpp_add_settings_menu', 11);
|
18 |
|
19 |
/**
|
20 |
* Add WP-Parsidate admin page settings
|
21 |
* */
|
22 |
+
function wpp_add_settings_menu()
|
23 |
+
{
|
24 |
+
global $wpp_settings;
|
25 |
+
|
26 |
+
if ($wpp_settings['submenu_move'] != 'disable') {
|
27 |
+
add_submenu_page(
|
28 |
+
'options-general.php',
|
29 |
+
__('Parsi Settings', 'wp-parsidate'),
|
30 |
+
__('Parsi Settings', 'wp-parsidate'),
|
31 |
+
'manage_options',
|
32 |
+
'wp-parsi-settings',
|
33 |
+
'wpp_render_settings'
|
34 |
+
);
|
35 |
+
} else {
|
36 |
+
add_menu_page(
|
37 |
+
__('Parsi Settings', 'wp-parsidate'),
|
38 |
+
__('Parsi Settings', 'wp-parsidate'),
|
39 |
+
'manage_options',
|
40 |
+
'wp-parsi-settings',
|
41 |
+
'wpp_render_settings',
|
42 |
+
'dashicons-admin-site'
|
43 |
+
);
|
44 |
+
}
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
* Gets saved settings from WP core
|
49 |
*
|
|
|
50 |
* @return array Parsi Settings
|
51 |
+
* @since 2.0
|
52 |
*/
|
53 |
+
function wp_parsi_get_settings()
|
54 |
+
{
|
55 |
+
$settings = get_option('wpp_settings');
|
56 |
+
if (empty($settings)) {
|
57 |
+
update_option('wpp_settings', array(
|
58 |
+
'admin_lang' => 'disable',
|
59 |
+
'user_lang' => 'disable',
|
60 |
+
'submenu_move' => 'disable',
|
61 |
+
'persian_date' => 'disable',
|
62 |
+
'conv_title' => 'disable',
|
63 |
+
'conv_contents' => 'disable',
|
64 |
+
'conv_excerpt' => 'disable',
|
65 |
+
'conv_comments' => 'disable',
|
66 |
+
'conv_comment_count' => 'disable',
|
67 |
+
'conv_dates' => 'disable',
|
68 |
+
'conv_cats' => 'disable',
|
69 |
+
'conv_arabic' => 'disable',
|
70 |
+
'conv_permalinks' => 'disable',
|
71 |
+
'news_source' => 'parsi'
|
72 |
+
));
|
73 |
+
}
|
74 |
+
|
75 |
+
return apply_filters('wpp_get_settings', $settings);
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
* Registers settings in WP core
|
80 |
*
|
|
|
81 |
* @return void
|
82 |
+
* @since 2.0
|
83 |
*/
|
84 |
+
function wpp_register_settings()
|
85 |
+
{
|
86 |
+
if (false == get_option('wpp_settings')) {
|
87 |
+
add_option('wpp_settings');
|
88 |
+
}
|
89 |
+
|
90 |
+
foreach (wpp_get_registered_settings() as $tab => $settings) {
|
91 |
+
add_settings_section(
|
92 |
+
'wpp_settings_' . $tab,
|
93 |
+
__return_null(),
|
94 |
+
'__return_false',
|
95 |
+
'wpp_settings_' . $tab
|
96 |
+
);
|
97 |
+
|
98 |
+
foreach ($settings as $option) {
|
99 |
+
$name = isset($option['name']) ? $option['name'] : '';
|
100 |
+
|
101 |
+
add_settings_field(
|
102 |
+
'wpp_settings[' . $option['id'] . ']',
|
103 |
+
$name,
|
104 |
+
function_exists('wpp_' . $option['type'] . '_callback') ? 'wpp_' . $option['type'] . '_callback' : 'wpp_missing_callback',
|
105 |
+
'wpp_settings_' . $tab,
|
106 |
+
'wpp_settings_' . $tab,
|
107 |
+
array(
|
108 |
+
'id' => isset($option['id']) ? $option['id'] : null,
|
109 |
+
'desc' => !empty($option['desc']) ? $option['desc'] : '',
|
110 |
+
'name' => isset($option['name']) ? $option['name'] : null,
|
111 |
+
'section' => $tab,
|
112 |
+
'size' => isset($option['size']) ? $option['size'] : null,
|
113 |
+
'options' => isset($option['options']) ? $option['options'] : '',
|
114 |
+
'std' => isset($option['std']) ? $option['std'] : ''
|
115 |
+
)
|
116 |
+
);
|
117 |
+
|
118 |
+
register_setting('wpp_settings', 'wpp_settings', 'wpp_settings_sanitize');
|
119 |
+
}
|
120 |
+
}
|
121 |
}
|
122 |
|
123 |
+
add_action('admin_init', 'wpp_register_settings');
|
124 |
|
125 |
/**
|
126 |
* Gets settings tabs
|
127 |
*
|
|
|
128 |
* @return array Tabs list
|
129 |
+
* @since 2.0
|
130 |
*/
|
131 |
+
function wpp_get_tabs()
|
132 |
+
{
|
133 |
+
$tabs = array(
|
134 |
+
'core' => sprintf(__('%s Core', 'wp-parsidate'), '<span class="dashicons dashicons-admin-site"></span>'),
|
135 |
+
'conv' => sprintf(__('%s Converts', 'wp-parsidate'), '<span class="dashicons dashicons-admin-settings"></span>'),
|
136 |
+
'plugins' => sprintf(__('%s Plugins compability', 'wp-parsidate'), '<span class="dashicons dashicons-admin-plugins"></span>')
|
137 |
+
);
|
138 |
+
|
139 |
+
return $tabs;
|
140 |
}
|
141 |
|
142 |
/**
|
143 |
* Sanitizes and saves settings after submit
|
144 |
*
|
145 |
+
* @param array $input Settings input
|
|
|
|
|
146 |
*
|
147 |
* @return array New settings
|
148 |
+
* @since 2.0
|
149 |
+
*
|
150 |
*/
|
151 |
+
function wpp_settings_sanitize($input = array())
|
152 |
+
{
|
153 |
|
154 |
+
global $wpp_settings;
|
155 |
|
156 |
+
if (empty($_POST['_wp_http_referer'])) {
|
157 |
+
return $input;
|
158 |
+
}
|
159 |
|
160 |
+
parse_str($_POST['_wp_http_referer'], $referrer);
|
161 |
|
162 |
+
$settings = wpp_get_registered_settings();
|
163 |
+
$tab = isset($referrer['tab']) ? $referrer['tab'] : 'core';
|
164 |
|
165 |
+
$input = $input ? $input : array();
|
166 |
+
$input = apply_filters('wpp_settings_' . $tab . '_sanitize', $input);
|
167 |
|
168 |
+
// Loop through each setting being saved and pass it through a sanitization filter
|
169 |
+
foreach ($input as $key => $value) {
|
170 |
|
171 |
+
// Get the setting type (checkbox, select, etc)
|
172 |
+
$type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false;
|
173 |
|
174 |
+
if ($type) {
|
175 |
+
// Field type specific filter
|
176 |
+
$input[$key] = apply_filters('wpp_settings_sanitize_' . $type, $value, $key);
|
177 |
+
}
|
178 |
|
179 |
+
// General filter
|
180 |
+
$input[$key] = apply_filters('wpp_settings_sanitize', $value, $key);
|
181 |
+
}
|
182 |
|
183 |
|
184 |
+
// Loop through the whitelist and unset any that are empty for the tab being saved
|
185 |
+
if (!empty($settings[$tab])) {
|
186 |
+
foreach ($settings[$tab] as $key => $value) {
|
187 |
|
188 |
+
// settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
|
189 |
+
if (is_numeric($key)) {
|
190 |
+
$key = $value['id'];
|
191 |
+
}
|
192 |
|
193 |
+
if (empty($input[$key])) {
|
194 |
+
unset($wpp_settings[$key]);
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
|
199 |
+
// Merge our new settings with the existing
|
200 |
+
$output = array_merge($wpp_settings, $input);
|
201 |
|
202 |
+
return $output;
|
203 |
|
204 |
}
|
205 |
|
206 |
/**
|
207 |
* Get settings fields
|
208 |
*
|
|
|
209 |
* @return array Fields
|
210 |
+
* @since 2.0
|
211 |
*/
|
212 |
+
function wpp_get_registered_settings()
|
213 |
+
{
|
214 |
+
$options = array(
|
215 |
+
'enable' => __('Enable', 'wp-parsidate'),
|
216 |
+
'disable' => __('Disable', 'wp-parsidate')
|
217 |
+
);
|
218 |
+
$settings = apply_filters('wpp_registered_settings', array(
|
219 |
+
'core' => apply_filters('wpp_core_settings', array(
|
220 |
+
'admin_lang' => array(
|
221 |
+
'id' => 'admin_lang',
|
222 |
+
'name' => __('Change Locale in admin', 'wp-parsidate'),
|
223 |
+
'type' => 'radio',
|
224 |
+
'options' => $options,
|
225 |
+
'std' => 'disable',
|
226 |
+
'desc' => __('This option change WordPress locale to Persian in Admin', 'wp-parsidate')
|
227 |
+
),
|
228 |
+
'user_lang' => array(
|
229 |
+
'id' => 'user_lang',
|
230 |
+
'name' => __('Change Locale in theme', 'wp-parsidate'),
|
231 |
+
'type' => 'radio',
|
232 |
+
'options' => $options,
|
233 |
+
'std' => 'disable',
|
234 |
+
'desc' => __('This option change WordPress locale to Persian in theme', 'wp-parsidate')
|
235 |
+
),
|
236 |
+
'persian_date' => array(
|
237 |
+
'id' => 'persian_date',
|
238 |
+
'name' => __('Shamsi date', 'wp-parsidate'),
|
239 |
+
'type' => 'radio',
|
240 |
+
'options' => $options,
|
241 |
+
'std' => 'disable',
|
242 |
+
'desc' => __('By enabling this, Dates will convert to Shamsi (Jalali) dates', 'wp-parsidate')
|
243 |
+
),
|
244 |
+
'submenu_move' => array(
|
245 |
+
'id' => 'submenu_move',
|
246 |
+
'name' => __('Move page to submenu?', 'wp-parsidate'),
|
247 |
+
'type' => 'radio',
|
248 |
+
'options' => $options,
|
249 |
+
'std' => 'disable',
|
250 |
+
'desc' => __('With enabling this option, page item will be moved to Settings menu as submenu.', 'wp-parsidate')
|
251 |
+
),
|
252 |
+
)),
|
253 |
+
'conv' => apply_filters('wpp_conv_settings', array(
|
254 |
+
'conv_nums' => array(
|
255 |
+
'id' => 'conv_nums',
|
256 |
+
'name' => __('Persian digits', 'wp-parsidate'),
|
257 |
+
'type' => 'header'
|
258 |
+
),
|
259 |
+
'conv_page_title' => array(
|
260 |
+
'id' => 'conv_page_title',
|
261 |
+
'name' => __('Page title', 'wp-parsidate'),
|
262 |
+
'type' => 'radio',
|
263 |
+
'options' => $options,
|
264 |
+
'std' => 'disable'
|
265 |
+
),
|
266 |
+
'conv_title' => array(
|
267 |
+
'id' => 'conv_title',
|
268 |
+
'name' => __('Post title', 'wp-parsidate'),
|
269 |
+
'type' => 'radio',
|
270 |
+
'options' => $options,
|
271 |
+
'std' => 'disable'
|
272 |
+
),
|
273 |
+
'conv_contents' => array(
|
274 |
+
'id' => 'conv_contents',
|
275 |
+
'name' => __('Post content', 'wp-parsidate'),
|
276 |
+
'type' => 'radio',
|
277 |
+
'options' => $options,
|
278 |
+
'std' => 'enable'
|
279 |
+
),
|
280 |
+
'conv_excerpt' => array(
|
281 |
+
'id' => 'conv_excerpt',
|
282 |
+
'name' => __('Post excerpt', 'wp-parsidate'),
|
283 |
+
'type' => 'radio',
|
284 |
+
'options' => $options,
|
285 |
+
'std' => 'disable'
|
286 |
+
),
|
287 |
+
'conv_comments' => array(
|
288 |
+
'id' => 'conv_comments',
|
289 |
+
'name' => __('Comments text', 'wp-parsidate'),
|
290 |
+
'type' => 'radio',
|
291 |
+
'options' => $options,
|
292 |
+
'std' => 'disable'
|
293 |
+
),
|
294 |
+
'conv_comment_count' => array(
|
295 |
+
'id' => 'conv_comment_count',
|
296 |
+
'name' => __('Comments count', 'wp-parsidate'),
|
297 |
+
'type' => 'radio',
|
298 |
+
'options' => $options,
|
299 |
+
'std' => 'disable'
|
300 |
+
),
|
301 |
+
'conv_dates' => array(
|
302 |
+
'id' => 'conv_dates',
|
303 |
+
'name' => __('Dates', 'wp-parsidate'),
|
304 |
+
'type' => 'radio',
|
305 |
+
'options' => $options,
|
306 |
+
'std' => 'disable'
|
307 |
+
),
|
308 |
+
'conv_cats' => array(
|
309 |
+
'id' => 'conv_cats',
|
310 |
+
'name' => __('Categories', 'wp-parsidate'),
|
311 |
+
'type' => 'radio',
|
312 |
+
'options' => $options,
|
313 |
+
'std' => 'disable'
|
314 |
+
),
|
315 |
+
'sep' => array(
|
316 |
+
'id' => 'sep',
|
317 |
+
'type' => 'header'
|
318 |
+
),
|
319 |
+
'conv_arabic' => array(
|
320 |
+
'id' => 'conv_arabic',
|
321 |
+
'name' => __('Fix arabic characters', 'wp-parsidate'),
|
322 |
+
'type' => 'radio',
|
323 |
+
'options' => $options,
|
324 |
+
'std' => 'disable',
|
325 |
+
'desc' => __('Fixes arabic characters caused by wrong keyboard layouts', 'wp-parsidate')
|
326 |
+
),
|
327 |
+
'conv_permalinks' => array(
|
328 |
+
'id' => 'conv_permalinks',
|
329 |
+
'name' => __('Fix permalinks dates', 'wp-parsidate'),
|
330 |
+
'type' => 'radio',
|
331 |
+
'options' => $options,
|
332 |
+
'std' => 'disable',
|
333 |
+
'desc' => __('By enabling this, dates in permalinks converted to Shamsi (Jalali) date', 'wp-parsidate')
|
334 |
+
),
|
335 |
+
'sep_font' => array(
|
336 |
+
'id' => 'sep_font',
|
337 |
+
'type' => 'header'
|
338 |
+
)
|
339 |
+
)),
|
340 |
+
'plugins' => apply_filters('wpp_plugins_compability_settings', array())
|
341 |
+
));
|
342 |
+
|
343 |
+
return $settings;
|
344 |
}
|
345 |
|
346 |
/* Form Callbacks Made by EDD Development Team */
|
347 |
+
function wpp_header_callback($args)
|
348 |
+
{
|
349 |
+
echo '<hr/>';
|
350 |
}
|
351 |
|
352 |
+
function wpp_checkbox_callback($args)
|
353 |
+
{
|
354 |
+
global $wpp_settings;
|
355 |
|
356 |
+
$checked = isset($wpp_settings[$args['id']]) ? checked(1, $wpp_settings[$args['id']], false) : '';
|
357 |
+
$html = '<input type="checkbox" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="1" ' . $checked . '/>';
|
358 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
359 |
|
360 |
+
echo $html;
|
361 |
}
|
362 |
|
363 |
+
function wpp_multicheck_callback($args)
|
364 |
+
{
|
365 |
+
global $wpp_settings;
|
366 |
+
|
367 |
+
$html = '';
|
368 |
+
foreach ($args['options'] as $key => $value) {
|
369 |
+
$option_name = $args['id'] . '-' . $key;
|
370 |
+
wpp_checkbox_callback(array(
|
371 |
+
'id' => $option_name,
|
372 |
+
'desc' => $value
|
373 |
+
));
|
374 |
+
echo '<br>';
|
375 |
+
}
|
376 |
+
|
377 |
+
echo $html;
|
378 |
}
|
379 |
|
380 |
+
function wpp_radio_callback($args)
|
381 |
+
{
|
382 |
+
global $wpp_settings;
|
383 |
|
384 |
+
foreach ($args['options'] as $key => $option) :
|
385 |
+
$checked = false;
|
386 |
|
387 |
+
if (isset($wpp_settings[$args['id']]) && $wpp_settings[$args['id']] == $key) {
|
388 |
+
$checked = true;
|
389 |
+
} elseif (isset($args['std']) && $args['std'] == $key && !isset($wpp_settings[$args['id']])) {
|
390 |
+
$checked = true;
|
391 |
+
}
|
392 |
|
393 |
+
echo '<input name="wpp_settings[' . $args['id'] . ']"" id="wpp_settings[' . $args['id'] . '][' . $key . ']" type="radio" value="' . $key . '" ' . checked(true, $checked, false) . '/>';
|
394 |
+
echo '<label for="wpp_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label> ';
|
395 |
+
endforeach;
|
396 |
|
397 |
+
echo '<p class="description">' . $args['desc'] . '</p>';
|
398 |
}
|
399 |
|
400 |
+
function wpp_text_callback($args)
|
401 |
+
{
|
402 |
+
global $wpp_settings;
|
403 |
|
404 |
+
if (isset($wpp_settings[$args['id']])) {
|
405 |
+
$value = $wpp_settings[$args['id']];
|
406 |
+
} else {
|
407 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
408 |
+
}
|
409 |
|
410 |
+
$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
|
411 |
+
$html = '<input type="text" class="' . $size . '-text" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
|
412 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
413 |
|
414 |
+
echo $html;
|
415 |
}
|
416 |
|
417 |
+
function wpp_number_callback($args)
|
418 |
+
{
|
419 |
+
global $wpp_settings;
|
420 |
|
421 |
+
if (isset($wpp_settings[$args['id']])) {
|
422 |
+
$value = $wpp_settings[$args['id']];
|
423 |
+
} else {
|
424 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
425 |
+
}
|
426 |
|
427 |
+
$max = isset($args['max']) ? $args['max'] : 999999;
|
428 |
+
$min = isset($args['min']) ? $args['min'] : 0;
|
429 |
+
$step = isset($args['step']) ? $args['step'] : 1;
|
430 |
|
431 |
+
$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
|
432 |
+
$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)) . '"/>';
|
433 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
434 |
|
435 |
+
echo $html;
|
436 |
}
|
437 |
|
438 |
+
function wpp_textarea_callback($args)
|
439 |
+
{
|
440 |
+
global $wpp_settings;
|
441 |
|
442 |
+
if (isset($wpp_settings[$args['id']])) {
|
443 |
+
$value = $wpp_settings[$args['id']];
|
444 |
+
} else {
|
445 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
446 |
+
}
|
447 |
|
448 |
+
$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
|
449 |
+
$html = '<textarea class="large-text" cols="50" rows="5" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
|
450 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
451 |
|
452 |
+
echo $html;
|
453 |
}
|
454 |
|
455 |
+
function wpp_password_callback($args)
|
456 |
+
{
|
457 |
+
global $wpp_settings;
|
458 |
|
459 |
+
if (isset($wpp_settings[$args['id']])) {
|
460 |
+
$value = $wpp_settings[$args['id']];
|
461 |
+
} else {
|
462 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
463 |
+
}
|
464 |
|
465 |
+
$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
|
466 |
+
$html = '<input type="password" class="' . $size . '-text" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr($value) . '"/>';
|
467 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
468 |
|
469 |
+
echo $html;
|
470 |
}
|
471 |
|
472 |
+
function wpp_missing_callback($args)
|
473 |
+
{
|
474 |
+
echo '–';
|
475 |
|
476 |
+
return false;
|
477 |
}
|
478 |
|
479 |
|
480 |
+
function wpp_select_callback($args)
|
481 |
+
{
|
482 |
+
global $wpp_settings;
|
483 |
|
484 |
+
if (isset($wpp_settings[$args['id']])) {
|
485 |
+
$value = $wpp_settings[$args['id']];
|
486 |
+
} else {
|
487 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
488 |
+
}
|
489 |
|
490 |
+
$html = '<select id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']"/>';
|
491 |
|
492 |
+
foreach ($args['options'] as $option => $name) :
|
493 |
+
$selected = selected($option, $value, false);
|
494 |
+
$html .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
|
495 |
+
endforeach;
|
496 |
|
497 |
+
$html .= '</select>';
|
498 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
499 |
|
500 |
+
echo $html;
|
501 |
}
|
502 |
|
503 |
+
function wpp_color_select_callback($args)
|
504 |
+
{
|
505 |
+
global $wpp_settings;
|
506 |
|
507 |
+
if (isset($wpp_settings[$args['id']])) {
|
508 |
+
$value = $wpp_settings[$args['id']];
|
509 |
+
} else {
|
510 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
511 |
+
}
|
512 |
|
513 |
+
$html = '<select id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']"/>';
|
514 |
|
515 |
+
foreach ($args['options'] as $option => $color) :
|
516 |
+
$selected = selected($option, $value, false);
|
517 |
+
$html .= '<option value="' . $option . '" ' . $selected . '>' . $color['label'] . '</option>';
|
518 |
+
endforeach;
|
519 |
|
520 |
+
$html .= '</select>';
|
521 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
522 |
|
523 |
+
echo $html;
|
524 |
}
|
525 |
|
526 |
+
function wpp_rich_editor_callback($args)
|
527 |
+
{
|
528 |
+
global $wpp_settings, $wp_version;
|
529 |
|
530 |
+
if (isset($wpp_settings[$args['id']])) {
|
531 |
+
$value = $wpp_settings[$args['id']];
|
532 |
+
} else {
|
533 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
534 |
+
}
|
535 |
|
536 |
+
if ($wp_version >= 3.3 && function_exists('wp_editor')) {
|
537 |
+
$html = wp_editor(stripslashes($value), 'wpp_settings[' . $args['id'] . ']', array('textarea_name' => 'wpp_settings[' . $args['id'] . ']'));
|
538 |
+
} else {
|
539 |
+
$html = '<textarea class="large-text" rows="10" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
|
540 |
+
}
|
541 |
|
542 |
+
$html .= '<br/><label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
543 |
|
544 |
+
echo $html;
|
545 |
}
|
546 |
|
547 |
+
function wpp_upload_callback($args)
|
548 |
+
{
|
549 |
+
global $wpp_settings;
|
550 |
|
551 |
+
if (isset($wpp_settings[$args['id']])) {
|
552 |
+
$value = $wpp_settings[$args['id']];
|
553 |
+
} else {
|
554 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
555 |
+
}
|
556 |
|
557 |
+
$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
|
558 |
+
$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)) . '"/>';
|
559 |
+
$html .= '<span> <input type="button" class="wpp_settings_upload_button button-secondary" value="' . __('Upload File', 'wpp') . '"/></span>';
|
560 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
561 |
|
562 |
+
echo $html;
|
563 |
}
|
564 |
|
565 |
+
function wpp_color_callback($args)
|
566 |
+
{
|
567 |
+
global $wpp_settings;
|
568 |
|
569 |
+
if (isset($wpp_settings[$args['id']])) {
|
570 |
+
$value = $wpp_settings[$args['id']];
|
571 |
+
} else {
|
572 |
+
$value = isset($args['std']) ? $args['std'] : '';
|
573 |
+
}
|
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 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
@@ -4,96 +4,101 @@
|
|
4 |
* @author lord_viper
|
5 |
* @copyright 2013
|
6 |
*/
|
7 |
-
class parsidate_archive extends WP_Widget
|
8 |
-
|
9 |
-
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
25 |
|
26 |
-
|
27 |
<p style="text-align:right; direction:rtl">
|
28 |
<label></label>
|
29 |
-
<input style="width: 200px;" id="<?php echo $this->get_field_id(
|
30 |
-
name="<?php echo $this->get_field_name(
|
31 |
-
value="<?php echo(
|
32 |
<br/>
|
33 |
<label><input type="radio" id="parsidate_archive_type1"
|
34 |
-
name="<?php echo $this->get_field_name(
|
35 |
-
value="yearly" <?php checked(
|
36 |
-
for="parsidate_archive_type1"><?php _e(
|
37 |
<label><input type="radio" id="parsidate_archive_type2"
|
38 |
-
name="<?php echo $this->get_field_name(
|
39 |
-
value="monthly" <?php checked(
|
40 |
</label><br/>
|
41 |
<label><input type="radio" id="parsidate_archive_type3"
|
42 |
-
name="<?php echo $this->get_field_name(
|
43 |
-
value="daily" <?php checked(
|
44 |
</label><br/>
|
45 |
<br/>
|
46 |
-
<input type="checkbox" name="<?php echo $this->get_field_name(
|
47 |
-
id="<?php echo $this->get_field_id(
|
48 |
-
value="1" <?php checked(
|
49 |
-
<label for="<?php echo $this->get_field_id(
|
50 |
<br/>
|
51 |
-
<input type="checkbox" name="<?php echo $this->get_field_name(
|
52 |
-
id="<?php echo $this->get_field_id(
|
53 |
-
value="1" <?php echo checked(
|
54 |
-
<label for="<?php echo $this->get_field_id(
|
55 |
</p>
|
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 |
}
|
4 |
* @author lord_viper
|
5 |
* @copyright 2013
|
6 |
*/
|
7 |
+
class parsidate_archive extends WP_Widget
|
8 |
+
{
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
global $wp_version;
|
12 |
|
13 |
+
// backwards compability
|
14 |
+
if (version_compare($wp_version, '4.3', '>=')) {
|
15 |
+
parent::__construct(false, __('Jalali Date Archives', 'wp-parsidate'), 'description=' . __('Jalali Date Archives', 'wp-parsidate'));
|
16 |
+
} else {
|
17 |
+
parent::WP_Widget(false, __('Jalali Date Archives', 'wp-parsidate'), 'description=' . __('Jalali Date Archives', 'wp-parsidate'));
|
18 |
+
}
|
19 |
+
}
|
20 |
|
21 |
+
public function form($instance)
|
22 |
+
{
|
23 |
+
global $wpp_settings;
|
24 |
+
$type = isset($instance['parsidate_archive_type']) ? $instance['parsidate_archive_type'] : 'monthly';
|
25 |
+
$instance['parsidate_archive_title'] = isset($instance['parsidate_archive_title']) ? strip_tags($instance['parsidate_archive_title']) : __('Jalali Date Archives', 'wp-parsidate');
|
26 |
+
$instance['parsidate_archive_count'] = isset($instance['parsidate_archive_count']) ? $instance['parsidate_archive_count'] : 0;
|
27 |
+
$instance['parsidate_archive_list'] = isset($instance['parsidate_archive_list']) ? $instance['parsidate_archive_list'] : 0;
|
28 |
|
29 |
+
?>
|
30 |
<p style="text-align:right; direction:rtl">
|
31 |
<label></label>
|
32 |
+
<input style="width: 200px;" id="<?php echo $this->get_field_id('parsidate_archive_title'); ?>"
|
33 |
+
name="<?php echo $this->get_field_name('parsidate_archive_title'); ?>" type="text"
|
34 |
+
value="<?php echo(empty($instance['parsidate_archive_title']) ? __('Jalali Date Archives', 'wp-parsidate') : $instance['parsidate_archive_title']) ?>"/>
|
35 |
<br/>
|
36 |
<label><input type="radio" id="parsidate_archive_type1"
|
37 |
+
name="<?php echo $this->get_field_name('parsidate_archive_type'); ?>"
|
38 |
+
value="yearly" <?php checked($type, 'yearly'); ?>/><label
|
39 |
+
for="parsidate_archive_type1"><?php _e('Yearly', 'wp-parsidate') ?></label><br/>
|
40 |
<label><input type="radio" id="parsidate_archive_type2"
|
41 |
+
name="<?php echo $this->get_field_name('parsidate_archive_type'); ?>"
|
42 |
+
value="monthly" <?php checked($type, 'monthly'); ?>/><?php _e('Monthly', 'wp-parsidate') ?>
|
43 |
</label><br/>
|
44 |
<label><input type="radio" id="parsidate_archive_type3"
|
45 |
+
name="<?php echo $this->get_field_name('parsidate_archive_type'); ?>"
|
46 |
+
value="daily" <?php checked($type, 'daily'); ?>/><?php _e('Daily', 'wp-parsidate') ?>
|
47 |
</label><br/>
|
48 |
<br/>
|
49 |
+
<input type="checkbox" name="<?php echo $this->get_field_name('parsidate_archive_count'); ?>"
|
50 |
+
id="<?php echo $this->get_field_id('parsidate_archive_count'); ?>"
|
51 |
+
value="1" <?php checked($instance['parsidate_archive_count'], 1, true); ?>/>
|
52 |
+
<label for="<?php echo $this->get_field_id('parsidate_archive_count'); ?>"><?php _e('Show post counts', 'wp-parsidate') ?></label>
|
53 |
<br/>
|
54 |
+
<input type="checkbox" name="<?php echo $this->get_field_name('parsidate_archive_list'); ?>"
|
55 |
+
id="<?php echo $this->get_field_id('parsidate_archive_list'); ?>"
|
56 |
+
value="1" <?php echo checked($instance['parsidate_archive_list'], 1, true); ?>/>
|
57 |
+
<label for="<?php echo $this->get_field_id('parsidate_archive_list'); ?>"><?php _e('Display as dropdown', 'wp-parsidate') ?></label>
|
58 |
</p>
|
59 |
+
<?php
|
60 |
+
if ($wpp_settings['conv_permalinks'] == 'disable') {
|
61 |
+
echo "<p style='color: #ff8153'>" . __('For use widget, active "Fix permalinks dates" option in plugin settings.', 'wp-parsidate') . "</p>";
|
62 |
+
}
|
63 |
+
}
|
64 |
|
65 |
+
public function update($new_instance, $old_instance)
|
66 |
+
{
|
67 |
+
$instance = $old_instance;
|
68 |
+
$instance['parsidate_archive_title'] = isset($new_instance['parsidate_archive_title']) ? strip_tags($new_instance['parsidate_archive_title']) : __('Jalali Date Archives', 'wp-parsidate');
|
69 |
+
$instance['parsidate_archive_count'] = isset($new_instance['parsidate_archive_count']) ? $new_instance['parsidate_archive_count'] : 0;
|
70 |
+
$instance['parsidate_archive_list'] = isset($new_instance['parsidate_archive_list']) ? $new_instance['parsidate_archive_list'] : 0;
|
71 |
+
$instance['parsidate_archive_type'] = isset($new_instance['parsidate_archive_type']) ? $new_instance['parsidate_archive_type'] : 'monthly';
|
72 |
|
73 |
+
return $instance;
|
74 |
+
}
|
75 |
|
76 |
+
public function widget($args, $instance)
|
77 |
+
{
|
78 |
+
global $wpp_settings;
|
79 |
+
if ($wpp_settings['conv_permalinks'] == 'disable') {
|
80 |
+
return;
|
81 |
+
}
|
82 |
|
83 |
+
$type = isset($instance['parsidate_archive_type']) ? $instance['parsidate_archive_type'] : 'monthly';
|
84 |
+
$title = isset($instance['parsidate_archive_title']) ? $instance['parsidate_archive_title'] : __('Jalali Date Archives', 'wp-parsidate');
|
85 |
+
$post_count = isset($instance['parsidate_archive_count']) ? $instance['parsidate_archive_count'] : false;
|
86 |
+
$ddl_style = isset($instance['parsidate_archive_list']) ? $instance['parsidate_archive_list'] : false;
|
87 |
|
88 |
+
echo $args['before_widget'];
|
89 |
+
if (!empty($instance['parsidate_archive_title'])) {
|
90 |
+
echo $args['before_title'] . apply_filters('widget_title', $instance['parsidate_archive_title']) . $args['after_title'];
|
91 |
+
}
|
92 |
|
93 |
+
if ($ddl_style) {
|
94 |
+
echo "<select name='parsidate_archive_list' onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value='0'>" . esc_attr($title) . "</option>";
|
95 |
+
wp_get_parchives("type=$type&format=option&show_post_count=$post_count");
|
96 |
+
echo '</select>';
|
97 |
+
} else {
|
98 |
+
echo '<ul>';
|
99 |
+
wpp_get_archives("type=$type&show_post_count=$post_count");
|
100 |
+
echo '</ul>';
|
101 |
+
}
|
102 |
+
echo $args['after_widget'];
|
103 |
+
}
|
104 |
}
|
includes/widget/widget_calendar.php
CHANGED
@@ -4,50 +4,53 @@
|
|
4 |
* @author lord_viper
|
5 |
* @copyright 2013
|
6 |
*/
|
7 |
-
class parsidate_calendar extends WP_Widget
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
20 |
<p style="text-align:right; direction:rtl">
|
21 |
-
<label><?php _e(
|
22 |
-
<input style="width: 200px;" id="<?php echo $this->get_field_id(
|
23 |
-
name="<?php echo $this->get_field_name(
|
24 |
-
value="<?php echo(
|
25 |
</p>
|
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 |
-
?>
|
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 |
|
19 |
+
public function form($instance)
|
20 |
+
{
|
21 |
+
global $wpp_settings;
|
22 |
+
?>
|
23 |
<p style="text-align:right; direction:rtl">
|
24 |
+
<label><?php _e('Title:', 'wp-parsidate') ?></label>
|
25 |
+
<input style="width: 200px;" id="<?php echo $this->get_field_id('parsidate_calendar_title'); ?>"
|
26 |
+
name="<?php echo $this->get_field_name('parsidate_calendar_title'); ?>" type="text"
|
27 |
+
value="<?php echo(empty($instance['parsidate_calendar_title']) ? __('Jalali Date Calender', 'wp-parsidate') : $instance['parsidate_calendar_title']) ?>"/>
|
28 |
</p>
|
29 |
+
<?php
|
30 |
+
if ($wpp_settings['conv_permalinks'] == 'disable') {
|
31 |
+
echo "<p style='color: #ff8153'>" . __('For use widget, active "Fix permalinks dates" option in plugin settings.', 'wp-parsidate') . "</p>";
|
32 |
+
}
|
33 |
+
}
|
34 |
|
35 |
+
public function update($new_instance, $old_instance)
|
36 |
+
{
|
37 |
+
$instance = $old_instance;
|
38 |
+
$instance['parsidate_calendar_title'] = strip_tags($new_instance['parsidate_calendar_title']);
|
39 |
|
40 |
+
return $instance;
|
41 |
+
}
|
42 |
|
43 |
+
public function widget($args, $instance)
|
44 |
+
{
|
45 |
+
global $wpp_settings;
|
46 |
+
if ($wpp_settings['conv_permalinks'] == 'disable') {
|
47 |
+
return;
|
48 |
+
}
|
49 |
+
echo $args['before_widget'];
|
50 |
+
if (!empty($instance['parsidate_calendar_title'])) {
|
51 |
+
echo $args['before_title'] . apply_filters('widget_title', $instance['parsidate_calendar_title']) . $args['after_title'];
|
52 |
+
}
|
53 |
+
wpp_get_calendar();
|
54 |
+
echo $args['after_widget'];
|
55 |
+
}
|
56 |
+
}
|
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Parsi Date ===
|
2 |
-
Contributors: lord_viper, man4toman, parselearn, alirdn, saeedfard
|
3 |
-
Donate link:
|
4 |
Tags: shamsi, wp-parsi, wpparsi, persian, parsi, farsi, jalali, date, calendar, i18n, l10n, Iran, Iranian, parsidate, rtl, gutenberg
|
5 |
-
Requires at least: 3
|
6 |
-
Tested up to: 5.
|
7 |
-
Stable tag: 3.0.
|
8 |
|
9 |
Persian date support for WordPress
|
10 |
|
@@ -44,6 +44,13 @@ List of some features:
|
|
44 |
|
45 |
== Changelog ==
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
= 3.0.1 =
|
48 |
* The Woocommerce hook has been temporarily disabled
|
49 |
|
1 |
=== Parsi Date ===
|
2 |
+
Contributors: lord_viper, man4toman, parselearn, alirdn, saeedfard, iehsanir
|
3 |
+
Donate link: https://wp-parsi.com/support/
|
4 |
Tags: shamsi, wp-parsi, wpparsi, persian, parsi, farsi, jalali, date, calendar, i18n, l10n, Iran, Iranian, parsidate, rtl, gutenberg
|
5 |
+
Requires at least: 5.3
|
6 |
+
Tested up to: 5.3
|
7 |
+
Stable tag: 3.0.2
|
8 |
|
9 |
Persian date support for WordPress
|
10 |
|
44 |
|
45 |
== Changelog ==
|
46 |
|
47 |
+
= 3.0.2 =
|
48 |
+
* Now we support WordPress 5.3!
|
49 |
+
* Replace/add wp_date instead old function
|
50 |
+
* Small fix in Woocommerce dates
|
51 |
+
* Fix date in media files
|
52 |
+
* All core codes cleaned and beautified
|
53 |
+
|
54 |
= 3.0.1 =
|
55 |
* The Woocommerce hook has been temporarily disabled
|
56 |
|
wp-parsidate.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: WP-Parsidate
|
4 |
-
* Version: 3.0.
|
5 |
-
* Plugin URI:
|
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/
|
@@ -50,154 +50,160 @@
|
|
50 |
*/
|
51 |
|
52 |
|
53 |
-
if (
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
}
|
202 |
|
203 |
return WP_Parsidate::get_instance();
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: WP-Parsidate
|
4 |
+
* Version: 3.0.2
|
5 |
+
* Plugin URI: https://wp-parsi.com/support/
|
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/
|
50 |
*/
|
51 |
|
52 |
|
53 |
+
if (!defined('ABSPATH')) exit; //No direct access allowed
|
54 |
+
|
55 |
+
final class WP_Parsidate
|
56 |
+
{
|
57 |
+
/**
|
58 |
+
* @var WP_Parsidate Class instance
|
59 |
+
*/
|
60 |
+
public static $instance = null;
|
61 |
+
|
62 |
+
private function __construct()
|
63 |
+
{
|
64 |
+
$this->define_const();
|
65 |
+
$this->setup_vars();
|
66 |
+
$this->include_files();
|
67 |
+
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'parsi_settings_link'));
|
68 |
+
add_action('widgets_init', array($this, 'register_widget'));
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Sets up constants for plugin
|
73 |
+
*
|
74 |
+
* @return void
|
75 |
+
* @since 2.0
|
76 |
+
*/
|
77 |
+
private function define_const()
|
78 |
+
{
|
79 |
+
if (!defined('WP_PARSI_ROOT')) {
|
80 |
+
define('WP_PARSI_ROOT', __FILE__);
|
81 |
+
}
|
82 |
+
|
83 |
+
if (!defined('WP_PARSI_DIR')) {
|
84 |
+
define('WP_PARSI_DIR', plugin_dir_path(WP_PARSI_ROOT));
|
85 |
+
}
|
86 |
+
|
87 |
+
if (!defined('WP_PARSI_URL')) {
|
88 |
+
define('WP_PARSI_URL', plugin_dir_url(WP_PARSI_ROOT));
|
89 |
+
}
|
90 |
+
|
91 |
+
if (!defined('WP_PARSI_VER')) {
|
92 |
+
define('WP_PARSI_VER', '2.2');
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Sets up global variables
|
98 |
+
*
|
99 |
+
* @return void
|
100 |
+
* @since 2.0
|
101 |
+
*/
|
102 |
+
private function setup_vars()
|
103 |
+
{
|
104 |
+
global $persian_month_names;
|
105 |
+
$persian_month_names = array(
|
106 |
+
'',
|
107 |
+
'فروردین',
|
108 |
+
'اردیبهشت',
|
109 |
+
'خرداد',
|
110 |
+
'تیر',
|
111 |
+
'مرداد',
|
112 |
+
'شهریور',
|
113 |
+
'مهر',
|
114 |
+
'آبان',
|
115 |
+
'آذر',
|
116 |
+
'دی',
|
117 |
+
'بهمن',
|
118 |
+
'اسفند'
|
119 |
+
);
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Includes files for plugin
|
124 |
+
*
|
125 |
+
* @return void
|
126 |
+
* @since 2.0
|
127 |
+
*/
|
128 |
+
public function include_files()
|
129 |
+
{
|
130 |
+
require_once(WP_PARSI_DIR . 'includes/settings.php');
|
131 |
+
global $wpp_settings;
|
132 |
+
$wpp_settings = wp_parsi_get_settings();
|
133 |
+
|
134 |
+
$files = array(
|
135 |
+
'parsidate',
|
136 |
+
'general',
|
137 |
+
'fixes-archive',
|
138 |
+
'fixes-permalinks',
|
139 |
+
'fixes-dates',
|
140 |
+
'fixes-misc',
|
141 |
+
'admin/styles-fix',
|
142 |
+
//'admin/datepicker-rtl',
|
143 |
+
'admin/gutenberg-jalali-calendar',
|
144 |
+
'admin/lists-fix',
|
145 |
+
'admin/widgets',
|
146 |
+
'fixes-calendar',
|
147 |
+
'fixes-archives',
|
148 |
+
'plugins/woocommerce',
|
149 |
+
//'plugins/fixes-woo',
|
150 |
+
'plugins/edd',
|
151 |
+
'plugins/disable',
|
152 |
+
'widget/widget_archive',
|
153 |
+
'widget/widget_calendar'
|
154 |
+
);
|
155 |
+
|
156 |
+
foreach ($files as $file) {
|
157 |
+
require_once(WP_PARSI_DIR . 'includes/' . $file . '.php');
|
158 |
+
}
|
159 |
+
|
160 |
+
if (get_locale() == 'fa_IR') {
|
161 |
+
load_textdomain('wp-parsidate', WP_PARSI_DIR . 'languages/fa_IR.mo');
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Returns an instance of WP_Parsidate class, makes instance if not exists
|
167 |
+
*
|
168 |
+
* @return WP_Parsidate Instance of WP_Parsidate
|
169 |
+
* @since 2.0
|
170 |
+
*/
|
171 |
+
public static function get_instance()
|
172 |
+
{
|
173 |
+
if (self::$instance == null) {
|
174 |
+
self::$instance = new WP_Parsidate();
|
175 |
+
}
|
176 |
+
|
177 |
+
return self::$instance;
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Add Setting Link To Install Plugin
|
182 |
+
*
|
183 |
+
* @param array $links
|
184 |
+
*
|
185 |
+
* @return array
|
186 |
+
*/
|
187 |
+
public static function parsi_settings_link($links)
|
188 |
+
{
|
189 |
+
$settings_link = array('<a href="' . menu_page_url('wp-parsi-settings', false) . '">' . __('settings', 'wp-parsidate') . '</a>');
|
190 |
+
|
191 |
+
return array_merge($links, $settings_link);
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Register Plugin Widgets
|
196 |
+
*
|
197 |
+
* @return boolean
|
198 |
+
* @since 2.0
|
199 |
+
*/
|
200 |
+
public function register_widget()
|
201 |
+
{
|
202 |
+
register_widget('parsidate_archive');
|
203 |
+
register_widget('parsidate_calendar');
|
204 |
+
|
205 |
+
return true;
|
206 |
+
}
|
207 |
}
|
208 |
|
209 |
return WP_Parsidate::get_instance();
|