Skip to content

Commit

Permalink
Fix Some problems in incompleted pr :(
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamid Reza Yazdani committed Mar 11, 2024
1 parent 72c0c1a commit eda7766
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 134 deletions.
1 change: 0 additions & 1 deletion assets/js/wc-pg-blocks/wpp-wc-mellat-pg.min.min.js

This file was deleted.

1 change: 0 additions & 1 deletion assets/js/wc-pg-blocks/wpp-wc-parsian-pg.min.min.js

This file was deleted.

4 changes: 2 additions & 2 deletions assets/js/wc-pg-blocks/wpp-wc-pasargad-pg.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const wppPasargadPG_data = window.wc.wcSettings.getSetting( 'parsian_data', {} );
const wppPasargadPG_data = window.wc.wcSettings.getSetting( 'pasargad_data', {} );
const wppPasargadPG_label = window.wp.htmlEntities.decodeEntities( wppPasargadPG_data.title )
|| window.wp.i18n.__( 'Pasargad Bank', 'wp-parsidate' );
const wppPasargadPG_content = ( wppPasargadPG_data ) => {
return window.wp.htmlEntities.decodeEntities( wppPasargadPG_data.description );
};
const wppPasargadPG = {
name: 'parsian',
name: 'pasargad',
label: wppPasargadPG_label,
content: Object( window.wp.element.createElement )( wppPasargadPG_content, null ),
edit: Object( window.wp.element.createElement )( wppPasargadPG_content, null ),
Expand Down
2 changes: 1 addition & 1 deletion assets/js/wc-pg-blocks/wpp-wc-pasargad-pg.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion assets/js/wc-pg-blocks/wpp-wc-pasargad-pg.min.min.js

This file was deleted.

1 change: 1 addition & 0 deletions includes/plugins/wc-gateways/wc-gateways.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function add_settings( $old_settings ) {
'std' => array( 'parsian', 'pasargad', 'mellat' )
)
);
var_dump('ddddddddddddddddddddd');

return array_merge( $old_settings, $settings );
}
Expand Down
51 changes: 27 additions & 24 deletions includes/plugins/woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class WPP_WooCommerce {
* Hooks required tags
*/
private function __construct() {
$this->include_files();

add_filter( 'wpp_plugins_compatibility_settings', array( $this, 'add_settings' ) );

if ( class_exists( 'WooCommerce' ) && get_locale() === 'fa_IR' ) {
Expand All @@ -30,7 +32,9 @@ private function __construct() {
add_filter( 'woocommerce_cart_total', 'fix_number' );
}

if ( wpp_is_active( 'woo_fix_date' ) ) {
if ( wpp_is_active( 'persian_date' ) ) {
add_action( 'wp_head', array( $this, 'fix_wc_date_time_direction' ) );
add_filter( 'woocommerce_email_styles', array( $this, 'fix_emails_order_date_direction' ), 9999, 2 );
// Jalali datepicker
add_action( 'admin_enqueue_scripts', array( $this, 'wpp_admin_woocommerce_jalali_datepicker_assets' ) );

Expand All @@ -46,7 +50,6 @@ private function __construct() {
}

add_filter( 'woocommerce_checkout_process', array( $this, 'wpp_accept_persian_numbers_in_checkout' ), 20 );

add_filter( 'woocommerce_checkout_posted_data', array( $this, 'wpp_convert_non_persian_values_in_checkout' ), 10 );

if ( wpp_is_active( 'woo_validate_postcode' ) ) {
Expand All @@ -56,15 +59,6 @@ private function __construct() {
if ( wpp_is_active( 'woo_validate_phone' ) ) {
add_action( 'woocommerce_after_checkout_validation', array( $this, 'wpp_validate_phone_number' ), 10, 2 );
}

if ( wpp_is_active( 'woo_dropdown_cities' ) ) {
include_once WP_PARSI_DIR . 'includes/plugins/wc-cities/wc-city-select.php';
}

if ( get_locale() == 'fa_IR' && wpp_is_active( 'persian_date' ) ) {
add_filter( 'woocommerce_email_styles', array( $this, 'fix_emails_order_date_direction' ), 9999, 2 );
add_action( 'woocommerce_before_account_navigation', array( $this, 'fix_myaccount_order_date_direction' ) );
}
}
}

Expand All @@ -81,6 +75,20 @@ public static function getInstance() {
return self::$instance;
}

/**
* Includes files for WooCommerce payment gateways
*
* @return void
* @since 4.0.1
*/
public function include_files() {
if ( wpp_is_active( 'woo_dropdown_cities' ) ) {
include_once WP_PARSI_DIR . 'includes/plugins/wc-cities/wc-city-select.php';
}

require_once( WP_PARSI_DIR . 'includes/plugins/wc-gateways/wc-gateways.php' );
}

/**
* Adds settings for toggle fixing
*
Expand All @@ -90,19 +98,12 @@ public static function getInstance() {
* @since 4.0.0
*/
public function add_settings( $old_settings ) {
$settings = array(
$settings = apply_filters( 'wpp_woocommerce_settings', array(
'woocommerce' => array(
'id' => 'woocommerce',
'name' => __( 'WooCommerce', 'wp-parsidate' ),
'type' => 'header'
),
'woo_fix_date' => array(
'id' => 'woo_fix_date',
'name' => __( 'Jalali Datepicker', 'wp-parsidate' ),
'type' => 'checkbox',
'options' => 1,
'std' => 0
),
'woo_per_price' => array(
'id' => 'woo_per_price',
'name' => __( 'Fix prices', 'wp-parsidate' ),
Expand Down Expand Up @@ -144,8 +145,8 @@ public function add_settings( $old_settings ) {
'type' => 'checkbox',
'options' => 1,
'std' => 0
)
);
),
) );

return array_merge( $old_settings, $settings );
}
Expand All @@ -167,7 +168,7 @@ public function wpp_admin_woocommerce_jalali_datepicker_assets() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || wpp_is_active( 'dev_mode' ) ? '' : '.min';
$current_screen = $screen->post_type;

if ( wpp_is_active( 'woo_fix_date' ) && in_array( $current_screen, array( 'product', 'shop_order', 'shop_coupon', 'wc-reports' ) ) ) {
if ( wpp_is_active( 'persian_date' ) && in_array( $current_screen, array( 'product', 'shop_order', 'shop_coupon', 'wc-reports' ) ) ) {
wp_enqueue_script( 'wpp_jalali_datepicker', WP_PARSI_URL . 'assets/js/jalalidatepicker.min.js', array( 'jquery', 'jquery-ui-datepicker' ), WP_PARSI_VER );

wp_enqueue_style( 'wpp_jalali_datepicker', WP_PARSI_URL . "assets/css/jalalidatepicker$suffix.css", null, WP_PARSI_VER );
Expand Down Expand Up @@ -548,8 +549,10 @@ public function fix_emails_order_date_direction( $style, $email ) {
* @return void
* @since 5.0.0
*/
public function fix_myaccount_order_date_direction() {
echo '<style>mark.order-date{unicode-bidi:embed!important}</style>';
public function fix_wc_date_time_direction() {
if ( is_woocommerce() || is_wc_endpoint_url() || is_cart() || is_checkout() ) {
echo '<style>mark.order-date,time{unicode-bidi:embed!important}</style>';
}
}
}

Expand Down
Loading

0 comments on commit eda7766

Please sign in to comment.