Changeset 1136401
- Timestamp:
- 04/16/2015 06:06:16 PM (11 years ago)
- Location:
- wp-farsi
- Files:
-
- 7 added
- 2 edited
-
tags/2.4.0 (added)
-
tags/2.4.0/index.php (added)
-
tags/2.4.0/license.html (added)
-
tags/2.4.0/pdate.php (added)
-
tags/2.4.0/wp-farsi.php (added)
-
tags/2.4.0/wpfa_admin.php (added)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/wp-farsi.php (modified) (7 diffs)
-
trunk/wpfa_admin.php (added)
Legend:
- Unmodified
- Added
- Removed
-
wp-farsi/trunk/readme.txt
r1133053 r1136401 43 43 44 44 == Changelog == 45 46 = 2.4.0 = 47 * Small improvements 48 * Fixed Bugs 45 49 46 50 = 2.3.3 = -
wp-farsi/trunk/wp-farsi.php
r1133053 r1136401 3 3 Plugin Name: WP-Farsi 4 4 Plugin URI: http://wordpress.org/extend/plugins/wp-farsi 5 Description: افزونهمبدل تاریخ میلادی وردپرس به خورشیدی، فارسی ساز، مبدل اعداد انگلیسی به فارسی، رفع مشکل هاست با زبان و تاریخ، سازگار با افزونههای مشابه.6 Author: Ali.Dbg 5 Description: مبدل تاریخ میلادی وردپرس به خورشیدی، فارسی ساز، مبدل اعداد انگلیسی به فارسی، رفع مشکل هاست با زبان و تاریخ، سازگار با افزونههای مشابه. 6 Author: Ali.Dbg 😉 7 7 Author URI: https://github.com/alidbg/wp-farsi 8 Version: 2. 3.38 Version: 2.4.0 9 9 License: GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html) 10 10 */ … … 12 12 defined('ABSPATH') or exit; 13 13 define('WPFA_NUMS', get_option('wpfa_nums')); 14 require_once plugin_dir_path(__FILE__) . 'pdate.php'; 14 define('WPFA_FILE', __FILE__); 15 16 require_once dirname( WPFA_FILE ) . '/pdate.php'; 15 17 16 18 function wpfa_activate() { … … 20 22 if (WPFA_NUMS === false) add_option('wpfa_nums', 'on'); 21 23 $inc = ABSPATH . 'wp-admin/includes/translation-install.php'; 22 if (file_exists($inc)) {24 if (file_exists($inc)) { 23 25 require_once($inc); 24 26 wp_download_language_pack('fa_IR'); 25 }26 }27 28 function wpfa_load_first(){29 $plugins = get_option('active_plugins');30 $path = plugin_basename(__FILE__);31 if (is_array($plugins) and $plugins[0] !== $path) {32 $key = array_search($path, $plugins);33 array_splice($plugins, $key, 1);34 array_unshift($plugins, $path);35 update_option('active_plugins', $plugins);36 27 } 37 28 } … … 45 36 } 46 37 47 function timestampdiv() {48 ?><script type='text/javascript'>49 var c = ("۰,۱,۲,۳,۴,۵,۶,۷,۸,۹,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec").split(",");50 var d = ("0,1,2,3,4,5,6,7,8,9,فرو,ارد,خرد,تیر,مرد,شهر,مهر,آبا,آذر,دی,بهم,اسف").split(",");51 jQuery(document).ready(function(){52 jQuery("#timestampdiv,.timestamp-wrap,.inline-edit-date,.jj,.mm,.aa,.hh,.mn,.ss").html(function(a,b){53 jQuery.each(c,function(a,c){b=b.replace(new RegExp(c,'g'),d[a])});return b});54 jQuery("#mm option[value='"+jQuery('#hidden_mm').val()+"']").attr("selected","selected")});55 </script><?php56 }57 58 38 function numbers_fa( $string ) { 59 39 static $en_nums = array('0','1','2','3','4','5','6','7','8','9'); … … 62 42 } 63 43 64 function dreg_jsfa() {65 wp_deregister_script('ztjalali_reg_admin_js');66 wp_deregister_script('ztjalali_reg_date_js');67 wp_deregister_script('wpp_admin');68 }69 70 44 function wpfa_date_i18n( $g, $f, $t ) { 71 45 $d = wpfa_date($f, intval($t)); 72 46 return WPFA_NUMS === "on" ? numbers_fa($d) : $d; 73 }74 75 function wpfa_nums() {76 register_setting('general', 'wpfa_nums', 'esc_attr');77 add_settings_field('wpfa_nums', '<label for="wpfa_nums">ساختار اعداد</label>', create_function('', '78 echo \'<label><input type="checkbox" name="wpfa_nums" ' . (WPFA_NUMS === "on" ? "checked" : "") . '/>79 <span>فارسی ۰۱۲۳۴۵۶۷۸۹</span></label>\';'), 'general');80 47 } 81 48 … … 93 60 ) as $i) remove_all_filters($i); 94 61 add_filter('date_i18n', 'wpfa_date_i18n', 10, 3); 95 if (WPFA_NUMS === "on") 62 if (WPFA_NUMS === "on") 96 63 add_filter('number_format_i18n', 'numbers_fa'); 64 } 65 66 function post_jalali2gregorian(){ 67 if (isset($_POST['aa'], $_POST['mm'], $_POST['jj'])) 68 list($_POST['aa'], $_POST['mm'], $_POST['jj']) = jalali2gregorian(zeroise(intval($_POST['aa']), 4), zeroise(intval($_POST['mm']), 2), zeroise(intval($_POST['jj']), 2)); 97 69 } 98 70 … … 101 73 $wp_locale->number_format['thousands_sep'] = ","; 102 74 $wp_locale->number_format['decimal_point'] = "."; 103 if (isset($_POST['aa'], $_POST['mm'], $_POST['jj']))104 list($_POST['aa'], $_POST['mm'], $_POST['jj']) = jalali2gregorian(zeroise(intval($_POST['aa']), 4), zeroise(intval($_POST['mm']), 2), zeroise(intval($_POST['jj']), 2));105 wpfa_load_first();106 75 if (numbers_fa(mysql2date("Y", "2015", 0)) !== "۱۳۹۴") 107 76 wpfa_patch_func(true); 77 else post_jalali2gregorian(); 78 } 79 80 function wpfa_admin(){ 81 require_once dirname( WPFA_FILE ) . "/wpfa_admin.php"; 82 wpfa_nums_field(); 83 wpfa_load_first(); 108 84 } 109 85 110 86 wpfa_apply_filters(); 111 87 add_action('init', 'wpfa_init'); 112 add_action('admin_init', 'wpfa_nums'); 113 add_action('admin_footer', 'timestampdiv'); 114 add_action('wp_print_scripts', 'dreg_jsfa', 900); 88 add_action('admin_init', 'wpfa_admin'); 115 89 add_action('wp_loaded', 'wpfa_apply_filters', 900); 116 register_activation_hook( __FILE__, 'wpfa_activate');117 register_deactivation_hook( __FILE__, 'wpfa_patch_func');90 register_activation_hook( WPFA_FILE , 'wpfa_activate'); 91 register_deactivation_hook( WPFA_FILE , 'wpfa_patch_func');
Note: See TracChangeset
for help on using the changeset viewer.