Changeset 1403457
- Timestamp:
- 04/25/2016 01:09:58 AM (10 years ago)
- Location:
- wp-farsi/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (1 diff)
-
wp-farsi.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-farsi/trunk/readme.txt
r1379976 r1403457 44 44 45 45 == Changelog == 46 47 = 4.0 = 48 * Added Persian Gravity Font Fixer 49 * Improved Patch Engine 50 * Fixed bugs 51 52 = 3.7 = 53 * Added Persian Gravity Font Fixer 54 * Improved Patch Engine 46 55 47 56 = 3.6 = -
wp-farsi/trunk/wp-farsi.php
r1379976 r1403457 6 6 Author: Ali.Dbg 😉 7 7 Author URI: https://github.com/alidbg/wp-farsi 8 Version: 3.68 Version: 4.0 9 9 License: GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html) 10 10 */ 11 11 12 12 defined('ABSPATH')||die; 13 defined('WPLANG')||define('WPLANG', 'fa_IR'); 13 14 define('WPFA_NUMS', get_option('wpfa_nums')); 14 15 define('WPFA_FILE', __FILE__); … … 27 28 update_option('WPLANG', 'fa_IR'); 28 29 } 30 wpfa_patch_func(); 29 31 } 30 32 31 function wpfa_patch_func($patch = false) { 33 function wpfa_file_put_contents($file = '', $str = '') { 34 $fp = fopen($file, "w"); 35 if (flock($fp, LOCK_EX | LOCK_NB)) { 36 fwrite($fp, $str); 37 sleep(2); 38 flock($fp, LOCK_UN); 39 fclose($fp); 40 } 41 } 42 43 function wpfa_patch_func() { 32 44 $file = ABSPATH . 'wp-includes/functions.php'; 33 45 if (is_writable($file)) { 34 46 $src = file_get_contents($file); 47 usleep(mt_rand(100000, 200000)); 35 48 if (preg_match_all('/else\s+return\s+(date.*)[(]/', $src, $match) === 1) { 36 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), LOCK_EX); 49 if (trim($match[1][0]) === 'date') { 50 wpfa_file_put_contents($file, str_replace($match[0][0], "else\n\t\treturn date_i18n(", $src)); 51 } 52 } 53 } else { 54 @chmod($file, 0666); // change file mode 55 } 56 } 57 58 function wpfa_unpatch_func() { 59 $file = ABSPATH . 'wp-includes/functions.php'; 60 if (is_writable($file)) { 61 $src = file_get_contents($file); 62 usleep(mt_rand(100000, 200000)); 63 if (preg_match_all('/else\s+return\s+(date_i18n.*)[(]/', $src, $match) === 1) { 64 65 if (trim($match[1][0]) === 'date_i18n') { 66 wpfa_file_put_contents($file, str_replace($match[0][0], "else\n\t\treturn date(", $src)); 67 } 37 68 } 38 69 } … … 45 76 } 46 77 78 function numbers_fa2en( $string ) { 79 static $en_nums = array('0','1','2','3','4','5','6','7','8','9'); 80 static $fa_nums = array('۰','۱','۲','۳','۴','۵','۶','۷','۸','۹'); 81 return str_replace($fa_nums, $en_nums, $string); 82 } 47 83 48 84 function iss_uri($s = '') { … … 98 134 $wp_locale->number_format['thousands_sep'] = ","; 99 135 $wp_locale->number_format['decimal_point'] = "."; 100 if ( numbers_fa(mysql2date("Y", "2015-07-23 06:12:45", false)) !== "۱۳۹۴") {101 wpfa_patch_func(true);102 } 136 if (trim(numbers_fa2en(mysql2date("Y", "2015-07-23 06:12:45", false))) == "2015") { 137 wpfa_patch_func(); 138 } 103 139 post_jalali2gregorian(); 104 140 } … … 110 146 } 111 147 112 function wpfa_remove_ google_fonts( $styles ) {148 function wpfa_remove_styles( $styles ) { 113 149 //Author: https://git.io/v2fH5 114 150 $styles->add( 'open-sans' , '' ); // Backend 151 $styles->add( 'googleFontsOpenSans' , '' ); // Backend 152 $styles->add( 'raleway-font' , '' ); // Backend 115 153 $styles->add( 'twentytwelve-fonts' , '' ); // Core themes ... 116 154 $styles->add( 'twentythirteen-fonts', '' ); 117 155 $styles->add( 'twentyfourteen-lato' , '' ); 118 $styles->add( 'twentyfifteen-fonts', '' ); 119 $styles->add( 'twentysixteen-fonts', '' ); 156 $styles->add( 'twentyfifteen-fonts' , '' ); 157 $styles->add( 'twentysixteen-fonts' , '' ); 158 $styles->add( 'gravity-forms-admin-yekan', ''); 159 $styles->add( 'ztjalali_reg_admin_style', ''); 160 $styles->add( 'ztjalali_reg_custom_admin_style', ''); 161 $styles->add( 'ztjalali_reg_theme_editor_style', ''); 120 162 if ( is_admin() ) { 121 163 // Remove Google fonts injected into WP editor … … 133 175 add_action('init', 'wpfa_init'); 134 176 add_action('admin_init', 'wpfa_admin'); 135 add_action('wp_default_styles', 'wpfa_remove_ google_fonts', 5 );177 add_action('wp_default_styles', 'wpfa_remove_styles', 5 ); 136 178 add_action('wp_loaded', 'wpfa_apply_filters', 900); 137 179 register_activation_hook( WPFA_FILE , 'wpfa_activate'); 138 register_deactivation_hook( WPFA_FILE , 'wpfa_ patch_func');180 register_deactivation_hook( WPFA_FILE , 'wpfa_unpatch_func'); 139 181 //End.
Note: See TracChangeset
for help on using the changeset viewer.