wp-jalali - Version 5.0.0-RC3

Version Description

Download this release

Release Info

Developer mani_monaj
Plugin Icon 128x128 wp-jalali
Version 5.0.0-RC3
Comparing to
See all releases

Code changes from version 5.0.0-RC2 to 5.0.0-RC3

inc/wp-jalali-admin.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  /**
4
  * register admin menu
 
5
  */
6
  add_action('admin_menu', 'ztjalali_reg_admin_meun_fn');
7
 
@@ -74,9 +75,12 @@ function ztjalali_admin_save_option_page_fn() {
74
  add_action('admin_init', 'ztjalali_install_redirect');
75
 
76
  function ztjalali_install_redirect() {
77
- if (get_option('ztjalali_do_activation_redirect', false)) {
78
  delete_option('ztjalali_do_activation_redirect');
79
- wp_redirect(menu_page_url('ztjalali_help_page', FALSE));
 
 
 
80
  }
81
  }
82
 
2
 
3
  /**
4
  * register admin menu
5
+ * @see http://codex.wordpress.org/Administration_Menus
6
  */
7
  add_action('admin_menu', 'ztjalali_reg_admin_meun_fn');
8
 
75
  add_action('admin_init', 'ztjalali_install_redirect');
76
 
77
  function ztjalali_install_redirect() {
78
+ if (get_option('ztjalali_do_activation_redirect')) {
79
  delete_option('ztjalali_do_activation_redirect');
80
+ $help_page = menu_page_url('ztjalali_help_page', FALSE);
81
+ header('Location: '.$help_page);
82
+ wp_redirect();
83
+ die('');
84
  }
85
  }
86
 
inc/wp-jalali-filters.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
-
3
  /**
4
  * define filters
 
5
  */
6
  //load options
7
  global $ztjalali_option;
@@ -17,15 +17,11 @@ if ($ztjalali_option['force_timezone'])
17
  if ($ztjalali_option['change_date_to_jalali'])
18
  add_filter('date_i18n', 'ztjalali_ch_date_i18n', 111, 4);
19
 
20
- //if(!defined( 'WP_ADMIN' )){
21
  //jalali link
22
  if ($ztjalali_option['change_url_date_to_jalali']) {
23
  add_filter("post_link", "ztjalali_permalink_filter_fn", 10, 3);
24
  add_action('pre_get_posts', 'ztjalali_pre_get_posts_filter_fn');
25
  add_filter('posts_where', 'ztjalali_posts_where_filter_fn');
26
- // add_filter('year_link', 'ztjalali_year_link_filter_fn', 10, 2);
27
- // add_filter('month_link', 'ztjalali_month_link_filter_fn', 10, 3);
28
- // add_filter('day_link', 'ztjalali_day_link_filter_fn', 10, 4);
29
  }
30
  if ($ztjalali_option['save_changes_in_db']) {
31
  // change en number to persian number in db
@@ -94,6 +90,7 @@ if ($ztjalali_option['change_archive_title'])
94
 
95
  /**
96
  * force_locale filter fn
 
97
  */
98
  function ztjalali_force_locale() {
99
  return 'fa_IR';
@@ -146,6 +143,7 @@ function ztjalali_ch_archive_title($title, $sep, $seplocation) {
146
 
147
  /**
148
  * posts where filter handler
 
149
  */
150
  function ztjalali_posts_where_filter_fn($where) {
151
  global $wp_query, $wpdb, $pagenow;
@@ -277,6 +275,7 @@ function ztjalali_posts_where_filter_fn($where) {
277
  /**
278
  * pre get posts filter handler
279
  * @param object $post
 
280
  */
281
  function ztjalali_pre_get_posts_filter_fn($query) {
282
  global $wpdb;
@@ -425,6 +424,7 @@ function ztjalali_pre_get_posts_filter_fn($query) {
425
  * @param string $perma
426
  * @param string $post
427
  * @param string $leavename
 
428
  */
429
  function ztjalali_permalink_filter_fn($perma, $post, $leavename = false) {
430
  $rewritecode = array(
@@ -484,8 +484,8 @@ function ztjalali_permalink_filter_fn($perma, $post, $leavename = false) {
484
  $jdate = gregorian_to_jalali($date[0], $date[1], $date[2]);
485
  $rewritereplace = array(
486
  $jdate[0],
487
- $jdate[1],
488
- $jdate[2],
489
  $date[3],
490
  $date[4],
491
  $date[5],
@@ -499,18 +499,4 @@ function ztjalali_permalink_filter_fn($perma, $post, $leavename = false) {
499
  return user_trailingslashit($permalink, 'single');
500
  }
501
 
502
- //function ztjalali_year_link_filter_fn($link, $y) {
503
- // if ($y < 1700)
504
- // return;
505
- //
506
- //}
507
- //
508
- //function ztjalali_month_link_filter_fn($link, $y, $m) {
509
- //
510
- //}
511
- //
512
- //function ztjalali_day_link_filter_fn($link, $y, $m, $d) {
513
- //
514
- //}
515
-
516
  /* =================================================================== */
1
  <?php
 
2
  /**
3
  * define filters
4
+ * @see http://codex.wordpress.org/Plugin_API/Filter_Reference
5
  */
6
  //load options
7
  global $ztjalali_option;
17
  if ($ztjalali_option['change_date_to_jalali'])
18
  add_filter('date_i18n', 'ztjalali_ch_date_i18n', 111, 4);
19
 
 
20
  //jalali link
21
  if ($ztjalali_option['change_url_date_to_jalali']) {
22
  add_filter("post_link", "ztjalali_permalink_filter_fn", 10, 3);
23
  add_action('pre_get_posts', 'ztjalali_pre_get_posts_filter_fn');
24
  add_filter('posts_where', 'ztjalali_posts_where_filter_fn');
 
 
 
25
  }
26
  if ($ztjalali_option['save_changes_in_db']) {
27
  // change en number to persian number in db
90
 
91
  /**
92
  * force_locale filter fn
93
+ * @see http://codex.wordpress.org/Plugin_API/Filter_Reference/locale
94
  */
95
  function ztjalali_force_locale() {
96
  return 'fa_IR';
143
 
144
  /**
145
  * posts where filter handler
146
+ * @see wp-includes\query.php 2353
147
  */
148
  function ztjalali_posts_where_filter_fn($where) {
149
  global $wp_query, $wpdb, $pagenow;
275
  /**
276
  * pre get posts filter handler
277
  * @param object $post
278
+ * @see wp-includes\query.php 2353
279
  */
280
  function ztjalali_pre_get_posts_filter_fn($query) {
281
  global $wpdb;
424
  * @param string $perma
425
  * @param string $post
426
  * @param string $leavename
427
+ * @see wp-includes\link-template.php line 112
428
  */
429
  function ztjalali_permalink_filter_fn($perma, $post, $leavename = false) {
430
  $rewritecode = array(
484
  $jdate = gregorian_to_jalali($date[0], $date[1], $date[2]);
485
  $rewritereplace = array(
486
  $jdate[0],
487
+ sprintf('%02d', $jdate[1]), // add leading zero if necessary
488
+ sprintf('%02d', $jdate[2]),
489
  $date[3],
490
  $date[4],
491
  $date[5],
499
  return user_trailingslashit($permalink, 'single');
500
  }
501
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
502
  /* =================================================================== */
inc/wp-jalali-help-page.php CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  <div class="wrap about-wrap">
2
 
3
  <h1 id="ztjalali_wellcome">به وردپرس فارسی خوش آمدید</h1>
1
+ <?php
2
+ /**
3
+ * similar wordpress admin option page
4
+ */
5
+ ?>
6
  <div class="wrap about-wrap">
7
 
8
  <h1 id="ztjalali_wellcome">به وردپرس فارسی خوش آمدید</h1>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.wp-persian.com/donate
4
  Tags: Calendar Conversion, Persian, Farsi, Afghan, Tajik, Jalali, Date, Calendar, i18n, l10n
5
  Tested up to: 4.0.0
6
  Requires at least: 3.9
7
- Stable tag: 5.0.0-RC2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
4
  Tags: Calendar Conversion, Persian, Farsi, Afghan, Tajik, Jalali, Date, Calendar, i18n, l10n
5
  Tested up to: 4.0.0
6
  Requires at least: 3.9
7
+ Stable tag: 5.0.0-RC3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
widget/widget_archive.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
-
 
 
3
  class ztjalali_archive extends WP_Widget {
4
 
5
  function __construct() {
1
  <?php
2
+ /**
3
+ * @see : http://codex.wordpress.org/Widgets_API#Default_Usage
4
+ */
5
  class ztjalali_archive extends WP_Widget {
6
 
7
  function __construct() {
widget/widget_calendar.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
-
 
 
3
  class ztjalali_calendar extends WP_Widget {
4
 
5
  function __construct() {
1
  <?php
2
+ /**
3
+ * @see : http://codex.wordpress.org/Widgets_API#Default_Usage
4
+ */
5
  class ztjalali_calendar extends WP_Widget {
6
 
7
  function __construct() {
wp-jalali-functions.php CHANGED
@@ -1,4 +1,14 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
2
 
3
  /**
4
  * preg_replace callback for convert number to farsi
@@ -6,6 +16,7 @@
6
  * @param string $matches
7
  * @return string
8
  * @since 5.0.0
 
9
  */
10
  function ztjalali_convertToFarsi($matches) {
11
  global $ztjalali_option;
@@ -29,9 +40,11 @@ function ztjalali_convertToFarsi($matches) {
29
  * @param string $content
30
  * @return string
31
  * @since 5.0.0
 
32
  */
33
  function ztjalali_ch_number_to_persian($content) {
34
- return preg_replace_callback('/(?:&#\d{2,4};)|(\d+[\.\d]*)|(?:[a-z](?:[\x00-\x3B\x3D-\x7F]|<\s*[^>]+>)*)|<\s*[^>]+>/i', 'ztjalali_convertToFarsi', $content);
 
35
  }
36
  /* =================================================================== */
37
 
@@ -41,6 +54,7 @@ function ztjalali_ch_number_to_persian($content) {
41
  * @param string $str
42
  * @return string
43
  * @since 5.0.0
 
44
  */
45
  function ztjalali_english_num($str) {
46
  global $ztjalali_option;
@@ -61,6 +75,7 @@ function ztjalali_english_num($str) {
61
  * @param string $str
62
  * @return string
63
  * @since 5.0.0
 
64
  */
65
  function ztjalali_persian_num($str) {
66
  global $ztjalali_option;
@@ -80,6 +95,7 @@ function ztjalali_persian_num($str) {
80
  * @param string $content
81
  * @return string
82
  * @since 5.0.0
 
83
  */
84
  function ztjalali_ch_arabic_to_persian($content) {
85
  return str_replace(array('ي', 'ك', '٤', '٥', '٦', 'ة'), array('ی', 'ک', '۴', '۵', '۶', 'ه'), $content);
@@ -121,6 +137,7 @@ function ztjalali_get_short_week_name($gWeek = 0) {
121
  * @param int $year year
122
  * @return string
123
  * @since 5.0.0
 
124
  */
125
  function ztjalali_year_link($year) {
126
  global $ztjalali_option;
@@ -138,6 +155,7 @@ function ztjalali_year_link($year) {
138
  * @param int $month month
139
  * @return string
140
  * @since 5.0.0
 
141
  */
142
  function ztjalali_month_link($year, $month) {
143
  global $ztjalali_option;
@@ -156,13 +174,14 @@ function ztjalali_month_link($year, $month) {
156
  * @param int $day day
157
  * @return string
158
  * @since 5.0.0
 
159
  */
160
  function ztjalali_day_link($year, $month, $day) {
161
  global $ztjalali_option;
162
  if ($ztjalali_option['change_url_date_to_jalali']) {
163
  $jdate = gregorian_to_jalali($year, $month, $day);
164
- return get_month_link($jdate[0], $jdate[1], $jdate[2]);
165
  }
166
- return get_month_link($year, $month, $day);
167
  }
168
  /* =================================================================== */
1
  <?php
2
+ /**
3
+ * get plugin version
4
+ */
5
+ function ztjalali_get_plugin_version() {
6
+ if(!function_exists('get_plugin_data')) {
7
+ include(ABSPATH . "wp-admin/includes/plugin.php");
8
+ }
9
+ $plugin_data = get_plugin_data(dirname(__FILE__).DIRECTORY_SEPARATOR.'wp-jalali.php', FALSE, FALSE );
10
+ return $plugin_data['Version'];
11
+ }
12
 
13
  /**
14
  * preg_replace callback for convert number to farsi
16
  * @param string $matches
17
  * @return string
18
  * @since 5.0.0
19
+ * @see wp-jalali 4.5.3 : inc/farsinum-core.php line 5
20
  */
21
  function ztjalali_convertToFarsi($matches) {
22
  global $ztjalali_option;
40
  * @param string $content
41
  * @return string
42
  * @since 5.0.0
43
+ * @see wp-jalali 4.5.3 : inc/farsinum-core.php line 23
44
  */
45
  function ztjalali_ch_number_to_persian($content) {
46
+ // return preg_replace_callback('/(?:&#\d{2,4};)|((?:\&nbsp\;)*\d+(?:\&nbsp\;)*\d*\.*(?:\&nbsp\;)*\d*(?:\&nbsp\;)*\d*)|(?:[a-z](?:[\x00-\x3B\x3D-\x7F]|<\s*[^>]+>)*)|<\s*[^>]+>/i', 'ztjalali_convertToFarsi', $content);
47
+ return preg_replace_callback('/(?:&#\d{2,4};)|(\d+[\.\d]*)|(?:[a-z](?:[\x20-\x3B\x3D-\x7F]|<\s*[^>]+>)*)|<\s*[^>]+>/i', 'ztjalali_convertToFarsi', $content);
48
  }
49
  /* =================================================================== */
50
 
54
  * @param string $str
55
  * @return string
56
  * @since 5.0.0
57
+ * @see wp-jalali 4.5.3 : inc/farsinum-core.php line 27
58
  */
59
  function ztjalali_english_num($str) {
60
  global $ztjalali_option;
75
  * @param string $str
76
  * @return string
77
  * @since 5.0.0
78
+ * @see wp-jalali 4.5.3 : inc/farsinum-core.php line 27
79
  */
80
  function ztjalali_persian_num($str) {
81
  global $ztjalali_option;
95
  * @param string $content
96
  * @return string
97
  * @since 5.0.0
98
+ * @see wp-jalali 4.5.3 inc\yk-core.php 44
99
  */
100
  function ztjalali_ch_arabic_to_persian($content) {
101
  return str_replace(array('ي', 'ك', '٤', '٥', '٦', 'ة'), array('ی', 'ک', '۴', '۵', '۶', 'ه'), $content);
137
  * @param int $year year
138
  * @return string
139
  * @since 5.0.0
140
+ * @see wp-includes\link-template.php line 439
141
  */
142
  function ztjalali_year_link($year) {
143
  global $ztjalali_option;
155
  * @param int $month month
156
  * @return string
157
  * @since 5.0.0
158
+ * @see wp-includes\link-template.php line 471
159
  */
160
  function ztjalali_month_link($year, $month) {
161
  global $ztjalali_option;
174
  * @param int $day day
175
  * @return string
176
  * @since 5.0.0
177
+ * @see wp-includes\link-template.php line 508
178
  */
179
  function ztjalali_day_link($year, $month, $day) {
180
  global $ztjalali_option;
181
  if ($ztjalali_option['change_url_date_to_jalali']) {
182
  $jdate = gregorian_to_jalali($year, $month, $day);
183
+ return get_day_link($jdate[0], $jdate[1], $jdate[2]);
184
  }
185
+ return get_day_link($year, $month, $day);
186
  }
187
  /* =================================================================== */
wp-jalali-init.php CHANGED
@@ -10,8 +10,13 @@ function ztjalali_installer() {
10
  $options = include JALALI_DIR . 'wp-jalali-config.php';
11
  add_option('ztjalali_options', json_encode($options));
12
  }
13
- add_option('ztjalali_do_activation_redirect', true);
14
 
 
 
 
 
 
 
15
  }
16
 
17
  /* =================================================================== */
@@ -48,6 +53,21 @@ function ztjalali_get_old_options() {
48
  );
49
  }
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  /**
52
  * init function
53
  * @global type $ztjalali_option
@@ -101,6 +121,7 @@ function ztjalali_add_settings_link( $links ) {
101
 
102
  /**
103
  * Enqueue styles & scripts
 
104
  */
105
  // site -------------------------
106
  //add_action('wp_enqueue_scripts', 'ztjalali_reg_css_and_js');
@@ -143,6 +164,7 @@ function ztjalali_reg_theme_editor_css_and_js() {
143
 
144
  /**
145
  * Login Form modifiers
 
146
  */
147
  //add_filter('login_headerurl', 'ztjalali_login_url', 111);
148
  add_filter('login_headertitle', 'ztjalali_login_text', 111);
10
  $options = include JALALI_DIR . 'wp-jalali-config.php';
11
  add_option('ztjalali_options', json_encode($options));
12
  }
 
13
 
14
+ $current_version = ztjalali_get_plugin_version();
15
+ add_option('ztjalali_version',$current_version )
16
+ OR update_option('ztjalali_version', $current_version );
17
+
18
+ add_option('ztjalali_do_activation_redirect', true)
19
+ OR update_option('ztjalali_do_activation_redirect', true );
20
  }
21
 
22
  /* =================================================================== */
53
  );
54
  }
55
 
56
+ add_action('upgrader_process_complete','ztjalali_updater');
57
+
58
+ /**
59
+ * plugin update
60
+ */
61
+ function ztjalali_updater() {
62
+ $current_ver = ztjalali_get_plugin_version();
63
+ if($current_ver != get_option('ztjalali_version')){
64
+ ztjalali_installer();
65
+ }
66
+ }
67
+
68
+
69
+ /* =================================================================== */
70
+
71
  /**
72
  * init function
73
  * @global type $ztjalali_option
121
 
122
  /**
123
  * Enqueue styles & scripts
124
+ * @see http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
125
  */
126
  // site -------------------------
127
  //add_action('wp_enqueue_scripts', 'ztjalali_reg_css_and_js');
164
 
165
  /**
166
  * Login Form modifiers
167
+ * @see http://codex.wordpress.org/Plugin_API/Filter_Reference/login_headerurl
168
  */
169
  //add_filter('login_headerurl', 'ztjalali_login_url', 111);
170
  add_filter('login_headertitle', 'ztjalali_login_text', 111);
wp-jalali.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: wp-jalali
4
  Plugin URI: http://wp-persian.com/wp-jalali
5
  Description: Full Jalali calendar support for Wordpress and localization improvements for Persian/Afghan/Tajik users.
6
- Version: 5.0.0-RC2
7
  Author: Zakrot Web Solutions (in collaboration with WP-Persian team)
8
  Author URI: http://zakrot.com/
9
  Text Domain: ztjalali
3
  Plugin Name: wp-jalali
4
  Plugin URI: http://wp-persian.com/wp-jalali
5
  Description: Full Jalali calendar support for Wordpress and localization improvements for Persian/Afghan/Tajik users.
6
+ Version: 5.0.0-RC3
7
  Author: Zakrot Web Solutions (in collaboration with WP-Persian team)
8
  Author URI: http://zakrot.com/
9
  Text Domain: ztjalali