class-wordpress-popular-posts-activator.php
8 years ago
class-wordpress-popular-posts-deactivator.php
8 years ago
class-wordpress-popular-posts-helper.php
8 years ago
class-wordpress-popular-posts-i18n.php
8 years ago
class-wordpress-popular-posts-image.php
8 years ago
class-wordpress-popular-posts-loader.php
8 years ago
class-wordpress-popular-posts-output.php
8 years ago
class-wordpress-popular-posts-query.php
8 years ago
class-wordpress-popular-posts-rest-controller.php
8 years ago
class-wordpress-popular-posts-settings.php
8 years ago
class-wordpress-popular-posts-template.php
8 years ago
class-wordpress-popular-posts-translate.php
8 years ago
class-wordpress-popular-posts-widget.php
8 years ago
class-wordpress-popular-posts.php
8 years ago
widget-form.php
8 years ago
class-wordpress-popular-posts-translate.php
142 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Obtains translation data from objects. |
| 4 | * |
| 5 | * @link http://cabrerahector.com |
| 6 | * @since 4.0.0 |
| 7 | * |
| 8 | * @package WordPressPopularPosts |
| 9 | * @subpackage WordPressPopularPosts/includes |
| 10 | */ |
| 11 | /** |
| 12 | * Obtains translation data from objects. |
| 13 | * |
| 14 | * @since 4.0.0 |
| 15 | * @package WordPressPopularPosts |
| 16 | * @subpackage WordPressPopularPosts/includes |
| 17 | * @author Hector Cabrera <me@cabrerahector.com> |
| 18 | */ |
| 19 | |
| 20 | class WPP_translate { |
| 21 | |
| 22 | /** |
| 23 | * Class instance. |
| 24 | * |
| 25 | * @since 4.0.0 |
| 26 | * @access private |
| 27 | * @var object|WPP_translate |
| 28 | */ |
| 29 | private static $instance; |
| 30 | |
| 31 | /** |
| 32 | * Default language code. |
| 33 | * |
| 34 | * @since 4.0.0 |
| 35 | * @access private |
| 36 | * @var string |
| 37 | */ |
| 38 | private $default_language; |
| 39 | |
| 40 | /** |
| 41 | * Current language code. |
| 42 | * |
| 43 | * @since 4.0.0 |
| 44 | * @access private |
| 45 | * @var string |
| 46 | */ |
| 47 | private $current_language; |
| 48 | |
| 49 | /** |
| 50 | * Initialize the collections used to maintain the actions and filters. |
| 51 | * |
| 52 | * @since 4.0.0 |
| 53 | * @access private |
| 54 | */ |
| 55 | private function __construct() { |
| 56 | |
| 57 | $this->default_language = apply_filters( 'wpml_default_language', NULL ); |
| 58 | $this->current_language = apply_filters( 'wpml_current_language', NULL ); |
| 59 | |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Get an instance of this class. |
| 64 | * |
| 65 | * @since 4.0.0 |
| 66 | * @return object|\WPP_translate |
| 67 | */ |
| 68 | public static function get_instance() { |
| 69 | |
| 70 | if ( is_null(self::$instance) ) { |
| 71 | self::$instance = new WPP_translate(); |
| 72 | } |
| 73 | |
| 74 | return self::$instance; |
| 75 | |
| 76 | } |
| 77 | |
| 78 | /* |
| 79 | * Retrieves the code of the default language. |
| 80 | * |
| 81 | * @since 4.0.0 |
| 82 | * @return string|null |
| 83 | */ |
| 84 | public function get_default_language() { |
| 85 | return $this->default_language; |
| 86 | } |
| 87 | |
| 88 | /* |
| 89 | * Retrieves the code of the currently active language. |
| 90 | * |
| 91 | * @since 4.0.0 |
| 92 | * @return string|null |
| 93 | */ |
| 94 | public function get_current_language() { |
| 95 | return $this->current_language; |
| 96 | } |
| 97 | |
| 98 | /* |
| 99 | * Retrieves the ID of an object. |
| 100 | * |
| 101 | * @since 4.0.0 |
| 102 | * @param integer $object_id |
| 103 | * @param string $object_type |
| 104 | * @param boolean $return_original_if_missing |
| 105 | * @param string $lang_code |
| 106 | * @return integer |
| 107 | */ |
| 108 | public function get_object_id( $object_id = null, $object_type = 'post', $return_original_if_missing = true, $lang_code = null ) { |
| 109 | |
| 110 | return apply_filters( |
| 111 | 'wpml_object_id', |
| 112 | $object_id, |
| 113 | $object_type, |
| 114 | $return_original_if_missing, |
| 115 | $lang_code |
| 116 | ); |
| 117 | |
| 118 | } |
| 119 | |
| 120 | /* |
| 121 | * Retrieves the language code of an object. |
| 122 | * |
| 123 | * @since 4.0.0 |
| 124 | * @param integer $object_id |
| 125 | * @param string $object_type |
| 126 | * @return string|null |
| 127 | */ |
| 128 | public function get_object_lang_code( $object_id = null, $object_type = 'post' ) { |
| 129 | |
| 130 | return apply_filters( |
| 131 | 'wpml_element_language_code', |
| 132 | null, |
| 133 | array( |
| 134 | 'element_id' => $object_id, |
| 135 | 'element_type' => $object_type |
| 136 | ) |
| 137 | ); |
| 138 | |
| 139 | } |
| 140 | |
| 141 | } // End WPP_translate class |
| 142 |