| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class LP_Strings |
| 4 |
* @deprecated |
| 5 |
*/ |
| 6 |
class LP_Strings { |
| 7 |
|
| 8 |
/** |
| 9 |
* @since 3.3.0 |
| 10 |
* |
| 11 |
* @var array |
| 12 |
*/ |
| 13 |
protected static $strings = array(); |
| 14 |
|
| 15 |
/** |
| 16 |
* @since 3.2.0 |
| 17 |
* @TODO should remove - tungnx, no important |
| 18 |
*/ |
| 19 |
public static function load() { |
| 20 |
$strings = apply_filters( |
| 21 |
'learnpress/strings', |
| 22 |
array( |
| 23 |
'you_have_completed_quiz' => __( 'You\'ve already completed the quiz.', 'learnpress' ), |
| 24 |
'confirm-redo-quiz' => __( 'Do you want to redo the quiz "%s"?', 'learnpress' ), |
| 25 |
'confirm-complete-quiz' => __( 'Do you want to complete the quiz "%s"?', 'learnpress' ), |
| 26 |
'confirm-complete-lesson' => __( 'Do you want to complete the lesson "%s"?', 'learnpress' ), |
| 27 |
'confirm-finish-course' => __( 'Do you want to finish the course "%s"?', 'learnpress' ), |
| 28 |
'confirm-retake-course' => __( 'Do you want to retake the course "%s"?', 'learnpress' ), |
| 29 |
) |
| 30 |
); |
| 31 |
|
| 32 |
self::$strings = $strings; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* @param string $str |
| 37 |
* @param string $context |
| 38 |
* @param string $args |
| 39 |
* |
| 40 |
* @return mixed|string |
| 41 |
*/ |
| 42 |
public static function get( $str, $context = '', $args = '' ) { |
| 43 |
$string = $str; |
| 44 |
|
| 45 |
$strings = self::$strings; |
| 46 |
|
| 47 |
if ( $strings ) { |
| 48 |
if ( array_key_exists( $str, $strings ) ) { |
| 49 |
$texts = $strings[ $str ]; |
| 50 |
|
| 51 |
if ( is_string( $texts ) ) { |
| 52 |
$string = $texts; |
| 53 |
} elseif ( $context && array_key_exists( $context, $texts ) ) { |
| 54 |
$string = $texts[ $context ]; |
| 55 |
} else { |
| 56 |
$string = reset( $texts ); |
| 57 |
} |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
return is_array( $args ) ? vsprintf( $string, $args ) : $string; |
| 62 |
} |
| 63 |
|
| 64 |
public static function esc_attr( $str, $context = '', $args = '' ) { |
| 65 |
return esc_attr( self::get( $str, $context, $args ) ); |
| 66 |
} |
| 67 |
|
| 68 |
public static function esc_attr_e( $str, $context = '', $args = '' ) { |
| 69 |
echo esc_attr( self::get( $str, $context, $args ) ); |
| 70 |
} |
| 71 |
|
| 72 |
public static function output( $str, $context = '', $args = '' ) { |
| 73 |
|
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
LP_Strings::load(); |
| 78 |
|