-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from omise/release/1.2.1
Release 1.2.1
- Loading branch information
Showing
19 changed files
with
750 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
**1. Objective reason** | ||
|
||
Explain in non-technical terms why this PR is required. | ||
E.g.: What feature it adds, what problem it solves, ... | ||
|
||
This section is used in the release notes. | ||
|
||
Related ticket: [Issue ID](https://git.omise.co/omise/omise-woocommerce/issues/) | ||
|
||
**2. Description of change** | ||
|
||
A description of WHAT changed in the codebase. Additionally add the reasoning if it's complex or abstract. But not the diff, that's what 'git diff' is for. | ||
|
||
**3. Users affected by the change** | ||
|
||
All, None or Specific Developer(s). | ||
|
||
**4. Impact of the change** | ||
|
||
List the steps that must be taken for this PR to work. | ||
E.g.: `rake yak:shave`, `Add "yak_key" to environment variables, ...` | ||
|
||
Be sure to include all systems that needs to be changed or which system is affected by | ||
the change (Ex: Requires Elastic search to be installed and configured in `secrets.yml`). | ||
|
||
**5. Priority of change** | ||
|
||
Normal, High or Immediate. | ||
|
||
**6. Alternate solution (if any)** | ||
|
||
Could we have done this any other way? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
<?php | ||
defined( 'ABSPATH' ) or die( "No direct script access allowed." ); | ||
|
||
if ( ! class_exists( 'Omise_Card_Image' ) ) { | ||
class Omise_Card_Image { | ||
/** | ||
* Compose the given parameters into the string of HTML <img> element | ||
* | ||
* @param string $file Image file name with extension such as image.jpg | ||
* @param string $alternate_text Alternate text for the image | ||
* @return string HTML <img> element | ||
*/ | ||
private static function get_image( $file, $alternate_text ) { | ||
$url = WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/' ); | ||
return "<img src='$url/$file' width='38px' alt='$alternate_text' />"; | ||
} | ||
|
||
/** | ||
* Return the default setting of display the American Express logo | ||
* | ||
* @return string | ||
*/ | ||
public static function get_amex_default_display() { | ||
return 'no'; | ||
} | ||
|
||
/** | ||
* Return the HTML <img> element of American Express logo | ||
* | ||
* @return string | ||
*/ | ||
public static function get_amex_image() { | ||
return self::get_image( 'amex.svg', 'American Express' ); | ||
} | ||
|
||
/** | ||
* Return the CSS used to format the image to be displayed vertical center align with checkbox | ||
* at the back-end setting page | ||
* | ||
* @return string | ||
*/ | ||
public static function get_css() { | ||
return 'vertical-align: 5px;'; | ||
} | ||
|
||
/** | ||
* Return the default setting of display the Diners Club logo | ||
* | ||
* @return string | ||
*/ | ||
public static function get_diners_default_display() { | ||
return 'no'; | ||
} | ||
|
||
/** | ||
* Return the HTML <img> element of Diners Club logo | ||
* | ||
* @return string | ||
*/ | ||
public static function get_diners_image() { | ||
return self::get_image( 'diners.svg', 'Diners Club' ); | ||
} | ||
|
||
/** | ||
* Return the default setting of display the JCB logo | ||
* | ||
* @return string | ||
*/ | ||
public static function get_jcb_default_display() { | ||
return 'no'; | ||
} | ||
|
||
/** | ||
* Return the HTML <img> element of JCB logo | ||
* | ||
* @return string | ||
*/ | ||
public static function get_jcb_image() { | ||
return self::get_image( 'jcb.svg', 'JCB' ); | ||
} | ||
|
||
/** | ||
* Return the default setting of display the MasterCard logo | ||
* | ||
* @return string | ||
*/ | ||
public static function get_mastercard_default_display() { | ||
return 'yes'; | ||
} | ||
|
||
/** | ||
* Return the HTML <img> element of MasterCard logo | ||
* | ||
* @return string | ||
*/ | ||
public static function get_mastercard_image() { | ||
return self::get_image( 'mastercard.svg', 'MasterCard' ); | ||
} | ||
|
||
/** | ||
* Return the default setting of display the Visa logo | ||
* | ||
* @return string | ||
*/ | ||
public static function get_visa_default_display() { | ||
return 'yes'; | ||
} | ||
|
||
/** | ||
* Return the HTML <img> element of Visa logo | ||
* | ||
* @return string | ||
*/ | ||
public static function get_visa_image() { | ||
return self::get_image( 'visa.svg', 'Visa' ); | ||
} | ||
|
||
/** | ||
* Check whether the setting for American Express logo is configured and it was set to display or not display | ||
* | ||
* @param mixed $setting The array that contains key for checking the flag | ||
* @return boolean | ||
*/ | ||
public static function is_amex_enabled( $setting ) { | ||
if ( isset( $setting['accept_amex'] ) && $setting['accept_amex'] == 'yes' ) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Check whether the setting for Diners Club logo is configured and it was set to display or not display | ||
* | ||
* @param mixed $setting The array that contains key for checking the flag | ||
* @return boolean | ||
*/ | ||
public static function is_diners_enabled( $setting ) { | ||
if ( isset( $setting['accept_diners'] ) && $setting['accept_diners'] == 'yes' ) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Check whether the setting for JCB logo is configured and it was set to display or not display | ||
* | ||
* @param mixed $setting The array that contains key for checking the flag | ||
* @return boolean | ||
*/ | ||
public static function is_jcb_enabled( $setting ) { | ||
if ( isset( $setting['accept_jcb'] ) && $setting['accept_jcb'] == 'yes' ) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Check whether the setting for MasterCard logo is configured and it was set to display or not display | ||
* | ||
* @param mixed $setting The array that contains key for checking the flag | ||
* @return boolean | ||
*/ | ||
public static function is_mastercard_enabled( $setting ) { | ||
// Make it backward compatible. If the setting is not configured, the MasterCard logo is display by default. | ||
if ( ! isset( $setting['accept_mastercard'] ) ) { | ||
return self::get_mastercard_default_display(); | ||
} | ||
|
||
if ( $setting['accept_mastercard'] == 'yes' ) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Check whether the setting for Visa logo is configured and it was set to display or not display | ||
* | ||
* @param mixed $setting The array that contains key for checking the flag | ||
* @return boolean | ||
*/ | ||
public static function is_visa_enabled( $setting ) { | ||
// Make it backward compatible. If the setting is not configured, the Visa logo is display by default. | ||
if ( ! isset( $setting['accept_visa'] ) ) { | ||
return self::get_visa_default_display(); | ||
} | ||
|
||
if ( $setting['accept_visa'] == 'yes' ) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.