Plugin Directory

Changeset 1403457


Ignore:
Timestamp:
04/25/2016 01:09:58 AM (10 years ago)
Author:
Ali.Dbg
Message:

Update to v4.0

Location:
wp-farsi/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-farsi/trunk/readme.txt

    r1379976 r1403457  
    4444
    4545== 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
    4655
    4756= 3.6 =
  • wp-farsi/trunk/wp-farsi.php

    r1379976 r1403457  
    66Author: Ali.Dbg 😉
    77Author URI: https://github.com/alidbg/wp-farsi
    8 Version: 3.6
     8Version: 4.0
    99License: GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html)
    1010*/
    1111
    1212defined('ABSPATH')||die;
     13defined('WPLANG')||define('WPLANG', 'fa_IR');
    1314define('WPFA_NUMS', get_option('wpfa_nums'));
    1415define('WPFA_FILE', __FILE__);
     
    2728        update_option('WPLANG', 'fa_IR');
    2829    }
     30    wpfa_patch_func();
    2931}
    3032
    31 function wpfa_patch_func($patch = false) {
     33function 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
     43function wpfa_patch_func() {
    3244    $file = ABSPATH . 'wp-includes/functions.php';
    3345    if (is_writable($file)) {
    3446        $src = file_get_contents($file);
     47        usleep(mt_rand(100000, 200000));
    3548        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
     58function 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            }
    3768        }
    3869    }
     
    4576}
    4677
     78function 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}
    4783
    4884function iss_uri($s = '') {
     
    98134    $wp_locale->number_format['thousands_sep'] = ",";
    99135    $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    }
    103139    post_jalali2gregorian();
    104140}
     
    110146}
    111147
    112 function wpfa_remove_google_fonts( $styles ) {
     148function wpfa_remove_styles( $styles ) {
    113149    //Author: https://git.io/v2fH5
    114150    $styles->add( 'open-sans'           , '' ); // Backend
     151    $styles->add( 'googleFontsOpenSans' , '' ); // Backend
     152    $styles->add( 'raleway-font'        , '' ); // Backend
    115153    $styles->add( 'twentytwelve-fonts'  , '' ); // Core themes ...
    116154    $styles->add( 'twentythirteen-fonts', '' );
    117155    $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', '');
    120162    if ( is_admin() ) {
    121163        // Remove Google fonts injected into WP editor
     
    133175add_action('init', 'wpfa_init');
    134176add_action('admin_init', 'wpfa_admin');
    135 add_action('wp_default_styles', 'wpfa_remove_google_fonts', 5 );
     177add_action('wp_default_styles', 'wpfa_remove_styles', 5 );
    136178add_action('wp_loaded', 'wpfa_apply_filters', 900);
    137179register_activation_hook( WPFA_FILE , 'wpfa_activate');
    138 register_deactivation_hook( WPFA_FILE , 'wpfa_patch_func');
     180register_deactivation_hook( WPFA_FILE , 'wpfa_unpatch_func');
    139181//End.
Note: See TracChangeset for help on using the changeset viewer.