PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.2.0
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.2.0
4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 4.2.1 All 138 releases
learnpress / inc / class-lp-strings.php

class-lp-strings.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.2.0, at inc/class-lp-strings.php

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