| @@ -8,42 +8,12 @@ | ||
| 8 | 8 | * |
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | class PLL_Static_Pages { |
| 12 | - /** | |
| 13 | - * Id of the page on front. | |
| 14 | - * | |
| 15 | - * @var int | |
| 16 | - */ | |
| 17 | - public $page_on_front; | |
| 12 | + public $model, $options; | |
| 13 | + public $page_on_front, $page_for_posts; | |
| 18 | 14 | |
| 19 | 15 | /** |
| 20 | - * Id of the page for posts. | |
| 21 | - * | |
| 22 | - * @var int | |
| 23 | - */ | |
| 24 | - public $page_for_posts; | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * Stores the plugin options. | |
| 28 | - * | |
| 29 | - * @var array | |
| 30 | - */ | |
| 31 | - protected $options; | |
| 32 | - | |
| 33 | - /** | |
| 34 | - * @var PLL_Model | |
| 35 | - */ | |
| 36 | - protected $model; | |
| 37 | - | |
| 38 | - /** | |
| 39 | - * Current language. | |
| 40 | - * | |
| 41 | - * @var PLL_Language | |
| 42 | - */ | |
| 43 | - protected $curlang; | |
| 44 | - | |
| 45 | - /** | |
| 46 | 16 | * Constructor: setups filters and actions |
| 47 | 17 | * |
| 48 | 18 | * @since 1.8 |
| 49 | 19 | * |
| @@ -74,10 +44,8 @@ | ||
| 74 | 44 | /** |
| 75 | 45 | * Stores the page on front and page for posts ids |
| 76 | 46 | * |
| 77 | 47 | * @since 1.8 |
| 78 | - * | |
| 79 | - * @return void | |
| 80 | 48 | */ |
| 81 | 49 | public function init() { |
| 82 | 50 | if ( 'page' == get_option( 'show_on_front' ) ) { |
| 83 | 51 | $this->page_on_front = get_option( 'page_on_front' ); |
| @@ -106,15 +74,14 @@ | ||
| 106 | 74 | return $link; |
| 107 | 75 | } |
| 108 | 76 | |
| 109 | 77 | /** |
| 110 | - * Adds page_on_front and page_for_posts properties to the language objects. | |
| 78 | + * Adds page_on_front and page_for_posts properties to the language objects | |
| 111 | 79 | * |
| 112 | 80 | * @since 1.8 |
| 113 | 81 | * |
| 114 | - * @param PLL_Language[] $languages The list of languages. | |
| 115 | - * @param PLL_Model $model The instance of PLL_Model. | |
| 116 | - * @return PLL_Language[] | |
| 82 | + * @param array $languages | |
| 83 | + * @param object $model | |
| 117 | 84 | */ |
| 118 | 85 | public static function pll_languages_list( $languages, $model ) { |
| 119 | 86 | if ( 'page' === get_option( 'show_on_front' ) ) { |
| 120 | 87 | foreach ( $languages as $k => $language ) { |
| @@ -135,9 +102,9 @@ | ||
| 135 | 102 | * @return int |
| 136 | 103 | */ |
| 137 | 104 | public function translate_page_for_posts( $v ) { |
| 138 | 105 | // Don't attempt to translate in a 'switch_blog' action as there is a risk to call this function while initializing the languages cache |
| 139 | - return isset( $this->curlang->page_for_posts ) && ( $this->curlang->page_for_posts ) && ! doing_action( 'switch_blog' ) ? $this->curlang->page_for_posts : $v; | |
| 106 | + return isset( $this->curlang->page_for_posts ) && ! doing_action( 'switch_blog' ) ? $this->curlang->page_for_posts : $v; | |
| 140 | 107 | } |
| 141 | 108 | |
| 142 | 109 | /** |
| 143 | 110 | * Fixes the oembed for the translated static front page |
| @@ -146,9 +113,8 @@ | ||
| 146 | 113 | * @since 2.6 |
| 147 | 114 | * |
| 148 | 115 | * @param int $post_id The post ID. |
| 149 | 116 | * @param string $url The requested URL. |
| 150 | - * @return int | |
| 151 | 117 | */ |
| 152 | 118 | public function oembed_request_post_id( $post_id, $url ) { |
| 153 | 119 | foreach ( $this->model->get_languages_list() as $lang ) { |
| 154 | 120 | if ( trailingslashit( $url ) === trailingslashit( $lang->home_url ) ) { |