Skip to content

Commit c830d56

Browse files
committed
Update README.md
1 parent 3e270d0 commit c830d56

16 files changed

+44
-42
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3333

3434
- name: Install Composer
35-
run: composer install --no-interaction --no-progress --optimize-autoloader --no-suggest
35+
run: composer install --no-interaction --no-progress --optimize-autoloader
3636

3737
- name: Run PHP Lint
3838
run: composer lint

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@ To enable mailhog for debug, follow the instruction below.
5656
# Get docker container ID.
5757
# Notice: run npm start before this step.
5858
npm run path
59-
# You will get container ID at the .
59+
# You will get container ID at the base name e.g. 0597019337936df00cda1cf5a15016e0
60+
# Save it as .wp_install_path
61+
touch .wp_install_path
62+
echo 0597019337936df00cda1cf5a15016e0 > .wp_install_path
63+
# Restart docker.
64+
npm run update
65+
# Open http://localhost:8025
66+
```
6067

6168
## License
6269

src/Hametuha/HametWoo.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ public function template_fallback( $template, $template_name, $template_path ) {
5252
* @return string
5353
*/
5454
public static function root_dir() {
55-
return dirname( dirname( __DIR__ ) );
55+
return dirname( __DIR__, 2 );
5656
}
5757

5858
/**
59-
* Send email short hand.
59+
* Send email shorthand.
6060
*
6161
* @param string $mail_id Mail ID.
6262
* @param array $arguments Argument passed to $mailer->trigger.
@@ -65,7 +65,7 @@ public function send_mail( $mail_id, $arguments = [] ) {
6565
$mailers = WC()->mailer()->get_emails();
6666
foreach ( $mailers as $mailer ) {
6767
/* @var \WC_Email $mailer */
68-
if ( $mail_id == $mailer->id ) {
68+
if ( $mail_id === $mailer->id ) {
6969
if ( $arguments ) {
7070
call_user_func_array( [ $mailer, 'trigger' ], $arguments );
7171
} else {

src/Hametuha/HametWoo/Custom/Email.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Email extends Singleton {
1616
* Activate Custom emails.
1717
*/
1818
public static function activate() {
19-
add_filter( 'woocommerce_email_classes', function( $email_classes ) {
19+
add_filter( 'woocommerce_email_classes', function ( $email_classes ) {
2020
$email_classes['Hametuha_Hametwoo_Emails_CancelNotification'] = new CancelNotification();
2121
return $email_classes;
2222
} );

src/Hametuha/HametWoo/Emails/CancelNotification.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public function is_enabled() {
2626
* Mail Constructor
2727
*/
2828
public function __construct() {
29-
$this->id = 'hametwoo_cancel_notification';
29+
$this->id = 'hametwoo_cancel_notification';
3030
$this->customer_email = true;
31-
$this->title = __( 'Order Cancel Notification', 'hametwoo' );
32-
$this->description = __( 'Send notification email to customer if the order is automatically cancelled.', 'hametwoo' );
33-
$this->heading = __( 'Order Cancelled', 'hametwoo' );
34-
$this->subject = __( 'Your order #{order_number} has been cancelled at {order_date}', 'hametwoo' );
31+
$this->title = __( 'Order Cancel Notification', 'hametwoo' );
32+
$this->description = __( 'Send notification email to customer if the order is automatically cancelled.', 'hametwoo' );
33+
$this->heading = __( 'Order Cancelled', 'hametwoo' );
34+
$this->subject = __( 'Your order #{order_number} has been cancelled at {order_date}', 'hametwoo' );
3535
$this->template_html = 'emails/customer-cancel-notification.php';
3636
$this->template_plain = 'emails/plain/customer-cancel-notification.php';
3737
$this->template_base = HametWoo::root_dir() . '/templates/';
@@ -71,14 +71,14 @@ public function trigger( $order_id ) {
7171
// Don't send with no reason.
7272
return;
7373
}
74-
$this->object = $order;
74+
$this->object = $order;
7575
$this->recipient = $this->object->billing_email;
7676
// Is html?
7777
foreach ( [
7878
'order_number' => $order->get_order_number(),
79-
'order_date' => date_i18n( get_option( 'date_format' ) ),
79+
'order_date' => date_i18n( get_option( 'date_format' ) ),
8080
] as $find => $result ) {
81-
$this->find[ $find ] = "{{$find}}";
81+
$this->find[ $find ] = "{{$find}}";
8282
$this->replace[ $find ] = $result;
8383
}
8484
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
@@ -96,7 +96,7 @@ public function get_content_html() {
9696
'email_heading' => $this->get_heading(),
9797
'sent_to_admin' => false,
9898
'plain_text' => false,
99-
'email' => $this,
99+
'email' => $this,
100100
] );
101101
}
102102

@@ -112,7 +112,7 @@ public function get_content_plain() {
112112
'email_heading' => $this->get_heading(),
113113
'sent_to_admin' => false,
114114
'plain_text' => true,
115-
'email' => $this,
115+
'email' => $this,
116116
] );
117117
}
118118
}

src/Hametuha/HametWoo/Pattern/AbstractMaster.php

-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ abstract class AbstractMaster {
1515
final private function __construct() {
1616
// Do nothing.
1717
}
18-
1918
}

src/Hametuha/HametWoo/Pattern/Singleton.php

-1
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,4 @@ final public static function get_instance() {
4040
}
4141
return self::$instances[ $class_name ];
4242
}
43-
4443
}

src/Hametuha/HametWoo/Pattern/Tab.php

-1
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,4 @@ public function add_query_vars( $vars ) {
113113

114114
return $vars;
115115
}
116-
117116
}

src/Hametuha/HametWoo/Pattern/Updater.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function __construct() {
4444
* @param string $current_version Version of plugin.
4545
*/
4646
public static function init( $current_version ) {
47-
$instance = static::get_instance();
47+
$instance = static::get_instance();
4848
$instance->current_version = $current_version;
4949
}
5050

@@ -106,12 +106,12 @@ protected function parse_result( $response ) {
106106
* @return object
107107
*/
108108
protected function remote_get_version() {
109-
$key = $this->cache_key;
109+
$key = $this->cache_key;
110110
$version = get_site_transient( $key );
111111
if ( false !== $version ) {
112112
return $version;
113113
}
114-
$url = $this->timestamped_endpoint( $this->endpoint() );
114+
$url = $this->timestamped_endpoint( $this->endpoint() );
115115
$response = wp_remote_get( $url );
116116
if ( is_wp_error( $response ) ) {
117117
$version = $this->parse_result( $response );
@@ -180,8 +180,8 @@ public function plugins_api_result( $response, $action, $args ) {
180180
*/
181181
public function wp_get_update_data( $update_data, $titles ) {
182182
if ( $this->has_update() ) {
183-
$update_data['counts']['plugins']++;
184-
$update_data['counts']['total']++;
183+
++$update_data['counts']['plugins'];
184+
++$update_data['counts']['total'];
185185
$titles['plugins'] = sprintf(
186186
/* translators: %d: Count of plugins to update */
187187
_n( '%d Plugin Update', '%d Plugin Updates', $update_data['counts']['plugins'], 'hametwoo' ),

src/Hametuha/HametWoo/Pattern/Validator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Validator extends Singleton {
3232
*/
3333
public static function validate() {
3434
$instance = static::get_instance();
35-
$error = new \WP_Error();
35+
$error = new \WP_Error();
3636
foreach ( get_class_methods( $instance ) as $method ) {
3737
$repl = new \ReflectionMethod( get_called_class(), $method );
3838
// Check if method is public.
@@ -48,6 +48,6 @@ public static function validate() {
4848
$error->add( $result->get_error_code(), $result->get_error_message() );
4949
}
5050
}
51-
return $error->get_error_messages()? $error : true;
51+
return $error->get_error_messages() ? $error : true;
5252
}
5353
}

src/Hametuha/HametWoo/Utility/Compatibility.php

-1
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,4 @@ public static function get_currency() {
101101
public static function check_currency( $currency ) {
102102
return self::get_currency() === $currency;
103103
}
104-
105104
}

src/Hametuha/HametWoo/Utility/OrderHandler.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ public static function restore_stock( $order ) {
3131
$restored = false;
3232
foreach ( $order->get_items( 'line_item' ) as $item ) {
3333
/* @var \WC_Order_Item_Product $item Order item. */
34-
$qty = $item->get_quantity();
34+
$qty = $item->get_quantity();
3535
$product = $item->get_product();
3636
if ( ! $qty || ! $product || ! $product->managing_stock() ) {
3737
continue;
3838
}
39-
$name = $product->get_formatted_name();
39+
$name = $product->get_formatted_name();
4040
$current_stock = $product->get_stock_quantity();
41-
$new_stock = wc_update_product_stock( $product, $qty, 'increase' );
41+
$new_stock = wc_update_product_stock( $product, $qty, 'increase' );
4242
if ( ! $new_stock ) {
4343
// Oops, failed to update stock.
4444
continue;

src/Hametuha/HametWoo/Utility/Tools.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ protected function post_data( $key ) {
103103
* @return array
104104
*/
105105
public function card_icons() {
106-
$icons = [];
106+
$icons = [];
107107
$base_url = WC()->plugin_url() . '/assets/images/icons/credit-cards/';
108108
$base_dir = WC()->plugin_path() . '/assets/images/icons/credit-cards/';
109109
if ( is_dir( $base_dir ) ) {
@@ -140,7 +140,6 @@ public function card_css( $selector = '.wc-credit-card-form-card-number' ) {
140140
CSS;
141141
}
142142
return sprintf( '<style type="text/css">%s</style>', $css );
143-
144143
}
145144

146145
/**
@@ -164,5 +163,4 @@ public function __get( $name ) {
164163
break;
165164
}
166165
}
167-
168166
}

src/Hametuha/HametWoo/Utility/UniqueId.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ public static function generate( $length = 16 ) {
3030
} elseif ( function_exists( 'openssl_random_pseudo_bytes' ) ) {
3131
return bin2hex( openssl_random_pseudo_bytes( $length ) );
3232
} else {
33-
$id = uniqid();
34-
$hash = '';
33+
$id = uniqid();
34+
$hash = '';
3535
$str_len = strlen( $id );
36-
$limit = floor( $length * 2 / $str_len );
36+
$limit = floor( $length * 2 / $str_len );
3737
for ( $i = 0; $i < $limit; $i++ ) {
3838
$hash .= $id;
3939
}

templates/emails/customer-cancel-notification.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@
3636

3737
<?php
3838
$reason = $order->get_meta( '_hametwoo_cancel_reason' );
39-
if ( $reason ) : ?>
39+
if ( $reason ) :
40+
?>
4041
<p>
41-
<strong><?php esc_html_e( 'Reason:', 'hametwoo' ) ?></strong><br />
42-
<?php echo esc_html( $reason ) ?>
42+
<strong><?php esc_html_e( 'Reason:', 'hametwoo' ); ?></strong><br />
43+
<?php echo esc_html( $reason ); ?>
4344
</p>
4445
<?php endif; ?>
4546

templates/emails/plain/customer-cancel-notification.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
exit;
1616
}
1717

18-
echo "= " . $email_heading . " =\n\n";
18+
echo '= ' . $email_heading . " =\n\n";
1919

20-
printf( __( 'Dear %s,', 'hametwoo' ), $order->get_formatted_billing_full_name() ). "\n";
21-
printf( __( 'Your order #%d has been automatically cancelled.', 'hametwoo' ), $order->get_order_number() )."\n\n";
20+
printf( __( 'Dear %s,', 'hametwoo' ), $order->get_formatted_billing_full_name() ) . "\n";
21+
printf( __( 'Your order #%d has been automatically cancelled.', 'hametwoo' ), $order->get_order_number() ) . "\n\n";
2222
$reason = $order->get_meta( '_hametwoo_cancel_reason' );
2323
if ( $reason ) {
2424
esc_html_e( 'Reason:', 'hametwoo' );

0 commit comments

Comments
 (0)