| 1 |
<?php |
| 2 |
/** |
| 3 |
* Includes global functions that can be accessible without class name |
| 4 |
* or objects throught the WordPress |
| 5 |
* |
| 6 |
* @package SupportCandy |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Perform outside scope translations within plugin or addons |
| 11 |
* |
| 12 |
* @param string $text - string to be translated. |
| 13 |
* @param string $domain - textdomain. |
| 14 |
* @return string |
| 15 |
*/ |
| 16 |
function wpsc__( $text, $domain = 'default' ) { |
| 17 |
return __( $text, $domain ); // phpcs:ignore |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Translate common strings required across addons but not used within the core product |
| 22 |
* |
| 23 |
* @param string $key - unique key for the string. |
| 24 |
* @return string |
| 25 |
*/ |
| 26 |
function wpsc_translate_common_strings( $key ) { |
| 27 |
|
| 28 |
switch ( $key ) { |
| 29 |
|
| 30 |
case 'activate-license': |
| 31 |
return __( 'Please activate your license!', 'supportcandy' ); |
| 32 |
|
| 33 |
case 'license-activated': |
| 34 |
return __( 'Your license key activated!', 'supportcandy' ); |
| 35 |
|
| 36 |
case 'license-expires': |
| 37 |
/* translators: %s: date */ |
| 38 |
return __( 'Your license key expires on %s', 'supportcandy' ); |
| 39 |
|
| 40 |
case 'license-expired': |
| 41 |
/* translators: %s: date */ |
| 42 |
return __( 'Your license key expired on %s', 'supportcandy' ); |
| 43 |
|
| 44 |
case 'view-details': |
| 45 |
return __( 'View Details', 'supportcandy' ); |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Returns EDD licence activation errors |
| 51 |
* |
| 52 |
* @param string $error - error code. |
| 53 |
* @return string |
| 54 |
*/ |
| 55 |
function wpsc_licence_errors( $error ) { |
| 56 |
|
| 57 |
$error_message = ''; |
| 58 |
switch ( $error ) { |
| 59 |
|
| 60 |
case 'missing': |
| 61 |
return esc_attr( 'License does not exist' ); |
| 62 |
|
| 63 |
case 'missing_url': |
| 64 |
return esc_attr( 'URL not provided' ); |
| 65 |
|
| 66 |
case 'license_not_activable': |
| 67 |
return esc_attr( 'Attempting to activate a parent license of bundle' ); |
| 68 |
|
| 69 |
case 'disabled': |
| 70 |
return esc_attr( 'License key revoked' ); |
| 71 |
|
| 72 |
case 'no_activations_left': |
| 73 |
return esc_attr( 'No activations left' ); |
| 74 |
|
| 75 |
case 'expired': |
| 76 |
return esc_attr( 'License has expired' ); |
| 77 |
|
| 78 |
case 'key_mismatch': |
| 79 |
return esc_attr( 'License is not valid for this product' ); |
| 80 |
|
| 81 |
case 'invalid_item_id': |
| 82 |
return esc_attr( 'Invalid Item ID' ); |
| 83 |
|
| 84 |
case 'item_name_mismatch': |
| 85 |
return esc_attr( 'License is not valid for this product' ); |
| 86 |
|
| 87 |
case 'site_inactive': |
| 88 |
return esc_attr( 'Site is not active for this license' ); |
| 89 |
|
| 90 |
case 'invalid': |
| 91 |
return esc_attr( 'License key does not match' ); |
| 92 |
} |
| 93 |
return ''; |
| 94 |
} |
| 95 |
|