Plugin Directory

Changeset 1406031


Ignore:
Timestamp:
04/27/2016 11:02:50 PM (10 years ago)
Author:
Ali.Dbg
Message:

Update to v4.0.1

Location:
wp-farsi
Files:
222 added
1 edited

Legend:

Unmodified
Added
Removed
  • wp-farsi/trunk/wp-farsi.php

    r1403690 r1406031  
    66Author: Ali.Dbg 😉
    77Author URI: https://github.com/alidbg/wp-farsi
    8 Version: 3.0
     8Version: 4.0.1
    99License: GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html)
    1010*/
     
    2525    if (file_exists($inc)) {
    2626        require_once($inc);
    27         wp_download_language_pack('fa_IR');
     27        if(function_exists('wp_download_language_pack'))
     28            wp_download_language_pack('fa_IR');
    2829        update_option('WPLANG', 'fa_IR');
    2930    }
     
    3334function wpfa_file_put_contents($file = '', $str = '') {
    3435$fp = fopen($file, "w");
    35   if (flock($fp, LOCK_EX | LOCK_NB)) {
     36  if ($fp !== FALSE and flock($fp, LOCK_EX)) {
    3637        fwrite($fp, $str);
    3738        sleep(2);
     
    4142}
    4243
     44function wpfa_file_get_contents($file = '') {
     45$content = '';
     46$fp = fopen($file, "r");
     47  if ($fp !== FALSE and flock($fp, LOCK_SH)) {
     48        $content = fread($fp, filesize($file));
     49        usleep(100000);
     50        flock($fp, LOCK_UN);
     51        fclose($fp);
     52  } else return false;
     53  return $content;
     54}
     55
    4356function wpfa_patch_func() {
    4457    $file = ABSPATH . 'wp-includes/functions.php';
    4558    if (is_writable($file)) {
    46         $src = file_get_contents($file);
    47         usleep(mt_rand(100000, 200000));
    48         if (preg_match_all('/else\s+return\s+(date.*)[(]/', $src, $match) === 1) {
     59        $src = wpfa_file_get_contents($file);
     60        if ($src and preg_match_all('/else\s+return\s+(date.*)[(]/', $src, $match) === 1) {
    4961            if (trim($match[1][0]) === 'date') {
    5062                wpfa_file_put_contents($file, str_replace($match[0][0], "else\n\t\treturn date_i18n(", $src));
     
    5971    $file = ABSPATH . 'wp-includes/functions.php';
    6072    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) {
     73        $src = wpfa_file_get_contents($file);
     74        if ($src and preg_match_all('/else\s+return\s+(date_i18n.*)[(]/', $src, $match) === 1) {
    6475           
    6576            if (trim($match[1][0]) === 'date_i18n') {
Note: See TracChangeset for help on using the changeset viewer.