Plugin Directory

Changeset 1878538


Ignore:
Timestamp:
05/21/2018 03:38:23 PM (8 years ago)
Author:
salemi
Message:

update 3.1.0

Location:
wp-persian/trunk
Files:
2 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • wp-persian/trunk/includes/class-wp-persian.php

    r1875927 r1878538  
    33if ( ! defined( 'ABSPATH' ) ) exit;
    44
    5 /** @define "WPP_DIR" "../" */
    6 require_once(WPP_DIR.'includes/widgets/class-wpp-widget-jarchive.php');
    7 require_once(WPP_DIR.'includes/widgets/class-wpp-widget-jcalendar.php');
    8 require_once(WPP_DIR.'includes/class-wpp-options.php');
    95
    106    /**
     
    128     *
    139     * @package WP-Persian
    14      * @author Siavash
    15      * @copyright 2016
     10     * @author Siavash Salemi
     11     * @copyright 2018
    1612     * @version $Id$
    1713     * @access public
     
    1915class WP_Persian {
    2016
    21     private static $instance;
     17    private static $_instance=null;
    2218    public $wpp_options;
    2319    public $frontpage_locale;
    2420    public $adminpanel_locale;
    2521    public $user_locale;
     22    public $version="3.0.3";
    2623
    2724    public static function getInstance()
    2825    {
    29         if (!isset(self::$instance)) {
    30             self::$instance = new self();
    31         }
    32         return self::$instance;
    33     }
    34 
     26        if (is_null(self::$_instance) || !isset(self::$_instance)) {
     27            self::$_instance = new self();
     28        }
     29        return self::$_instance;
     30    }
     31
     32    /**
     33     * WP_Persian constructor.
     34     */
    3535    protected function __construct() {
     36        $this->includes();
    3637        $this->adminpanel_locale=get_option( 'wpp_adminpanel_locale' );
    3738        $this->frontpage_locale=get_option( 'wpp_frontpage_locale' );
    3839    }
     40
     41    public function includes()
     42    {
     43        include_once(WPP_DIR.'includes/wpp-jdate.php');
     44        include_once(WPP_DIR.'includes/wpp-farsi.php');
     45        include_once(WPP_DIR.'includes/general-template.php');
     46        include_once(WPP_DIR.'includes/class-wpp-hooks.php');
     47        include_once(WPP_DIR.'includes/class-wpp-options.php');
     48        include_once(WPP_DIR.'includes/widgets/class-wpp-widget-jarchive.php');
     49        include_once(WPP_DIR.'includes/widgets/class-wpp-widget-jcalendar.php');
     50    }
    3951
    4052    public function run() {
     
    8193
    8294        if ( is_admin() ) {
     95            add_filter('media_library_months_with_files', array('WPP_Hooks','wpp_media_library_months_with_files'),10,0 );
     96            add_filter('ajax_query_attachments_args', array('WPP_Hooks','wpp_ajax_query_attachments_args'),10,1 );
     97
    8398            if ( !empty(get_option( 'wpp_adminpanel_thousands_sep' )) ) {
    8499                $wp_locale->number_format['thousands_sep'] = get_option( 'wpp_adminpanel_thousands_sep' );
     
    171186
    172187    private function admin_hooks() {
    173         add_action('admin_notices', array($this,'wpp_admin_notice'));
     188        //add_action('admin_notices', array($this,'wpp_admin_notice'));
    174189
    175190        if ( get_option( 'wpp_adminpanel_convert_date' ) ) {
     
    179194            add_filter( 'disable_months_dropdown' , array( 'WPP_Hooks', 'wpp_disable_months_dropdown' ) , 10 , 2 );
    180195            add_action( 'load-edit.php', array( 'WPP_Hooks', 'wpp_load_editphp' ), 10, 0 );
     196            add_action( 'load-upload.php', array( 'WPP_Hooks', 'wpp_load_editphp' ), 10, 0 );
    181197        }
    182198        add_action( 'admin_enqueue_scripts', array( 'WPP_Hooks', 'wpp_admin_enqueue_scripts' ) );
     
    334350        update_option( 'wpp_adminpanel_numbers_format_i18n', 0 );
    335351
    336         update_option( 'wpp_installed_version', WPPERSIAN_VER );
    337 
    338         if ( ! function_exists( 'wp_download_language_pack' ) ) {
    339             require_once ABSPATH . '/wp-admin/includes/translation-install.php';
    340         }
    341         if (wp_can_install_language_pack()) {
    342             wp_download_language_pack( 'fa_IR' );
    343         }
     352        update_option( 'wpp_installed_version', $this->version );
     353
     354        if (!function_exists('wp_download_language_pack')) {
     355            require_once ABSPATH . '/wp-admin/includes/translation-install.php';
     356        }
     357
     358        if (wp_can_install_language_pack()) {
     359            @wp_download_language_pack('fa_IR');
     360        }
     361
    344362
    345363    }
  • wp-persian/trunk/includes/class-wpp-hooks.php

    r1875927 r1878538  
    3636            $num_lang = 'fa';
    3737        }
    38         $j = jdate( $req_format, $i, '', get_option( 'timezone_string' ), $num_lang );
     38        $j = wpp_jdate( $req_format, $i, '', get_option( 'timezone_string' ), $num_lang );
    3939
    4040        return $j;
     
    163163
    164164
    165     function wpp_disable_months_dropdown( $false , $post_type ) {
     165    public static function wpp_disable_months_dropdown( $false , $post_type ) {
    166166        $disable_months_dropdown = $false;
    167         $disable_post_types = array( 'post' , 'page' );
     167        //$disable_post_types = array( 'post' , 'page' );
     168        $disable_post_types = array( 'post' , 'page', 'attachment' );
    168169        if( in_array( $post_type , $disable_post_types ) ) {
    169170            $disable_months_dropdown = true;
     
    212213    }
    213214
     215    //jalali date in media library
     216    public static function wpp_media_library_months_with_files()
     217    {
     218        global $wpdb,$wp_locale;
     219        for ($i=1;$i<=12;$i++) {
     220            $wp_locale->month[str_pad(strval($i),2,'0',STR_PAD_LEFT)] = wpp_jmonth_name($i);
     221        }
     222
     223            $months = $wpdb->get_results( $wpdb->prepare( "
     224            SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month, DAY( post_date ) as day
     225            FROM $wpdb->posts
     226            WHERE post_type = %s
     227            ORDER BY post_date DESC
     228        ", 'attachment' ) );
     229        $pre_date='';
     230        foreach ( $months as $k=>$month_year ) {
     231            if($pre_date==$month_year->year.$month_year->month){
     232                unset($months[$k]);
     233                continue;
     234            }
     235            $pre_date=$month_year->year.$month_year->month;
     236            list($month_year->year, $month_year->month, )=wpp_gregorian_to_jalali($month_year->year,$month_year->month,$month_year->day);
     237
     238        }
     239        return $months;
     240
     241    }
     242    //jalali date in media library
     243    public static function wpp_ajax_query_attachments_args($query = array()){
     244        if(!isset($query['year']) || !isset($query['monthnum']) || empty($query['year']) || $query['year']=='false' || $query['monthnum']=='false') {
     245            return $query;
     246        }
     247
     248        $month=$query['monthnum'];
     249        $year=$query['year'];
     250
     251        $jtime=wpp_jmktime( 0, 0, 0, $month, 1, $year );
     252        $after = date( 'Y-m-d H:i:s', $jtime );
     253        $kab=($year%33%4-1==(int)($year%33*.05))?1:0;
     254        $extra = ( $month <= 6 ) ? $extra = 31 * 24 * 3600 : ( ( $month == 12 && ! $kab ) ? 29 * 24 * 3600 : 30 * 24 * 3600 );
     255        $before = date( 'Y-m-d H:i:s', $jtime + $extra );
     256        $query['date_query']=array('after'=>$after,'before'=>$before);
     257        $query['monthnum']='';
     258        $query['year']='';
     259
     260        return $query;
     261    }
    214262
    215263    /**
     
    340388    }
    341389
    342 /*
    343     public static function wpp_parse_admin_query($wp_query)
    344     {
    345         if ( !is_admin() ) return;
    346 
    347         if( isset($_GET['mfa']) && !empty($_GET['mfa']) && $_GET['mfa'] != '0' ) {
    348             $mfa  = preg_replace( '/[^0-9]/', '', $_GET['mfa'] );
    349             $wp_query->set('m', $mfa);
    350         }
    351 
    352     }
    353 */
    354390
    355391    public static function wpp_load_editphp() {
    356392        add_filter( "pre_get_posts", array( 'WPP_Hooks', 'wpp_filter_posts' ) );
    357         //add_filter('parse_query', array('WPP_Hooks','wpp_parse_admin_query') );
     393
    358394        add_filter('posts_where', array('WPP_Hooks','wpp_jalali_query') );
     395
     396
    359397
    360398    }
  • wp-persian/trunk/includes/jdf.php

    r1875927 r1878538  
    1717
    1818 if($time_zone!='local')date_default_timezone_set(($time_zone==='')?'Asia/Tehran':$time_zone);
    19  $ts=$T_sec+(($timestamp==='')?time():tr_num($timestamp));
     19 $ts=$T_sec+intval(($timestamp==='')?time():tr_num($timestamp)); //fix by 30yavash
    2020 $date=explode('_',date('H_i_j_n_O_P_s_w_Y',$ts));
    2121 list($j_y,$j_m,$j_d)=gregorian_to_jalali($date[8],$date[3],$date[2]);
  • wp-persian/trunk/includes/widgets/class-wpp-widget-jarchive.php

    r1872636 r1878538  
    1616    public function __construct() {
    1717        parent::__construct(
    18             'wpp_widget_jarchive', // Base ID
     18            'wpp_jarchive', // Base ID
    1919            __( 'Jalali Archive', 'wp-persian' ), // Name
    2020            array( 'description' => __( 'A jalali monthly archive of your site’s posts', 'wp-persian' ), ) // Args
     
    8787        $title           = sanitize_text_field( $instance['title'] );
    8888        ?>
    89         <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'wp-persian' ); ?> <input
     89        <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'wp-persian' ); ?></label>
     90            <input
    9091                    class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>"
    9192                    name="<?php echo $this->get_field_name( 'title' ); ?>" type="text"
    92                     value="<?php echo esc_attr( $title ); ?>"/></label></p>
     93                    value="<?php echo esc_attr( $title ); ?>"/></p>
    9394        <p><input name="<?php echo $this->get_field_name( 'dropdown' ); ?>" type="checkbox" value="1"
    9495                  id="<?php echo $this->get_field_id( 'dropdown' ); ?>" <?php checked( $instance['dropdown'] ); ?> />
  • wp-persian/trunk/includes/widgets/class-wpp-widget-jcalendar.php

    r1872636 r1878538  
    1313    public function __construct() {
    1414        parent::__construct(
    15             'jcalendar', // Base ID
     15            'wpp_jcalendar', // Base ID
    1616            __( 'Jalali Calendar', 'wp-persian' ), // Name
    1717            array( 'description' => __( 'A jalali calendar of your site’s posts', 'wp-persian' ), ) // Args
     
    8383     */
    8484    public function update( $new_instance, $old_instance ) {
    85         $instance          = array();
    86         $instance['title'] = strip_tags( $new_instance['title'] );
     85        $instance          = $old_instance;
     86        $instance['title'] = sanitize_text_field( $new_instance['title'] );
    8787
    8888        return $instance;
     
    9191
    9292    public function form( $instance ) {
    93         if ( isset( $instance['title'] ) ) {
    94             $title = $instance['title'];
    95         } else {
    96             $title = __( 'title', 'wp_persian' );
    97         }
     93        $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
     94        $title = sanitize_text_field( $instance['title'] );
    9895        ?>
    99         <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?> <input class="widefat"
    100                                                                                                       id="<?php echo $this->get_field_id( 'title' ); ?>"
    101                                                                                                       name="<?php echo $this->get_field_name( 'title' ); ?>"
    102                                                                                                       type="text"
    103                                                                                                       value="<?php echo esc_attr( $title ); ?>"/></label>
    104         </p>
     96        <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
     97            <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"/></p>
    10598        <?php
    10699    }
  • wp-persian/trunk/readme.txt

    r1875952 r1878538  
    22Contributors: salemi
    33Donate link: https://zarinp.al/22741
    4 Tags: persian, farsi, jalali, date, calendar, iran, ltr, rtl, direction, shamsi, فارسی, تقویم, شمسی, هجری, خورشیدی, افزونه, جلالی, میلادی, پارسی, ایران, پیشرفته
     4Tags: persian, farsi, jalali, date, calendar, iran, ltr, rtl, direction, shamsi, فارسی, تقویم, شمسی, هجری شمسی, افزونه, جلالی, میلادی, پارسی, ایران, پیشرفته
    55Requires at least: 4.0
    6 Tested up to: 4.9.5
    7 Stable tag: 3.0.2
     6Tested up to: 4.9.6
     7Stable tag: 3.1.0
    88License: GPL2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1616
    1717= Farsi Description =
    18 * ‏فارسی ساز پیشرفته وردپرس
     18* تاریخ هجری شمسی در همه بخش ها حتی بخش آپلود عکس و مدیا
     19* تشخیص خودکار جهت متن ورودی در بخش مدیریت
    1920* قابلیت تبدیل کلیه تاریخ های میلادی به هجری شمسی
    2021* امکان تغییر زبان و تقویم بخش مدیریت و بخش کاربری به صورت مجزا‬
    2122* به همراه راهنمای کامل تنظیمات به زبان فارسی
    2223* بدون ایجاد تغییرات در هسته وردپرس
    23 
     24[راهنمای فارسی نگارش سوم](https://plugins.svn.wordpress.org/wp-persian/assets/help.pdf)
     25[راهنمای نصب فارسی نگارش سوم](https://plugins.svn.wordpress.org/wp-persian/assets/install.pdf)
    2426
    2527= Features =
     
    3335* Jalali Calendar widget.
    3436* Jalali/Gregorian compatible permalinks.
    35 
    36 [Download PDF document in persian](https://plugins.svn.wordpress.org/wp-persian/assets/help.pdf)
    3737[Video Demo](https://youtu.be/4BIaH5_y-u8)
    3838
     
    4848
    4949== Changelog ==
     50= 3.1.0 (May 21th,2018) =
     51* (NEW) jalali date in media library page
     52* (FIX) bug fix in activate plugin
     53* (TEST) PHP 7.0.10 + Wordpress 4.9.6
     54
    5055= 3.0.2 (May 17th,2018) =
    5156* (UPDATE) update language repository
  • wp-persian/trunk/uninstall.php

    r1462478 r1878538  
    1414    'wpp_tinymce_bidi_buttons',
    1515    'wpp_tinymce_css',
    16     'wpp_adminpanel_complex_css',
     16    'wpp_adminpanel_context',
    1717    'wpp_adminpanel_numbers_post_content',
    1818    'wpp_adminpanel_numbers_post_excerpt',
     
    3737    'wpp_frontpage_numbers_date_i18n',
    3838    'wpp_frontpage_numbers_format_i18n',
    39     'wpp_frontpage_letters'
     39    'wpp_frontpage_letters',
     40    'widget_wpp_jarchive',
     41    'widget_wpp_jcalendar'
    4042);
    4143
  • wp-persian/trunk/wp-persian.php

    r1875927 r1878538  
    66 * Plugin URI:        https://wordpress.org/plugins/wp-persian/
    77 * Description:       WP-Persian is a fast and powerful plugin for support jalali date and persian language in wordpress and all other standard plugins.
    8  * Version:           3.0.2
     8 * Version:           3.0.3
    99 * Author:            Siavash Salemi
    1010 * Author URI:        http://www.30yavash.ir
     
    1919
    2020
    21 define('WPPERSIAN_ID', 'wppersian');
     21//define('WPPERSIAN_ID', 'wppersian');
    2222define('WPPERSIAN_NICK', 'WP Persian');
    23 define('WPPERSIAN_VER', '3.0.2');
     23//define('WPPERSIAN_VER', '3.0.3');
    2424
    2525/** @define "WPP_DIR" "./" */
     
    3030
    3131
    32 require_once(WPP_DIR.'includes/jdf.php');
    33 require_once(WPP_DIR.'includes/wpp-helper.php');
    34 
     32/*
     33require_once(WPP_DIR.'includes/wpp-jdate.php');
     34require_once(WPP_DIR.'includes/wpp-farsi.php');
    3535require_once(WPP_DIR.'includes/general-template.php');
    36 
    3736require_once(WPP_DIR.'includes/class-wpp-hooks.php');
    38 
     37*/
    3938
    4039require_once(WPP_DIR.'includes/class-wp-persian.php');
Note: See TracChangeset for help on using the changeset viewer.