Plugin Directory

Changeset 1354288


Ignore:
Timestamp:
02/19/2016 04:21:08 PM (10 years ago)
Author:
Ali.Dbg
Message:

Update to v3.3.1

Location:
wp-farsi
Files:
31 added
3 deleted
2 edited

Legend:

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

    r1104080 r1354288  
    1 WP-Farsi!
     1<?php
     2/**
     3Plugin Name: WP-Farsi
     4Plugin URI: http://wordpress.org/extend/plugins/wp-farsi
     5Description: مبدل تاریخ میلادی وردپرس به خورشیدی، فارسی ساز، مبدل اعداد انگلیسی به فارسی، رفع مشکل هاست با زبان و تاریخ، سازگار با افزونه‌های مشابه.
     6Author: Ali.Dbg 😉
     7Author URI: https://github.com/alidbg/wp-farsi
     8Version: 3.1.3
     9License: GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html)
     10*/
     11
     12defined('ABSPATH')||die;
     13define('WPFA_NUMS', get_option('wpfa_nums'));
     14define('WPFA_FILE', __FILE__);
     15
     16require_once dirname( WPFA_FILE ) . '/includes/pdate.php';
     17
     18function 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
     31function 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
     41function 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
     48function 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
     58function 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
     64function 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
     72function 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
     90function 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
     95function 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
     104function wpfa_admin(){
     105    require_once dirname( WPFA_FILE ) . "/includes/wpfa_admin.php";
     106    wpfa_nums_field();
     107    wpfa_load_first();
     108}
     109
     110function 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
     130wpfa_apply_filters();
     131add_action('init', 'wpfa_init');
     132add_action('admin_init', 'wpfa_admin');
     133add_action('wp_default_styles', 'wpfa_remove_google_fonts', 5 );
     134add_action('wp_loaded', 'wpfa_apply_filters', 900);
     135register_activation_hook( WPFA_FILE , 'wpfa_activate');
     136register_deactivation_hook( WPFA_FILE , 'wpfa_patch_func');
     137//End.
  • wp-farsi/trunk/readme.txt

    r1324328 r1354288  
    4444
    4545== 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
    4652
    4753= 3.1.3 =
Note: See TracChangeset for help on using the changeset viewer.