Changeset 1354288
- Timestamp:
- 02/19/2016 04:21:08 PM (10 years ago)
- Location:
- wp-farsi
- Files:
-
- 31 added
- 3 deleted
- 2 edited
-
tags/3.1.3 (added)
-
tags/3.1.3/index.php (added)
-
tags/3.1.3/license.html (added)
-
tags/3.1.3/pdate.php (added)
-
tags/3.1.3/readme.txt (added)
-
tags/3.1.3/wp-farsi.php (added)
-
tags/3.1.3/wpfa_admin.php (added)
-
tags/3.3.1 (added)
-
tags/3.3.1/assets (added)
-
tags/3.3.1/assets/DroidNaskh-Bold.woff (added)
-
tags/3.3.1/assets/DroidNaskh-Regular.woff (added)
-
tags/3.3.1/assets/index.html (added)
-
tags/3.3.1/assets/wpfa-font.css (added)
-
tags/3.3.1/assets/wpfajs.js (added)
-
tags/3.3.1/includes (added)
-
tags/3.3.1/includes/index.html (added)
-
tags/3.3.1/includes/pdate.php (added)
-
tags/3.3.1/includes/wpfa_admin.php (added)
-
tags/3.3.1/index.php (added)
-
tags/3.3.1/license.html (added)
-
tags/3.3.1/readme.txt (added)
-
trunk/assets (added)
-
trunk/assets/DroidNaskh-Bold.woff (added)
-
trunk/assets/DroidNaskh-Regular.woff (added)
-
trunk/assets/index.html (added)
-
trunk/assets/wpfa-font.css (added)
-
trunk/assets/wpfajs.js (added)
-
trunk/includes (added)
-
trunk/includes/index.html (added)
-
trunk/includes/pdate.php (added)
-
trunk/includes/wpfa_admin.php (added)
-
trunk/index.php (modified) (1 diff)
-
trunk/pdate.php (deleted)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/wp-farsi.php (deleted)
-
trunk/wpfa_admin.php (deleted)
Legend:
- Unmodified
- Added
- Removed
-
wp-farsi/trunk/index.php
r1104080 r1354288 1 WP-Farsi! 1 <?php 2 /** 3 Plugin Name: WP-Farsi 4 Plugin URI: http://wordpress.org/extend/plugins/wp-farsi 5 Description: مبدل تاریخ میلادی وردپرس به خورشیدی، فارسی ساز، مبدل اعداد انگلیسی به فارسی، رفع مشکل هاست با زبان و تاریخ، سازگار با افزونههای مشابه. 6 Author: Ali.Dbg 😉 7 Author URI: https://github.com/alidbg/wp-farsi 8 Version: 3.1.3 9 License: GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html) 10 */ 11 12 defined('ABSPATH')||die; 13 define('WPFA_NUMS', get_option('wpfa_nums')); 14 define('WPFA_FILE', __FILE__); 15 16 require_once dirname( WPFA_FILE ) . '/includes/pdate.php'; 17 18 function wpfa_activate() { 19 update_option('WPLANG', 'fa_IR'); 20 update_option('start_of_week', '6'); 21 update_option('timezone_string', 'Asia/Tehran'); 22 if (WPFA_NUMS === false) add_option('wpfa_nums', 'on'); 23 $inc = ABSPATH . 'wp-admin/includes/translation-install.php'; 24 if (file_exists($inc)) { 25 require_once($inc); 26 wp_download_language_pack('fa_IR'); 27 update_option('WPLANG', 'fa_IR'); 28 } 29 } 30 31 function wpfa_patch_func($patch = false) { 32 $file = ABSPATH . 'wp-includes/functions.php'; 33 if (!is_writable($file)) @chmod($file, 0644); 34 if (is_writable($file)) { 35 $src = @file_get_contents($file); 36 if (preg_match_all('/else\s+return\s+(date.*)[(]/', $src, $match) === 1) 37 @file_put_contents($file, str_replace($match[0][0], (rtrim($match[1][0]) === "date" && $patch ? "else\n\t\treturn date_i18n(" : "else\n\t\treturn date("), $src)); 38 } 39 } 40 41 function numbers_fa( $string ) { 42 static $en_nums = array('0','1','2','3','4','5','6','7','8','9'); 43 static $fa_nums = array('۰','۱','۲','۳','۴','۵','۶','۷','۸','۹'); 44 return str_replace($en_nums, $fa_nums, $string); 45 } 46 47 48 function iss_uri($s = '') { 49 if (isset($_SERVER['REQUEST_URI']) and trim($s) !== '') { 50 $r = trim($_SERVER['REQUEST_URI']); 51 if ($r !== '' or $r !== '/') 52 if (strpos($r, $s) !== false) 53 return true; 54 } 55 return false; 56 } 57 58 function exception_date() { 59 if (iss_uri('/feed') or iss_uri('feed=') or defined('WXR_VERSION') or isset($autosave) or isset($lasttime) or isset($signup)) 60 return true; 61 return false; 62 } 63 64 function wpfa_date_i18n($g, $f, $t) { 65 if (exception_date()) 66 return date($f, $t); 67 else 68 $d = wpfa_date($f, intval($t)); 69 return WPFA_NUMS === "on" ? numbers_fa($d) : $d; 70 } 71 72 function wpfa_apply_filters() { 73 @ini_set('default_charset', 'UTF-8'); 74 @ini_set('date.timezone', 'UTC'); 75 @setlocale(LC_ALL, 'Persian_Iran.1256', 'fa_IR.utf8', 'fa_IR'); 76 if (@extension_loaded('mbstring')) { 77 @mb_internal_encoding('UTF-8'); 78 @mb_language('neutral'); 79 @mb_http_output('UTF-8'); 80 } 81 foreach (array( 82 'date_i18n', 'get_post_time', 'get_comment_date', 'get_comment_time', 'get_the_date', 'the_date', 'get_the_time', 'the_time', 83 'get_the_modified_date', 'the_modified_date', 'get_the_modified_time', 'the_modified_time', 'get_post_modified_time', 'number_format_i18n' 84 ) as $i) remove_all_filters($i); 85 add_filter('date_i18n', 'wpfa_date_i18n', 10, 3); 86 if (WPFA_NUMS === "on") 87 add_filter('number_format_i18n', 'numbers_fa'); 88 } 89 90 function post_jalali2gregorian(){ 91 if (isset($_POST['aa'], $_POST['mm'], $_POST['jj'])) 92 list($_POST['aa'], $_POST['mm'], $_POST['jj']) = jalali2gregorian(zeroise(intval($_POST['aa']), 4), zeroise(intval($_POST['mm']), 2), zeroise(intval($_POST['jj']), 2)); 93 } 94 95 function wpfa_init() { 96 global $wp_locale; 97 $wp_locale->number_format['thousands_sep'] = ","; 98 $wp_locale->number_format['decimal_point'] = "."; 99 if (numbers_fa(mysql2date("Y", "2015", 0)) !== "۱۳۹۴") 100 wpfa_patch_func(true); 101 else post_jalali2gregorian(); 102 } 103 104 function wpfa_admin(){ 105 require_once dirname( WPFA_FILE ) . "/includes/wpfa_admin.php"; 106 wpfa_nums_field(); 107 wpfa_load_first(); 108 } 109 110 function wpfa_remove_google_fonts( $styles ) { 111 //Author: https://git.io/v2fH5 112 $styles->add( 'open-sans' , '' ); // Backend 113 $styles->add( 'twentytwelve-fonts' , '' ); // Core themes ... 114 $styles->add( 'twentythirteen-fonts', '' ); 115 $styles->add( 'twentyfourteen-lato' , '' ); 116 $styles->add( 'twentyfifteen-fonts', '' ); 117 $styles->add( 'twentysixteen-fonts', '' ); 118 if ( is_admin() ) { 119 // Remove Google fonts injected into WP editor 120 global $editor_styles; 121 if ( function_exists( 'twentyfifteen_fonts_url' ) ) { 122 unset( $editor_styles[ array_search( twentyfifteen_fonts_url(), $editor_styles ) ] ); 123 } 124 if ( function_exists( 'twentysixteen_fonts_url' ) ) { 125 unset( $editor_styles[ array_search( twentysixteen_fonts_url(), $editor_styles ) ] ); 126 } 127 } 128 } 129 130 wpfa_apply_filters(); 131 add_action('init', 'wpfa_init'); 132 add_action('admin_init', 'wpfa_admin'); 133 add_action('wp_default_styles', 'wpfa_remove_google_fonts', 5 ); 134 add_action('wp_loaded', 'wpfa_apply_filters', 900); 135 register_activation_hook( WPFA_FILE , 'wpfa_activate'); 136 register_deactivation_hook( WPFA_FILE , 'wpfa_patch_func'); 137 //End. -
wp-farsi/trunk/readme.txt
r1324328 r1354288 44 44 45 45 == Changelog == 46 47 48 = 3.3.1 = 49 * Added Google Fonts Remover 50 * Added Droid Arabic Naskh Font v7.0.5 51 * Fixed Gregorian month names to jalai 46 52 47 53 = 3.1.3 =
Note: See TracChangeset
for help on using the changeset viewer.