Changeset 1878538
- Timestamp:
- 05/21/2018 03:38:23 PM (8 years ago)
- Location:
- wp-persian/trunk
- Files:
-
- 2 added
- 1 deleted
- 8 edited
-
includes/class-wp-persian.php (modified) (7 diffs)
-
includes/class-wpp-hooks.php (modified) (4 diffs)
-
includes/jdf.php (modified) (1 diff)
-
includes/widgets/class-wpp-widget-jarchive.php (modified) (2 diffs)
-
includes/widgets/class-wpp-widget-jcalendar.php (modified) (3 diffs)
-
includes/wpp-farsi.php (added)
-
includes/wpp-helper.php (deleted)
-
includes/wpp-jdate.php (added)
-
readme.txt (modified) (4 diffs)
-
uninstall.php (modified) (2 diffs)
-
wp-persian.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-persian/trunk/includes/class-wp-persian.php
r1875927 r1878538 3 3 if ( ! defined( 'ABSPATH' ) ) exit; 4 4 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');9 5 10 6 /** … … 12 8 * 13 9 * @package WP-Persian 14 * @author Siavash 15 * @copyright 201 610 * @author Siavash Salemi 11 * @copyright 2018 16 12 * @version $Id$ 17 13 * @access public … … 19 15 class WP_Persian { 20 16 21 private static $ instance;17 private static $_instance=null; 22 18 public $wpp_options; 23 19 public $frontpage_locale; 24 20 public $adminpanel_locale; 25 21 public $user_locale; 22 public $version="3.0.3"; 26 23 27 24 public static function getInstance() 28 25 { 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 */ 35 35 protected function __construct() { 36 $this->includes(); 36 37 $this->adminpanel_locale=get_option( 'wpp_adminpanel_locale' ); 37 38 $this->frontpage_locale=get_option( 'wpp_frontpage_locale' ); 38 39 } 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 } 39 51 40 52 public function run() { … … 81 93 82 94 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 83 98 if ( !empty(get_option( 'wpp_adminpanel_thousands_sep' )) ) { 84 99 $wp_locale->number_format['thousands_sep'] = get_option( 'wpp_adminpanel_thousands_sep' ); … … 171 186 172 187 private function admin_hooks() { 173 add_action('admin_notices', array($this,'wpp_admin_notice'));188 //add_action('admin_notices', array($this,'wpp_admin_notice')); 174 189 175 190 if ( get_option( 'wpp_adminpanel_convert_date' ) ) { … … 179 194 add_filter( 'disable_months_dropdown' , array( 'WPP_Hooks', 'wpp_disable_months_dropdown' ) , 10 , 2 ); 180 195 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 ); 181 197 } 182 198 add_action( 'admin_enqueue_scripts', array( 'WPP_Hooks', 'wpp_admin_enqueue_scripts' ) ); … … 334 350 update_option( 'wpp_adminpanel_numbers_format_i18n', 0 ); 335 351 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 344 362 345 363 } -
wp-persian/trunk/includes/class-wpp-hooks.php
r1875927 r1878538 36 36 $num_lang = 'fa'; 37 37 } 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 ); 39 39 40 40 return $j; … … 163 163 164 164 165 function wpp_disable_months_dropdown( $false , $post_type ) {165 public static function wpp_disable_months_dropdown( $false , $post_type ) { 166 166 $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' ); 168 169 if( in_array( $post_type , $disable_post_types ) ) { 169 170 $disable_months_dropdown = true; … … 212 213 } 213 214 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 } 214 262 215 263 /** … … 340 388 } 341 389 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 */354 390 355 391 public static function wpp_load_editphp() { 356 392 add_filter( "pre_get_posts", array( 'WPP_Hooks', 'wpp_filter_posts' ) ); 357 //add_filter('parse_query', array('WPP_Hooks','wpp_parse_admin_query') ); 393 358 394 add_filter('posts_where', array('WPP_Hooks','wpp_jalali_query') ); 395 396 359 397 360 398 } -
wp-persian/trunk/includes/jdf.php
r1875927 r1878538 17 17 18 18 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 20 20 $date=explode('_',date('H_i_j_n_O_P_s_w_Y',$ts)); 21 21 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 16 16 public function __construct() { 17 17 parent::__construct( 18 'wpp_ widget_jarchive', // Base ID18 'wpp_jarchive', // Base ID 19 19 __( 'Jalali Archive', 'wp-persian' ), // Name 20 20 array( 'description' => __( 'A jalali monthly archive of your site’s posts', 'wp-persian' ), ) // Args … … 87 87 $title = sanitize_text_field( $instance['title'] ); 88 88 ?> 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 90 91 class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" 91 92 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> 93 94 <p><input name="<?php echo $this->get_field_name( 'dropdown' ); ?>" type="checkbox" value="1" 94 95 id="<?php echo $this->get_field_id( 'dropdown' ); ?>" <?php checked( $instance['dropdown'] ); ?> /> -
wp-persian/trunk/includes/widgets/class-wpp-widget-jcalendar.php
r1872636 r1878538 13 13 public function __construct() { 14 14 parent::__construct( 15 ' jcalendar', // Base ID15 'wpp_jcalendar', // Base ID 16 16 __( 'Jalali Calendar', 'wp-persian' ), // Name 17 17 array( 'description' => __( 'A jalali calendar of your site’s posts', 'wp-persian' ), ) // Args … … 83 83 */ 84 84 public function update( $new_instance, $old_instance ) { 85 $instance = array();86 $instance['title'] = s trip_tags( $new_instance['title'] );85 $instance = $old_instance; 86 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 87 87 88 88 return $instance; … … 91 91 92 92 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'] ); 98 95 ?> 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> 105 98 <?php 106 99 } -
wp-persian/trunk/readme.txt
r1875952 r1878538 2 2 Contributors: salemi 3 3 Donate link: https://zarinp.al/22741 4 Tags: persian, farsi, jalali, date, calendar, iran, ltr, rtl, direction, shamsi, فارسی, تقویم, شمسی, هجری , خورشیدی, افزونه, جلالی, میلادی, پارسی, ایران, پیشرفته4 Tags: persian, farsi, jalali, date, calendar, iran, ltr, rtl, direction, shamsi, فارسی, تقویم, شمسی, هجری شمسی, افزونه, جلالی, میلادی, پارسی, ایران, پیشرفته 5 5 Requires at least: 4.0 6 Tested up to: 4.9. 57 Stable tag: 3. 0.26 Tested up to: 4.9.6 7 Stable tag: 3.1.0 8 8 License: GPL2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 16 16 17 17 = Farsi Description = 18 * فارسی ساز پیشرفته وردپرس 18 * تاریخ هجری شمسی در همه بخش ها حتی بخش آپلود عکس و مدیا 19 * تشخیص خودکار جهت متن ورودی در بخش مدیریت 19 20 * قابلیت تبدیل کلیه تاریخ های میلادی به هجری شمسی 20 21 * امکان تغییر زبان و تقویم بخش مدیریت و بخش کاربری به صورت مجزا 21 22 * به همراه راهنمای کامل تنظیمات به زبان فارسی 22 23 * بدون ایجاد تغییرات در هسته وردپرس 23 24 [راهنمای فارسی نگارش سوم](https://plugins.svn.wordpress.org/wp-persian/assets/help.pdf) 25 [راهنمای نصب فارسی نگارش سوم](https://plugins.svn.wordpress.org/wp-persian/assets/install.pdf) 24 26 25 27 = Features = … … 33 35 * Jalali Calendar widget. 34 36 * Jalali/Gregorian compatible permalinks. 35 36 [Download PDF document in persian](https://plugins.svn.wordpress.org/wp-persian/assets/help.pdf)37 37 [Video Demo](https://youtu.be/4BIaH5_y-u8) 38 38 … … 48 48 49 49 == 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 50 55 = 3.0.2 (May 17th,2018) = 51 56 * (UPDATE) update language repository -
wp-persian/trunk/uninstall.php
r1462478 r1878538 14 14 'wpp_tinymce_bidi_buttons', 15 15 'wpp_tinymce_css', 16 'wpp_adminpanel_co mplex_css',16 'wpp_adminpanel_context', 17 17 'wpp_adminpanel_numbers_post_content', 18 18 'wpp_adminpanel_numbers_post_excerpt', … … 37 37 'wpp_frontpage_numbers_date_i18n', 38 38 'wpp_frontpage_numbers_format_i18n', 39 'wpp_frontpage_letters' 39 'wpp_frontpage_letters', 40 'widget_wpp_jarchive', 41 'widget_wpp_jcalendar' 40 42 ); 41 43 -
wp-persian/trunk/wp-persian.php
r1875927 r1878538 6 6 * Plugin URI: https://wordpress.org/plugins/wp-persian/ 7 7 * 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. 28 * Version: 3.0.3 9 9 * Author: Siavash Salemi 10 10 * Author URI: http://www.30yavash.ir … … 19 19 20 20 21 define('WPPERSIAN_ID', 'wppersian');21 //define('WPPERSIAN_ID', 'wppersian'); 22 22 define('WPPERSIAN_NICK', 'WP Persian'); 23 define('WPPERSIAN_VER', '3.0.2');23 //define('WPPERSIAN_VER', '3.0.3'); 24 24 25 25 /** @define "WPP_DIR" "./" */ … … 30 30 31 31 32 require_once(WPP_DIR.'includes/jdf.php'); 33 require_once(WPP_DIR.'includes/wpp- helper.php');34 32 /* 33 require_once(WPP_DIR.'includes/wpp-jdate.php'); 34 require_once(WPP_DIR.'includes/wpp-farsi.php'); 35 35 require_once(WPP_DIR.'includes/general-template.php'); 36 37 36 require_once(WPP_DIR.'includes/class-wpp-hooks.php'); 38 37 */ 39 38 40 39 require_once(WPP_DIR.'includes/class-wp-persian.php');
Note: See TracChangeset
for help on using the changeset viewer.