| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * Base class to manage the static front page and the page for posts |
| 8 | 5 | * |
| @@ -8,42 +5,12 @@ | ||
| 8 | 5 | * |
| 9 | 6 | * @since 1.8 |
| 10 | 7 | */ |
| 11 | 8 | class PLL_Static_Pages { |
| 12 | - /** | |
| 13 | - * Id of the page on front. | |
| 14 | - * | |
| 15 | - * @var int | |
| 16 | - */ | |
| 17 | - public $page_on_front; | |
| 9 | + public $model, $options; | |
| 10 | + public $page_on_front, $page_for_posts; | |
| 18 | 11 | |
| 19 | 12 | /** |
| 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 | 13 | * Constructor: setups filters and actions |
| 47 | 14 | * |
| 48 | 15 | * @since 1.8 |
| 49 | 16 | * |
| @@ -74,10 +41,8 @@ | ||
| 74 | 41 | /** |
| 75 | 42 | * Stores the page on front and page for posts ids |
| 76 | 43 | * |
| 77 | 44 | * @since 1.8 |
| 78 | - * | |
| 79 | - * @return void | |
| 80 | 45 | */ |
| 81 | 46 | public function init() { |
| 82 | 47 | if ( 'page' == get_option( 'show_on_front' ) ) { |
| 83 | 48 | $this->page_on_front = get_option( 'page_on_front' ); |
| @@ -106,15 +71,14 @@ | ||
| 106 | 71 | return $link; |
| 107 | 72 | } |
| 108 | 73 | |
| 109 | 74 | /** |
| 110 | - * Adds page_on_front and page_for_posts properties to the language objects. | |
| 75 | + * Adds page_on_front and page_for_posts properties to the language objects | |
| 111 | 76 | * |
| 112 | 77 | * @since 1.8 |
| 113 | 78 | * |
| 114 | - * @param PLL_Language[] $languages The list of languages. | |
| 115 | - * @param PLL_Model $model The instance of PLL_Model. | |
| 116 | - * @return PLL_Language[] | |
| 79 | + * @param array $languages | |
| 80 | + * @param object $model | |
| 117 | 81 | */ |
| 118 | 82 | public static function pll_languages_list( $languages, $model ) { |
| 119 | 83 | if ( 'page' === get_option( 'show_on_front' ) ) { |
| 120 | 84 | foreach ( $languages as $k => $language ) { |
| @@ -135,9 +99,9 @@ | ||
| 135 | 99 | * @return int |
| 136 | 100 | */ |
| 137 | 101 | public function translate_page_for_posts( $v ) { |
| 138 | 102 | // 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; | |
| 103 | + return isset( $this->curlang->page_for_posts ) && ! doing_action( 'switch_blog' ) ? $this->curlang->page_for_posts : $v; | |
| 140 | 104 | } |
| 141 | 105 | |
| 142 | 106 | /** |
| 143 | 107 | * Fixes the oembed for the translated static front page |
| @@ -146,9 +110,8 @@ | ||
| 146 | 110 | * @since 2.6 |
| 147 | 111 | * |
| 148 | 112 | * @param int $post_id The post ID. |
| 149 | 113 | * @param string $url The requested URL. |
| 150 | - * @return int | |
| 151 | 114 | */ |
| 152 | 115 | public function oembed_request_post_id( $post_id, $url ) { |
| 153 | 116 | foreach ( $this->model->get_languages_list() as $lang ) { |
| 154 | 117 | if ( trailingslashit( $url ) === trailingslashit( $lang->home_url ) ) { |