Version Description
*
Download this release
Release Info
Developer | Persianscript |
Plugin | Persian Woocommerce |
Version | 2.6.2 |
Comparing to | |
See all releases |
Code changes from version 2.6.1 to 2.6.2
- include/class-yahoo-download-problem.php +128 -0
- readme.txt +4 -0
- woocommerce-persian.php +2 -1
include/class-yahoo-download-problem.php
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) )
|
3 |
+
exit; // Exit if accessed directly
|
4 |
+
|
5 |
+
class wc_yahoo_redirect {
|
6 |
+
|
7 |
+
private static $yahoo;
|
8 |
+
|
9 |
+
public function __construct() {
|
10 |
+
|
11 |
+
self::$yahoo = base64_encode('yahoo.com');
|
12 |
+
|
13 |
+
if ( defined('WC_YAHOO') ) {
|
14 |
+
self::$yahoo = WC_YAHOO;
|
15 |
+
}
|
16 |
+
|
17 |
+
add_filter( 'woocommerce_get_item_downloads' , array( $this , 'woocommerce_get_item_downloads') , 10 , 3 );
|
18 |
+
|
19 |
+
add_filter( 'woocommerce_account_download_actions' , array( $this , 'woocommerce_account_download_actions') , 10 , 2 );
|
20 |
+
|
21 |
+
add_filter( 'woocommerce_available_download_link' , array( $this , 'woocommerce_available_download_link') , 10 , 2 );
|
22 |
+
|
23 |
+
if ( isset( $_GET['download_file'] ) && isset( $_GET['order'] ) && isset( $_GET['email'] ) && stripos( $_GET['email'] , self::$yahoo ) !== false ) {
|
24 |
+
|
25 |
+
add_action( 'init', array( __CLASS__ , 'download_product' ) );
|
26 |
+
|
27 |
+
remove_action( 'init', array( 'WC_Download_Handler' , 'download_product' ) );
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
public function woocommerce_get_item_downloads( $files, $item, $obj ) {
|
32 |
+
|
33 |
+
$edited_files = array();
|
34 |
+
|
35 |
+
foreach ( $files as $download_id => $val ) {
|
36 |
+
$edited_files[$download_id] = $files[$download_id];
|
37 |
+
$edited_files[$download_id]['download_url'] = str_replace( 'yahoo.com' , self::$yahoo , $files[$download_id]['download_url']);
|
38 |
+
}
|
39 |
+
|
40 |
+
return $edited_files;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function woocommerce_account_download_actions( $actions, $download ) {
|
44 |
+
|
45 |
+
$actions['download']['url'] = str_replace( 'yahoo.com' , self::$yahoo , $actions['download']['url'] );
|
46 |
+
|
47 |
+
return $actions;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function woocommerce_available_download_link( $download_url , $download ) {
|
51 |
+
|
52 |
+
$download_url = str_replace( 'yahoo.com' , self::$yahoo , $download_url );
|
53 |
+
|
54 |
+
return $download_url;
|
55 |
+
}
|
56 |
+
|
57 |
+
public static function download_product() {
|
58 |
+
$product_id = absint( $_GET['download_file'] );
|
59 |
+
$_product = wc_get_product( $product_id );
|
60 |
+
$download_data = self::get_download_data( array(
|
61 |
+
'product_id' => $product_id,
|
62 |
+
'order_key' => wc_clean( $_GET['order'] ),
|
63 |
+
'email' => sanitize_email( str_replace( array(' ', self::$yahoo ), array('+', 'yahoo.com'), $_GET['email'] ) ),
|
64 |
+
'download_id' => wc_clean( isset( $_GET['key'] ) ? preg_replace( '/\s+/', ' ', $_GET['key'] ) : '' )
|
65 |
+
) );
|
66 |
+
|
67 |
+
if ( $_product && $download_data ) {
|
68 |
+
|
69 |
+
if ( $download_data->order_id && ( $order = wc_get_order( $download_data->order_id ) ) && ! $order->is_download_permitted() ) {
|
70 |
+
self::download_error( __( 'Invalid order.', 'woocommerce' ), '', 403 ); //
|
71 |
+
}
|
72 |
+
|
73 |
+
if ( '0' == $download_data->downloads_remaining ) {
|
74 |
+
self::download_error( __( 'Sorry, you have reached your download limit for this file', 'woocommerce' ), '', 403 );
|
75 |
+
}
|
76 |
+
|
77 |
+
if ( $download_data->access_expires > 0 && strtotime( $download_data->access_expires ) < strtotime( 'midnight', current_time( 'timestamp' ) ) ) {
|
78 |
+
self::download_error( __( 'Sorry, this download has expired', 'woocommerce' ), '', 403 );
|
79 |
+
}
|
80 |
+
|
81 |
+
if ( $download_data->user_id && 'yes' === get_option( 'woocommerce_downloads_require_login' ) ) {
|
82 |
+
if ( ! is_user_logged_in() ) {
|
83 |
+
if ( wc_get_page_id( 'myaccount' ) ) {
|
84 |
+
wp_safe_redirect( add_query_arg( 'wc_error', urlencode( __( 'You must be logged in to download files.', 'woocommerce' ) ), wc_get_page_permalink( 'myaccount' ) ) );
|
85 |
+
exit;
|
86 |
+
} else {
|
87 |
+
self::download_error( __( 'You must be logged in to download files.', 'woocommerce' ) . ' <a href="' . esc_url( wp_login_url( wc_get_page_permalink( 'myaccount' ) ) ) . '" class="wc-forward">' . __( 'Login', 'woocommerce' ) . '</a>', __( 'Log in to Download Files', 'woocommerce' ), 403 );
|
88 |
+
}
|
89 |
+
} elseif ( ! current_user_can( 'download_file', $download_data ) ) {
|
90 |
+
self::download_error( __( 'This is not your download link.', 'woocommerce' ), '', 403 );
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
do_action( 'woocommerce_download_product', $download_data->user_email, $download_data->order_key, $download_data->product_id, $download_data->user_id, $download_data->download_id, $download_data->order_id );
|
95 |
+
|
96 |
+
WC_Download_Handler::count_download( $download_data );
|
97 |
+
WC_Download_Handler::download( $_product->get_file_download_path( $download_data->download_id ), $download_data->product_id );
|
98 |
+
} else {
|
99 |
+
self::download_error( __( 'Invalid download link.', 'woocommerce' ) );
|
100 |
+
}
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
private static function get_download_data( $args = array() ) {
|
105 |
+
global $wpdb;
|
106 |
+
|
107 |
+
$query = "SELECT * FROM " . $wpdb->prefix . "woocommerce_downloadable_product_permissions ";
|
108 |
+
$query .= "WHERE user_email = %s ";
|
109 |
+
$query .= "AND order_key = %s ";
|
110 |
+
$query .= "AND product_id = %s ";
|
111 |
+
|
112 |
+
if ( $args['download_id'] ) {
|
113 |
+
$query .= "AND download_id = %s ";
|
114 |
+
}
|
115 |
+
|
116 |
+
$query .= "ORDER BY downloads_remaining DESC";
|
117 |
+
|
118 |
+
return $wpdb->get_row( $wpdb->prepare( $query, array( $args['email'], $args['order_key'], $args['product_id'], $args['download_id'] ) ) );
|
119 |
+
}
|
120 |
+
|
121 |
+
private static function download_error( $message, $title = '', $status = 404 ) {
|
122 |
+
if ( ! strstr( $message, '<a ' ) ) {
|
123 |
+
$message .= ' <a href="' . esc_url( wc_get_page_permalink( 'shop' ) ) . '" class="wc-forward">' . __( 'Go to shop', 'woocommerce' ) . '</a>';
|
124 |
+
}
|
125 |
+
wp_die( $message, $title, array( 'response' => $status ) );
|
126 |
+
}
|
127 |
+
}
|
128 |
+
new wc_yahoo_redirect();
|
readme.txt
CHANGED
@@ -53,6 +53,8 @@ You can read complete documentations on the [woocommerce.ir](http://www.woocomme
|
|
53 |
|
54 |
|
55 |
== Changelog ==
|
|
|
|
|
56 |
= 2.6.1 =
|
57 |
* رفع نقص
|
58 |
= 2.6 =
|
@@ -101,6 +103,8 @@ You can read complete documentations on the [woocommerce.ir](http://www.woocomme
|
|
101 |
* نسخه اولیه
|
102 |
|
103 |
== Upgrade Notice ==
|
|
|
|
|
104 |
= 2.6.1 =
|
105 |
* رفع نقص
|
106 |
= 2.6 =
|
53 |
|
54 |
|
55 |
== Changelog ==
|
56 |
+
= 2.6.2 =
|
57 |
+
* رفع مشکل عدم دانلود محصولات با ایمیل یاهو
|
58 |
= 2.6.1 =
|
59 |
* رفع نقص
|
60 |
= 2.6 =
|
103 |
* نسخه اولیه
|
104 |
|
105 |
== Upgrade Notice ==
|
106 |
+
= 2.6.2 =
|
107 |
+
* رفع مشکل عدم دانلود محصولات با ایمیل یاهو
|
108 |
= 2.6.1 =
|
109 |
* رفع نقص
|
110 |
= 2.6 =
|
woocommerce-persian.php
CHANGED
@@ -4,7 +4,7 @@ Contributors: Persianscript, hannanstd, mahdiy
|
|
4 |
Plugin Name: ووکامرس پارسی
|
5 |
Plugin URI: http://woocommerce.ir
|
6 |
Description: بسته فارسی ساز ووکامرس پارسی به راحتی سیستم فروشگاه ساز ووکامرس را فارسی می کند. با فعال سازی افزونه ، واحد پولی ریال و تومان ایران و همچنین لیست استان های ایران به افزونه افزوده می شوند. پشتیبانی در <a href="http://www.woocommerce.ir/" target="_blank">ووکامرس پارسی</a>.
|
7 |
-
Version: 2.6.
|
8 |
Requires at least: 5.0
|
9 |
Author: ووکامرس فارسی
|
10 |
Author URI: http://woocommerce.ir
|
@@ -26,6 +26,7 @@ Author URI: http://woocommerce.ir
|
|
26 |
require_once( dirname(__FILE__) . '/include/class-currency.php');
|
27 |
require_once( dirname(__FILE__) . '/include/class-rtl.php');
|
28 |
require_once( dirname(__FILE__) . '/include/class-widget.php');
|
|
|
29 |
|
30 |
register_activation_hook( __FILE__ , array('Persian_Wooommerce_Plugin', 'persian_wc_install') );
|
31 |
|
4 |
Plugin Name: ووکامرس پارسی
|
5 |
Plugin URI: http://woocommerce.ir
|
6 |
Description: بسته فارسی ساز ووکامرس پارسی به راحتی سیستم فروشگاه ساز ووکامرس را فارسی می کند. با فعال سازی افزونه ، واحد پولی ریال و تومان ایران و همچنین لیست استان های ایران به افزونه افزوده می شوند. پشتیبانی در <a href="http://www.woocommerce.ir/" target="_blank">ووکامرس پارسی</a>.
|
7 |
+
Version: 2.6.2
|
8 |
Requires at least: 5.0
|
9 |
Author: ووکامرس فارسی
|
10 |
Author URI: http://woocommerce.ir
|
26 |
require_once( dirname(__FILE__) . '/include/class-currency.php');
|
27 |
require_once( dirname(__FILE__) . '/include/class-rtl.php');
|
28 |
require_once( dirname(__FILE__) . '/include/class-widget.php');
|
29 |
+
require_once( dirname(__FILE__) . '/include/class-yahoo-download-problem.php');
|
30 |
|
31 |
register_activation_hook( __FILE__ , array('Persian_Wooommerce_Plugin', 'persian_wc_install') );
|
32 |
|